@@ -30,12 +30,12 @@ |
||
| 30 | 30 | { |
| 31 | 31 | $accountModel=new AccountModel(); |
| 32 | 32 | $info=$accountModel->detail($uid); |
| 33 | - if($info == null) { |
|
| 33 | + if ($info==null) { |
|
| 34 | 34 | return redirect("/"); |
| 35 | 35 | } |
| 36 | 36 | $feed=$accountModel->feed($uid); |
| 37 | - $extraInfo = User::find($uid)->getExtra(['gender', 'contact', 'school', 'country', 'location'], 0); |
|
| 38 | - $socialiteInfo = User::find($uid)->getSocialiteInfo(0); |
|
| 37 | + $extraInfo=User::find($uid)->getExtra(['gender', 'contact', 'school', 'country', 'location'], 0); |
|
| 38 | + $socialiteInfo=User::find($uid)->getSocialiteInfo(0); |
|
| 39 | 39 | return view("account.dashboard", [ |
| 40 | 40 | 'page_title'=>$info["name"], |
| 41 | 41 | 'site_title'=>config("app.name"), |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | class AccountController extends Controller |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - public function updateAvatar(Request $request){ |
|
| 18 | + public function updateAvatar(Request $request) { |
|
| 19 | 19 | $isValid=$request->file('avatar')->isValid(); |
| 20 | 20 | if ($isValid) { |
| 21 | 21 | $extension=$request->file('avatar')->extension(); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function changeBasicInfo(Request $request){ |
|
| 45 | + public function changeBasicInfo(Request $request) { |
|
| 46 | 46 | $request->validate([ |
| 47 | 47 | "username" => [ |
| 48 | 48 | "required", |
@@ -53,98 +53,98 @@ discard block |
||
| 53 | 53 | ], |
| 54 | 54 | "describes" => "required|string|max:255" |
| 55 | 55 | ]); |
| 56 | - $username = $request->input('username'); |
|
| 57 | - $describes = $request->input('describes'); |
|
| 56 | + $username=$request->input('username'); |
|
| 57 | + $describes=$request->input('describes'); |
|
| 58 | 58 | $user=Auth::user(); |
| 59 | - if(!Auth::user()->contest_account){ |
|
| 60 | - $user->name = $username; |
|
| 59 | + if (!Auth::user()->contest_account) { |
|
| 60 | + $user->name=$username; |
|
| 61 | 61 | } |
| 62 | - $user->describes = $describes; |
|
| 62 | + $user->describes=$describes; |
|
| 63 | 63 | $user->save(); |
| 64 | 64 | return ResponseModel::success(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public function changePassword(Request $request){ |
|
| 68 | - if(!$request->has('old_password') || !$request->has('new_password') || !$request->has('confirm_password')){ |
|
| 67 | + public function changePassword(Request $request) { |
|
| 68 | + if (!$request->has('old_password') || !$request->has('new_password') || !$request->has('confirm_password')) { |
|
| 69 | 69 | return ResponseModel::err(1003); |
| 70 | 70 | } |
| 71 | - $old_password = $request->input('old_password'); |
|
| 72 | - $new_password = $request->input('new_password'); |
|
| 73 | - $confirm_password = $request->input('confirm_password'); |
|
| 74 | - if($new_password != $confirm_password){ |
|
| 71 | + $old_password=$request->input('old_password'); |
|
| 72 | + $new_password=$request->input('new_password'); |
|
| 73 | + $confirm_password=$request->input('confirm_password'); |
|
| 74 | + if ($new_password!=$confirm_password) { |
|
| 75 | 75 | return ResponseModel::err(2004); |
| 76 | 76 | } |
| 77 | - if(strlen($new_password) < 8 || strlen($old_password) < 8){ |
|
| 77 | + if (strlen($new_password)<8 || strlen($old_password)<8) { |
|
| 78 | 78 | return ResponseModel::err(1006); |
| 79 | 79 | } |
| 80 | - $user = Auth::user(); |
|
| 81 | - if($user->hasIndependentPassword() && !Hash::check($old_password, $user->password)){ |
|
| 80 | + $user=Auth::user(); |
|
| 81 | + if ($user->hasIndependentPassword() && !Hash::check($old_password, $user->password)) { |
|
| 82 | 82 | return ResponseModel::err(2005); |
| 83 | 83 | } |
| 84 | - $user->password = Hash::make($new_password); |
|
| 84 | + $user->password=Hash::make($new_password); |
|
| 85 | 85 | $user->save(); |
| 86 | 86 | return ResponseModel::success(); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function checkEmailCooldown(Request $request){ |
|
| 90 | - $last_send = $request->session()->get('last_email_send'); |
|
| 91 | - if(empty($last_send) || time() - $last_send >= 300){ |
|
| 92 | - $request->session()->put('last_email_send',time()); |
|
| 93 | - return ResponseModel::success(200,null,0); |
|
| 94 | - }else{ |
|
| 95 | - $cooldown = 300 - (time() - $last_send); |
|
| 96 | - return ResponseModel::success(200,null,$cooldown); |
|
| 89 | + public function checkEmailCooldown(Request $request) { |
|
| 90 | + $last_send=$request->session()->get('last_email_send'); |
|
| 91 | + if (empty($last_send) || time()-$last_send>=300) { |
|
| 92 | + $request->session()->put('last_email_send', time()); |
|
| 93 | + return ResponseModel::success(200, null, 0); |
|
| 94 | + } else { |
|
| 95 | + $cooldown=300-(time()-$last_send); |
|
| 96 | + return ResponseModel::success(200, null, $cooldown); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function changeExtraInfo(Request $request){ |
|
| 101 | - $input = $request->input(); |
|
| 102 | - $allow_change = ['gender','contact','school','country','location']; |
|
| 103 | - foreach($input as $key => $value){ |
|
| 104 | - if(!in_array($key,$allow_change)){ |
|
| 100 | + public function changeExtraInfo(Request $request) { |
|
| 101 | + $input=$request->input(); |
|
| 102 | + $allow_change=['gender', 'contact', 'school', 'country', 'location']; |
|
| 103 | + foreach ($input as $key => $value) { |
|
| 104 | + if (!in_array($key, $allow_change)) { |
|
| 105 | 105 | return ResponseModel::error(1007); |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | foreach ($input as $key => $value) { |
| 109 | - if(strlen($value) != 0){ |
|
| 109 | + if (strlen($value)!=0) { |
|
| 110 | 110 | Auth::user()->setExtra($key, $value, 0); |
| 111 | - }else{ |
|
| 111 | + } else { |
|
| 112 | 112 | Auth::user()->setExtra($key, null); |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | return ResponseModel::success(); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function saveEditorWidth(Request $request){ |
|
| 119 | - $input = $request->input(); |
|
| 120 | - $allow_change = ['editor_left_width']; |
|
| 121 | - foreach($input as $key => $value){ |
|
| 122 | - if(!in_array($key,$allow_change)){ |
|
| 118 | + public function saveEditorWidth(Request $request) { |
|
| 119 | + $input=$request->input(); |
|
| 120 | + $allow_change=['editor_left_width']; |
|
| 121 | + foreach ($input as $key => $value) { |
|
| 122 | + if (!in_array($key, $allow_change)) { |
|
| 123 | 123 | return ResponseModel::error(1007); |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | foreach ($input as $key => $value) { |
| 127 | - if(strlen($value) != 0){ |
|
| 127 | + if (strlen($value)!=0) { |
|
| 128 | 128 | Auth::user()->setExtra($key, $value, 0); |
| 129 | - }else{ |
|
| 129 | + } else { |
|
| 130 | 130 | Auth::user()->setExtra($key, null); |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | return ResponseModel::success(); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function saveEditorTheme(Request $request){ |
|
| 137 | - $input = $request->input(); |
|
| 138 | - $allow_change = ['editor_theme']; |
|
| 139 | - foreach($input as $key => $value){ |
|
| 140 | - if(!in_array($key,$allow_change)){ |
|
| 136 | + public function saveEditorTheme(Request $request) { |
|
| 137 | + $input=$request->input(); |
|
| 138 | + $allow_change=['editor_theme']; |
|
| 139 | + foreach ($input as $key => $value) { |
|
| 140 | + if (!in_array($key, $allow_change)) { |
|
| 141 | 141 | return ResponseModel::error(1007); |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | foreach ($input as $key => $value) { |
| 145 | - if(strlen($value) != 0){ |
|
| 145 | + if (strlen($value)!=0) { |
|
| 146 | 146 | Auth::user()->setExtra($key, $value, 0); |
| 147 | - }else{ |
|
| 147 | + } else { |
|
| 148 | 148 | Auth::user()->setExtra($key, null); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | if(empty($last_send) || time() - $last_send >= 300){ |
| 92 | 92 | $request->session()->put('last_email_send',time()); |
| 93 | 93 | return ResponseModel::success(200,null,0); |
| 94 | - }else{ |
|
| 94 | + } else{ |
|
| 95 | 95 | $cooldown = 300 - (time() - $last_send); |
| 96 | 96 | return ResponseModel::success(200,null,$cooldown); |
| 97 | 97 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | foreach ($input as $key => $value) { |
| 109 | 109 | if(strlen($value) != 0){ |
| 110 | 110 | Auth::user()->setExtra($key, $value, 0); |
| 111 | - }else{ |
|
| 111 | + } else{ |
|
| 112 | 112 | Auth::user()->setExtra($key, null); |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | foreach ($input as $key => $value) { |
| 127 | 127 | if(strlen($value) != 0){ |
| 128 | 128 | Auth::user()->setExtra($key, $value, 0); |
| 129 | - }else{ |
|
| 129 | + } else{ |
|
| 130 | 130 | Auth::user()->setExtra($key, null); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | foreach ($input as $key => $value) { |
| 145 | 145 | if(strlen($value) != 0){ |
| 146 | 146 | Auth::user()->setExtra($key, $value, 0); |
| 147 | - }else{ |
|
| 147 | + } else{ |
|
| 148 | 148 | Auth::user()->setExtra($key, null); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $all_data=$request->all(); |
| 38 | 38 | |
| 39 | - if(($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)){ |
|
| 39 | + if (($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)) { |
|
| 40 | 40 | return ResponseModel::err(4007); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | return ResponseModel::err(1003); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $cid = $contestModel->arrangeContest($all_data["gid"], [ |
|
| 70 | + $cid=$contestModel->arrangeContest($all_data["gid"], [ |
|
| 71 | 71 | "assign_uid"=>Auth::user()->id, |
| 72 | 72 | "name"=>$all_data["name"], |
| 73 | 73 | "description"=>$all_data["description"], |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | "public"=>$all_data["public"] ?? 0, |
| 79 | 79 | ], $problemSet); |
| 80 | 80 | |
| 81 | - return ResponseModel::success(200,'Successful!',$cid); |
|
| 81 | + return ResponseModel::success(200, 'Successful!', $cid); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public function changeGroupName(Request $request) |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $groupModel=new GroupModel(); |
| 94 | 94 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 95 | - if ($clearance < 2){ |
|
| 95 | + if ($clearance<2) { |
|
| 96 | 96 | return ResponseModel::err(2001); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $groupModel=new GroupModel(); |
| 113 | 113 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 114 | - if ($clearance < 2){ |
|
| 114 | + if ($clearance<2) { |
|
| 115 | 115 | return ResponseModel::err(2001); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ($all_data["join_policy"] < 1 || $all_data["join_policy"] > 3){ |
|
| 118 | + if ($all_data["join_policy"]<1 || $all_data["join_policy"]>3) { |
|
| 119 | 119 | return ResponseModel::err(1007); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'gid' => 'required|integer', |
| 130 | 130 | ]); |
| 131 | 131 | |
| 132 | - $all_data = $request->all(); |
|
| 132 | + $all_data=$request->all(); |
|
| 133 | 133 | |
| 134 | 134 | if (!empty($request->file('img')) && $request->file('img')->isValid()) { |
| 135 | 135 | $extension=$request->file('img')->extension(); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $groupModel=new GroupModel(); |
| 143 | 143 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 144 | - if ($clearance < 2){ |
|
| 144 | + if ($clearance<2) { |
|
| 145 | 145 | return ResponseModel::err(2001); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 180 | 180 | $target_clearance=$groupModel->judgeClearance($all_data["gid"], $all_data['uid']); |
| 181 | 181 | |
| 182 | - if($target_clearance == -3){ |
|
| 182 | + if ($target_clearance==-3) { |
|
| 183 | 183 | return ResponseModel::err(7004); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if($target_clearance >= $clearance || $clearance < 2 || $all_data['permission'] >= $clearance){ |
|
| 186 | + if ($target_clearance>=$clearance || $clearance<2 || $all_data['permission']>=$clearance) { |
|
| 187 | 187 | return ResponseModel::err(2001); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $groupModel->changeClearance($all_data['uid'], $all_data["gid"], $all_data['permission']); |
| 191 | 191 | |
| 192 | - $result_info = $groupModel->userProfile($all_data['uid'],$all_data["gid"]); |
|
| 193 | - return ResponseModel::success(200,null,$result_info); |
|
| 192 | + $result_info=$groupModel->userProfile($all_data['uid'], $all_data["gid"]); |
|
| 193 | + return ResponseModel::success(200, null, $result_info); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | public function approveMember(Request $request) |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 207 | 207 | $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]); |
| 208 | 208 | if ($clearance>1) { |
| 209 | - if($targetClearance!=0) { |
|
| 209 | + if ($targetClearance!=0) { |
|
| 210 | 210 | return ResponseModel::err(7003); |
| 211 | 211 | } |
| 212 | 212 | $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $groupModel=new GroupModel(); |
| 228 | 228 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 229 | 229 | $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]); |
| 230 | - if ($clearance <= 1 || $clearance <= $targetClearance){ |
|
| 230 | + if ($clearance<=1 || $clearance<=$targetClearance) { |
|
| 231 | 231 | return ResponseModel::err(7002); |
| 232 | 232 | } |
| 233 | 233 | |
@@ -247,16 +247,16 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | $groupModel=new GroupModel(); |
| 249 | 249 | $is_user=$groupModel->isUser($all_data["email"]); |
| 250 | - if(!$is_user) return ResponseModel::err(2006); |
|
| 250 | + if (!$is_user) return ResponseModel::err(2006); |
|
| 251 | 251 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 252 | - if($clearance<2) return ResponseModel::err(7002); |
|
| 252 | + if ($clearance<2) return ResponseModel::err(7002); |
|
| 253 | 253 | $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]); |
| 254 | - if($targetClearance!=-3) return ResponseModel::err(7003); |
|
| 254 | + if ($targetClearance!=-3) return ResponseModel::err(7003); |
|
| 255 | 255 | $groupModel->inviteMember($all_data["gid"], $all_data["email"]); |
| 256 | - $basic = $groupModel->basic($all_data['gid']); |
|
| 257 | - $url = route('group.detail',['gcode' => $basic['gcode']]); |
|
| 258 | - $receiverInfo = User::where('email',$all_data['email'])->first(); |
|
| 259 | - $sender_name = Auth::user()->name; |
|
| 256 | + $basic=$groupModel->basic($all_data['gid']); |
|
| 257 | + $url=route('group.detail', ['gcode' => $basic['gcode']]); |
|
| 258 | + $receiverInfo=User::where('email', $all_data['email'])->first(); |
|
| 259 | + $sender_name=Auth::user()->name; |
|
| 260 | 260 | sendMessage([ |
| 261 | 261 | 'receiver' => $receiverInfo["id"], |
| 262 | 262 | 'sender' => Auth::user()->id, |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | $groupModel=new GroupModel(); |
| 300 | 300 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 301 | - if ($clearance < 2){ |
|
| 301 | + if ($clearance<2) { |
|
| 302 | 302 | return ResponseModel::err(2001); |
| 303 | 303 | } |
| 304 | 304 | $groupModel->createNotice($all_data["gid"], Auth::user()->id, $all_data["title"], $all_data["content"]); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function settings($gcode) |
| 23 | 23 | { |
| 24 | - return Redirect::route('group.settings.general', ['gcode' => $gcode]);; |
|
| 24 | + return Redirect::route('group.settings.general', ['gcode' => $gcode]); ; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function settingsReturn($gcode) |
| 33 | 33 | { |
| 34 | - return Redirect::route('group.detail', ['gcode' => $gcode]);; |
|
| 34 | + return Redirect::route('group.detail', ['gcode' => $gcode]); ; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return Response |
| 62 | 62 | */ |
| 63 | - public function problems($gcode){ |
|
| 64 | - $groupModel = new GroupModel(); |
|
| 65 | - $group_info = $groupModel->details($gcode); |
|
| 66 | - $problems = $groupModel->problems($group_info['gid']); |
|
| 63 | + public function problems($gcode) { |
|
| 64 | + $groupModel=new GroupModel(); |
|
| 65 | + $group_info=$groupModel->details($gcode); |
|
| 66 | + $problems=$groupModel->problems($group_info['gid']); |
|
| 67 | 67 | $basic_info=$groupModel->details($gcode); |
| 68 | 68 | return view('group.settings.problems', [ |
| 69 | 69 | 'page_title'=>"Group Problems", |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $member_list=$groupModel->userList($basic_info["gid"]); |
| 106 | 106 | $group_notice=$groupModel->detailNotice($gcode); |
| 107 | 107 | // PHP 7.4 Fix |
| 108 | - if(is_null($group_notice)){ |
|
| 108 | + if (is_null($group_notice)) { |
|
| 109 | 109 | $group_notice=[ |
| 110 | 110 | 'content'=>null, |
| 111 | 111 | 'title'=>null, |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $group_notice=$groupModel->groupNotice($basic_info["gid"]); |
| 50 | 50 | // PHP 7.4 Fix |
| 51 | 51 | $groupContest=$contestModel->listByGroup($basic_info["gid"]); |
| 52 | - if(is_null($groupContest)){ |
|
| 52 | + if (is_null($groupContest)) { |
|
| 53 | 53 | $contest_list=null; |
| 54 | 54 | $paginator=null; |
| 55 | 55 | } else { |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return Response |
| 94 | 94 | */ |
| 95 | - public function analysis($gcode){ |
|
| 96 | - $groupModel = new GroupModel(); |
|
| 95 | + public function analysis($gcode) { |
|
| 96 | + $groupModel=new GroupModel(); |
|
| 97 | 97 | $basic_info=$groupModel->details($gcode); |
| 98 | 98 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
| 99 | - if($clearance < 1) return Redirect::route('group.detail',['gcode' => $gcode]); |
|
| 100 | - $group_info = $groupModel->details($gcode); |
|
| 99 | + if ($clearance<1) return Redirect::route('group.detail', ['gcode' => $gcode]); |
|
| 100 | + $group_info=$groupModel->details($gcode); |
|
| 101 | 101 | return view('group.settings.analysis', [ |
| 102 | 102 | 'page_title'=>"Group Analysis", |
| 103 | 103 | 'site_title'=>"NOJ", |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | ]); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function analysisDownload($gcode,Request $request){ |
|
| 111 | - $all_data = $request->all(); |
|
| 112 | - $groupModel = new GroupModel(); |
|
| 113 | - $group_info = $groupModel->details($gcode); |
|
| 114 | - $mode = $all_data['mode'] ?? 'contest'; |
|
| 115 | - if($mode == 'contest'){ |
|
| 116 | - $data = $groupModel->groupMemberPracticeContestStat($group_info['gid']); |
|
| 110 | + public function analysisDownload($gcode, Request $request) { |
|
| 111 | + $all_data=$request->all(); |
|
| 112 | + $groupModel=new GroupModel(); |
|
| 113 | + $group_info=$groupModel->details($gcode); |
|
| 114 | + $mode=$all_data['mode'] ?? 'contest'; |
|
| 115 | + if ($mode=='contest') { |
|
| 116 | + $data=$groupModel->groupMemberPracticeContestStat($group_info['gid']); |
|
| 117 | 117 | return Excel::download( |
| 118 | 118 | new GroupAnalysisExport( |
| 119 | 119 | [ |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | 'percent' => $all_data['percent'] ?? false, |
| 127 | 127 | ] |
| 128 | 128 | ), |
| 129 | - $gcode . '_Group_Contest_Analysis.xlsx' |
|
| 129 | + $gcode.'_Group_Contest_Analysis.xlsx' |
|
| 130 | 130 | ); |
| 131 | - }else{ |
|
| 132 | - $data = $groupModel->groupMemberPracticeTagStat($group_info['gid']); |
|
| 131 | + } else { |
|
| 132 | + $data=$groupModel->groupMemberPracticeTagStat($group_info['gid']); |
|
| 133 | 133 | return Excel::download( |
| 134 | 134 | new GroupAnalysisExport( |
| 135 | 135 | [ |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | 'percent' => $all_data['percent'] ?? false, |
| 143 | 143 | ] |
| 144 | 144 | ), |
| 145 | - $gcode . '_Group_Tag_Analysis.xlsx' |
|
| 145 | + $gcode.'_Group_Tag_Analysis.xlsx' |
|
| 146 | 146 | ); |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | public function redirectTo() |
| 21 | 21 | { |
| 22 | 22 | // 2 ways to access this page, you want to bind(logined), you want to login(not logined) |
| 23 | - if(Auth::check()){ |
|
| 23 | + if (Auth::check()) { |
|
| 24 | 24 | // logined user, only users with non-temp email & pass access and binded can unbind |
| 25 | - if(!Auth::user()->isIndependent()){ |
|
| 25 | + if (!Auth::user()->isIndependent()) { |
|
| 26 | 26 | return redirect()->route('account.settings'); |
| 27 | 27 | } |
| 28 | - if(Auth::user()->getExtra('github_id')){ |
|
| 28 | + if (Auth::user()->getExtra('github_id')) { |
|
| 29 | 29 | return $this->generateOperationView(Auth::user()->getExtra('github_email')); |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function handleCallback() |
| 36 | 36 | { |
| 37 | - try{ |
|
| 38 | - $github_user = Socialite::driver('github')->user(); |
|
| 39 | - }catch(\Laravel\Socialite\Two\InvalidStateException $e){ |
|
| 37 | + try { |
|
| 38 | + $github_user=Socialite::driver('github')->user(); |
|
| 39 | + } catch (\Laravel\Socialite\Two\InvalidStateException $e) { |
|
| 40 | 40 | return redirect()->route('home'); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if(Auth::check()){ |
|
| 44 | - $user_id = Auth::user()->id; |
|
| 45 | - $ret = UserExtra::search('github_id', $github_user->id); |
|
| 46 | - if(!empty($ret) && $ret[0]['uid'] != $user_id){ |
|
| 47 | - $user = User::find($ret[0]['uid']); |
|
| 43 | + if (Auth::check()) { |
|
| 44 | + $user_id=Auth::user()->id; |
|
| 45 | + $ret=UserExtra::search('github_id', $github_user->id); |
|
| 46 | + if (!empty($ret) && $ret[0]['uid']!=$user_id) { |
|
| 47 | + $user=User::find($ret[0]['uid']); |
|
| 48 | 48 | return $this->generateDuplicateView($user->email); |
| 49 | 49 | } |
| 50 | 50 | Auth::user()->setExtra('github_id', $github_user->id); |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | Auth::user()->setExtra('github_homepage', ($github_user->user)['html_url']); |
| 54 | 54 | Auth::user()->setExtra('github_token', $github_user->token, 101); |
| 55 | 55 | return $this->generateSuccessView(Auth::user()->getExtra('github_email')); |
| 56 | - }else{ |
|
| 57 | - $ret = UserExtra::search('github_id', $github_user->id); |
|
| 58 | - if(!empty($ret)){ |
|
| 56 | + } else { |
|
| 57 | + $ret=UserExtra::search('github_id', $github_user->id); |
|
| 58 | + if (!empty($ret)) { |
|
| 59 | 59 | Auth::loginUsingId($ret[0]['uid'], true); |
| 60 | 60 | Auth::user()->setExtra('github_email', $github_user->email); |
| 61 | 61 | Auth::user()->setExtra('github_nickname', $github_user->nickname); |
| 62 | 62 | Auth::user()->setExtra('github_homepage', ($github_user->user)['html_url']); |
| 63 | 63 | Auth::user()->setExtra('github_token', $github_user->token, 101); |
| 64 | 64 | return redirect()->route('account.dashboard'); |
| 65 | - }else{ |
|
| 66 | - if(config('app.allow_oauth_temp_account')){ |
|
| 65 | + } else { |
|
| 66 | + if (config('app.allow_oauth_temp_account')) { |
|
| 67 | 67 | try { |
| 68 | 68 | $createdUser=User::create([ |
| 69 | 69 | 'name' => Str::random(12), |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | 'password' => '', |
| 72 | 72 | 'avatar' => '/static/img/avatar/default.png', |
| 73 | 73 | ]); |
| 74 | - }catch(QueryException $exception){ |
|
| 74 | + } catch (QueryException $exception) { |
|
| 75 | 75 | return $this->generateUnknownErrorView(); |
| 76 | 76 | } |
| 77 | 77 | Auth::loginUsingId($createdUser->id, true); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | 'text' => 'login', |
| 87 | 87 | 'href' => route('login'), |
| 88 | 88 | ]]; |
| 89 | - if(config('function.register')){ |
|
| 89 | + if (config('function.register')) { |
|
| 90 | 90 | $buttons[]=[ |
| 91 | 91 | 'text' => 'register', |
| 92 | 92 | 'href' => route('register'), |
@@ -99,29 +99,29 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public function unbind() |
| 101 | 101 | { |
| 102 | - if(!Auth::check()){ |
|
| 102 | + if (!Auth::check()) { |
|
| 103 | 103 | return redirect()->route('home'); |
| 104 | 104 | } |
| 105 | - if(Auth::user()->getExtra('github_id')){ |
|
| 105 | + if (Auth::user()->getExtra('github_id')) { |
|
| 106 | 106 | return $this->generateUnbindConfirmView(Auth::user()->email, Auth::user()->getExtra('github_email')); |
| 107 | - }else{ |
|
| 107 | + } else { |
|
| 108 | 108 | return $this->generateAlreadyUnbindView(); |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | public function confirmUnbind() |
| 113 | 113 | { |
| 114 | - if(!Auth::check()){ |
|
| 114 | + if (!Auth::check()) { |
|
| 115 | 115 | return redirect()->route('home'); |
| 116 | 116 | } |
| 117 | - if(Auth::user()->getExtra('github_id')){ |
|
| 117 | + if (Auth::user()->getExtra('github_id')) { |
|
| 118 | 118 | Auth::user()->setExtra('github_id', null); |
| 119 | 119 | Auth::user()->setExtra('github_email', null); |
| 120 | 120 | Auth::user()->setExtra('github_nickname', null); |
| 121 | 121 | Auth::user()->setExtra('github_homepage', null); |
| 122 | 122 | Auth::user()->setExtra('github_token', null); |
| 123 | 123 | return $this->generateUnbindSuccessView(); |
| 124 | - }else{ |
|
| 124 | + } else { |
|
| 125 | 125 | return $this->generateAlreadyUnbindView(); |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | try{ |
| 38 | 38 | $github_user = Socialite::driver('github')->user(); |
| 39 | - }catch(\Laravel\Socialite\Two\InvalidStateException $e){ |
|
| 39 | + } catch(\Laravel\Socialite\Two\InvalidStateException $e){ |
|
| 40 | 40 | return redirect()->route('home'); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | Auth::user()->setExtra('github_homepage', ($github_user->user)['html_url']); |
| 54 | 54 | Auth::user()->setExtra('github_token', $github_user->token, 101); |
| 55 | 55 | return $this->generateSuccessView(Auth::user()->getExtra('github_email')); |
| 56 | - }else{ |
|
| 56 | + } else{ |
|
| 57 | 57 | $ret = UserExtra::search('github_id', $github_user->id); |
| 58 | 58 | if(!empty($ret)){ |
| 59 | 59 | Auth::loginUsingId($ret[0]['uid'], true); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | Auth::user()->setExtra('github_homepage', ($github_user->user)['html_url']); |
| 63 | 63 | Auth::user()->setExtra('github_token', $github_user->token, 101); |
| 64 | 64 | return redirect()->route('account.dashboard'); |
| 65 | - }else{ |
|
| 65 | + } else{ |
|
| 66 | 66 | if(config('app.allow_oauth_temp_account')){ |
| 67 | 67 | try { |
| 68 | 68 | $createdUser=User::create([ |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | 'password' => '', |
| 72 | 72 | 'avatar' => '/static/img/avatar/default.png', |
| 73 | 73 | ]); |
| 74 | - }catch(QueryException $exception){ |
|
| 74 | + } catch(QueryException $exception){ |
|
| 75 | 75 | return $this->generateUnknownErrorView(); |
| 76 | 76 | } |
| 77 | 77 | Auth::loginUsingId($createdUser->id, true); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | if(Auth::user()->getExtra('github_id')){ |
| 106 | 106 | return $this->generateUnbindConfirmView(Auth::user()->email, Auth::user()->getExtra('github_email')); |
| 107 | - }else{ |
|
| 107 | + } else{ |
|
| 108 | 108 | return $this->generateAlreadyUnbindView(); |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | Auth::user()->setExtra('github_homepage', null); |
| 122 | 122 | Auth::user()->setExtra('github_token', null); |
| 123 | 123 | return $this->generateUnbindSuccessView(); |
| 124 | - }else{ |
|
| 124 | + } else{ |
|
| 125 | 125 | return $this->generateAlreadyUnbindView(); |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | public function redirectTo() |
| 24 | 24 | { |
| 25 | 25 | // 2 ways to access this page, you want to bind(logined), you want to login(not logined) |
| 26 | - if(Auth::check()){ |
|
| 26 | + if (Auth::check()) { |
|
| 27 | 27 | // logined user, only users with non-temp email & pass access and binded can unbind |
| 28 | - if(!Auth::user()->isIndependent()){ |
|
| 28 | + if (!Auth::user()->isIndependent()) { |
|
| 29 | 29 | return redirect()->route('account.settings'); |
| 30 | 30 | } |
| 31 | - if(Auth::user()->getExtra('aauth_id')){ |
|
| 31 | + if (Auth::user()->getExtra('aauth_id')) { |
|
| 32 | 32 | return $this->generateOperationView(Auth::user()->getExtra('aauth_nickname')); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | private function user($code) |
| 39 | 39 | { |
| 40 | - $response = Requests::post('https://cn.api.aauth.link/auth/',[], json_encode([ |
|
| 40 | + $response=Requests::post('https://cn.api.aauth.link/auth/', [], json_encode([ |
|
| 41 | 41 | 'code' => $code, |
| 42 | 42 | 'app' => config('services.aauth.client_id'), |
| 43 | 43 | 'secret' => config('services.aauth.client_secret') |
| 44 | 44 | ])); |
| 45 | - if(!$response->success){ |
|
| 45 | + if (!$response->success) { |
|
| 46 | 46 | throw new Exception('Requesting Error'); |
| 47 | 47 | } |
| 48 | - $user = json_decode($response->body); |
|
| 49 | - if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 48 | + $user=json_decode($response->body); |
|
| 49 | + if (json_last_error()!==JSON_ERROR_NONE) { |
|
| 50 | 50 | throw new Exception('JSON Error'); |
| 51 | 51 | } |
| 52 | 52 | return $user; |
@@ -54,30 +54,30 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function handleCallback() |
| 56 | 56 | { |
| 57 | - try{ |
|
| 58 | - $aauth_user = $this->user(request()->code); |
|
| 59 | - }catch(Throwable $e){ |
|
| 57 | + try { |
|
| 58 | + $aauth_user=$this->user(request()->code); |
|
| 59 | + } catch (Throwable $e) { |
|
| 60 | 60 | return redirect()->route('home'); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if(Auth::check()){ |
|
| 64 | - $user_id = Auth::user()->id; |
|
| 65 | - $ret = UserExtra::search('aauth_id', $aauth_user->id); |
|
| 66 | - if(!empty($ret) && $ret[0]['uid'] != $user_id){ |
|
| 67 | - $user = User::find($ret[0]['uid']); |
|
| 63 | + if (Auth::check()) { |
|
| 64 | + $user_id=Auth::user()->id; |
|
| 65 | + $ret=UserExtra::search('aauth_id', $aauth_user->id); |
|
| 66 | + if (!empty($ret) && $ret[0]['uid']!=$user_id) { |
|
| 67 | + $user=User::find($ret[0]['uid']); |
|
| 68 | 68 | return $this->generateDuplicateView($user->email); |
| 69 | 69 | } |
| 70 | 70 | Auth::user()->setExtra('aauth_id', $aauth_user->id); |
| 71 | 71 | Auth::user()->setExtra('aauth_nickname', $aauth_user->name); |
| 72 | 72 | return $this->generateSuccessView(Auth::user()->getExtra('aauth_nickname')); |
| 73 | - }else{ |
|
| 74 | - $ret = UserExtra::search('aauth_id', $aauth_user->id); |
|
| 75 | - if(!empty($ret)){ |
|
| 73 | + } else { |
|
| 74 | + $ret=UserExtra::search('aauth_id', $aauth_user->id); |
|
| 75 | + if (!empty($ret)) { |
|
| 76 | 76 | Auth::loginUsingId($ret[0]['uid'], true); |
| 77 | 77 | Auth::user()->setExtra('aauth_nickname', $aauth_user->name); |
| 78 | 78 | return redirect()->route('account.dashboard'); |
| 79 | - }else{ |
|
| 80 | - if(config('app.allow_oauth_temp_account')){ |
|
| 79 | + } else { |
|
| 80 | + if (config('app.allow_oauth_temp_account')) { |
|
| 81 | 81 | try { |
| 82 | 82 | $createdUser=User::create([ |
| 83 | 83 | 'name' => Str::random(12), |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | 'password' => '', |
| 86 | 86 | 'avatar' => '/static/img/avatar/default.png', |
| 87 | 87 | ]); |
| 88 | - }catch(QueryException $exception){ |
|
| 88 | + } catch (QueryException $exception) { |
|
| 89 | 89 | return $this->generateUnknownErrorView(); |
| 90 | 90 | } |
| 91 | 91 | Auth::loginUsingId($createdUser->id, true); |
@@ -100,26 +100,26 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | public function unbind() |
| 102 | 102 | { |
| 103 | - if(!Auth::check()){ |
|
| 103 | + if (!Auth::check()) { |
|
| 104 | 104 | return redirect()->route('home'); |
| 105 | 105 | } |
| 106 | - if(Auth::user()->getExtra('aauth_id')){ |
|
| 106 | + if (Auth::user()->getExtra('aauth_id')) { |
|
| 107 | 107 | return $this->generateUnbindConfirmView(Auth::user()->email, Auth::user()->getExtra('aauth_nickname')); |
| 108 | - }else{ |
|
| 108 | + } else { |
|
| 109 | 109 | return $this->generateAlreadyUnbindView(); |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function confirmUnbind() |
| 114 | 114 | { |
| 115 | - if(!Auth::check()){ |
|
| 115 | + if (!Auth::check()) { |
|
| 116 | 116 | return redirect()->route('home'); |
| 117 | 117 | } |
| 118 | - if(Auth::user()->getExtra('aauth_id')){ |
|
| 118 | + if (Auth::user()->getExtra('aauth_id')) { |
|
| 119 | 119 | Auth::user()->setExtra('aauth_id', null); |
| 120 | 120 | Auth::user()->setExtra('aauth_nickname', null); |
| 121 | 121 | return $this->generateUnbindSuccessView(); |
| 122 | - }else{ |
|
| 122 | + } else { |
|
| 123 | 123 | return $this->generateAlreadyUnbindView(); |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | try{ |
| 58 | 58 | $aauth_user = $this->user(request()->code); |
| 59 | - }catch(Throwable $e){ |
|
| 59 | + } catch(Throwable $e){ |
|
| 60 | 60 | return redirect()->route('home'); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | Auth::user()->setExtra('aauth_id', $aauth_user->id); |
| 71 | 71 | Auth::user()->setExtra('aauth_nickname', $aauth_user->name); |
| 72 | 72 | return $this->generateSuccessView(Auth::user()->getExtra('aauth_nickname')); |
| 73 | - }else{ |
|
| 73 | + } else{ |
|
| 74 | 74 | $ret = UserExtra::search('aauth_id', $aauth_user->id); |
| 75 | 75 | if(!empty($ret)){ |
| 76 | 76 | Auth::loginUsingId($ret[0]['uid'], true); |
| 77 | 77 | Auth::user()->setExtra('aauth_nickname', $aauth_user->name); |
| 78 | 78 | return redirect()->route('account.dashboard'); |
| 79 | - }else{ |
|
| 79 | + } else{ |
|
| 80 | 80 | if(config('app.allow_oauth_temp_account')){ |
| 81 | 81 | try { |
| 82 | 82 | $createdUser=User::create([ |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | 'password' => '', |
| 86 | 86 | 'avatar' => '/static/img/avatar/default.png', |
| 87 | 87 | ]); |
| 88 | - }catch(QueryException $exception){ |
|
| 88 | + } catch(QueryException $exception){ |
|
| 89 | 89 | return $this->generateUnknownErrorView(); |
| 90 | 90 | } |
| 91 | 91 | Auth::loginUsingId($createdUser->id, true); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | if(Auth::user()->getExtra('aauth_id')){ |
| 107 | 107 | return $this->generateUnbindConfirmView(Auth::user()->email, Auth::user()->getExtra('aauth_nickname')); |
| 108 | - }else{ |
|
| 108 | + } else{ |
|
| 109 | 109 | return $this->generateAlreadyUnbindView(); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | Auth::user()->setExtra('aauth_id', null); |
| 120 | 120 | Auth::user()->setExtra('aauth_nickname', null); |
| 121 | 121 | return $this->generateUnbindSuccessView(); |
| 122 | - }else{ |
|
| 122 | + } else{ |
|
| 123 | 123 | return $this->generateAlreadyUnbindView(); |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | protected $platformName; |
| 10 | 10 | protected $platformID; |
| 11 | 11 | |
| 12 | - private function generateView($config){ |
|
| 12 | + private function generateView($config) { |
|
| 13 | 13 | $config+=[ |
| 14 | 14 | 'page_title' => __("oauth.title.platform", ['platform' => $this->platformName]), |
| 15 | 15 | 'site_title' => config("app.name"), |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | return view('oauth.index', $config); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - protected function generateOperationView($OAuthAccount){ |
|
| 22 | + protected function generateOperationView($OAuthAccount) { |
|
| 23 | 23 | return $this->generateView([ |
| 24 | 24 | 'display_html' => __("oauth.operation", ['platform' => $this->platformName, 'oauthaccount' => $OAuthAccount]), |
| 25 | 25 | 'buttons' => [ |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | ]); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - protected function generateDuplicateView($NOJAccount){ |
|
| 39 | + protected function generateDuplicateView($NOJAccount) { |
|
| 40 | 40 | return $this->generateView([ |
| 41 | - 'display_html' => __("oauth.duplicate", [ 'platform' => $this->platformName, 'appname' => config("app.name"), 'nojaccount' => $NOJAccount ]), |
|
| 41 | + 'display_html' => __("oauth.duplicate", ['platform' => $this->platformName, 'appname' => config("app.name"), 'nojaccount' => $NOJAccount]), |
|
| 42 | 42 | 'buttons' => [ |
| 43 | 43 | [ |
| 44 | 44 | 'text' => __("oauth.action.home"), |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | ]); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function generateSuccessView($OAuthAccount){ |
|
| 51 | + protected function generateSuccessView($OAuthAccount) { |
|
| 52 | 52 | return $this->generateView([ |
| 53 | - 'display_html' => __("oauth.success", [ 'platform' => $this->platformName, 'appname' => config("app.name"), 'oauthaccount' => $OAuthAccount ]), |
|
| 53 | + 'display_html' => __("oauth.success", ['platform' => $this->platformName, 'appname' => config("app.name"), 'oauthaccount' => $OAuthAccount]), |
|
| 54 | 54 | 'buttons' => [ |
| 55 | 55 | [ |
| 56 | 56 | 'text' => __("oauth.action.home"), |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | ]); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - protected function generateUnknownErrorView(){ |
|
| 63 | + protected function generateUnknownErrorView() { |
|
| 64 | 64 | return $this->generateView([ |
| 65 | 65 | 'display_text' => __("oauth.action.unknownerror"), |
| 66 | 66 | 'buttons' => [ |
@@ -72,26 +72,26 @@ discard block |
||
| 72 | 72 | ]); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - protected function generateAccountNotFoundView(){ |
|
| 75 | + protected function generateAccountNotFoundView() { |
|
| 76 | 76 | $buttons=[[ |
| 77 | 77 | 'text' => __("oauth.action.login"), |
| 78 | 78 | 'href' => route('login'), |
| 79 | 79 | ]]; |
| 80 | - if(config('function.register')){ |
|
| 80 | + if (config('function.register')) { |
|
| 81 | 81 | $buttons[]=[ |
| 82 | 82 | 'text' => __("oauth.action.register"), |
| 83 | 83 | 'href' => route('register'), |
| 84 | 84 | ]; |
| 85 | 85 | } |
| 86 | 86 | return $this->generateView([ |
| 87 | - 'display_text' => __("oauth.accountnotfound", [ 'platform' => $this->platformName, 'appname' => config("app.name") ]), |
|
| 87 | + 'display_text' => __("oauth.accountnotfound", ['platform' => $this->platformName, 'appname' => config("app.name")]), |
|
| 88 | 88 | 'buttons' => $buttons |
| 89 | 89 | ]); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - protected function generateUnbindConfirmView($NOJAccount, $OAuthAccount){ |
|
| 92 | + protected function generateUnbindConfirmView($NOJAccount, $OAuthAccount) { |
|
| 93 | 93 | return $this->generateView([ |
| 94 | - 'display_html' => __("oauth.unbindconfirm", [ 'platform' => $this->platformName, 'appname' => config("app.name"), 'oauthaccount' => $OAuthAccount, 'nojaccount' => $NOJAccount ]), |
|
| 94 | + 'display_html' => __("oauth.unbindconfirm", ['platform' => $this->platformName, 'appname' => config("app.name"), 'oauthaccount' => $OAuthAccount, 'nojaccount' => $NOJAccount]), |
|
| 95 | 95 | 'buttons' => [ |
| 96 | 96 | [ |
| 97 | 97 | 'text' => __("oauth.action.confirm"), |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | ]); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - protected function generateAlreadyUnbindView(){ |
|
| 109 | + protected function generateAlreadyUnbindView() { |
|
| 110 | 110 | return $this->generateView([ |
| 111 | - 'display_html' => __("oauth.alreadyunbind", [ 'platform' => $this->platformName ]), |
|
| 111 | + 'display_html' => __("oauth.alreadyunbind", ['platform' => $this->platformName]), |
|
| 112 | 112 | 'buttons' => [ |
| 113 | 113 | [ |
| 114 | 114 | 'text' => __("oauth.action.home"), |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | ]); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - protected function generateUnbindSuccessView(){ |
|
| 121 | + protected function generateUnbindSuccessView() { |
|
| 122 | 122 | return $this->generateView([ |
| 123 | - 'display_html' => __("oauth.unbindsuccess", [ 'platform' => $this->platformName, 'appname' => config("app.name") ]), |
|
| 123 | + 'display_html' => __("oauth.unbindsuccess", ['platform' => $this->platformName, 'appname' => config("app.name")]), |
|
| 124 | 124 | 'buttons' => [ |
| 125 | 125 | [ |
| 126 | 126 | 'text' => __("oauth.action.home"), |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $contestModel=new ContestModel(); |
| 28 | 28 | $verified=$contestModel->isVerified($cid); |
| 29 | 29 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
| 30 | - if ($clearance <= 2) { |
|
| 30 | + if ($clearance<=2) { |
|
| 31 | 31 | return Redirect::route('contest.detail', ['cid' => $cid]); |
| 32 | 32 | } |
| 33 | 33 | $contest_name=$contestModel->contestName($cid); |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | $basicInfo=$contestModel->basic($cid); |
| 37 | 37 | $contest_accounts=$accountModel->getContestAccount($cid); |
| 38 | 38 | $gcode=$contestModel->gcode($cid); |
| 39 | - $isEnd = $contestModel->remainingTime($cid) < 0; |
|
| 40 | - $generatePDFStatus = JobStatus::find(Cache::tags(['contest', 'admin', 'PDFGenerate'])->get($cid, 0)); |
|
| 41 | - $generatePDFStatus = is_null($generatePDFStatus)?'empty':$generatePDFStatus->status; |
|
| 42 | - if(in_array($generatePDFStatus,['finished','failed'])){ |
|
| 39 | + $isEnd=$contestModel->remainingTime($cid)<0; |
|
| 40 | + $generatePDFStatus=JobStatus::find(Cache::tags(['contest', 'admin', 'PDFGenerate'])->get($cid, 0)); |
|
| 41 | + $generatePDFStatus=is_null($generatePDFStatus) ? 'empty' : $generatePDFStatus->status; |
|
| 42 | + if (in_array($generatePDFStatus, ['finished', 'failed'])) { |
|
| 43 | 43 | Cache::tags(['contest', 'admin', 'PDFGenerate'])->forget($cid); |
| 44 | 44 | } |
| 45 | - $anticheatStatus = JobStatus::find(Cache::tags(['contest', 'admin', 'anticheat'])->get($cid, 0)); |
|
| 46 | - $anticheatProgress = is_null($anticheatStatus)?0:$anticheatStatus->progress_percentage; |
|
| 47 | - $anticheatStatus = is_null($anticheatStatus)?'empty':$anticheatStatus->status; |
|
| 48 | - if(Storage::disk('local')->exists("contest/anticheat/$cid/report/report.zip")) { |
|
| 45 | + $anticheatStatus=JobStatus::find(Cache::tags(['contest', 'admin', 'anticheat'])->get($cid, 0)); |
|
| 46 | + $anticheatProgress=is_null($anticheatStatus) ? 0 : $anticheatStatus->progress_percentage; |
|
| 47 | + $anticheatStatus=is_null($anticheatStatus) ? 'empty' : $anticheatStatus->status; |
|
| 48 | + if (Storage::disk('local')->exists("contest/anticheat/$cid/report/report.zip")) { |
|
| 49 | 49 | $anticheatStatus='finished'; |
| 50 | 50 | $anticheatProgress=100; |
| 51 | 51 | } |
| 52 | - if(in_array($anticheatStatus, ['finished','failed'])){ |
|
| 52 | + if (in_array($anticheatStatus, ['finished', 'failed'])) { |
|
| 53 | 53 | Cache::tags(['contest', 'admin', 'anticheat'])->forget($cid); |
| 54 | 54 | } |
| 55 | 55 | return view('contest.board.admin', [ |
@@ -77,51 +77,51 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $contestModel=new ContestModel(); |
| 79 | 79 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
| 80 | - if ($clearance <= 2) { |
|
| 80 | + if ($clearance<=2) { |
|
| 81 | 81 | return Redirect::route('contest.detail', ['cid' => $cid]); |
| 82 | 82 | } |
| 83 | 83 | $account=$contestModel->getContestAccount($cid); |
| 84 | - if($account==null){ |
|
| 85 | - return ; |
|
| 86 | - }else{ |
|
| 84 | + if ($account==null) { |
|
| 85 | + return; |
|
| 86 | + } else { |
|
| 87 | 87 | $AccountExport=new AccountExport($account); |
| 88 | 88 | $filename="ContestAccount$cid"; |
| 89 | 89 | return Excel::download($AccountExport, $filename.'.xlsx'); |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function refreshContestRank($cid){ |
|
| 93 | + public function refreshContestRank($cid) { |
|
| 94 | 94 | $contestModel=new ContestModel(); |
| 95 | 95 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
| 96 | - if ($clearance <= 2) { |
|
| 96 | + if ($clearance<=2) { |
|
| 97 | 97 | return Redirect::route('contest.detail', ['cid' => $cid]); |
| 98 | 98 | } |
| 99 | - $contest_eloquent = EloquentContestModel::find($cid); |
|
| 99 | + $contest_eloquent=EloquentContestModel::find($cid); |
|
| 100 | 100 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
| 101 | 101 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
| 102 | 102 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
| 103 | 103 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 104 | - if(time() > strtotime($end_time)){ |
|
| 104 | + if (time()>strtotime($end_time)) { |
|
| 105 | 105 | $contestModel->storeContestRankInMySQL($cid, $contestRankRaw); |
| 106 | 106 | } |
| 107 | 107 | $contestModel->deleteZip("contestCodeZip/$cid/"); |
| 108 | 108 | return Redirect::route('contest.board.rank', ['cid' => $cid]); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function scrollBoard($cid){ |
|
| 111 | + public function scrollBoard($cid) { |
|
| 112 | 112 | $contestModel=new ContestModel(); |
| 113 | 113 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
| 114 | - if ($clearance <= 2) { |
|
| 114 | + if ($clearance<=2) { |
|
| 115 | 115 | return Redirect::route('contest.detail', ['cid' => $cid]); |
| 116 | 116 | } |
| 117 | 117 | $basicInfo=$contestModel->basic($cid); |
| 118 | - if($basicInfo['froze_length'] == 0){ |
|
| 118 | + if ($basicInfo['froze_length']==0) { |
|
| 119 | 119 | return Redirect::route('contest.board.admin', ['cid' => $cid]); |
| 120 | 120 | } |
| 121 | - if($basicInfo['registration'] == 0){ |
|
| 121 | + if ($basicInfo['registration']==0) { |
|
| 122 | 122 | return Redirect::route('contest.board.admin', ['cid' => $cid]); |
| 123 | 123 | } |
| 124 | - if($basicInfo['rule'] != 1){ |
|
| 124 | + if ($basicInfo['rule']!=1) { |
|
| 125 | 125 | return Redirect::route('contest.board.admin', ['cid' => $cid]); |
| 126 | 126 | } |
| 127 | 127 | return view('contest.board.scrollBoard', [ |