Passed
Pull Request — master (#264)
by
unknown
05:25
created
app/Admin/Controllers/BabelController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     {
91 91
         $extensionList=ExtensionModel::list();
92 92
 
93
-        if(empty($extensionList)){
93
+        if (empty($extensionList)) {
94 94
             return view('admin::babel.empty');
95 95
         }
96 96
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $details=ExtensionModel::remoteDetail($code);
105 105
 
106
-        if(empty($details)){
106
+        if (empty($details)) {
107 107
             return view('admin::babel.empty');
108 108
         }
109 109
 
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
     {
117 117
         header("Connection: Keep-alive");
118 118
 
119
-        $fp = popen('"'.PHP_BINARY.'" "'.base_path('artisan').'" '.$command, "r");
120
-        while($b = fgets($fp, 2048)) {
119
+        $fp=popen('"'.PHP_BINARY.'" "'.base_path('artisan').'" '.$command, "r");
120
+        while ($b=fgets($fp, 2048)) {
121 121
             echo $b."<br>";
122 122
             flush();
123 123
         }
Please login to merge, or discard this patch.
app/Admin/routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     $router->resource('contests', ContestController::class);
18 18
     $router->resource('groups', GroupController::class);
19 19
 
20
-    Route::group(['prefix' => 'babel'], function (Router $router) {
20
+    Route::group(['prefix' => 'babel'], function(Router $router) {
21 21
         $router->get('/', 'BabelController@index')->name('admin.babel.index');
22 22
         $router->get('installed', 'BabelController@installed')->name('admin.babel.installed');
23 23
         $router->get('marketspace', 'BabelController@marketspace')->name('admin.babel.marketspace');
Please login to merge, or discard this patch.
app/Models/ContestModel.php 1 patch
Spacing   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 
113 113
     public function gcode($cid)
114 114
     {
115
-        $gid = $this->gid($cid);
116
-        return DB::table('group')->where('gid','=',$gid)->first()["gcode"];
115
+        $gid=$this->gid($cid);
116
+        return DB::table('group')->where('gid', '=', $gid)->first()["gcode"];
117 117
     }
118 118
 
119 119
     public function runningContest()
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
 
139 139
     public function listForSetting($gid)
140 140
     {
141
-        $uid = Auth::user()->id;
142
-        $group_contests = DB::table('contest')
143
-            ->where('gid',$gid)
144
-            ->orderBy('begin_time','desc')
141
+        $uid=Auth::user()->id;
142
+        $group_contests=DB::table('contest')
143
+            ->where('gid', $gid)
144
+            ->orderBy('begin_time', 'desc')
145 145
             ->get()->all();
146
-        $groupModel = new GroupModel();
147
-        $group_clearance = $groupModel->judgeClearance($gid,$uid);
146
+        $groupModel=new GroupModel();
147
+        $group_clearance=$groupModel->judgeClearance($gid, $uid);
148 148
         foreach ($group_contests as &$contest) {
149
-            $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3);
150
-            $contest['begin_stamps'] = strtotime($contest['begin_time']);
151
-            $contest['end_stamps'] = strtotime($contest['end_time']);
152
-            $contest['status'] = time() >= $contest['end_stamps'] ? 1
153
-                : (time() <= $contest['begin_stamps'] ? -1 : 0);
149
+            $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3);
150
+            $contest['begin_stamps']=strtotime($contest['begin_time']);
151
+            $contest['end_stamps']=strtotime($contest['end_time']);
152
+            $contest['status']=time()>=$contest['end_stamps'] ? 1
153
+                : (time()<=$contest['begin_stamps'] ? -1 : 0);
154 154
             $contest["rule_parsed"]=$this->rule[$contest["rule"]];
155 155
             $contest["date_parsed"]=[
156 156
                 "date"=>date_format(date_create($contest["begin_time"]), 'j'),
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
             ];
159 159
             $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]);
160 160
         }
161
-        usort($group_contests,function($a,$b){
162
-            if($a['is_admin'] == $b['is_admin']){
163
-                return $b['begin_stamps'] - $a['begin_stamps'];
161
+        usort($group_contests, function($a, $b) {
162
+            if ($a['is_admin']==$b['is_admin']) {
163
+                return $b['begin_stamps']-$a['begin_stamps'];
164 164
             }
165
-            return $b['is_admin'] - $a['is_admin'];
165
+            return $b['is_admin']-$a['is_admin'];
166 166
         });
167 167
         return $group_contests;
168 168
     }
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
         //     "gid"=>$gid
174 174
         // ])->orderBy('begin_time', 'desc')->get()->all();
175 175
         $preQuery=DB::table($this->tableName);
176
-        $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10);
176
+        $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10);
177 177
         $contest_list=$paginator->all();
178
-        if(empty($contest_list)){
178
+        if (empty($contest_list)) {
179 179
             return null;
180 180
         }
181 181
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         ])->first()["rule"];
201 201
     }
202 202
 
203
-    public function list($filter,$uid)
203
+    public function list($filter, $uid)
204 204
     {
205 205
         if ($uid) {
206 206
             //$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);
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
                 if ($filter['practice']) {
225 225
                     $paginator=$paginator->where(["practice"=>$filter['practice']]);
226 226
                 }
227
-                $paginator = $paginator ->paginate(10);
228
-            }elseif($filter['public']=='0'){
227
+                $paginator=$paginator ->paginate(10);
228
+            }elseif ($filter['public']=='0') {
229 229
                 $paginator=DB::table('group_member')
230 230
                 ->groupBy('contest.cid')
231 231
                 ->select('contest.*')
232 232
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
233 233
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
234 234
                 ->where(
235
-                    function ($query) use ($filter,$uid) {
235
+                    function($query) use ($filter, $uid) {
236 236
                         if ($filter['rule']) {
237 237
                             $query=$query->where(["rule"=>$filter['rule']]);
238 238
                         }
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
                 )
256 256
                 ->orderBy('contest.begin_time', 'desc')
257 257
                 ->paginate(10);
258
-            }else{
258
+            } else {
259 259
                 $paginator=DB::table('group_member')
260 260
                 ->groupBy('contest.cid')
261 261
                 ->select('contest.*')
262 262
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
263 263
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
264 264
                 ->where(
265
-                    function ($query) use ($filter) {
265
+                    function($query) use ($filter) {
266 266
                         if ($filter['rule']) {
267 267
                             $query=$query->where(["rule"=>$filter['rule']]);
268 268
                         }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                     }
284 284
                 )
285 285
                 ->orWhere(
286
-                    function ($query) use ($filter,$uid) {
286
+                    function($query) use ($filter, $uid) {
287 287
                         if ($filter['rule']) {
288 288
                             $query=$query->where(["rule"=>$filter['rule']]);
289 289
                         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             if ($filter['practice']) {
330 330
                 $paginator=$paginator->where(["practice"=>$filter['practice']]);
331 331
             }
332
-            $paginator = $paginator ->paginate(10);
332
+            $paginator=$paginator ->paginate(10);
333 333
         }
334 334
         $contest_list=$paginator->all();
335 335
         foreach ($contest_list as &$c) {
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
         }
368 368
     }
369 369
 
370
-    public function registContest($cid,$uid)
370
+    public function registContest($cid, $uid)
371 371
     {
372 372
         $registered=DB::table("contest_participant")->where([
373 373
             "cid"=>$cid,
374 374
             "uid"=>$uid
375 375
         ])->first();
376 376
 
377
-        if(empty($registered)){
377
+        if (empty($registered)) {
378 378
             DB::table("contest_participant")->insert([
379 379
                 "cid"=>$cid,
380 380
                 "uid"=>$uid,
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
     public function problems($cid)
408 408
     {
409 409
         return DB::table('contest_problem')
410
-            ->join('problem','contest_problem.pid','=','problem.pid')
411
-            ->where('cid',$cid)
412
-            ->select('problem.pid as pid','pcode','number')
410
+            ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
411
+            ->where('cid', $cid)
412
+            ->select('problem.pid as pid', 'pcode', 'number')
413 413
             ->orderBy('number')
414 414
             ->get()->all();
415 415
     }
@@ -431,18 +431,18 @@  discard block
 block discarded – undo
431 431
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
432 432
 
433 433
         foreach ($problemSet as &$p) {
434
-            if($p['practice']){
435
-                $tags = DB::table("group_problem_tag")
436
-                ->where('gid',$p['gid'])
437
-                ->where('pid',$p['pid'])
434
+            if ($p['practice']) {
435
+                $tags=DB::table("group_problem_tag")
436
+                ->where('gid', $p['gid'])
437
+                ->where('pid', $p['pid'])
438 438
                 ->get()->all();
439
-                $tags_arr = [];
440
-                if(!empty($tags)){
439
+                $tags_arr=[];
440
+                if (!empty($tags)) {
441 441
                     foreach ($tags as $value) {
442
-                        array_push($tags_arr,$value['tag']);
442
+                        array_push($tags_arr, $value['tag']);
443 443
                     }
444 444
                 }
445
-                $p['tags'] = $tags_arr;
445
+                $p['tags']=$tags_arr;
446 446
             }
447 447
             if ($contest_rule==1) {
448 448
                 $prob_stat=DB::table("submission")->select(
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
                     "problem_detail" => $prob_detail
704 704
                 ];
705 705
             }
706
-            usort($ret, function ($a, $b) {
706
+            usort($ret, function($a, $b) {
707 707
                 if ($a["score"]==$b["score"]) {
708 708
                     if ($a["penalty"]==$b["penalty"]) {
709 709
                         return 0;
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
                     "problem_detail" => $prob_detail
751 751
                 ];
752 752
             }
753
-            usort($ret, function ($a, $b) {
753
+            usort($ret, function($a, $b) {
754 754
                 if ($a["score"]==$b["score"]) {
755 755
                     if ($a["solved"]==$b["solved"]) {
756 756
                         return 0;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
         return $ret;
773 773
     }
774 774
 
775
-    public function contestRank($cid, $uid = 0)
775
+    public function contestRank($cid, $uid=0)
776 776
     {
777 777
         // [ToDo] If the current user's in the organizer group show nick name
778 778
         // [ToDo] The participants determination
@@ -790,35 +790,35 @@  discard block
 block discarded – undo
790 790
             "gid" => $contest_info["gid"]
791 791
         ])->where("role", ">", 0)->first());
792 792
 
793
-        $clearance = $this -> judgeClearance($cid, $uid);
793
+        $clearance=$this -> judgeClearance($cid, $uid);
794 794
 
795 795
         /** New Version With MySQL */
796 796
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
797 797
 
798
-        if(time() < $end_time){
799
-            if($clearance == 3){
798
+        if (time()<$end_time) {
799
+            if ($clearance==3) {
800 800
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
801
-            }else{
801
+            } else {
802 802
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
803 803
             }
804
-            if(!isset($contestRankRaw)){
804
+            if (!isset($contestRankRaw)) {
805 805
                 $contestRankRaw=$this->contestRankCache($cid);
806 806
             }
807
-        }else{
808
-            if($clearance == 3){
807
+        } else {
808
+            if ($clearance==3) {
809 809
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
810 810
                 if (!isset($contestRankRaw)) {
811 811
                     $contestRankRaw=$this->getContestRankFromMySQL($cid);
812
-                    if(!isset($contestRankRaw)){
812
+                    if (!isset($contestRankRaw)) {
813 813
                         $contestRankRaw=$this->contestRankCache($cid);
814 814
                         $this->storeContestRankInMySQL($cid, $contestRankRaw);
815 815
                     }
816 816
                 }
817
-            }else{
817
+            } else {
818 818
                 $contestRankRaw=$this->getContestRankFromMySQL($cid);
819
-                if(!isset($contestRankRaw)){
819
+                if (!isset($contestRankRaw)) {
820 820
                     $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
821
-                    if(!isset($contestRankRaw)){
821
+                    if (!isset($contestRankRaw)) {
822 822
                         $contestRankRaw=$this->contestRankCache($cid);
823 823
                     }
824 824
                     $this->storeContestRankInMySQL($cid, $contestRankRaw);
@@ -836,15 +836,15 @@  discard block
 block discarded – undo
836 836
         //         $contestRankRaw=$this->contestRankCache($cid);
837 837
         //     }
838 838
         // }
839
-        if($contest_info["rule"]==1){
839
+        if ($contest_info["rule"]==1) {
840 840
             foreach ($contestRankRaw as &$cr) {
841
-                $solved = 0;
842
-                foreach($cr['problem_detail'] as $pd){
843
-                    if(!empty($pd['solved_time_parsed'])){
844
-                        $solved ++;
841
+                $solved=0;
842
+                foreach ($cr['problem_detail'] as $pd) {
843
+                    if (!empty($pd['solved_time_parsed'])) {
844
+                        $solved++;
845 845
                     }
846 846
                 }
847
-                $cr['solved'] = $solved;
847
+                $cr['solved']=$solved;
848 848
             }
849 849
         }
850 850
 
@@ -893,16 +893,16 @@  discard block
 block discarded – undo
893 893
 
894 894
     public function getClarificationList($cid)
895 895
     {
896
-        $uid = Auth::user()->id;
897
-        $clearance = $this -> judgeClearance($cid, $uid);
898
-        if($clearance == 3){
896
+        $uid=Auth::user()->id;
897
+        $clearance=$this -> judgeClearance($cid, $uid);
898
+        if ($clearance==3) {
899 899
             return DB::table("contest_clarification")->where([
900 900
                 "cid"=>$cid
901 901
             ])->orderBy('create_time', 'desc')->get()->all();
902
-        }else{
902
+        } else {
903 903
             return DB::table("contest_clarification")->where([
904 904
                 "cid"=>$cid
905
-            ])->where(function ($query) {
905
+            ])->where(function($query) {
906 906
                 $query->where([
907 907
                     "public"=>1
908 908
                 ])->orWhere([
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
     public function getContestRecord($filter, $cid)
1049 1049
     {
1050 1050
         $basicInfo=$this->basic($cid);
1051
-        $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first();
1051
+        $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first();
1052 1052
         $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
1053 1053
             "cid"=>$cid
1054 1054
         ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all();
@@ -1061,14 +1061,14 @@  discard block
 block discarded – undo
1061 1061
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1062 1062
         $contestEnd=time()>$end_time;
1063 1063
 
1064
-        $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1065
-        if($filter['pid']==false){
1066
-            $filter['pid'] = null;
1067
-        }else{
1068
-            $filter['pid'] = $problemSet_temp[$filter['pid']]['pid'];
1064
+        $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1065
+        if ($filter['pid']==false) {
1066
+            $filter['pid']=null;
1067
+        } else {
1068
+            $filter['pid']=$problemSet_temp[$filter['pid']]['pid'];
1069 1069
         }
1070 1070
 
1071
-        if($userInfo==null || $userInfo["role"]!=3){
1071
+        if ($userInfo==null || $userInfo["role"]!=3) {
1072 1072
             if ($basicInfo["status_visibility"]==2) {
1073 1073
                 // View all
1074 1074
                 $paginator=DB::table("submission")->where([
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
                     "users.id",
1083 1083
                     "=",
1084 1084
                     "submission.uid"
1085
-                )->where(function ($query) use ($frozen_time) {
1085
+                )->where(function($query) use ($frozen_time) {
1086 1086
                     $query->where(
1087 1087
                         "submission_date",
1088 1088
                         "<",
@@ -1109,15 +1109,15 @@  discard block
 block discarded – undo
1109 1109
                     'desc'
1110 1110
                 );
1111 1111
 
1112
-                if($filter["pid"]){
1112
+                if ($filter["pid"]) {
1113 1113
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1114 1114
                 }
1115 1115
 
1116
-                if($filter["result"]){
1116
+                if ($filter["result"]) {
1117 1117
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1118 1118
                 }
1119 1119
 
1120
-                if($filter["account"]){
1120
+                if ($filter["account"]) {
1121 1121
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1122 1122
                 }
1123 1123
 
@@ -1153,15 +1153,15 @@  discard block
 block discarded – undo
1153 1153
                     'desc'
1154 1154
                 );
1155 1155
 
1156
-                if($filter["pid"]){
1156
+                if ($filter["pid"]) {
1157 1157
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1158 1158
                 }
1159 1159
 
1160
-                if($filter["result"]){
1160
+                if ($filter["result"]) {
1161 1161
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1162 1162
                 }
1163 1163
 
1164
-                if($filter["account"]){
1164
+                if ($filter["account"]) {
1165 1165
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1166 1166
                 }
1167 1167
 
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
                     "records"=>[]
1173 1173
                 ];
1174 1174
             }
1175
-        }else{
1175
+        } else {
1176 1176
             if ($basicInfo["status_visibility"]==2) {
1177 1177
                 // View all
1178 1178
                 $paginator=DB::table("submission")->where([
@@ -1204,15 +1204,15 @@  discard block
 block discarded – undo
1204 1204
                     'desc'
1205 1205
                 );
1206 1206
 
1207
-                if($filter["pid"]){
1207
+                if ($filter["pid"]) {
1208 1208
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1209 1209
                 }
1210 1210
 
1211
-                if($filter["result"]){
1211
+                if ($filter["result"]) {
1212 1212
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1213 1213
                 }
1214 1214
 
1215
-                if($filter["account"]){
1215
+                if ($filter["account"]) {
1216 1216
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1217 1217
                 }
1218 1218
 
@@ -1248,15 +1248,15 @@  discard block
 block discarded – undo
1248 1248
                     'desc'
1249 1249
                 );
1250 1250
 
1251
-                if($filter["pid"]){
1251
+                if ($filter["pid"]) {
1252 1252
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1253 1253
                 }
1254 1254
 
1255
-                if($filter["result"]){
1255
+                if ($filter["result"]) {
1256 1256
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1257 1257
                 }
1258 1258
 
1259
-                if($filter["account"]){
1259
+                if ($filter["account"]) {
1260 1260
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1261 1261
                 }
1262 1262
 
@@ -1312,21 +1312,21 @@  discard block
 block discarded – undo
1312 1312
         if ($uid==0) {
1313 1313
             return 0;
1314 1314
         }
1315
-        $groupModel = new GroupModel();
1315
+        $groupModel=new GroupModel();
1316 1316
         $contest_info=DB::table("contest")->where("cid", $cid)->first();
1317
-        $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first();
1317
+        $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first();
1318 1318
 
1319
-        if(empty($contest_info)){
1319
+        if (empty($contest_info)) {
1320 1320
             // contest not exist
1321 1321
             return 0;
1322 1322
         }
1323 1323
 
1324
-        if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){
1324
+        if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) {
1325 1325
             return 3;
1326 1326
         }
1327 1327
 
1328
-        $contest_started = strtotime($contest_info['begin_time']) < time();
1329
-        $contest_ended = strtotime($contest_info['end_time']) < time();
1328
+        $contest_started=strtotime($contest_info['begin_time'])<time();
1329
+        $contest_ended=strtotime($contest_info['end_time'])<time();
1330 1330
         if (!$contest_started) {
1331 1331
             // not started or do not exist
1332 1332
             return 0;
@@ -1417,12 +1417,12 @@  discard block
 block discarded – undo
1417 1417
     public function updateProfessionalRate($cid)
1418 1418
     {
1419 1419
         $basic=$this->basic($cid);
1420
-        if($basic["rated"]&&!$basic["is_rated"]){
1420
+        if ($basic["rated"] && !$basic["is_rated"]) {
1421 1421
             $ratingCalculator=new RatingCalculator($cid);
1422
-            if($ratingCalculator->calculate()){
1422
+            if ($ratingCalculator->calculate()) {
1423 1423
                 $ratingCalculator->storage();
1424 1424
                 return true;
1425
-            }else{
1425
+            } else {
1426 1426
                 return false;
1427 1427
             }
1428 1428
         } else {
@@ -1430,26 +1430,26 @@  discard block
 block discarded – undo
1430 1430
         }
1431 1431
     }
1432 1432
 
1433
-    public function contestUpdate($cid,$data,$problems)
1433
+    public function contestUpdate($cid, $data, $problems)
1434 1434
     {
1435
-        if($problems !== false){
1436
-            $old_problmes = array_column(
1435
+        if ($problems!==false) {
1436
+            $old_problmes=array_column(
1437 1437
                 DB::table('contest_problem')
1438
-                ->where('cid',$cid)
1438
+                ->where('cid', $cid)
1439 1439
                 ->get()->all(),
1440 1440
                 'pid'
1441 1441
             );
1442
-            DB::transaction(function () use ($cid, $data, $problems,$old_problmes) {
1442
+            DB::transaction(function() use ($cid, $data, $problems, $old_problmes) {
1443 1443
                 DB::table($this->tableName)
1444
-                    ->where('cid',$cid)
1444
+                    ->where('cid', $cid)
1445 1445
                     ->update($data);
1446 1446
                 DB::table('contest_problem')
1447
-                    ->where('cid',$cid)
1447
+                    ->where('cid', $cid)
1448 1448
                     ->delete();
1449
-                $new_problems = [];
1449
+                $new_problems=[];
1450 1450
                 foreach ($problems as $p) {
1451 1451
                     $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"];
1452
-                    array_push($new_problems,$pid);
1452
+                    array_push($new_problems, $pid);
1453 1453
                     DB::table("contest_problem")->insert([
1454 1454
                         "cid"=>$cid,
1455 1455
                         "number"=>$p["number"],
@@ -1459,29 +1459,29 @@  discard block
 block discarded – undo
1459 1459
                         "points"=>$p["points"]
1460 1460
                     ]);
1461 1461
                 }
1462
-                foreach($old_problmes as $op) {
1463
-                    if(!in_array($op,$new_problems)){
1462
+                foreach ($old_problmes as $op) {
1463
+                    if (!in_array($op, $new_problems)) {
1464 1464
                         DB::table('submission')
1465
-                            ->where('cid',$cid)
1466
-                            ->where('pid',$op)
1465
+                            ->where('cid', $cid)
1466
+                            ->where('pid', $op)
1467 1467
                             ->delete();
1468 1468
                     }
1469 1469
                 }
1470 1470
             }, 5);
1471
-            $contestRankRaw = $this->contestRankCache($cid);
1471
+            $contestRankRaw=$this->contestRankCache($cid);
1472 1472
             Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
1473 1473
             Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
1474
-        }else{
1474
+        } else {
1475 1475
             DB::table($this->tableName)
1476
-                ->where('cid',$cid)
1476
+                ->where('cid', $cid)
1477 1477
                 ->update($data);
1478 1478
         }
1479 1479
     }
1480 1480
 
1481
-    public function contestUpdateProblem($cid,$problems)
1481
+    public function contestUpdateProblem($cid, $problems)
1482 1482
     {
1483 1483
         DB::table('contest_problem')
1484
-                ->where('cid',$cid)
1484
+                ->where('cid', $cid)
1485 1485
                 ->delete();
1486 1486
         foreach ($problems as $p) {
1487 1487
             DB::table("contest_problem")->insertGetId([
@@ -1497,8 +1497,8 @@  discard block
 block discarded – undo
1497 1497
 
1498 1498
     public function arrangeContest($gid, $config, $problems)
1499 1499
     {
1500
-        $cid = -1;
1501
-        DB::transaction(function () use ($gid, $config, $problems,&$cid) {
1500
+        $cid=-1;
1501
+        DB::transaction(function() use ($gid, $config, $problems, &$cid) {
1502 1502
             $cid=DB::table($this->tableName)->insertGetId([
1503 1503
                 "gid"=>$gid,
1504 1504
                 "name"=>$config["name"],
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
                 "rule"=>1, //todo
1513 1513
                 "begin_time"=>$config["begin_time"],
1514 1514
                 "end_time"=>$config["end_time"],
1515
-                "vcid"=>isset($config["vcid"])?$config["vcid"]:null,
1515
+                "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null,
1516 1516
                 "public"=>$config["public"],
1517 1517
                 "registration"=>0, //todo
1518 1518
                 "registration_due"=>null, //todo
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
                 "froze_length"=>0, //todo
1521 1521
                 "status_visibility"=>2, //todo
1522 1522
                 "create_time"=>date("Y-m-d H:i:s"),
1523
-                "crawled" => isset($config['vcid'])?$config['crawled'] : null,
1523
+                "crawled" => isset($config['vcid']) ? $config['crawled'] : null,
1524 1524
                 "audit_status"=>$config["public"] ? 0 : 1
1525 1525
             ]);
1526 1526
 
@@ -1539,13 +1539,13 @@  discard block
 block discarded – undo
1539 1539
         return $cid;
1540 1540
     }
1541 1541
 
1542
-    public function updateContestRankTable($cid,$sub)
1542
+    public function updateContestRankTable($cid, $sub)
1543 1543
     {
1544
-        $lock = Cache::lock("contestrank$cid",10);
1545
-        try{
1546
-            if($lock->get()){
1547
-                if(Cache::tags(['contest','rank'])->get($cid) != null){
1548
-                    $ret = Cache::tags(['contest','rank'])->get($cid);
1544
+        $lock=Cache::lock("contestrank$cid", 10);
1545
+        try {
1546
+            if ($lock->get()) {
1547
+                if (Cache::tags(['contest', 'rank'])->get($cid)!=null) {
1548
+                    $ret=Cache::tags(['contest', 'rank'])->get($cid);
1549 1549
                     $chache=[];
1550 1550
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
1551 1551
                     $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
@@ -1554,27 +1554,27 @@  discard block
 block discarded – undo
1554 1554
                     $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"];
1555 1555
                     $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1556 1556
 
1557
-                    $id = 0;
1557
+                    $id=0;
1558 1558
 
1559
-                    foreach($chache['problemSet'] as $key => $p){
1560
-                        if ($p['pid'] == $sub['pid']){
1561
-                            $chache['problemSet'][$key]['cpid'] = $key;
1562
-                            $id = $key;
1559
+                    foreach ($chache['problemSet'] as $key => $p) {
1560
+                        if ($p['pid']==$sub['pid']) {
1561
+                            $chache['problemSet'][$key]['cpid']=$key;
1562
+                            $id=$key;
1563 1563
                         }
1564 1564
                     }
1565 1565
 
1566
-                    $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret);
1567
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1566
+                    $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret);
1567
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1568 1568
 
1569
-                    if (time() < $chache['frozen_time']){
1569
+                    if (time()<$chache['frozen_time']) {
1570 1570
                         Cache::tags(['contest', 'rank'])->put($cid, $ret);
1571 1571
                     }
1572 1572
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret);
1573
-                    if(time() > $chache['end_time']){
1573
+                    if (time()>$chache['end_time']) {
1574 1574
                         $this->storeContestRankInMySQL($cid, $ret);
1575 1575
                     }
1576 1576
                 }
1577
-                else{
1577
+                else {
1578 1578
                     $ret=[];
1579 1579
                     $chache=[];
1580 1580
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
                             "cid"=>$cid,
1590 1590
                             "audit"=>1
1591 1591
                         ])->select('uid')->get()->all();
1592
-                    }else{
1592
+                    } else {
1593 1593
                         $submissionUsers=DB::table("submission")->where([
1594 1594
                             "cid"=>$cid
1595 1595
                         ])->where(
@@ -1602,39 +1602,39 @@  discard block
 block discarded – undo
1602 1602
                         ])->select('uid')->groupBy('uid')->get()->all();
1603 1603
                     }
1604 1604
 
1605
-                    $chacheAdmin = $chache;
1605
+                    $chacheAdmin=$chache;
1606 1606
 
1607 1607
                     foreach ($submissionUsers as $s) {
1608 1608
                         foreach ($chache['problemSet'] as $key => $p) {
1609
-                            $p['cpid'] = $key;
1610
-                            $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret);
1609
+                            $p['cpid']=$key;
1610
+                            $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret);
1611 1611
                         }
1612 1612
                     }
1613
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1613
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1614 1614
                     Cache::tags(['contest', 'rank'])->put($cid, $ret);
1615 1615
 
1616 1616
                     $retAdmin=[];
1617 1617
                     foreach ($submissionUsersAdmin as $s) {
1618 1618
                         foreach ($chacheAdmin['problemSet'] as $key => $p) {
1619
-                            $p['cpid'] = $key;
1620
-                            $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin);
1619
+                            $p['cpid']=$key;
1620
+                            $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin);
1621 1621
                         }
1622 1622
                     }
1623
-                    $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin);
1623
+                    $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin);
1624 1624
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin);
1625 1625
                 }
1626 1626
             }
1627
-        }catch(LockTimeoutException $e){
1627
+        } catch (LockTimeoutException $e) {
1628 1628
             Log::warning("Contest Rank Lock Timed Out");
1629
-        }finally{
1629
+        } finally {
1630 1630
             optional($lock)->release();
1631 1631
         }
1632 1632
     }
1633 1633
 
1634
-    public function sortContestRankTable($contest_info,$cid,$ret)
1634
+    public function sortContestRankTable($contest_info, $cid, $ret)
1635 1635
     {
1636
-        if ($contest_info["rule"]==1){
1637
-            usort($ret, function ($a, $b) {
1636
+        if ($contest_info["rule"]==1) {
1637
+            usort($ret, function($a, $b) {
1638 1638
                 if ($a["score"]==$b["score"]) {
1639 1639
                     if ($a["penalty"]==$b["penalty"]) {
1640 1640
                         return 0;
@@ -1649,8 +1649,8 @@  discard block
 block discarded – undo
1649 1649
                     return 1;
1650 1650
                 }
1651 1651
             });
1652
-        }else if ($contest_info["rule"]==2){
1653
-            usort($ret, function ($a, $b) {
1652
+        } else if ($contest_info["rule"]==2) {
1653
+            usort($ret, function($a, $b) {
1654 1654
                 if ($a["score"]==$b["score"]) {
1655 1655
                     if ($a["solved"]==$b["solved"]) {
1656 1656
                         return 0;
@@ -1669,21 +1669,21 @@  discard block
 block discarded – undo
1669 1669
         return $ret;
1670 1670
     }
1671 1671
 
1672
-    public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret)
1672
+    public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret)
1673 1673
     {
1674
-        $id = count($ret);
1675
-        foreach($ret as $key => $r){
1676
-            if($r['uid'] == $uid)
1677
-                $id = $key;
1674
+        $id=count($ret);
1675
+        foreach ($ret as $key => $r) {
1676
+            if ($r['uid']==$uid)
1677
+                $id=$key;
1678 1678
         }
1679 1679
         if ($contest_info["rule"]==1) {
1680 1680
             // ACM/ICPC Mode
1681
-            if($id == count($ret)){
1682
-                $prob_detail = [];
1683
-                $totPen = 0;
1684
-                $totScore = 0;
1685
-            }else{
1686
-                $prob_detail = $ret[$id]['problem_detail'];
1681
+            if ($id==count($ret)) {
1682
+                $prob_detail=[];
1683
+                $totPen=0;
1684
+                $totScore=0;
1685
+            } else {
1686
+                $prob_detail=$ret[$id]['problem_detail'];
1687 1687
                 $totPen=$ret[$id]['penalty'];
1688 1688
                 $totScore=$ret[$id]['score'];
1689 1689
             };
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
                 "uid"=>$uid,
1702 1702
             ])->orderBy('submission_date', 'desc')->first();
1703 1703
 
1704
-            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){
1704
+            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") {
1705 1705
                 $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid);
1706 1706
 
1707 1707
                 $prob_detail[$problem['cpid']]=[
@@ -1733,12 +1733,12 @@  discard block
 block discarded – undo
1733 1733
             }
1734 1734
         } elseif ($contest_info["rule"]==2) {
1735 1735
             // OI Mode
1736
-            if($id == count($ret)){
1737
-                $prob_detail = [];
1738
-                $totSolved = 0;
1739
-                $totScore = 0;
1740
-            }else{
1741
-                $prob_detail = $ret[$id]['problem_detail'];
1736
+            if ($id==count($ret)) {
1737
+                $prob_detail=[];
1738
+                $totSolved=0;
1739
+                $totScore=0;
1740
+            } else {
1741
+                $prob_detail=$ret[$id]['problem_detail'];
1742 1742
                 $totSolved=$ret[$id]['solved'];
1743 1743
                 $totScore=$ret[$id]['score'];
1744 1744
             };
@@ -1771,47 +1771,47 @@  discard block
 block discarded – undo
1771 1771
         return $ret;
1772 1772
     }
1773 1773
 
1774
-    public function assignMember($cid,$uid){
1774
+    public function assignMember($cid, $uid) {
1775 1775
         return DB::table("contest")->where(["cid"=>$cid])->update([
1776 1776
             "assign_uid"=>$uid
1777 1777
         ]);
1778 1778
     }
1779 1779
 
1780
-    public function canUpdateContestTime($cid,$time = [])
1780
+    public function canUpdateContestTime($cid, $time=[])
1781 1781
     {
1782
-        $begin_time_new = $time['begin'] ?? null;
1783
-        $end_time_new = $time['end'] ?? null;
1782
+        $begin_time_new=$time['begin'] ?? null;
1783
+        $end_time_new=$time['end'] ?? null;
1784 1784
 
1785
-        $hold_time = DB::table('contest')
1786
-            ->where('cid',$cid)
1787
-            ->select('begin_time','end_time')
1785
+        $hold_time=DB::table('contest')
1786
+            ->where('cid', $cid)
1787
+            ->select('begin_time', 'end_time')
1788 1788
             ->first();
1789
-        $begin_stamps = strtotime($hold_time['begin_time']);
1790
-        $end_stamps = strtotime($hold_time['end_time']);
1789
+        $begin_stamps=strtotime($hold_time['begin_time']);
1790
+        $end_stamps=strtotime($hold_time['end_time']);
1791 1791
         /*
1792 1792
         -1 : have not begun
1793 1793
          0 : ing
1794 1794
          1 : end
1795 1795
         */
1796
-        $status = time() >= $end_stamps ? 1
1797
-                : (time() <= $begin_stamps ? -1 : 0);
1798
-        if($status === -1){
1799
-            if(time() > $begin_time_new){
1796
+        $status=time()>=$end_stamps ? 1
1797
+                : (time()<=$begin_stamps ? -1 : 0);
1798
+        if ($status===-1) {
1799
+            if (time()>$begin_time_new) {
1800 1800
                 return false;
1801 1801
             }
1802 1802
             return true;
1803
-        }else if($status === 0){
1804
-            if($begin_time_new !== null){
1803
+        } else if ($status===0) {
1804
+            if ($begin_time_new!==null) {
1805 1805
                 return false;
1806 1806
             }
1807
-            if($end_time_new !== null){
1808
-                if(strtotime($end_time_new) <= time()){
1807
+            if ($end_time_new!==null) {
1808
+                if (strtotime($end_time_new)<=time()) {
1809 1809
                     return false;
1810
-                }else{
1810
+                } else {
1811 1811
                     return true;
1812 1812
                 }
1813 1813
             }
1814
-        }else{
1814
+        } else {
1815 1815
             return false;
1816 1816
         }
1817 1817
 
@@ -1820,22 +1820,22 @@  discard block
 block discarded – undo
1820 1820
 
1821 1821
     public function replyClarification($ccid, $content)
1822 1822
     {
1823
-        return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1823
+        return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1824 1824
             "reply"=>$content
1825 1825
         ]);
1826 1826
     }
1827 1827
 
1828 1828
     public function setClarificationPublic($ccid, $public)
1829 1829
     {
1830
-        if($public)
1830
+        if ($public)
1831 1831
         {
1832
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1832
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1833 1833
                 "public"=>1
1834 1834
             ]);
1835 1835
         }
1836 1836
         else
1837 1837
         {
1838
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1838
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1839 1839
                 "public"=>0
1840 1840
             ]);
1841 1841
         }
@@ -1848,90 +1848,90 @@  discard block
 block discarded – undo
1848 1848
 
1849 1849
     public function praticeAnalysis($cid)
1850 1850
     {
1851
-        $gid = DB::table('contest')
1852
-            ->where('cid',$cid)
1851
+        $gid=DB::table('contest')
1852
+            ->where('cid', $cid)
1853 1853
             ->first()['gid'];
1854
-        $contestRank = $this->contestRank($cid,Auth::user()->id);
1855
-        if(!empty($contestRank)){
1856
-            $all_problems = DB::table('problem')
1857
-            ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid'))
1858
-            ->select('pid','title')
1854
+        $contestRank=$this->contestRank($cid, Auth::user()->id);
1855
+        if (!empty($contestRank)) {
1856
+            $all_problems=DB::table('problem')
1857
+            ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid'))
1858
+            ->select('pid', 'title')
1859 1859
             ->get()->all();
1860
-        }else{
1861
-            $all_problems = [];
1860
+        } else {
1861
+            $all_problems=[];
1862 1862
         }
1863
-        $tags = DB::table('group_problem_tag')
1863
+        $tags=DB::table('group_problem_tag')
1864 1864
             ->where('gid', $gid)
1865
-            ->whereIn('pid', array_column($all_problems,'pid'))
1865
+            ->whereIn('pid', array_column($all_problems, 'pid'))
1866 1866
             ->get()->all();
1867
-        $all_tags = array_unique(array_column($tags,'tag'));
1868
-        $memberData = [];
1869
-        foreach($contestRank as $member){
1870
-            $m = [
1867
+        $all_tags=array_unique(array_column($tags, 'tag'));
1868
+        $memberData=[];
1869
+        foreach ($contestRank as $member) {
1870
+            $m=[
1871 1871
                 'uid' => $member['uid'],
1872 1872
                 'name' => $member['name'],
1873 1873
                 'nick_name' => $member['nick_name'],
1874 1874
             ];
1875
-            $completion = [];
1876
-            foreach ($all_tags as $tag){
1877
-                $completion[$tag] = [];
1875
+            $completion=[];
1876
+            foreach ($all_tags as $tag) {
1877
+                $completion[$tag]=[];
1878 1878
                 foreach ($tags as $t) {
1879
-                    if($t['tag'] == $tag){
1879
+                    if ($t['tag']==$tag) {
1880 1880
                         foreach ($member['problem_detail'] as $pd) {
1881
-                            if($pd['pid'] == $t['pid']){
1882
-                                $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1;
1881
+                            if ($pd['pid']==$t['pid']) {
1882
+                                $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1;
1883 1883
                             }
1884 1884
                         }
1885 1885
                     }
1886 1886
                 }
1887 1887
             }
1888
-            $m['completion'] = $completion;
1889
-            $memberData[] = $m;
1888
+            $m['completion']=$completion;
1889
+            $memberData[]=$m;
1890 1890
         }
1891 1891
         return $memberData;
1892 1892
     }
1893 1893
 
1894 1894
     public function storeContestRankInMySQL($cid, $data)
1895 1895
     {
1896
-        $contestRankJson = json_encode($data);
1897
-        return DB::table('contest')->where('cid','=',$cid)->update([
1896
+        $contestRankJson=json_encode($data);
1897
+        return DB::table('contest')->where('cid', '=', $cid)->update([
1898 1898
             'rank' => $contestRankJson
1899 1899
         ]);
1900 1900
     }
1901 1901
 
1902 1902
     public function getContestRankFromMySQL($cid)
1903 1903
     {
1904
-        $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first();
1905
-        $data = json_decode($contestRankJson, true);
1904
+        $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first();
1905
+        $data=json_decode($contestRankJson, true);
1906 1906
         return $data;
1907 1907
     }
1908 1908
 
1909 1909
     public function isVerified($cid)
1910 1910
     {
1911
-        return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first();
1911
+        return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first();
1912 1912
     }
1913 1913
 
1914 1914
     public function getScrollBoardData($cid)
1915 1915
     {
1916
-        $members = DB::table("submission")
1917
-            ->join('users','users.id','=','submission.uid')
1916
+        $members=DB::table("submission")
1917
+            ->join('users', 'users.id', '=', 'submission.uid')
1918 1918
             ->join('contest', 'contest.cid', '=', 'submission.cid')
1919 1919
             ->join('group_member', 'users.id', '=', 'group_member.uid')
1920
-            ->where('submission.cid', $cid)->select('users.id as uid','users.name as name','group_member.nick_name as nick_name')
1920
+            ->where('submission.cid', $cid)->select('users.id as uid', 'users.name as name', 'group_member.nick_name as nick_name')
1921 1921
             ->groupBy('uid')->get()->all();
1922
-        $submissions = DB::table("submission")
1922
+        $submissions=DB::table("submission")
1923 1923
             ->where('cid', $cid)
1924 1924
             ->select('sid', 'verdict', 'submission_date', 'pid', 'uid')
1925 1925
             ->orderBy('submission_date')
1926 1926
             ->get()->all();
1927
-        $problems = DB::table('contest_problem')
1927
+        $problems=DB::table('contest_problem')
1928 1928
             ->where('cid', $cid)
1929
-            ->select('ncode','pid')
1929
+            ->select('ncode', 'pid')
1930 1930
             ->orderBy('ncode')
1931 1931
             ->get()->all();
1932
-        $contest = DB::table('contest')
1933
-            ->where('cid',$cid)
1934
-            ->select('begin_time','end_time','froze_length')
1932
+        $contest=DB::table('contest')
1933
+            ->where('cid', $cid)
1934
+            ->select('begin_time', 'end_time', 'froze_length')
1935 1935
             ->first();
1936 1936
         return [
1937 1937
             'members' => $members,
@@ -1943,16 +1943,16 @@  discard block
 block discarded – undo
1943 1943
   
1944 1944
     public function judgeOver($cid)
1945 1945
     {
1946
-        $submissions =  DB::table('submission')
1946
+        $submissions=DB::table('submission')
1947 1947
             ->where(['cid' => $cid])
1948
-            ->whereIn('verdict',['Waiting','Pending'])
1948
+            ->whereIn('verdict', ['Waiting', 'Pending'])
1949 1949
             ->select('sid')
1950 1950
             ->get()->all();
1951
-        if(empty($submissions)){
1951
+        if (empty($submissions)) {
1952 1952
             return [
1953 1953
                 'result' => true
1954 1954
             ];
1955
-        }else{
1955
+        } else {
1956 1956
             return [
1957 1957
                 'result' => false,
1958 1958
                 'sid' => $submissions
Please login to merge, or discard this patch.
app/Models/Eloquent/MessageModel.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public static function send($config)
19 19
     {
20
-        $message = new MessageModel;
21
-        $message->sender = $config['sender'];
22
-        $message->receiver = $config['receiver'];
23
-        $message->title = $config['title'];
24
-        $message->content = $config['content'];
20
+        $message=new MessageModel;
21
+        $message->sender=$config['sender'];
22
+        $message->receiver=$config['receiver'];
23
+        $message->title=$config['title'];
24
+        $message->content=$config['content'];
25 25
         /*
26 26
         if(isset($config['reply'])){
27 27
             $message->reply = $config['reply'];
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             $message->reply = $config['allow_reply'];
31 31
         }
32 32
         */
33
-        $message->official = 1;
33
+        $message->official=1;
34 34
         $message->save();
35 35
         return true;
36 36
     }
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public static function allowReply($id)
63 63
     {
64
-        $message = static::where('id',$id)->first();
65
-        if(empty($message)){
64
+        $message=static::where('id', $id)->first();
65
+        if (empty($message)) {
66 66
             return false;
67 67
         }
68 68
         return $message['allow_reply'] ? true : false;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function list($uid)
79 79
     {
80
-        return static::join('users','message.sender','=','users.id')
81
-            ->where('receiver',$uid)
80
+        return static::join('users', 'message.sender', '=', 'users.id')
81
+            ->where('receiver', $uid)
82 82
             ->select(
83 83
                 'message.id as id',
84 84
                 'users.name as sender_name',
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public static function read($mid)
105 105
     {
106
-        $message = static::find($mid);
107
-        if(!empty($message)){
108
-            $message->unread = 0;
106
+        $message=static::find($mid);
107
+        if (!empty($message)) {
108
+            $message->unread=0;
109 109
             $message->save();
110 110
         }
111
-        return static::join('users','message.sender','=','users.id')
112
-            ->where('message.id',$mid)
111
+        return static::join('users', 'message.sender', '=', 'users.id')
112
+            ->where('message.id', $mid)
113 113
             ->select(
114 114
                 'message.id as id',
115 115
                 'users.name as sender_name',
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public static function allRead($uid)
135 135
     {
136
-        return static::where('receiver',$uid)
136
+        return static::where('receiver', $uid)
137 137
             ->update(['unread' => 0]);
138 138
     }
139 139
 
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public static function remove($messages)
163 163
     {
164
-        $del_count = 0;
165
-        if(is_array($messages)){
164
+        $del_count=0;
165
+        if (is_array($messages)) {
166 166
             foreach ($messages as $mid) {
167
-                $message = static::find($mid);
168
-                if(!empty($message)){
167
+                $message=static::find($mid);
168
+                if (!empty($message)) {
169 169
                     $message->delete();
170
-                    $del_count ++;
170
+                    $del_count++;
171 171
                 }
172 172
             }
173
-        }else{
174
-            $message = static::find($messages);
175
-            if(!empty($message)){
173
+        } else {
174
+            $message=static::find($messages);
175
+            if (!empty($message)) {
176 176
                 $message->delete();
177
-                $del_count ++;
177
+                $del_count++;
178 178
             }
179 179
         }
180 180
         return $del_count;
Please login to merge, or discard this patch.
app/Models/ProblemModel.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
             $prob_detail["pdf"]=false;
49 49
             $prob_detail["viewerShow"]=false;
50 50
             $prob_detail["file_ext"]=null;
51
-            if($prob_detail['file'] && !blank($prob_detail['file_url'])){
52
-                $prob_detail["file_ext"]=explode('.',basename($prob_detail['file_url']));
51
+            if ($prob_detail['file'] && !blank($prob_detail['file_url'])) {
52
+                $prob_detail["file_ext"]=explode('.', basename($prob_detail['file_url']));
53 53
                 $prob_detail["file_ext"]=end($prob_detail["file_ext"]);
54 54
                 $prob_detail["pdf"]=Str::is("*.pdf", basename($prob_detail['file_url']));
55
-                $prob_detail["viewerShow"]= blank($prob_detail["parsed"]["description"]) &&
55
+                $prob_detail["viewerShow"]=blank($prob_detail["parsed"]["description"]) &&
56 56
                                             blank($prob_detail["parsed"]["input"]) &&
57 57
                                             blank($prob_detail["parsed"]["output"]) &&
58 58
                                             blank($prob_detail["parsed"]["note"]);
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 
195 195
     private function inteliAudit($uid, $content)
196 196
     {
197
-        if (strpos($content, '```')!==false){
197
+        if (strpos($content, '```')!==false) {
198 198
             $userSolutionHistory=DB::table("problem_solution")->where(['uid'=>$uid])->orderByDesc('updated_at')->first();
199
-            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1){
199
+            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1) {
200 200
                 return 1;
201 201
             }
202 202
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     {
293 293
         // $prob_list = DB::table($this->table)->select("pid","pcode","title")->get()->all(); // return a array
294 294
         $submissionModel=new SubmissionModel();
295
-        $preQuery=DB::table($this->table)->where('hide','=',0);
295
+        $preQuery=DB::table($this->table)->where('hide', '=', 0);
296 296
         if ($filter['oj']) {
297 297
             $preQuery=$preQuery->where(["OJ"=>$filter['oj']]);
298 298
         }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 
447 447
         if (!empty($data["sample"])) {
448 448
             foreach ($data["sample"] as $d) {
449
-                if(!isset($d['sample_note'])) $d['sample_note']=null;
449
+                if (!isset($d['sample_note'])) $d['sample_note']=null;
450 450
                 DB::table("problem_sample")->insert([
451 451
                     'pid'=>$pid,
452 452
                     'sample_input'=>$d['sample_input'],
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
         if (!empty($data["sample"])) {
494 494
             foreach ($data["sample"] as $d) {
495
-                if(!isset($d['sample_note'])) $d['sample_note']=null;
495
+                if (!isset($d['sample_note'])) $d['sample_note']=null;
496 496
                 DB::table("problem_sample")->insert([
497 497
                     'pid'=>$pid,
498 498
                     'sample_input'=>$d['sample_input'],
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 
508 508
     public function discussionList($pid)
509 509
     {
510
-        $paginator = DB::table('problem_discussion')->join(
510
+        $paginator=DB::table('problem_discussion')->join(
511 511
             "users",
512 512
             "id",
513 513
             "=",
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
             'users.name',
527 527
             'users.id as uid'
528 528
         ])->paginate(15);
529
-        $list = $paginator->all();
530
-        foreach($list as &$l){
531
-            $l['updated_at'] = $this->formatTime($l['updated_at']);
532
-            $l['comment_count'] = DB::table('problem_discussion_comment')->where('pdid','=',$l['pdid'])->count();
529
+        $list=$paginator->all();
530
+        foreach ($list as &$l) {
531
+            $l['updated_at']=$this->formatTime($l['updated_at']);
532
+            $l['comment_count']=DB::table('problem_discussion_comment')->where('pdid', '=', $l['pdid'])->count();
533 533
         }
534 534
         return [
535 535
             'paginator' => $paginator,
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
     public function discussionDetail($pdid)
574 574
     {
575
-        $main = DB::table('problem_discussion')->join(
575
+        $main=DB::table('problem_discussion')->join(
576 576
             "users",
577 577
             "id",
578 578
             "=",
@@ -591,12 +591,12 @@  discard block
 block discarded – undo
591 591
             'users.name',
592 592
             'users.id as uid'
593 593
         ])->get()->first();
594
-        $main['created_at'] = $this->formatTime($main['created_at']);
594
+        $main['created_at']=$this->formatTime($main['created_at']);
595 595
         $main['content']=clean(Markdown::convertToHtml($main["content"]));
596 596
 
597
-        $comment_count = DB::table('problem_discussion_comment')->where('pdid','=',$pdid)->count();
597
+        $comment_count=DB::table('problem_discussion_comment')->where('pdid', '=', $pdid)->count();
598 598
 
599
-        $paginator = DB::table('problem_discussion_comment')->join(
599
+        $paginator=DB::table('problem_discussion_comment')->join(
600 600
             "users",
601 601
             "id",
602 602
             "=",
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
             'users.name',
616 616
             'users.id as uid'
617 617
         ])->paginate(10);
618
-        $comment = $paginator->all();
619
-        foreach($comment as &$c){
618
+        $comment=$paginator->all();
619
+        foreach ($comment as &$c) {
620 620
             $c['content']=clean(Markdown::convertToHtml($c["content"]));
621
-            $c['created_at'] = $this->formatTime($c['created_at']);
622
-            $c['reply'] = DB::table('problem_discussion_comment')->join(
621
+            $c['created_at']=$this->formatTime($c['created_at']);
622
+            $c['reply']=DB::table('problem_discussion_comment')->join(
623 623
                 "users",
624 624
                 "id",
625 625
                 "=",
@@ -647,20 +647,20 @@  discard block
 block discarded – undo
647 647
                 'users.name',
648 648
                 'users.id as uid'
649 649
             ])->get()->all();
650
-            foreach($c['reply'] as $k=>&$cr){
650
+            foreach ($c['reply'] as $k=>&$cr) {
651 651
                 $cr['content']=clean(Markdown::convertToHtml($cr["content"]));
652
-                $cr['reply_uid'] = DB::table('problem_discussion_comment')->where(
652
+                $cr['reply_uid']=DB::table('problem_discussion_comment')->where(
653 653
                     'pdcid',
654 654
                     '=',
655 655
                     $cr['reply_id']
656 656
                 )->get()->first()['uid'];
657
-                $cr['reply_name'] = DB::table('users')->where(
657
+                $cr['reply_name']=DB::table('users')->where(
658 658
                     'id',
659 659
                     '=',
660 660
                     $cr['reply_uid']
661 661
                 )->get()->first()['name'];
662
-                $cr['created_at'] = $this->formatTime($cr['created_at']);
663
-                if($this->replyParent($cr['pdcid'])!=$c['pdcid']){
662
+                $cr['created_at']=$this->formatTime($cr['created_at']);
663
+                if ($this->replyParent($cr['pdcid'])!=$c['pdcid']) {
664 664
                     unset($c['reply'][$k]);
665 665
                 }
666 666
             }
@@ -675,19 +675,19 @@  discard block
 block discarded – undo
675 675
 
676 676
     public function replyParent($pdcid)
677 677
     {
678
-        $reply_id=DB::table('problem_discussion_comment')->where('pdcid','=',$pdcid)->get()->first()['reply_id'];
679
-        $top=DB::table('problem_discussion_comment')->where('pdcid','=',$reply_id)->get()->first()['reply_id'];
680
-        if(isset($top)){
678
+        $reply_id=DB::table('problem_discussion_comment')->where('pdcid', '=', $pdcid)->get()->first()['reply_id'];
679
+        $top=DB::table('problem_discussion_comment')->where('pdcid', '=', $reply_id)->get()->first()['reply_id'];
680
+        if (isset($top)) {
681 681
             return $this->replyParent($reply_id);
682
-        }else{
682
+        } else {
683 683
             return $reply_id;
684 684
         }
685 685
     }
686 686
 
687 687
     public function pcodeByPdid($dcode)
688 688
     {
689
-        $pid = DB::table('problem_discussion')->where('pdid','=',$dcode)->get()->first()['pid'];
690
-        $pcode = $this->pcode($pid);
689
+        $pid=DB::table('problem_discussion')->where('pdid', '=', $dcode)->get()->first()['pid'];
690
+        $pcode=$this->pcode($pid);
691 691
         return $pcode;
692 692
     }
693 693
 
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 
709 709
     public function pidByPdid($pdid)
710 710
     {
711
-        $pid = DB::table('problem_discussion')->where('pdid','=',$pdid)->get()->first()['pid'];
711
+        $pid=DB::table('problem_discussion')->where('pdid', '=', $pdid)->get()->first()['pid'];
712 712
         return $pid;
713 713
     }
714 714
 
715
-    public function addComment($uid,$pdid,$content,$reply_id)
715
+    public function addComment($uid, $pdid, $content, $reply_id)
716 716
     {
717 717
         $pid=$this->pidByPdid($pdid);
718 718
         $pdcid=DB::table('problem_discussion_comment')->insertGetId([
@@ -731,6 +731,6 @@  discard block
 block discarded – undo
731 731
   
732 732
     public function isHidden($pid)
733 733
     {
734
-        return DB::table('problem')->where('pid','=',$pid)->get()->first()['hide'];
734
+        return DB::table('problem')->where('pid', '=', $pid)->get()->first()['hide'];
735 735
     }
736 736
 }
Please login to merge, or discard this patch.
app/Models/Babel/ExtensionModel.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
         $ret=[];
23 23
         $marketspaceRaw=self::getRemote();
24 24
         $marketspace=[];
25
-        foreach($marketspaceRaw["packages"] as $extension){
25
+        foreach ($marketspaceRaw["packages"] as $extension) {
26 26
             $marketspace[$extension["name"]]=$extension;
27 27
         }
28 28
 
29 29
         $localList=self::getLocal();
30 30
 
31
-        foreach($localList as $extension){
31
+        foreach ($localList as $extension) {
32 32
             $temp=[
33 33
                 "details"=>$extension,
34 34
                 "status"=>0,
@@ -37,30 +37,30 @@  discard block
 block discarded – undo
37 37
                 "settings"=>null,
38 38
                 "available"=>null
39 39
             ];
40
-            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge";
40
+            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge";
41 41
             try {
42 42
                 if ($extension["version"]=='__cur__') {
43 43
                     $extension["version"]=explode("-", version())[0];
44 44
                 }
45 45
                 $downloadedVersion=new Version($extension["version"]);
46 46
 
47
-                if(isset($marketspace[$extension["name"]])){
47
+                if (isset($marketspace[$extension["name"]])) {
48 48
                     //remote extension, else is local extension
49 49
                     $remoteVersion=new Version($marketspace[$extension["name"]]["version"]);
50 50
                     $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion);
51 51
                     $temp["details"]["official"]=$marketspace[$extension["name"]]["official"];
52
-                } else{
52
+                } else {
53 53
                     $temp["updatable"]=false;
54 54
                     $temp["details"]["official"]=0;
55 55
                 }
56 56
 
57 57
                 $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();
58
-                if (is_null($installedConfig)){
58
+                if (is_null($installedConfig)) {
59 59
                     $temp["status"]=1;
60 60
                 } else {
61 61
                     $temp["version"]=$installedConfig->version; // local installed version
62 62
                     $installedVersion=new Version($temp["version"]);
63
-                    if ($downloadedVersion->isGreaterThan($installedVersion)){
63
+                    if ($downloadedVersion->isGreaterThan($installedVersion)) {
64 64
                         $temp["status"]=1;
65 65
                     } else {
66 66
                         $temp["status"]=2;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     $temp["settings"]=false;
69 69
                     $temp["available"]=$installedConfig->status;
70 70
                 }
71
-            }catch (Throwable $e){
71
+            } catch (Throwable $e) {
72 72
                 continue;
73 73
             }
74 74
             $ret[]=$temp;
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     {
81 81
         $ret=[];
82 82
         $marketspaceRaw=self::getRemote();
83
-        if(empty($marketspaceRaw)) return [];
84
-        foreach($marketspaceRaw["packages"] as $extension){
83
+        if (empty($marketspaceRaw)) return [];
84
+        foreach ($marketspaceRaw["packages"] as $extension) {
85 85
             $temp=[
86 86
                 "details"=>$extension,
87 87
                 "status"=>0,
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
                 "settings"=>null,
91 91
                 "available"=>null
92 92
             ];
93
-            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge";
93
+            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge";
94 94
             try {
95 95
                 try {
96 96
                     $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true);
97
-                }catch (Throwable $e){
97
+                } catch (Throwable $e) {
98 98
                     $BabelConfig=[];
99 99
                 }
100 100
                 if (!empty($BabelConfig)) {
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
                     $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion);
107 107
 
108 108
                     $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();
109
-                    if (is_null($installedConfig)){
109
+                    if (is_null($installedConfig)) {
110 110
                         $temp["status"]=1;
111 111
                     } else {
112 112
                         $temp["version"]=$installedConfig->version; // local installed version
113 113
                         $installedVersion=new Version($temp["version"]);
114
-                        if ($downloadedVersion->isGreaterThan($installedVersion)){
114
+                        if ($downloadedVersion->isGreaterThan($installedVersion)) {
115 115
                             $temp["status"]=1;
116 116
                         } else {
117 117
                             $temp["status"]=2;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                         $temp["available"]=$installedConfig->status;
121 121
                     }
122 122
                 }
123
-            }catch (Throwable $e){
123
+            } catch (Throwable $e) {
124 124
                 continue;
125 125
             }
126 126
             $ret[]=$temp;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
     public static function getLocal()
133 133
     {
134 134
         $ret=[];
135
-        $dirs = array_filter(glob(babel_path("Extension/*")), 'is_dir');
136
-        foreach($dirs as $d){
135
+        $dirs=array_filter(glob(babel_path("Extension/*")), 'is_dir');
136
+        foreach ($dirs as $d) {
137 137
             $extension=basename($d);
138 138
             $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$extension/babel.json")), true);
139
-            if($extension==$BabelConfig["code"]) $ret[]=$BabelConfig;
139
+            if ($extension==$BabelConfig["code"]) $ret[]=$BabelConfig;
140 140
         }
141 141
         return $ret;
142 142
     }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         try {
147 147
             return json_decode(file_get_contents(config('babel.mirror')."/babel.json"), true);
148
-        }catch(Throwable $e){
148
+        } catch (Throwable $e) {
149 149
             return [];
150 150
         }
151 151
     }
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
     public static function remoteDetail($code)
154 154
     {
155 155
         $babelConfig=self::getRemote();
156
-        if(empty($babelConfig)) return [];
156
+        if (empty($babelConfig)) return [];
157 157
         $babelConfigPackages=$babelConfig["packages"];
158
-        foreach($babelConfigPackages as $package) {
159
-            if($package["code"]==$code) return $package;
158
+        foreach ($babelConfigPackages as $package) {
159
+            if ($package["code"]==$code) return $package;
160 160
         }
161 161
         return [];
162 162
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Contest/AdminController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $contestModel=new ContestModel();
25 25
         $verified=$contestModel->isVerified($cid);
26 26
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
27
-        if ($clearance <= 2) {
27
+        if ($clearance<=2) {
28 28
             return Redirect::route('contest_detail', ['cid' => $cid]);
29 29
         }
30 30
         $contest_name=$contestModel->contestName($cid);
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $basicInfo=$contestModel->basic($cid);
34 34
         $contest_accounts=$accountModel->getContestAccount($cid);
35 35
         $gcode=$contestModel->gcode($cid);
36
-        $isEnd = $contestModel->remainingTime($cid) < 0;
36
+        $isEnd=$contestModel->remainingTime($cid)<0;
37 37
         return view('contest.board.admin', [
38 38
             'page_title'=>"Admin",
39 39
             'navigation' => "Contest",
@@ -54,43 +54,43 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $contestModel=new ContestModel();
56 56
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
57
-        if ($clearance <= 2) {
57
+        if ($clearance<=2) {
58 58
             return Redirect::route('contest_detail', ['cid' => $cid]);
59 59
         }
60 60
         $account=$contestModel->getContestAccount($cid);
61
-        if($account==null){
62
-            return ;
63
-        }else{
61
+        if ($account==null) {
62
+            return;
63
+        } else {
64 64
             $AccountExport=new AccountExport($account);
65 65
             $filename="ContestAccount$cid";
66 66
             return Excel::download($AccountExport, $filename.'.xlsx');
67 67
         }
68 68
     }
69 69
 
70
-    public function refreshContestRank($cid){
70
+    public function refreshContestRank($cid) {
71 71
         $contestModel=new ContestModel();
72 72
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
73
-        if ($clearance <= 2) {
73
+        if ($clearance<=2) {
74 74
             return Redirect::route('contest.detail', ['cid' => $cid]);
75 75
         }
76 76
         $contestRankRaw=$contestModel->contestRankCache($cid);
77 77
         Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
78 78
         Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
79 79
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
80
-        if(time() > strtotime($end_time)){
80
+        if (time()>strtotime($end_time)) {
81 81
             $contestModel->storeContestRankInMySQL($cid, $contestRankRaw);
82 82
         }
83 83
         return Redirect::route('contest.rank', ['cid' => $cid]);
84 84
     }
85 85
 
86
-    public function scrollBoard($cid){
86
+    public function scrollBoard($cid) {
87 87
         $contestModel=new ContestModel();
88 88
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
89
-        if ($clearance <= 2) {
89
+        if ($clearance<=2) {
90 90
             return Redirect::route('contest_detail', ['cid' => $cid]);
91 91
         }
92 92
         $basicInfo=$contestModel->basic($cid);
93
-        if($basicInfo['froze_length'] == 0){
93
+        if ($basicInfo['froze_length']==0) {
94 94
             return Redirect::route('contest.admin', ['cid' => $cid]);
95 95
         }
96 96
         return view('contest.board.scrollBoard', [
Please login to merge, or discard this patch.
app/Http/Controllers/MessageController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 {
11 11
     public function index()
12 12
     {
13
-        $uid = Auth::user()->id;
14
-        $messages = MessageModel::list($uid);
13
+        $uid=Auth::user()->id;
14
+        $messages=MessageModel::list($uid);
15 15
         return view('message.index', [
16 16
             'page_title'=>"Message",
17 17
             'site_title'=>config("app.name"),
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function detail($id)
24 24
     {
25
-        $message = MessageModel::read($id);
26
-        if(empty($message || $message->receiver != Auth::user()->id)){
25
+        $message=MessageModel::read($id);
26
+        if (empty($message || $message->receiver!=Auth::user()->id)) {
27 27
             return Redirect::route('message.index');
28 28
         }
29 29
         return view('message.detail', [
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/GroupManageController.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
         $all_data=$request->all();
37 37
 
38
-        if(($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)){
38
+        if (($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)) {
39 39
             return ResponseModel::err(4007);
40 40
         }
41 41
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             return ResponseModel::err(1003);
67 67
         }
68 68
 
69
-        $cid = $contestModel->arrangeContest($all_data["gid"], [
69
+        $cid=$contestModel->arrangeContest($all_data["gid"], [
70 70
             "assign_uid"=>Auth::user()->id,
71 71
             "name"=>$all_data["name"],
72 72
             "description"=>$all_data["description"],
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             "public"=>$all_data["public"] ?? 0,
77 77
         ], $problemSet);
78 78
 
79
-        return ResponseModel::success(200,'Successful!',$cid);
79
+        return ResponseModel::success(200, 'Successful!', $cid);
80 80
     }
81 81
 
82 82
     public function changeGroupName(Request $request)
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
         $groupModel=new GroupModel();
92 92
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
93
-        if ($clearance < 2){
93
+        if ($clearance<2) {
94 94
             return ResponseModel::err(2001);
95 95
         }
96 96
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 
110 110
         $groupModel=new GroupModel();
111 111
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
112
-        if ($clearance < 2){
112
+        if ($clearance<2) {
113 113
             return ResponseModel::err(2001);
114 114
         }
115 115
 
116
-        if ($all_data["join_policy"] < 1 || $all_data["join_policy"] > 3){
116
+        if ($all_data["join_policy"]<1 || $all_data["join_policy"]>3) {
117 117
             return ResponseModel::err(1007);
118 118
         }
119 119
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             'gid' => 'required|integer',
128 128
         ]);
129 129
 
130
-        $all_data = $request->all();
130
+        $all_data=$request->all();
131 131
 
132 132
         if (!empty($request->file('img')) && $request->file('img')->isValid()) {
133 133
             $extension=$request->file('img')->extension();
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         $groupModel=new GroupModel();
141 141
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
142
-        if ($clearance < 2){
142
+        if ($clearance<2) {
143 143
             return ResponseModel::err(2001);
144 144
         }
145 145
 
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
178 178
         $target_clearance=$groupModel->judgeClearance($all_data["gid"], $all_data['uid']);
179 179
 
180
-        if($target_clearance == -3){
180
+        if ($target_clearance==-3) {
181 181
             return ResponseModel::err(7004);
182 182
         }
183 183
 
184
-        if($target_clearance >= $clearance || $clearance < 2 || $all_data['permission'] >= $clearance){
184
+        if ($target_clearance>=$clearance || $clearance<2 || $all_data['permission']>=$clearance) {
185 185
             return ResponseModel::err(2001);
186 186
         }
187 187
 
188 188
         $groupModel->changeClearance($all_data['uid'], $all_data["gid"], $all_data['permission']);
189 189
 
190
-        $result_info = $groupModel->userProfile($all_data['uid'],$all_data["gid"]);
191
-        return ResponseModel::success(200,null,$result_info);
190
+        $result_info=$groupModel->userProfile($all_data['uid'], $all_data["gid"]);
191
+        return ResponseModel::success(200, null, $result_info);
192 192
     }
193 193
 
194 194
     public function approveMember(Request $request)
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
205 205
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
206 206
         if ($clearance>1) {
207
-            if($targetClearance!=0) {
207
+            if ($targetClearance!=0) {
208 208
                 return ResponseModel::err(7003);
209 209
             }
210 210
             $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         $groupModel=new GroupModel();
226 226
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
227 227
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
228
-        if ($clearance <= 1 || $clearance <= $targetClearance){
228
+        if ($clearance<=1 || $clearance<=$targetClearance) {
229 229
             return ResponseModel::err(7002);
230 230
         }
231 231
 
@@ -245,16 +245,16 @@  discard block
 block discarded – undo
245 245
 
246 246
         $groupModel=new GroupModel();
247 247
         $is_user=$groupModel->isUser($all_data["email"]);
248
-        if(!$is_user) return ResponseModel::err(2006);
248
+        if (!$is_user) return ResponseModel::err(2006);
249 249
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
250
-        if($clearance<2) return ResponseModel::err(7002);
250
+        if ($clearance<2) return ResponseModel::err(7002);
251 251
         $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]);
252
-        if($targetClearance!=-3) return ResponseModel::err(7003);
252
+        if ($targetClearance!=-3) return ResponseModel::err(7003);
253 253
         $groupModel->inviteMember($all_data["gid"], $all_data["email"]);
254
-        $basic = $groupModel->basic($all_data['gid']);
255
-        $url = route('group.detail',['gcode' => $basic['gcode']]);
256
-        $receiver_id = UserModel::where('email',$all_data['email'])->first()['id'];
257
-        $sender_name = Auth::user()->name;
254
+        $basic=$groupModel->basic($all_data['gid']);
255
+        $url=route('group.detail', ['gcode' => $basic['gcode']]);
256
+        $receiver_id=UserModel::where('email', $all_data['email'])->first()['id'];
257
+        $sender_name=Auth::user()->name;
258 258
         sendMessage([
259 259
             'receiver' => $receiver_id,
260 260
             'sender' => Auth::user()->id,
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 
297 297
         $groupModel=new GroupModel();
298 298
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
299
-        if ($clearance < 2){
299
+        if ($clearance<2) {
300 300
             return ResponseModel::err(2001);
301 301
         }
302 302
         $groupModel->createNotice($all_data["gid"], Auth::user()->id, $all_data["title"], $all_data["content"]);
Please login to merge, or discard this patch.