Skip to content

Commit

Permalink
update to 0.17.0 of NOJ adding timeout of 30 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsgsDesign committed Oct 21, 2021
1 parent f5b2e71 commit 847b66f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Judger.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public function judge($row)

if ($sub['verdict']=='Compile Error') {
try {
$res=Requests::get('http://poj.org/showcompileinfo?solution_id='.$row['remote_id']);
$res=Requests::get('http://poj.org/showcompileinfo?solution_id='.$row['remote_id'], [], [
'timeout' => 30
]);
preg_match('/<pre>([\s\S]*)<\/pre>/', $res->body, $match);
$sub['compile_info']=html_entity_decode($match[1], ENT_QUOTES);
} catch (Exception $e) {
Expand All @@ -74,7 +76,9 @@ private function appendPOJStatus($judger, $first=null)
if ($first!==null) {
$first++;
}
$res=Requests::get("http://poj.org/status?user_id={$judger}&top={$first}");
$res=Requests::get("http://poj.org/status?user_id={$judger}&top={$first}", [], [
'timeout' => 30
]);
$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);
for ($i=0; $i<$rows; $i++) {
$this->poj[$matches[1][$i]]=[
Expand Down
4 changes: 2 additions & 2 deletions 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.4",
"version":"0.1.5",
"website":"http://poj.org/",
"custom":{
"css":"resources/custom.css"
Expand All @@ -18,6 +18,6 @@
"installer":"Installer"
},
"require":{
"NOJ":"^0.3.0"
"NOJ":"^0.17.0"
}
}

0 comments on commit 847b66f

Please sign in to comment.