mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-29 23:46:21 +00:00
119 lines
3.8 KiB
PHP
119 lines
3.8 KiB
PHP
<?php
|
|
requirePHPLib('form');
|
|
requirePHPLib('judger');
|
|
requirePHPLib('data');
|
|
requireLib('bootstrap5');
|
|
requireLib('hljs');
|
|
|
|
Auth::check() || redirectToLogin();
|
|
UOJHack::init(UOJRequest::get('id')) || UOJResponse::page404();
|
|
UOJHack::cur()->setProblem() || UOJResponse::page404();
|
|
UOJHack::cur()->userCanView(Auth::user(), ['ensure' => true]);
|
|
|
|
if (UOJHack::cur()->setSubmission()) {
|
|
UOJHack::cur()->submission->setAsCur();
|
|
UOJSubmission::cur()->setProblem(['problem' => UOJHack::cur()->problem]) || UOJResponse::page404();
|
|
UOJSubmission::cur()->userCanView(Auth::user(), ['ensure' => true]);
|
|
}
|
|
|
|
if (UOJHack::cur()->userCanDelete(Auth::user())) {
|
|
$delete_form = new UOJForm('delete');
|
|
$delete_form->handle = function () {
|
|
DB::delete([
|
|
"delete from hacks",
|
|
"where", ["id" => UOJHack::info('id')]
|
|
]);
|
|
};
|
|
$delete_form->config['submit_container']['class'] = 'text-end';
|
|
$delete_form->config['submit_button']['class'] = 'btn btn-sm btn-danger';
|
|
$delete_form->config['submit_button']['text'] = '删除此 Hack';
|
|
$delete_form->config['confirm']['smart'] = true;
|
|
$delete_form->succ_href = "/hacks";
|
|
$delete_form->runAtServer();
|
|
}
|
|
|
|
if (UOJHack::cur()->userCanReview(Auth::user())) {
|
|
$addex_form = new UOJForm('addex');
|
|
$addex_form->handle = function () {
|
|
$input = UOJContext::storagePath() . UOJHack::info('input');
|
|
$new_in = "{$input}_in";
|
|
$new_out = "{$input}_out";
|
|
$reason = null;
|
|
$err = dataAddHackPoint(UOJHack::cur()->problem->info, $new_in, $new_out, $reason, Auth::user());
|
|
$err === '' || UOJResponse::message($err);
|
|
unlink($new_in);
|
|
unlink($new_out);
|
|
DB::update([
|
|
"update hacks",
|
|
"set", [
|
|
'status' => 'Judged',
|
|
], "where", ['id' => UOJHack::info('id')]
|
|
]);
|
|
};
|
|
$addex_form->config['submit_button']['class'] = 'btn btn-sm btn-danger';
|
|
$addex_form->config['submit_button']['text'] = '确认无误,添加到测试数据';
|
|
$addex_form->config['submit_container']['class'] = 'mt-3 text-end';
|
|
$addex_form->config['confirm']['text'] = '将这个 Hack 数据添加到测试数据中';
|
|
$addex_form->succ_href = "/hacks";
|
|
$addex_form->runAtServer();
|
|
}
|
|
|
|
$perm = UOJHack::cur()->viewerCanSeeComponents(Auth::user());
|
|
?>
|
|
|
|
<?php echoUOJPageHeader(UOJLocale::get('problems::hack') . ' #' . UOJHack::info('id')) ?>
|
|
|
|
<h1>
|
|
<?= UOJLocale::get('problems::hack') . ' #' . UOJHack::info('id') ?>
|
|
</h1>
|
|
|
|
<?php echoHackListOnlyOne(UOJHack::info(), [], Auth::user()) ?>
|
|
|
|
<?php if (UOJHack::cur()->hasJudged()) : ?>
|
|
<?php if ($perm['high_level_details']) : ?>
|
|
<div class="card mb-3">
|
|
<div class="card-header fw-bold">
|
|
<?= UOJLocale::get('details') ?>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<?php
|
|
$styler = new HackDetailsStyler();
|
|
if (!$perm['low_level_details']) {
|
|
$styler->fade_all_details = true;
|
|
$styler->show_small_tip = false;
|
|
}
|
|
echoJudgmentDetails(UOJHack::info('details'), $styler, 'details');
|
|
?>
|
|
<?php if ($perm['manager_view'] && !$perm['low_level_details']) : ?>
|
|
<hr />
|
|
<h4 class="text-info">全部详细信息(仅管理员可见)</h4>
|
|
<?php echoHackDetails(UOJHack::info('details'), 'all_details') ?>
|
|
<?php endif ?>
|
|
</div>
|
|
</div>
|
|
<?php endif ?>
|
|
<?php endif ?>
|
|
|
|
<h2 class="mt-3">
|
|
<?= UOJLocale::get('problems::submission') . ' #' . UOJSubmission::info('id') ?>
|
|
</h2>
|
|
|
|
<?php if (UOJSubmission::cur()) : ?>
|
|
<?php UOJSubmission::cur()->echoStatusTable(['show_actual_score' => $perm['score']], Auth::user()) ?>
|
|
<?php if ($perm['content'] || $perm['manager_view']) : ?>
|
|
<?php UOJSubmission::cur()->echoContent() ?>
|
|
<?php endif ?>
|
|
<?php else : ?>
|
|
<h3 class="text-danger">提交记录信息损坏</h3>
|
|
<?php endif ?>
|
|
|
|
<?php if (isset($delete_form)) : ?>
|
|
<?php $delete_form->printHTML() ?>
|
|
<?php endif ?>
|
|
|
|
<?php if (isset($addex_form)) : ?>
|
|
<?php $addex_form->printHTML() ?>
|
|
<?php endif ?>
|
|
|
|
<?php echoUOJPageFooter() ?>
|