aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcassio <cassiopc@gmail.com>2015-09-09 13:22:56 +0000
committercassio <cassiopc@gmail.com>2015-09-09 13:22:56 +0000
commit0275d9a10cafd301239dc09d1400973a5e44ed98 (patch)
treeafdb635d0c9127e5bb973331fd9a6affc805f492 /src
parent64143437a294aa4e0e94d60e79ba3ac677c40e5b (diff)
downloadboca-0275d9a10cafd301239dc09d1400973a5e44ed98.tar.gz
boca-0275d9a10cafd301239dc09d1400973a5e44ed98.zip
minor fixes
Diffstat (limited to 'src')
-rw-r--r--src/frun.php20
-rwxr-xr-xsrc/globals.php10
-rw-r--r--src/team/run.php25
3 files changed, 32 insertions, 23 deletions
diff --git a/src/frun.php b/src/frun.php
index e272b85..bdd1a02 100644
--- a/src/frun.php
+++ b/src/frun.php
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////////////
-// Last modified 06/sep/2013 by cassio@ime.usp.br
+// Last modified 09/sep/2015 by cassio@ime.usp.br
function DBDropRunTable() {
$c = DBConnect();
@@ -705,7 +705,7 @@ function DBNewRun($param,$c=null) {
DBExec($c, "rollback work", "DBNewRun(rollback-site)");
LOGError("Unable to find a unique site/contest in the database. SQL=(" . $sql . ")");
MSGError("Unable to find a unique site/contest in the database.");
- exit;
+ return false;
}
$a = DBRow($r,0);
$n = $a["nextrun"] + 1;
@@ -735,13 +735,13 @@ function DBNewRun($param,$c=null) {
DBExec($c, "rollback work", "DBNewRun(rollback-started)");
LOGError("Tried to submit a run but the contest is not started. SQL=(" . $sql . ")");
MSGError("The contest is not started yet!");
- return false;
+ return 0;
} }
if (!$b["siterunning"]) {
DBExec($c, "rollback work", "DBNewRun(rollback-over)");
LOGError("Tried to submit a run but the contest is over. SQL=(" . $sql . ")");
MSGError("The contest is over!");
- return false;
+ return 0;
}
} else {
$dif = $rundatediff;
@@ -759,14 +759,14 @@ function DBNewRun($param,$c=null) {
DBExec($c, "rollback work", "DBNewRun(rollback-import stdout)");
LOGError("Unable to create a large object for file stdout (run=$runnumber,site=$site,contest=$contest).");
MSGError("problem importing stdout to database. Contact an admin now!");
- exit;
+ return false;
}
} else {
if($autostdout != '') {
DBExec($c, "rollback work", "DBNewRun(rollback-import stderr)");
LOGError("Unable to create a large object for file stdout that is not BASE64 (run=$runnumber,site=$site,contest=$contest).");
MSGError("problem importing stdout (not BASE64) to database. Contact an admin now!");
- exit;
+ return false;
}
$oid1 = 'NULL';
}
@@ -778,14 +778,14 @@ function DBNewRun($param,$c=null) {
DBExec($c, "rollback work", "DBNewRun(rollback-import stderr)");
LOGError("Unable to create a large object for file stderr (run=$runnumber,site=$site,contest=$contest).");
MSGError("problem importing stderr to database. Contact an admin now!");
- exit;
+ return false;
}
} else {
if($autostderr != '') {
DBExec($c, "rollback work", "DBNewRun(rollback-import stderr)");
LOGError("Unable to create a large object for file stderr that is not BASE64 (run=$runnumber,site=$site,contest=$contest).");
MSGError("problem importing stderr (not BASE64) to database. Contact an admin now!");
- exit;
+ return false;
}
$oid2 = 'NULL';
}
@@ -797,7 +797,7 @@ function DBNewRun($param,$c=null) {
DBExec($c, "rollback work", "DBNewRun(rollback-import)");
LOGError("DBNewRun: Unable to create a large object for file $filepath.");
MSGError("problem importing file $filepath to database. Contact an admin now!");
- exit;
+ return false;
}
} else {
$filepath = base64_decode(substr($filepath,7));
@@ -805,7 +805,7 @@ function DBNewRun($param,$c=null) {
DBExec($c, "rollback work", "DBNewRun(rollback-import)");
LOGError("DBNewRun: Unable to create a large object for file.");
MSGError("problem importing file to database. Contact an admin now!");
- exit;
+ return false;
}
}
DBExec($c, "INSERT INTO runtable (contestnumber, runsitenumber, runnumber, usernumber, rundate, " .
diff --git a/src/globals.php b/src/globals.php
index 0f034ce..5ece1e8 100755
--- a/src/globals.php
+++ b/src/globals.php
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////////////
-// Last modified 15/aug/2014 by cassio@ime.usp.br
+// Last modified 07/sep/2015 by cassio@ime.usp.br
require_once('db.php');
define("dbcompat_1_4_1",true);
@@ -205,13 +205,13 @@ function IntrusionNotify($where) {
// verifica se a sessao esta aberta e ok
function ValidSession() {
if (!isset($_SESSION["usertable"])) return(FALSE);
+ if ($_SESSION["usertable"]["usersession"] == session_id() || $_SESSION["usertable"]["usersessionextra"] == session_id()) return(TRUE);
+ if(($_SESSION["usertable"]["userip"] == getIP() && $_SESSION["usertable"]["usermultilogin"] == 't') ||
+ $_SESSION["usertable"]["usertype"] == 'score') return(TRUE);
$_SESSION["usertable"] = DBUserInfo($_SESSION["usertable"]["contestnumber"],
$_SESSION["usertable"]["usersitenumber"],
$_SESSION["usertable"]["usernumber"]);
- if ($_SESSION["usertable"]["usersession"] != session_id() &&
- ($_SESSION["usertable"]["usermultilogin"] != 't' ||
- $_SESSION["usertable"]["usertype"] != 'score'))
- return(FALSE);
+ if ($_SESSION["usertable"]["usersession"] != session_id() && $_SESSION["usertable"]["usersessionextra"] != session_id()) return(FALSE);
return(TRUE);
}
// grava erro no arquivo de log
diff --git a/src/team/run.php b/src/team/run.php
index 846fef0..c7add5d 100644
--- a/src/team/run.php
+++ b/src/team/run.php
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////////////
-// Last modified 08/aug/2015 by cassio@ime.usp.br
+// Last modified 09/sep/2015 by cassio@ime.usp.br
require('header.php');
$ds = DIRECTORY_SEPARATOR;
if($ds=="") $ds = "/";
@@ -136,7 +136,7 @@ if (isset($_POST["problem"]) && isset($_POST["language"]) &&
} else {
$pastval = 0;
}
- $verify = $pastcode . '-' .$_SESSION["usertable"]["contestnumber"].'-'.$_SESSION["usertable"]["usersitenumber"].'-'.$_SESSION["usertable"]["usernumber"];
+ $verify = $pastcode . '-' .$name . '-'. $_SESSION["usertable"]["contestnumber"].'-'.$_SESSION["usertable"]["usersitenumber"].'-'.$_SESSION["usertable"]["usernumber"];
$fcname = $_SESSION["locr"] . $ds . "private" . $ds . 'laterun-submitted-' . $_SESSION["usertable"]["contestnumber"].'-'.
$_SESSION["usertable"]["usersitenumber"].'-'.$_SESSION["usertable"]["usernumber"].'.txt';
$codes = @file($fcname,FILE_IGNORE_NEW_LINES);
@@ -149,9 +149,15 @@ if (isset($_POST["problem"]) && isset($_POST["language"]) &&
$dif = $b["currenttime"];
$param['rundatediff']=$dif - $pastval;
}
- if(DBNewRun ($param) == 2)
+ $retv = DBNewRun ($param);
+ if($retv == 2) {
@file_put_contents($fcname, $verify . "\n", FILE_APPEND | LOCK_EX);
- echo "\nRESULT: RUN SUBMITTED SUCCESSFULLY ($pastval)";
+ echo "\nRESULT: RUN SUBMITTED SUCCESSFULLY ($pastval)";
+ } else {
+ if($retv == 0) echo "\nRESULT: CONTEST NOT RUNNING";
+ else
+ echo "\nRESULT: UNKNOWN PROBLEM";
+ }
}
exit;
}
@@ -159,8 +165,11 @@ if (isset($_POST["problem"]) && isset($_POST["language"]) &&
if(isset($_POST['name']) && $_POST['name'] != '') {
if($retv == 2)
echo "\nRESULT: RUN SUBMITTED SUCCESSFULLY";
- else
- echo "\nRESULT: UNKNOWN PROBLEM";
+ else {
+ if($retv == 0) echo "\nRESULT: CONTEST NOT RUNNING";
+ else
+ echo "\nRESULT: UNKNOWN PROBLEM";
+ }
exit;
}
$_SESSION['forceredo']=true;
@@ -234,7 +243,7 @@ $linesubmission = @file_get_contents($_SESSION["locr"] . $ds . "private" . $ds .
if(trim($linesubmission) == '1') {
$strtmp .= "<br><br><center><b>To submit a program, use the command-line tool:</b>\n<br>".
"<pre>boca-submit-run USER PASSWORD PROBLEM LANGUAGE FILE</pre><br>".
- "where USER is your username, PASSWORD is your password, FILE is your submission file,<br>".
+ "where USER is your username, PASSWORD is your password, <br>".
"PROBLEM is one of { ";
$prob = DBGetProblems($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usertype"]=='judge');
@@ -244,7 +253,7 @@ $strtmp .= "} and<br>LANGUAGE is one of { ";
$lang = DBGetLanguages($_SESSION["usertable"]["contestnumber"]);
for ($i=0;$i<count($lang);$i++)
$strtmp .= $lang[$i]["name"] . " ";
-$strtmp .= "}<br><br>\n";
+$strtmp .= "}<br>FILE is your submission file<br><br>\n";
} else {
$strtmp .= "<br><br><center><b>To submit a program, just fill in the following fields:</b></center>\n".