result('contests', 'Active contests', 'E', 'No currently active contests found. System will not function.'); } else { $cidstring = implode(', ', array_map(function ($cid) { return 'c' . $cid; }, $cids)); result('contests', 'Active contests', 'O', 'Currently active contests: ' . $cidstring); } // get all contests $res = $DB->q('SELECT * FROM contest ORDER BY cid'); $detail = ''; $has_errors = FALSE; while ($cdata = $res->next()) { $cp = $DB->q('SELECT * FROM contestproblem WHERE cid = %i', $cdata['cid']); $detail .= "c" . (int) $cdata['cid'] . ": "; $CHECKER_ERRORS = array(); check_contest($cdata, array('cid' => $cdata['cid'])); while ($cpdata = $cp->next()) { check_contestproblem($cpdata, array('cid' => $cpdata['cid'], 'probid' => $cpdata['probid'])); } if (count($CHECKER_ERRORS) > 0) { foreach ($CHECKER_ERRORS as $chk_err) { $detail .= $chk_err . "\n"; $has_errors = TRUE; } } else { $detail .= "OK"; } $detail .= "\n"; } result('contests', 'Contests integrity', $has_errors ? 'E' : 'O', $detail); flushresults();
$invalid_regex = '/[^' . substr(IDENTIFIER_CHARS, 1) . '/'; $contest = array(); $contest['name'] = $contest_yaml_data['name']; $contest['shortname'] = preg_replace($invalid_regex, '_', $contest_yaml_data['short-name']); $contest['starttime_string'] = strftime('%Y-%m-%d %H:%M:%S', strtotime($contest_yaml_data['start-time'])); $contest['activatetime_string'] = '-1:00'; // chop off final ":00" because our contests do not support // that precision in relative notation $contest['endtime_string'] = '+' . substr($contest_yaml_data['duration'], 0, -3); // unfreezetime is not supported by the current standard $contest['unfreezetime_string'] = null; if (!empty($contest_yaml_data['scoreboard-freeze'])) { $contest['freezetime_string'] = '+' . substr($contest_yaml_data['scoreboard-freeze'], 0, -3); } $contest['enabled'] = 1; $contest = check_contest($contest); $cid = $DB->q("RETURNID INSERT INTO contest SET %S", $contest); if (!empty($CHECKER_ERRORS)) { echo "<p>Contest data not valid:</p>\n"; echo "<ul>\n"; foreach ($CHECKER_ERRORS as $error) { echo "<li>" . $error . "</li>\n"; } echo "</ul>\n"; require LIBWWWDIR . '/footer.php'; exit; } dbconfig_init(); // TODO: event-feed-port if (isset($contest_yaml_data)) { $LIBDBCONFIG['penalty_time']['value'] = (int) $contest_yaml_data['penaltytime'];