$problem['id']), $contest_problems) + 1; } function queryContest($id) { return DB::selectFirst("select * from contests where id = $id", MYSQLI_ASSOC); } function queryBlog($id) { return DB::selectFirst("select * from blogs where id='$id'", MYSQLI_ASSOC); } function queryBlogComment($id) { return DB::selectFirst("select * from blogs_comments where id='$id'", MYSQLI_ASSOC); } function isProblemVisibleToUser($problem, $user) { return !$problem['is_hidden'] || hasProblemPermission($user, $problem); } function isListVisibleToUser($list, $user) { return !$list['is_hidden'] || isSuperUser($user); } function isRegisteredRunningContestProblem($user, $problem) { $result = DB::query("select contest_id from contests_problems where problem_id = {$problem['id']}"); while (list($contest_id) = DB::fetch($result, MYSQLI_NUM)) { $contest = queryContest($contest_id); genMoreContestInfo($contest); if ( $contest['cur_progress'] == CONTEST_IN_PROGRESS && hasRegistered($user, $contest) && !hasContestPermission($user, $contest) && queryContestProblemRank($contest, $problem) ) { return true; } } return false; }