function MsgAndBack($msg = "", $keepCache = true) { if ($keepCache) { if (empty($msg)) { $alertMsg = ""; } else { $alertMsg = 'alert("' . htmlspecialchars($msg) . '");'; } header('Cache-control: private, must-revalidate'); die("<script> {$alertMsg} history.go(-1); </script>"); } else { MsgAndRedirect($_SERVER['HTTP_REFERER'], $msg); } }
<?php include_once "./FCKeditor/fckeditor.php"; $cid = @$_GET['cid']; $pid = @$_GET['pid']; if ($cid) { $problem = new ContestProblem($cid); $contest = new ContestsTbl($cid); $contest->Get(); $contest_title = $contest->detail['title']; } else { $problem = new ProblemTbl(); $cid = 0; } if (!$problem->Get($pid)) { MsgAndRedirect("No such problem", "index.php"); } $title = $problem->detail['title']; ?> <form action="process.php?act=EditContestProblem" method="post" enctype="multipart/form-data"> <input type="hidden" name="avail" value="1" /> <input name="cid" type="hidden" id="cid" value="<?php echo $cid; ?> "> <table id="tb" width="100%" class="ui-widget tblcontainer ui-widget-content ui-corner-all"> <caption>Edit problems</caption> <thead> <tr class="ui-widget-header"> <th width="150">Option</th> <th>Content</th>
require "./navigation.php"; $course_id = safeget("course_id"); $courseTbl = new CourseTbl($course_id); if (!$courseTbl->Get()) { error("Course not found"); } $course = $courseTbl->detail; if ($course['require_cinfo'] && !is_info_complete()) { MsgAndRedirect("profile_edit.php", "Your information is not complete."); } if ($course['require_bound'] && !is_authorized()) { MsgAndRedirect("netid_bind.php", "You need to bind your netid with your account first."); } if (is_course_registered($course_id)) { MsgAndRedirect("course_detail.php?course_id={$course_id}"); } $now = time(); ?> <table class="ui-widget tblcontainer ui-widget-content ui-corner-all" width="100%"> <caption> Course Detail </caption> <thead> <tr class="ui-widget-header"> <th width="50">ID</th> <th width="200">Name</th> <th width="200">Teacher</th> <th>Statistics</th> </tr> </thead>
function StdSubmit(&$arg) { $pid = safefetch($arg, 'pid'); $source = isset($arg['source']) ? $arg['source'] : ''; $language = safefetch($arg, 'language'); $cid = 0; $ret = submit_source($pid, $cid, $language, $source); if (is_numeric($ret)) { // success $sid = intval($ret); $problem = new ProblemTbl($pid); $problem->Get(); $problem->update['stdsid'] = $sid; $problem->Update(); MsgAndRedirect('stdprogram.php?pid=' . $pid); } else { MsgAndRedirect('stdprogram.php?pid=' . $pid, $ret); } }
<?php require "./navigation.php"; global $logged; if (!$logged) { error("Please login first"); } $course_id = safeget("course_id"); if (!is_course_registered($course_id)) { MsgAndRedirect("course_register.php?course_id={$course_id}"); } $courseTbl = new CourseTbl($course_id); if (!$courseTbl->Get()) { error("Course not found"); } $course = $courseTbl->detail; $p = tryget("p", 1); $authname = array('free' => _("Public Exercise"), 'password' => _("Password"), 'internal' => _("Internal"), "bound" => _("Netid")); $rs = new RecordSet($conn); $query_str = "SELECT * FROM contests WHERE avail = 1 AND course_id = {$course_id} "; $count_str = "SELECT count(*) FROM contests WHERE avail = 1 AND course_id = {$course_id} "; $rs->nPageSize = 20; $rs->PageCount($count_str); $rs->SetPage($p); $query_str .= "ORDER BY cid DESC"; $rs->dpQuery($query_str); $now = time(); ?> <h1><?php echo _("Course Detail"); ?>
$contest->Get() or error("No such contest"); if (isset($_POST['pwd'])) { $pwd = safepost('pwd'); if ($contest->detail['authtype'] != 'password') { error("No password is needed"); } if ($contest->detail['pwd'] == $pwd) { $_SESSION["access{$cid}"] = 1; MsgAndRedirect("contest_detail.php?cid={$cid}"); } else { $error_msg = "Password Incorrect"; } } if (isset($_SESSION["access{$cid}"]) && $_SESSION["access{$cid}"] == 1 || $contest->detail['authtype'] != 'password') { // already auth MsgAndRedirect("contest_detail.php?cid={$cid}"); } ?> <div class="background_container"> <div class="ui-corner-all ui-widget-content"> <table width="900" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="300" height="100" bgcolor="#F0F0F0"><img src="images/register_01.jpg" width="300" height="100"></td> <td rowspan="3" align="center" valign="top" background="images/register_02.jpg"> <br> <br> <br> <br>
<?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();