示例#1
0
</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']);
}
if (empty($cids) || $res->count() == 0) {
    echo "<p class=\"nodata\">No judgings.</p>\n\n";
} else {
    echo "<table class=\"list sortable\">\n<thead>\n" . "<tr><th scope=\"col\" class=\"sorttable_numeric\">ID</th><th " . "scope=\"col\">started</th><th scope=\"col\">runtime</th><th " . "scope=\"col\">result</th><th scope=\"col\">valid</th><th " . "scope=\"col\">verified</th></tr>\n</thead>\n<tbody>\n";
    while ($jud = $res->next()) {
        if (empty($jud['endtime'])) {
            if ($jud['valid']) {
                $runtime = printtimediff($jud['starttime'], NULL);
            } else {
示例#2
0
文件: index.php 项目: retnan/domjudge
/**
 * Judging Queue
 *
 * FIXME: duplicates code with judgings_post
 * not used in judgedaemon
 */
function queue($args)
{
    global $DB;
    // TODO: make this configurable
    $cdatas = getCurContests(TRUE);
    $cids = array_keys($cdatas);
    if (empty($cids)) {
        return array();
    }
    $hasLimit = array_key_exists('limit', $args);
    // TODO: validate limit
    $sdatas = $DB->q('TABLE SELECT submitid
	                  FROM submission s
	                  LEFT JOIN team t USING (teamid)
	                  LEFT JOIN problem p USING (probid)
	                  LEFT JOIN language l USING (langid)
	                  LEFT JOIN contestproblem cp USING (probid, cid)
	                  WHERE judgehost IS NULL AND s.cid IN (%Ai)
	                  AND l.allow_judge = 1 AND cp.allow_judge = 1 AND valid = 1
	                  ORDER BY judging_last_started ASC, submittime ASC, submitid ASC' . ($hasLimit ? ' LIMIT %i' : ' %_'), $cids, $hasLimit ? $args['limit'] : -1);
    return array_map(function ($sdata) {
        return array('submitid' => safe_int($sdata['submitid']));
    }, $sdatas);
}
 // TODO: event-feed-port
 $contest_data['penaltytime'] = dbconfig_get('penalty_time');
 /*
 $contest_data['default-clars'] = dbconfig_get('clar_answers');
 $contest_data['clar-categories'] = array_values(dbconfig_get('clar_categories'));
 */
 $contest_data['languages'] = array();
 $q = $DB->q("SELECT * FROM language");
 while ($lang = $q->next()) {
     $language = array();
     $language['name'] = $lang['name'];
     // TODO: compiler, -flags, runner, -flags?
     $contest_data['languages'][] = $language;
 }
 $contest_data['problems'] = array();
 $contests = getCurContests(FALSE);
 if (!empty($contests)) {
     $q = $DB->q("SELECT * FROM problem INNER JOIN contestproblem USING (probid) WHERE cid IN (%Ai)", $contests);
     while ($prob = $q->next()) {
         $problem = array();
         $problem['letter'] = $prob['probid'];
         $problem['short-name'] = $prob['name'];
         // 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;
示例#4
0
/**
 * Calculate contest time from wall-clock time.
 * Returns time since contest start in seconds.
 * This function is currently a stub around timediff, but introduced
 * to allow minimal changes wrt. the removed intervals required for
 * the ICPC specification.
 */
function calcContestTime($walltime, $cid)
{
    // get contest data in case of non-public contests
    $cdatas = getCurContests(TRUE);
    $contesttime = difftime($walltime, $cdatas[$cid]['starttime']);
    return $contesttime;
}
示例#5
0
if (@$_POST['cmd'] == 'login') {
    do_login();
}
if (!logged_in()) {
    show_loginpage();
}
if (!checkrole('team')) {
    error("You do not have permission to perform that action (Missing role: 'team')");
}
if (empty($teamdata)) {
    error("You do not have a team associated with your account.  Please contact a staff member.");
}
if ($teamdata['enabled'] != 1) {
    error("Team is not enabled.");
}
$cdatas = getCurContests(TRUE, $teamdata['teamid']);
$cids = array_keys($cdatas);
// If the cookie has a existing contest, use it
if (isset($_COOKIE['domjudge_cid']) && isset($cdatas[$_COOKIE['domjudge_cid']])) {
    $cid = $_COOKIE['domjudge_cid'];
    $cdata = $cdatas[$cid];
} elseif (count($cids) >= 1) {
    // Otherwise, select the first contest
    $cid = $cids[0];
    $cdata = $cdatas[$cid];
}
// Data to be sent as AJAX updates:
$updates = array('clarifications' => array(), 'judgings' => array());
if (count($cids)) {
    $updates['clarifications'] = $DB->q('TABLE SELECT clarid, submittime, sender, recipient, probid, body
	        FROM team_unread
示例#6
0
文件: init.php 项目: sponi78/domjudge
<?php

/**
 * Include required files.
 *
 * Part of the DOMjudge Programming Contest Jury System and licenced
 * under the GNU GPL. See README and COPYING for details.
 */
require_once '../configure.php';
/* For plugins to have jury access rights to the DB, they should
 * successfully authenticate as user 'jury'.
 */
require_once LIBDIR . '/init.php';
require_once LIBWWWDIR . '/common.php';
require_once LIBWWWDIR . '/print.php';
require_once LIBWWWDIR . '/auth.php';
setup_database_connection();
if (!logged_in() && isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    do_login_native($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
    $userdata['roles'] = get_user_roles($userdata['userid']);
}
if (!checkrole('full_event_reader')) {
    error("User role full_event_reader required.");
}
define('IS_JURY', true);
define('IS_PUBLIC', false);
$cdatas = getCurContests(TRUE);
$cids = array_keys($cdatas);
示例#7
0
/**
 * Output a form to send a new clarification.
 * Set respid to a clarid, to make only responses to same
 * sender(s)/recipient(s) or ALL selectable.
 */
function putClarificationForm($action, $respid = NULL, $onlycontest = NULL)
{
    $cdatas = getCurContests(TRUE);
    if (isset($onlycontest)) {
        $cdatas = array($onlycontest => $cdatas[$onlycontest]);
    }
    $cids = array_keys($cdatas);
    if (empty($cids)) {
        echo '<p class="nodata">No active contests</p>';
        return;
    }
    require_once 'forms.php';
    global $DB;
    ?>

<script type="text/javascript">
<!--
function confirmClar() {
<?php 
    if (IS_JURY) {
        ?>
	var sendto_field = document.forms['sendclar'].sendto;
	var sendto = sendto_field.value;
	var sendto_text = sendto_field.options[sendto_field.selectedIndex].text;

	if ( sendto=='domjudge-must-select' ) {
		alert('You must select a recipient for this clarification.');
		return false;
	}
	return confirm("Send clarification to " + sendto_text + "?");
<?php 
    } else {
        ?>
	return confirm("Send clarification request to Jury?");
<?php 
    }
    ?>
}
// -->
</script>

<?php 
    echo addForm($action, 'post', 'sendclar');
    echo "<table>\n";
    if ($respid) {
        $clar = $DB->q('MAYBETUPLE SELECT c.*, t.name AS toname, f.name AS fromname
		                FROM clarification c
		                LEFT JOIN team t ON (t.teamid = c.recipient)
		                LEFT JOIN team f ON (f.teamid = c.sender)
		                WHERE c.clarid = %i', $respid);
    }
    if (IS_JURY) {
        // list all possible recipients in the "sendto" box
        echo "<tr><td><b><label for=\"sendto\">Send to</label>:</b></td><td>\n";
        if (!empty($respid)) {
            echo addHidden('id', $respid);
        }
        $options = array('domjudge-must-select' => '(select...)', '' => 'ALL');
        if (!$respid) {
            $teams = $DB->q('KEYVALUETABLE SELECT teamid, name
			                 FROM team
			                 ORDER BY categoryid ASC, team.name COLLATE utf8_general_ci ASC');
            $options += $teams;
        } else {
            if ($clar['sender']) {
                $options[$clar['sender']] = $clar['fromname'] . ' (t' . $clar['sender'] . ')';
            } else {
                if ($clar['recipient']) {
                    $options[$clar['recipient']] = $clar['toname'] . ' (t' . $clar['recipient'] . ')';
                }
            }
        }
        echo addSelect('sendto', $options, 'domjudge-must-select', true);
        echo "</td></tr>\n";
    } else {
        echo "<tr><td><b>To:</b></td><td>Jury</td></tr>\n";
    }
    // Select box for a specific problem (only when the contest
    // has started) or general issue.
    $options = array();
    foreach ($cdatas as $cid => $cdata) {
        $row = $DB->q('TUPLE SELECT CONCAT(cid, "-general") AS c
		               FROM contest WHERE cid = %i', $cid);
        if (IS_JURY && count($cdatas) > 1) {
            $options[$row['c']] = "{$cdata['shortname']} - General issue";
        } else {
            $options[$row['c']] = "General issue";
        }
        if (difftime($cdata['starttime'], now()) <= 0) {
            $problem_options = $DB->q('KEYVALUETABLE SELECT CONCAT(cid, "-", probid),
				                             CONCAT(shortname, ": ", name) as name
				        FROM problem
				        INNER JOIN contestproblem USING (probid)
				        WHERE cid = %i AND allow_submit = 1
				        ORDER BY shortname ASC', $cid);
            if (IS_JURY && count($cdatas) > 1) {
                foreach ($problem_options as &$problem_option) {
                    $problem_option = $cdata['shortname'] . ' - ' . $problem_option;
                }
                unset($problem_option);
            }
            $options += $problem_options;
        }
    }
    echo "<tr><td><b>Subject:</b></td><td>\n" . addSelect('problem', $options, $respid ? $clar['cid'] . '-' . $clar['probid'] : 'general', true) . "</td></tr>\n";
    ?>
<tr>
<td><b><label for="bodytext">Text</label>:</b></td>
<td><?php 
    $body = "";
    if ($respid) {
        $text = explode("\n", wrap_unquoted($clar['body']), 75);
        foreach ($text as $line) {
            $body .= "> {$line}\n";
        }
    }
    echo addTextArea('bodytext', $body, 80, 10, 'required');
    ?>
</td></tr>
<tr>
<td>&nbsp;</td>
<td><?php 
    echo addSubmit('Send', 'submit', 'return confirmClar()');
    ?>
</td>
</tr>
</table>
</form>
<script type="text/javascript">
<!--
document.forms['sendclar'].bodytext.focus();
document.forms['sendclar'].bodytext.select();
// -->
</script>
<?php 
}
示例#8
0
require LIBWWWDIR . '/header.php';
require LIBWWWDIR . '/scoreboard.php';
echo "<h1>Refresh Cache</h1>\n\n";
requireAdmin();
if (!isset($_REQUEST['refresh'])) {
    echo addForm($pagename);
    echo msgbox('Significant database impact', 'Refreshing the scoreboard cache can have a significant impact on the database load, ' . 'and is not necessary in normal operating circumstances.<br /><br />Refresh scoreboard cache now?' . '<br /><br />' . addSubmit(" Refresh now! ", 'refresh'));
    echo addEndForm();
    require LIBWWWDIR . '/footer.php';
    exit;
}
$time_start = microtime(TRUE);
auditlog('scoreboard', null, 'refresh cache');
// no output buffering... we want to see what's going on real-time
ob_implicit_flush();
$contests = getCurContests(TRUE);
foreach ($contests as $contest) {
    // get the contest, teams and problems
    $teams = $DB->q('TABLE SELECT t.teamid FROM team t
	                 INNER JOIN contest c ON c.cid = %i
	                 LEFT JOIN contestteam ct ON ct.teamid = t.teamid AND ct.cid = c.cid
	                 WHERE (c.public = 1 OR ct.teamid IS NOT NULL) ORDER BY teamid', $contest['cid']);
    $probs = $DB->q('TABLE SELECT probid, cid FROM problem
	                 INNER JOIN contestproblem USING (probid)
	                 WHERE cid = %i ORDER BY shortname', $contest['cid']);
    echo "<p>Recalculating all values for the scoreboard cache for contest c{$contest['cid']} (" . count($teams) . " teams, " . count($probs) . " problems)...</p>\n\n<pre>\n";
    if (count($teams) == 0) {
        echo "No teams defined, doing nothing.</pre>\n\n";
        continue;
    }
    if (count($probs) == 0) {
示例#9
0
<?php

/**
 * DOMjudge REST API
 *
 * Part of the DOMjudge Programming Contest Jury System and licenced
 * under the GNU GPL. See README and COPYING for details.
 */
require_once '../configure.php';
require_once LIBDIR . '/init.php';
setup_database_connection();
require_once LIBWWWDIR . '/common.php';
require_once LIBWWWDIR . '/print.php';
require_once LIBWWWDIR . '/scoreboard.php';
require_once LIBWWWDIR . '/auth.php';
require_once LIBWWWDIR . '/restapi.php';
$cdatas = getCurContests(TRUE, -1);
$cids = array_keys($cdatas);
if (!logged_in() && isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    do_login_native($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
    $userdata['roles'] = get_user_roles($userdata['userid']);
}
示例#10
0
文件: init.php 项目: sponi78/domjudge
    $REQUIRED_ROLES = array('jury');
}
$allowed = false;
foreach ($REQUIRED_ROLES as $role) {
    if (checkrole($role)) {
        $allowed = true;
    }
}
if (!$allowed) {
    error("You do not have permission to perform that action (Missing role(s): " . implode($REQUIRED_ROLES, ',') . ")");
}
require_once LIBWWWDIR . '/common.jury.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) && empty($_FILES) && isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > 0) {
    error("POST data exceeded php.ini's 'post_max_size' directive.");
}
$cdatas = getCurContests(TRUE, null, TRUE);
$cids = array_keys($cdatas);
// List of executable script types, used in various places:
$executable_types = array('compare' => 'compare', 'compile' => 'compile', 'run' => 'run');
// If the cookie has a existing contest, use it
if (isset($_COOKIE['domjudge_cid'])) {
    if (isset($cdatas[$_COOKIE['domjudge_cid']])) {
        $cid = $_COOKIE['domjudge_cid'];
        $cdata = $cdatas[$cid];
    }
} elseif (count($cids) >= 1) {
    // Otherwise, select the first contest
    $cid = $cids[0];
    $cdata = $cdatas[$cid];
}
// Data to be sent as AJAX updates: