@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function index() |
| 23 | 23 | { |
| 24 | 24 | $contestModel=new ContestModel(); |
| 25 | - $return_list=$contestModel->list(Auth::check()?Auth::user()->id:0); |
|
| 25 | + $return_list=$contestModel->list(Auth::check() ?Auth::user()->id : 0); |
|
| 26 | 26 | $featured=$contestModel->featured(); |
| 27 | 27 | return view('contest.index', [ |
| 28 | 28 | 'page_title'=>"Contest", |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | ]; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $editor_left_width = $accountModel->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40'; |
|
| 160 | + $editor_left_width=$accountModel->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40'; |
|
| 161 | 161 | |
| 162 | 162 | return view('contest.board.editor', [ |
| 163 | 163 | 'page_title'=>"Problem Detail", |
@@ -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", |
@@ -364,22 +364,22 @@ discard block |
||
| 364 | 364 | "verdict"=>$sub['verdict'] |
| 365 | 365 | ]; |
| 366 | 366 | $this->MODEL->updateSubmission($row['sid'], $sub); |
| 367 | - }else if($row['oid'] == 8) { |
|
| 367 | + } else if ($row['oid']==8) { |
|
| 368 | 368 | try { |
| 369 | - $sub = []; |
|
| 370 | - $response = Request::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']); |
|
| 371 | - 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, $match); |
|
| 372 | - $sub['verdict'] = $hdu_v[trim(strip_tags($match[1]))]; |
|
| 373 | - preg_match ("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response, $matches); |
|
| 374 | - $sub['remote_id'] = $row['remote_id']; |
|
| 375 | - $sub['time'] = intval($matches[1]); |
|
| 376 | - $sub['memory'] = intval($matches[2]); |
|
| 369 | + $sub=[]; |
|
| 370 | + $response=Request::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']); |
|
| 371 | + 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, $match); |
|
| 372 | + $sub['verdict']=$hdu_v[trim(strip_tags($match[1]))]; |
|
| 373 | + preg_match("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response, $matches); |
|
| 374 | + $sub['remote_id']=$row['remote_id']; |
|
| 375 | + $sub['time']=intval($matches[1]); |
|
| 376 | + $sub['memory']=intval($matches[2]); |
|
| 377 | 377 | // $sub['score'] = ($sub['verdict'] == 'Accepted')?100:0; |
| 378 | 378 | |
| 379 | - if($sub['verdict'] == 'Compile Error') { |
|
| 380 | - $ret = Request::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']); |
|
| 381 | - preg_match ("/<pre>([\\s\\S]*?)<\/pre>/", $ret, $match); |
|
| 382 | - $sub['compile_info'] = trim(strip_tags($match[0])); |
|
| 379 | + if ($sub['verdict']=='Compile Error') { |
|
| 380 | + $ret=Request::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']); |
|
| 381 | + preg_match("/<pre>([\\s\\S]*?)<\/pre>/", $ret, $match); |
|
| 382 | + $sub['compile_info']=trim(strip_tags($match[0])); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | $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 | } |
@@ -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 | } |
@@ -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'] = 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']=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) { |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | $this->post_data=$all_data; |
| 19 | 19 | $judger=new JudgerModel(); |
| 20 | 20 | $judger_list=$judger->list(8); |
| 21 | - $this->judgerAccount = $judger_list[array_rand($judger_list)]; |
|
| 21 | + $this->judgerAccount=$judger_list[array_rand($judger_list)]; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | private function hduLogin() |
| 25 | 25 | { |
| 26 | - $response=$this->grab_page('http://acm.hdu.edu.cn','hdu'); |
|
| 26 | + $response=$this->grab_page('http://acm.hdu.edu.cn', 'hdu'); |
|
| 27 | 27 | if (strpos($response, 'Sign In')!==false) { |
| 28 | 28 | $params=[ |
| 29 | 29 | 'username' => $this->judgerAccount["handle"], |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | ]; |
| 45 | 45 | |
| 46 | 46 | $response=$this->post_data("http://acm.hdu.edu.cn/submit.php", http_build_query($params), "hdu", true, false); |
| 47 | - $this->sub['jid'] = $this->judgerAccount['jid']; |
|
| 47 | + $this->sub['jid']=$this->judgerAccount['jid']; |
|
| 48 | 48 | $res=Requests::get('http://acm.hdu.edu.cn/status.php?user='.$this->judgerAccount['handle'].'&pid='.$this->post_data['iid']); |
| 49 | 49 | if (!preg_match("/<td height=22px>([\s\S]*?)<\/td>/", $res->body, $match)) { |
| 50 | 50 | $this->sub['verdict']='Submission Error'; |