Test Setup Failed
Push — master ( e2b9fb...698287 )
by
unknown
04:27
created
app/Http/Controllers/VirtualJudge/Curl.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 
13 13
     protected function login($url, $data, $oj, $ret='false')
14 14
     {
15
-        $datapost = curl_init();
16
-        $headers = array("Expect:");
15
+        $datapost=curl_init();
16
+        $headers=array("Expect:");
17 17
 
18 18
         curl_setopt($datapost, CURLOPT_CAINFO, dirname(__FILE__)."/cookie/cacert.pem");
19 19
         curl_setopt($datapost, CURLOPT_URL, $url);
20
-        curl_setopt($datapost, CURLOPT_HEADER, true);//
21
-        curl_setopt($datapost, CURLOPT_HTTPHEADER, $headers);//
20
+        curl_setopt($datapost, CURLOPT_HEADER, true); //
21
+        curl_setopt($datapost, CURLOPT_HTTPHEADER, $headers); //
22 22
         curl_setopt($datapost, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36");
23 23
         curl_setopt($datapost, CURLOPT_POST, true);
24 24
 
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
 
42 42
     protected function grab_page($site, $oj)
43 43
     {
44
-        $ch = curl_init();
44
+        $ch=curl_init();
45 45
         curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cookie/cacert.pem");
46 46
         // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
47 47
         // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
48 48
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
49 49
         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36");
50
-        curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) ."/cookie/{$oj}_cookie.txt");
50
+        curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/cookie/{$oj}_cookie.txt");
51 51
         curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/cookie/{$oj}_cookie.txt");
52 52
         curl_setopt($ch, CURLOPT_URL, $site);
53 53
         ob_start();
54
-        $response= curl_exec($ch);
54
+        $response=curl_exec($ch);
55 55
         if (curl_errno($ch)) {
56 56
             die(curl_error($ch));
57 57
         }
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
         return $response;
61 61
     }
62 62
 
