aboutsummaryrefslogtreecommitdiff
path: root/src/team
diff options
context:
space:
mode:
authorcassio <cassiopc@gmail.com>2013-07-02 05:46:45 +0000
committercassio <cassiopc@gmail.com>2013-07-02 05:46:45 +0000
commitbe2491b093b1f0ca430bede679ecbb670041e483 (patch)
treefe2da63d1811cb93e4352a43a113ace37b9f6017 /src/team
parenta9aa438ea0558eb0044cf1e54a9190ddb41b65e5 (diff)
downloadboca-be2491b093b1f0ca430bede679ecbb670041e483.tar.gz
boca-be2491b093b1f0ca430bede679ecbb670041e483.zip
restructuring of boca's git
Diffstat (limited to 'src/team')
-rw-r--r--src/team/clar.php113
-rw-r--r--src/team/files.php123
-rw-r--r--src/team/getfile.php47
-rw-r--r--src/team/header.php143
-rw-r--r--src/team/index.php22
-rw-r--r--src/team/option.php21
-rw-r--r--src/team/problem.php58
-rw-r--r--src/team/run.php196
-rw-r--r--src/team/score.php21
-rw-r--r--src/team/task.php121
10 files changed, 865 insertions, 0 deletions
diff --git a/src/team/clar.php b/src/team/clar.php
new file mode 100644
index 0000000..a1e3972
--- /dev/null
+++ b/src/team/clar.php
@@ -0,0 +1,113 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require('header.php');
+
+if (isset($_POST["message"]) && isset($_POST["problem"]) && isset($_POST["Submit"]) && is_numeric($_POST["problem"])) {
+ if ($_POST["confirmation"] == "confirm") {
+ $param['contest']=$_SESSION["usertable"]["contestnumber"];
+ $param['site']=$_SESSION["usertable"]["usersitenumber"];
+ $param['user']= $_SESSION["usertable"]["usernumber"];
+ $param['problem'] = htmlspecialchars($_POST["problem"]);
+ $param['question'] = htmlspecialchars($_POST["message"]);
+ DBNewClar($param);
+ }
+ ForceLoad("clar.php");
+}
+$_SESSION["popuptime"] = time();
+?>
+<br>
+<table width="100%" border=1>
+ <tr>
+<!-- <td><b>Clar #</b></td>-->
+ <td><b>Time</b></td>
+ <td><b>Problem</b></td>
+<!-- <td><b>Status</b></td>-->
+ <td><b>Question</b></td>
+ <td><b>Answer</b></td>
+ </tr>
+<?php
+if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null)
+ ForceLoad("../index.php");
+$clar = DBUserClars($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"]);
+for ($i=0; $i<count($clar); $i++) {
+ echo " <tr>\n";
+// echo " <td nowrap>" . $clar[$i]["number"] . "</td>\n";
+ echo " <td nowrap>" . dateconvminutes($clar[$i]["timestamp"]) . "</td>\n";
+ echo " <td nowrap>" . $clar[$i]["problem"] . "</td>\n";
+// echo " <td nowrap>" . $clar[$i]["status"] . "</td>\n";
+ if ($clar[$i]["question"] == "") $clar[$i]["question"] = "&nbsp;";
+ echo " <td>";
+// echo "<pre>" . $clar[$i]["question"] . "</pre>";
+ echo " <textarea name=\"m$i\" cols=\"60\" rows=\"8\" readonly>".$clar[$i]["question"]."</textarea>\n";
+ echo "</td>\n";
+
+ if (trim($clar[$i]["answer"]) == "") $clar[$i]["answer"] = "Not answered yet";
+ echo " <td>";
+// echo " <pre>" . $clar[$i]["answer"] . "</pre>";
+ echo " <textarea name=\"a$i\" cols=\"60\" rows=\"8\" readonly>".$clar[$i]["answer"]."</textarea>\n";
+ echo "</td>\n";
+ echo " </tr>\n";
+}
+echo "</table>";
+if (count($clar) == 0) echo "<br><center><b><font color=\"#ff0000\">NO CLARIFICATIONS AVAILABLE</font></b></center>";
+
+?>
+
+<br><br><center><b>To submit a clarification, just fill in the following fields</b></center>
+<form name="form1" method="post" action="clar.php">
+ <input type=hidden name="confirmation" value="noconfirm" />
+ <center>
+ <table border="0">
+ <tr>
+ <td width="13%" align=right>Problem:</td>
+ <td width="87%">
+ <select name="problem" onclick="Arquivo()">
+<?php
+$prob = DBGetAllProblems($_SESSION["usertable"]["contestnumber"]);
+for ($i=0;$i<count($prob);$i++)
+ echo "<option value=\"" . $prob[$i]["number"] . "\">" . $prob[$i]["problem"] . "</option>\n";
+?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="13%" align=right>Clarification:</td>
+ <td width="87%">
+ <textarea name="message" cols="60" rows="8" maxlength="2000"></textarea>
+ </td>
+ </tr>
+ </table>
+ </center>
+ <script language="javascript">
+ function conf() {
+ if (confirm("Confirm clarification?")) {
+ document.form1.confirmation.value='confirm';
+ }
+ }
+ </script>
+ <center>
+ <input type="submit" name="Submit" value="Send" onClick="conf()">
+ <input type="reset" name="Submit2" value="Clear">
+ </center>
+</form>
+
+</body>
+</html>
diff --git a/src/team/files.php b/src/team/files.php
new file mode 100644
index 0000000..42fba28
--- /dev/null
+++ b/src/team/files.php
@@ -0,0 +1,123 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require 'header.php';
+
+if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null)
+ ForceLoad("../index.php");
+if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null)
+ ForceLoad("../index.php");
+
+if (isset($_GET["delete"]) && is_numeric($_GET["delete"])) {
+ DBBkpDelete($_GET["delete"],$_SESSION["usertable"]["usersitenumber"],$_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usernumber"]);
+ ForceLoad("files.php");
+}
+
+if (isset($_FILES["sourcefile"]) && isset($_POST["Submit"]) && $_FILES["sourcefile"]["name"]!="") {
+ if ($_POST["confirmation"] == "confirm") {
+ $type=myhtmlspecialchars($_FILES["sourcefile"]["type"]);
+ $size=myhtmlspecialchars($_FILES["sourcefile"]["size"]);
+ $name=myhtmlspecialchars($_FILES["sourcefile"]["name"]);
+ $temp=myhtmlspecialchars($_FILES["sourcefile"]["tmp_name"]);
+
+ if ($size > $ct["contestmaxfilesize"]) {
+ LOGLevel("User {$_SESSION["usertable"]["username"]} tried to submit file " .
+ "$name with $size bytes ({$ct["contestmaxfilesize"]} max allowed).", 1);
+ MSGError("File size exceeds the limit allowed.");
+ ForceLoad("run.php");
+ }
+ if (!is_uploaded_file($temp) || strlen($name)>100) {
+ IntrusionNotify("file upload problem.");
+ ForceLoad("../index.php");
+ }
+
+ DBNewBkp ($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"],
+ $name,
+ $temp, $size);
+ }
+ ForceLoad("files.php");
+}
+?>
+<br>
+<table width="100%" border=1>
+ <tr>
+ <td><b>Bkp #</b></td>
+ <td><b>Time</b></td>
+ <td><b>File</b></td>
+ </tr>
+<?php
+$run = DBUserBkps($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"]);
+
+for ($i=0; $i<count($run); $i++) {
+ echo " <tr>\n";
+ echo " <td nowrap><a href=\"javascript:conf2('files.php?delete=" . $run[$i]["number"] .
+ "')\">" . $run[$i]["number"] . "</a></td>\n";
+
+ echo " <td nowrap>" . dateconvsimple($run[$i]["timestamp"]) . "</td>\n";
+ echo "<td nowrap><a href=\"../filedownload.php?". filedownload($run[$i]["oid"],$run[$i]["filename"]) . "\">";
+ echo $run[$i]["filename"] . "</a>";
+
+ echo "</td>\n";
+ echo " </tr>\n";
+
+}
+echo "</table>";
+if (count($run) == 0) echo "<br><center><b><font color=\"#ff0000\">NO BACKUPS AVAILABLE</font></b></center>";
+
+?>
+
+<br><br><center><b>To erase a file, click on its number. To download a file, click on its name.
+To submit a new backup file, just fill in the following fields:</b></center>
+<form name="form1" enctype="multipart/form-data" method="post" action="files.php">
+<!--<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $ct["contestmaxfilesize"] ?>">-->
+ <input type=hidden name="confirmation" value="noconfirm" />
+ <center>
+ <table border="0">
+ <tr>
+ <td width="35%" align=right>File (size restrictions apply):</td>
+ <td width="65%">
+ <input type="file" name="sourcefile" size="40">
+ </td>
+ </tr>
+ </table>
+ </center>
+ <script language="javascript">
+ function conf() {
+ if (confirm("Confirm submission?")) {
+ document.form1.confirmation.value='confirm';
+ }
+ }
+ function conf2(url) {
+ if (confirm("Confirm?")) {
+ document.location=url;
+ } else {
+ document.location='files.php';
+ }
+ }
+ </script>
+ <center>
+ <input type="submit" name="Submit" value="Send" onClick="conf()">
+ </center>
+</form>
+
+</body>
+</html>
diff --git a/src/team/getfile.php b/src/team/getfile.php
new file mode 100644
index 0000000..8c594d0
--- /dev/null
+++ b/src/team/getfile.php
@@ -0,0 +1,47 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require 'header.php';
+
+if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null)
+ ForceLoad("../index.php");
+if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null)
+ ForceLoad("../index.php");
+
+$fn = tempnam("/tmp","bkp-");
+$fout = fopen($fn,"wb");
+echo $_POST;
+echo $_POST['data'];
+fwrite($fout,base64_decode($_POST['data']));
+fclose($fout);
+$size=filesize($fn);
+$name=$_POST['name'];
+ if ($size > $ct["contestmaxfilesize"] || strlen($name)>100 || strlen($name)<1) {
+ LOGLevel("User {$_SESSION["usertable"]["username"]} tried to submit file " .
+ ":${name}: with $size bytes.", 1);
+ MSGError("File size exceeds the limit allowed or invalid name.");
+ } else
+
+ DBNewBkp ($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"],
+ $name,
+ $fn, $size);
+@unlink($fn);
+ForceLoad("../index.php");
+?>
diff --git a/src/team/header.php b/src/team/header.php
new file mode 100644
index 0000000..ec7352a
--- /dev/null
+++ b/src/team/header.php
@@ -0,0 +1,143 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 21/jul/2012 by cassio@ime.usp.br
+ob_start();
+header ("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
+header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+header ("Cache-Control: no-cache, must-revalidate");
+header ("Pragma: no-cache");
+header ("Content-Type: text/html; charset=utf-8");
+session_start();
+ob_end_flush();
+require_once('../version.php');
+
+require_once("../globals.php");
+require_once("../db.php");
+$runteam='run.php';
+
+echo "<html><head><title>Team's Page</title>\n";
+echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
+echo "<link rel=stylesheet href=\"../Css.php\" type=\"text/css\">\n";
+
+//echo "<meta http-equiv=\"refresh\" content=\"60\" />";
+
+if(!ValidSession()) {
+ InvalidSession("team/index.php");
+ ForceLoad("../index.php");
+}
+if($_SESSION["usertable"]["usertype"] != "team") {
+ IntrusionNotify("team/index.php");
+ ForceLoad("../index.php");
+}
+
+echo "<script language=\"javascript\" src=\"../reload.js\"></script>\n";
+echo "</head><body onload=\"Comecar()\" onunload=\"Parar()\"><table border=1 width=\"100%\">\n";
+echo "<tr><td nowrap bgcolor=\"#aaaaee\" align=center>";
+echo "<img src=\"../images/smallballoontransp.png\" alt=\"\">";
+echo "<font color=\"#000000\">BOCA</font>";
+echo "</td><td bgcolor=\"#aaaaee\" width=\"99%\">\n";
+echo "Username: " . $_SESSION["usertable"]["userfullname"] . " (site=".$_SESSION["usertable"]["usersitenumber"].")\n";
+
+$ds = DIRECTORY_SEPARATOR;
+if($ds=="") $ds = "/";
+
+$runtmp = $_SESSION["locr"] . $ds . "private" . $ds . "runtmp" . $ds . "run-contest" . $_SESSION["usertable"]["contestnumber"] .
+ "-site". $_SESSION["usertable"]["usersitenumber"] . "-user" . $_SESSION["usertable"]["usernumber"] . ".php";
+$doslow=true;
+if(file_exists($runtmp)) {
+ if(($strtmp = file_get_contents($runtmp,FALSE,NULL,-1,1000000)) !== FALSE) {
+ $postab=strpos($strtmp,"\t");
+ $conf=globalconf();
+ $strcolors = decryptData(substr($strtmp,$postab+1,strpos($strtmp,"\n")-$postab-1),$conf['key'],'');
+ $doslow=false;
+ $rn=explode("\t",$strcolors);
+ $n=count($rn);
+ for($i=1; $i<$n-1;$i++) {
+ echo "<img alt=\"".$rn[$i]."\" width=\"10\" ".
+ "src=\"" . balloonurl($rn[$i+1]) . "\" />\n";
+ $i++;
+ }
+ } else unset($strtmp);
+}
+if($doslow) {
+ $run = DBUserRunsYES($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"]);
+ $n=count($run);
+ for($i=0; $i<$n;$i++) {
+ echo "<img alt=\"".$run[$i]["colorname"]."\" width=\"10\" ".
+ "src=\"" . balloonurl($run[$i]["color"]) . "\" />\n";
+ }
+}
+
+if(!isset($_SESSION["popuptime"]) || $_SESSION["popuptime"] < time()-120) {
+ $_SESSION["popuptime"] = time();
+
+ if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) != null) {
+ $clar = DBUserClars($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"]);
+ for ($i=0; $i<count($clar); $i++) {
+ if ($clar[$i]["anstime"]>$_SESSION["usertable"]["userlastlogin"]-$st["sitestartdate"] &&
+ $clar[$i]["anstime"] < $st['siteduration'] &&
+ trim($clar[$i]["answer"])!='' && !isset($_SESSION["popups"]['clar' . $i . '-' . $clar[$i]["anstime"]])) {
+ $_SESSION["popups"]['clar' . $i . '-' . $clar[$i]["anstime"]] = "(Clar for problem ".$clar[$i]["problem"]." answered)\n";
+ }
+ }
+ $run = DBUserRuns($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"]);
+ for ($i=0; $i<count($run); $i++) {
+ if ($run[$i]["anstime"]>$_SESSION["usertable"]["userlastlogin"]-$st["sitestartdate"] &&
+ $run[$i]["anstime"] < $st['sitelastmileanswer'] &&
+ $run[$i]["ansfake"]!="t" && !isset($_SESSION["popups"]['run' . $i . '-' . $run[$i]["anstime"]])) {
+ $_SESSION["popups"]['run' . $i . '-' . $run[$i]["anstime"]] = "(Run ".$run[$i]["number"]." result: ".$run[$i]["answer"] . ')\n';
+ }
+ }
+ }
+
+ $str = '';
+ if(isset($_SESSION["popups"])) {
+ foreach($_SESSION["popups"] as $key => $value) {
+ if($value != '') {
+ $str .= $value;
+ $_SESSION["popups"][$key] = '';
+ }
+ }
+ if($str != '') {
+ MSGError('YOU GOT NEWS:\n' . $str . '\n');
+ }
+ }
+}
+
+list($clockstr,$clocktype)=siteclock();
+echo "</td><td bgcolor=\"#aaaaee\" align=center nowrap>&nbsp;".$clockstr."&nbsp;</td></tr>\n";
+echo "</table>\n";
+echo "<table border=0 width=\"100%\" align=center>\n";
+echo " <tr>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=problem.php>Problems</a></td>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=run.php>Runs</a></td>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=score.php>Score</a></td>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=clar.php>Clarifications</a></td>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=task.php>Tasks</a></td>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=files.php>Backups</a></td>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=option.php>Options</a></td>\n";
+echo " <td align=center width=\"12%\"><a class=menu style=\"font-weight:bold\" href=../index.php>Logout</a></td>\n";
+echo " </tr>\n";
+echo "</table>\n";
+?>
diff --git a/src/team/index.php b/src/team/index.php
new file mode 100644
index 0000000..ec74ce9
--- /dev/null
+++ b/src/team/index.php
@@ -0,0 +1,22 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require('header.php');
+?>
+</body>
+</html>
diff --git a/src/team/option.php b/src/team/option.php
new file mode 100644
index 0000000..81e5879
--- /dev/null
+++ b/src/team/option.php
@@ -0,0 +1,21 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require('header.php');
+require('../optionlower.php');
+?>
diff --git a/src/team/problem.php b/src/team/problem.php
new file mode 100644
index 0000000..2627990
--- /dev/null
+++ b/src/team/problem.php
@@ -0,0 +1,58 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require('header.php');
+
+if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null)
+ ForceLoad("../index.php");
+
+?>
+<br>
+<table width="100%" border=1>
+ <tr>
+ <td><b>Name</b></td>
+ <td><b>Basename</b></td>
+ <td><b>Fullname</b></td>
+ <td><b>Descfile</b></td>
+ </tr>
+<?php
+$prob = DBGetProblems($_SESSION["usertable"]["contestnumber"]);
+for ($i=0; $i<count($prob); $i++) {
+ echo " <tr>\n";
+// echo " <td nowrap>" . $prob[$i]["number"] . "</td>\n";
+ echo " <td nowrap>" . $prob[$i]["problem"];
+ if($prob[$i]["color"] != "")
+ echo " <img alt=\"".$prob[$i]["colorname"]."\" width=\"20\" ".
+ "src=\"" . balloonurl($prob[$i]["color"]) ."\" />\n";
+ echo "</td>\n";
+ echo " <td nowrap>" . $prob[$i]["basefilename"] . "&nbsp;</td>\n";
+ echo " <td nowrap>" . $prob[$i]["fullname"] . "&nbsp;</td>\n";
+ if (isset($prob[$i]["descoid"]) && $prob[$i]["descoid"] != null && isset($prob[$i]["descfilename"])) {
+ echo " <td nowrap><a href=\"../filedownload.php?" . filedownload($prob[$i]["descoid"], $prob[$i]["descfilename"]) .
+ "\">" . basename($prob[$i]["descfilename"]) . "</td>\n";
+ }
+ else
+ echo " <td nowrap>no description file available</td>\n";
+ echo " </tr>\n";
+}
+echo "</table>";
+if (count($prob) == 0) echo "<br><center><b><font color=\"#ff0000\">NO PROBLEMS AVAILABLE YET</font></b></center>";
+
+?>
+</body>
+</html>
diff --git a/src/team/run.php b/src/team/run.php
new file mode 100644
index 0000000..270a672
--- /dev/null
+++ b/src/team/run.php
@@ -0,0 +1,196 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 21/jul/2012 by cassio@ime.usp.br
+require('header.php');
+
+if (isset($_FILES["sourcefile"]) && isset($_POST["problem"]) && isset($_POST["Submit"]) && isset($_POST["language"]) &&
+ is_numeric($_POST["problem"]) && is_numeric($_POST["language"]) && $_FILES["sourcefile"]["name"]!="") {
+ if ($_POST["confirmation"] == "confirm") {
+ if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null)
+ ForceLoad("../index.php");
+
+ $prob = myhtmlspecialchars($_POST["problem"]);
+ $lang = myhtmlspecialchars($_POST["language"]);
+
+ $type=myhtmlspecialchars($_FILES["sourcefile"]["type"]);
+ $size=myhtmlspecialchars($_FILES["sourcefile"]["size"]);
+ $name=myhtmlspecialchars($_FILES["sourcefile"]["name"]);
+ $temp=myhtmlspecialchars($_FILES["sourcefile"]["tmp_name"]);
+
+ if ($size > $ct["contestmaxfilesize"]) {
+ LOGLevel("User {$_SESSION["usertable"]["username"]} tried to submit file " .
+ "$name with $size bytes ({$ct["contestmaxfilesize"]} max allowed).", 1);
+ MSGError("File size exceeds the limit allowed.");
+ ForceLoad($runteam);
+ }
+ if(strpos($name,' ') === true || strpos($temp,' ') === true) {
+ MSGError("File name cannot contain spaces.");
+ ForceLoad($runteam);
+ }
+ if (!is_uploaded_file($temp) || strlen($name)>100) {
+ IntrusionNotify("file upload problem.");
+ ForceLoad("../index.php");
+ }
+
+
+ $ac=array('contest','site','user','problem','lang','filename','filepath');
+ $ac1=array('runnumber','rundate','rundatediff','rundatediffans','runanswer','runstatus','runjudge','runjudgesite',
+ 'runjudge1','runjudgesite1','runanswer1','runjudge2','runjudgesite2','runanswer2',
+ 'autoip','autobegindate','autoenddate','autoanswer','autostdout','autostderr','updatetime');
+ $param = array('contest'=>$_SESSION["usertable"]["contestnumber"],
+ 'site'=>$_SESSION["usertable"]["usersitenumber"],
+ 'user'=> $_SESSION["usertable"]["usernumber"],
+ 'problem'=>$prob,
+ 'lang'=>$lang,
+ 'filename'=>$name,
+ 'filepath'=>$temp);
+ DBNewRun ($param);
+ $_SESSION['forceredo']=true;
+ }
+ ForceLoad($runteam);
+}
+
+$ds = DIRECTORY_SEPARATOR;
+if($ds=="") $ds = "/";
+
+$runtmp = $_SESSION["locr"] . $ds . "private" . $ds . "runtmp" . $ds . "run-contest" . $_SESSION["usertable"]["contestnumber"] .
+ "-site". $_SESSION["usertable"]["usersitenumber"] . "-user" . $_SESSION["usertable"]["usernumber"] . ".php";
+$redo = TRUE;
+if(!isset($_SESSION['forceredo']) || $_SESSION['forceredo']==false) {
+ $actualdelay = 30;
+ if(file_exists($runtmp)) {
+ if(isset($strtmp) || (($strtmp = file_get_contents($runtmp,FALSE,NULL,-1,1000000)) !== FALSE)) {
+ list($d) = sscanf($strtmp,"%*s %d");
+ if($d > time() - $actualdelay) {
+ $conf=globalconf();
+ $strtmp = decryptData(substr($strtmp,strpos($strtmp,"\n")+1),$conf["key"],'runtmp');
+ if($strtmp !== false)
+ $redo = FALSE;
+ }
+ }
+ }
+}
+if($redo) {
+ $_SESSION["popuptime"] = time();
+ $_SESSION['forceredo']=false;
+ if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null)
+ ForceLoad("../index.php");
+ $strtmp="<br>\n<table width=\"100%\" border=1>\n <tr>\n <td><b>Run #</b></td>\n<td><b>Time</b></td>\n".
+ " <td><b>Problem</b></td>\n <td><b>Language</b></td>\n <td><b>Answer</b></td>\n <td><b>File</b></td>\n </tr>\n";
+ $strcolors = "0";
+ $run = DBUserRuns($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"]);
+ for ($i=0; $i<count($run); $i++) {
+ $strtmp .= " <tr>\n";
+ $strtmp .= " <td nowrap>" . $run[$i]["number"] . "</td>\n";
+ $strtmp .= " <td nowrap>" . dateconvminutes($run[$i]["timestamp"]) . "</td>\n";
+ $strtmp .= " <td nowrap>" . $run[$i]["problem"] . "</td>\n";
+ $strtmp .= " <td nowrap>" . $run[$i]["language"] . "</td>\n";
+// $strtmp .= " <td nowrap>" . $run[$i]["status"] . "</td>\n";
+ if (trim($run[$i]["answer"]) == "") {
+ $run[$i]["answer"] = "Not answered yet";
+ $strtmp .= " <td>Not answered yet";
+ }
+ else {
+ $strtmp .= " <td>" . $run[$i]["answer"];
+ if($run[$i]['yes']=='t') {
+ $strtmp .= " <img alt=\"".$run[$i]["colorname"]."\" width=\"15\" ".
+ "src=\"" . balloonurl($run[$i]["color"]) ."\" />";
+ $strcolors .= "\t" . $run[$i]["colorname"] . "\t" . $run[$i]["color"];
+ }
+ }
+ $strtmp .= "</td>\n";
+ $strtmp .= "<td nowrap><a href=\"../filedownload.php?" . filedownload($run[$i]["oid"],$run[$i]["filename"]) . "\">";
+ $strtmp .= $run[$i]["filename"] . "</a>";
+
+ $strtmp .= "</td>\n";
+
+ $strtmp .= " </tr>\n";
+ }
+$strtmp .= "</table>";
+if (count($run) == 0) $strtmp .= "<br><center><b><font color=\"#ff0000\">NO RUNS AVAILABLE</font></b></center>";
+
+$strtmp .= "<br><br><center><b>To submit a program, just fill in the following fields:</b></center>\n".
+"<form name=\"form1\" enctype=\"multipart/form-data\" method=\"post\" action=\"". $runteam ."\">\n".
+" <input type=hidden name=\"confirmation\" value=\"noconfirm\" />\n".
+" <center>\n".
+" <table border=\"0\">\n".
+" <tr> \n".
+" <td width=\"25%\" align=right>Problem:</td>\n".
+" <td width=\"75%\">\n".
+" <select name=\"problem\" onclick=\"Arquivo()\">\n";
+$prob = DBGetProblems($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usertype"]=='judge');
+$strtmp .= "<option value=\"-1\"></option>\n";
+for ($i=0;$i<count($prob);$i++)
+ $strtmp .= "<option value=\"" . $prob[$i]["number"] . "\">" . $prob[$i]["problem"] . "</option>\n";
+$strtmp .= " </select>\n".
+" </td>\n".
+" </tr>\n".
+" <tr> \n".
+" <td width=\"25%\" align=right>Language:</td>\n".
+" <td width=\"75%\"> \n".
+" <select name=\"language\" onclick=\"Arquivo()\">\n";
+$lang = DBGetLanguages($_SESSION["usertable"]["contestnumber"]);
+$strtmp .= "<option value=\"-1\"></option>\n";
+for ($i=0;$i<count($lang);$i++)
+ $strtmp .= "<option value=\"" . $lang[$i]["number"] . "\">" . $lang[$i]["name"] . "</option>\n";
+$strtmp .= " </select>\n".
+" </td>\n".
+" </tr>\n".
+" <tr> \n".
+" <td width=\"25%\" align=right>Source code:</td>\n".
+" <td width=\"75%\">\n".
+" <input type=\"file\" name=\"sourcefile\" size=\"40\" onclick=\"Arquivo()\">\n".
+" </td>\n".
+" </tr>\n".
+" </table>\n".
+" </center>\n".
+" <script language=\"javascript\">\n".
+" function conf() {\n".
+" if (document.form1.problem.value != '-1' && document.form1.language.value != '-1') {\n".
+" if (confirm(\"Confirm submission?\")) {\n".
+" document.form1.confirmation.value='confirm';\n".
+" }\n".
+" } else {\n".
+" alert('Invalid problem and/or language');\n".
+" }\n".
+" }\n".
+" </script>\n".
+" <center>\n".
+" <input type=\"submit\" name=\"Submit\" value=\"Send\" onClick=\"conf()\">\n".
+" <input type=\"reset\" name=\"Submit2\" value=\"Clear\">\n".
+" </center>\n".
+"</form>\n";
+ $conf=globalconf();
+ $strtmp1 = "<!-- " . time() . " --> <?php exit; ?>\t" . encryptData($strcolors,$conf["key"],false) . "\n" . encryptData($strtmp,$conf["key"],false);
+ $randnum = session_id() . "_" . rand();
+ if(file_put_contents($runtmp . "_" . $randnum, $strtmp1,LOCK_EX)===FALSE) {
+ if(!isset($_SESSION['writewarn'])) {
+ LOGError("Cannot write to the user-run cache file $runtmp -- performance might be compromised");
+ $_SESSION['writewarn']=true;
+ }
+ }
+ @rename($runtmp . "_" . $randnum, $runtmp);
+}
+echo $strtmp;
+?>
+
+
+</body>
+</html>
diff --git a/src/team/score.php b/src/team/score.php
new file mode 100644
index 0000000..ef9675d
--- /dev/null
+++ b/src/team/score.php
@@ -0,0 +1,21 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require('header.php');
+require('../scorelower.php');
+?>
diff --git a/src/team/task.php b/src/team/task.php
new file mode 100644
index 0000000..b23605c
--- /dev/null
+++ b/src/team/task.php
@@ -0,0 +1,121 @@
+<?php
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 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 05/aug/2012 by cassio@ime.usp.br
+require('header.php');
+
+if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null)
+ ForceLoad("../index.php");
+if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null)
+ ForceLoad("../index.php");
+
+if (isset($_POST["Submit"]) && $_POST["Submit"]=="S.O.S.") {
+ if ($_POST["confirmation"] == "confirm") {
+ $param['contest']=$_SESSION["usertable"]["contestnumber"];
+ $param['site']=$_SESSION["usertable"]["usersitenumber"];
+ $param['user']=$_SESSION["usertable"]["usernumber"];
+ $param['desc']= "Staff assistance";
+ DBNewTask ($param);
+ }
+ ForceLoad("task.php");
+}
+if (isset($_FILES["filename"]) && isset($_POST["Submit"]) && $_FILES["filename"]["name"]!="") {
+ if ($_POST["confirmation"] == "confirm") {
+ $type=myhtmlspecialchars($_FILES["filename"]["type"]);
+ $size=myhtmlspecialchars($_FILES["filename"]["size"]);
+ $name=myhtmlspecialchars($_FILES["filename"]["name"]);
+ $temp=myhtmlspecialchars($_FILES["filename"]["tmp_name"]);
+
+ if ($size > $ct["contestmaxfilesize"]) {
+ LOGLevel("User {$_SESSION["usertable"]["username"]} tried to print file " .
+ "$name with $size bytes ({$ct["contestmaxfilesize"]} max allowed).", 1);
+ MSGError("File size exceeds the limit allowed.");
+ ForceLoad("task.php");
+ }
+ if (!is_uploaded_file($temp)) {
+ IntrusionNotify("Printing file upload problem");
+ ForceLoad("../index.php");
+ }
+ $param['contest']=$_SESSION["usertable"]["contestnumber"];
+ $param['site']=$_SESSION["usertable"]["usersitenumber"];
+ $param['user']=$_SESSION["usertable"]["usernumber"];
+ $param['desc']= "File to print";
+ $param['filename']=$name;
+ $param['filepath']=$temp;
+ DBNewTask ($param);
+ }
+ ForceLoad("task.php");
+}
+?>
+<br>
+<table width="100%" border=1>
+ <tr>
+ <td><b>Task #</b></td>
+ <td><b>Time</b></td>
+ <td><b>Description</b></td>
+ <td><b>File</b></td>
+ <td><b>Status</b></td>
+ </tr>
+<?php
+$task = DBUserTasks($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"]);
+for ($i=0; $i<count($task); $i++) {
+ echo " <tr>\n";
+ echo " <td nowrap>" . $task[$i]["number"] . "</td>\n";
+ echo " <td nowrap>" . dateconvminutes($task[$i]["timestamp"]) . "</td>\n";
+ echo " <td nowrap>" . $task[$i]["description"] . "</td>\n";
+ echo " <td nowrap>" . $task[$i]["filename"] . "&nbsp;</td>\n";
+ echo " <td nowrap>" . $task[$i]["status"] . "</td>\n";
+}
+echo "</table>";
+if (count($task) == 0) echo "<br><center><b><font color=\"#ff0000\">NO TASKS FOUND</font></b></center>";
+?>
+
+<br><br><center><b>To submit a file for printing, just fill in the following field:</b></center>
+<form name="form1" enctype="multipart/form-data" method="post" action="task.php">
+<!--<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $ct["contestmaxfilesize"] ?>">-->
+ <input type=hidden name="confirmation" value="noconfirm" />
+ <center>
+ <table border="0">
+ <tr>
+ <td width="25%" align=right>File name:</td>
+ <td width="75%">
+ <input type="file" name="filename" size="40" onclick="Arquivo()">
+ </td>
+ </tr>
+ </table>
+ </center>
+ <script language="javascript">
+ function conf() {
+ if (confirm("Confirm?")) {
+ document.form1.confirmation.value='confirm';
+ }
+ }
+ </script>
+ <center>
+ <input type="submit" name="Submit" value="Send" onClick="conf()">
+ <input type="reset" name="Submit2" value="Clear">
+ </center>
+<br><br><center><b>If you needed staff assistance, please click
+on the button above and wait.</b><br>
+ <input type="submit" name="Submit" value="S.O.S." onClick="conf()">
+ </center>
+</form>
+
+</body>
+</html>