@@ -59,8 +59,8 @@ |
||
| 59 | 59 | $UVa->submit(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if($oj=='hdu') { |
|
| 63 | - $HDU = new HDU($sub, $all_data); |
|
| 62 | + if ($oj=='hdu') { |
|
| 63 | + $HDU=new HDU($sub, $all_data); |
|
| 64 | 64 | $HDU->submit(); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | // "gid"=>$gid |
| 124 | 124 | // ])->orderBy('begin_time', 'desc')->get()->all(); |
| 125 | 125 | $preQuery=DB::table($this->tableName); |
| 126 | - $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
| 126 | + $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
| 127 | 127 | $contest_list=$paginator->all(); |
| 128 | - if(empty($contest_list)){ |
|
| 128 | + if (empty($contest_list)) { |
|
| 129 | 129 | return null; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
| 161 | 161 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
| 162 | 162 | ->where( |
| 163 | - function ($query) { |
|
| 163 | + function($query) { |
|
| 164 | 164 | $query->where('public', 1) |
| 165 | 165 | ->where('audit_status', 1); |
| 166 | 166 | } |
| 167 | 167 | ) |
| 168 | 168 | ->orWhere( |
| 169 | - function ($query) use ($uid) { |
|
| 169 | + function($query) use ($uid) { |
|
| 170 | 170 | $query->where('group_member.uid', $uid) |
| 171 | 171 | ->where('group_member.role', '>', 0); |
| 172 | 172 | // ->where(function ($query) use ($uid) { |
@@ -231,14 +231,14 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - public function registContest($cid,$uid) |
|
| 234 | + public function registContest($cid, $uid) |
|
| 235 | 235 | { |
| 236 | 236 | $registered=DB::table("contest_participant")->where([ |
| 237 | 237 | "cid"=>$cid, |
| 238 | 238 | "uid"=>$uid |
| 239 | 239 | ])->first(); |
| 240 | 240 | |
| 241 | - if(empty($registered)){ |
|
| 241 | + if (empty($registered)) { |
|
| 242 | 242 | DB::table("contest_participant")->insert([ |
| 243 | 243 | "cid"=>$cid, |
| 244 | 244 | "uid"=>$uid, |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | "problem_detail" => $prob_detail |
| 540 | 540 | ]; |
| 541 | 541 | } |
| 542 | - usort($ret, function ($a, $b) { |
|
| 542 | + usort($ret, function($a, $b) { |
|
| 543 | 543 | if ($a["score"]==$b["score"]) { |
| 544 | 544 | if ($a["penalty"]==$b["penalty"]) { |
| 545 | 545 | return 0; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | "problem_detail" => $prob_detail |
| 587 | 587 | ]; |
| 588 | 588 | } |
| 589 | - usort($ret, function ($a, $b) { |
|
| 589 | + usort($ret, function($a, $b) { |
|
| 590 | 590 | if ($a["score"]==$b["score"]) { |
| 591 | 591 | if ($a["solved"]==$b["solved"]) { |
| 592 | 592 | return 0; |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | { |
| 680 | 680 | return DB::table("contest_clarification")->where([ |
| 681 | 681 | "cid"=>$cid |
| 682 | - ])->where(function ($query) { |
|
| 682 | + ])->where(function($query) { |
|
| 683 | 683 | $query->where([ |
| 684 | 684 | "public"=>1 |
| 685 | 685 | ])->orWhere([ |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | "users.id", |
| 828 | 828 | "=", |
| 829 | 829 | "submission.uid" |
| 830 | - )->where(function ($query) use ($frozen_time) { |
|
| 830 | + )->where(function($query) use ($frozen_time) { |
|
| 831 | 831 | $query->where( |
| 832 | 832 | "submission_date", |
| 833 | 833 | "<", |
@@ -1020,12 +1020,12 @@ discard block |
||
| 1020 | 1020 | public function updateProfessionalRate($cid) |
| 1021 | 1021 | { |
| 1022 | 1022 | $basic=$this->basic($cid); |
| 1023 | - if($basic["rated"]&&!$basic["is_rated"]){ |
|
| 1023 | + if ($basic["rated"] && !$basic["is_rated"]) { |
|
| 1024 | 1024 | $ratingCalculator=new RatingCalculator($cid); |
| 1025 | - if($ratingCalculator->calculate()){ |
|
| 1025 | + if ($ratingCalculator->calculate()) { |
|
| 1026 | 1026 | $ratingCalculator->storage(); |
| 1027 | 1027 | return true; |
| 1028 | - }else{ |
|
| 1028 | + } else { |
|
| 1029 | 1029 | return false; |
| 1030 | 1030 | } |
| 1031 | 1031 | } else { |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | |
| 1036 | 1036 | public function arrangeContest($gid, $config, $problems) |
| 1037 | 1037 | { |
| 1038 | - DB::transaction(function () use ($gid, $config, $problems) { |
|
| 1038 | + DB::transaction(function() use ($gid, $config, $problems) { |
|
| 1039 | 1039 | $cid=DB::table($this->tableName)->insertGetId([ |
| 1040 | 1040 | "gid"=>$gid, |
| 1041 | 1041 | "name"=>$config["name"], |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | 'WRONG_ANSWER'=>"Wrong Answer", |
| 109 | 109 | ]; |
| 110 | 110 | |
| 111 | - $hdu_v = [ |
|
| 111 | + $hdu_v=[ |
|
| 112 | 112 | 'Accepted'=>"Accepted", |
| 113 | 113 | "Presentation Error"=>"Presentation Error", |
| 114 | 114 | 'Time Limit Exceeded'=>"Time Limit Exceed", |
@@ -365,22 +365,22 @@ discard block |
||
| 365 | 365 | ]; |
| 366 | 366 | $this->MODEL->updateSubmission($row['sid'], $sub); |
| 367 | 367 | } |
| 368 | - }else if($row['oid']==8) { |
|
| 368 | + } else if ($row['oid']==8) { |
|
| 369 | 369 | try { |
| 370 | - $sub = []; |
|
| 371 | - $response = Requests::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']); |
|
| 372 | - preg_match ('/<\/td><td>[\\s\\S]*?<\/td><td>[\\s\\S]*?<\/td><td>([\\s\\S]*?)<\/td><td>[\\s\\S]*?<\/td><td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/', $response->body, $match); |
|
| 373 | - $sub['verdict'] = $hdu_v[trim(strip_tags($match[1]))]; |
|
| 374 | - preg_match ("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response->body, $matches); |
|
| 375 | - $sub['remote_id'] = $row['remote_id']; |
|
| 376 | - $sub['time'] = intval($matches[1]); |
|
| 377 | - $sub['memory'] = intval($matches[2]); |
|
| 370 | + $sub=[]; |
|
| 371 | + $response=Requests::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']); |
|
| 372 | + preg_match('/<\/td><td>[\\s\\S]*?<\/td><td>[\\s\\S]*?<\/td><td>([\\s\\S]*?)<\/td><td>[\\s\\S]*?<\/td><td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/', $response->body, $match); |
|
| 373 | + $sub['verdict']=$hdu_v[trim(strip_tags($match[1]))]; |
|
| 374 | + preg_match("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response->body, $matches); |
|
| 375 | + $sub['remote_id']=$row['remote_id']; |
|
| 376 | + $sub['time']=intval($matches[1]); |
|
| 377 | + $sub['memory']=intval($matches[2]); |
|
| 378 | 378 | // $sub['score'] = ($sub['verdict'] == 'Accepted')?100:0; |
| 379 | 379 | |
| 380 | - if($sub['verdict'] == 'Compile Error') { |
|
| 381 | - $ret = Requests::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']); |
|
| 382 | - preg_match ("/<pre>([\\s\\S]*?)<\/pre>/", $ret->body, $match); |
|
| 383 | - $sub['compile_info'] = trim(strip_tags($match[0])); |
|
| 380 | + if ($sub['verdict']=='Compile Error') { |
|
| 381 | + $ret=Requests::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']); |
|
| 382 | + preg_match("/<pre>([\\s\\S]*?)<\/pre>/", $ret->body, $match); |
|
| 383 | + $sub['compile_info']=trim(strip_tags($match[0])); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $this->MODEL->updateSubmission($row['sid'], $sub); |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | private function get_last_uva($earliest) |
| 434 | 434 | { |
| 435 | - $ret = []; |
|
| 435 | + $ret=[]; |
|
| 436 | 436 | if (!$earliest) { |
| 437 | 437 | return $ret; |
| 438 | 438 | } |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | $this->post_data=$all_data; |
| 20 | 20 | $judger=new JudgerModel(); |
| 21 | 21 | $judger_list=$judger->list(8); |
| 22 | - $this->judgerAccount = $judger_list[array_rand($judger_list)]; |
|
| 22 | + $this->judgerAccount=$judger_list[array_rand($judger_list)]; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | private function hduLogin() |
| 26 | 26 | { |
| 27 | - $response=$this->grab_page('http://acm.hdu.edu.cn','hdu', [], $this->judgerAccount["handle"]); |
|
| 27 | + $response=$this->grab_page('http://acm.hdu.edu.cn', 'hdu', [], $this->judgerAccount["handle"]); |
|
| 28 | 28 | if (strpos($response, 'Sign In')!==false) { |
| 29 | 29 | $params=[ |
| 30 | 30 | 'username' => $this->judgerAccount["handle"], |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $response=$this->post_data("http://acm.hdu.edu.cn/submit.php?action=submit", http_build_query($params), "hdu", true, false, true, false, [], $this->judgerAccount['handle']); |
| 48 | 48 | // Log::debug($response); |
| 49 | - $this->sub['jid'] = $this->judgerAccount['jid']; |
|
| 49 | + $this->sub['jid']=$this->judgerAccount['jid']; |
|
| 50 | 50 | $res=Requests::get('http://acm.hdu.edu.cn/status.php?user='.$this->judgerAccount['handle'].'&pid='.$this->post_data['iid']); |
| 51 | 51 | if (!preg_match("/<td height=22px>([\s\S]*?)<\/td>/", $res->body, $match)) { |
| 52 | 52 | $this->sub['verdict']='Submission Error'; |
@@ -80,46 +80,46 @@ |
||
| 80 | 80 | |
| 81 | 81 | public function crawler($con) |
| 82 | 82 | { |
| 83 | - if($con == "all") { |
|
| 84 | - return ; |
|
| 83 | + if ($con=="all") { |
|
| 84 | + return; |
|
| 85 | 85 | } |
| 86 | - $this->con = $con; |
|
| 87 | - $this->imgi = 1; |
|
| 88 | - $problemModel = new ProblemModel(); |
|
| 89 | - $res = Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}"); |
|
| 90 | - if (strpos("No such problem",$res->body) !== false) { |
|
| 86 | + $this->con=$con; |
|
| 87 | + $this->imgi=1; |
|
| 88 | + $problemModel=new ProblemModel(); |
|
| 89 | + $res=Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}"); |
|
| 90 | + if (strpos("No such problem", $res->body)!==false) { |
|
| 91 | 91 | header('HTTP/1.1 404 Not Found'); |
| 92 | 92 | die(); |
| 93 | 93 | } |
| 94 | - else if(strpos("Invalid Parameter.",$res->body) !== false) { |
|
| 94 | + else if (strpos("Invalid Parameter.", $res->body)!==false) { |
|
| 95 | 95 | header('HTTP/1.1 404 Not Found'); |
| 96 | 96 | die(); |
| 97 | 97 | } |
| 98 | 98 | else { |
| 99 | - $this->pro['pcode'] = "HDU".$con; |
|
| 100 | - $this->pro['OJ'] = 8; |
|
| 101 | - $this->pro['contest_id'] = null; |
|
| 102 | - $this->pro['index_id'] = $con; |
|
| 103 | - $this->pro['origin'] = "http://acm.hdu.edu.cn/showproblem.php?pid={$con}"; |
|
| 104 | - $this->pro['title'] = self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/",$res->body); |
|
| 105 | - $this->pro['time_limit'] = self::find('/Time Limit:.*\/(.*) MS/',$res->body); |
|
| 106 | - $this->pro['memory_limit'] = self::find('/Memory Limit:.*\/(.*) K/',$res->body); |
|
| 107 | - $this->pro['solved_count'] = self::find("/Accepted Submission(s): ([\d+]*?)/",$res->body); |
|
| 99 | + $this->pro['pcode']="HDU".$con; |
|
| 100 | + $this->pro['OJ']=8; |
|
| 101 | + $this->pro['contest_id']=null; |
|
| 102 | + $this->pro['index_id']=$con; |
|
| 103 | + $this->pro['origin']="http://acm.hdu.edu.cn/showproblem.php?pid={$con}"; |
|
| 104 | + $this->pro['title']=self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/", $res->body); |
|
| 105 | + $this->pro['time_limit']=self::find('/Time Limit:.*\/(.*) MS/', $res->body); |
|
| 106 | + $this->pro['memory_limit']=self::find('/Memory Limit:.*\/(.*) K/', $res->body); |
|
| 107 | + $this->pro['solved_count']=self::find("/Accepted Submission(s): ([\d+]*?)/", $res->body); |
|
| 108 | 108 | $this->pro['input_type']='standard input'; |
| 109 | 109 | $this->pro['output_type']='standard output'; |
| 110 | - $this->pro['description'] = $this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body), true, true, DEFAULT_TARGET_CHARSET, false)); |
|
| 111 | - $this->pro['input'] = self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body); |
|
| 112 | - $this->pro['output'] = self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body); |
|
| 113 | - $this->pro['sample'] = []; |
|
| 114 | - $this->pro['sample'][] = [ |
|
| 115 | - 'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body), |
|
| 116 | - 'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body) |
|
| 110 | + $this->pro['description']=$this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body), true, true, DEFAULT_TARGET_CHARSET, false)); |
|
| 111 | + $this->pro['input']=self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body); |
|
| 112 | + $this->pro['output']=self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body); |
|
| 113 | + $this->pro['sample']=[]; |
|
| 114 | + $this->pro['sample'][]=[ |
|
| 115 | + 'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU", $res->body), |
|
| 116 | + 'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU", $res->body) |
|
| 117 | 117 | ]; |
| 118 | 118 | // $this->pro['sample']['sample_input'] = self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body); |
| 119 | 119 | // $this->pro['sample']['sample_output'] = self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body); |
| 120 | - $this->pro['note'] = self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU",$res->body); |
|
| 121 | - $this->pro['source'] = strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU",$res->body)); |
|
| 122 | - $this->pro['force_raw'] = 0; |
|
| 120 | + $this->pro['note']=self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU", $res->body); |
|
| 121 | + $this->pro['source']=strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU", $res->body)); |
|
| 122 | + $this->pro['force_raw']=0; |
|
| 123 | 123 | $problem=$problemModel->pid($this->pro['pcode']); |
| 124 | 124 | |
| 125 | 125 | if ($problem) { |