aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCassio de Campos <cassiopc@gmail.com>2017-11-01 18:31:47 +0000
committerCassio de Campos <cassiopc@gmail.com>2017-11-01 18:31:47 +0000
commit02d57eeeb41da2bdf5ca28d419815997a4df67ea (patch)
treec4d259049c62d66bc77d05d2a27e02ba35d006c5 /src
parent92bda853b5c48a8cd4a4bdaa6272ad21c51cfe86 (diff)
downloadboca-02d57eeeb41da2bdf5ca28d419815997a4df67ea.tar.gz
boca-02d57eeeb41da2bdf5ca28d419815997a4df67ea.zip
small fixes
Diffstat (limited to 'src')
-rw-r--r--src/db.php7
-rw-r--r--src/fcontest.php26
2 files changed, 19 insertions, 14 deletions
diff --git a/src/db.php b/src/db.php
index 5948186..c43816f 100644
--- a/src/db.php
+++ b/src/db.php
@@ -245,9 +245,10 @@ function DBGetRow ($sql,$i,$c=null,$txt='') {
if (DBnlines($r) < $i+1) return null;
$a = DBRow ($r, $i);
if (!$a) {
- LOGError("Unable to get row $i from a query ($txt). SQL=(" . $sql . ")");
- MSGError("Unable to get row from query ($txt).");
- exit;
+ DBClose($c);
+ LOGError("Unable to get row $i from a query ($txt). SQL=(" . $sql . ")");
+ MSGError("Unable to get row from query ($txt).");
+ exit;
}
return $a;
}
diff --git a/src/fcontest.php b/src/fcontest.php
index 9787e1c..f441c33 100644
--- a/src/fcontest.php
+++ b/src/fcontest.php
@@ -316,7 +316,7 @@ function DBDeleteUser($contest, $site, $user) {
DBExec($c, "lock table usertable");
$sql = "select * from usertable where usernumber=$user and usersitenumber=$site and " .
"contestnumber=$contest for update";
- $a = DBGetRow ($sql, 0);
+ $a = DBGetRow ($sql, 0, $c);
if ($a != null) {
$sql = "update usertable set userenabled='f', userlastlogin=NULL, usersessionextra='', usersession='', updatetime=".time(). " where usernumber=$user and usersitenumber=$site and " .
"contestnumber=$contest";
@@ -1304,9 +1304,10 @@ function DBNewUser($param, $c=null) {
$r = DBExec($c, "select * from sitetable where sitenumber=$site and contestnumber=$contest", "DBNewUser(get site)");
$n = DBnlines ($r);
if($n == 0) {
- DBExec ($c, "rollback work","DBNewUser(no-site)");
- MSGError("DBNewUser param error: site $site does not exist");
- return false;
+ if($cw)
+ DBExec ($c, "rollback work","DBNewUser(no-site)");
+ MSGError("DBNewUser param error: site $site does not exist");
+ return false;
}
if($pass != myhash("") && $type != "admin" && $changepass != "t") $pass='!'.$pass;
$r = DBExec($c, "select * from usertable where username='$username' and usernumber!=$user and ".
@@ -1320,11 +1321,12 @@ function DBNewUser($param, $c=null) {
if ($a == null) {
$ret=2;
$sql = "select * from sitetable where sitenumber=$site and contestnumber=$contest";
- $aa = DBGetRow ($sql, 0);
+ $aa = DBGetRow ($sql, 0, $c);
if($aa==null) {
+ if($cw)
DBExec ($c, "rollback work");
- MSGError("Site $site does not exist");
- return false;
+ MSGError("Site $site does not exist");
+ return false;
}
$sql = "insert into usertable (contestnumber, usersitenumber, usernumber, username, usericpcid, userfullname, " .
"userdesc, usertype, userenabled, usermultilogin, userpassword, userpermitip) values " .
@@ -1356,11 +1358,13 @@ function DBNewUser($param, $c=null) {
}
}
} else {
- DBExec ($c, "rollback work");
- LOGLevel ("Update problem for user $user (site=$site,contest=$contest) (maybe username already in use).",1);
- MSGError ("Update problem for user $user, site $site (maybe username already in use).");
- return false;
+ if($cw)
+ DBExec ($c, "rollback work");
+ LOGLevel ("Update problem for user $user (site=$site,contest=$contest) (maybe username already in use).",1);
+ MSGError ("Update problem for user $user, site $site (maybe username already in use).");
+ return false;
}
+ if($cw) DBExec($c, "commit work");
return $ret;
}