/** * Check whether the contest is accessible * @param type $cid * @return type */ function is_contest_accessible($cid) { if (is_contest_modifiable($cid)) { return true; } // This is a user. Auth to login $contest = new ContestsTbl($cid); if (!$contest->Get()) { return false; } if (!$contest->detail['avail']) { return false; } if ($contest->detail['course_id'] && !is_course_registered($contest->detail['course_id'])) { return false; } if (is_temporary_user()) { return $contest->detail['perm'] == 'temp' && is_contest_registered($cid) && is_contest_auth($cid) && is_contest_started($cid); } else { return $contest->detail['perm'] == 'user' && is_contest_auth($cid) && is_contest_started($cid); } return false; }
<?php $navmode = "contest"; require "navigation.php"; $cid = safeget("cid"); $contest = new ContestsTbl($cid); $contest->Get() or error("No such contest"); if (!is_contest_accessible($cid)) { if ($contest->detail['authtype'] == 'password' && !isset($_SESSION["access{$cid}"])) { MsgAndRedirect("contest_password.php?cid={$cid}"); } else { if (!is_contest_started($cid)) { error(_("This contest is not started yet.")); } else { error(_("You can't access to the contest")); } } } $problem = new ContestProblem($cid); if (!$problem->GetByFields(array())) { error("No problem found"); } global $conn; $rs = new RecordSet($conn); $rs->Query("SELECT cpid, COUNT(*) AS num FROM contest_status left join status on contest_status.sid = status.sid " . "WHERE cid = {$cid} and status = 'Accepted' GROUP BY cpid ORDER BY cpid"); $ac_num = array(); while ($rs->MoveNext()) { $ac_num[$rs->Fields['cpid']] = intval($rs->Fields['num']); } $rs->Query("SELECT cpid, COUNT(*) AS num FROM contest_status " . "WHERE cid = {$cid} GROUP BY cpid ORDER BY cpid"); $sm_num = array();