';
$accordion_parent = "{$this->name}_details_accordion";
if ($this->subtask_num != null) {
$accordion_parent .= "_collapse_subtask_{$this->subtask_num}_accordion";
}
$accordion_collapse = "{$accordion_parent}_collapse_test_{$test_num}";
if (!$this->styler->shouldFadeDetails($test_info)) {
echo '';
} elseif ($node->nodeName == 'custom-test') {
$test_info = $node->getAttribute('info');
$test_time = $node->getAttribute('time');
$test_memory = $node->getAttribute('memory');
echo '
';
$accordion_parent = "{$this->name}_details_accordion";
$accordion_collapse = "{$accordion_parent}_collapse_custom_test";
if (!$this->styler->shouldFadeDetails($test_info)) {
echo '';
}
} elseif ($node->nodeName == 'in') {
echo "
标准输入:
\n";
$this->_print_c($node);
echo "\n
";
} elseif ($node->nodeName == 'out') {
echo "
标准输出:
\n";
$this->_print_c($node);
echo "\n
";
} elseif ($node->nodeName == 'res') {
echo "
检验结果:
\n";
$this->_print_c($node);
echo "\n
";
} else {
echo '<', $node->nodeName;
foreach ($node->attributes as $attr) {
echo ' ', $attr->name, '="', htmlspecialchars($attr->value), '"';
}
echo '>';
$this->_print_c($node);
echo '', $node->nodeName, '>';
}
}
public function __construct($details, $styler, $name) {
$this->name = $name;
$this->styler = $styler;
$this->details = $details;
$this->dom = new DOMDocument();
if (!$this->dom->loadXML($this->details)) {
throw new Exception("XML syntax error");
}
$this->details = '';
}
public function printHTML() {
$this->subtask_num = null;
$this->_print($this->dom->documentElement);
}
}
function echoJudgementDetails($raw_details, $styler, $name) {
try {
$printer = new JudgementDetailsPrinter($raw_details, $styler, $name);
$printer->printHTML();
} catch (Exception $e) {
echo 'Failed to show details';
}
}
class SubmissionDetailsStyler {
public $show_score = true;
public $show_small_tip = true;
public $collapse_in = false;
public $fade_all_details = false;
public function getTestInfoClass($info) {
if ($info == 'Accepted' || $info == 'Extra Test Passed') {
return 'card-uoj-accepted';
} elseif ($info == 'Time Limit Exceeded') {
return 'card-uoj-tle';
} elseif ($info == 'Acceptable Answer') {
return 'card-uoj-acceptable-answer';
} else {
return 'card-uoj-wrong';
}
}
public function shouldFadeDetails($info) {
return $this->fade_all_details || $info == 'Extra Test Passed';
}
}
class CustomTestSubmissionDetailsStyler {
public $show_score = true;
public $show_small_tip = false;
public $collapse_in = true;
public $fade_all_details = false;
public $ioi_contest_is_running = false;
public function getTestInfoClass($info) {
if ($info == 'Success') {
return 'card-uoj-accepted';
} elseif ($info == 'Time Limit Exceeded') {
return 'card-uoj-tle';
} elseif ($info == 'Acceptable Answer') {
return 'card-uoj-acceptable-answer';
} else {
return 'card-uoj-wrong';
}
}
public function shouldFadeDetails($info) {
return $this->fade_all_details;
}
}
class HackDetailsStyler {
public $show_score = false;
public $show_small_tip = false;
public $collapse_in = true;
public $fade_all_details = false;
public function getTestInfoClass($info) {
if ($info == 'Accepted' || $info == 'Extra Test Passed') {
return 'card-uoj-accepted';
} elseif ($info == 'Time Limit Exceeded') {
return 'card-uoj-tle';
} elseif ($info == 'Acceptable Answer') {
return 'card-uoj-acceptable-answer';
} else {
return 'card-uoj-wrong';
}
}
public function shouldFadeDetails($info) {
return $this->fade_all_details;
}
}
function echoSubmissionDetails($submission_details, $name) {
echoJudgementDetails($submission_details, new SubmissionDetailsStyler(), $name);
}
function echoCustomTestSubmissionDetails($submission_details, $name) {
echoJudgementDetails($submission_details, new CustomTestSubmissionDetailsStyler(), $name);
}
function echoHackDetails($hack_details, $name) {
echoJudgementDetails($hack_details, new HackDetailsStyler(), $name);
}
function echoHack($hack, $config, $user) {
$problem = queryProblemBrief($hack['problem_id']);
echo '
';
if (!isset($config['id_hidden'])) {
echo '| #', $hack['id'], ' | ';
}
if (!isset($config['submission_hidden'])) {
echo '#', $hack['submission_id'], ' | ';
}
if (!isset($config['problem_hidden'])) {
if ($hack['contest_id']) {
echo '', getContestProblemLink($problem, $hack['contest_id'], '!id_and_title'), ' | ';
} else {
echo '', getProblemLink($problem, '!id_and_title'), ' | ';
}
}
if (!isset($config['hacker_hidden'])) {
echo '', getUserLink($hack['hacker']), ' | ';
}
if (!isset($config['owner_hidden'])) {
echo '', getUserLink($hack['owner']), ' | ';
}
if (!isset($config['result_hidden'])) {
if ($hack['judge_time'] == null) {
echo 'Waiting | ';
} elseif ($hack['success'] == null) {
echo 'Judging | ';
} elseif ($hack['success']) {
echo 'Success! | ';
} else {
echo 'Failed. | ';
}
} else {
echo 'Hidden | ';
}
if (!isset($config['submit_time_hidden'])) {
echo '', $hack['submit_time'], ' | ';
}
if (!isset($config['judge_time_hidden'])) {
echo '', $hack['judge_time'], ' | ';
}
echo '
';
}
function echoHackListOnlyOne($hack, $config, $user) {
echo '
';
echo '
';
echo '';
echo '';
if (!isset($config['id_hidden'])) {
echo '| ID | ';
}
if (!isset($config['submission_id_hidden'])) {
echo ''.UOJLocale::get('problems::submission id').' | ';
}
if (!isset($config['problem_hidden'])) {
echo ''.UOJLocale::get('problems::problem').' | ';
}
if (!isset($config['hacker_hidden'])) {
echo ''.UOJLocale::get('problems::hacker').' | ';
}
if (!isset($config['owner_hidden'])) {
echo ''.UOJLocale::get('problems::owner').' | ';
}
if (!isset($config['result_hidden'])) {
echo ''.UOJLocale::get('problems::result').' | ';
}
if (!isset($config['submit_time_hidden'])) {
echo ''.UOJLocale::get('problems::submit time').' | ';
}
if (!isset($config['judge_time_hidden'])) {
echo ''.UOJLocale::get('problems::judge time').' | ';
}
echo '
';
echo '';
echo '';
echoHack($hack, $config, $user);
echo '';
echo '
';
echo '
';
}
function echoHacksList($cond, $tail, $config, $user) {
$header_row = '
';
$col_names = array();
$col_names[] = 'id';
$col_names[] = 'success';
$col_names[] = 'judge_time';
if (!isset($config['id_hidden'])) {
$header_row .= '| ID | ';
}
if (!isset($config['submission_id_hidden'])) {
$header_row .= ''.UOJLocale::get('problems::submission id').' | ';
$col_names[] = 'submission_id';
}
if (!isset($config['problem_hidden'])) {
$header_row .= ''.UOJLocale::get('problems::problem').' | ';
$col_names[] = 'problem_id';
}
if (!isset($config['hacker_hidden'])) {
$header_row .= ''.UOJLocale::get('problems::hacker').' | ';
$col_names[] = 'hacker';
}
if (!isset($config['owner_hidden'])) {
$header_row .= ''.UOJLocale::get('problems::owner').' | ';
$col_names[] = 'owner';
}
if (!isset($config['result_hidden'])) {
$header_row .= ''.UOJLocale::get('problems::result').' | ';
}
if (!isset($config['submit_time_hidden'])) {
$header_row .= ''.UOJLocale::get('problems::submit time').' | ';
$col_names[] = 'submit_time';
}
if (!isset($config['judge_time_hidden'])) {
$header_row .= ''.UOJLocale::get('problems::judge time').' | ';
}
$header_row .= '
';
if (!isSuperUser($user)) {
if ($user != null) {
$permission_cond = "is_hidden = false or (is_hidden = true and problem_id in (select problem_id from problems_permissions where username = '{$user['username']}'))";
} else {
$permission_cond = "is_hidden = false";
}
if ($cond !== '1') {
$cond = "($cond) and ($permission_cond)";
} else {
$cond = $permission_cond;
}
}
echoLongTable($col_names, 'hacks', $cond, $tail, $header_row,
function($hacks) use ($config, $user) {
echoHack($hacks, $config, $user);
}, null);
}
function echoDatum($datum) {
$pid = $datum['pid'];
$title = queryProblemBrief($pid)['title'];
echo '
';
echo '| ' . $datum['id'] . ' | ';
echo '', getProblemLink(queryProblemBrief($pid), '!id_and_title'), ' | ';
if ($datum['status'] == 'Done')
echo 'Done | ';
else if ($datum['status'] == 'Failed')
echo 'Failed | ';
else echo '' . $datum['status'] . ' | ';
echo '' . $datum['request_time'] . ' | ';
echo '' . $datum['finish_time'] . ' | ';
echo '' . $datum['timelimit'] . ' s | ';
echo '' . $datum['memlimit'] . ' MB | ';
echo '
';
}
function echoDatumlistOnlyOne($datum) {
$header_row = '
| ID | 题目 | 状态 | 请求时间 | 完成时间 | 时间限制 | 空间限制 |
|---|
';
echo '
';
echo '
';
echo '';
echo $header_row;
echo '';
echo '';
echoDatum($datum);
echo '';
echo '
';
}
function echoDatumList() {
$col_names = array('id', 'pid', 'request_time', 'status', 'finish_time', 'timelimit', 'memlimit');
$header_row = '
| ID | 题目 | 状态 | 请求时间 | 完成时间 | 时间限制 | 空间限制 |
|---|
';
echoLongTable($col_names, 'datum_requests', '1', '', $header_row,
function($datum) { echoDatum($datum); }, null);
}
function getBlogPreview($str) {
return '';
}
function echoBlogCard($blog) {
if ($blog == null)
return;
$bloghref = "/blogs/" . $blog['id'];
$blogtitle = $blog['title'];
$poster = queryUser($blog['poster']);
$userlink = getUserLink($blog['poster']);
$posttime = $blog['post_time'];
$usermotto = $poster['motto'];
$zanblock = getClickZanBlock('B', $blog['id'], $blog['zan']);
$avatar = "https://q.qlogo.cn/g?b=qq&nk=" . $poster['qq'] . "&s=100";
return <<
$blogtitle
$userlink
$posttime
$usermotto
$zanblock