Passed
Pull Request — master (#414)
by John
12:18
created
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
-        $receiverInfo = UserModel::where('email',$all_data['email'])->first();
257
-        $sender_name = Auth::user()->name;
254
+        $basic=$groupModel->basic($all_data['gid']);
255
+        $url=route('group.detail', ['gcode' => $basic['gcode']]);
256
+        $receiverInfo=UserModel::where('email', $all_data['email'])->first();
257
+        $sender_name=Auth::user()->name;
258 258
         sendMessage([
259 259
             'receiver' => $receiverInfo["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.
app/Admin/Controllers/BabelController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $extensionList=ExtensionModel::list();
134 134
 
135
-        if(empty($extensionList)){
135
+        if (empty($extensionList)) {
136 136
             return view('admin::babel.empty');
137 137
         }
138 138
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         $details=ExtensionModel::remoteDetail($code);
147 147
 
148
-        if(empty($details)){
148
+        if (empty($details)) {
149 149
             return view('admin::babel.empty');
150 150
         }
151 151
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $details=ExtensionModel::remoteDetail($extension);
160 160
 
161
-        if(empty($details)){
161
+        if (empty($details)) {
162 162
             return view('admin::babel.empty');
163 163
         }
164 164
 
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 
170 170
     private static function executeArtisan($command)
171 171
     {
172
-        $fp = popen('php "'.base_path('artisan').'" '.$command, "r");
173
-        while($b = fgets($fp, 2048)) {
172
+        $fp=popen('php "'.base_path('artisan').'" '.$command, "r");
173
+        while ($b=fgets($fp, 2048)) {
174 174
             echo str_pad(json_encode([
175 175
                 "ret"=>200,
176 176
                 "desc"=>"Succeed",
177 177
                 "data"=>[
178 178
                     "message"=>$b
179 179
                 ]
180
-            ])."\n",4096);
180
+            ])."\n", 4096);
181 181
             @ob_flush();
182 182
             flush();
183 183
         }
Please login to merge, or discard this patch.
app/Http/Controllers/OAuth/GithubController.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function redirectTo()
14 14
     {
15
-        $accountModel = new AccountModel();
16
-        if(Auth::check()){
15
+        $accountModel=new AccountModel();
16
+        if (Auth::check()) {
17 17
             $info=$accountModel->detail(Auth::user()->id);
18
-            if(Auth::check() && $info['contest_account']){
18
+            if (Auth::check() && $info['contest_account']) {
19 19
                 return redirect('/account/settings');
20 20
             }
21 21
         }
22
-        if(Auth::check() && $accountModel->getExtra(Auth::user()->id ,'github_id')){
23
-            return view('oauth.index',[
22
+        if (Auth::check() && $accountModel->getExtra(Auth::user()->id, 'github_id')) {
23
+            return view('oauth.index', [
24 24
                 'page_title'=>"OAuth",
25 25
                 'site_title'=>config("app.name"),
26 26
                 'navigation'=>"OAuth",
27 27
                 'platform' => 'Github',
28
-                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
28
+                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
29 29
                 You can choose to unbind or go back to the homepage',
30 30
                 'buttons' => [
31 31
                     [
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function handleCallback()
47 47
     {
48
-        try{
49
-            $github_user = Socialite::driver('github')->user();
50
-        }catch(\Laravel\Socialite\Two\InvalidStateException $e){
48
+        try {
49
+            $github_user=Socialite::driver('github')->user();
50
+        } catch (\Laravel\Socialite\Two\InvalidStateException $e) {
51 51
             return redirect('/');
52 52
         }
53 53
 
54
-        $accountModel = new AccountModel();
55
-        if(Auth::check()){
56
-            $user_id = Auth::user()->id;
57
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
58
-            if(!empty($ret) && $ret['uid'] != $user_id){
59
-                $user = UserModel::find($ret['uid']);
60
-                return view('oauth.index',[
54
+        $accountModel=new AccountModel();
55
+        if (Auth::check()) {
56
+            $user_id=Auth::user()->id;
57
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
58
+            if (!empty($ret) && $ret['uid']!=$user_id) {
59
+                $user=UserModel::find($ret['uid']);
60
+                return view('oauth.index', [
61 61
                     'page_title'=>"OAuth",
62 62
                     'site_title'=>config("app.name"),
63 63
                     'navigation'=>"OAuth",
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
                     ]
73 73
                 ]);
74 74
             }
75
-            $accountModel->setExtra($user_id,'github_id',$github_user->id);
76
-            $accountModel->setExtra($user_id,'github_email',$github_user->email);
77
-            $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
78
-            $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
79
-            $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
80
-            return view('oauth.index',[
75
+            $accountModel->setExtra($user_id, 'github_id', $github_user->id);
76
+            $accountModel->setExtra($user_id, 'github_email', $github_user->email);
77
+            $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
78
+            $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
79
+            $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
80
+            return view('oauth.index', [
81 81
                 'page_title'=>"OAuth",
82 82
                 'site_title'=>config("app.name"),
83 83
                 'navigation'=>"OAuth",
84 84
                 'platform' => 'Github',
85
-                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
85
+                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
86 86
                 You can log in to '.config("app.name").' later using this account',
87 87
                 'buttons' => [
88 88
                     [
@@ -91,18 +91,18 @@  discard block
 block discarded – undo
91 91
                     ],
92 92
                 ]
93 93
             ]);
94
-        }else{
95
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
96
-            if(!empty($ret)){
94
+        } else {
95
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
96
+            if (!empty($ret)) {
97 97
                 Auth::loginUsingId($ret['uid']);
98
-                $user_id = Auth::user()->id;
99
-                $accountModel->setExtra($user_id,'github_email',$github_user->email);
100
-                $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
101
-                $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
102
-                $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
98
+                $user_id=Auth::user()->id;
99
+                $accountModel->setExtra($user_id, 'github_email', $github_user->email);
100
+                $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
101
+                $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
102
+                $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
103 103
                 return redirect('/');
104
-            }else{
105
-                return view('oauth.index',[
104
+            } else {
105
+                return view('oauth.index', [
106 106
                     'page_title'=>"OAuth",
107 107
                     'site_title'=>config("app.name"),
108 108
                     'navigation'=>"OAuth",
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function unbind()
127 127
     {
128
-        if(!Auth::check()){
128
+        if (!Auth::check()) {
129 129
             return redirect('/');
130 130
         }
131
-        $accountModel = new AccountModel();
132
-        if($accountModel->getExtra(Auth::user()->id ,'github_id')){
133
-            return view('oauth.index',[
131
+        $accountModel=new AccountModel();
132
+        if ($accountModel->getExtra(Auth::user()->id, 'github_id')) {
133
+            return view('oauth.index', [
134 134
                 'page_title'=>"OAuth",
135 135
                 'site_title'=>config("app.name"),
136 136
                 'navigation'=>"OAuth",
137 137
                 'platform' => 'Github',
138 138
                 'display_html' => 'You are trying to unbind the following two : <br />
139 139
                 Your '.config("app.name").' account : <span class="text-info">'.Auth::user()->email.'</span><br />
140
-                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
140
+                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
141 141
                 Make your decision carefully, although you can later establish the binding again',
142 142
                 'buttons' => [
143 143
                     [
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
                     ],
152 152
                 ]
153 153
             ]);
154
-        }else{
155
-            return view('oauth.index',[
154
+        } else {
155
+            return view('oauth.index', [
156 156
                 'page_title'=>"OAuth",
157 157
                 'site_title'=>config("app.name"),
158 158
                 'navigation'=>"OAuth",
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 
171 171
     public function confirmUnbind()
172 172
     {
173
-        if(!Auth::check()){
173
+        if (!Auth::check()) {
174 174
             return redirect('/');
175 175
         }
176
-        $accountModel = new AccountModel();
177
-        $user_id = Auth::user()->id;
178
-        if($accountModel->getExtra($user_id ,'github_id')){
179
-            $accountModel->setExtra($user_id,'github_id',null);
180
-            $accountModel->setExtra($user_id,'github_email',null);
181
-            $accountModel->setExtra($user_id,'github_nickname',null);
182
-            $accountModel->setExtra($user_id,'github_homepage',null);
183
-            $accountModel->setExtra($user_id,'github_token',null);
184
-            return view('oauth.index',[
176
+        $accountModel=new AccountModel();
177
+        $user_id=Auth::user()->id;
178
+        if ($accountModel->getExtra($user_id, 'github_id')) {
179
+            $accountModel->setExtra($user_id, 'github_id', null);
180
+            $accountModel->setExtra($user_id, 'github_email', null);
181
+            $accountModel->setExtra($user_id, 'github_nickname', null);
182
+            $accountModel->setExtra($user_id, 'github_homepage', null);
183
+            $accountModel->setExtra($user_id, 'github_token', null);
184
+            return view('oauth.index', [
185 185
                 'page_title'=>"OAuth",
186 186
                 'site_title'=>config("app.name"),
187 187
                 'navigation'=>"OAuth",
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
                     ],
195 195
                 ]
196 196
             ]);
197
-        }else{
198
-            return view('oauth.index',[
197
+        } else {
198
+            return view('oauth.index', [
199 199
                 'page_title'=>"OAuth",
200 200
                 'site_title'=>config("app.name"),
201 201
                 'navigation'=>"OAuth",
Please login to merge, or discard this patch.
app/Http/Controllers/Contest/BoardController.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
         $contestModel=new ContestModel();
35 35
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
36 36
         $basicInfo=$contestModel->basic($cid);
37
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
38
-            if($clearance == 3){
37
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
38
+            if ($clearance==3) {
39 39
                 return Redirect::route('contest.admin', ['cid' => $cid]);
40
-            }else{
40
+            } else {
41 41
                 return Redirect::route('contest.detail', ['cid' => $cid]);
42 42
             }
43 43
         }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         if ($remainingTime<=0) {
51 51
             $remainingTime=0;
52 52
         }
53
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
53
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
54 54
             return Redirect::route('contest.detail', ['cid' => $cid]);
55 55
         }
56 56
         return view('contest.board.challenge', [
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
         $accountModel=new AccountModel();
84 84
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
85 85
         $basicInfo=$contestModel->basic($cid);
86
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
87
-            if($clearance == 3){
86
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
87
+            if ($clearance==3) {
88 88
                 return Redirect::route('contest.admin', ['cid' => $cid]);
89
-            }else{
89
+            } else {
90 90
                 return Redirect::route('contest.detail', ['cid' => $cid]);
91 91
             }
92 92
         }
93 93
         $basicInfo=$contestModel->basic($cid);
94
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
94
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
95 95
             return Redirect::route('contest.detail', ['cid' => $cid]);
96 96
         }
97 97
         $contest_name=$contestModel->contestName($cid);
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
             ];
123 123
         }
124 124
 
125
-        $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width');
126
-        if(empty($editor_left_width)) $editor_left_width='40';
125
+        $editor_left_width=$accountModel->getExtra(Auth::user()->id, 'editor_left_width');
126
+        if (empty($editor_left_width)) $editor_left_width='40';
127 127
 
128 128
         return view('contest.board.editor', [
129 129
             'page_title'=>"Problem Detail",
@@ -157,15 +157,15 @@  discard block
 block discarded – undo
157 157
         $contestModel=new ContestModel();
158 158
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
159 159
         $basicInfo=$contestModel->basic($cid);
160
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
161
-            if($clearance == 3){
160
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
161
+            if ($clearance==3) {
162 162
                 return Redirect::route('contest.admin', ['cid' => $cid]);
163
-            }else{
163
+            } else {
164 164
                 return Redirect::route('contest.detail', ['cid' => $cid]);
165 165
             }
166 166
         }
167 167
         $basicInfo=$contestModel->basic($cid);
168
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
168
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
169 169
             return Redirect::route('contest.detail', ['cid' => $cid]);
170 170
         }
171 171
         $contest_name=$contestModel->contestName($cid);
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 
177 177
         // To determine the ranking
178 178
         foreach ($contestRank as $i => &$r) {
179
-            if($i != 0) {
180
-                if($r['score'] == $contestRank[$i-1]['score'] && ($contest_rule == 1 ? ($r['penalty'] == $contestRank[$i-1]['penalty']) : 1) ){
181
-                    $r['rank'] = $contestRank[$i-1]['rank'];
182
-                }else{
183
-                    $r['rank'] = $i + 1;
179
+            if ($i!=0) {
180
+                if ($r['score']==$contestRank[$i-1]['score'] && ($contest_rule==1 ? ($r['penalty']==$contestRank[$i-1]['penalty']) : 1)) {
181
+                    $r['rank']=$contestRank[$i-1]['rank'];
182
+                } else {
183
+                    $r['rank']=$i+1;
184 184
                 }
185
-            }else{
186
-                $r['rank'] = 1;
185
+            } else {
186
+                $r['rank']=1;
187 187
             }
188 188
         }
189 189
         $rankFrozen=$contestModel->isFrozen($cid);
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
         $contestModel=new ContestModel();
221 221
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
222 222
         $basicInfo=$contestModel->basic($cid);
223
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
224
-            if($clearance == 3){
223
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
224
+            if ($clearance==3) {
225 225
                 return Redirect::route('contest.admin', ['cid' => $cid]);
226
-            }else{
226
+            } else {
227 227
                 return Redirect::route('contest.detail', ['cid' => $cid]);
228 228
             }
229 229
         }
230 230
         $basicInfo=$contestModel->basic($cid);
231
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
231
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
232 232
             return Redirect::route('contest.detail', ['cid' => $cid]);
233 233
         }
234 234
         $contest_name=$contestModel->contestName($cid);
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
         $contestModel=new ContestModel();
263 263
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
264 264
         $basicInfo=$contestModel->basic($cid);
265
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
266
-            if($clearance == 3){
265
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
266
+            if ($clearance==3) {
267 267
                 return Redirect::route('contest.admin', ['cid' => $cid]);
268
-            }else{
268
+            } else {
269 269
                 return Redirect::route('contest.detail', ['cid' => $cid]);
270 270
             }
271 271
         }
272
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
272
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
273 273
             return Redirect::route('contest.detail', ['cid' => $cid]);
274 274
         }
275 275
         $contest_name=$contestModel->contestName($cid);
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
         $contestModel=new ContestModel();
301 301
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
302 302
         $basicInfo=$contestModel->basic($cid);
303
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
304
-            if($clearance == 3){
303
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
304
+            if ($clearance==3) {
305 305
                 return Redirect::route('contest.admin', ['cid' => $cid]);
306
-            }else{
306
+            } else {
307 307
                 return Redirect::route('contest.detail', ['cid' => $cid]);
308 308
             }
309 309
         }
310
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
310
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
311 311
             return Redirect::route('contest.detail', ['cid' => $cid]);
312 312
         }
313 313
         $contest_name=$contestModel->contestName($cid);
@@ -324,19 +324,19 @@  discard block
 block discarded – undo
324 324
         ]);
325 325
     }
326 326
 
327
-    public function analysis($cid){
327
+    public function analysis($cid) {
328 328
         $contestModel=new ContestModel();
329 329
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
330 330
         $basicInfo=$contestModel->basic($cid);
331
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
332
-            if($clearance == 3){
331
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
332
+            if ($clearance==3) {
333 333
                 return Redirect::route('contest.admin', ['cid' => $cid]);
334
-            }else{
334
+            } else {
335 335
                 return Redirect::route('contest.detail', ['cid' => $cid]);
336 336
             }
337 337
         }
338 338
         $basicInfo=$contestModel->basic($cid);
339
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
339
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
340 340
             return Redirect::route('contest.detail', ['cid' => $cid]);
341 341
         }
342 342
         $contest_name=$contestModel->contestName($cid);
Please login to merge, or discard this patch.
app/Models/Submission/SubmissionModel.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
                                             ->where(['verdict'=>'Waiting'])
372 372
                                             ->get()
373 373
                                             ->all();
374
-        foreach($ret as &$r){
374
+        foreach ($ret as &$r) {
375 375
             $r["ocode"]=DB::table("oj")->where(["oid"=>$r["oid"]])->first()["ocode"];
376 376
         }
377 377
         return $ret;
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
         if (isset($sub['verdict'])) {
390 390
             $sub["color"]=$this->colorScheme[$sub['verdict']];
391 391
         }
392
-        $result = DB::table($this->tableName)->where(['sid'=>$sid])->update($sub);
393
-        $contestModel = new ContestModel();
394
-        $submission_info = DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first();
395
-        if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])){
396
-            $sub['pid'] = $submission_info['pid'];
397
-            $sub['uid'] = $submission_info['uid'];
398
-            $sub['cid'] = $submission_info['cid'];
399
-            $sub['sid'] = $sid;
392
+        $result=DB::table($this->tableName)->where(['sid'=>$sid])->update($sub);
393
+        $contestModel=new ContestModel();
394
+        $submission_info=DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first();
395
+        if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])) {
396
+            $sub['pid']=$submission_info['pid'];
397
+            $sub['uid']=$submission_info['uid'];
398
+            $sub['cid']=$submission_info['cid'];
399
+            $sub['sid']=$sid;
400 400
             // $contestModel->updateContestRankTable($submission_info['cid'],$sub);
401 401
         }
402 402
         return $result;
@@ -468,15 +468,15 @@  discard block
 block discarded – undo
468 468
             'desc'
469 469
         );
470 470
 
471
-        if($filter["pcode"]){
471
+        if ($filter["pcode"]) {
472 472
             $paginator=$paginator->where(["pcode"=>$filter["pcode"]]);
473 473
         }
474 474
 
475
-        if($filter["result"]){
475
+        if ($filter["result"]) {
476 476
             $paginator=$paginator->where(["verdict"=>$filter["result"]]);
477 477
         }
478 478
 
479
-        if($filter["account"]){
479
+        if ($filter["account"]) {
480 480
             $paginator=$paginator->where(["name"=>$filter["account"]]);
481 481
         }
482 482
 
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestParticipant.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,6 +19,6 @@
 block discarded – undo
19 19
 
20 20
     public function contest()
21 21
     {
22
-        return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid');
22
+        return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid');
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestProblem.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@  discard block
 block discarded – undo
8 8
 {
9 9
     protected $table='contest_problem';
10 10
     protected $primaryKey='cpid';
11
-    public $timestamps = null;
11
+    public $timestamps=null;
12 12
     const DELETED_AT=null;
13 13
     const UPDATED_AT=null;
14 14
     const CREATED_AT=null;
15 15
 
16 16
     public function contest()
17 17
     {
18
-        return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid');
18
+        return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid');
19 19
     }
20 20
 
21 21
     public function problem()
22 22
     {
23
-        return $this->belongsTo('App\Models\Eloquent\ProblemModel','pid','pid');
23
+        return $this->belongsTo('App\Models\Eloquent\ProblemModel', 'pid', 'pid');
24 24
     }
25 25
 
26 26
     public function submissions()
27 27
     {
28
-        return $this->problem->submissions()->where('cid',$this->contest->cid);
28
+        return $this->problem->submissions()->where('cid', $this->contest->cid);
29 29
     }
30 30
 
31 31
     //This should be a repository...or service function ?
@@ -38,34 +38,34 @@  discard block
 block discarded – undo
38 38
             'wrong_doings'       => 0,
39 39
             'color'              => '',
40 40
         ];
41
-        $ac_record = $this->ac_record($user);
42
-        if(!empty($ac_record[0])){
43
-            $ret['solved']             = 1;
44
-            $ret['solved_time']        = $ac_record[0]->submission_date - strtotime($this->contest->begin_time);
45
-            $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']);
46
-            $ret['wrong_doings']       = $ac_record[2];
47
-            $ret['color']              = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text';
48
-        }else{
49
-            $ret['wrong_doings']       = $ac_record[2];
41
+        $ac_record=$this->ac_record($user);
42
+        if (!empty($ac_record[0])) {
43
+            $ret['solved']=1;
44
+            $ret['solved_time']=$ac_record[0]->submission_date-strtotime($this->contest->begin_time);
45
+            $ret['solved_time_parsed']=formatProblemSolvedTime($ret['solved_time']);
46
+            $ret['wrong_doings']=$ac_record[2];
47
+            $ret['color']=$ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text';
48
+        } else {
49
+            $ret['wrong_doings']=$ac_record[2];
50 50
         }
51 51
         return $ret;
52 52
     }
53 53
 
54 54
     public function ac_record($user)
55 55
     {
56
-        $user_ac = $this->submissions()->where([
56
+        $user_ac=$this->submissions()->where([
57 57
             'uid'     => $user->id,
58 58
             'verdict' => 'Accepted'
59 59
         ])->first();
60 60
 
61
-        $other_ac = 1;
62
-        $wrong_trys = 0;
63
-        if(!empty($user_ac)){
64
-            $other_ac = $this->submissions()
65
-                ->where('verdict','Accepted')
61
+        $other_ac=1;
62
+        $wrong_trys=0;
63
+        if (!empty($user_ac)) {
64
+            $other_ac=$this->submissions()
65
+                ->where('verdict', 'Accepted')
66 66
                 ->where('submission_date', '<', $user_ac->submission_date)
67 67
                 ->count();
68
-            $wrong_trys = $this->submissions()->where([
68
+            $wrong_trys=$this->submissions()->where([
69 69
                     'uid'     => $user->id,
70 70
                 ])->whereIn('verdict', [
71 71
                     'Runtime Error',
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
                     'Presentation Error',
77 77
                     'Output Limit Exceeded'
78 78
                 ])->where('submission_date', '<', $user_ac->submission_date)->count();
79
-        }else{
80
-            $wrong_trys = $this->submissions()->where([
79
+        } else {
80
+            $wrong_trys=$this->submissions()->where([
81 81
                 'uid'     => $user->id,
82 82
             ])->whereIn('verdict', [
83 83
                 'Runtime Error',
Please login to merge, or discard this patch.
app/Console/Kernel.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     protected function schedule(Schedule $schedule)
36 36
     {
37
-        $schedule->call(function () {
37
+        $schedule->call(function() {
38 38
             $babel=new Babel();
39 39
             for ($i=1; $i<=12; $i++) {
40 40
                 $babel->judge();
@@ -43,35 +43,35 @@  discard block
 block discarded – undo
43 43
             // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Judger");
44 44
         })->everyMinute()->description("Sync Judger");
45 45
 
46
-        $schedule->call(function () {
46
+        $schedule->call(function() {
47 47
             $rankModel=new RankModel();
48 48
             $rankModel->rankList();
49 49
             // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated Rank");
50 50
         })->dailyAt('02:00')->description("Update Rank");
51 51
 
52
-        $schedule->call(function () {
52
+        $schedule->call(function() {
53 53
             $siteMapModel=new SiteMapModel();
54 54
             // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated SiteMap");
55 55
         })->dailyAt('02:00')->description("Update SiteMap");
56 56
 
57
-        $schedule->call(function () {
57
+        $schedule->call(function() {
58 58
             $groupModel=new GroupModel();
59 59
             $groupModel->cacheTrendingGroups();
60 60
             // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Cached Trending Groups");
61 61
         })->dailyAt('03:00')->description("Update Trending Groups");
62 62
 
63 63
         $schedule->call(function() {
64
-            $groupModel = new GroupModel();
65
-            $ret = $groupModel->refreshAllElo();
64
+            $groupModel=new GroupModel();
65
+            $ret=$groupModel->refreshAllElo();
66 66
             foreach ($ret as $gid => $group) {
67
-                if(empty($group['result'])){
67
+                if (empty($group['result'])) {
68 68
                     Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']);
69
-                }else{
69
+                } else {
70 70
                     Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']);
71 71
                     foreach ($group['result'] as $contest) {
72
-                        if($contest['ret'] == 'success'){
72
+                        if ($contest['ret']=='success') {
73 73
                             Log::channel('group_elo')->info('    Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']);
74
-                        }else{
74
+                        } else {
75 75
                             Log::channel('group_elo')->info('    Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].'  sids:');
76 76
                             foreach ($contest['submissions'] as $sid) {
77 77
                                 Log::channel('group_elo')->info('        '.$sid['sid']);
@@ -82,46 +82,46 @@  discard block
 block discarded – undo
82 82
             }
83 83
         })->dailyAt('04:00')->description("Update Group Elo");
84 84
 
85
-        $schedule->call(function () {
86
-            $contestModel = new ContestModel();
87
-            $syncList = $contestModel->runningContest();
85
+        $schedule->call(function() {
86
+            $contestModel=new ContestModel();
87
+            $syncList=$contestModel->runningContest();
88 88
             foreach ($syncList as $syncContest) {
89 89
                 if (!isset($syncContest['vcid'])) {
90
-                    $contest = EloquentContestModel::find($syncContest['cid']);
91
-                    $contestRankRaw = $contest->rankRefresh();
90
+                    $contest=EloquentContestModel::find($syncContest['cid']);
91
+                    $contestRankRaw=$contest->rankRefresh();
92 92
                     $cid=$syncContest['cid'];
93 93
                     Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
94 94
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
95
-                    continue ;
95
+                    continue;
96 96
                 }
97
-                $className = "App\\Babel\\Extension\\hdu\\Synchronizer";  // TODO Add OJ judgement.
98
-                $all_data = [
97
+                $className="App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement.
98
+                $all_data=[
99 99
                     'oj'=>"hdu",
100 100
                     'vcid'=>$syncContest['vcid'],
101 101
                     'gid'=>$syncContest['gid'],
102 102
                     'cid'=>$syncContest['cid'],
103 103
                 ];
104
-                $hduSync = new $className($all_data);
104
+                $hduSync=new $className($all_data);
105 105
                 $hduSync->crawlRank();
106 106
                 $hduSync->crawlClarification();
107 107
             }
108 108
             // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Remote Rank and Clarification");
109 109
         })->everyMinute()->description("Sync Remote Rank and Clarification");
110 110
 
111
-        $schedule->call(function () {
112
-            $contestModel = new ContestModel();
113
-            $syncList = $contestModel->runningContest();
111
+        $schedule->call(function() {
112
+            $contestModel=new ContestModel();
113
+            $syncList=$contestModel->runningContest();
114 114
             foreach ($syncList as $syncContest) {
115 115
                 if (isset($syncContest['crawled'])) {
116 116
                     if (!$syncContest['crawled']) {
117
-                        $className = "App\\Babel\\Extension\\hdu\\Synchronizer";
118
-                        $all_data = [
117
+                        $className="App\\Babel\\Extension\\hdu\\Synchronizer";
118
+                        $all_data=[
119 119
                             'oj'=>"hdu",
120 120
                             'vcid'=>$syncContest['vcid'],
121 121
                             'gid'=>$syncContest['gid'],
122 122
                             'cid'=>$syncContest['cid'],
123 123
                         ];
124
-                        $hduSync = new $className($all_data);
124
+                        $hduSync=new $className($all_data);
125 125
                         $hduSync->scheduleCrawl();
126 126
                         $contestModel->updateCrawlStatus($syncContest['cid']);
127 127
                     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
             }
130 130
         })->everyMinute()->description("Sync Contest Problem");
131 131
 
132
-        $schedule->call(function () {
132
+        $schedule->call(function() {
133 133
             $oidList=EloquentJudgeServerModel::column('oid');
134 134
             $babel=new Babel();
135 135
             foreach ($oidList as $oid) {
Please login to merge, or discard this patch.
app/Http/Controllers/LatexController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function svg(Request $request)
14 14
     {
15
-        $ltxsource = $request->input('ltxsource');
15
+        $ltxsource=$request->input('ltxsource');
16 16
         if (is_null($ltxsource)) {
17 17
             return;
18 18
         }
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function png(Request $request)
26 26
     {
27
-        $ltxsource = $request->input('ltxsource');
27
+        $ltxsource=$request->input('ltxsource');
28 28
         if (is_null($ltxsource)) {
29 29
             return;
30 30
         }
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
         if (!Storage::exists('latex-svg/'.urlencode($ltxsource).'.svg')) {
40 40
             self::generateSVG($ltxsource);
41 41
         }
42
-        $image = new Imagick();
42
+        $image=new Imagick();
43 43
         $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg'));
44
-        $res = $image->getImageResolution();
45
-        $x_ratio = $res['x'] / $image->getImageWidth();
46
-        $y_ratio = $res['y'] / $image->getImageHeight();
44
+        $res=$image->getImageResolution();
45
+        $x_ratio=$res['x'] / $image->getImageWidth();
46
+        $y_ratio=$res['y'] / $image->getImageHeight();
47 47
         // $ratio=intval(200/$image->getImageHeight());
48 48
         $ratio=10;
49
-        $width=$image->getImageWidth()*$ratio;
50
-        $height=$image->getImageHeight()*$ratio;
49
+        $width=$image->getImageWidth() * $ratio;
50
+        $height=$image->getImageHeight() * $ratio;
51 51
         $image->removeImage();
52
-        $image->setResolution($width*$x_ratio, $height*$y_ratio);
52
+        $image->setResolution($width * $x_ratio, $height * $y_ratio);
53 53
         $image->setBackgroundColor(new \ImagickPixel('transparent'));
54 54
         $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg'));
55 55
         $image->setImageFormat("png32");
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     private static function generateSVG($ltxsource)
60 60
     {
61
-        $contents=str_replace('fill:rgb(0%,0%,0%)', 'fill:rgb(0,0,0)', Requests::get('http://www.tlhiv.org/ltxpreview/ltxpreview.cgi?' . http_build_query([
61
+        $contents=str_replace('fill:rgb(0%,0%,0%)', 'fill:rgb(0,0,0)', Requests::get('http://www.tlhiv.org/ltxpreview/ltxpreview.cgi?'.http_build_query([
62 62
             'width' => 10,
63 63
             'height' => 10,
64 64
             'ltx' => '',
Please login to merge, or discard this patch.