0 ){ $sql="select start_time,end_time from contest where contest_id=?"; $result=pdo_query($sql,$contest_id); if($result){ $row=$result[0]; $start_time = strtotime($row['start_time']); $end_time = strtotime($row['end_time']); $now=time(); if( $end_time < $now ){ // 当前提交,属于已经结束的比赛,考察是否有进行中的比赛在使用。 //echo $now."-".$end_time; $need_check_using=true; }else{ // 属于进行中的比赛,可以看 $need_check_using=false; } } }else{ //非比赛提交.考察是否有进行中的比赛在使用 $need_check_using=true; } // 检查是否使用中 $now = date('Y-m-d H:i', time()); $sql="select contest_id from contest where contest_id in (select contest_id from contest_problem where problem_id=?) and start_time < '$now' and end_time > '$now' "; // and title like '%$OJ_NOIP_KEYWORD%' if($need_check_using){ //echo $sql; $result=pdo_query($sql,$sproblem_id); if(count($result)>0){ $view_errors = "
"; $view_errors .= "

$MSG_CONTEST_ID : ".$result[0][0]."

"; $view_errors .= "

$MSG_SOURCE_NOT_ALLOWED_FOR_EXAM

"; $view_errors .= "
"; $view_errors .= "
"; $view_errors .= "

"; require("template/".$OJ_TEMPLATE."/error.php"); exit(0); } } } if(isset($OJ_EXAM_CONTEST_ID)){ if($contest_id<$OJ_EXAM_CONTEST_ID&&!isset($_SESSION[$OJ_NAME.'_'.'source_browser'])){ $view_errors = "
"; $view_errors .= "

$MSG_CONTEST_ID : ".$OJ_EXAM_CONTEST_ID."+

"; $view_errors .= "

$MSG_SOURCE_NOT_ALLOWED_FOR_EXAM

"; $view_errors .= "
"; $view_errors .= "
"; $view_errors .= "

"; require("template/".$OJ_TEMPLATE."/error.php"); exit(0); } } if (isset($OJ_AUTO_SHARE)&&$OJ_AUTO_SHARE&&isset($_SESSION[$OJ_NAME.'_'.'user_id'])){ $sql="SELECT 1 FROM solution where result=4 and problem_id=$sproblem_id and user_id=?"; $rrs=pdo_query($sql,$_SESSION[$OJ_NAME.'_'.'user_id']); if(count($rrs)>0) $ok=true; } //check whether user has the right of view solutions of this problem //echo "checking..."; if(isset($_SESSION[$OJ_NAME.'_'.'s'.$sproblem_id])){ $ok=true; // echo "Yes"; }else{ $sql="select count(1) from privilege where user_id=? and rightstr=?"; $count=pdo_query($sql,$_SESSION[$OJ_NAME.'_'.'user_id'],"s".$sproblem_id); if($count&&$count[0][0]>0){ $_SESSION[$OJ_NAME.'_'.'s'.$sproblem_id]=true; $ok=true; }else{ //echo "not right"; } } $view_source="No source code available!"; if (isset($_SESSION[$OJ_NAME.'_'.'user_id'])&&$row && $owner ==$_SESSION[$OJ_NAME.'_'.'user_id']) $ok=true; if (isset($_SESSION[$OJ_NAME.'_'.'source_browser'])) $ok=true; $sql="SELECT `source` FROM `source_code_user` WHERE `solution_id`=?"; $result=pdo_query($sql,$id); $row=$result[0]; if($row) $view_source=$row['source']; /////////////////////////Template require("template/".$OJ_TEMPLATE."/showsource.php"); /////////////////////////Common foot if(file_exists('./include/cache_end.php')) require_once('./include/cache_end.php'); ?>