Passed
Push — master ( bc03d4...3c12ae )
by Chenyi
07:50 queued 03:46
created
app/Models/ContestModel.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
         //     "gid"=>$gid
124 124
         // ])->orderBy('begin_time', 'desc')->get()->all();
125 125
         $preQuery=DB::table($this->tableName);
126
-        $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10);
126
+        $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10);
127 127
         $contest_list=$paginator->all();
128
-        if(empty($contest_list)){
128
+        if (empty($contest_list)) {
129 129
             return null;
130 130
         }
131 131
 
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
161 161
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
162 162
                 ->where(
163
-                    function ($query) {
163
+                    function($query) {
164 164
                         $query->where('public', 1)
165 165
                               ->where('audit_status', 1);
166 166
                     }
167 167
                 )
168 168
                 ->orWhere(
169
-                    function ($query) use ($uid) {
169
+                    function($query) use ($uid) {
170 170
                         $query->where('group_member.uid', $uid)
171 171
                                 ->where('group_member.role', '>', 0);
172 172
                             //     ->where(function ($query) use ($uid) {
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
         }
232 232
     }
233 233
 
234
-    public function registContest($cid,$uid)
234
+    public function registContest($cid, $uid)
235 235
     {
236 236
         $registered=DB::table("contest_participant")->where([
237 237
             "cid"=>$cid,
238 238
             "uid"=>$uid
239 239
         ])->first();
240 240
 
241
-        if(empty($registered)){
241
+        if (empty($registered)) {
242 242
             DB::table("contest_participant")->insert([
243 243
                 "cid"=>$cid,
244 244
                 "uid"=>$uid,
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
                     "problem_detail" => $prob_detail
540 540
                 ];
541 541
             }
542
-            usort($ret, function ($a, $b) {
542
+            usort($ret, function($a, $b) {
543 543
                 if ($a["score"]==$b["score"]) {
544 544
                     if ($a["penalty"]==$b["penalty"]) {
545 545
                         return 0;
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
                     "problem_detail" => $prob_detail
587 587
                 ];
588 588
             }
589
-            usort($ret, function ($a, $b) {
589
+            usort($ret, function($a, $b) {
590 590
                 if ($a["score"]==$b["score"]) {
591 591
                     if ($a["solved"]==$b["solved"]) {
592 592
                         return 0;
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     {
680 680
         return DB::table("contest_clarification")->where([
681 681
             "cid"=>$cid
682
-        ])->where(function ($query) {
682
+        ])->where(function($query) {
683 683
             $query->where([
684 684
                 "public"=>1
685 685
             ])->orWhere([
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
                 "users.id",
828 828
                 "=",
829 829
                 "submission.uid"
830
-            )->where(function ($query) use ($frozen_time) {
830
+            )->where(function($query) use ($frozen_time) {
831 831
                 $query->where(
832 832
                     "submission_date",
833 833
                     "<",
@@ -1020,12 +1020,12 @@  discard block
 block discarded – undo
1020 1020
     public function updateProfessionalRate($cid)
1021 1021
     {
1022 1022
         $basic=$this->basic($cid);
1023
-        if($basic["rated"]&&!$basic["is_rated"]){
1023
+        if ($basic["rated"] && !$basic["is_rated"]) {
1024 1024
             $ratingCalculator=new RatingCalculator($cid);
1025
-            if($ratingCalculator->calculate()){
1025
+            if ($ratingCalculator->calculate()) {
1026 1026
                 $ratingCalculator->storage();
1027 1027
                 return true;
1028
-            }else{
1028
+            } else {
1029 1029
                 return false;
1030 1030
             }
1031 1031
         } else {
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
     public function arrangeContest($gid, $config, $problems)
1037 1037
     {
1038
-        DB::transaction(function () use ($gid, $config, $problems) {
1038
+        DB::transaction(function() use ($gid, $config, $problems) {
1039 1039
             $cid=DB::table($this->tableName)->insertGetId([
1040 1040
                 "gid"=>$gid,
1041 1041
                 "name"=>$config["name"],
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualJudge/HDU/HDU.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
         $this->post_data=$all_data;
20 20
         $judger=new JudgerModel();
21 21
         $judger_list=$judger->list(8);
22
-        $this->judgerAccount = $judger_list[array_rand($judger_list)];
22
+        $this->judgerAccount=$judger_list[array_rand($judger_list)];
23 23
     }
24 24
 
25 25
     private function hduLogin()
26 26
     {
27
-        $response=$this->grab_page('http://acm.hdu.edu.cn','hdu', [], $this->judgerAccount["handle"]);
27
+        $response=$this->grab_page('http://acm.hdu.edu.cn', 'hdu', [], $this->judgerAccount["handle"]);
28 28
         if (strpos($response, 'Sign In')!==false) {
29 29
             $params=[
30 30
                 'username' => $this->judgerAccount["handle"],
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
         $response=$this->post_data("http://acm.hdu.edu.cn/submit.php?action=submit", http_build_query($params), "hdu", true, false, true, false, [], $this->judgerAccount['handle']);
48 48
         // Log::debug($response);
49
-        $this->sub['jid'] = $this->judgerAccount['jid'];
49
+        $this->sub['jid']=$this->judgerAccount['jid'];
50 50
         $res=Requests::get('http://acm.hdu.edu.cn/status.php?user='.$this->judgerAccount['handle'].'&pid='.$this->post_data['iid']);
51 51
         if (!preg_match("/<td height=22px>([\s\S]*?)<\/td>/", $res->body, $match)) {
52 52
                 $this->sub['verdict']='Submission Error';
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualJudge/Core.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@
 block discarded – undo
61 61
             $UVa->submit();
62 62
         }
63 63
 
64
-        if($oj=='hdu') {
65
-            $HDU = new HDU($sub, $all_data);
64
+        if ($oj=='hdu') {
65
+            $HDU=new HDU($sub, $all_data);
66 66
             $HDU->submit();
67 67
         }
68 68
 
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualCrawler/HDU/HDU.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -80,53 +80,53 @@
 block discarded – undo
80 80
 
81 81
     public function crawler($con)
82 82
     {
83
-        if($con == "all") {
84
-            return ;
83
+        if ($con=="all") {
84
+            return;
85 85
         }
86
-        $this->con = $con;
87
-        $this->imgi = 1;
88
-        $problemModel = new ProblemModel();
89
-        $res = Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}");
90
-        if (strpos("No such problem",$res->body) !== false) {
86
+        $this->con=$con;
87
+        $this->imgi=1;
88
+        $problemModel=new ProblemModel();
89
+        $res=Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}");
90
+        if (strpos("No such problem", $res->body)!==false) {
91 91
             header('HTTP/1.1 404 Not Found');
92 92
             die();
93 93
         }
94
-        else if(strpos("Invalid Parameter.",$res->body) !== false) {
94
+        else if (strpos("Invalid Parameter.", $res->body)!==false) {
95 95
             header('HTTP/1.1 404 Not Found');
96 96
             die();
97 97
         }
98 98
         else {
99
-            $res->body = iconv("gb2312","utf-8//IGNORE",$res->body);
100
-            $this->pro['pcode'] = "HDU".$con;
101
-            $this->pro['OJ'] = 8;
102
-            $this->pro['contest_id'] = null;
103
-            $this->pro['index_id'] = $con;
104
-            $this->pro['origin'] = "http://acm.hdu.edu.cn/showproblem.php?pid={$con}";
105
-            $this->pro['title'] = self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/",$res->body);
106
-            $this->pro['time_limit'] = self::find('/Time Limit:.*\/(.*) MS/',$res->body);
107
-            $this->pro['memory_limit'] = self::find('/Memory Limit:.*\/(.*) K/',$res->body);
108
-            $this->pro['solved_count'] = self::find("/Accepted Submission(s): ([\d+]*?)/",$res->body);
99
+            $res->body=iconv("gb2312", "utf-8//IGNORE", $res->body);
100
+            $this->pro['pcode']="HDU".$con;
101
+            $this->pro['OJ']=8;
102
+            $this->pro['contest_id']=null;
103
+            $this->pro['index_id']=$con;
104
+            $this->pro['origin']="http://acm.hdu.edu.cn/showproblem.php?pid={$con}";
105
+            $this->pro['title']=self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/", $res->body);
106
+            $this->pro['time_limit']=self::find('/Time Limit:.*\/(.*) MS/', $res->body);
107
+            $this->pro['memory_limit']=self::find('/Memory Limit:.*\/(.*) K/', $res->body);
108
+            $this->pro['solved_count']=self::find("/Accepted Submission(s): ([\d+]*?)/", $res->body);
109 109
             $this->pro['input_type']='standard input';
110 110
             $this->pro['output_type']='standard output';
111
-            $this->pro['description'] = $this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body), true, true, DEFAULT_TARGET_CHARSET, false));
111
+            $this->pro['description']=$this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body), true, true, DEFAULT_TARGET_CHARSET, false));
112 112
             $this->pro['description']=str_replace("$", "$$", $this->pro['description']);
113
-            $this->pro['input'] = self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body);
113
+            $this->pro['input']=self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body);
114 114
             $this->pro['input']=str_replace("$", "$$", $this->pro['input']);
115
-            $this->pro['output'] = self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body);
115
+            $this->pro['output']=self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body);
116 116
             $this->pro['output']=str_replace("$", "$$", $this->pro['output']);
117
-            $this->pro['sample'] = [];
118
-            $this->pro['sample'][] = [
119
-                'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body),
120
-                'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body)
117
+            $this->pro['sample']=[];
118
+            $this->pro['sample'][]=[
119
+                'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU", $res->body),
120
+                'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU", $res->body)
121 121
             ];
122 122
             // $this->pro['sample']['sample_input'] = self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body);
123 123
             // $this->pro['sample']['sample_output'] = self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body);
124
-            $this->pro['note'] = self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU",$res->body);
125
-            $this->pro['source'] = strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU",$res->body));
126
-            if($this->pro['source'] === "") {
127
-                $this->pro['source'] = $this->pro['pcode'];
124
+            $this->pro['note']=self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU", $res->body);
125
+            $this->pro['source']=strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU", $res->body));
126
+            if ($this->pro['source']==="") {
127
+                $this->pro['source']=$this->pro['pcode'];
128 128
             }
129
-            $this->pro['force_raw'] = 0;
129
+            $this->pro['force_raw']=0;
130 130
             $problem=$problemModel->pid($this->pro['pcode']);
131 131
 
132 132
             if ($problem) {
Please login to merge, or discard this patch.
app/Http/Controllers/MainController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,11 +56,11 @@
 block discarded – undo
56 56
     public function oldRedirect(Request $request)
57 57
     {
58 58
         $all_data=$request->all();
59
-        $method=isset($all_data["method"])?$all_data["method"]:null;
60
-        $id=isset($all_data["id"])?$all_data["id"]:null;
61
-        if($method=="showdetail" && !is_null($id)){
59
+        $method=isset($all_data["method"]) ? $all_data["method"] : null;
60
+        $id=isset($all_data["id"]) ? $all_data["id"] : null;
61
+        if ($method=="showdetail" && !is_null($id)) {
62 62
             $problemModel=new ProblemModel();
63
-            return ($problemModel->existPCode("NOJ$id"))?Redirect::route('problem_detail', ['pcode' => "NOJ$id"]):Redirect::route('problem_index');
63
+            return ($problemModel->existPCode("NOJ$id")) ?Redirect::route('problem_detail', ['pcode' => "NOJ$id"]) : Redirect::route('problem_index');
64 64
         }
65 65
         return Redirect::route('home');
66 66
     }
Please login to merge, or discard this patch.
app/Console/Commands/upgrade.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @var string
13 13
      */
14
-    protected $signature = 'upgrade';
14
+    protected $signature='upgrade';
15 15
 
16 16
     /**
17 17
      * The console command description.
18 18
      *
19 19
      * @var string
20 20
      */
21
-    protected $description = 'Upgrade to the Latest of NOJ';
21
+    protected $description='Upgrade to the Latest of NOJ';
22 22
 
23 23
     /**
24 24
      * Create a new command instance.
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function handle()
39 39
     {
40
-        $bar = $this->output->createProgressBar(8);
40
+        $bar=$this->output->createProgressBar(8);
41 41
         $bar->setFormat("%current%/%max% [%bar%] %percent:3s%%\n<info>%message%</info>");
42 42
 
43 43
         $bar->setMessage("Enable Maintenance Mode.");
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualJudge/Judge.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
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",
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
                 } catch (Exception $e) {
346 346
                 }
347 347
             } elseif ($row['oid']==7 || $row['oid']==9) {
348
-                $host = [7=>'uva.onlinejudge.org', 9=>'icpcarchive.ecs.baylor.edu'][$row['oid']];
349
-                $handle = [7=>'uva', 9=>'uvalive'][$row['oid']];
350
-                $list = [7=>$uvaList, 9=>$uvalList][$row['oid']];
348
+                $host=[7=>'uva.onlinejudge.org', 9=>'icpcarchive.ecs.baylor.edu'][$row['oid']];
349
+                $handle=[7=>'uva', 9=>'uvalive'][$row['oid']];
350
+                $list=[7=>$uvaList, 9=>$uvalList][$row['oid']];
351 351
                 var_dump($host);
352 352
                 var_dump($handle);
353 353
                 var_dump($list);
@@ -372,23 +372,23 @@  discard block
 block discarded – undo
372 372
                     ];
373 373
                     $this->MODEL->updateSubmission($row['sid'], $sub);
374 374
                 }
375
-            }else if($row['oid']==8) {
375
+            } else if ($row['oid']==8) {
376 376
                 try {
377
-                    $sub = [];
378
-                    $response = Requests::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']);
379
-                    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->body, $match);
380
-                    if(strpos('Runtime error',trim(strip_tags($match[1])))!==false)  $sub['verdict'] = 'Runtime Error';
381
-                    else $sub['verdict'] = $hdu_v[trim(strip_tags($match[1]))];
382
-                    preg_match ("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response->body, $matches);
383
-                    $sub['remote_id'] = $row['remote_id'];
384
-                    $sub['time'] = intval($matches[1]);
385
-                    $sub['memory'] = intval($matches[2]);
377
+                    $sub=[];
378
+                    $response=Requests::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']);
379
+                    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->body, $match);
380
+                    if (strpos('Runtime error', trim(strip_tags($match[1])))!==false)  $sub['verdict']='Runtime Error';
381
+                    else $sub['verdict']=$hdu_v[trim(strip_tags($match[1]))];
382
+                    preg_match("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response->body, $matches);
383
+                    $sub['remote_id']=$row['remote_id'];
384
+                    $sub['time']=intval($matches[1]);
385
+                    $sub['memory']=intval($matches[2]);
386 386
                     // $sub['score'] = ($sub['verdict'] == 'Accepted')?100:0;
387 387
 
388
-                    if($sub['verdict'] == 'Compile Error') {
389
-                        $ret = Requests::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']);
390
-                        preg_match ("/<pre>([\\s\\S]*?)<\/pre>/", $ret->body, $match);
391
-                        $sub['compile_info'] = trim(strip_tags($match[0]));
388
+                    if ($sub['verdict']=='Compile Error') {
389
+                        $ret=Requests::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']);
390
+                        preg_match("/<pre>([\\s\\S]*?)<\/pre>/", $ret->body, $match);
391
+                        $sub['compile_info']=trim(strip_tags($match[0]));
392 392
                     }
393 393
 
394 394
                     $this->MODEL->updateSubmission($row['sid'], $sub);
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      */
441 441
     private function get_last_uva($earliest, $host, $handle)
442 442
     {
443
-        $ret = [];
443
+        $ret=[];
444 444
         if (!$earliest) {
445 445
             return $ret;
446 446
         }
Please login to merge, or discard this patch.