mirror of
https://github.com/renbaoshuo/UOJ-Luogu-RemoteJudge.git
synced 2024-12-29 16:51:59 +00:00
79 lines
3.4 KiB
PHP
79 lines
3.4 KiB
PHP
|
<?php
|
||
|
requirePHPLib('form');
|
||
|
requirePHPLib('data');
|
||
|
requirePHPLib('luogu');
|
||
|
|
||
|
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
|
||
|
become404Page();
|
||
|
}
|
||
|
if (!hasProblemPermission($myUser, $problem)) {
|
||
|
become403Page();
|
||
|
}
|
||
|
|
||
|
$problem_content = queryProblemContent($problem['id']);
|
||
|
$problem_tags = queryProblemTags($problem['id']);
|
||
|
|
||
|
$problem_editor = new UOJBlogEditor();
|
||
|
$problem_editor->name = 'problem';
|
||
|
$problem_editor->blog_url = "/problem/{$problem['id']}";
|
||
|
$problem_editor->cur_data = array(
|
||
|
'title' => $problem['title'],
|
||
|
'content_md' => $problem_content['statement_md'],
|
||
|
'content' => $problem_content['statement'],
|
||
|
'tags' => $problem_tags,
|
||
|
'is_hidden' => $problem['is_hidden']
|
||
|
);
|
||
|
$problem_editor->label_text = array_merge($problem_editor->label_text, array(
|
||
|
'view blog' => '查看题目',
|
||
|
'blog visibility' => '题目可见性'
|
||
|
));
|
||
|
|
||
|
$problem_editor->save = function($data) {
|
||
|
global $problem, $problem_tags;
|
||
|
DB::update("update problems set title = '".DB::escape($data['title'])."' where id = {$problem['id']}");
|
||
|
DB::update("update problems_contents set statement = '".DB::escape($data['content'])."', statement_md = '".DB::escape($data['content_md'])."' where id = {$problem['id']}");
|
||
|
|
||
|
if ($data['tags'] !== $problem_tags) {
|
||
|
DB::delete("delete from problems_tags where problem_id = {$problem['id']}");
|
||
|
foreach ($data['tags'] as $tag) {
|
||
|
DB::insert("insert into problems_tags (problem_id, tag) values ({$problem['id']}, '".DB::escape($tag)."')");
|
||
|
}
|
||
|
}
|
||
|
if ($data['is_hidden'] != $problem['is_hidden'] ) {
|
||
|
DB::update("update problems set is_hidden = {$data['is_hidden']} where id = {$problem['id']}");
|
||
|
DB::update("update submissions set is_hidden = {$data['is_hidden']} where problem_id = {$problem['id']}");
|
||
|
DB::update("update hacks set is_hidden = {$data['is_hidden']} where problem_id = {$problem['id']}");
|
||
|
}
|
||
|
};
|
||
|
|
||
|
$problem_editor->runAtServer();
|
||
|
|
||
|
if ($problem['type'] == 'luogu') {
|
||
|
$refetch_problem_form = new UOJForm('refetch_luogu');
|
||
|
$refetch_problem_form->submit_button_config['align'] = 'left';
|
||
|
$refetch_problem_form->submit_button_config['class_str'] = 'btn btn-danger';
|
||
|
$refetch_problem_form->submit_button_config['text'] = '重新拉取题目';
|
||
|
$refetch_problem_form->handle = function() use ($problem) {
|
||
|
try {
|
||
|
refetchLuoguProblemInfo($problem['id']);
|
||
|
} catch (Exception $e) {
|
||
|
becomeMsgPage('<h2>拉取失败</h2><pre>' . $e->getMessage() . '</pre>');
|
||
|
}
|
||
|
};
|
||
|
$refetch_problem_form->runAtServer();
|
||
|
}
|
||
|
?>
|
||
|
<?php echoUOJPageHeader(HTML::stripTags($problem['title']) . ' - 编辑 - 题目管理') ?>
|
||
|
<h1 class="page-header" align="center">#<?=$problem['id']?> : <?=$problem['title']?> 管理</h1>
|
||
|
<ul class="nav nav-tabs" role="tablist">
|
||
|
<li class="nav-item"><a class="nav-link active" href="/problem/<?= $problem['id'] ?>/manage/statement" role="tab">编辑</a></li>
|
||
|
<li class="nav-item"><a class="nav-link" href="/problem/<?= $problem['id'] ?>/manage/managers" role="tab">管理者</a></li>
|
||
|
<li class="nav-item"><a class="nav-link" href="/problem/<?= $problem['id'] ?>/manage/data" role="tab">数据</a></li>
|
||
|
<li class="nav-item"><a class="nav-link" href="/problem/<?=$problem['id']?>" role="tab">返回</a></li>
|
||
|
</ul>
|
||
|
<?php $problem_editor->printHTML() ?>
|
||
|
<?php if (isset($refetch_problem_form)): ?>
|
||
|
<?php $refetch_problem_form->printHTML() ?>
|
||
|
<?php endif ?>
|
||
|
<?php echoUOJPageFooter() ?>
|