Passed
Pull Request — master (#610)
by John
10:48
created
app/Http/Controllers/ProblemController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,10 +132,10 @@
 block discarded – undo
132 132
             ];
133 133
         }
134 134
 
135
-        $accountExt = Auth::user()->getExtra(['editor_left_width', 'editor_theme']);
136
-        $editor_left_width = isset($accountExt['editor_left_width'])?$accountExt['editor_left_width']:'40';
137
-        $editor_theme = isset($accountExt['editor_theme'])?$accountExt['editor_theme']:'vs-dark';
138
-        $themeConfig = MonacoTheme::getTheme($editor_theme);
135
+        $accountExt=Auth::user()->getExtra(['editor_left_width', 'editor_theme']);
136
+        $editor_left_width=isset($accountExt['editor_left_width']) ? $accountExt['editor_left_width'] : '40';
137
+        $editor_theme=isset($accountExt['editor_theme']) ? $accountExt['editor_theme'] : 'vs-dark';
138
+        $themeConfig=MonacoTheme::getTheme($editor_theme);
139 139
 
140 140
         return is_null($prob_detail) ?  redirect("/problem") : view('problem.editor', [
141 141
                                             'page_title'=>$prob_detail["title"],
Please login to merge, or discard this patch.
app/Babel/TestRun/TestRunner.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
         } catch (ErrorException $e) {
30 30
         } catch (Exception $e) {
31 31
         }
32
-        $className = "App\\Babel\\Extension\\$name\\$runnerProvider";
32
+        $className="App\\Babel\\Extension\\$name\\$runnerProvider";
33 33
         if (class_exists($className)) {
34 34
             return new $className($conf);
35 35
         } else {
Please login to merge, or discard this patch.
app/Babel/Extension/noj/Languages.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 'run' => [
99 99
                     'command' => '/usr/bin/python3.7 {exe_path}',
100 100
                     'seccomp_rule' => 'general',
101
-                    'env' => array_merge(['MALLOC_ARENA_MAX=1','PYTHONIOENCODING=UTF-8'], $default_env)
101
+                    'env' => array_merge(['MALLOC_ARENA_MAX=1', 'PYTHONIOENCODING=UTF-8'], $default_env)
102 102
                 ]
103 103
             ],
104 104
             'php7_lang_config' => [
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                     'max_real_time' => 10000,
129 129
                     'max_memory' => -1,
130 130
                     'compile_command' => '/usr/bin/go build -o {exe_path} {src_path}',
131
-                    'env' => ["GOCACHE=/tmp","GOPATH=/root/go"]
131
+                    'env' => ["GOCACHE=/tmp", "GOPATH=/root/go"]
132 132
                 ],
133 133
                 'run' => [
134 134
                     'command' => '{exe_path}',
Please login to merge, or discard this patch.
app/Babel/Extension/noj/JudgeClient.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
             'language_config' => $languageConfig,
44 44
             'src' => $src,
45 45
             'test_case_id' => $testCaseId,
46
-            'max_cpu_time' => is_null($languageConfig['compile'])?null:$languageConfig['compile']['max_cpu_time'],
47
-            'max_memory' =>  is_null($languageConfig['compile'])?null:$languageConfig['compile']['max_memory'],
46
+            'max_cpu_time' => is_null($languageConfig['compile']) ?null:$languageConfig['compile']['max_cpu_time'],
47
+            'max_memory' =>  is_null($languageConfig['compile']) ?null:$languageConfig['compile']['max_memory'],
48 48
             'spj_version' => null,
49 49
             'spj_config' => null,
50 50
             'spj_compile_config' => null,
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     }
65 65
     public function getLanguageConfigByLanguage($language, $spj=false)
66 66
     {
67
-        return $this->getLanguageConfigByKey($language.($spj?'_lang_spj_config':'_lang_config'));
67
+        return $this->getLanguageConfigByKey($language.($spj ? '_lang_spj_config' : '_lang_config'));
68 68
     }
69 69
     public function getLanguageConfigByKey($key)
70 70
     {
Please login to merge, or discard this patch.
app/Babel/Extension/noj/TestRunner.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             "spj_compile_config" => null,
66 66
             "spj_src" => null
67 67
         ];
68
-        if($probBasic["spj"] && $probBasic["spj_version"]){
68
+        if ($probBasic["spj"] && $probBasic["spj_version"]) {
69 69
             $submit_data["spj_version"]=$probBasic["spj_version"];
70 70
             $submit_data["spj_config"]=$probBasic["spj_lang"];
71 71
             $submit_data["spj_compile_config"]=[
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             $submit_data["spj_src"]=$probBasic["spj_src"];
80 80
         }
81 81
         $judgeClient=new JudgeClient($submit_data["token"], $submitURL);
82
-        $temp = $judgeClient->judge($submit_data["solution"], $submit_data["language"], $submit_data["test_case_id"], [
82
+        $temp=$judgeClient->judge($submit_data["solution"], $submit_data["language"], $submit_data["test_case_id"], [
83 83
             'output' => false,
84 84
             'max_cpu_time'=>$submit_data['max_cpu_time'],
85 85
             'max_memory'=>$submit_data['max_memory'],
Please login to merge, or discard this patch.
app/Models/Search/ProblemSearchModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
 
14 14
     public function search($key)
15 15
     {
16
-        $result = [];
17
-        if(strlen($key) >= 2){
18
-            $ret = self::where('pcode', $key)
19
-                ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)',[$key])
16
+        $result=[];
17
+        if (strlen($key)>=2) {
18
+            $ret=self::where('pcode', $key)
19
+                ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)', [$key])
20 20
                 ->select('pid', 'pcode', 'title')
21 21
                 ->limit(120)
22 22
                 ->get()->all();
23
-            if(!empty($ret)){
24
-                $result += $ret;
23
+            if (!empty($ret)) {
24
+                $result+=$ret;
25 25
             }
26 26
         }
27
-        $problemModel = new ProblemModel();
27
+        $problemModel=new ProblemModel();
28 28
         foreach ($result as $p_index => $p) {
29
-            if($problemModel->isBlocked($p['pid']) || $problemModel->isHidden($p["pid"])){
29
+            if ($problemModel->isBlocked($p['pid']) || $problemModel->isHidden($p["pid"])) {
30 30
                 unset($result[$p_index]);
31 31
             }
32 32
         }
Please login to merge, or discard this patch.
app/Models/Submission/SubmissionModel.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         ], [
108 108
             "id" => "haskell",
109 109
             "extensions" => [".hs"],
110
-            "aliases" => ["Haskell","haskell"]
110
+            "aliases" => ["Haskell", "haskell"]
111 111
         ], [
112 112
             "id" => "html",
113 113
             "extensions" => [".html", ".htm", ".shtml", ".xhtml", ".mdoc", ".jsp", ".asp", ".aspx", ".jshtm"],
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                                             ->where(['verdict'=>'Waiting'])
376 376
                                             ->get()
377 377
                                             ->all();
378
-        foreach($ret as &$r){
378
+        foreach ($ret as &$r) {
379 379
             $r["ocode"]=DB::table("oj")->where(["oid"=>$r["oid"]])->first()["ocode"];
380 380
         }
381 381
         return $ret;
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
         if (isset($sub['verdict'])) {
394 394
             $sub["color"]=$this->colorScheme[$sub['verdict']];
395 395
         }
396
-        $result = DB::table($this->tableName)->where(['sid'=>$sid])->update($sub);
397
-        $contestModel = new ContestModel();
398
-        $submission_info = DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first();
399
-        if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])){
400
-            $sub['pid'] = $submission_info['pid'];
401
-            $sub['uid'] = $submission_info['uid'];
402
-            $sub['cid'] = $submission_info['cid'];
403
-            $sub['sid'] = $sid;
396
+        $result=DB::table($this->tableName)->where(['sid'=>$sid])->update($sub);
397
+        $contestModel=new ContestModel();
398
+        $submission_info=DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first();
399
+        if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])) {
400
+            $sub['pid']=$submission_info['pid'];
401
+            $sub['uid']=$submission_info['uid'];
402
+            $sub['cid']=$submission_info['cid'];
403
+            $sub['sid']=$sid;
404 404
             // $contestModel->updateContestRankTable($submission_info['cid'],$sub);
405 405
         }
406 406
         return $result;
@@ -439,15 +439,15 @@  discard block
 block discarded – undo
439 439
             'desc'
440 440
         );
441 441
 
442
-        if($filter["pcode"]){
442
+        if ($filter["pcode"]) {
443 443
             $paginator=$paginator->where(["pcode"=>$filter["pcode"]]);
444 444
         }
445 445
 
446
-        if($filter["result"]){
446
+        if ($filter["result"]) {
447 447
             $paginator=$paginator->where(["verdict"=>$filter["result"]]);
448 448
         }
449 449
 
450
-        if($filter["account"]){
450
+        if ($filter["account"]) {
451 451
             $paginator=$paginator->where(["name"=>$filter["account"]]);
452 452
         }
453 453
 
Please login to merge, or discard this patch.
app/Models/ContestModel.php 2 patches
Spacing   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 
116 116
     public function gcode($cid)
117 117
     {
118
-        $gid = $this->gid($cid);
119
-        return DB::table('group')->where('gid','=',$gid)->first()["gcode"];
118
+        $gid=$this->gid($cid);
119
+        return DB::table('group')->where('gid', '=', $gid)->first()["gcode"];
120 120
     }
121 121
 
122 122
     public function runningContest()
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 
142 142
     public function listForSetting($gid)
143 143
     {
144
-        $uid = Auth::user()->id;
145
-        $group_contests = DB::table('contest')
146
-            ->where('gid',$gid)
147
-            ->orderBy('begin_time','desc')
144
+        $uid=Auth::user()->id;
145
+        $group_contests=DB::table('contest')
146
+            ->where('gid', $gid)
147
+            ->orderBy('begin_time', 'desc')
148 148
             ->get()->all();
149
-        $groupModel = new GroupModel();
150
-        $group_clearance = $groupModel->judgeClearance($gid,$uid);
149
+        $groupModel=new GroupModel();
150
+        $group_clearance=$groupModel->judgeClearance($gid, $uid);
151 151
         foreach ($group_contests as &$contest) {
152
-            $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3);
153
-            $contest['begin_stamps'] = strtotime($contest['begin_time']);
154
-            $contest['end_stamps'] = strtotime($contest['end_time']);
155
-            $contest['status'] = time() >= $contest['end_stamps'] ? 1
156
-                : (time() <= $contest['begin_stamps'] ? -1 : 0);
152
+            $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3);
153
+            $contest['begin_stamps']=strtotime($contest['begin_time']);
154
+            $contest['end_stamps']=strtotime($contest['end_time']);
155
+            $contest['status']=time()>=$contest['end_stamps'] ? 1
156
+                : (time()<=$contest['begin_stamps'] ? -1 : 0);
157 157
             $contest["rule_parsed"]=$this->rule[$contest["rule"]];
158 158
             $contest["date_parsed"]=[
159 159
                 "date"=>date_format(date_create($contest["begin_time"]), 'j'),
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
             ];
162 162
             $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]);
163 163
         }
164
-        usort($group_contests,function($a,$b){
165
-            if($a['is_admin'] == $b['is_admin']){
166
-                return $b['begin_stamps'] - $a['begin_stamps'];
164
+        usort($group_contests, function($a, $b) {
165
+            if ($a['is_admin']==$b['is_admin']) {
166
+                return $b['begin_stamps']-$a['begin_stamps'];
167 167
             }
168
-            return $b['is_admin'] - $a['is_admin'];
168
+            return $b['is_admin']-$a['is_admin'];
169 169
         });
170 170
         return $group_contests;
171 171
     }
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
         //     "gid"=>$gid
177 177
         // ])->orderBy('begin_time', 'desc')->get()->all();
178 178
         $preQuery=DB::table($this->tableName);
179
-        $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10);
179
+        $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10);
180 180
         $contest_list=$paginator->all();
181
-        if(empty($contest_list)){
181
+        if (empty($contest_list)) {
182 182
             return null;
183 183
         }
184 184
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         ])->first()["rule"];
204 204
     }
205 205
 
206
-    public function list($filter,$uid)
206
+    public function list($filter, $uid)
207 207
     {
208 208
         if ($uid) {
209 209
             //$paginator=DB::select('SELECT DISTINCT contest.* FROM group_member inner join contest on group_member.gid=contest.gid left join contest_participant on contest.cid=contest_participant.cid where (public=1 and audit=1) or (group_member.uid=:uid and group_member.role>0 and (contest_participant.uid=:uidd or ISNULL(contest_participant.uid)) and (registration=0 or (registration=1 and not ISNULL(contest_participant.uid))))',["uid"=>$uid,"uidd"=>$uid])->paginate(10);
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
                 if ($filter['practice']) {
228 228
                     $paginator=$paginator->where(["practice"=>$filter['practice']]);
229 229
                 }
230
-                $paginator = $paginator ->paginate(10);
231
-            }elseif($filter['public']=='0'){
230
+                $paginator=$paginator ->paginate(10);
231
+            }elseif ($filter['public']=='0') {
232 232
                 $paginator=DB::table('group_member')
233 233
                 ->groupBy('contest.cid')
234 234
                 ->select('contest.*')
235 235
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
236 236
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
237 237
                 ->where(
238
-                    function ($query) use ($filter,$uid) {
238
+                    function($query) use ($filter, $uid) {
239 239
                         if ($filter['rule']) {
240 240
                             $query=$query->where(["rule"=>$filter['rule']]);
241 241
                         }
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
                 )
259 259
                 ->orderBy('contest.begin_time', 'desc')
260 260
                 ->paginate(10);
261
-            }else{
261
+            } else {
262 262
                 $paginator=DB::table('group_member')
263 263
                 ->groupBy('contest.cid')
264 264
                 ->select('contest.*')
265 265
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
266 266
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
267 267
                 ->where(
268
-                    function ($query) use ($filter) {
268
+                    function($query) use ($filter) {
269 269
                         if ($filter['rule']) {
270 270
                             $query=$query->where(["rule"=>$filter['rule']]);
271 271
                         }
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
                     }
287 287
                 )
288 288
                 ->orWhere(
289
-                    function ($query) use ($filter,$uid) {
289
+                    function($query) use ($filter, $uid) {
290 290
                         if ($filter['rule']) {
291 291
                             $query=$query->where(["rule"=>$filter['rule']]);
292 292
                         }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
             if ($filter['practice']) {
333 333
                 $paginator=$paginator->where(["practice"=>$filter['practice']]);
334 334
             }
335
-            $paginator = $paginator ->paginate(10);
335
+            $paginator=$paginator ->paginate(10);
336 336
         }
337 337
         $contest_list=$paginator->all();
338 338
         foreach ($contest_list as &$c) {
@@ -370,14 +370,14 @@  discard block
 block discarded – undo
370 370
         }
371 371
     }
372 372
 
373
-    public function registContest($cid,$uid)
373
+    public function registContest($cid, $uid)
374 374
     {
375 375
         $registered=DB::table("contest_participant")->where([
376 376
             "cid"=>$cid,
377 377
             "uid"=>$uid
378 378
         ])->first();
379 379
 
380
-        if(empty($registered)){
380
+        if (empty($registered)) {
381 381
             DB::table("contest_participant")->insert([
382 382
                 "cid"=>$cid,
383 383
                 "uid"=>$uid,
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
             ]);
386 386
             $name=User::find($uid)->name;
387 387
             $contest=$this->basic($cid);
388
-            $url=route('contest.detail',['cid' => $cid]);
388
+            $url=route('contest.detail', ['cid' => $cid]);
389 389
             sendMessage([
390 390
                 'receiver' => $uid,
391 391
                 'sender' => 1, // potential bugs
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
     public function problems($cid)
420 420
     {
421 421
         return DB::table('contest_problem')
422
-            ->join('problem','contest_problem.pid','=','problem.pid')
423
-            ->where('cid',$cid)
424
-            ->select('problem.pid as pid','pcode','number')
422
+            ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
423
+            ->where('cid', $cid)
424
+            ->select('problem.pid as pid', 'pcode', 'number')
425 425
             ->orderBy('number')
426 426
             ->get()->all();
427 427
     }
@@ -443,18 +443,18 @@  discard block
 block discarded – undo
443 443
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
444 444
 
445 445
         foreach ($problemSet as &$p) {
446
-            if($p['practice']){
447
-                $tags = DB::table("group_problem_tag")
448
-                ->where('gid',$p['gid'])
449
-                ->where('pid',$p['pid'])
446
+            if ($p['practice']) {
447
+                $tags=DB::table("group_problem_tag")
448
+                ->where('gid', $p['gid'])
449
+                ->where('pid', $p['pid'])
450 450
                 ->get()->all();
451
-                $tags_arr = [];
452
-                if(!empty($tags)){
451
+                $tags_arr=[];
452
+                if (!empty($tags)) {
453 453
                     foreach ($tags as $value) {
454
-                        array_push($tags_arr,$value['tag']);
454
+                        array_push($tags_arr, $value['tag']);
455 455
                     }
456 456
                 }
457
-                $p['tags'] = $tags_arr;
457
+                $p['tags']=$tags_arr;
458 458
             }
459 459
             if ($contest_rule==1) {
460 460
                 $prob_stat=DB::table("submission")->select(
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
                     "gid" => $contest_info["gid"]
708 708
                 ])->where("role", ">", 0)->first();
709 709
 
710
-                $nickName=is_null($nickName)?null:$nickName["nick_name"];
710
+                $nickName=is_null($nickName) ?null:$nickName["nick_name"];
711 711
                 $ret[]=[
712 712
                     "uid" => $s["uid"],
713 713
                     "name" => DB::table("users")->where([
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
                     "problem_detail" => $prob_detail
720 720
                 ];
721 721
             }
722
-            usort($ret, function ($a, $b) {
722
+            usort($ret, function($a, $b) {
723 723
                 if ($a["score"]==$b["score"]) {
724 724
                     if ($a["penalty"]==$b["penalty"]) {
725 725
                         return 0;
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
                     "gid" => $contest_info["gid"]
759 759
                 ])->where("role", ">", 0)->first();
760 760
 
761
-                $nickName=is_null($nickName)?null:$nickName["nick_name"];
761
+                $nickName=is_null($nickName) ?null:$nickName["nick_name"];
762 762
                 $ret[]=[
763 763
                     "uid" => $s["uid"],
764 764
                     "name" => DB::table("users")->where([
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
                     "problem_detail" => $prob_detail
771 771
                 ];
772 772
             }
773
-            usort($ret, function ($a, $b) {
773
+            usort($ret, function($a, $b) {
774 774
                 if ($a["score"]==$b["score"]) {
775 775
                     if ($a["solved"]==$b["solved"]) {
776 776
                         return 0;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
         return $ret;
793 793
     }
794 794
 
795
-    public function contestRank($cid, $uid = 0)
795
+    public function contestRank($cid, $uid=0)
796 796
     {
797 797
         // [ToDo] If the current user's in the organizer group show nick name
798 798
         // [ToDo] The participants determination
@@ -809,36 +809,36 @@  discard block
 block discarded – undo
809 809
             "gid" => $contest_info["gid"]
810 810
         ])->where("role", ">", 0)->first());
811 811
 
812
-        $clearance = $this -> judgeClearance($cid, $uid);
812
+        $clearance=$this -> judgeClearance($cid, $uid);
813 813
 
814 814
         /** New Version With MySQL */
815 815
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
816
-        $contest_eloquent = EloquentContestModel::find($cid);
816
+        $contest_eloquent=EloquentContestModel::find($cid);
817 817
 
818
-        if(time() < $end_time){
819
-            if($clearance == 3){
818
+        if (time()<$end_time) {
819
+            if ($clearance==3) {
820 820
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
821
-            }else{
821
+            } else {
822 822
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
823 823
             }
824
-            if(!isset($contestRankRaw)){
824
+            if (!isset($contestRankRaw)) {
825 825
                 $contestRankRaw=$contest_eloquent->rankRefresh();
826 826
             }
827
-        }else{
828
-            if($clearance == 3){
827
+        } else {
828
+            if ($clearance==3) {
829 829
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
830 830
                 if (!isset($contestRankRaw)) {
831 831
                     $contestRankRaw=$this->getContestRankFromMySQL($cid);
832
-                    if(!isset($contestRankRaw)){
832
+                    if (!isset($contestRankRaw)) {
833 833
                         $contestRankRaw=$contest_eloquent->rankRefresh();
834 834
                         $this->storeContestRankInMySQL($cid, $contestRankRaw);
835 835
                     }
836 836
                 }
837
-            }else{
837
+            } else {
838 838
                 $contestRankRaw=$this->getContestRankFromMySQL($cid);
839
-                if(!isset($contestRankRaw)){
839
+                if (!isset($contestRankRaw)) {
840 840
                     $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
841
-                    if(!isset($contestRankRaw)){
841
+                    if (!isset($contestRankRaw)) {
842 842
                         $contestRankRaw=$contest_eloquent->rankRefresh();
843 843
                     }
844 844
                     $this->storeContestRankInMySQL($cid, $contestRankRaw);
@@ -856,15 +856,15 @@  discard block
 block discarded – undo
856 856
         //         $contestRankRaw=$this->contestRankCache($cid);
857 857
         //     }
858 858
         // }
859
-        if($contest_info["rule"]==1){
859
+        if ($contest_info["rule"]==1) {
860 860
             foreach ($contestRankRaw as &$cr) {
861
-                $solved = 0;
862
-                foreach($cr['problem_detail'] as $pd){
863
-                    if(!empty($pd['solved_time_parsed'])){
864
-                        $solved ++;
861
+                $solved=0;
862
+                foreach ($cr['problem_detail'] as $pd) {
863
+                    if (!empty($pd['solved_time_parsed'])) {
864
+                        $solved++;
865 865
                     }
866 866
                 }
867
-                $cr['solved'] = $solved;
867
+                $cr['solved']=$solved;
868 868
             }
869 869
         }
870 870
 
@@ -913,16 +913,16 @@  discard block
 block discarded – undo
913 913
 
914 914
     public function getClarificationList($cid)
915 915
     {
916
-        $uid = Auth::user()->id;
917
-        $clearance = $this -> judgeClearance($cid, $uid);
918
-        if($clearance == 3){
916
+        $uid=Auth::user()->id;
917
+        $clearance=$this -> judgeClearance($cid, $uid);
918
+        if ($clearance==3) {
919 919
             return DB::table("contest_clarification")->where([
920 920
                 "cid"=>$cid
921 921
             ])->orderBy('created_at', 'desc')->get()->all();
922
-        }else{
922
+        } else {
923 923
             return DB::table("contest_clarification")->where([
924 924
                 "cid"=>$cid
925
-            ])->where(function ($query) {
925
+            ])->where(function($query) {
926 926
                 $query->where([
927 927
                     "public"=>1
928 928
                 ])->orWhere([
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
     public function getContestRecord($filter, $cid)
1036 1036
     {
1037 1037
         $basicInfo=$this->basic($cid);
1038
-        $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first();
1038
+        $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first();
1039 1039
         $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
1040 1040
             "cid"=>$cid
1041 1041
         ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all();
@@ -1048,14 +1048,14 @@  discard block
 block discarded – undo
1048 1048
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1049 1049
         $contestEnd=time()>$end_time;
1050 1050
 
1051
-        $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1052
-        if($filter['pid']===false){
1053
-            $filter['pid'] = is_null($filter['ncode'])?null:-1;
1054
-        }else{
1055
-            $filter['pid'] = $problemSet_temp[$filter['pid']]['pid'];
1051
+        $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1052
+        if ($filter['pid']===false) {
1053
+            $filter['pid']=is_null($filter['ncode']) ?null:-1;
1054
+        } else {
1055
+            $filter['pid']=$problemSet_temp[$filter['pid']]['pid'];
1056 1056
         }
1057 1057
 
1058
-        if($userInfo==null || $userInfo["role"]!=3){
1058
+        if ($userInfo==null || $userInfo["role"]!=3) {
1059 1059
             if ($basicInfo["status_visibility"]==2) {
1060 1060
                 // View all
1061 1061
                 $paginator=DB::table("submission")->where([
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
                     "users.id",
1070 1070
                     "=",
1071 1071
                     "submission.uid"
1072
-                )->where(function ($query) use ($frozen_time) {
1072
+                )->where(function($query) use ($frozen_time) {
1073 1073
                     $query->where(
1074 1074
                         "submission_date",
1075 1075
                         "<",
@@ -1096,15 +1096,15 @@  discard block
 block discarded – undo
1096 1096
                     'desc'
1097 1097
                 );
1098 1098
 
1099
-                if($filter["pid"]){
1099
+                if ($filter["pid"]) {
1100 1100
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1101 1101
                 }
1102 1102
 
1103
-                if($filter["result"]){
1103
+                if ($filter["result"]) {
1104 1104
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1105 1105
                 }
1106 1106
 
1107
-                if($filter["account"]){
1107
+                if ($filter["account"]) {
1108 1108
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1109 1109
                 }
1110 1110
 
@@ -1140,15 +1140,15 @@  discard block
 block discarded – undo
1140 1140
                     'desc'
1141 1141
                 );
1142 1142
 
1143
-                if($filter["pid"]){
1143
+                if ($filter["pid"]) {
1144 1144
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1145 1145
                 }
1146 1146
 
1147
-                if($filter["result"]){
1147
+                if ($filter["result"]) {
1148 1148
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1149 1149
                 }
1150 1150
 
1151
-                if($filter["account"]){
1151
+                if ($filter["account"]) {
1152 1152
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1153 1153
                 }
1154 1154
 
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
                     "records"=>[]
1160 1160
                 ];
1161 1161
             }
1162
-        }else{
1162
+        } else {
1163 1163
             if ($basicInfo["status_visibility"]==2) {
1164 1164
                 // View all
1165 1165
                 $paginator=DB::table("submission")->where([
@@ -1191,15 +1191,15 @@  discard block
 block discarded – undo
1191 1191
                     'desc'
1192 1192
                 );
1193 1193
 
1194
-                if($filter["pid"]){
1194
+                if ($filter["pid"]) {
1195 1195
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1196 1196
                 }
1197 1197
 
1198
-                if($filter["result"]){
1198
+                if ($filter["result"]) {
1199 1199
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1200 1200
                 }
1201 1201
 
1202
-                if($filter["account"]){
1202
+                if ($filter["account"]) {
1203 1203
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1204 1204
                 }
1205 1205
 
@@ -1235,15 +1235,15 @@  discard block
 block discarded – undo
1235 1235
                     'desc'
1236 1236
                 );
1237 1237
 
1238
-                if($filter["pid"]){
1238
+                if ($filter["pid"]) {
1239 1239
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1240 1240
                 }
1241 1241
 
1242
-                if($filter["result"]){
1242
+                if ($filter["result"]) {
1243 1243
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1244 1244
                 }
1245 1245
 
1246
-                if($filter["account"]){
1246
+                if ($filter["account"]) {
1247 1247
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1248 1248
                 }
1249 1249
 
@@ -1296,24 +1296,24 @@  discard block
 block discarded – undo
1296 1296
          * 2 stands for participant*
1297 1297
          * 3 stands for admin      *
1298 1298
          ***************************/
1299
-        if ($uid==0 || filter_var($cid, FILTER_VALIDATE_INT) === false) {
1299
+        if ($uid==0 || filter_var($cid, FILTER_VALIDATE_INT)===false) {
1300 1300
             return 0;
1301 1301
         }
1302
-        $groupModel = new GroupModel();
1302
+        $groupModel=new GroupModel();
1303 1303
         $contest_info=DB::table("contest")->where("cid", $cid)->first();
1304
-        $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first();
1304
+        $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first();
1305 1305
 
1306
-        if(empty($contest_info)){
1306
+        if (empty($contest_info)) {
1307 1307
             // contest not exist
1308 1308
             return 0;
1309 1309
         }
1310 1310
 
1311
-        if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){
1311
+        if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) {
1312 1312
             return 3;
1313 1313
         }
1314 1314
 
1315
-        $contest_started = strtotime($contest_info['begin_time']) < time();
1316
-        $contest_ended = strtotime($contest_info['end_time']) < time();
1315
+        $contest_started=strtotime($contest_info['begin_time'])<time();
1316
+        $contest_ended=strtotime($contest_info['end_time'])<time();
1317 1317
         if (!$contest_started) {
1318 1318
             // not started or do not exist
1319 1319
             return 0;
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 
1375 1375
     public function judgeOutsideClearance($cid, $uid=0)
1376 1376
     {
1377
-        if (filter_var($cid, FILTER_VALIDATE_INT) === false) {
1377
+        if (filter_var($cid, FILTER_VALIDATE_INT)===false) {
1378 1378
             return 0;
1379 1379
         }
1380 1380
         $contest_info=DB::table("contest")->where("cid", $cid)->first();
@@ -1407,12 +1407,12 @@  discard block
 block discarded – undo
1407 1407
     public function updateProfessionalRate($cid)
1408 1408
     {
1409 1409
         $basic=$this->basic($cid);
1410
-        if($basic["rated"]&&!$basic["is_rated"]){
1410
+        if ($basic["rated"] && !$basic["is_rated"]) {
1411 1411
             $ratingCalculator=new RatingCalculator($cid);
1412
-            if($ratingCalculator->calculate()){
1412
+            if ($ratingCalculator->calculate()) {
1413 1413
                 $ratingCalculator->storage();
1414 1414
                 return true;
1415
-            }else{
1415
+            } else {
1416 1416
                 return false;
1417 1417
             }
1418 1418
         } else {
@@ -1420,26 +1420,26 @@  discard block
 block discarded – undo
1420 1420
         }
1421 1421
     }
1422 1422
 
1423
-    public function contestUpdate($cid,$data,$problems)
1423
+    public function contestUpdate($cid, $data, $problems)
1424 1424
     {
1425
-        if($problems !== false){
1426
-            $old_problmes = array_column(
1425
+        if ($problems!==false) {
1426
+            $old_problmes=array_column(
1427 1427
                 DB::table('contest_problem')
1428
-                ->where('cid',$cid)
1428
+                ->where('cid', $cid)
1429 1429
                 ->get()->all(),
1430 1430
                 'pid'
1431 1431
             );
1432
-            DB::transaction(function () use ($cid, $data, $problems,$old_problmes) {
1432
+            DB::transaction(function() use ($cid, $data, $problems, $old_problmes) {
1433 1433
                 DB::table($this->tableName)
1434
-                    ->where('cid',$cid)
1434
+                    ->where('cid', $cid)
1435 1435
                     ->update($data);
1436 1436
                 DB::table('contest_problem')
1437
-                    ->where('cid',$cid)
1437
+                    ->where('cid', $cid)
1438 1438
                     ->delete();
1439
-                $new_problems = [];
1439
+                $new_problems=[];
1440 1440
                 foreach ($problems as $p) {
1441 1441
                     $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"];
1442
-                    array_push($new_problems,$pid);
1442
+                    array_push($new_problems, $pid);
1443 1443
                     DB::table("contest_problem")->insert([
1444 1444
                         "cid"=>$cid,
1445 1445
                         "number"=>$p["number"],
@@ -1449,29 +1449,29 @@  discard block
 block discarded – undo
1449 1449
                         "points"=>$p["points"]
1450 1450
                     ]);
1451 1451
                 }
1452
-                foreach($old_problmes as $op) {
1453
-                    if(!in_array($op,$new_problems)){
1452
+                foreach ($old_problmes as $op) {
1453
+                    if (!in_array($op, $new_problems)) {
1454 1454
                         DB::table('submission')
1455
-                            ->where('cid',$cid)
1456
-                            ->where('pid',$op)
1455
+                            ->where('cid', $cid)
1456
+                            ->where('pid', $op)
1457 1457
                             ->delete();
1458 1458
                     }
1459 1459
                 }
1460 1460
             }, 5);
1461
-            $contestRankRaw = $this->contestRankCache($cid);
1461
+            $contestRankRaw=$this->contestRankCache($cid);
1462 1462
             Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
1463 1463
             Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
1464
-        }else{
1464
+        } else {
1465 1465
             DB::table($this->tableName)
1466
-                ->where('cid',$cid)
1466
+                ->where('cid', $cid)
1467 1467
                 ->update($data);
1468 1468
         }
1469 1469
     }
1470 1470
 
1471
-    public function contestUpdateProblem($cid,$problems)
1471
+    public function contestUpdateProblem($cid, $problems)
1472 1472
     {
1473 1473
         DB::table('contest_problem')
1474
-                ->where('cid',$cid)
1474
+                ->where('cid', $cid)
1475 1475
                 ->delete();
1476 1476
         foreach ($problems as $p) {
1477 1477
             DB::table("contest_problem")->insertGetId([
@@ -1487,8 +1487,8 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
     public function arrangeContest($gid, $config, $problems)
1489 1489
     {
1490
-        $cid = -1;
1491
-        DB::transaction(function () use ($gid, $config, $problems,&$cid) {
1490
+        $cid=-1;
1491
+        DB::transaction(function() use ($gid, $config, $problems, &$cid) {
1492 1492
             $cid=DB::table($this->tableName)->insertGetId([
1493 1493
                 "gid"=>$gid,
1494 1494
                 "name"=>$config["name"],
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
                 "rule"=>1, //todo
1503 1503
                 "begin_time"=>$config["begin_time"],
1504 1504
                 "end_time"=>$config["end_time"],
1505
-                "vcid"=>isset($config["vcid"])?$config["vcid"]:null,
1505
+                "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null,
1506 1506
                 "public"=>$config["public"],
1507 1507
                 "registration"=>0, //todo
1508 1508
                 "registration_due"=>null, //todo
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
                 "froze_length"=>0, //todo
1511 1511
                 "status_visibility"=>$config["status_visibility"],
1512 1512
                 "created_at"=>date("Y-m-d H:i:s"),
1513
-                "crawled" => isset($config['vcid'])?$config['crawled'] : null,
1513
+                "crawled" => isset($config['vcid']) ? $config['crawled'] : null,
1514 1514
                 "audit_status"=>$config["public"] ? 0 : 1
1515 1515
             ]);
1516 1516
 
@@ -1529,13 +1529,13 @@  discard block
 block discarded – undo
1529 1529
         return $cid;
1530 1530
     }
1531 1531
 
1532
-    public function updateContestRankTable($cid,$sub)
1532
+    public function updateContestRankTable($cid, $sub)
1533 1533
     {
1534
-        $lock = Cache::lock("contestrank$cid",10);
1535
-        try{
1536
-            if($lock->get()){
1537
-                if(Cache::tags(['contest','rank'])->get($cid) != null){
1538
-                    $ret = Cache::tags(['contest','rank'])->get($cid);
1534
+        $lock=Cache::lock("contestrank$cid", 10);
1535
+        try {
1536
+            if ($lock->get()) {
1537
+                if (Cache::tags(['contest', 'rank'])->get($cid)!=null) {
1538
+                    $ret=Cache::tags(['contest', 'rank'])->get($cid);
1539 1539
                     $chache=[];
1540 1540
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
1541 1541
                     $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
@@ -1544,27 +1544,27 @@  discard block
 block discarded – undo
1544 1544
                     $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"];
1545 1545
                     $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1546 1546
 
1547
-                    $id = 0;
1547
+                    $id=0;
1548 1548
 
1549
-                    foreach($chache['problemSet'] as $key => $p){
1550
-                        if ($p['pid'] == $sub['pid']){
1551
-                            $chache['problemSet'][$key]['cpid'] = $key;
1552
-                            $id = $key;
1549
+                    foreach ($chache['problemSet'] as $key => $p) {
1550
+                        if ($p['pid']==$sub['pid']) {
1551
+                            $chache['problemSet'][$key]['cpid']=$key;
1552
+                            $id=$key;
1553 1553
                         }
1554 1554
                     }
1555 1555
 
1556
-                    $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret);
1557
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1556
+                    $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret);
1557
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1558 1558
 
1559
-                    if (time() < $chache['frozen_time']){
1559
+                    if (time()<$chache['frozen_time']) {
1560 1560
                         Cache::tags(['contest', 'rank'])->put($cid, $ret);
1561 1561
                     }
1562 1562
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret);
1563
-                    if(time() > $chache['end_time']){
1563
+                    if (time()>$chache['end_time']) {
1564 1564
                         $this->storeContestRankInMySQL($cid, $ret);
1565 1565
                     }
1566 1566
                 }
1567
-                else{
1567
+                else {
1568 1568
                     $ret=[];
1569 1569
                     $chache=[];
1570 1570
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
                             "cid"=>$cid,
1580 1580
                             "audit"=>1
1581 1581
                         ])->select('uid')->get()->all();
1582
-                    }else{
1582
+                    } else {
1583 1583
                         $submissionUsers=DB::table("submission")->where([
1584 1584
                             "cid"=>$cid
1585 1585
                         ])->where(
@@ -1592,39 +1592,39 @@  discard block
 block discarded – undo
1592 1592
                         ])->select('uid')->groupBy('uid')->get()->all();
1593 1593
                     }
1594 1594
 
1595
-                    $chacheAdmin = $chache;
1595
+                    $chacheAdmin=$chache;
1596 1596
 
1597 1597
                     foreach ($submissionUsers as $s) {
1598 1598
                         foreach ($chache['problemSet'] as $key => $p) {
1599
-                            $p['cpid'] = $key;
1600
-                            $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret);
1599
+                            $p['cpid']=$key;
1600
+                            $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret);
1601 1601
                         }
1602 1602
                     }
1603
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1603
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1604 1604
                     Cache::tags(['contest', 'rank'])->put($cid, $ret);
1605 1605
 
1606 1606
                     $retAdmin=[];
1607 1607
                     foreach ($submissionUsersAdmin as $s) {
1608 1608
                         foreach ($chacheAdmin['problemSet'] as $key => $p) {
1609
-                            $p['cpid'] = $key;
1610
-                            $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin);
1609
+                            $p['cpid']=$key;
1610
+                            $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin);
1611 1611
                         }
1612 1612
                     }
1613
-                    $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin);
1613
+                    $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin);
1614 1614
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin);
1615 1615
                 }
1616 1616
             }
1617
-        }catch(LockTimeoutException $e){
1617
+        } catch (LockTimeoutException $e) {
1618 1618
             Log::warning("Contest Rank Lock Timed Out");
1619
-        }finally{
1619
+        } finally {
1620 1620
             optional($lock)->release();
1621 1621
         }
1622 1622
     }
1623 1623
 
1624
-    public function sortContestRankTable($contest_info,$cid,$ret)
1624
+    public function sortContestRankTable($contest_info, $cid, $ret)
1625 1625
     {
1626
-        if ($contest_info["rule"]==1){
1627
-            usort($ret, function ($a, $b) {
1626
+        if ($contest_info["rule"]==1) {
1627
+            usort($ret, function($a, $b) {
1628 1628
                 if ($a["score"]==$b["score"]) {
1629 1629
                     if ($a["penalty"]==$b["penalty"]) {
1630 1630
                         return 0;
@@ -1639,8 +1639,8 @@  discard block
 block discarded – undo
1639 1639
                     return 1;
1640 1640
                 }
1641 1641
             });
1642
-        }else if ($contest_info["rule"]==2){
1643
-            usort($ret, function ($a, $b) {
1642
+        } else if ($contest_info["rule"]==2) {
1643
+            usort($ret, function($a, $b) {
1644 1644
                 if ($a["score"]==$b["score"]) {
1645 1645
                     if ($a["solved"]==$b["solved"]) {
1646 1646
                         return 0;
@@ -1659,21 +1659,21 @@  discard block
 block discarded – undo
1659 1659
         return $ret;
1660 1660
     }
1661 1661
 
1662
-    public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret)
1662
+    public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret)
1663 1663
     {
1664
-        $id = count($ret);
1665
-        foreach($ret as $key => $r){
1666
-            if($r['uid'] == $uid)
1667
-                $id = $key;
1664
+        $id=count($ret);
1665
+        foreach ($ret as $key => $r) {
1666
+            if ($r['uid']==$uid)
1667
+                $id=$key;
1668 1668
         }
1669 1669
         if ($contest_info["rule"]==1) {
1670 1670
             // ACM/ICPC Mode
1671
-            if($id == count($ret)){
1672
-                $prob_detail = [];
1673
-                $totPen = 0;
1674
-                $totScore = 0;
1675
-            }else{
1676
-                $prob_detail = $ret[$id]['problem_detail'];
1671
+            if ($id==count($ret)) {
1672
+                $prob_detail=[];
1673
+                $totPen=0;
1674
+                $totScore=0;
1675
+            } else {
1676
+                $prob_detail=$ret[$id]['problem_detail'];
1677 1677
                 $totPen=$ret[$id]['penalty'];
1678 1678
                 $totScore=$ret[$id]['score'];
1679 1679
             };
@@ -1691,7 +1691,7 @@  discard block
 block discarded – undo
1691 1691
                 "uid"=>$uid,
1692 1692
             ])->orderBy('submission_date', 'desc')->first();
1693 1693
 
1694
-            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){
1694
+            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") {
1695 1695
                 $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid);
1696 1696
 
1697 1697
                 $prob_detail[$problem['cpid']]=[
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
                     "uid" => $uid,
1712 1712
                     "gid" => $contest_info["gid"]
1713 1713
                 ])->where("role", ">", 0)->first();
1714
-                $nickName=is_null($nickName)?null:$nickName["nick_name"];
1714
+                $nickName=is_null($nickName) ?null:$nickName["nick_name"];
1715 1715
 
1716 1716
                 $ret[$id]=[
1717 1717
                     "uid" => $uid,
@@ -1726,12 +1726,12 @@  discard block
 block discarded – undo
1726 1726
             }
1727 1727
         } elseif ($contest_info["rule"]==2) {
1728 1728
             // IOI Mode
1729
-            if($id == count($ret)){
1730
-                $prob_detail = [];
1731
-                $totSolved = 0;
1732
-                $totScore = 0;
1733
-            }else{
1734
-                $prob_detail = $ret[$id]['problem_detail'];
1729
+            if ($id==count($ret)) {
1730
+                $prob_detail=[];
1731
+                $totSolved=0;
1732
+                $totScore=0;
1733
+            } else {
1734
+                $prob_detail=$ret[$id]['problem_detail'];
1735 1735
                 $totSolved=$ret[$id]['solved'];
1736 1736
                 $totScore=$ret[$id]['score'];
1737 1737
             };
@@ -1751,7 +1751,7 @@  discard block
 block discarded – undo
1751 1751
                 "uid" => $uid,
1752 1752
                 "gid" => $contest_info["gid"]
1753 1753
             ])->where("role", ">", 0)->first();
1754
-            $nickName=is_null($nickName)?null:$nickName["nick_name"];
1754
+            $nickName=is_null($nickName) ?null:$nickName["nick_name"];
1755 1755
 
1756 1756
             $ret[$id]=[
1757 1757
                 "uid" => $uid,
@@ -1767,47 +1767,47 @@  discard block
 block discarded – undo
1767 1767
         return $ret;
1768 1768
     }
1769 1769
 
1770
-    public function assignMember($cid,$uid){
1770
+    public function assignMember($cid, $uid) {
1771 1771
         return DB::table("contest")->where(["cid"=>$cid])->update([
1772 1772
             "assign_uid"=>$uid
1773 1773
         ]);
1774 1774
     }
1775 1775
 
1776
-    public function canUpdateContestTime($cid,$time = [])
1776
+    public function canUpdateContestTime($cid, $time=[])
1777 1777
     {
1778
-        $begin_time_new = $time['begin'] ?? null;
1779
-        $end_time_new = $time['end'] ?? null;
1778
+        $begin_time_new=$time['begin'] ?? null;
1779
+        $end_time_new=$time['end'] ?? null;
1780 1780
 
1781
-        $hold_time = DB::table('contest')
1782
-            ->where('cid',$cid)
1783
-            ->select('begin_time','end_time')
1781
+        $hold_time=DB::table('contest')
1782
+            ->where('cid', $cid)
1783
+            ->select('begin_time', 'end_time')
1784 1784
             ->first();
1785
-        $begin_stamps = strtotime($hold_time['begin_time']);
1786
-        $end_stamps = strtotime($hold_time['end_time']);
1785
+        $begin_stamps=strtotime($hold_time['begin_time']);
1786
+        $end_stamps=strtotime($hold_time['end_time']);
1787 1787
         /*
1788 1788
         -1 : have not begun
1789 1789
          0 : ing
1790 1790
          1 : end
1791 1791
         */
1792
-        $status = time() >= $end_stamps ? 1
1793
-                : (time() <= $begin_stamps ? -1 : 0);
1794
-        if($status === -1){
1795
-            if(time() > $begin_time_new){
1792
+        $status=time()>=$end_stamps ? 1
1793
+                : (time()<=$begin_stamps ? -1 : 0);
1794
+        if ($status===-1) {
1795
+            if (time()>$begin_time_new) {
1796 1796
                 return false;
1797 1797
             }
1798 1798
             return true;
1799
-        }else if($status === 0){
1800
-            if($begin_time_new !== null){
1799
+        } else if ($status===0) {
1800
+            if ($begin_time_new!==null) {
1801 1801
                 return false;
1802 1802
             }
1803
-            if($end_time_new !== null){
1804
-                if(strtotime($end_time_new) <= time()){
1803
+            if ($end_time_new!==null) {
1804
+                if (strtotime($end_time_new)<=time()) {
1805 1805
                     return false;
1806
-                }else{
1806
+                } else {
1807 1807
                     return true;
1808 1808
                 }
1809 1809
             }
1810
-        }else{
1810
+        } else {
1811 1811
             return false;
1812 1812
         }
1813 1813
 
@@ -1816,22 +1816,22 @@  discard block
 block discarded – undo
1816 1816
 
1817 1817
     public function replyClarification($ccid, $content)
1818 1818
     {
1819
-        return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1819
+        return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1820 1820
             "reply"=>$content
1821 1821
         ]);
1822 1822
     }
1823 1823
 
1824 1824
     public function setClarificationPublic($ccid, $public)
1825 1825
     {
1826
-        if($public)
1826
+        if ($public)
1827 1827
         {
1828
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1828
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1829 1829
                 "public"=>1
1830 1830
             ]);
1831 1831
         }
1832 1832
         else
1833 1833
         {
1834
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1834
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1835 1835
                 "public"=>0
1836 1836
             ]);
1837 1837
         }
@@ -1844,67 +1844,67 @@  discard block
 block discarded – undo
1844 1844
 
1845 1845
     public function praticeAnalysis($cid)
1846 1846
     {
1847
-        $gid = DB::table('contest')
1848
-            ->where('cid',$cid)
1847
+        $gid=DB::table('contest')
1848
+            ->where('cid', $cid)
1849 1849
             ->first()['gid'];
1850
-        $contestRank = $this->contestRank($cid,Auth::user()->id);
1851
-        if(!empty($contestRank)){
1852
-            $all_problems = DB::table('problem')
1853
-            ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid'))
1854
-            ->select('pid','title')
1850
+        $contestRank=$this->contestRank($cid, Auth::user()->id);
1851
+        if (!empty($contestRank)) {
1852
+            $all_problems=DB::table('problem')
1853
+            ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid'))
1854
+            ->select('pid', 'title')
1855 1855
             ->get()->all();
1856
-        }else{
1857
-            $all_problems = [];
1856
+        } else {
1857
+            $all_problems=[];
1858 1858
         }
1859
-        $tags = DB::table('group_problem_tag')
1859
+        $tags=DB::table('group_problem_tag')
1860 1860
             ->where('gid', $gid)
1861
-            ->whereIn('pid', array_column($all_problems,'pid'))
1861
+            ->whereIn('pid', array_column($all_problems, 'pid'))
1862 1862
             ->get()->all();
1863
-        $all_tags = array_unique(array_column($tags,'tag'));
1864
-        $memberData = [];
1865
-        foreach($contestRank as $member){
1866
-            $m = [
1863
+        $all_tags=array_unique(array_column($tags, 'tag'));
1864
+        $memberData=[];
1865
+        foreach ($contestRank as $member) {
1866
+            $m=[
1867 1867
                 'uid' => $member['uid'],
1868 1868
                 'name' => $member['name'],
1869 1869
                 'nick_name' => $member['nick_name'],
1870 1870
             ];
1871
-            $completion = [];
1872
-            foreach ($all_tags as $tag){
1873
-                $completion[$tag] = [];
1871
+            $completion=[];
1872
+            foreach ($all_tags as $tag) {
1873
+                $completion[$tag]=[];
1874 1874
                 foreach ($tags as $t) {
1875
-                    if($t['tag'] == $tag){
1875
+                    if ($t['tag']==$tag) {
1876 1876
                         foreach ($member['problem_detail'] as $pd) {
1877
-                            if($pd['pid'] == $t['pid']){
1878
-                                $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1;
1877
+                            if ($pd['pid']==$t['pid']) {
1878
+                                $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1;
1879 1879
                             }
1880 1880
                         }
1881 1881
                     }
1882 1882
                 }
1883 1883
             }
1884
-            $m['completion'] = $completion;
1885
-            $memberData[] = $m;
1884
+            $m['completion']=$completion;
1885
+            $memberData[]=$m;
1886 1886
         }
1887 1887
         return $memberData;
1888 1888
     }
1889 1889
 
1890 1890
     public function storeContestRankInMySQL($cid, $data)
1891 1891
     {
1892
-        $contestRankJson = json_encode($data);
1893
-        return DB::table('contest')->where('cid','=',$cid)->update([
1892
+        $contestRankJson=json_encode($data);
1893
+        return DB::table('contest')->where('cid', '=', $cid)->update([
1894 1894
             'rank' => $contestRankJson
1895 1895
         ]);
1896 1896
     }
1897 1897
 
1898 1898
     public function getContestRankFromMySQL($cid)
1899 1899
     {
1900
-        $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first();
1901
-        $data = json_decode($contestRankJson, true);
1900
+        $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first();
1901
+        $data=json_decode($contestRankJson, true);
1902 1902
         return $data;
1903 1903
     }
1904 1904
 
1905 1905
     public function isVerified($cid)
1906 1906
     {
1907
-        return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first();
1907
+        return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first();
1908 1908
     }
1909 1909
 
1910 1910
     public function getScrollBoardData($cid)
@@ -1912,20 +1912,20 @@  discard block
 block discarded – undo
1912 1912
         $members=DB::table("contest_participant")->where([
1913 1913
             "cid"=>$cid,
1914 1914
             "audit"=>1
1915
-        ])->leftjoin('users','users.id','=','contest_participant.uid')->select('users.id as uid', 'users.name as name', DB::raw('NULL AS nick_name'))->get()->all();
1916
-        $submissions = DB::table("submission")
1915
+        ])->leftjoin('users', 'users.id', '=', 'contest_participant.uid')->select('users.id as uid', 'users.name as name', DB::raw('NULL AS nick_name'))->get()->all();
1916
+        $submissions=DB::table("submission")
1917 1917
             ->where('cid', $cid)
1918 1918
             ->select('sid', 'verdict', 'submission_date', 'pid', 'uid')
1919 1919
             ->orderBy('submission_date')
1920 1920
             ->get()->all();
1921
-        $problems = DB::table('contest_problem')
1921
+        $problems=DB::table('contest_problem')
1922 1922
             ->where('cid', $cid)
1923
-            ->select('ncode','pid')
1923
+            ->select('ncode', 'pid')
1924 1924
             ->orderBy('ncode')
1925 1925
             ->get()->all();
1926
-        $contest = DB::table('contest')
1927
-            ->where('cid',$cid)
1928
-            ->select('begin_time','end_time','froze_length')
1926
+        $contest=DB::table('contest')
1927
+            ->where('cid', $cid)
1928
+            ->select('begin_time', 'end_time', 'froze_length')
1929 1929
             ->first();
1930 1930
         return [
1931 1931
             'members' => $members,
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
         ];
1936 1936
     }
1937 1937
 
1938
-    public function storageCode($path,$cid)
1938
+    public function storageCode($path, $cid)
1939 1939
     {
1940 1940
 
1941 1941
         Storage::disk("private")->makeDirectory($path);
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
             "cid"=>$cid
1947 1947
         ])->get();
1948 1948
         $problem_info=array();
1949
-        foreach($contest_problems as $contest_problem) {
1949
+        foreach ($contest_problems as $contest_problem) {
1950 1950
             $problem_info[$contest_problem["pid"]]=DB::table("problem")->where([
1951 1951
                 "pid"=>$contest_problem["pid"]
1952 1952
             ])->first();
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 
1958 1958
         $compilers=DB::table("compiler")->get();
1959 1959
         $language=array();
1960
-        foreach($compilers as $compiler) {
1960
+        foreach ($compilers as $compiler) {
1961 1961
             $language[$compiler["coid"]]=$compiler["lang"];
1962 1962
         }
1963 1963
 
@@ -1966,14 +1966,14 @@  discard block
 block discarded – undo
1966 1966
         $submissions=DB::table("submission")->where([
1967 1967
             "cid"=>$cid,
1968 1968
         ])->get();
1969
-        foreach($submissions as $submission) {
1969
+        foreach ($submissions as $submission) {
1970 1970
             $user_name=DB::table("users")->where([
1971 1971
                 "id"=>$submission["uid"]
1972 1972
             ])->first();
1973 1973
             $SubmissionModel=new SubmissionModel();
1974 1974
             $suffix_name=isset($SubmissionModel->langConfig[$language[$submission["coid"]]]) ? $SubmissionModel->langConfig[$language[$submission["coid"]]]["extensions"][0] : $SubmissionModel->langConfig["plaintext"]["extensions"][0];
1975 1975
             //die($submission["sid"]);
1976
-            $file_name=(string)($submission["sid"])."-".$user_name["name"]."-".$problem_info[$submission["pid"]]["ncode"]."-".$submission["verdict"].$suffix_name;
1976
+            $file_name=(string) ($submission["sid"])."-".$user_name["name"]."-".$problem_info[$submission["pid"]]["ncode"]."-".$submission["verdict"].$suffix_name;
1977 1977
             Storage::disk("private")->put($path."/".urlencode($problem_info[$submission["pid"]]["path"])."/".$file_name, $submission["solution"]);
1978 1978
         }
1979 1979
     }
@@ -1983,33 +1983,33 @@  discard block
 block discarded – undo
1983 1983
         Storage::disk("private")->deleteDirectory($path);
1984 1984
     }
1985 1985
 
1986
-    public function GenerateZip($path,$cid,$code_path,$outputFilename)
1986
+    public function GenerateZip($path, $cid, $code_path, $outputFilename)
1987 1987
     {
1988 1988
         Storage::disk("private")->deleteDirectory($code_path);
1989 1989
 
1990
-        $this->storageCode($code_path,$cid);
1990
+        $this->storageCode($code_path, $cid);
1991 1991
 
1992 1992
         Storage::disk("private")->makeDirectory($path);
1993 1993
 
1994 1994
         // create new archive
1995
-        $zipFile = new \PhpZip\ZipFile();
1996
-        $directories = Storage::disk("private")->allDirectories($code_path);
1997
-        try{
1998
-            foreach($directories as $directorie)
1995
+        $zipFile=new \PhpZip\ZipFile();
1996
+        $directories=Storage::disk("private")->allDirectories($code_path);
1997
+        try {
1998
+            foreach ($directories as $directorie)
1999 1999
             {
2000 2000
 
2001
-                preg_match("/contestCode\/\d+(.*)/",$directorie,$problem_name);
2002
-                $zipFile->addDir(base_path('storage/app/private/'.$directorie),urldecode($problem_name[1]));// add files from the directory
2001
+                preg_match("/contestCode\/\d+(.*)/", $directorie, $problem_name);
2002
+                $zipFile->addDir(base_path('storage/app/private/'.$directorie), urldecode($problem_name[1])); // add files from the directory
2003 2003
             }
2004 2004
             $zipFile
2005 2005
                 ->saveAsFile(base_path('storage/app/private/'.$path.$cid.".zip")); // save the archive to a file
2006 2006
                 //->extractTo(base_path('storage/app/private/'.$path)); // extract files to the specified directory
2007 2007
         }
2008
-        catch(\PhpZip\Exception\ZipException $e){
2008
+        catch (\PhpZip\Exception\ZipException $e) {
2009 2009
             // handle exception
2010 2010
             Log::debug($e);
2011 2011
         }
2012
-        finally{
2012
+        finally {
2013 2013
             $zipFile->close();
2014 2014
         }
2015 2015
     }
@@ -2021,21 +2021,21 @@  discard block
 block discarded – undo
2021 2021
         $contest=DB::table("contest")->where([
2022 2022
             "cid"=>$cid
2023 2023
         ])->first();
2024
-        return $outputFilename=(string)($contest["cid"])."-".$contest["name"].".zip";
2024
+        return $outputFilename=(string) ($contest["cid"])."-".$contest["name"].".zip";
2025 2025
     }
2026 2026
 
2027 2027
     public function judgeOver($cid)
2028 2028
     {
2029
-        $submissions =  DB::table('submission')
2029
+        $submissions=DB::table('submission')
2030 2030
             ->where(['cid' => $cid])
2031
-            ->whereIn('verdict',['Waiting','Pending'])
2031
+            ->whereIn('verdict', ['Waiting', 'Pending'])
2032 2032
             ->select('sid')
2033 2033
             ->get()->all();
2034
-        if(empty($submissions)){
2034
+        if (empty($submissions)) {
2035 2035
             return [
2036 2036
                 'result' => true
2037 2037
             ];
2038
-        }else{
2038
+        } else {
2039 2039
             return [
2040 2040
                 'result' => false,
2041 2041
                 'sid' => $submissions
Please login to merge, or discard this patch.
Braces   +28 added lines, -31 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                     $paginator=$paginator->where(["practice"=>$filter['practice']]);
229 229
                 }
230 230
                 $paginator = $paginator ->paginate(10);
231
-            }elseif($filter['public']=='0'){
231
+            } elseif($filter['public']=='0'){
232 232
                 $paginator=DB::table('group_member')
233 233
                 ->groupBy('contest.cid')
234 234
                 ->select('contest.*')
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                 )
259 259
                 ->orderBy('contest.begin_time', 'desc')
260 260
                 ->paginate(10);
261
-            }else{
261
+            } else{
262 262
                 $paginator=DB::table('group_member')
263 263
                 ->groupBy('contest.cid')
264 264
                 ->select('contest.*')
@@ -818,13 +818,13 @@  discard block
 block discarded – undo
818 818
         if(time() < $end_time){
819 819
             if($clearance == 3){
820 820
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
821
-            }else{
821
+            } else{
822 822
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
823 823
             }
824 824
             if(!isset($contestRankRaw)){
825 825
                 $contestRankRaw=$contest_eloquent->rankRefresh();
826 826
             }
827
-        }else{
827
+        } else{
828 828
             if($clearance == 3){
829 829
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
830 830
                 if (!isset($contestRankRaw)) {
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
                         $this->storeContestRankInMySQL($cid, $contestRankRaw);
835 835
                     }
836 836
                 }
837
-            }else{
837
+            } else{
838 838
                 $contestRankRaw=$this->getContestRankFromMySQL($cid);
839 839
                 if(!isset($contestRankRaw)){
840 840
                     $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
             return DB::table("contest_clarification")->where([
920 920
                 "cid"=>$cid
921 921
             ])->orderBy('created_at', 'desc')->get()->all();
922
-        }else{
922
+        } else{
923 923
             return DB::table("contest_clarification")->where([
924 924
                 "cid"=>$cid
925 925
             ])->where(function ($query) {
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
         $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1052 1052
         if($filter['pid']===false){
1053 1053
             $filter['pid'] = is_null($filter['ncode'])?null:-1;
1054
-        }else{
1054
+        } else{
1055 1055
             $filter['pid'] = $problemSet_temp[$filter['pid']]['pid'];
1056 1056
         }
1057 1057
 
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
                     "records"=>[]
1160 1160
                 ];
1161 1161
             }
1162
-        }else{
1162
+        } else{
1163 1163
             if ($basicInfo["status_visibility"]==2) {
1164 1164
                 // View all
1165 1165
                 $paginator=DB::table("submission")->where([
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
             if($ratingCalculator->calculate()){
1413 1413
                 $ratingCalculator->storage();
1414 1414
                 return true;
1415
-            }else{
1415
+            } else{
1416 1416
                 return false;
1417 1417
             }
1418 1418
         } else {
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
             $contestRankRaw = $this->contestRankCache($cid);
1462 1462
             Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
1463 1463
             Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
1464
-        }else{
1464
+        } else{
1465 1465
             DB::table($this->tableName)
1466 1466
                 ->where('cid',$cid)
1467 1467
                 ->update($data);
@@ -1563,8 +1563,7 @@  discard block
 block discarded – undo
1563 1563
                     if(time() > $chache['end_time']){
1564 1564
                         $this->storeContestRankInMySQL($cid, $ret);
1565 1565
                     }
1566
-                }
1567
-                else{
1566
+                } else{
1568 1567
                     $ret=[];
1569 1568
                     $chache=[];
1570 1569
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
@@ -1579,7 +1578,7 @@  discard block
 block discarded – undo
1579 1578
                             "cid"=>$cid,
1580 1579
                             "audit"=>1
1581 1580
                         ])->select('uid')->get()->all();
1582
-                    }else{
1581
+                    } else{
1583 1582
                         $submissionUsers=DB::table("submission")->where([
1584 1583
                             "cid"=>$cid
1585 1584
                         ])->where(
@@ -1614,9 +1613,9 @@  discard block
 block discarded – undo
1614 1613
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin);
1615 1614
                 }
1616 1615
             }
1617
-        }catch(LockTimeoutException $e){
1616
+        } catch(LockTimeoutException $e){
1618 1617
             Log::warning("Contest Rank Lock Timed Out");
1619
-        }finally{
1618
+        } finally{
1620 1619
             optional($lock)->release();
1621 1620
         }
1622 1621
     }
@@ -1639,7 +1638,7 @@  discard block
 block discarded – undo
1639 1638
                     return 1;
1640 1639
                 }
1641 1640
             });
1642
-        }else if ($contest_info["rule"]==2){
1641
+        } else if ($contest_info["rule"]==2){
1643 1642
             usort($ret, function ($a, $b) {
1644 1643
                 if ($a["score"]==$b["score"]) {
1645 1644
                     if ($a["solved"]==$b["solved"]) {
@@ -1663,8 +1662,9 @@  discard block
 block discarded – undo
1663 1662
     {
1664 1663
         $id = count($ret);
1665 1664
         foreach($ret as $key => $r){
1666
-            if($r['uid'] == $uid)
1667
-                $id = $key;
1665
+            if($r['uid'] == $uid) {
1666
+                            $id = $key;
1667
+            }
1668 1668
         }
1669 1669
         if ($contest_info["rule"]==1) {
1670 1670
             // ACM/ICPC Mode
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
                 $prob_detail = [];
1673 1673
                 $totPen = 0;
1674 1674
                 $totScore = 0;
1675
-            }else{
1675
+            } else{
1676 1676
                 $prob_detail = $ret[$id]['problem_detail'];
1677 1677
                 $totPen=$ret[$id]['penalty'];
1678 1678
                 $totScore=$ret[$id]['score'];
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
                 $prob_detail = [];
1731 1731
                 $totSolved = 0;
1732 1732
                 $totScore = 0;
1733
-            }else{
1733
+            } else{
1734 1734
                 $prob_detail = $ret[$id]['problem_detail'];
1735 1735
                 $totSolved=$ret[$id]['solved'];
1736 1736
                 $totScore=$ret[$id]['score'];
@@ -1796,18 +1796,18 @@  discard block
 block discarded – undo
1796 1796
                 return false;
1797 1797
             }
1798 1798
             return true;
1799
-        }else if($status === 0){
1799
+        } else if($status === 0){
1800 1800
             if($begin_time_new !== null){
1801 1801
                 return false;
1802 1802
             }
1803 1803
             if($end_time_new !== null){
1804 1804
                 if(strtotime($end_time_new) <= time()){
1805 1805
                     return false;
1806
-                }else{
1806
+                } else{
1807 1807
                     return true;
1808 1808
                 }
1809 1809
             }
1810
-        }else{
1810
+        } else{
1811 1811
             return false;
1812 1812
         }
1813 1813
 
@@ -1828,8 +1828,7 @@  discard block
 block discarded – undo
1828 1828
             return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1829 1829
                 "public"=>1
1830 1830
             ]);
1831
-        }
1832
-        else
1831
+        } else
1833 1832
         {
1834 1833
             return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1835 1834
                 "public"=>0
@@ -1853,7 +1852,7 @@  discard block
 block discarded – undo
1853 1852
             ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid'))
1854 1853
             ->select('pid','title')
1855 1854
             ->get()->all();
1856
-        }else{
1855
+        } else{
1857 1856
             $all_problems = [];
1858 1857
         }
1859 1858
         $tags = DB::table('group_problem_tag')
@@ -2004,12 +2003,10 @@  discard block
 block discarded – undo
2004 2003
             $zipFile
2005 2004
                 ->saveAsFile(base_path('storage/app/private/'.$path.$cid.".zip")); // save the archive to a file
2006 2005
                 //->extractTo(base_path('storage/app/private/'.$path)); // extract files to the specified directory
2007
-        }
2008
-        catch(\PhpZip\Exception\ZipException $e){
2006
+        } catch(\PhpZip\Exception\ZipException $e){
2009 2007
             // handle exception
2010 2008
             Log::debug($e);
2011
-        }
2012
-        finally{
2009
+        } finally{
2013 2010
             $zipFile->close();
2014 2011
         }
2015 2012
     }
@@ -2035,7 +2032,7 @@  discard block
 block discarded – undo
2035 2032
             return [
2036 2033
                 'result' => true
2037 2034
             ];
2038
-        }else{
2035
+        } else{
2039 2036
             return [
2040 2037
                 'result' => false,
2041 2038
                 'sid' => $submissions
Please login to merge, or discard this patch.
app/Models/JudgerModel.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             "oid"=>$oid,
60 60
             "available"=>1,
61 61
             "status"=>0
62
-        ])->orderBy('usage','asc')->get()->first();
62
+        ])->orderBy('usage', 'asc')->get()->first();
63 63
 
64 64
         return $serverList;
65 65
     }
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
     public function fetchServer($oid=0)
68 68
     {
69 69
         $serverList=DB::table("judge_server");
70
-        if($oid) $serverList=$serverList->where(["oid"=>$oid]);
70
+        if ($oid) $serverList=$serverList->where(["oid"=>$oid]);
71 71
         $serverList=$serverList->get()->all();
72 72
         foreach ($serverList as &$server) {
73
-            $server["status_parsed"]=is_null($server["status"])?self::$status["-1"]:self::$status[$server["status"]];
73
+            $server["status_parsed"]=is_null($server["status"]) ?self::$status["-1"] : self::$status[$server["status"]];
74 74
         }
75 75
         return $serverList;
76 76
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,9 @@
 block discarded – undo
67 67
     public function fetchServer($oid=0)
68 68
     {
69 69
         $serverList=DB::table("judge_server");
70
-        if($oid) $serverList=$serverList->where(["oid"=>$oid]);
70
+        if($oid) {
71
+            $serverList=$serverList->where(["oid"=>$oid]);
72
+        }
71 73
         $serverList=$serverList->get()->all();
72 74
         foreach ($serverList as &$server) {
73 75
             $server["status_parsed"]=is_null($server["status"])?self::$status["-1"]:self::$status[$server["status"]];
Please login to merge, or discard this patch.