Skip to content

Commit

Permalink
Merge pull request #5 from lys0829/permession
Browse files Browse the repository at this point in the history
題目檢視全限BUG
  • Loading branch information
LFsWang authored Mar 23, 2017
2 parents c7b233e + ce38af5 commit 3445ab1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions challenge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion css/third
3 changes: 3 additions & 0 deletions function/common/contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
25 changes: 14 additions & 11 deletions function/common/problem.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,24 @@ 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 )
return [];
$cache[$uid]=[];
foreach($res as $row)
$cache[$uid][] = (int)$row['pid'];
foreach($res as $row){
$cont_id = $row['cont_id'];
$contest = new \SKYOJ\Contest($cont_id);
if( $contest->isIdfail() )continue;
if( $now<$contest->starttime || $now>$contest->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];
}

Expand Down
2 changes: 1 addition & 1 deletion js/third
1 change: 1 addition & 0 deletions problem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3445ab1

Please sign in to comment.