From df5138660d51ee5c3585d155163ae29402c5f881 Mon Sep 17 00:00:00 2001 From: Sveneld Date: Sun, 26 Nov 2023 20:02:17 +0100 Subject: [PATCH] sql injection fix --- admin.php | 9 ++++++++- command.php | 15 ++++++++++++--- index.php | 14 ++++++++++---- scan.php | 14 +++++++++++--- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/admin.php b/admin.php index 4a2fb31c..d89ab19e 100644 --- a/admin.php +++ b/admin.php @@ -7,7 +7,14 @@ $db->connect(); checksession(); -if (getprivileges($_COOKIE["loguserid"])<=0) exit(_('You need admin privileges to access this page.')); + +if (isset($_COOKIE["loguserid"])) { + $userid = $db->conn->real_escape_string(trim($_COOKIE["loguserid"])); +} else { + $userid = 0; +} + +if (getprivileges($userid)<=0) exit(_('You need admin privileges to access this page.')); ?> diff --git a/command.php b/command.php index ded4283e..2423bbfc 100644 --- a/command.php +++ b/command.php @@ -6,9 +6,18 @@ $db=new Database($dbserver,$dbuser,$dbpassword,$dbname); $db->connect(); -if (isset($_COOKIE["loguserid"])) $userid=$_COOKIE["loguserid"]; -else $userid=0; -if (isset($_COOKIE["logsession"])) $session=$_COOKIE["logsession"]; +if (isset($_COOKIE["loguserid"])) { + $userid = $db->conn->real_escape_string(trim($_COOKIE["loguserid"])); +} else { + $userid = 0; +} + +if (isset($_COOKIE["logsession"])) { + $session = $db->conn->real_escape_string(trim($_COOKIE["logsession"])); +} else { + $session = ''; +} + $action=""; if (isset($_GET["action"])) $action=trim($_GET["action"]); diff --git a/index.php b/index.php index ef7d79cf..2bfbc449 100644 --- a/index.php +++ b/index.php @@ -43,10 +43,16 @@ var mapzoom=; var standselected=0; conn->real_escape_string(trim($_COOKIE["loguserid"])); +} else { + $userid = 0; +} + if (isloggedin()) { echo 'var loggedin=1;',"\n"; - echo 'var priv=',getprivileges($_COOKIE["loguserid"]),";\n"; + echo 'var priv=',getprivileges($userid),";\n"; } else { @@ -81,11 +87,11 @@