mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
test return value from db_query before assuming it is valid
make the sql query form consistent in usage by cleaning up instances where db_query's result was not inspected before attempting to fetch row data from the handle Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
d38f3460e5
commit
0898f1447a
7 changed files with 135 additions and 68 deletions
|
@ -21,14 +21,26 @@ if ($atype == "Trusted User" OR $atype == "Developer") {
|
|||
|
||||
if (!empty($_POST['user'])) {
|
||||
$qcheck = "SELECT * FROM Users WHERE Username = '" . mysql_real_escape_string($_POST['user']) . "'";
|
||||
$check = mysql_num_rows(db_query($qcheck, $dbh));
|
||||
$result = db_query($qcheck, $dbh);
|
||||
if ($result) {
|
||||
$check = mysql_num_rows($result);
|
||||
}
|
||||
else {
|
||||
$check = 0;
|
||||
}
|
||||
|
||||
if ($check == 0) {
|
||||
$error.= __("Username does not exist.");
|
||||
} else {
|
||||
$qcheck = "SELECT * FROM TU_VoteInfo WHERE User = '" . mysql_real_escape_string($_POST['user']) . "'";
|
||||
$qcheck.= " AND End > UNIX_TIMESTAMP()";
|
||||
$check = mysql_num_rows(db_query($qcheck, $dbh));
|
||||
$result = db_query($qcheck, $dbh);
|
||||
if ($result) {
|
||||
$check = mysql_num_rows($result);
|
||||
}
|
||||
else {
|
||||
$check = 0;
|
||||
}
|
||||
|
||||
if ($check != 0) {
|
||||
$error.= __("%s already has proposal running for them.", htmlentities($_POST['user']));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue