Skip to content

Commit

Permalink
fixing time out bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsgsDesign committed Oct 21, 2021
1 parent 847b66f commit ed88818
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions Judger.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public function judge($row)

if ($sub['verdict']=='Compile Error') {
try {
$res=Requests::get('http://poj.org/showcompileinfo?solution_id='.$row['remote_id'], [], [
'timeout' => 30
]);
$res=Requests::get('http://poj.org/showcompileinfo?solution_id='.$row['remote_id']);
preg_match('/<pre>([\s\S]*)<\/pre>/', $res->body, $match);
$sub['compile_info']=html_entity_decode($match[1], ENT_QUOTES);
} catch (Exception $e) {
Expand All @@ -76,10 +74,14 @@ private function appendPOJStatus($judger, $first=null)
if ($first!==null) {
$first++;
}
$res=Requests::get("http://poj.org/status?user_id={$judger}&top={$first}", [], [
'timeout' => 30
$res = $this->grab_page([
'site' => "http://poj.org/status?user_id={$judger}&top={$first}",
'oj' => 'poj',
'handle' => $judger,
]);
$rows=preg_match_all('/<tr align=center><td>(\d+)<\/td><td>.*?<\/td><td>.*?<\/td><td>.*?<font color=.*?>(.*?)<\/font>.*?<\/td><td>(\d*)K?<\/td><td>(\d*)(?:MS)?<\/td>/', $res->body, $matches);
// Timed out for no reason
// $res=Requests::get("http://poj.org/status?user_id={$judger}&top={$first}");
$rows=preg_match_all('/<tr align=center><td>(\d+)<\/td><td>.*?<\/td><td>.*?<\/td><td>.*?<font color=.*?>(.*?)<\/font>.*?<\/td><td>(\d*)K?<\/td><td>(\d*)(?:MS)?<\/td>/', $res, $matches);
for ($i=0; $i<$rows; $i++) {
$this->poj[$matches[1][$i]]=[
'verdict'=>$matches[2][$i],
Expand Down
2 changes: 1 addition & 1 deletion babel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "POJ Interface for NOJ",
"license": "MIT",
"repository":"https://github.com/NJUPTAAA/NOJ_Extension_POJ",
"version":"0.1.5",
"version":"0.2.0",
"website":"http://poj.org/",
"custom":{
"css":"resources/custom.css"
Expand Down

0 comments on commit ed88818

Please sign in to comment.