63
-    protected function post_data($site, $data, $oj, $ret=false, $follow=true, $returnHeader = true, $postJson = false)
63
+    protected function post_data($site, $data, $oj, $ret=false, $follow=true, $returnHeader=true, $postJson=false)
64 64
     {
65
-        $datapost = curl_init();
66
-        $headers = array("Expect:");
65
+        $datapost=curl_init();
66
+        $headers=array("Expect:");
67 67
         if ($postJson) {
68
-            $data = $data ? json_encode($data) : '{}';
68
+            $data=$data ? json_encode($data) : '{}';
69 69
             array_push($headers, 'Content-Type: application/json', 'Content-Length: '.strlen($data));
70 70
         }
71 71
         curl_setopt($datapost, CURLOPT_CAINFO, dirname(__FILE__)."/cookie/cacert.pem");
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualJudge/PTA/PTA.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
     private function submitSolution()
30 30
     {
31
-        $compilerModel = new CompilerModel();
32
-        $lang = $compilerModel->detail($this->post_data["coid"]);
33
-        $pid = $this->post_data['iid'];
31
+        $compilerModel=new CompilerModel();
32
+        $lang=$compilerModel->detail($this->post_data["coid"]);
33
+        $pid=$this->post_data['iid'];
34 34
         $this->sub['language']=$lang['display_name'];
35 35
         $this->sub['solution']=$this->post_data["solution"];
36 36
         $this->sub['pid']=$this->post_data["pid"];
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
             $this->sub['cid']=null;
42 42
         }
43 43
 
44
-        $response = $this->post_data("https://pintia.cn/api/problem-sets/{$this->post_data['cid']}/exams", null, 'pta', true, false, false, true);
44
+        $response=$this->post_data("https://pintia.cn/api/problem-sets/{$this->post_data['cid']}/exams", null, 'pta', true, false, false, true);
45 45
 
46
-        if (strpos($response, 'PROBLEM_SET_NOT_FOUND') !== false) {
46
+        if (strpos($response, 'PROBLEM_SET_NOT_FOUND')!==false) {
47 47
             header('HTTP/1.1 404 Not Found');
48 48
             die();
49 49
         }
50
-        $generalDetails=json_decode($response,true);
51
-        $examId = $generalDetails['exam']['id'];
50
+        $generalDetails=json_decode($response, true);
51
+        $examId=$generalDetails['exam']['id'];
52 52
 
53
-        $params = [
53
+        $params=[
54 54
             'details' => [
55 55
                 [
56 56
                     'problemSetProblemId' => $this->post_data['iid'],
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
         ];
65 65
 
66 66
         $response=$this->post_data("https://pintia.cn/api/problem-sets/$examId/submissions?exam_id=".$examId, $params, 'pta', true, false, false, true);
67
-        $ret = json_decode($response, true);
67
+        $ret=json_decode($response, true);
68 68
         if (isset($ret['submissionId'])) {
69
-            $this->sub['remote_id'] = $examId.'|'.$ret['submissionId'];
69
+            $this->sub['remote_id']=$examId.'|'.$ret['submissionId'];
70 70
         } else {
71
-            $this->sub['verdict'] = 'Submission Error';
71
+            $this->sub['verdict']='Submission Error';
72 72
         }
73 73
     }
74 74
 
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualJudge/Judge.php 2 patches
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
             "COMPILATION_ERROR"=>"Compile Error",
31 31
             "RUNTIME_ERROR"=> "Runtime Error",
32 32
             "WRONG_ANSWER"=> "Wrong Answer",
33
-            "TIME_LIMIT_EXCEEDED"=>"Time Limit Exceed" ,
34
-            "OK"=>"Accepted" ,
33
+            "TIME_LIMIT_EXCEEDED"=>"Time Limit Exceed",
34
+            "OK"=>"Accepted",
35 35
             "MEMORY_LIMIT_EXCEEDED"=>"Memory Limit Exceed",
36 36
             "PRESENTATION_ERROR"=>"Presentation Error"];
37 37
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
         $result=$this->MODEL->get_wating_submission();
103 103
         $judger=new JudgerModel();
104
-        $curl = new Curl();
104
+        $curl=new Curl();
105 105
 
106 106
         $cf=$this->get_last_codeforces($this->MODEL->count_wating_submission(2));
107 107
         $poj=[];
@@ -121,115 +121,115 @@  discard block
 block discarded – undo
121 121
             if ($row['oid']==2) {
122 122
                 if (isset($codeforces_v[$cf[$i][2]])) {
123 123
 
124
-                    $sub['verdict'] = $codeforces_v[$cf[$i][2]];
125
-                    $sub["score"]=$sub['verdict']=="Accepted"?1:0;
126
-                    $sub['time'] = $cf[$i][0];
127
-                    $sub['memory'] = $cf[$i][1];
128
-                    $sub['remote_id'] = $cf[$i][3];
124
+                    $sub['verdict']=$codeforces_v[$cf[$i][2]];
125
+                    $sub["score"]=$sub['verdict']=="Accepted" ? 1 : 0;
126
+                    $sub['time']=$cf[$i][0];
127
+                    $sub['memory']=$cf[$i][1];
128
+                    $sub['remote_id']=$cf[$i][3];
129 129
 
130
-                    $ret[$row['sid']] = [
130
+                    $ret[$row['sid']]=[
131 131
                         "verdict"=>$sub['verdict']
132 132
                     ];
133 133
 
134 134
                     $this->MODEL->update_submission($row['sid'], $sub);
135 135
                 }
136 136
                 $i++;
137
-            } else if ($row['oid'] == 3) {
137
+            } else if ($row['oid']==3) {
138 138
                 try {
139
-                    $res = Requests::get('http://contest-hunter.org:83/record/'.$row['remote_id']);
139
+                    $res=Requests::get('http://contest-hunter.org:83/record/'.$row['remote_id']);
140 140
                     preg_match('/<dt>状态<\/dt>[\s\S]*?<dd class=".*?">(.*?)<\/dd>/m', $res->body, $match);
141
-                    $status = $match[1];
141
+                    $status=$match[1];
142 142
                     if (!array_key_exists($status, $contesthunter_v)) continue;
143
-                    $sub['verdict'] = $contesthunter_v[$status];
144
-                    $sub["score"]=$sub['verdict']=="Accepted"?1:0;
145
-                    $sub['remote_id'] = $row['remote_id'];
146
-                    if ($sub['verdict'] != "Submission Error" && $sub['verdict'] != "Compile Error") {
143
+                    $sub['verdict']=$contesthunter_v[$status];
144
+                    $sub["score"]=$sub['verdict']=="Accepted" ? 1 : 0;
145
+                    $sub['remote_id']=$row['remote_id'];
146
+                    if ($sub['verdict']!="Submission Error" && $sub['verdict']!="Compile Error") {
147 147
                         preg_match('/占用内存[\s\S]*?(\d+).*?KiB/m', $res->body, $match);
148
-                        $sub['memory'] = $match[1];
149
-                        $maxtime = 0;
148
+                        $sub['memory']=$match[1];
149
+                        $maxtime=0;
150 150
                         preg_match_all('/<span class="pull-right muted">(\d+) ms \/ \d+ KiB<\/span>/', $res->body, $matches);
151 151
                         foreach ($matches[1] as $time) {
152
-                            if ($time < $maxtime) $maxtime = $time;
152
+                            if ($time<$maxtime) $maxtime=$time;
153 153
                         }
154
-                        $sub['time'] = $maxtime;
154
+                        $sub['time']=$maxtime;
155 155
                     } else {
156
-                        $sub['memory'] = 0;
157
-                        $sub['time'] = 0;
156
+                        $sub['memory']=0;
157
+                        $sub['time']=0;
158 158
                     }
159 159
 
160
-                    $ret[$row['sid']] = [
160
+                    $ret[$row['sid']]=[
161 161
                         "verdict"=>$sub['verdict']
162 162
                     ];
163 163
                     $this->MODEL->update_submission($row['sid'], $sub);
164 164
                 }
165
-                catch(Exception $e) {}
166
-            } else if ($row['oid'] == 4) {
165
+                catch (Exception $e) {}
166
+            } else if ($row['oid']==4) {
167 167
                 if (!isset($poj[$row['remote_id']])) {
168 168
                     $this->appendPOJStatus($poj, $pojJudgerName, $row['remote_id']);
169 169
                     if (!isset($poj[$row['remote_id']])) continue;
170 170
                 }
171
-                $status = $poj[$row['remote_id']];
172
-                $sub['verdict'] = $poj_v[$status['verdict']];
173
-                $sub["score"]=$sub['verdict']=="Accepted"?1:0;
174
-                $sub['time'] = $status['time'];
175
-                $sub['memory'] = $status['memory'];
176
-                $sub['remote_id'] = $row['remote_id'];
177
-
178
-                $ret[$row['sid']] = [
171
+                $status=$poj[$row['remote_id']];
172
+                $sub['verdict']=$poj_v[$status['verdict']];
173
+                $sub["score"]=$sub['verdict']=="Accepted" ? 1 : 0;
174
+                $sub['time']=$status['time'];
175
+                $sub['memory']=$status['memory'];
176
+                $sub['remote_id']=$row['remote_id'];
177
+
178
+                $ret[$row['sid']]=[
179 179
                     "verdict"=>$sub['verdict']
180 180
                 ];
181 181
                 $this->MODEL->update_submission($row['sid'], $sub);
182
-            } else if ($row['oid'] == 5) {
182
+            } else if ($row['oid']==5) {
183 183
                 try {
184
-                    $res = Requests::get('https://vijos.org/records/'.$row['remote_id']);
184
+                    $res=Requests::get('https://vijos.org/records/'.$row['remote_id']);
185 185
                     preg_match('/<span class="record-status--text \w*">\s*(.*?)\s*<\/span>/', $res->body, $match);
186
-                    $status = $match[1];
186
+                    $status=$match[1];
187 187
                     if (!array_key_exists($status, $vijos_v)) continue;
188
-                    $sub['verdict'] = $vijos_v[$status];
188
+                    $sub['verdict']=$vijos_v[$status];
189 189
                     preg_match('/<dt>分数<\/dt>\s*<dd>(\d+)<\/dd>/', $res->body, $match);
190
-                    $sub['score'] = $match[1];
191
-                    if ($sub['verdict'] == "Wrong Answer" && $sub['score'] != 0) $sub['verdict'] = 'Partially Accepted';
192
-                    $sub['remote_id'] = $row['remote_id'];
193
-                    if ($sub['verdict'] != "Submission Error" && $sub['verdict'] != "Compile Error") {
194
-                        $maxtime = 0;
190
+                    $sub['score']=$match[1];
191
+                    if ($sub['verdict']=="Wrong Answer" && $sub['score']!=0) $sub['verdict']='Partially Accepted';
192
+                    $sub['remote_id']=$row['remote_id'];
193
+                    if ($sub['verdict']!="Submission Error" && $sub['verdict']!="Compile Error") {
194
+                        $maxtime=0;
195 195
                         preg_match_all('/<td class="col--time">(?:&ge;)?(\d+)ms<\/td>/', $res->body, $matches);
196 196
                         foreach ($matches as $match) {
197
-                            if ($match[1] > $maxtime) $maxtime = $match[1];
197
+                            if ($match[1]>$maxtime) $maxtime=$match[1];
198 198
                         }
199
-                        $sub['time'] = $maxtime;
199
+                        $sub['time']=$maxtime;
200 200
                         preg_match('/<dt>峰值内存<\/dt>\s*<dd>(?:&ge;)?([\d.]+) ([KM])iB<\/dd>/', $res->body, $match);
201
-                        $memory = $match[1];
202
-                        if ($match[2] == 'M') $memory *= 1024;
203
-                        $sub['memory'] = intval($memory);
201
+                        $memory=$match[1];
202
+                        if ($match[2]=='M') $memory*=1024;
203
+                        $sub['memory']=intval($memory);
204 204
                     } else {
205
-                        $sub['memory'] = 0;
206
-                        $sub['time'] = 0;
205
+                        $sub['memory']=0;
206
+                        $sub['time']=0;
207 207
                     }
208 208
 
209
-                    $ret[$row['sid']] = [
209
+                    $ret[$row['sid']]=[
210 210
                         "verdict"=>$sub['verdict']
211 211
                     ];
212 212
                     $this->MODEL->update_submission($row['sid'], $sub);
213 213
                 }
214
-                catch(Exception $e) {}
215
-            } else if ($row['oid'] == 6) {
214
+                catch (Exception $e) {}
215
+            } else if ($row['oid']==6) {
216 216
                 try {
217
-                    $remoteId = explode('|', $row['remote_id']);
218
-                    $response = $curl->grab_page("https://pintia.cn/api/problem-sets/$remoteId[0]/submissions/".$remoteId[1], 'pta');
219
-                    $data = json_decode($response, true);
217
+                    $remoteId=explode('|', $row['remote_id']);
218
+                    $response=$curl->grab_page("https://pintia.cn/api/problem-sets/$remoteId[0]/submissions/".$remoteId[1], 'pta');
219
+                    $data=json_decode($response, true);
220 220
                     if (!isset($pta_v[$data['submission']['status']])) continue;
221
-                    $sub['verdict'] = $pta_v[$data['submission']['status']];
222
-                    $sub['score'] = $data['submission']['score'];
223
-                    $sub['remote_id'] = $row['remote_id'];
224
-                    $sub['memory'] = $data['submission']['memory'] / 1024;
225
-                    $sub['time'] = $data['submission']['time'] * 1000;
221
+                    $sub['verdict']=$pta_v[$data['submission']['status']];
222
+                    $sub['score']=$data['submission']['score'];
223
+                    $sub['remote_id']=$row['remote_id'];
224
+                    $sub['memory']=$data['submission']['memory'] / 1024;
225
+                    $sub['time']=$data['submission']['time'] * 1000;
226 226
 
227
-                    $ret[$row['sid']] = [
227
+                    $ret[$row['sid']]=[
228 228
                         "verdict"=>$sub['verdict']
229 229
                     ];
230 230
                     $this->MODEL->update_submission($row['sid'], $sub);
231 231
                 }
232
-                catch(Exception $e) {}
232
+                catch (Exception $e) {}
233 233
             }
234 234
             // if ($row['oid']=='Spoj') {
235 235
             //     if (isset($spoj_v[$sj[$j][2]])) {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             return $ret;
282 282
         }
283 283
         $response=$this->grab_page('https://uva.onlinejudge.org', 'uva');
284
-        if (!(strpos($response, 'UVa Online Judge - Offline') !== false)) {
284
+        if (!(strpos($response, 'UVa Online Judge - Offline')!==false)) {
285 285
             $this->uva_live_login('https://uva.onlinejudge.org', 'https://uva.onlinejudge.org/index.php?option=com_comprofiler&task=login', 'uva');
286 286
         } else {
287 287
             return $ret;
@@ -291,24 +291,24 @@  discard block
 block discarded – undo
291 291
         while (true) {
292 292
             $response=$this->grab_page("https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9&limit=50&limitstart={$i}", 'uva');
293 293
 
294
-            $exploded = explode('<table cellpadding="4" cellspacing="0" border="0" width="100%">', $response);
295
-            $table = explode('</table>', $exploded[1])[0];
294
+            $exploded=explode('<table cellpadding="4" cellspacing="0" border="0" width="100%">', $response);
295
+            $table=explode('</table>', $exploded[1])[0];
296 296
 
297
-            $table = explode('<tr class="sectiontableentry', $table);
297
+            $table=explode('<tr class="sectiontableentry', $table);
298 298
 
299
-            for ($j=1;$j<count($table);$j++) {
299
+            for ($j=1; $j<count($table); $j++) {
300 300
                 $num--;
301 301
                 $sub=$table[$j];
302 302
 
303
-                $sub = explode('<td>', $sub);
303
+                $sub=explode('<td>', $sub);
304 304
                 $verdict=explode('</td>', $sub[3])[0];
305 305
                 $time=explode('</td>', $sub[5])[0];
306 306
 
307
-                if ((strpos($verdict, '<a href=') !== false)) {
307
+                if ((strpos($verdict, '<a href=')!==false)) {
308 308
                     $verdict=explode('</a', explode('>', explode('<a href=', $verdict)[1])[1])[0];
309 309
                 }
310 310
 
311
-                array_push($ret, array($time*1000,-1,$verdict));
311
+                array_push($ret, array($time * 1000, -1, $verdict));
312 312
 
313 313
                 if ($num==0) {
314 314
                     return array_reverse($ret);
@@ -338,24 +338,24 @@  discard block
 block discarded – undo
338 338
         while (true) {
339 339
             $response=$this->grab_page("https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=9&limit=50&limitstart={$i}", 'uvalive');
340 340
 
341
-            $exploded = explode('<table cellpadding="4" cellspacing="0" border="0" width="100%">', $response);
342
-            $table = explode('</table>', $exploded[1])[0];
341
+            $exploded=explode('<table cellpadding="4" cellspacing="0" border="0" width="100%">', $response);
342
+            $table=explode('</table>', $exploded[1])[0];
343 343
 
344
-            $table = explode('<tr class="sectiontableentry', $table);
344
+            $table=explode('<tr class="sectiontableentry', $table);
345 345
 
346
-            for ($j=1;$j<count($table);$j++) {
346
+            for ($j=1; $j<count($table); $j++) {
347 347
                 $num--;
348 348
                 $sub=$table[$j];
349 349
 
350
-                $sub = explode('<td>', $sub);
350
+                $sub=explode('<td>', $sub);
351 351
                 $verdict=explode('</td>', $sub[3])[0];
352 352
                 $time=explode('</td>', $sub[5])[0];
353 353
 
354
-                if ((strpos($verdict, '<a href=') !== false)) {
354
+                if ((strpos($verdict, '<a href=')!==false)) {
355 355
                     $verdict=explode('</a', explode('>', explode('<a href=', $verdict)[1])[1])[0];
356 356
                 }
357 357
 
358
-                array_push($ret, array($time*1000,-1,$verdict));
358
+                array_push($ret, array($time * 1000, -1, $verdict));
359 359
 
360 360
                 if ($num==0) {
361 361
                     return array_reverse($ret);
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
         curl_close($ch);
389 389
         $result=json_decode($response, true);
390 390
         if ($result["status"]=="OK") {
391
-            for ($i=0;$i<$num;$i++) {
391
+            for ($i=0; $i<$num; $i++) {
392 392
                 if (!isset($result["result"][$i]["verdict"])) {
393 393
                     return array_reverse($ret);
394 394
                 }
395
-                array_push($ret, array($result["result"][$i]["timeConsumedMillis"],$result["result"][$i]["memoryConsumedBytes"]/1000,$result["result"][$i]["verdict"],$result["result"][$i]["id"]));
395
+                array_push($ret, array($result["result"][$i]["timeConsumedMillis"], $result["result"][$i]["memoryConsumedBytes"] / 1000, $result["result"][$i]["verdict"], $result["result"][$i]["id"]));
396 396
             }
397 397
         }
398 398
         return array_reverse($ret);
@@ -417,22 +417,22 @@  discard block
 block discarded – undo
417 417
             $response=file_get_contents("http://www.spoj.com/status/our_judge/all/start={$i}");
418 418
 
419 419
 
420
-            $exploded = explode('<table class="problems table newstatus">', $response);
421
-            $table = explode('</table>', $exploded[1])[0];
420
+            $exploded=explode('<table class="problems table newstatus">', $response);
421
+            $table=explode('</table>', $exploded[1])[0];
422 422
 
423
-            $table = explode('<td class="statustext text-center">', $table);
423
+            $table=explode('<td class="statustext text-center">', $table);
424 424
 
425
-            for ($j=1;$j<count($table);$j++) {
425
+            for ($j=1; $j<count($table); $j++) {
426 426
                 $num--;
427 427
                 $sub=$table[$j];
428 428
 
429 429
 
430 430
                 $verdict=explode('</td>', explode('manual="0">', explode('<td class="statusres text-center"', $sub)[1])[1])[0];
431
-                if ((strpos($verdict, '<strong>') !== false)) {
431
+                if ((strpos($verdict, '<strong>')!==false)) {
432 432
                     $verdict=explode('</strong>', explode('<strong>', $verdict)[1])[0];
433 433
                 }
434 434
 
435
-                if ((strpos($verdict, '(') !== false)) {
435
+                if ((strpos($verdict, '(')!==false)) {
436 436
                     $verdict=explode('(', $verdict)[0];
437 437
                 }
438 438
                 if (is_numeric(trim($verdict))) {
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
                     $memory=substr($memory, 0, strlen($memory)-1);
454 454
                 }
455 455
 
456
-                array_push($ret, array($time*1000,$memory*1000,trim($verdict)));
456
+                array_push($ret, array($time * 1000, $memory * 1000, trim($verdict)));
457 457
                 if ($num==0) {
458 458
                     return array_reverse($ret);
459 459
                 }
@@ -462,13 +462,13 @@  discard block
 block discarded – undo
462 462
         }
463 463
     }
464 464
 
465
-    private function appendPOJStatus(&$results, $judger, $first = null)
465
+    private function appendPOJStatus(&$results, $judger, $first=null)
466 466
     {
467
-        if ($first !== null) $first++;
468
-        $res = Requests::get("http://poj.org/status?user_id={$judger}&top={$first}");
469
-        $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);
470
-        for ($i = 0; $i < $rows; $i++) {
471
-            $results[$matches[1][$i]] = [
467
+        if ($first!==null) $first++;
468
+        $res=Requests::get("http://poj.org/status?user_id={$judger}&top={$first}");
469
+        $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);
470
+        for ($i=0; $i<$rows; $i++) {
471
+            $results[$matches[1][$i]]=[
472 472
                 'verdict'=>$matches[2][$i],
473 473
                 'memory'=>$matches[3][$i] ? $matches[3][$i] : 0,
474 474
                 'time'=>$matches[4][$i] ? $matches[4][$i] : 0,
Please login to merge, or discard this patch.
Braces   +33 added lines, -16 removed lines patch added patch discarded remove patch
@@ -108,7 +108,9 @@  discard block
 block discarded – undo
108 108
 
109 109
         $pojJudgerList=$judger->list(4);
110 110
         $pojJudgerName=urlencode($pojJudgerList[0]["handle"]);
111
-        if ($this->MODEL->count_wating_submission(5)) $this->appendPOJStatus($poj, $pojJudgerName);
111
+        if ($this->MODEL->count_wating_submission(5)) {
112
+            $this->appendPOJStatus($poj, $pojJudgerName);
113
+        }
112 114
         // $uva=$this->get_last_uva($this->MODEL->count_wating_submission('Uva'));
113 115
         // $uval=$this->get_last_uvalive($this->MODEL->count_wating_submission('UvaLive'));
114 116
         // $sj=$this->get_last_spoj($this->MODEL->count_wating_submission('Spoj'));
@@ -139,7 +141,9 @@  discard block
 block discarded – undo
139 141
                     $res = Requests::get('http://contest-hunter.org:83/record/'.$row['remote_id']);
140 142
                     preg_match('/<dt>状态<\/dt>[\s\S]*?<dd class=".*?">(.*?)<\/dd>/m', $res->body, $match);
141 143
                     $status = $match[1];
142
-                    if (!array_key_exists($status, $contesthunter_v)) continue;
144
+                    if (!array_key_exists($status, $contesthunter_v)) {
145
+                        continue;
146
+                    }
143 147
                     $sub['verdict'] = $contesthunter_v[$status];
144 148
                     $sub["score"]=$sub['verdict']=="Accepted"?1:0;
145 149
                     $sub['remote_id'] = $row['remote_id'];
@@ -149,7 +153,9 @@  discard block
 block discarded – undo
149 153
                         $maxtime = 0;
150 154
                         preg_match_all('/<span class="pull-right muted">(\d+) ms \/ \d+ KiB<\/span>/', $res->body, $matches);
151 155
                         foreach ($matches[1] as $time) {
152
-                            if ($time < $maxtime) $maxtime = $time;
156
+                            if ($time < $maxtime) {
157
+                                $maxtime = $time;
158
+                            }
153 159
                         }
154 160
                         $sub['time'] = $maxtime;
155 161
                     } else {
@@ -161,12 +167,13 @@  discard block
 block discarded – undo
161 167
                         "verdict"=>$sub['verdict']
162 168
                     ];
163 169
                     $this->MODEL->update_submission($row['sid'], $sub);
164
-                }
165
-                catch(Exception $e) {}
170
+                } catch(Exception $e) {}
166 171
             } else if ($row['oid'] == 4) {
167 172
                 if (!isset($poj[$row['remote_id']])) {
168 173
                     $this->appendPOJStatus($poj, $pojJudgerName, $row['remote_id']);
169
-                    if (!isset($poj[$row['remote_id']])) continue;
174
+                    if (!isset($poj[$row['remote_id']])) {
175
+                        continue;
176
+                    }
170 177
                 }
171 178
                 $status = $poj[$row['remote_id']];
172 179
                 $sub['verdict'] = $poj_v[$status['verdict']];
@@ -184,22 +191,30 @@  discard block
 block discarded – undo
184 191
                     $res = Requests::get('https://vijos.org/records/'.$row['remote_id']);
185 192
                     preg_match('/<span class="record-status--text \w*">\s*(.*?)\s*<\/span>/', $res->body, $match);
186 193
                     $status = $match[1];
187
-                    if (!array_key_exists($status, $vijos_v)) continue;
194
+                    if (!array_key_exists($status, $vijos_v)) {
195
+                        continue;
196
+                    }
188 197
                     $sub['verdict'] = $vijos_v[$status];
189 198
                     preg_match('/<dt>分数<\/dt>\s*<dd>(\d+)<\/dd>/', $res->body, $match);
190 199
                     $sub['score'] = $match[1];
191
-                    if ($sub['verdict'] == "Wrong Answer" && $sub['score'] != 0) $sub['verdict'] = 'Partially Accepted';
200
+                    if ($sub['verdict'] == "Wrong Answer" && $sub['score'] != 0) {
201
+                        $sub['verdict'] = 'Partially Accepted';
202
+                    }
192 203
                     $sub['remote_id'] = $row['remote_id'];
193 204
                     if ($sub['verdict'] != "Submission Error" && $sub['verdict'] != "Compile Error") {
194 205
                         $maxtime = 0;
195 206
                         preg_match_all('/<td class="col--time">(?:&ge;)?(\d+)ms<\/td>/', $res->body, $matches);
196 207
                         foreach ($matches as $match) {
197
-                            if ($match[1] > $maxtime) $maxtime = $match[1];
208
+                            if ($match[1] > $maxtime) {
209
+                                $maxtime = $match[1];
210
+                            }
198 211
                         }
199 212
                         $sub['time'] = $maxtime;
200 213
                         preg_match('/<dt>峰值内存<\/dt>\s*<dd>(?:&ge;)?([\d.]+) ([KM])iB<\/dd>/', $res->body, $match);
201 214
                         $memory = $match[1];
202
-                        if ($match[2] == 'M') $memory *= 1024;
215
+                        if ($match[2] == 'M') {
216
+                            $memory *= 1024;
217
+                        }
203 218
                         $sub['memory'] = intval($memory);
204 219
                     } else {
205 220
                         $sub['memory'] = 0;
@@ -210,14 +225,15 @@  discard block
 block discarded – undo
210 225
                         "verdict"=>$sub['verdict']
211 226
                     ];
212 227
                     $this->MODEL->update_submission($row['sid'], $sub);
213
-                }
214
-                catch(Exception $e) {}
228
+                } catch(Exception $e) {}
215 229
             } else if ($row['oid'] == 6) {
216 230
                 try {
217 231
                     $remoteId = explode('|', $row['remote_id']);
218 232
                     $response = $curl->grab_page("https://pintia.cn/api/problem-sets/$remoteId[0]/submissions/".$remoteId[1], 'pta');
219 233
                     $data = json_decode($response, true);
220
-                    if (!isset($pta_v[$data['submission']['status']])) continue;
234
+                    if (!isset($pta_v[$data['submission']['status']])) {
235
+                        continue;
236
+                    }
221 237
                     $sub['verdict'] = $pta_v[$data['submission']['status']];
222 238
                     $sub['score'] = $data['submission']['score'];
223 239
                     $sub['remote_id'] = $row['remote_id'];
@@ -228,8 +244,7 @@  discard block
 block discarded – undo
228 244
                         "verdict"=>$sub['verdict']
229 245
                     ];
230 246
                     $this->MODEL->update_submission($row['sid'], $sub);
231
-                }
232
-                catch(Exception $e) {}
247
+                } catch(Exception $e) {}
233 248
             }
234 249
             // if ($row['oid']=='Spoj') {
235 250
             //     if (isset($spoj_v[$sj[$j][2]])) {
@@ -464,7 +479,9 @@  discard block
 block discarded – undo
464 479
 
465 480
     private function appendPOJStatus(&$results, $judger, $first = null)
466 481
     {
467
-        if ($first !== null) $first++;
482
+        if ($first !== null) {
483
+            $first++;
484
+        }
468 485
         $res = Requests::get("http://poj.org/status?user_id={$judger}&top={$first}");
469 486
         $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);
470 487
         for ($i = 0; $i < $rows; $i++) {
Please login to merge, or discard this patch.