Passed
Branch dev (6688ef)
by John
08:01
created
app/Http/Controllers/Ajax/ProblemController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
         if (empty($basic)) {
111 111
             return ResponseModel::err(3001);
112 112
         }
113
-        $ret=$problemModel->addSolution($pid,Auth::user()->id,$content);
114
-        return $ret?ResponseModel::success(200):ResponseModel::err(3003);
113
+        $ret=$problemModel->addSolution($pid, Auth::user()->id, $content);
114
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3003);
115 115
     }
116 116
     /**
117 117
      * The Ajax Problem Solution Discussion Update.
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
         $problemModel=new ProblemModel();
127 127
         $psoid=$all_data["psoid"];
128 128
         $content=$all_data["content"];
129
-        $ret=$problemModel->updateSolution($psoid,Auth::user()->id,$content);
130
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
129
+        $ret=$problemModel->updateSolution($psoid, Auth::user()->id, $content);
130
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
131 131
     }
132 132
     /**
133 133
      * The Ajax Problem Solution Discussion Delete.
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
         $all_data=$request->all();
142 142
         $problemModel=new ProblemModel();
143 143
         $psoid=$all_data["psoid"];
144
-        $ret=$problemModel->removeSolution($psoid,Auth::user()->id);
145
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
144
+        $ret=$problemModel->removeSolution($psoid, Auth::user()->id);
145
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
146 146
     }
147 147
     /**
148 148
      * The Ajax Problem Solution Discussion Vote.
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
         $problemModel=new ProblemModel();
158 158
         $psoid=$all_data["psoid"];
159 159
         $type=$all_data["type"];
160
-        $ret=$problemModel->voteSolution($psoid,Auth::user()->id,$type);
161
-        return $ret["ret"]?ResponseModel::success(200,null,["votes"=>$ret["votes"],"select"=>$ret["select"]]):ResponseModel::err(3004);
160
+        $ret=$problemModel->voteSolution($psoid, Auth::user()->id, $type);
161
+        return $ret["ret"] ?ResponseModel::success(200, null, ["votes"=>$ret["votes"], "select"=>$ret["select"]]) : ResponseModel::err(3004);
162 162
     }
163 163
     /**
164 164
      * The Ajax Problem Solution Submit.
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 
252 252
         $submissionData=$submissionModel->basic($all_data["sid"]);
253 253
 
254
-        if($submissionData["uid"]!=Auth::user()->id){
254
+        if ($submissionData["uid"]!=Auth::user()->id) {
255 255
             return ResponseModel::err(2001);
256 256
         }
257 257
 
258
-        if($submissionData["verdict"]!="Submission Error"){
258
+        if ($submissionData["verdict"]!="Submission Error") {
259 259
             return ResponseModel::err(6003);
260 260
         }
261 261
 
262
-        $submissionModel->updateSubmission($all_data["sid"],[
262
+        $submissionModel->updateSubmission($all_data["sid"], [
263 263
             "verdict"=>"Pending",
264 264
             "time"=>0,
265 265
             "memory"=>0
Please login to merge, or discard this patch.
app/Models/ProblemModel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -177,9 +177,9 @@
 block discarded – undo
177 177
 
178 178
     private function inteliAudit($uid, $content)
179 179
     {
180
-        if (strpos($content, '```')!==false){
180
+        if (strpos($content, '```')!==false) {
181 181
             $userSolutionHistory=DB::table("problem_solution")->where(['uid'=>$uid])->orderByDesc('updated_at')->first();
182
-            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1){
182
+            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1) {
183 183
                 return 1;
184 184
             }
185 185
         }
Please login to merge, or discard this patch.
app/Models/Search/GroupSearchModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 
13 13
     public function search($key)
14 14
     {
15
-        $result = [];
15
+        $result=[];
16 16
         //group name or gcode find
17
-        if(strlen($key) >= 2){
18
-            $ret = self::where(function($query) use ($key){
19
-                $query->whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key])
17
+        if (strlen($key)>=2) {
18
+            $ret=self::where(function($query) use ($key){
19
+                $query->whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key])
20 20
                     ->orWhere('gcode', $key);
21 21
                 })
22
-                ->where('public',1)
23
-                ->select('gid','gcode', 'img', 'name', 'description')
22
+                ->where('public', 1)
23
+                ->select('gid', 'gcode', 'img', 'name', 'description')
24 24
                 ->limit(120)
25 25
                 ->get()->all();
26
-            if(!empty($ret)){
27
-                $result += $ret;
26
+            if (!empty($ret)) {
27
+                $result+=$ret;
28 28
             }
29 29
         }
30 30
 
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('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'])){
29
+            if ($problemModel->isBlocked($p['pid'])) {
30 30
                 unset($result[$p_index]);
31 31
             }
32 32
         }
Please login to merge, or discard this patch.
app/Models/Search/ContestSearchModel.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@
 block discarded – undo
15 15
 
16 16
     public function search($key)
17 17
     {
18
-        $result = [];
18
+        $result=[];
19 19
         //contest name find
20
-        if(strlen($key) >= 2){
21
-            $ret = self::whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key])
20
+        if (strlen($key)>=2) {
21
+            $ret=self::whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key])
22 22
                 ->select('cid', 'gid', 'name', 'rule', 'public', 'verified', 'practice', 'rated', 'anticheated', 'begin_time', 'end_time')
23
-                ->orderBy('end_time','DESC')
23
+                ->orderBy('end_time', 'DESC')
24 24
                 ->limit(120)
25 25
                 ->get()->all();
26
-            $user_id = Auth::user()->id;
27
-            $contestModel = new ContestModel();
28
-            foreach($ret as $c_index => $c){
29
-                if(!$contestModel->judgeClearance($c['cid'],$user_id)){
26
+            $user_id=Auth::user()->id;
27
+            $contestModel=new ContestModel();
28
+            foreach ($ret as $c_index => $c) {
29
+                if (!$contestModel->judgeClearance($c['cid'], $user_id)) {
30 30
                     unset($ret[$c_index]);
31 31
                 }
32 32
             }
33
-            if(!empty($ret)){
34
-                $result += $ret;
33
+            if (!empty($ret)) {
34
+                $result+=$ret;
35 35
             }
36 36
         }
37
-        if(!empty($result)) {
37
+        if (!empty($result)) {
38 38
             foreach ($result as &$contest) {
39 39
                 $contest["rule_parsed"]=$this->rule[$contest["rule"]];
40 40
                 $contest["date_parsed"]=[
Please login to merge, or discard this patch.
app/Models/Search/UserSearchModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
 
11 11
     public function search($key)
12 12
     {
13
-        $result = [];
14
-        if(strlen($key) >= 2){
15
-            $ret = self::where('email',$key)
16
-                ->orWhereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key])
17
-                ->select('id','avatar', 'name',  'describes', 'professional_rate')
18
-                ->orderBy('professional_rate','DESC')
13
+        $result=[];
14
+        if (strlen($key)>=2) {
15
+            $ret=self::where('email', $key)
16
+                ->orWhereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key])
17
+                ->select('id', 'avatar', 'name', 'describes', 'professional_rate')
18
+                ->orderBy('professional_rate', 'DESC')
19 19
                 ->limit(120)
20 20
                 ->get()->all();
21
-            if(!empty($ret)){
22
-                $result += $ret;
21
+            if (!empty($ret)) {
22
+                $result+=$ret;
23 23
             }
24 24
         }
25 25
         return $result;
Please login to merge, or discard this patch.
app/Models/Babel/ExtensionModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
     {
22 22
         $ret=[];
23 23
         $marketspaceRaw=self::getRemote();
24
-        if(empty($marketspaceRaw)) return [];
25
-        foreach($marketspaceRaw["packages"] as $extension){
24
+        if (empty($marketspaceRaw)) return [];
25
+        foreach ($marketspaceRaw["packages"] as $extension) {
26 26
             $temp=[
27 27
                 "details"=>$extension,
28 28
                 "status"=>0,
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
                 "settings"=>null,
32 32
                 "available"=>null
33 33
             ];
34
-            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge";
34
+            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge";
35 35
             try {
36 36
                 try {
37 37
                     $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true);
38
-                }catch (Throwable $e){
38
+                } catch (Throwable $e) {
39 39
                     $BabelConfig=[];
40 40
                 }
41 41
                 if (!empty($BabelConfig)) {
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
                     $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion);
48 48
 
49 49
                     $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();
50
-                    if (is_null($installedConfig)){
50
+                    if (is_null($installedConfig)) {
51 51
                         $temp["status"]=1;
52 52
                     } else {
53 53
                         $temp["version"]=$installedConfig->version; // local installed version
54 54
                         $installedVersion=new Version($temp["version"]);
55
-                        if ($downloadedVersion->isGreaterThan($installedVersion)){
55
+                        if ($downloadedVersion->isGreaterThan($installedVersion)) {
56 56
                             $temp["status"]=1;
57 57
                         } else {
58 58
                             $temp["status"]=2;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                         $temp["available"]=$installedConfig->status;
62 62
                     }
63 63
                 }
64
-            }catch (Throwable $e){
64
+            } catch (Throwable $e) {
65 65
                 $temp["status"]=-1;
66 66
             }
67 67
             $ret[]=$temp;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     {
75 75
         try {
76 76
             return json_decode(file_get_contents(env("BABEL_MIRROR", "https://acm.njupt.edu.cn/babel")."/babel.json"), true);
77
-        }catch(Throwable $e){
77
+        } catch (Throwable $e) {
78 78
             return [];
79 79
         }
80 80
     }
Please login to merge, or discard this patch.
app/Models/ContestModel.php 1 patch
Spacing   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 
112 112
     public function gcode($cid)
113 113
     {
114
-        $gid = $this->gid($cid);
115
-        return DB::table('group')->where('gid','=',$gid)->first()["gcode"];
114
+        $gid=$this->gid($cid);
115
+        return DB::table('group')->where('gid', '=', $gid)->first()["gcode"];
116 116
     }
117 117
 
118 118
     public function runningContest()
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
 
138 138
     public function listForSetting($gid)
139 139
     {
140
-        $uid = Auth::user()->id;
141
-        $group_contests = DB::table('contest')
142
-            ->where('gid',$gid)
143
-            ->orderBy('begin_time','desc')
140
+        $uid=Auth::user()->id;
141
+        $group_contests=DB::table('contest')
142
+            ->where('gid', $gid)
143
+            ->orderBy('begin_time', 'desc')
144 144
             ->get()->all();
145
-        $groupModel = new GroupModel();
146
-        $group_clearance = $groupModel->judgeClearance($gid,$uid);
145
+        $groupModel=new GroupModel();
146
+        $group_clearance=$groupModel->judgeClearance($gid, $uid);
147 147
         foreach ($group_contests as &$contest) {
148
-            $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3);
149
-            $contest['begin_stamps'] = strtotime($contest['begin_time']);
150
-            $contest['end_stamps'] = strtotime($contest['end_time']);
151
-            $contest['status'] = time() >= $contest['end_stamps'] ? 1
152
-                : (time() <= $contest['begin_stamps'] ? -1 : 0);
148
+            $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3);
149
+            $contest['begin_stamps']=strtotime($contest['begin_time']);
150
+            $contest['end_stamps']=strtotime($contest['end_time']);
151
+            $contest['status']=time()>=$contest['end_stamps'] ? 1
152
+                : (time()<=$contest['begin_stamps'] ? -1 : 0);
153 153
             $contest["rule_parsed"]=$this->rule[$contest["rule"]];
154 154
             $contest["date_parsed"]=[
155 155
                 "date"=>date_format(date_create($contest["begin_time"]), 'j'),
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
             ];
158 158
             $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]);
159 159
         }
160
-        usort($group_contests,function($a,$b){
161
-            if($a['is_admin'] == $b['is_admin']){
162
-                return $b['begin_stamps'] - $a['begin_stamps'];
160
+        usort($group_contests, function($a, $b) {
161
+            if ($a['is_admin']==$b['is_admin']) {
162
+                return $b['begin_stamps']-$a['begin_stamps'];
163 163
             }
164
-            return $b['is_admin'] - $a['is_admin'];
164
+            return $b['is_admin']-$a['is_admin'];
165 165
         });
166 166
         return $group_contests;
167 167
     }
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
         //     "gid"=>$gid
173 173
         // ])->orderBy('begin_time', 'desc')->get()->all();
174 174
         $preQuery=DB::table($this->tableName);
175
-        $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10);
175
+        $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10);
176 176
         $contest_list=$paginator->all();
177
-        if(empty($contest_list)){
177
+        if (empty($contest_list)) {
178 178
             return null;
179 179
         }
180 180
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         ])->first()["rule"];
200 200
     }
201 201
 
202
-    public function list($filter,$uid)
202
+    public function list($filter, $uid)
203 203
     {
204 204
         if ($uid) {
205 205
             //$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);
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
                 if ($filter['practice']) {
224 224
                     $paginator=$paginator->where(["practice"=>$filter['practice']]);
225 225
                 }
226
-                $paginator = $paginator ->paginate(10);
227
-            }elseif($filter['public']=='0'){
226
+                $paginator=$paginator ->paginate(10);
227
+            }elseif ($filter['public']=='0') {
228 228
                 $paginator=DB::table('group_member')
229 229
                 ->groupBy('contest.cid')
230 230
                 ->select('contest.*')
231 231
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
232 232
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
233 233
                 ->where(
234
-                    function ($query) use ($filter,$uid) {
234
+                    function($query) use ($filter, $uid) {
235 235
                         if ($filter['rule']) {
236 236
                             $query=$query->where(["rule"=>$filter['rule']]);
237 237
                         }
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
                 )
255 255
                 ->orderBy('contest.begin_time', 'desc')
256 256
                 ->paginate(10);
257
-            }else{
257
+            } else {
258 258
                 $paginator=DB::table('group_member')
259 259
                 ->groupBy('contest.cid')
260 260
                 ->select('contest.*')
261 261
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
262 262
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
263 263
                 ->where(
264
-                    function ($query) use ($filter) {
264
+                    function($query) use ($filter) {
265 265
                         if ($filter['rule']) {
266 266
                             $query=$query->where(["rule"=>$filter['rule']]);
267 267
                         }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                     }
283 283
                 )
284 284
                 ->orWhere(
285
-                    function ($query) use ($filter,$uid) {
285
+                    function($query) use ($filter, $uid) {
286 286
                         if ($filter['rule']) {
287 287
                             $query=$query->where(["rule"=>$filter['rule']]);
288 288
                         }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             if ($filter['practice']) {
329 329
                 $paginator=$paginator->where(["practice"=>$filter['practice']]);
330 330
             }
331
-            $paginator = $paginator ->paginate(10);
331
+            $paginator=$paginator ->paginate(10);
332 332
         }
333 333
         $contest_list=$paginator->all();
334 334
         foreach ($contest_list as &$c) {
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
         }
367 367
     }
368 368
 
369
-    public function registContest($cid,$uid)
369
+    public function registContest($cid, $uid)
370 370
     {
371 371
         $registered=DB::table("contest_participant")->where([
372 372
             "cid"=>$cid,
373 373
             "uid"=>$uid
374 374
         ])->first();
375 375
 
376
-        if(empty($registered)){
376
+        if (empty($registered)) {
377 377
             DB::table("contest_participant")->insert([
378 378
                 "cid"=>$cid,
379 379
                 "uid"=>$uid,
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
     public function problems($cid)
407 407
     {
408 408
         return DB::table('contest_problem')
409
-            ->join('problem','contest_problem.pid','=','problem.pid')
410
-            ->where('cid',$cid)
411
-            ->select('problem.pid as pid','pcode','number')
409
+            ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
410
+            ->where('cid', $cid)
411
+            ->select('problem.pid as pid', 'pcode', 'number')
412 412
             ->orderBy('number')
413 413
             ->get()->all();
414 414
     }
@@ -430,18 +430,18 @@  discard block
 block discarded – undo
430 430
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
431 431
 
432 432
         foreach ($problemSet as &$p) {
433
-            if($p['practice']){
434
-                $tags = DB::table("group_problem_tag")
435
-                ->where('gid',$p['gid'])
436
-                ->where('pid',$p['pid'])
433
+            if ($p['practice']) {
434
+                $tags=DB::table("group_problem_tag")
435
+                ->where('gid', $p['gid'])
436
+                ->where('pid', $p['pid'])
437 437
                 ->get()->all();
438
-                $tags_arr = [];
439
-                if(!empty($tags)){
438
+                $tags_arr=[];
439
+                if (!empty($tags)) {
440 440
                     foreach ($tags as $value) {
441
-                        array_push($tags_arr,$value['tag']);
441
+                        array_push($tags_arr, $value['tag']);
442 442
                     }
443 443
                 }
444
-                $p['tags'] = $tags_arr;
444
+                $p['tags']=$tags_arr;
445 445
             }
446 446
             if ($contest_rule==1) {
447 447
                 $prob_stat=DB::table("submission")->select(
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
                     "problem_detail" => $prob_detail
703 703
                 ];
704 704
             }
705
-            usort($ret, function ($a, $b) {
705
+            usort($ret, function($a, $b) {
706 706
                 if ($a["score"]==$b["score"]) {
707 707
                     if ($a["penalty"]==$b["penalty"]) {
708 708
                         return 0;
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
                     "problem_detail" => $prob_detail
750 750
                 ];
751 751
             }
752
-            usort($ret, function ($a, $b) {
752
+            usort($ret, function($a, $b) {
753 753
                 if ($a["score"]==$b["score"]) {
754 754
                     if ($a["solved"]==$b["solved"]) {
755 755
                         return 0;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
         return $ret;
772 772
     }
773 773
 
774
-    public function contestRank($cid, $uid = 0)
774
+    public function contestRank($cid, $uid=0)
775 775
     {
776 776
         // [ToDo] If the current user's in the organizer group show nick name
777 777
         // [ToDo] The participants determination
@@ -789,35 +789,35 @@  discard block
 block discarded – undo
789 789
             "gid" => $contest_info["gid"]
790 790
         ])->where("role", ">", 0)->first());
791 791
 
792
-        $clearance = $this -> judgeClearance($cid, $uid);
792
+        $clearance=$this -> judgeClearance($cid, $uid);
793 793
 
794 794
         /** New Version With MySQL */
