/** * Internal error reporting (back from judgehost) */ function internal_error_POST($args) { global $DB; checkargs($args, array('description', 'judgehostlog', 'disabled')); global $cdatas, $api; // group together duplicate internal errors // note that it may be good to be able to ignore fields here, e.g. judgingid with compile errors $errorid = $DB->q('MAYBEVALUE SELECT errorid FROM internal_error WHERE description=%s AND disabled=%s AND status=%s' . (isset($args['cid']) ? ' AND cid=%i' : '%_'), $args['description'], $args['disabled'], 'open', $args['cid']); if (isset($errorid)) { // FIXME: in some cases it makes sense to extend the known information, e.g. the judgehostlog return $errorid; } $errorid = $DB->q('RETURNID INSERT INTO internal_error (judgingid, cid, description, judgehostlog, time, disabled) VALUES (%i, %i, %s, %s, %i, %s)', $args['judgingid'], $args['cid'], $args['description'], $args['judgehostlog'], now(), $args['disabled']); $disabled = dj_json_decode($args['disabled']); // disable what needs to be disabled set_internal_error($disabled, $args['cid'], 0); if (in_array($disabled['kind'], array('problem', 'language'))) { // give back judging if we have to $submitid = $DB->q('VALUE SELECT submitid FROM judging WHERE judgingid = %i', $args['judgingid']); give_back_judging($args['judgingid'], $submitid); } return $errorid; }
/** * Scoreboard */ function scoreboard($args) { global $DB; checkargs($args, array('cid')); global $cdatas; $filter = array(); if (array_key_exists('category', $args)) { $filter['categoryid'] = array($args['category']); } if (array_key_exists('country', $args)) { $filter['country'] = array($args['country']); } if (array_key_exists('affiliation', $args)) { $filter['affilid'] = array($args['affiliation']); } $scoreboard = genScoreBoard($cdatas[$args['cid']], !$args['public'], $filter); $prob2label = $DB->q('KEYVALUETABLE SELECT probid, shortname FROM contestproblem WHERE cid = %i', $args['cid']); $res = array(); foreach ($scoreboard['scores'] as $teamid => $data) { $row = array('rank' => $data['rank'], 'team' => $teamid); $row['score'] = array('num_solved' => safe_int($data['num_points']), 'total_time' => safe_int($data['total_time'])); $row['problems'] = array(); foreach ($scoreboard['matrix'][$teamid] as $probid => $pdata) { $row['problems'][] = array('problem' => safe_int($probid), 'label' => $prob2label[$probid], 'num_judged' => safe_int($pdata['num_submissions']), 'num_pending' => safe_int($pdata['num_pending']), 'time' => safe_int($pdata['time']), 'solved' => safe_bool($pdata['is_correct'])); } $res[] = $row; } return $res; }
function getUser() { $auth = checkargs('auth') ? $_REQUEST['auth'] : ''; list($uid) = empty($auth) ? array(0, 0, 0, 0) : addslashes_deep(explode("\t", authcode($auth, 'DECODE'))); if ($uid) { //手机端 return array('uid' => $uid); } else { $keys = array('uid', 'collegeid', 'username', 'gender'); if (empty($_SERVER['HTTP_LOGININFO'])) { return; } else { //这里因为手机端加密时候只使用了uid顾需要作兼容处理,否则array_combine会返回false if (count($userArray = explode("\t", $_SERVER['HTTP_LOGININFO'])) > 1) { return array_combine($keys, $userArray); } return array('uid' => $userArray['0']); } } }