function put_print_form() { global $DB, $pagename; $langs = $DB->q('KEYTABLE SELECT langid AS ARRAYKEY, name, extensions FROM language WHERE allow_submit = 1 ORDER BY name'); echo "<script type=\"text/javascript\">\n<!--\n"; echo "function detectLanguage(filename)\n\t{\n\t\tvar parts = filename.toLowerCase().split('.').reverse();\n\t\tif ( parts.length < 2 ) return;\n\n\t\t// language ID\n\n\t\tvar elt=document.getElementById('langid');\n\t\t// the 'autodetect' option has empty value\n\t\tif ( elt.value != '' ) return;\n\n\t\tvar langid = getMainExtension(parts[0]);\n\t\tfor (i=0;i<elt.length;i++) {\n\t\t\tif ( elt.options[i].value == langid ) {\n\t\t\t\telt.selectedIndex = i;\n\t\t\t}\n\t\t}\n\n\t}\n"; putgetMainExtension($langs); echo "// -->\n</script>\n"; echo addForm($pagename, 'post', null, 'multipart/form-data'); ?> <table> <tr><td><label for="code">File</label>:</td> <td><input type="file" name="code" id="code" size="40" required onChange='detectLanguage(document.getElementById("code").value);' /></td> </tr> <tr><td colspan="2"> </td></tr> <tr><td><label for="langid">Language</label>:</td> <td><?php $langlist = array(); foreach ($langs as $langid => $langdata) { $langlist[$langid] = $langdata['name']; } $langlist[''] = 'plain text'; echo addSelect('langid', $langlist, '', true); ?> </td> </tr> <tr><td colspan="2"> </td></tr> <tr><td></td> <td><?php echo addSubmit('Print code', 'submit'); ?> </td> </tr> </table> <?php echo addEndForm(); }
} echo "</table>\n"; echo "<h2>Details</h2>\n"; $restrictions = array('rejudgingid' => $id); if ($viewtypes[$view] == 'unverified') { $restrictions['verified'] = 0; } if ($viewtypes[$view] == 'unjudged') { $restrictions['judged'] = 0; } if ($viewtypes[$view] == 'diff') { $restrictions['rejudgingdiff'] = 1; } if (isset($_REQUEST['old_verdict']) && $_REQUEST['old_verdict'] != 'all') { $restrictions['old_result'] = $_REQUEST['old_verdict']; } if (isset($_REQUEST['new_verdict']) && $_REQUEST['new_verdict'] != 'all') { $restrictions['result'] = $_REQUEST['new_verdict']; } echo addForm($pagename, 'get') . "<p>Show submissions:\n" . addHidden('id', $id); for ($i = 0; $i < count($viewtypes); ++$i) { echo addSubmit($viewtypes[$i], 'view[' . $i . ']', null, $view != $i); } $verdicts = array_keys($verdicts); array_unshift($verdicts, 'all'); echo "<br/>old verdict: " . addSelect('old_verdict', $verdicts, isset($_REQUEST['old_verdict']) ? $_REQUEST['old_verdict'] : 'all'); echo ", new verdict: " . addSelect('new_verdict', $verdicts, isset($_REQUEST['new_verdict']) ? $_REQUEST['new_verdict'] : 'all'); echo addSubmit('filter'); echo "</p>\n" . addEndForm(); putSubmissions($cdatas, $restrictions); require LIBWWWDIR . '/footer.php';
/** * Function to output a complete scoreboard. * This takes care of outputting the headings, start/endtimes and footer * of the scoreboard. It calls genScoreBoard to generate the data and * renderScoreBoardTable for displaying the actual table. * * Arguments: * $cdata current contest data, as from an index in 'getCurContests(TRUE)' * $myteamid set to highlight that teamid in the scoreboard * $static generate a static scoreboard, e.g. for external use * $filter set to TRUE to generate filter options, or pass array * with keys 'affilid', 'country', 'categoryid' pointing * to array of values to filter on these. * $sdata if not NULL, use this as scoreboard data instead of fetching it locally */ function putScoreBoard($cdata, $myteamid = NULL, $static = FALSE, $filter = FALSE, $sdata = NULL) { global $DB, $pagename; if (empty($cdata)) { echo "<p class=\"nodata\">No active contest</p>\n"; return; } $fdata = calcFreezeData($cdata); if ($sdata === NULL) { $sdata = genScoreBoard($cdata, IS_JURY, $filter); } // page heading with contestname and start/endtimes echo '<div class="score-head">'; echo "<h1>Scoreboard " . htmlspecialchars($cdata['name']) . "</h1>\n\n"; if ($fdata['showfinal']) { echo "<h4>final standings</h4>\n\n"; } elseif (!$fdata['cstarted']) { echo "<h4>" . printContestStart($cdata) . "</h4>\n\n"; // Stop here (do not leak problem number, descriptions etc). // Alternatively we could only display the list of teams? if (!IS_JURY) { return; } } else { echo "<h4>starts: " . printtime($cdata['starttime']) . " - ends: " . printtime($cdata['endtime']); if ($fdata['showfrozen']) { echo " ("; if (IS_JURY) { echo '<a href="../public/">the public scoreboard</a> is '; } echo "frozen since " . printtime($cdata['freezetime']) . ")"; } echo "</h4>\n\n"; } echo '</div>'; // The static scoreboard does not support filtering if ($filter !== FALSE && $static !== TRUE) { $categids = $DB->q('KEYVALUETABLE SELECT categoryid, name FROM team_category ' . (IS_JURY ? '' : 'WHERE visible = 1 ')); // show only affilids/countries with visible teams if (empty($categids)) { $affils = array(); } else { $affils = $DB->q('KEYTABLE SELECT affilid AS ARRAYKEY, team_affiliation.name, country FROM team_affiliation LEFT JOIN team t USING (affilid) INNER JOIN contest c ON (c.cid = %i) LEFT JOIN contestteam ct ON (ct.teamid = t.teamid AND ct.cid = c.cid) WHERE categoryid IN (%As) AND c.cid = %i AND (c.public = 1 OR ct.teamid IS NOT NULL) GROUP BY affilid', $cdata['cid'], array_keys($categids), $cdata['cid']); } $affilids = array(); $countries = array(); foreach ($affils as $id => $affil) { $affilids[$id] = $affil['name']; if (isset($affil['country'])) { $countries[] = $affil['country']; } } $countries = array_unique($countries); sort($countries); $filteron = array(); $filtertext = ""; foreach (array('affilid' => 'affiliation', 'country' => 'country', 'categoryid' => 'category') as $type => $text) { if (isset($filter[$type])) { $filteron[] = $text; } } if (sizeof($filteron) > 0) { $filtertext = "(filtered on " . implode(", ", $filteron) . ")"; } require_once LIBWWWDIR . '/forms.php'; ?> <table class="scorefilter"> <tr> <td><a class="collapse" href="javascript:collapse('filter')"><img src="../images/filter.png" alt="filter…" title="filter…" class="picto" /></a></td> <td><?php echo $filtertext; ?> </td> <td><div id="detailfilter"> <?php echo addForm($pagename, 'get') . (count($affilids) > 1 ? addSelect('affilid[]', $affilids, @$filter['affilid'], TRUE, 8) : "") . (count($countries) > 1 ? addSelect('country[]', $countries, @$filter['country'], FALSE, 8) : "") . (count($categids) > 1 ? addSelect('categoryid[]', $categids, @$filter['categoryid'], TRUE, 8) : "") . addSubmit('filter', 'filter') . addSubmit('clear', 'clear') . addEndForm(); ?> </div></td></tr> </table> <script type="text/javascript"> <!-- collapse("filter"); // --> </script> <?php } renderScoreBoardTable($sdata, $myteamid, $static); // last modified date, now if we are the jury, else include the // freeze time if (!IS_JURY && $fdata['showfrozen']) { $lastupdate = printtime($cdata['freezetime'], '%a %d %b %Y %T %Z'); } else { $lastupdate = printtime(now(), '%a %d %b %Y %T %Z'); } echo "<p id=\"lastmod\">Last Update: {$lastupdate}<br />\n" . "using <a href=\"https://www.domjudge.org/\">DOMjudge</a></p>\n\n"; return; }
/** * Returns a form to rejudge all judgings based on a (table,id) * pair. For example, to rejudge all for language 'java', call * as rejudgeForm('language', 'java'). */ function rejudgeForm($table, $id) { $ret = addForm('rejudge.php') . addHidden('table', $table) . addHidden('id', $id); $button = 'REJUDGE this submission'; $question = "Rejudge submission s{$id}?"; $disabled = false; $allbutton = false; // special case submission if ($table == 'submission') { // disable the form button if there are no valid judgings anyway // (nothing to rejudge) or if the result is already correct global $DB; $validresult = $DB->q('MAYBEVALUE SELECT result FROM judging WHERE submitid = %i AND valid = 1', $id); if (IS_ADMIN) { if (!$validresult) { $question = "Restart judging of PENDING submission s{$id}, " . 'are you sure?'; $button = 'RESTART judging'; } elseif ($validresult == 'correct') { $question = "Rejudge CORRECT submission s{$id}, " . 'are you sure?'; } } else { if (!$validresult || $validresult == 'correct') { $disabled = true; } } } else { $button = "REJUDGE ALL for {$table} {$id}"; $question = "Rejudge all submissions for this {$table}?"; if (IS_ADMIN) { $allbutton = true; } } $ret .= '<input type="submit" value="' . htmlspecialchars($button) . '" ' . ($disabled ? 'disabled="disabled"' : 'onclick="return confirm(\'' . htmlspecialchars($question) . '\');"') . " />\n" . ($allbutton ? addCheckBox('include_all') . '<label for="include_all">include pending/correct submissions</label>' : '') . addCheckBox('full_rejudge') . '<label for="full_rejudge">create rejudging with reason: </label>' . addInput('reason', '', 0, 255) . addEndForm(); return $ret; }
if (checkrole('team')) { echo "<a target=\"_top\" href=\"../team/\" accesskey=\"t\"><span class=\"octicon octicon-arrow-right\"></span> team</a>\n"; } ?> </div> <div id="menutopright"> <?php putClock(); $notify_flag = isset($_COOKIE["domjudge_notify"]) && (bool) $_COOKIE["domjudge_notify"]; $refresh_flag = !isset($_COOKIE["domjudge_refresh"]) || (bool) $_COOKIE["domjudge_refresh"]; echo "<div id=\"toggles\">\n"; if (isset($refresh)) { $text = $refresh_flag ? 'Disable' : 'Enable'; echo '<input id="refresh-toggle" type="button" value="' . $text . ' refresh" />'; } // Default hide this from view, only show when javascript and // notifications are available: echo '<div id="notify" style="display: none">' . addForm('toggle_notify.php', 'get') . addHidden('enable', $notify_flag ? 0 : 1) . addSubmit(($notify_flag ? 'Dis' : 'En') . 'able notifications', 'toggle_notify', 'return toggleNotifications(' . ($notify_flag ? 'false' : 'true') . ')') . addEndForm() . "</div>"; ?> <script type="text/javascript"> <!-- if ( 'Notification' in window ) { document.getElementById('notify').style.display = 'block'; } // --> </script> </div> </div></nav>
break; case 'NOCONSTRAINT': break; default: error("{$t}.{$key} is referenced in {$table} with unknown action '{$action}'."); } } } } if (isset($_POST['confirm'])) { // LIMIT 1 is a security measure to prevent our bugs from // wiping a table by accident. $DB->q("DELETE FROM {$t} WHERE %SS LIMIT 1", $k); auditlog($t, implode(', ', $k), 'deleted'); echo "<p>" . ucfirst($t) . " <strong>" . specialchars(implode(", ", $k)) . "</strong> has been deleted.</p>\n\n"; if (!empty($referrer)) { echo "<p><a href=\"" . $referrer . "\">back to overview</a></p>"; } else { // one table falls outside the predictable filenames $tablemulti = $t == 'team_category' ? 'team_categories' : $t . 's'; echo "<p><a href=\"" . $tablemulti . ".php\">back to {$tablemulti}</a></p>"; } } else { echo addForm($pagename) . addHidden('table', $t); foreach ($k as $key => $val) { echo addHidden($key, $val); } echo msgbox("Really delete?", "You're about to delete {$t} <strong>" . specialchars(join(", ", array_values($k))) . (empty($desc) ? '' : ' "' . specialchars($desc) . '"') . "</strong>.<br />\n" . (count($warnings) > 0 ? "<br /><strong>Warning, this will:</strong><br />" . implode('<br />', $warnings) : '') . "<br /><br />\n" . "Are you sure?<br /><br />\n\n" . (empty($referrer) ? '' : addHidden('referrer', $referrer)) . addSubmit(" Never mind... ", 'cancel') . addSubmit(" Yes I'm sure! ", 'confirm')); echo addEndForm(); } require LIBWWWDIR . '/footer.php';
echo (int) $data['outputlimit'] . ' kB' . (@$defaultoutputlimit ? ' (default)' : ''); ?> </td></tr> <?php if (!empty($data['color'])) { echo '<tr><td>Colour:</td><td><div class="circle" style="background-color: ' . specialchars($data['color']) . ';"></div> ' . specialchars($data['color']) . "</td></tr>\n"; } if (!empty($data['problemtext_type'])) { echo '<tr><td>Problem text:</td><td class="nobreak"><a href="problem.php?id=' . urlencode($id) . '&cmd=viewtext"><img src="../images/' . urlencode($data['problemtext_type']) . '.png" alt="problem text" ' . 'title="view problem description" /></a> ' . "</td></tr>\n"; } echo '<tr><td>Run script:</td><td class="filename">' . '<a href="executable.php?id=' . urlencode($data['special_run']) . '">' . specialchars($data['special_run']) . "</a>" . (@$defaultrun ? ' (default)' : '') . "</td></tr>\n"; echo '<tr><td>Compare script:</td><td class="filename">' . '<a href="executable.php?id=' . urlencode($data['special_compare']) . '">' . specialchars($data['special_compare']) . "</a>" . (@$defaultcompare ? ' (default)' : '') . "</td></tr>\n"; if (!empty($data['special_compare_args'])) { echo '<tr><td>Compare script arguments:</td><td>' . specialchars($data['special_compare_args']) . "</td></tr>\n"; } echo "</table>\n" . addEndForm(); if (IS_ADMIN) { echo "<p>" . exportLink($id) . "\n" . editLink('problem', $id) . "\n" . delLink('problem', 'probid', $id) . "</p>\n\n"; } echo rejudgeForm('problem', $id) . "<br />\n\n"; if ($current_cid === null) { echo "<h3>Contests</h3>\n\n"; $res = $DB->q('TABLE SELECT c.*, cp.shortname AS problemshortname, cp.allow_submit, cp.allow_judge, cp.color FROM contest c INNER JOIN contestproblem cp USING (cid) WHERE cp.probid = %i ORDER BY starttime DESC', $id); if (count($res) == 0) { echo "<p class=\"nodata\">No contests defined</p>\n\n"; } else { $times = array('activate', 'start', 'freeze', 'end', 'unfreeze');
LEFT JOIN team t ON (t.teamid = c.recipient) LEFT JOIN team f ON (f.teamid = c.sender) WHERE c.cid = %i AND c.sender = %i ORDER BY submittime DESC, clarid DESC', $cid, $teamid); $clarifications = $DB->q('SELECT c.*, cp.shortname, t.name AS toname, f.name AS fromname, u.mesgid AS unread FROM clarification c LEFT JOIN problem p USING (probid) LEFT JOIN contestproblem cp USING (probid, cid) LEFT JOIN team t ON (t.teamid = c.recipient) LEFT JOIN team f ON (f.teamid = c.sender) LEFT JOIN team_unread u ON (c.clarid=u.mesgid AND u.teamid = %i) WHERE c.cid = %i AND c.sender IS NULL AND ( c.recipient IS NULL OR c.recipient = %i ) ORDER BY c.submittime DESC, c.clarid DESC', $teamid, $cid, $teamid); echo "<h3 class=\"teamoverview\">Clarifications</h3>\n"; # FIXME: column width and wrapping/shortening of clarification text if ($clarifications->count() == 0) { echo "<p class=\"nodata\">No clarifications.</p>\n\n"; } else { putClarificationList($clarifications, $teamid); } echo "<h3 class=\"teamoverview\">Clarification Requests</h3>\n"; if ($requests->count() == 0) { echo "<p class=\"nodata\">No clarification requests.</p>\n\n"; } else { putClarificationList($requests, $teamid); } echo addForm('clarification.php', 'get') . "<p>" . addSubmit('request clarification') . "</p>" . addEndForm(); echo "</div>\n"; require LIBWWWDIR . '/footer.php';
endtime = %s, freezetime = %s, unfreezetime = %s, activatetime = %s, deactivatetime = %s WHERE cid = %i', $docdata['starttime'], $docdata['starttime_string'], $docdata['endtime'], $docdata['freezetime'], $docdata['unfreezetime'], $docdata['activatetime'], $docdata['deactivatetime'], $docid); header("Location: ./contests.php?edited=1"); } else { $DB->q('UPDATE contest SET ' . $time . 'time = %s, ' . $time . 'time_string = %s WHERE cid = %i', $now, $nowstring, $docid); header("Location: ./contests.php"); } exit; } $title = 'Contests'; require LIBWWWDIR . '/header.php'; echo "<h1>Contests</h1>\n\n"; if (isset($_GET['edited'])) { echo addForm('refresh_cache.php') . msgbox("Warning: Refresh scoreboard cache", "After changing the contest start time, it may be necessary to recalculate any cached scoreboards.<br /><br />" . addSubmit('recalculate caches now', 'refresh')) . addEndForm(); } // Display current contest data prominently echo "<fieldset><legend>Current contests: "; $curcids = getCurContests(FALSE); if (empty($curcids)) { echo "none</legend>\n\n"; $row = $DB->q('MAYBETUPLE SELECT * FROM contest WHERE activatetime > UNIX_TIMESTAMP() AND enabled = 1 ORDER BY activatetime LIMIT 1'); if ($row) { echo "<form action=\"contests.php\" method=\"post\">\n"; echo addHidden('cid', $row['cid']); echo "<p>No active contest. Upcoming:<br/> <em>" . specialchars($row['name']) . ' (' . specialchars($row['shortname']) . ')' . "</em>; active from " . printtime($row['activatetime'], '%a %d %b %Y %T %Z') . "<br /><br />\n"; if (IS_ADMIN) { echo addSubmit("activate now", "donow[activate]");
/** * Output clock */ function putClock() { global $cdata, $username; echo '<div id="clock">'; // timediff to end of contest if (difftime(now(), $cdata['starttime']) >= 0 && difftime(now(), $cdata['endtime']) < 0) { $left = "time left: " . printtimediff(now(), $cdata['endtime']); } else { if (difftime(now(), $cdata['activatetime']) >= 0 && difftime(now(), $cdata['starttime']) < 0) { $left = "time to start: " . printtimediff(now(), $cdata['starttime']); } else { $left = ""; } } echo "<span id=\"timeleft\">" . $left . "</span>"; global $cid, $cdatas; // Show a contest selection form, if there are contests if (IS_JURY || count($cdatas) > 1) { echo "<div id=\"selectcontest\">\n"; echo addForm('change_contest.php', 'get', 'selectcontestform'); $contests = array_map(function ($c) { return $c['shortname']; }, $cdatas); if (IS_JURY) { $values = array(-1 => '- No contest'); } foreach ($contests as $contestid => $name) { $values[$contestid] = $name; } echo 'contest: ' . addSelect('cid', $values, $cid, true); echo addEndForm(); echo "<script type=\"text/javascript\">\n\t\t document.getElementById('cid').addEventListener('change', function() {\n\t\t document.getElementById('selectcontestform').submit();\n\t});\n</script>\n"; echo "</div>\n"; } if (logged_in()) { echo "<div id=\"username\">logged in as " . $username . (have_logout() ? " <a href=\"../auth/logout.php\">×</a>" : "") . "</div>"; } echo "</div>"; echo "<script type=\"text/javascript\">\n\tvar initial = " . time() . ";\n\tvar activatetime = " . (isset($cdata['activatetime']) ? $cdata['activatetime'] : -1) . ";\n\tvar starttime = " . (isset($cdata['starttime']) ? $cdata['starttime'] : -1) . ";\n\tvar endtime = " . (isset($cdata['endtime']) ? $cdata['endtime'] : -1) . ";\n\tvar offset = 0;\n\tvar date = new Date(initial*1000);\n\tvar timeleftelt = document.getElementById(\"timeleft\");\n\n\tsetInterval(function(){updateClock();},1000);\n\tupdateClock();\n</script>\n"; }
} echo "</script>\n\n"; ?> <h3>Create new testcase</h3> <table> <tr><td>Input testdata: </td><td><?php echo addFileField('add_input'); ?> </td></tr> <tr><td>Output testdata:</td><td><?php echo addFileField('add_output'); ?> </td></tr> <tr><td>Sample testcase:</td><td><?php echo addSelect('add_sample', array("no", "yes"), 0, true); ?> </td></tr> <tr><td>Description: </td><td><?php echo addInput('add_desc', '', 30); ?> </td></tr> <tr><td>Image: </td><td><?php echo addFileField('add_image'); ?> </td></tr> </table> <?php echo "<br />" . addSubmit('Submit all changes') . addEndForm(); } require LIBWWWDIR . '/footer.php';
<p>Unknown authentication scheme in use.</p> <?php } echo addForm($pagename); ?> <p>Generate a random password for:<br/> <input type="checkbox" name="group[]" value="team">all teams<br /> <input type="checkbox" name="group[]" value="teamwithoutpw">teams without password<br /> <input type="checkbox" name="group[]" value="judge">jury members<br /> <input type="checkbox" name="group[]" value="admin">admins<br /> </p> <p>Output format:<br/> <input type="radio" name="format" value="page" checked>on web page<br/> <input type="radio" name="format" value="tsv">as userdata.tsv download<br/> <?php echo addSubmit('generate') . addEndForm(); require LIBWWWDIR . '/footer.php'; /** * Generate a random password of length 6 with lowercase alphanumeric * characters, except o, 0, l and 1 since these can be confusing. */ function genrandpasswd() { $chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7', '8', '9'); $max_chars = count($chars) - 1; $rand_str = ''; for ($i = 0; $i < 6; ++$i) { $rand_str .= $chars[mt_rand(0, $max_chars)]; } return $rand_str; }
echo "<p>Claimed: " . "<strong>" . printyn(!empty($req['jury_member'])) . "</strong>"; if (empty($req['jury_member'])) { echo '; '; } else { echo ', by ' . specialchars($req['jury_member']) . '; ' . addSubmit('unclaim', 'unclaim') . ' or '; } echo addSubmit('claim', 'claim') . '</p>' . addEndForm(); } if (!empty($req['respid'])) { $orig = $DB->q('MAYBETUPLE SELECT q.*, t.name AS name FROM clarification q LEFT JOIN team t ON (t.teamid = q.sender) WHERE q.clarid = %i', $respid); echo '<p>See the <a href="clarification.php?id=' . $respid . '">original clarification ' . $respid . '</a> by ' . ($orig['sender'] == NULL ? 'Jury' : '<a href="team.php?id=' . urlencode($orig['sender']) . '">' . specialchars($orig['name'] . " (t" . $orig['sender'] . ")") . '</a>') . "</p>\n\n"; } putClarification($id, NULL); // Display button to (un)set request as 'answered' // Not relevant for 'general clarifications', ie those with sender=null if (!empty($req['sender'])) { echo addForm($pagename) . addHidden('id', $id) . addHidden('answered', !$req['answered']) . addSubmit('Set ' . ($req['answered'] ? 'unanswered' : 'answered'), 'answer') . addEndForm(); } } // end if ( ! $isgeneral ) // display a clarification send box if ($isgeneral) { echo "<h1>Send Clarification</h1>\n\n"; putClarificationForm("clarification.php"); } else { echo "<h1>Send Response</h1>\n\n"; putClarificationForm("clarification.php", $respid); } require LIBWWWDIR . '/footer.php';
?> ', preventDuplicates: true, excludeCurrent: true, prePopulate: <?php echo json_encode($prepopulate); ?> }); }); </script> <?php } $rejudge_own = !isset($row['restrictions']['rejudge_own']) || (bool) $row['restrictions']['rejudge_own']; echo '<tr><td>Rejudge on same judgehost:</td><td>' . addRadioButton('data[0][restrictions][rejudge_own]', $rejudge_own, 1) . '<label for="data_0__restrictions__rejudge_own_1">yes</label>' . addRadioButton('data[0][restrictions][rejudge_own]', !$rejudge_own, 0) . '<label for="data_0__restrictions__rejudge_own_0">no</label>' . "</td></tr>\n"; echo "</table>\n\n"; echo addHidden('cmd', $cmd) . addHidden('table', 'judgehost_restriction') . addHidden('referrer', @$_GET['referrer']) . addSubmit('Save') . addSubmit('Cancel', 'cancel', null, true, 'formnovalidate') . addEndForm(); require LIBWWWDIR . '/footer.php'; exit; } $data = $DB->q('TUPLE SELECT * FROM judgehost_restriction WHERE restrictionid = %i', $id); if (!$data) { error("Missing or invalid restriction id"); } echo "<h1>Restriction: " . specialchars($data['name']) . "</h1>\n\n"; echo "<table>\n"; echo '<tr><td>ID:</td><td>' . specialchars($data['restrictionid']) . "</td></tr>\n"; echo '<tr><td>Name:</td><td>' . specialchars($data['name']) . "</td></tr>\n"; $restrictions = json_decode($data['restrictions'], true); foreach (array('contest', 'problem', 'language') as $type) { echo "<tr><td>Restrict to {$type}s:</td>"; if (empty($restrictions[$type])) {
// Our color field can be both a HTML color name and an RGB value, // so we output it only in the human-readable field "color" and // leave the field "rgb" unset. $problem['color'] = $prob['color']; $contest_data['problems'][] = $problem; } } $yaml = Spyc::YAMLDump($contest_data); echo $yaml; header('Content-type: text/x-yaml'); header('Content-Disposition: attachment; filename="contest.yaml"'); exit; } $title = "Import / export configuration"; require LIBWWWDIR . '/header.php'; echo "<h1>Import / export configuration</h1>\n\n"; if (isset($_GET['import-ok'])) { echo msgbox("Import successful!", "The file " . specialchars(@$_GET['file']) . " is successfully imported."); } echo "<h2>Import from YAML</h2>\n\n"; echo addForm('impexp_contestyaml.php', 'post', null, 'multipart/form-data'); echo msgbox("Please note!", "Importing a contest.yaml may overwrite some settings " . "(e.g. penalty time, clarification categories, clarification answers, etc.)." . "This action can not be undone!"); echo addFileField('import_config'); echo addSubmit('Import', 'import') . addEndForm(); echo "<h2>Export to YAML</h2>\n\n"; echo addForm('impexp_contestyaml.php'); echo '<label for="contest">Select contest: </label>'; $contests = $DB->q("KEYVALUETABLE SELECT cid, name FROM contest"); echo addSelect('contest', $contests, null, true); echo addSubmit('Export', 'export') . addEndForm(); require LIBWWWDIR . '/footer.php';
<li><a href="impexp_contestyaml.php">Contest data (contest.yaml)</a></li> <li><a href="problems.php">Problem archive</a></li> <li>Tab separated, export: <a href="impexp_tsv.php?act=ex&fmt=groups">groups.tsv</a>, <a href="impexp_tsv.php?act=ex&fmt=teams">teams.tsv</a>, <a href="impexp_tsv.php?act=ex&fmt=scoreboard">scoreboard.tsv</a>, <a href="impexp_tsv.php?act=ex&fmt=results">results.tsv</a> <li> <?php echo addForm('impexp_tsv.php', 'post', null, 'multipart/form-data') . 'Tab separated, import: ' . '<label for="fmt">type:</label> ' . addSelect('fmt', array('groups', 'teams', 'accounts')) . ', <label for="tsv">file:</label>' . addFileField('tsv') . addHidden('act', 'im') . addSubmit('import') . addEndForm(); ?> </li> </ul> <h2>Import teams / Upload standings from / to icpc.baylor.edu</h2> <p> Create a "Web Services Token" with appropriate rights in the "Export" section for your contest at <a href="https://icpc.baylor.edu/login">https://icpc.baylor.edu/login</a>. You can find the Contest ID (e.g. <code>Southwestern-Europe-2014</code>) in the URL. </p> <?php echo addForm("impexp_baylor.php"); echo "<table>\n"; echo "<tr><td><label for=\"contest\">Contest ID:</label></td>" . "<td>" . addInput('contest', @$contest, null, null, 'required') . "</td></tr>\n"; echo "<tr><td><label for=\"token\">Access token:</label></td>" . "<td>" . addInput('token', @$token, null, null, 'required') . "</td></tr>\n"; echo "</table>\n"; echo addSubmit('Fetch teams', 'fetch') . addSubmit('Upload standings', 'upload') . addEndForm(); require LIBWWWDIR . '/footer.php';
$classes = array(); if (!isset($activecontests[$row['probid']])) { $classes[] = 'disabled'; } $link = '<a href="problem.php?id=' . urlencode($row['probid']) . '">'; echo "<tr class=\"" . implode(' ', $classes) . "\"><td>" . $link . "p" . specialchars($row['probid']) . "</a>" . "</td><td>" . $link . specialchars($row['name']) . "</a>" . "</td><td>" . $link . specialchars(isset($activecontests[$row['probid']]) ? $activecontests[$row['probid']] : 0) . "</a>" . "</td><td>" . $link . (int) $row['timelimit'] . "</a>" . "</td><td>" . $link . (isset($row['memlimit']) ? (int) $row['memlimit'] : 'default') . "</a>" . "</td><td>" . $link . (isset($row['outputlimit']) ? (int) $row['outputlimit'] : 'default') . "</a>" . "</td><td><a href=\"testcase.php?probid=" . $row['probid'] . "\">" . $row['testcases'] . "</a></td>"; if (!empty($row['problemtext_type'])) { echo '<td title="view problem description">' . '<a href="problem.php?id=' . urlencode($row['probid']) . '&cmd=viewtext"><img src="../images/' . urlencode($row['problemtext_type']) . '.png" alt="problem text" /></a></td>'; } else { echo '<td></td>'; } if (IS_ADMIN) { echo '<td title="export problem as zip-file">' . exportLink($row['probid']) . '</td>' . "<td class=\"editdel\">" . editLink('problem', $row['probid']) . " " . delLink('problem', 'probid', $row['probid']) . "</td>"; } echo "</tr>\n"; } echo "</tbody>\n</table>\n\n"; } if (IS_ADMIN) { echo "<p>" . addLink('problem') . "</p>\n\n"; if (class_exists("ZipArchive")) { $selected_cid = $cid === null ? -1 : $cid; $contests = $DB->q("KEYVALUETABLE SELECT cid,\n\t\t CONCAT('c', cid, ': ', shortname, ' - ', name) FROM contest"); $values = array(-1 => 'Do not link to a contest'); foreach ($contests as $cid => $contest) { $values[$cid] = $contest; } echo "\n" . addForm('problem.php', 'post', null, 'multipart/form-data') . 'Contest: ' . addSelect('contest', $values, $selected_cid, true) . 'Problem archive(s): ' . addFileField('problem_archive[]', null, ' required multiple accept="application/zip"') . addSubmit('Upload', 'upload') . addEndForm() . "\n"; } } require LIBWWWDIR . '/footer.php';
?> <label for="data_0__visible_0">no</label></td></tr> </table> <?php echo addHidden('cmd', $cmd) . addHidden('table', 'team_category') . addHidden('referrer', @$_GET['referrer'] . ($cmd == 'edit' ? strstr(@$_GET['referrer'], '?') === FALSE ? '?edited=1' : '&edited=1' : '')) . addSubmit('Save') . addSubmit('Cancel', 'cancel', null, true, 'formnovalidate' . (isset($_GET['referrer']) ? ' formaction="' . specialchars($_GET['referrer']) . '"' : '')) . addEndForm(); require LIBWWWDIR . '/footer.php'; exit; } $data = $DB->q('TUPLE SELECT * FROM team_category WHERE categoryid = %i', $id); if (!$data) { error("Missing or invalid category id"); } if (isset($_GET['edited'])) { echo addForm('refresh_cache.php') . msgbox("Warning: Refresh scoreboard cache", "If the category sort order was changed, it may be necessary to " . "recalculate any cached scoreboards.<br /><br />" . addSubmit('recalculate caches now', 'refresh')) . addHidden('cid', $id) . addEndForm(); } echo "<h1>Category: " . specialchars($data['name']) . "</h1>\n\n"; echo "<table>\n"; echo '<tr><td>ID:</td><td>' . specialchars($data['categoryid']) . "</td></tr>\n"; echo '<tr><td>Name:</td><td>' . specialchars($data['name']) . "</td></tr>\n"; echo '<tr><td>Sortorder:</td><td>' . specialchars($data['sortorder']) . "</td></tr>\n"; if (isset($data['color'])) { echo '<tr><td>Colour: </td><td style="background: ' . specialchars($data['color']) . ';">' . specialchars($data['color']) . "</td></tr>\n"; } echo '<tr><td>Visible:</td><td>' . printyn($data['visible']) . "</td></tr>\n"; echo "</table>\n\n"; if (IS_ADMIN) { echo "<p>" . editLink('team_category', $data['categoryid']) . "\n" . delLink('team_category', 'categoryid', $data['categoryid'], $data['name']) . "</p>\n\n"; } echo "<h2>Teams in " . specialchars($data['name']) . "</h2>\n\n";
if ($reltime < dbconfig_get('judgehost_critical', 120)) { echo "Warning"; } else { echo "Critical"; } } echo ", time since judgehost last checked in: " . printtimediff($row['polltime']) . 's.'; } ?> </td></tr> </table> <?php if (IS_ADMIN) { $cmd = $row['active'] == 1 ? 'deactivate' : 'activate'; echo addForm($pagename) . "<p>\n" . addHidden('id', $row['hostname']) . addHidden('cmd', $cmd) . addSubmit($cmd) . "</p>\n" . addEndForm(); } if (IS_ADMIN) { echo "<p>" . delLink('judgehost', 'hostname', $row['hostname']) . "</p>\n\n"; } echo rejudgeForm('judgehost', $row['hostname']) . "<br />\n\n"; echo "<h3>Judgings by " . printhost($row['hostname']) . "</h3>\n\n"; // get the judgings for a specific key and value pair // select only specific fields to avoid retrieving large blobs $cids = getCurContests(FALSE); if (!empty($cids)) { $res = $DB->q('SELECT judgingid, submitid, starttime, endtime, judgehost, result, verified, valid FROM judging WHERE cid IN (%Ai) AND judgehost = %s ORDER BY starttime DESC, judgingid DESC', $cids, $row['hostname']); }
$editfield = ''; $i = 0; foreach ($data['value'] as $k => $v) { if ($data['type'] == 'array_keyval') { $editfield .= addInput("config_{$key}[{$i}][key]", $k, 0, 0, $extra); $editfield .= addInput("config_{$key}[{$i}][val]", $v, 0, 0, $extra); } else { $editfield .= addInput("config_{$key}[{$i}]", $v, 0, 0, $extra); } $editfield .= "<br />"; $i++; } if ($data['type'] == 'array_keyval') { $editfield .= addInput("config_{$key}[{$i}][key]", '', 0, 0, $extra); $editfield .= addInput("config_{$key}[{$i}][val]", '', 0, 0, $extra); } else { $editfield .= addInput("config_{$key}[{$i}]", '', 0, 0, $extra); } break; default: $editfield = ''; break; } // Ignore unknown datatypes if (empty($editfield)) { continue; } echo "<tr><td>" . htmlspecialchars(ucfirst(strtr($key, '_', ' '))) . "</td><td style=\"white-space: nowrap;\">" . $editfield . "</td><td>" . htmlspecialchars($data['desc']) . "</td></tr>\n"; } echo "</tbody>\n</table>\n<p>" . addSubmit('Save', 'save') . addSubmit('Cancel', 'cancel', null, true, 'formnovalidate') . "</p>" . addEndForm(); require LIBWWWDIR . '/footer.php';
$nunchecked++; if ($results === NULL) { $nomatch[] = "string '<code>@EXPECTED_RESULTS@:</code>' not found in " . "<a href=\"submission.php?id=" . $sid . "\">s{$sid}</a>, leaving submission unchecked"; } else { $earlier[] = "<a href=\"submission.php?id=" . $sid . "\">s{$sid}</a> already verified earlier"; } } } echo "{$nchecked} submissions checked: " . count($unexpected) . " unexpected results, " . count($multiple) . ($verify_multiple ? " automatically verified (multiple outcomes), " : " to check manually, ") . count($verified) . " automatically verified<br/>\n"; echo "{$nunchecked} submissions not checked: " . count($earlier) . " verified earlier, " . count($nomatch) . " without magic string<br/>\n"; if (count($unexpected)) { flushresults("Unexpected results", $unexpected); } if (count($multiple)) { if ($verify_multiple) { flushresults("Automatically verified (multiple outcomes)", $multiple, TRUE); } else { flushresults("Check manually", $multiple); echo "<div class=\"details\" id=\"detail{$section}\">\n" . addForm($pagename) . "<p>Verify all multiple outcome submissions: " . addHidden('verify_multiple', '1') . addSubmit('verify') . addEndForm() . "</p>\n</div>\n\n"; } } if (count($verified)) { flushresults("Automatically verified", $verified, TRUE); } if (count($earlier)) { flushresults("Verified earlier", $earlier, TRUE); } if (count($nomatch)) { flushresults("Without magic string", $nomatch, TRUE); } require LIBWWWDIR . '/footer.php';
* under the GNU GPL. See README and COPYING for details. */ require 'init.php'; $title = 'Executables'; require LIBWWWDIR . '/header.php'; echo "<h1>Executables</h1>\n\n"; // Select all data, sort problems from the current contest on top. $res = $DB->q('SELECT execid, description, md5sum, type, OCTET_LENGTH(zipfile) AS size FROM executable ORDER BY execid'); if ($res->count() == 0) { echo "<p class=\"nodata\">No executables defined</p>\n\n"; } else { echo "<table class=\"list sortable\">\n<thead>\n" . "<tr><th scope=\"col\">ID</th><th scope=\"col\">type</th>" . "<th scope=\"col\">description</th>" . "<th scope=\"col\">size</th><th scope=\"col\">md5</th>" . "<th></th><th></th></tr></thead>\n<tbody>\n"; $lastcid = -1; while ($row = $res->next()) { $link = '<a href="executable.php?id=' . urlencode($row['execid']) . '">'; echo "<tr><td class=\"execid\">" . $link . htmlspecialchars($row['execid']) . "</a>" . "</td><td>" . $link . htmlspecialchars($row['type']) . "</a>" . "</td><td>" . $link . htmlspecialchars(str_cut($row['description'], 40)) . "</a>" . "</td><td class=\"size\">" . $link . printsize($row['size']) . "</a>" . "</td><td class=\"md5\">" . $link . htmlspecialchars($row['md5sum']) . "</a>" . "</td>"; if (IS_ADMIN) { echo '<td title="export executable as zip-file"><a href="executable.php?fetch&id=' . urlencode($row['execid']) . '"><img src="../images/b_save.png" alt="export" /></a></td>' . "<td class=\"editdel\">" . editLink('executable', $row['execid']) . " " . delLink('executable', 'execid', $row['execid']) . "</td>"; } echo "</tr>\n"; } echo "</tbody>\n</table>\n\n"; } if (IS_ADMIN) { echo "<p>" . addLink('executable') . "</p>\n\n"; if (class_exists("ZipArchive")) { echo "\n" . addForm('executable.php', 'post', null, 'multipart/form-data') . 'Executable archive(s): ' . addSelect('type', $executable_types) . addFileField('executable_archive[]', null, ' required multiple accept="application/zip"') . addSubmit('Upload', 'upload') . addEndForm() . "\n"; } } require LIBWWWDIR . '/footer.php';
$restrictions['judged'] = 0; } if ($viewtypes[$view] == 'diff') { $restrictions['rejudgingdiff'] = 1; } if (isset($_REQUEST['old_verdict']) && $_REQUEST['old_verdict'] != 'all') { $restrictions['old_result'] = $_REQUEST['old_verdict']; } if (isset($_REQUEST['new_verdict']) && $_REQUEST['new_verdict'] != 'all') { $restrictions['result'] = $_REQUEST['new_verdict']; } echo "<p>Show submissions:</p>\n" . addForm($pagename, 'get') . addHidden('id', $id); for ($i = 0; $i < count($viewtypes); ++$i) { echo addSubmit($viewtypes[$i], 'view[' . $i . ']', null, $view != $i); } if (isset($_REQUEST['old_verdict'])) { echo addHidden('old_verdict', $_REQUEST['old_verdict']); } if (isset($_REQUEST['new_verdict'])) { echo addHidden('new_verdict', $_REQUEST['new_verdict']); } echo addEndForm() . "<br />\n"; echo addForm($pagename, 'get') . addHidden('id', $id) . addHidden("view[{$view}]", $viewtypes[$view]); $verdicts = array_keys($verdicts); array_unshift($verdicts, 'all'); echo "old verdict: " . addSelect('old_verdict', $verdicts, isset($_REQUEST['old_verdict']) ? $_REQUEST['old_verdict'] : 'all'); echo ", new verdict: " . addSelect('new_verdict', $verdicts, isset($_REQUEST['new_verdict']) ? $_REQUEST['new_verdict'] : 'all'); echo addSubmit('filter') . addEndForm(); echo addForm($pagename, 'get') . addHidden('id', $id) . addHidden("view[{$view}]", $viewtypes[$view]) . addSubmit('clear') . addEndForm() . "<br /><br />\n"; putSubmissions($cdatas, $restrictions); require LIBWWWDIR . '/footer.php';
$restrictions = array(); if (isset($_GET['restrict'])) { list($key, $value) = explode(":", $_GET['restrict'], 2); $restrictions[$key] = $value; } $row = $DB->q('MAYBETUPLE SELECT t.*, a.country, c.name AS catname, a.shortname AS affshortname, a.name AS affname FROM team t LEFT JOIN team_category c USING (categoryid) LEFT JOIN team_affiliation a ON (t.affilid = a.affilid) WHERE teamid = %i', $id); if (!$row) { error("Invalid team identifier"); } if (isset($_GET['edited'])) { echo addForm('refresh_cache.php') . msgbox("Warning: Refresh scoreboard cache", "If the membership of a team in a contest was changed, it may be necessary to recalculate any cached scoreboards.<br /><br />" . addSubmit('recalculate caches now', 'refresh')) . addEndForm(); } $users = $DB->q('TABLE SELECT userid,username FROM user WHERE teamid = %i', $id); $affillogo = "../images/affiliations/" . urlencode($row['affilid']) . ".png"; $countryflag = "../images/countries/" . urlencode($row['country']) . ".png"; $teamimage = "../images/teams/" . urlencode($row['teamid']) . ".jpg"; echo "<h1>Team " . specialchars($row['name']) . "</h1>\n\n"; if ($row['enabled'] != 1) { echo "<p><em>Team is disabled</em></p>\n\n"; } ?> <div class="col1"><table> <tr><td>ID: </td><td>t<?php echo specialchars($row['teamid']); ?>
} else { if ($reltime < dbconfig_get('judgehost_critical', 120)) { echo "judgehost-warn"; } else { echo "judgehost-crit"; } } echo "\" title =\"last checked in {$reltime} seconds ago\">"; } echo $link . CIRCLE_SYM . "</a></td>"; echo "<td>" . $link . (is_null($row['name']) ? '<i>none</i>' : $row['name']) . '</a></td>'; echo "<td title=\"load during the last 2 and 10 minutes and the whole contest\">" . $link . sprintf('%.2f %.2f %.2f', @$work2min[$row['hostname']] / (2 * 60), @$work10min[$row['hostname']] / (10 * 60), @$workcontest[$row['hostname']] / $clen) . "</a></td>"; if (IS_ADMIN) { if ($row['active']) { $activepicto = "pause"; $activecmd = "deactivate"; } else { $activepicto = "play"; $activecmd = "activate"; } echo "<td><a href=\"judgehost.php?id=" . $row['hostname'] . "&cmd=" . $activecmd . "\"><img class=\"picto\" alt=\"" . $activecmd . "\" title=\"" . $activecmd . " judgehost\" " . "src=\"../images/" . $activepicto . ".png\" /></a></td>"; echo "<td>" . delLink('judgehost', 'hostname', $row['hostname']) . "</td>"; } echo "</tr>\n"; } echo "</tbody>\n</table>\n\n"; } if (IS_ADMIN) { echo addForm($pagename) . "<p>" . addSubmit('Start all judgehosts', 'cmd-activate') . addSubmit('Stop all judgehosts', 'cmd-deactivate') . "<br /><br />\n\n" . addLink('judgehosts', true) . "\n" . editLink('judgehosts', null, true) . "</p>\n" . addEndForm(); } require LIBWWWDIR . '/footer.php';
echo addInput('data[0][country]', @$row['country'], 4, 3, 'pattern="[A-Z]{3}" title="three uppercase letters (ISO-3166-1 alpha-3)"'); ?> <a target="_blank" href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3#Current_codes"><img src="../images/b_help.png" class="smallpicto" alt="?" /></a></td></tr> <tr><td><label for="data_0__comments_">Comments:</label></td> <td><?php echo addTextArea('data[0][comments]', @$row['comments']); ?> </td></tr> </table> <?php echo addHidden('cmd', $cmd) . addHidden('table', 'team_affiliation') . addHidden('referrer', @$_GET['referrer']) . addSubmit('Save') . addSubmit('Cancel', 'cancel', null, true, 'formnovalidate') . addEndForm(); require LIBWWWDIR . '/footer.php'; exit; } $data = $DB->q('MAYBETUPLE SELECT * FROM team_affiliation WHERE affilid = %s', $id); if (!$data) { error("Missing or invalid affiliation id"); } $affillogo = "../images/affiliations/" . urlencode($data['affilid']) . ".png"; $countryflag = "../images/countries/" . urlencode($data['country']) . ".png"; echo "<h1>Affiliation: " . specialchars($data['name']) . "</h1>\n\n"; echo "<table>\n"; echo '<tr><td>ID:</td><td>' . specialchars($data['affilid']) . "</td></tr>\n"; echo '<tr><td>Shortname:</td><td>' . specialchars($data['shortname']) . "</td></tr>\n"; echo '<tr><td>Name:</td><td>' . specialchars($data['name']) . "</td></tr>\n"; echo '<tr><td>Logo:</td><td>';
$val = !$jud['verified']; echo addForm('verify.php') . addHidden('id', $jud['judgingid']) . addHidden('val', $val) . addHidden('redirect', @$_SERVER['HTTP_REFERER']); } echo "<p>Verified: " . "<strong>" . printyn($jud['verified']) . "</strong>"; if ($jud['verified'] && !empty($jud['jury_member'])) { echo ", by " . specialchars($jud['jury_member']); if (!empty($jud['verify_comment'])) { echo ' with comment "' . specialchars($jud['verify_comment']) . '"'; } } if (!($verification_required && $jud['verified'])) { echo '; ' . addSubmit(($val ? '' : 'un') . 'mark verified', 'verify'); if ($val) { echo ' with comment ' . addInput('comment', '', 25); } echo "</p>" . addEndForm(); } else { echo "</p>\n"; } } } else { // judging not ended yet echo "<p><b>Judging is not finished yet!</b></p>\n"; } ?> <script type="text/javascript"> <!-- togglelastruns(); // --> </script> <?php
echo "<tr><td>Related Contest:</td><td>" . "<a href=\"contest.php?id=" . urlencode($edata['cid']) . "\">c" . specialchars($edata['cid']) . "</a>" . "</td></tr>\n"; } $kind = $disabled['kind']; echo "<tr><td>Affected " . specialchars($kind) . ":</td><td>"; switch ($kind) { case 'problem': $probid = $disabled['probid']; $shortname = $DB->q('VALUE SELECT shortname FROM contestproblem WHERE probid=%i AND cid=%i', $probid, $edata['cid']); $name = $DB->q('VALUE SELECT name FROM problem WHERE probid=%i', $probid); echo "<a href=\"problem.php?id=" . urlencode($probid) . "\">" . specialchars($shortname . " - " . $name) . "</a>"; break; case 'judgehost': $judgehost = $disabled['hostname']; echo "<a href=\"judgehost.php?id=" . urlencode($judgehost) . "\">" . specialchars($judgehost) . "</a>"; break; case 'language': $langid = $disabled['langid']; echo "<a href=\"language.php?id=" . urlencode($langid) . "\">" . specialchars($langid) . "</a>"; break; default: // FIXME } echo "<tr><td>Judgehost log snippet:</td><td>"; echo "<pre class=\"output_text\">\n"; echo specialchars(base64_decode($edata['judgehostlog'])); echo "</pre></td></tr>\n</table>\n\n"; if ($edata['status'] == 'open') { echo addForm($pagename . '?id=' . urlencode($id)) . addSubmit('ignore error', 'ignore') . addEndForm(); echo addForm($pagename . '?id=' . urlencode($id)) . addSubmit('mark as resolved and re-enable ' . specialchars($disabled['kind']), 'resolve') . addEndForm(); } require LIBWWWDIR . '/footer.php';