795 795
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
796 796
 
797
-        if(time() < $end_time){
798
-            if($clearance == 3){
797
+        if (time()<$end_time) {
798
+            if ($clearance==3) {
799 799
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
800
-            }else{
800
+            } else {
801 801
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
802 802
             }
803
-            if(!isset($contestRankRaw)){
803
+            if (!isset($contestRankRaw)) {
804 804
                 $contestRankRaw=$this->contestRankCache($cid);
805 805
             }
806
-        }else{
807
-            if($clearance == 3){
806
+        } else {
807
+            if ($clearance==3) {
808 808
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
809 809
                 if (!isset($contestRankRaw)) {
810 810
                     $contestRankRaw=$this->getContestRankFromMySQL($cid);
811
-                    if(!isset($contestRankRaw)){
811
+                    if (!isset($contestRankRaw)) {
812 812
                         $contestRankRaw=$this->contestRankCache($cid);
813 813
                         $this->storeContestRankInMySQL($cid, $contestRankRaw);
814 814
                     }
815 815
                 }
816
-            }else{
816
+            } else {
817 817
                 $contestRankRaw=$this->getContestRankFromMySQL($cid);
818
-                if(!isset($contestRankRaw)){
818
+                if (!isset($contestRankRaw)) {
819 819
                     $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
820
-                    if(!isset($contestRankRaw)){
820
+                    if (!isset($contestRankRaw)) {
821 821
                         $contestRankRaw=$this->contestRankCache($cid);
822 822
                     }
823 823
                     $this->storeContestRankInMySQL($cid, $contestRankRaw);
@@ -835,15 +835,15 @@  discard block
 block discarded – undo
835 835
         //         $contestRankRaw=$this->contestRankCache($cid);
836 836
         //     }
837 837
         // }
838
-        if($contest_info["rule"]==1){
838
+        if ($contest_info["rule"]==1) {
839 839
             foreach ($contestRankRaw as &$cr) {
840
-                $solved = 0;
841
-                foreach($cr['problem_detail'] as $pd){
842
-                    if(!empty($pd['solved_time_parsed'])){
843
-                        $solved ++;
840
+                $solved=0;
841
+                foreach ($cr['problem_detail'] as $pd) {
842
+                    if (!empty($pd['solved_time_parsed'])) {
843
+                        $solved++;
844 844
                     }
845 845
                 }
846
-                $cr['solved'] = $solved;
846
+                $cr['solved']=$solved;
847 847
             }
848 848
         }
849 849
 
@@ -892,16 +892,16 @@  discard block
 block discarded – undo
892 892
 
893 893
     public function getClarificationList($cid)
894 894
     {
895
-        $uid = Auth::user()->id;
896
-        $clearance = $this -> judgeClearance($cid, $uid);
897
-        if($clearance == 3){
895
+        $uid=Auth::user()->id;
896
+        $clearance=$this -> judgeClearance($cid, $uid);
897
+        if ($clearance==3) {
898 898
             return DB::table("contest_clarification")->where([
899 899
                 "cid"=>$cid
900 900
             ])->orderBy('create_time', 'desc')->get()->all();
901
-        }else{
901
+        } else {
902 902
             return DB::table("contest_clarification")->where([
903 903
                 "cid"=>$cid
904
-            ])->where(function ($query) {
904
+            ])->where(function($query) {
905 905
                 $query->where([
906 906
                     "public"=>1
907 907
                 ])->orWhere([
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
     public function getContestRecord($filter, $cid)
1047 1047
     {
1048 1048
         $basicInfo=$this->basic($cid);
1049
-        $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first();
1049
+        $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first();
1050 1050
         $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
1051 1051
             "cid"=>$cid
1052 1052
         ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all();
@@ -1059,14 +1059,14 @@  discard block
 block discarded – undo
1059 1059
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1060 1060
         $contestEnd=time()>$end_time;
1061 1061
 
1062
-        $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1063
-        if($filter['pid']==false){
1064
-            $filter['pid'] = null;
1065
-        }else{
1066
-            $filter['pid'] = $problemSet_temp[$filter['pid']]['pid'];
1062
+        $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1063
+        if ($filter['pid']==false) {
1064
+            $filter['pid']=null;
1065
+        } else {
1066
+            $filter['pid']=$problemSet_temp[$filter['pid']]['pid'];
1067 1067
         }
1068 1068
 
1069
-        if($userInfo==null || $userInfo["role"]!=3){
1069
+        if ($userInfo==null || $userInfo["role"]!=3) {
1070 1070
             if ($basicInfo["status_visibility"]==2) {
1071 1071
                 // View all
1072 1072
                 $paginator=DB::table("submission")->where([
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
                     "users.id",
1081 1081
                     "=",
1082 1082
                     "submission.uid"
1083
-                )->where(function ($query) use ($frozen_time) {
1083
+                )->where(function($query) use ($frozen_time) {
1084 1084
                     $query->where(
1085 1085
                         "submission_date",
1086 1086
                         "<",
@@ -1107,15 +1107,15 @@  discard block
 block discarded – undo
1107 1107
                     'desc'
1108 1108
                 );
1109 1109
 
1110
-                if($filter["pid"]){
1110
+                if ($filter["pid"]) {
1111 1111
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1112 1112
                 }
1113 1113
 
1114
-                if($filter["result"]){
1114
+                if ($filter["result"]) {
1115 1115
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1116 1116
                 }
1117 1117
 
1118
-                if($filter["account"]){
1118
+                if ($filter["account"]) {
1119 1119
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1120 1120
                 }
1121 1121
 
@@ -1151,15 +1151,15 @@  discard block
 block discarded – undo
1151 1151
                     'desc'
1152 1152
                 );
1153 1153
 
1154
-                if($filter["pid"]){
1154
+                if ($filter["pid"]) {
1155 1155
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1156 1156
                 }
1157 1157
 
1158
-                if($filter["result"]){
1158
+                if ($filter["result"]) {
1159 1159
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1160 1160
                 }
1161 1161
 
1162
-                if($filter["account"]){
1162
+                if ($filter["account"]) {
1163 1163
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1164 1164
                 }
1165 1165
 
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
                     "records"=>[]
1171 1171
                 ];
1172 1172
             }
1173
-        }else{
1173
+        } else {
1174 1174
             if ($basicInfo["status_visibility"]==2) {
1175 1175
                 // View all
1176 1176
                 $paginator=DB::table("submission")->where([
@@ -1202,15 +1202,15 @@  discard block
 block discarded – undo
1202 1202
                     'desc'
1203 1203
                 );
1204 1204
 
1205
-                if($filter["pid"]){
1205
+                if ($filter["pid"]) {
1206 1206
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1207 1207
                 }
1208 1208
 
1209
-                if($filter["result"]){
1209
+                if ($filter["result"]) {
1210 1210
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1211 1211
                 }
1212 1212
 
1213
-                if($filter["account"]){
1213
+                if ($filter["account"]) {
1214 1214
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1215 1215
                 }
1216 1216
 
@@ -1246,15 +1246,15 @@  discard block
 block discarded – undo
1246 1246
                     'desc'
1247 1247
                 );
1248 1248
 
1249
-                if($filter["pid"]){
1249
+                if ($filter["pid"]) {
1250 1250
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1251 1251
                 }
1252 1252
 
1253
-                if($filter["result"]){
1253
+                if ($filter["result"]) {
1254 1254
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1255 1255
                 }
1256 1256
 
1257
-                if($filter["account"]){
1257
+                if ($filter["account"]) {
1258 1258
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1259 1259
                 }
1260 1260
 
@@ -1310,21 +1310,21 @@  discard block
 block discarded – undo
1310 1310
         if ($uid==0) {
1311 1311
             return 0;
1312 1312
         }
1313
-        $groupModel = new GroupModel();
1313
+        $groupModel=new GroupModel();
1314 1314
         $contest_info=DB::table("contest")->where("cid", $cid)->first();
1315
-        $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first();
1315
+        $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first();
1316 1316
 
1317
-        if(empty($contest_info)){
1317
+        if (empty($contest_info)) {
1318 1318
             // contest not exist
1319 1319
             return 0;
1320 1320
         }
1321 1321
 
1322
-        if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){
1322
+        if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) {
1323 1323
             return 3;
1324 1324
         }
1325 1325
 
1326
-        $contest_started = strtotime($contest_info['begin_time']) < time();
1327
-        $contest_ended = strtotime($contest_info['end_time']) < time();
1326
+        $contest_started=strtotime($contest_info['begin_time'])<time();
1327
+        $contest_ended=strtotime($contest_info['end_time'])<time();
1328 1328
         if (!$contest_started) {
1329 1329
             // not started or do not exist
1330 1330
             return 0;
@@ -1415,12 +1415,12 @@  discard block
 block discarded – undo
1415 1415
     public function updateProfessionalRate($cid)
1416 1416
     {
1417 1417
         $basic=$this->basic($cid);
1418
-        if($basic["rated"]&&!$basic["is_rated"]){
1418
+        if ($basic["rated"] && !$basic["is_rated"]) {
1419 1419
             $ratingCalculator=new RatingCalculator($cid);
1420
-            if($ratingCalculator->calculate()){
1420
+            if ($ratingCalculator->calculate()) {
1421 1421
                 $ratingCalculator->storage();
1422 1422
                 return true;
1423
-            }else{
1423
+            } else {
1424 1424
                 return false;
1425 1425
             }
1426 1426
         } else {
@@ -1428,26 +1428,26 @@  discard block
 block discarded – undo
1428 1428
         }
1429 1429
     }
1430 1430
 
1431
-    public function contestUpdate($cid,$data,$problems)
1431
+    public function contestUpdate($cid, $data, $problems)
1432 1432
     {
1433
-        if($problems !== false){
1434
-            $old_problmes = array_column(
1433
+        if ($problems!==false) {
1434
+            $old_problmes=array_column(
1435 1435
                 DB::table('contest_problem')
1436
-                ->where('cid',$cid)
1436
+                ->where('cid', $cid)
1437 1437
                 ->get()->all(),
1438 1438
                 'pid'
1439 1439
             );
1440
-            DB::transaction(function () use ($cid, $data, $problems,$old_problmes) {
1440
+            DB::transaction(function() use ($cid, $data, $problems, $old_problmes) {
1441 1441
                 DB::table($this->tableName)
1442
-                    ->where('cid',$cid)
1442
+                    ->where('cid', $cid)
1443 1443
                     ->update($data);
1444 1444
                 DB::table('contest_problem')
1445
-                    ->where('cid',$cid)
1445
+                    ->where('cid', $cid)
1446 1446
                     ->delete();
1447
-                $new_problems = [];
1447
+                $new_problems=[];
1448 1448
                 foreach ($problems as $p) {
1449 1449
                     $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"];
1450
-                    array_push($new_problems,$pid);
1450
+                    array_push($new_problems, $pid);
1451 1451
                     DB::table("contest_problem")->insert([
1452 1452
                         "cid"=>$cid,
1453 1453
                         "number"=>$p["number"],
@@ -1457,29 +1457,29 @@  discard block
 block discarded – undo
1457 1457
                         "points"=>$p["points"]
1458 1458
                     ]);
1459 1459
                 }
1460
-                foreach($old_problmes as $op) {
1461
-                    if(!in_array($op,$new_problems)){
1460
+                foreach ($old_problmes as $op) {
1461
+                    if (!in_array($op, $new_problems)) {
1462 1462
                         DB::table('submission')
1463
-                            ->where('cid',$cid)
1464
-                            ->where('pid',$op)
1463
+                            ->where('cid', $cid)
1464
+                            ->where('pid', $op)
1465 1465
                             ->delete();
1466 1466
                     }
1467 1467
                 }
1468 1468
             }, 5);
1469
-            $contestRankRaw = $this->contestRankCache($cid);
1469
+            $contestRankRaw=$this->contestRankCache($cid);
1470 1470
             Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
1471 1471
             Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
1472
-        }else{
1472
+        } else {
1473 1473
             DB::table($this->tableName)
1474
-                ->where('cid',$cid)
1474
+                ->where('cid', $cid)
1475 1475
                 ->update($data);
1476 1476
         }
1477 1477
     }
1478 1478
 
1479
-    public function contestUpdateProblem($cid,$problems)
1479
+    public function contestUpdateProblem($cid, $problems)
1480 1480
     {
1481 1481
         DB::table('contest_problem')
1482
-                ->where('cid',$cid)
1482
+                ->where('cid', $cid)
1483 1483
                 ->delete();
1484 1484
         foreach ($problems as $p) {
1485 1485
             DB::table("contest_problem")->insertGetId([
@@ -1495,8 +1495,8 @@  discard block
 block discarded – undo
1495 1495
 
1496 1496
     public function arrangeContest($gid, $config, $problems)
1497 1497
     {
1498
-        $cid = -1;
1499
-        DB::transaction(function () use ($gid, $config, $problems,&$cid) {
1498
+        $cid=-1;
1499
+        DB::transaction(function() use ($gid, $config, $problems, &$cid) {
1500 1500
             $cid=DB::table($this->tableName)->insertGetId([
1501 1501
                 "gid"=>$gid,
1502 1502
                 "name"=>$config["name"],
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
                 "rule"=>1, //todo
1511 1511
                 "begin_time"=>$config["begin_time"],
1512 1512
                 "end_time"=>$config["end_time"],
1513
-                "vcid"=>isset($config["vcid"])?$config["vcid"]:null,
1513
+                "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null,
1514 1514
                 "public"=>$config["public"],
1515 1515
                 "registration"=>0, //todo
1516 1516
                 "registration_due"=>null, //todo
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
                 "froze_length"=>0, //todo
1519 1519
                 "status_visibility"=>2, //todo
1520 1520
                 "create_time"=>date("Y-m-d H:i:s"),
1521
-                "crawled" => isset($config['vcid'])?$config['crawled'] : null,
1521
+                "crawled" => isset($config['vcid']) ? $config['crawled'] : null,
1522 1522
                 "audit_status"=>$config["public"] ? 0 : 1
1523 1523
             ]);
1524 1524
 
@@ -1537,13 +1537,13 @@  discard block
 block discarded – undo
1537 1537
         return $cid;
1538 1538
     }
1539 1539
 
1540
-    public function updateContestRankTable($cid,$sub)
1540
+    public function updateContestRankTable($cid, $sub)
1541 1541
     {
1542
-        $lock = Cache::lock("contestrank$cid",10);
1543
-        try{
1544
-            if($lock->get()){
1545
-                if(Cache::tags(['contest','rank'])->get($cid) != null){
1546
-                    $ret = Cache::tags(['contest','rank'])->get($cid);
1542
+        $lock=Cache::lock("contestrank$cid", 10);
1543
+        try {
1544
+            if ($lock->get()) {
1545
+                if (Cache::tags(['contest', 'rank'])->get($cid)!=null) {
1546
+                    $ret=Cache::tags(['contest', 'rank'])->get($cid);
1547 1547
                     $chache=[];
1548 1548
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
1549 1549
                     $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
@@ -1552,27 +1552,27 @@  discard block
 block discarded – undo
1552 1552
                     $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"];
1553 1553
                     $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1554 1554
 
1555
-                    $id = 0;
1555
+                    $id=0;
1556 1556
 
1557
-                    foreach($chache['problemSet'] as $key => $p){
1558
-                        if ($p['pid'] == $sub['pid']){
1559
-                            $chache['problemSet'][$key]['cpid'] = $key;
1560
-                            $id = $key;
1557
+                    foreach ($chache['problemSet'] as $key => $p) {
1558
+                        if ($p['pid']==$sub['pid']) {
1559
+                            $chache['problemSet'][$key]['cpid']=$key;
1560
+                            $id=$key;
1561 1561
                         }
1562 1562
                     }
1563 1563
 
1564
-                    $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret);
1565
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1564
+                    $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret);
1565
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1566 1566
 
1567
-                    if (time() < $chache['frozen_time']){
1567
+                    if (time()<$chache['frozen_time']) {
1568 1568
                         Cache::tags(['contest', 'rank'])->put($cid, $ret);
1569 1569
                     }
1570 1570
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret);
1571
-                    if(time() > $chache['end_time']){
1571
+                    if (time()>$chache['end_time']) {
1572 1572
                         $this->storeContestRankInMySQL($cid, $ret);
1573 1573
                     }
1574 1574
                 }
1575
-                else{
1575
+                else {
1576 1576
                     $ret=[];
1577 1577
                     $chache=[];
1578 1578
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
                             "cid"=>$cid,
1588 1588
                             "audit"=>1
1589 1589
                         ])->select('uid')->get()->all();
1590
-                    }else{
1590
+                    } else {
1591 1591
                         $submissionUsers=DB::table("submission")->where([
1592 1592
                             "cid"=>$cid
1593 1593
                         ])->where(
@@ -1600,39 +1600,39 @@  discard block
 block discarded – undo
1600 1600
                         ])->select('uid')->groupBy('uid')->get()->all();
1601 1601
                     }
1602 1602
 
1603
-                    $chacheAdmin = $chache;
1603
+                    $chacheAdmin=$chache;
1604 1604
 
1605 1605
                     foreach ($submissionUsers as $s) {
1606 1606
                         foreach ($chache['problemSet'] as $key => $p) {
1607
-                            $p['cpid'] = $key;
1608
-                            $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret);
1607
+                            $p['cpid']=$key;
1608
+                            $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret);
1609 1609
                         }
1610 1610
                     }
1611
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1611
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1612 1612
                     Cache::tags(['contest', 'rank'])->put($cid, $ret);
1613 1613
 
1614 1614
                     $retAdmin=[];
1615 1615
                     foreach ($submissionUsersAdmin as $s) {
1616 1616
                         foreach ($chacheAdmin['problemSet'] as $key => $p) {
1617
-                            $p['cpid'] = $key;
1618
-                            $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin);
1617
+                            $p['cpid']=$key;
1618
+                            $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin);
1619 1619
                         }
1620 1620
                     }
1621
-                    $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin);
1621
+                    $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin);
1622 1622
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin);
1623 1623
                 }
1624 1624
             }
1625
-        }catch(LockTimeoutException $e){
1625
+        } catch (LockTimeoutException $e) {
1626 1626
             Log::warning("Contest Rank Lock Timed Out");
1627
-        }finally{
1627
+        } finally {
1628 1628
             optional($lock)->release();
1629 1629
         }
1630 1630
     }
1631 1631
 
1632
-    public function sortContestRankTable($contest_info,$cid,$ret)
1632
+    public function sortContestRankTable($contest_info, $cid, $ret)
1633 1633
     {
1634
-        if ($contest_info["rule"]==1){
1635
-            usort($ret, function ($a, $b) {
1634
+        if ($contest_info["rule"]==1) {
1635
+            usort($ret, function($a, $b) {
1636 1636
                 if ($a["score"]==$b["score"]) {
1637 1637
                     if ($a["penalty"]==$b["penalty"]) {
1638 1638
                         return 0;
@@ -1647,8 +1647,8 @@  discard block
 block discarded – undo
1647 1647
                     return 1;
1648 1648
                 }
1649 1649
             });
1650
-        }else if ($contest_info["rule"]==2){
1651
-            usort($ret, function ($a, $b) {
1650
+        } else if ($contest_info["rule"]==2) {
1651
+            usort($ret, function($a, $b) {
1652 1652
                 if ($a["score"]==$b["score"]) {
1653 1653
                     if ($a["solved"]==$b["solved"]) {
1654 1654
                         return 0;
@@ -1667,21 +1667,21 @@  discard block
 block discarded – undo
1667 1667
         return $ret;
1668 1668
     }
1669 1669
 
1670
-    public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret)
1670
+    public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret)
1671 1671
     {
1672
-        $id = count($ret);
1673
-        foreach($ret as $key => $r){
1674
-            if($r['uid'] == $uid)
1675
-                $id = $key;
1672
+        $id=count($ret);
1673
+        foreach ($ret as $key => $r) {
1674
+            if ($r['uid']==$uid)
1675
+                $id=$key;
1676 1676
         }
1677 1677
         if ($contest_info["rule"]==1) {
1678 1678
             // ACM/ICPC Mode
1679
-            if($id == count($ret)){
1680
-                $prob_detail = [];
1681
-                $totPen = 0;
1682
-                $totScore = 0;
1683
-            }else{
1684
-                $prob_detail = $ret[$id]['problem_detail'];
1679
+            if ($id==count($ret)) {
1680
+                $prob_detail=[];
1681
+                $totPen=0;
1682
+                $totScore=0;
1683
+            } else {
1684
+                $prob_detail=$ret[$id]['problem_detail'];
1685 1685
                 $totPen=$ret[$id]['penalty'];
1686 1686
                 $totScore=$ret[$id]['score'];
1687 1687
             };
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
                 "uid"=>$uid,
1700 1700
             ])->orderBy('submission_date', 'desc')->first();
1701 1701
 
1702
-            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){
1702
+            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") {
1703 1703
                 $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid);
1704 1704
 
1705 1705
                 $prob_detail[$problem['cpid']]=[
@@ -1731,12 +1731,12 @@  discard block
 block discarded – undo
1731 1731
             }
1732 1732
         } elseif ($contest_info["rule"]==2) {
1733 1733
             // OI Mode
1734
-            if($id == count($ret)){
1735
-                $prob_detail = [];
1736
-                $totSolved = 0;
1737
-                $totScore = 0;
1738
-            }else{
1739
-                $prob_detail = $ret[$id]['problem_detail'];
1734
+            if ($id==count($ret)) {
1735
+                $prob_detail=[];
1736
+                $totSolved=0;
1737
+                $totScore=0;
1738
+            } else {
1739
+                $prob_detail=$ret[$id]['problem_detail'];
1740 1740
                 $totSolved=$ret[$id]['solved'];
1741 1741
                 $totScore=$ret[$id]['score'];
1742 1742
             };
@@ -1769,47 +1769,47 @@  discard block
 block discarded – undo
1769 1769
         return $ret;
1770 1770
     }
1771 1771
 
1772
-    public function assignMember($cid,$uid){
1772
+    public function assignMember($cid, $uid) {
1773 1773
         return DB::table("contest")->where(["cid"=>$cid])->update([
1774 1774
             "assign_uid"=>$uid
1775 1775
         ]);
1776 1776
     }
1777 1777
 
1778
-    public function canUpdateContestTime($cid,$time = [])
1778
+    public function canUpdateContestTime($cid, $time=[])
1779 1779
     {
1780
-        $begin_time_new = $time['begin'] ?? null;
1781
-        $end_time_new = $time['end'] ?? null;
1780
+        $begin_time_new=$time['begin'] ?? null;
1781
+        $end_time_new=$time['end'] ?? null;
1782 1782
 
1783
-        $hold_time = DB::table('contest')
1784
-            ->where('cid',$cid)
1785
-            ->select('begin_time','end_time')
1783
+        $hold_time=DB::table('contest')
1784
+            ->where('cid', $cid)
1785
+            ->select('begin_time', 'end_time')
1786 1786
             ->first();
1787
-        $begin_stamps = strtotime($hold_time['begin_time']);
1788
-        $end_stamps = strtotime($hold_time['end_time']);
1787
+        $begin_stamps=strtotime($hold_time['begin_time']);
1788
+        $end_stamps=strtotime($hold_time['end_time']);
1789 1789
         /*
1790 1790
         -1 : have not begun
1791 1791
          0 : ing
1792 1792
          1 : end
1793 1793
         */
1794
-        $status = time() >= $end_stamps ? 1
1795
-                : (time() <= $begin_stamps ? -1 : 0);
1796
-        if($status === -1){
1797
-            if(time() > $begin_time_new){
1794
+        $status=time()>=$end_stamps ? 1
1795
+                : (time()<=$begin_stamps ? -1 : 0);
1796
+        if ($status===-1) {
1797
+            if (time()>$begin_time_new) {
1798 1798
                 return false;
1799 1799
             }
1800 1800
             return true;
1801
-        }else if($status === 0){
1802
-            if($begin_time_new !== null){
1801
+        } else if ($status===0) {
1802
+            if ($begin_time_new!==null) {
1803 1803
                 return false;
1804 1804
             }
1805
-            if($end_time_new !== null){
1806
-                if(strtotime($end_time_new) <= time()){
1805
+            if ($end_time_new!==null) {
1806
+                if (strtotime($end_time_new)<=time()) {
1807 1807
                     return false;
1808
-                }else{
1808
+                } else {
1809 1809
                     return true;
1810 1810
                 }
1811 1811
             }
1812
-        }else{
1812
+        } else {
1813 1813
             return false;
1814 1814
         }
1815 1815
 
@@ -1818,22 +1818,22 @@  discard block
 block discarded – undo
1818 1818
 
1819 1819
     public function replyClarification($ccid, $content)
1820 1820
     {
1821
-        return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1821
+        return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1822 1822
             "reply"=>$content
1823 1823
         ]);
1824 1824
     }
1825 1825
 
1826 1826
     public function setClarificationPublic($ccid, $public)
1827 1827
     {
1828
-        if($public)
1828
+        if ($public)
1829 1829
         {
1830
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1830
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1831 1831
                 "public"=>1
1832 1832
             ]);
1833 1833
         }
1834 1834
         else
1835 1835
         {
1836
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1836
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1837 1837
                 "public"=>0
1838 1838
             ]);
1839 1839
         }
@@ -1844,67 +1844,67 @@  discard block
 block discarded – undo
1844 1844
         return Cache::tags(['contest', 'account'])->get($cid);
1845 1845
     }
1846 1846
 
1847
-    public function praticeAnalysis($cid){
1848
-        $gid = DB::table('contest')
1849
-            ->where('cid',$cid)
1847
+    public function praticeAnalysis($cid) {
1848
+        $gid=DB::table('contest')
1849
+            ->where('cid', $cid)
1850 1850
             ->first()['gid'];
1851
-        $contestRank = $this->contestRank($cid,Auth::user()->id);
1852
-        if(!empty($contestRank)){
1853
-            $all_problems = DB::table('problem')
1854
-            ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid'))
1855
-            ->select('pid','title')
1851
+        $contestRank=$this->contestRank($cid, Auth::user()->id);
1852
+        if (!empty($contestRank)) {
1853
+            $all_problems=DB::table('problem')
1854
+            ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid'))
1855
+            ->select('pid', 'title')
1856 1856
             ->get()->all();
1857
-        }else{
1858
-            $all_problems = [];
1857
+        } else {
1858
+            $all_problems=[];
1859 1859
         }
1860
-        $tags = DB::table('group_problem_tag')
1860
+        $tags=DB::table('group_problem_tag')
1861 1861
             ->where('gid', $gid)
1862
-            ->whereIn('pid', array_column($all_problems,'pid'))
1862
+            ->whereIn('pid', array_column($all_problems, 'pid'))
1863 1863
             ->get()->all();
1864
-        $all_tags = array_unique(array_column($tags,'tag'));
1865
-        $memberData = [];
1866
-        foreach($contestRank as $member){
1867
-            $m = [
1864
+        $all_tags=array_unique(array_column($tags, 'tag'));
1865
+        $memberData=[];
1866
+        foreach ($contestRank as $member) {
1867
+            $m=[
1868 1868
                 'uid' => $member['uid'],
1869 1869
                 'name' => $member['name'],
1870 1870
                 'nick_name' => $member['nick_name'],
1871 1871
             ];
1872
-            $completion = [];
1873
-            foreach ($all_tags as $tag){
1874
-                $completion[$tag] = [];
1872
+            $completion=[];
1873
+            foreach ($all_tags as $tag) {
1874
+                $completion[$tag]=[];
1875 1875
                 foreach ($tags as $t) {
1876
-                    if($t['tag'] == $tag){
1876
+                    if ($t['tag']==$tag) {
1877 1877
                         foreach ($member['problem_detail'] as $pd) {
1878
-                            if($pd['pid'] == $t['pid']){
1879
-                                $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1;
1878
+                            if ($pd['pid']==$t['pid']) {
1879
+                                $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1;
1880 1880
                             }
1881 1881
                         }
1882 1882
                     }
1883 1883
                 }
1884 1884
             }
1885
-            $m['completion'] = $completion;
1886
-            $memberData[] = $m;
1885
+            $m['completion']=$completion;
1886
+            $memberData[]=$m;
1887 1887
         }
1888 1888
         return $memberData;
1889 1889
     }
1890 1890
 
1891 1891
     public function storeContestRankInMySQL($cid, $data)
1892 1892
     {
1893
-        $contestRankJson = json_encode($data);
1894
-        return DB::table('contest')->where('cid','=',$cid)->update([
1893
+        $contestRankJson=json_encode($data);
1894
+        return DB::table('contest')->where('cid', '=', $cid)->update([
1895 1895
             'rank' => $contestRankJson
1896 1896
         ]);
1897 1897
     }
1898 1898
 
1899 1899
     public function getContestRankFromMySQL($cid)
1900 1900
     {
1901
-        $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first();
1902
-        $data = json_decode($contestRankJson, true);
1901
+        $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first();
1902
+        $data=json_decode($contestRankJson, true);
1903 1903
         return $data;
1904 1904
     }
1905 1905
 
1906 1906
     public function isVerified($cid)
1907 1907
     {
1908
-        return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first();
1908
+        return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first();
1909 1909
     }
1910 1910
 }
Please login to merge, or discard this patch.
app/Models/Update/UpdateModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
                 "name"=>$versionInfo[0]["name"],
25 25
                 "updatable"=>$updatable
26 26
             ];
27
-        }catch(Throwable $e){
27
+        } catch (Throwable $e) {
28 28
             return null;
29 29
         }
30 30
     }
Please login to merge, or discard this patch.