fix(web/contest/self_reviews): remove useless DB::escape
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-11-07 19:25:45 +08:00
parent 4f5bbf82a5
commit 80e8b72fb6
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 18 additions and 14 deletions

View File

@ -259,7 +259,7 @@ if ($cur_tab == 'dashboard') {
}
for ($i = 0; $i < count($contest_problems); $i++) {
$content = DB::selectFirst([
$content = DB::selectSingle([
"select content",
"from", "contests_reviews",
"where", [
@ -271,7 +271,7 @@ if ($cur_tab == 'dashboard') {
$self_reviews_update_form->addVTextArea(
'self_review_update__problem_' . $contest_problems[$i]['problem']->getLetter(),
'<b>' . $contest_problems[$i]['problem']->getLetter() . '</b>: ' . $contest_problems[$i]['problem']->info['title'],
$content['content'],
$content,
function ($content) {
if (strlen($content) > 200) {
return '总结不能超过200字';
@ -284,7 +284,7 @@ if ($cur_tab == 'dashboard') {
);
}
$content = DB::selectFirst([
$content = DB::selectSingle([
"select content",
"from", "contests_reviews",
"where", [
@ -296,7 +296,7 @@ if ($cur_tab == 'dashboard') {
$self_reviews_update_form->addVTextArea(
'self_review_update__overall',
'比赛总结',
$content['content'],
$content,
function ($content) {
if (strlen($content) > 200) {
return '总结不能超过200字';
@ -309,27 +309,31 @@ if ($cur_tab == 'dashboard') {
);
$self_reviews_update_form->handle = function () use ($contest, $contest_problems) {
global $contest, $contest_problems, $myUser;
for ($i = 0; $i < count($contest_problems); $i++) {
if (isset($_POST['self_review_update__problem_' . $contest_problems[$i]['problem']->getLetter()])) {
$esc_content = DB::escape($_POST['self_review_update__problem_' . $contest_problems[$i]['problem']->getLetter()]);
$problem_id = $contest_problems[$i]['problem_id'];
DB::query([
"replace into contests_reviews",
"(contest_id, problem_id, poster, content)",
"values", DB::tuple([$contest['id'], $problem_id, Auth::id(), $esc_content]),
"values", DB::tuple([
$contest['id'],
$contest_problems[$i]['problem_id'],
Auth::id(),
$_POST['self_review_update__problem_' . $contest_problems[$i]['problem']->getLetter()],
]),
]);
}
}
if (isset($_POST['self_review_update__overall'])) {
$esc_content = DB::escape($_POST['self_review_update__overall']);
DB::query([
"replace into contests_reviews",
"(contest_id, problem_id, poster, content)",
"values", DB::tuple([$contest['id'], -1, Auth::id(), $esc_content]),
"values", DB::tuple([
$contest['id'],
-1,
Auth::id(),
$_POST['self_review_update__overall'],
]),
]);
}
};

View File

@ -543,7 +543,7 @@ $solution_view_type_form->handle = function () {
$config = $problem_extra_config;
$config['view_solution_type'] = $_POST['view_solution_type'];
$config['submit_solution_type'] = $_POST['submit_solution_type'];
$esc_config = DB::escape(json_encode($config));
$esc_config = json_encode($config);
DB::update([
"update problems",
@ -919,7 +919,7 @@ $info_form->runAtServer();
<label for="time_limit" class="col-sm-5 control-label">time_limit</label>
<div class="col-sm-7">
<?php $time_limit_value = is_array($problem_conf) ? getUOJConfVal($problem_conf, 'time_limit', 1) : ""; ?>
<input type="number" class="form-control" id="time_limit" name="time_limit" placeholder="时间限制(不能填写小数,默认为 1s" value="<?= $time_limit_value ?>">
<input type="text" class="form-control" id="time_limit" name="time_limit" placeholder="时间限制(默认为 1s" value="<?= $time_limit_value ?>">
</div>
</div>
<div class="form-group row">