Protect shard admin auth SQL queries

This commit is contained in:
kaetemi 2014-09-06 01:40:37 +02:00
parent 4a186cc233
commit 0e76ed6386
2 changed files with 9 additions and 5 deletions

View file

@ -8,7 +8,7 @@
{ {
global $db; global $db;
$sql = "UPDATE ". NELDB_USER_TABLE ." SET user_logged_count=user_logged_count+1,user_logged_last=". time() ." WHERE user_id=". $user_id; $sql = "UPDATE ". NELDB_USER_TABLE ." SET user_logged_count=user_logged_count+1,user_logged_last=". time() ." WHERE user_id=". (int)$user_id;
$db->sql_query($sql); $db->sql_query($sql);
} }
@ -18,7 +18,7 @@
$data = null; $data = null;
$sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_id=". $nelid; $sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_id=". (int)$nelid;
if ($result = $db->sql_query($sql)) if ($result = $db->sql_query($sql))
{ {
if ($db->sql_numrows($result)) if ($db->sql_numrows($result))
@ -34,7 +34,7 @@
{ {
global $db; global $db;
$sql = "SELECT user_name FROM ". NELDB_USER_TABLE ." WHERE user_id=". $group_id; $sql = "SELECT user_name FROM ". NELDB_USER_TABLE ." WHERE user_id=". (int)$group_id;
if ($result = $db->sql_query($sql)) if ($result = $db->sql_query($sql))
{ {
if ($db->sql_numrows($result)) if ($db->sql_numrows($result))
@ -53,7 +53,7 @@
$data = null; $data = null;
$user = trim($user); $user = $db->sql_escape_string(trim($user));
$passwd = md5(trim($passwd)); $passwd = md5(trim($passwd));
$sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_name='". $user ."' AND user_password='". $passwd ."' AND user_active=1 AND group_active=1"; $sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_name='". $user ."' AND user_password='". $passwd ."' AND user_active=1 AND group_active=1";
@ -120,4 +120,4 @@
unset($NELTOOL['SESSION_VARS'][$name]); unset($NELTOOL['SESSION_VARS'][$name]);
} }
?> ?>

View file

@ -251,6 +251,10 @@ class sql_db
return false; return false;
} }
} }
function sql_escape_string($str)
{
return mysqli_real_escape_string($this->db_connect_id, $str);
}
function sql_error($query_id = 0) function sql_error($query_id = 0)
{ {
$result["message"] = mysqli_error($this->db_connect_id); $result["message"] = mysqli_error($this->db_connect_id);