From f4729f6350d53ffe589a538e7abbd8988647b3f7 Mon Sep 17 00:00:00 2001 From: lys0829 Date: Sat, 18 Mar 2017 16:38:54 +0800 Subject: [PATCH 1/3] fix problem permession bug --- challenge.php | 1 + css/third | 2 +- function/common/contest.php | 3 +++ function/common/problem.php | 21 +++++++++++++++++---- js/third | 2 +- problem.php | 1 + 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/challenge.php b/challenge.php index 0443f0a..69fa92a 100644 --- a/challenge.php +++ b/challenge.php @@ -10,6 +10,7 @@ /chal/list/[page] ? quest str (default) */ require_once 'function/challenge/challenge.lib.php'; +require_once 'function/common/contest.php'; function ChallengeHandle() { global $SkyOJ,$_E; diff --git a/css/third b/css/third index fca6897..fbda5f5 160000 --- a/css/third +++ b/css/third @@ -1 +1 @@ -Subproject commit fca6897f10382ad410973631d333181888f1b3db +Subproject commit fbda5f55fccdd9826c0024db14242123c328153f diff --git a/function/common/contest.php b/function/common/contest.php index dd4b7f8..83908c3 100644 --- a/function/common/contest.php +++ b/function/common/contest.php @@ -412,6 +412,9 @@ function get_all_problems_info():array $data = []; foreach( $probs as $row ) { + if(!ContestProblemStateEnum::allow($row['state'])){ + continue; + } $tmp = new ContestProblemInfo(); foreach( ContestProblemInfo::$column as $c ) { diff --git a/function/common/problem.php b/function/common/problem.php index 30f4137..b769eea 100644 --- a/function/common/problem.php +++ b/function/common/problem.php @@ -214,7 +214,7 @@ public static function uid_contest_playing_problem_set(int $uid) $tcp = \DB::tname("contest_problem"); $tcu = \DB::tname("contest_user"); $now = \SKYOJ\get_timestamp(time()); - $res = \DB::fetchAllEx(" + /*$res = \DB::fetchAllEx(" SELECT DISTINCT `pid` FROM `{$tcp}` INNER JOIN `tojtest_contest` ON `{$tcp}`.`cont_id`=`{$tc}`.`cont_id` @@ -222,13 +222,26 @@ public static function uid_contest_playing_problem_set(int $uid) IN (SELECT `cont_id` FROM `{$tcu}` WHERE `uid` = ?) AND `starttime`<= ? AND ? <= `endtime` - ",$uid,$now,$now); + ",$uid,$now,$now);*/ + $res = \DB::fetchAllEx("SELECT `cont_id` FROM `{$tcu}` WHERE `uid` = ?",$uid); if( $res === false ) return []; $cache[$uid]=[]; - foreach($res as $row) - $cache[$uid][] = (int)$row['pid']; + foreach($res as $row){ + $cont_id = $row['cont_id']; + if( !\SKYOJ\check_tocint($cont_id) )continue; + $contest = new \SKYOJ\Contest($cont_id); + if( $contest->isIdfail() )continue; + if( $now<$contest->__get('starttime') || $now>$contest->__get('endtime'))continue; + $probs = $contest->get_all_problems_info(); + foreach($probs as $prob){ + $pid = $prob->pid; + if(!in_array($pid,$cache[$uid])){ + $cache[$uid][] = (int)$pid; + } + } + } return $cache[$uid]; } diff --git a/js/third b/js/third index 9660dff..3a60a8a 160000 --- a/js/third +++ b/js/third @@ -1 +1 @@ -Subproject commit 9660dfff85da552f79a0882739817ea6dc60fc69 +Subproject commit 3a60a8af1cf2c62ffd3ef268e41b88c4b9f9df9f diff --git a/problem.php b/problem.php index 791f7a2..3528896 100644 --- a/problem.php +++ b/problem.php @@ -14,6 +14,7 @@ /problem/api/[method] */ require_once 'function/problem/problem.lib.php'; +require_once 'function/common/contest.php'; function ProblemHandle() { global $SkyOJ,$_E; From 26d5f0eb365765f40b5ee6b92412f3240c6fd581 Mon Sep 17 00:00:00 2001 From: lys0829 Date: Wed, 22 Mar 2017 22:15:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AF=AB=E6=B3=95=20&=20?= =?UTF-8?q?merge=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function/Skyoj.lib.php | 2 +- function/common/problem.php | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/function/Skyoj.lib.php b/function/Skyoj.lib.php index 411a02f..0eb633f 100644 --- a/function/Skyoj.lib.php +++ b/function/Skyoj.lib.php @@ -464,7 +464,7 @@ function getresulttexthtml($resultid,bool $simple = false) "{$mini}"; } -function html(?string $str):string +function html(string $str):string { return htmlentities($str,ENT_HTML5|ENT_COMPAT,"UTF-8"); } \ No newline at end of file diff --git a/function/common/problem.php b/function/common/problem.php index b769eea..d63019d 100644 --- a/function/common/problem.php +++ b/function/common/problem.php @@ -214,15 +214,6 @@ public static function uid_contest_playing_problem_set(int $uid) $tcp = \DB::tname("contest_problem"); $tcu = \DB::tname("contest_user"); $now = \SKYOJ\get_timestamp(time()); - /*$res = \DB::fetchAllEx(" -SELECT DISTINCT `pid` FROM `{$tcp}` - INNER JOIN `tojtest_contest` - ON `{$tcp}`.`cont_id`=`{$tc}`.`cont_id` - WHERE `{$tcp}`.`cont_id` - IN (SELECT `cont_id` FROM `{$tcu}` WHERE `uid` = ?) - AND `starttime`<= ? - AND ? <= `endtime` - ",$uid,$now,$now);*/ $res = \DB::fetchAllEx("SELECT `cont_id` FROM `{$tcu}` WHERE `uid` = ?",$uid); if( $res === false ) @@ -230,10 +221,9 @@ public static function uid_contest_playing_problem_set(int $uid) $cache[$uid]=[]; foreach($res as $row){ $cont_id = $row['cont_id']; - if( !\SKYOJ\check_tocint($cont_id) )continue; $contest = new \SKYOJ\Contest($cont_id); if( $contest->isIdfail() )continue; - if( $now<$contest->__get('starttime') || $now>$contest->__get('endtime'))continue; + if( $now<$contest->starttime || $now>$contest->endtime)continue; $probs = $contest->get_all_problems_info(); foreach($probs as $prob){ $pid = $prob->pid; From ce38af598375e15b19c140071d9b268d600a89f3 Mon Sep 17 00:00:00 2001 From: lys0829 Date: Thu, 23 Mar 2017 23:11:48 +0800 Subject: [PATCH 3/3] fix bug --- function/Skyoj.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/function/Skyoj.lib.php b/function/Skyoj.lib.php index 0eb633f..411a02f 100644 --- a/function/Skyoj.lib.php +++ b/function/Skyoj.lib.php @@ -464,7 +464,7 @@ function getresulttexthtml($resultid,bool $simple = false) "{$mini}"; } -function html(string $str):string +function html(?string $str):string { return htmlentities($str,ENT_HTML5|ENT_COMPAT,"UTF-8"); } \ No newline at end of file