From 80e8b72fb6edf6764e0bd348995ae33976c192ad Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 7 Nov 2022 19:25:45 +0800 Subject: [PATCH] fix(web/contest/self_reviews): remove useless DB::escape --- web/app/controllers/contest_inside.php | 28 ++++++++++++--------- web/app/controllers/problem_data_manage.php | 4 +-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/web/app/controllers/contest_inside.php b/web/app/controllers/contest_inside.php index b4e901d..d9c36cb 100644 --- a/web/app/controllers/contest_inside.php +++ b/web/app/controllers/contest_inside.php @@ -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(), '' . $contest_problems[$i]['problem']->getLetter() . ': ' . $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'], + ]), ]); } }; diff --git a/web/app/controllers/problem_data_manage.php b/web/app/controllers/problem_data_manage.php index 0942832..ca34b18 100644 --- a/web/app/controllers/problem_data_manage.php +++ b/web/app/controllers/problem_data_manage.php @@ -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();
- +