@@ -79,42 +79,42 @@ |
||
| 79 | 79 | |
| 80 | 80 | public function crawler($con) |
| 81 | 81 | { |
| 82 | - if($con == "all") { |
|
| 83 | - return ; |
|
| 82 | + if ($con=="all") { |
|
| 83 | + return; |
|
| 84 | 84 | } |
| 85 | - $this->con = $con; |
|
| 86 | - $this->imgi = 1; |
|
| 87 | - $problemModel = new ProblemModel(); |
|
| 88 | - $res = Request::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}"); |
|
| 89 | - if (strpos("No such problem",$res->body) !== false) { |
|
| 85 | + $this->con=$con; |
|
| 86 | + $this->imgi=1; |
|
| 87 | + $problemModel=new ProblemModel(); |
|
| 88 | + $res=Request::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}"); |
|
| 89 | + if (strpos("No such problem", $res->body)!==false) { |
|
| 90 | 90 | header('HTTP/1.1 404 Not Found'); |
| 91 | 91 | die(); |
| 92 | 92 | } |
| 93 | - else if(strpos("Invalid Parameter.",$res->body) !== false) { |
|
| 93 | + else if (strpos("Invalid Parameter.", $res->body)!==false) { |
|
| 94 | 94 | header('HTTP/1.1 404 Not Found'); |
| 95 | 95 | die(); |
| 96 | 96 | } |
| 97 | 97 | else { |
| 98 | - $this->pro['pcode'] = "HDU".$con; |
|
| 99 | - $this->pro['OJ'] = 1; |
|
| 100 | - $this->pro['contest_id'] = null; |
|
| 101 | - $this->pro['index_id'] = $con; |
|
| 102 | - $this->pro['origin'] = "http://acm.hdu.edu.cn/showproblem.php?pid={$con}"; |
|
| 103 | - $this->pro['title'] = find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/",$res->body); |
|
| 104 | - $this->pro['time_limit'] = find('/Time Limit:.*\/(.*) MS/',$res->body); |
|
| 105 | - $this->pro['memory_limit'] = find('/Memory Limit:.*\/(.*) K/',$res->body); |
|
| 106 | - $this->pro['solved_count'] = find("/Accepted Submission(s): ([\d+]*?)/",$res->body); |
|
| 98 | + $this->pro['pcode']="HDU".$con; |
|
| 99 | + $this->pro['OJ']=1; |
|
| 100 | + $this->pro['contest_id']=null; |
|
| 101 | + $this->pro['index_id']=$con; |
|
| 102 | + $this->pro['origin']="http://acm.hdu.edu.cn/showproblem.php?pid={$con}"; |
|
| 103 | + $this->pro['title']=find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/", $res->body); |
|
| 104 | + $this->pro['time_limit']=find('/Time Limit:.*\/(.*) MS/', $res->body); |
|
| 105 | + $this->pro['memory_limit']=find('/Memory Limit:.*\/(.*) K/', $res->body); |
|
| 106 | + $this->pro['solved_count']=find("/Accepted Submission(s): ([\d+]*?)/", $res->body); |
|
| 107 | 107 | $this->pro['input_type']='standard input'; |
| 108 | 108 | $this->pro['output_type']='standard output'; |
| 109 | - $this->pro['description'] = cacheImage(find("/this->problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body)); |
|
| 110 | - $this->pro['input'] = find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body); |
|
| 111 | - $this->pro['output'] = find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body); |
|
| 112 | - $this->pro['sample'] = []; |
|
| 113 | - $this->pro['sample']['sample_input'] = find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body); |
|
| 114 | - $this->pro['sample']['sample_output'] = find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body); |
|
| 115 | - $this->pro['note'] = find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU",$res->body); |
|
| 116 | - $this->pro['source'] = find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU",$res->body); |
|
| 117 | - $this->pro['force_raw'] = 0; |
|
| 109 | + $this->pro['description']=cacheImage(find("/this->problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body)); |
|
| 110 | + $this->pro['input']=find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body); |
|
| 111 | + $this->pro['output']=find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body); |
|
| 112 | + $this->pro['sample']=[]; |
|
| 113 | + $this->pro['sample']['sample_input']=find("/<pre><div.*>(.*)<\/div><\/pre>/sU", $res->body); |
|
| 114 | + $this->pro['sample']['sample_output']=find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU", $res->body); |
|
| 115 | + $this->pro['note']=find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU", $res->body); |
|
| 116 | + $this->pro['source']=find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU", $res->body); |
|
| 117 | + $this->pro['force_raw']=0; |
|
| 118 | 118 | $problem=$problemModel->pid($this->pro['pcode']); |
| 119 | 119 | |
| 120 | 120 | if ($problem) { |
@@ -89,12 +89,10 @@ |
||
| 89 | 89 | if (strpos("No such problem",$res->body) !== false) { |
| 90 | 90 | header('HTTP/1.1 404 Not Found'); |
| 91 | 91 | die(); |
| 92 | - } |
|
| 93 | - else if(strpos("Invalid Parameter.",$res->body) !== false) { |
|
| 92 | + } else if(strpos("Invalid Parameter.",$res->body) !== false) { |
|
| 94 | 93 | header('HTTP/1.1 404 Not Found'); |
| 95 | 94 | die(); |
| 96 | - } |
|
| 97 | - else { |
|
| 95 | + } else { |
|
| 98 | 96 | $this->pro['pcode'] = "HDU".$con; |
| 99 | 97 | $this->pro['OJ'] = 1; |
| 100 | 98 | $this->pro['contest_id'] = null; |
@@ -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 | } |
@@ -364,7 +364,7 @@ |
||
| 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 | 369 | $sub = []; |
| 370 | 370 | $response = Request::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']); |
@@ -18,12 +18,12 @@ |
||
| 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"], |
@@ -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 | } |