diff options
| author | cassiopc <cassiopc@gmail.com> | 2017-10-20 15:31:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-20 15:31:03 +0000 |
| commit | 006561454093d44a789463d531cfbc640c519867 (patch) | |
| tree | 60529befdd5b7ccefbdee7486e402a4217603d10 /src/admin/report | |
| parent | 1bfadfa27cb0b94d2063054ccf78f8bfedd62f59 (diff) | |
| parent | bf6f929ce5119aa5669696b6596ce9435962422a (diff) | |
| download | boca-006561454093d44a789463d531cfbc640c519867.tar.gz boca-006561454093d44a789463d531cfbc640c519867.zip | |
Merge pull request #9 from cjoa/s4ris
S4RiS
Diffstat (limited to 'src/admin/report')
| -rw-r--r-- | src/admin/report/s4ris.php | 162 | ||||
| -rw-r--r-- | src/admin/report/webcast.php | 4 |
2 files changed, 164 insertions, 2 deletions
diff --git a/src/admin/report/s4ris.php b/src/admin/report/s4ris.php new file mode 100644 index 0000000..7c2908b --- /dev/null +++ b/src/admin/report/s4ris.php @@ -0,0 +1,162 @@ +<?php +//////////////////////////////////////////////////////////////////////////////// +//BOCA Online Contest Administrator +// Copyright (C) 2003-2012 by BOCA System (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 updated 18/oct/2017 + +require('header.php'); + +$contest = $_SESSION["usertable"]["contestnumber"]; +$site = $_SESSION["usertable"]["usersitenumber"]; + +$ct = DBContestInfo($contest); +if(($st = DBSiteInfo($contest, $site)) == null) + ForceLoad("../index.php"); + +//if(isset($_GET['full']) && $_GET['full'] > 0) + $freezeTime = $st['siteduration']; +//else +// $freezeTime = $st['sitelastmilescore']; + + +$obj = array( + 'contestName' => $ct['contestname'], + 'freezeTimeMinutesFromStart' => $ct['contestlastmilescore']/60 +); + +$c = DBConnect(); + +$r = DBExec($c, + 'SELECT problemname FROM problemtable' . + ' WHERE contestnumber = ' . $contest . + ' AND problemnumber > 0'); + +$problems = array(); +$numProblems = DBnlines($r); +for ($i = 0; $i < $numProblems; $i++) { + $a = DBRow($r, $i); + $problems[$i] = $a['problemname']; +} + +$obj['problemLetters'] = $problems; + + +$r = DBExec($c, + 'SELECT * FROM usertable' . + ' WHERE contestnumber = ' . $contest . + ' AND userenabled = \'t\' AND usersitenumber = ' . $site . + ' AND usertype = \'team\''); + +$contestans = array(); +$numTeams = DBnlines($r); +for ($i = 0; $i < $numTeams; $i++) { + $a = cleanuserdesc(DBRow($r, $i)); + //$teamID = $a['username']; + + if (isset($a['usershortname'])) + $teamName = $a['usershortname']; + else + $teamName = $a['userfullname']; + + if (isset($a['usershortinstitution'])) { + $teamName .= ' @ ' . $a['usershortinstitution']; + if (isset($a['userflag'])) { + $teamName .= '.' . $a['userflag']; + } + } + + $contestants[$i] = $teamName; +} + +$obj['contestants'] = $contestants; + +$run = DBAllRunsInSites($contest, $site, 'report'); +$numRuns = count($run); + +$runs = array(); +for ($i = 0; $i < $numRuns; $i++) { + $runTime = dateconvminutes($run[$i]['timestamp']); + if ($runTime > $freezeTime) { + continue; + } + + $u = DBUserInfo($contest, $site, $run[$i]['user']); + + if(isset($u['usershortname'])) + $runTeam = $u['usershortname']; + else + $runTeam = $u['userfullname']; + + if(isset($u['usershortinstitution'])) { + $runTeam .= ' @ ' . $u['usershortinstitution']; + if (isset($u['userflag'])) { + $runTeam .= '.' . $u['userflag']; + } + } + + $runProblem = $run[$i]['problem']; + + $runs[$i] = array( + 'contestant' => $runTeam, + 'problemLetter' => $runProblem, + 'timeMinutesFromStart' => $runTime, + 'success' => $run[$i]['yes'] == 't' + ); +} + +$obj['runs'] = $runs; + + + +$ds = DIRECTORY_SEPARATOR; +if($ds=="") $ds = "/"; + +if(isset($_SESSION['locr'])) { + $s4risparentdir = $_SESSION['locr'] . $ds. 'private'; + $s4risdir = $s4risparentdir .$ds. 's4ris'; +} else { + $s4risparentdir = $locr . $ds . 'private'; + $s4risdir = $s4risparentdir . $ds . 's4ris'; +} +cleardir($s4risdir); +@mkdir($s4risdir); +if(is_writable($s4risdir)) { + file_put_contents($s4risdir . $ds . 'results.json', json_encode($obj, JSON_PRETTY_PRINT)); + if(@create_zip($s4risparentdir,array('s4ris'), $s4risdir . ".tmp") != 1) { + LOGError("Cannot create score s4risdir.tmp file"); + MSGError("Cannot create score s4risdir.tmp file"); + } else { + $cf = globalconf(); + file_put_contents($s4risdir . ".tmp", encryptData(file_get_contents($s4risdir . ".tmp"), $cf["key"],false)); + @rename($s4risdir . ".tmp",$s4risdir . '.zip'); + } + echo "<br><br><br><center>"; + echo "<a href=\"$locr/filedownload.php?". + filedownload(-1,$s4risdir . '.zip') . "\">CLICK TO DOWNLOAD</a>"; + echo "</center>"; +} else { + LOGError('Error creating the folder for the ZIP file: '. $s4risdir); + MSGError('Error creating the folder for the ZIP file: '.$s4risdir); + ForceLoad("../index.php"); +} +echo "<br><br><br>\n"; +echo "<br><br><br>\n"; +echo "<br><br><br>\n"; +echo "<br><br><br>\n"; +echo "<br><br><br>\n"; +echo "<br><br><br>\n"; +?> +<?php include("$locr/footnote.php"); ?> diff --git a/src/admin/report/webcast.php b/src/admin/report/webcast.php index 5a595fc..0f85317 100644 --- a/src/admin/report/webcast.php +++ b/src/admin/report/webcast.php @@ -46,7 +46,7 @@ $r = DBExec($c, ' AND problemnumber > 0'); $numProblems = DBnlines($r); $r = DBExec($c, - 'SELECT username, userfullname FROM usertable' . + 'SELECT * FROM usertable' . ' WHERE contestnumber = ' . $contest . ' AND userenabled = \'t\' AND usersitenumber = ' . $site . ' AND usertype = \'team\''); @@ -57,7 +57,7 @@ $contestfile = $contestfile . $numProblems . "\n"; for ($i = 0; $i < $numTeams; $i++) { - $a = DBRow($r, $i); + $a = cleanuserdesc(DBRow($r, $i)); $teamID = $a['username']; if(isset($a['usershortname'])) $teamName = $a['usershortname']; |