From 847b66fc701de31429363c019d3559d124403513 Mon Sep 17 00:00:00 2001 From: ZsgsDesign Date: Thu, 21 Oct 2021 20:07:09 +0800 Subject: [PATCH] update to 0.17.0 of NOJ adding timeout of 30 seconds --- Judger.php | 8 ++++++-- babel.json | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Judger.php b/Judger.php index 6641800..50ec38a 100644 --- a/Judger.php +++ b/Judger.php @@ -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('/
([\s\S]*)<\/pre>/', $res->body, $match);
                 $sub['compile_info']=html_entity_decode($match[1], ENT_QUOTES);
             } catch (Exception $e) {
@@ -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('/(\d+)<\/td>.*?<\/td>.*?<\/td>.*?(.*?)<\/font>.*?<\/td>(\d*)K?<\/td>(\d*)(?:MS)?<\/td>/', $res->body, $matches);
         for ($i=0; $i<$rows; $i++) {
             $this->poj[$matches[1][$i]]=[
diff --git a/babel.json b/babel.json
index b1f88c9..0e58572 100644
--- a/babel.json
+++ b/babel.json
@@ -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"
@@ -18,6 +18,6 @@
         "installer":"Installer"
     },
     "require":{
-        "NOJ":"^0.3.0"
+        "NOJ":"^0.17.0"
     }
 }