Completed
Push — master ( e6516a...3fa133 )
by John
17s queued 10s
created
app/Http/Controllers/OAuth/GithubController.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function redirectTo()
15 15
     {
16
-        $accountModel = new AccountModel();
17
-        if(Auth::check() && $accountModel->getExtra(Auth::user()->id ,'github_id')){
18
-            return view('oauth.index',[
16
+        $accountModel=new AccountModel();
17
+        if (Auth::check() && $accountModel->getExtra(Auth::user()->id, 'github_id')) {
18
+            return view('oauth.index', [
19 19
                 'page_title'=>"OAuth",
20 20
                 'site_title'=>config("app.name"),
21 21
                 'navigation'=>"OAuth",
22 22
                 'platform' => 'Github',
23
-                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
23
+                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
24 24
                 You can choose to unbind or go back to the homepage',
25 25
                 'buttons' => [
26 26
                     [
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function handleCallback()
42 42
     {
43
-        try{
44
-            $github_user = Socialite::driver('github')->user();
45
-        }catch(\Laravel\Socialite\Two\InvalidStateException $e){
43
+        try {
44
+            $github_user=Socialite::driver('github')->user();
45
+        } catch (\Laravel\Socialite\Two\InvalidStateException $e) {
46 46
             return redirect('/');
47 47
         }
48 48
 
49
-        $accountModel = new AccountModel();
50
-        if(Auth::check()){
51
-            $user_id = Auth::user()->id;
52
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
53
-            if(!empty($ret) && $ret['uid'] != $user_id){
54
-                $user = UserModel::find($ret['uid']);
55
-                return view('oauth.index',[
49
+        $accountModel=new AccountModel();
50
+        if (Auth::check()) {
51
+            $user_id=Auth::user()->id;
52
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
53
+            if (!empty($ret) && $ret['uid']!=$user_id) {
54
+                $user=UserModel::find($ret['uid']);
55
+                return view('oauth.index', [
56 56
                     'page_title'=>"OAuth",
57 57
                     'site_title'=>config("app.name"),
58 58
                     'navigation'=>"OAuth",
@@ -67,17 +67,17 @@  discard block
 block discarded – undo
67 67
                     ]
68 68
                 ]);
69 69
             }
70
-            $accountModel->setExtra($user_id,'github_id',$github_user->id);
71
-            $accountModel->setExtra($user_id,'github_email',$github_user->email);
72
-            $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
73
-            $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
74
-            $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
75
-            return view('oauth.index',[
70
+            $accountModel->setExtra($user_id, 'github_id', $github_user->id);
71
+            $accountModel->setExtra($user_id, 'github_email', $github_user->email);
72
+            $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
73
+            $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
74
+            $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
75
+            return view('oauth.index', [
76 76
                 'page_title'=>"OAuth",
77 77
                 'site_title'=>config("app.name"),
78 78
                 'navigation'=>"OAuth",
79 79
                 'platform' => 'Github',
80
-                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
80
+                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
81 81
                 You can log in to '.config("app.name").' later using this account',
82 82
                 'buttons' => [
83 83
                     [
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
                     ],
87 87
                 ]
88 88
             ]);
89
-        }else{
90
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
91
-            if(!empty($ret)){
89
+        } else {
90
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
91
+            if (!empty($ret)) {
92 92
                 Auth::loginUsingId($ret['uid']);
93
-                $user_id = Auth::user()->id;
94
-                $accountModel->setExtra($user_id,'github_email',$github_user->email);
95
-                $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
96
-                $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
97
-                $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
93
+                $user_id=Auth::user()->id;
94
+                $accountModel->setExtra($user_id, 'github_email', $github_user->email);
95
+                $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
96
+                $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
97
+                $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
98 98
                 return redirect('/');
99
-            }else{
100
-                return view('oauth.index',[
99
+            } else {
100
+                return view('oauth.index', [
101 101
                     'page_title'=>"OAuth",
102 102
                     'site_title'=>config("app.name"),
103 103
                     'navigation'=>"OAuth",
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
 
121 121
     public function unbind()
122 122
     {
123
-        $accountModel = new AccountModel();
124
-        if($accountModel->getExtra(Auth::user()->id ,'github_id')){
125
-            return view('oauth.index',[
123
+        $accountModel=new AccountModel();
124
+        if ($accountModel->getExtra(Auth::user()->id, 'github_id')) {
125
+            return view('oauth.index', [
126 126
                 'page_title'=>"OAuth",
127 127
                 'site_title'=>config("app.name"),
128 128
                 'navigation'=>"OAuth",
129 129
                 'platform' => 'Github',
130 130
                 'display_html' => 'You are trying to unbind the following two : <br />
131 131
                 Your '.config("app.name").' account : <span class="text-info">'.Auth::user()->email.'</span><br />
132
-                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
132
+                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
133 133
                 Make your decision carefully, although you can later establish the binding again',
134 134
                 'buttons' => [
135 135
                     [
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
                     ],
144 144
                 ]
145 145
             ]);
146
-        }else{
147
-            return view('oauth.index',[
146
+        } else {
147
+            return view('oauth.index', [
148 148
                 'page_title'=>"OAuth",
149 149
                 'site_title'=>config("app.name"),
150 150
                 'navigation'=>"OAuth",
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 
163 163
     public function confirmUnbind()
164 164
     {
165
-        $accountModel = new AccountModel();
166
-        $user_id = Auth::user()->id;
167
-        if($accountModel->getExtra($user_id ,'github_id')){
168
-            $accountModel->setExtra($user_id,'github_id',null);
169
-            $accountModel->setExtra($user_id,'github_email',null);
170
-            $accountModel->setExtra($user_id,'github_nickname',null);
171
-            $accountModel->setExtra($user_id,'github_homepage',null);
172
-            $accountModel->setExtra($user_id,'github_token',null);
173
-            return view('oauth.index',[
165
+        $accountModel=new AccountModel();
166
+        $user_id=Auth::user()->id;
167
+        if ($accountModel->getExtra($user_id, 'github_id')) {
168
+            $accountModel->setExtra($user_id, 'github_id', null);
169
+            $accountModel->setExtra($user_id, 'github_email', null);
170
+            $accountModel->setExtra($user_id, 'github_nickname', null);
171
+            $accountModel->setExtra($user_id, 'github_homepage', null);
172
+            $accountModel->setExtra($user_id, 'github_token', null);
173
+            return view('oauth.index', [
174 174
                 'page_title'=>"OAuth",
175 175
                 'site_title'=>config("app.name"),
176 176
                 'navigation'=>"OAuth",
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
                     ],
184 184
                 ]
185 185
             ]);
186
-        }else{
187
-            return view('oauth.index',[
186
+        } else {
187
+            return view('oauth.index', [
188 188
                 'page_title'=>"OAuth",
189 189
                 'site_title'=>config("app.name"),
190 190
                 'navigation'=>"OAuth",
Please login to merge, or discard this patch.
app/Http/Controllers/UserController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@
 block discarded – undo
28 28
         $accountModel=new AccountModel();
29 29
         $info=$accountModel->detail($uid);
30 30
         $feed=$accountModel->feed($uid);
31
-        $extraInfo = $accountModel->getExtra($uid, ['gender', 'contanct', 'school', 'country', 'location'],0);
32
-        $socialiteInfo = $accountModel->getSocialiteInfo($uid,0);
31
+        $extraInfo=$accountModel->getExtra($uid, ['gender', 'contanct', 'school', 'country', 'location'], 0);
32
+        $socialiteInfo=$accountModel->getSocialiteInfo($uid, 0);
33 33
         return view("account.dashboard", [
34 34
             'page_title'=>$info["name"],
35 35
             'site_title'=>config("app.name"),
Please login to merge, or discard this patch.
app/Http/Controllers/Auth/ForgotPasswordController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
      */
38 38
     public function showLinkRequestForm()
39 39
     {
40
-        return view('auth.passwords.email',[
40
+        return view('auth.passwords.email', [
41 41
             'page_title'=>"Reset Password",
42 42
             'site_title'=>config("app.name"),
43 43
             'navigation' => "Account"
Please login to merge, or discard this patch.
app/Http/Controllers/AccountController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
         $accountModel=new AccountModel();
29 29
         $info=$accountModel->detail(Auth::user()->id);
30 30
         $feed=$accountModel->feed(Auth::user()->id);
31
-        $extraInfo = $accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'],100);
32
-        $socialiteInfo = $accountModel->getSocialiteInfo(Auth::user()->id,100);
31
+        $extraInfo=$accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'], 100);
32
+        $socialiteInfo=$accountModel->getSocialiteInfo(Auth::user()->id, 100);
33 33
         return view("account.dashboard", [
34 34
             'page_title'=>"DashBoard",
35 35
             'site_title'=>config("app.name"),
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $accountModel=new AccountModel();
54 54
         $info=$accountModel->detail(Auth::user()->id);
55
-        if(!empty(session('last_email_send'))){
56
-            $email_cooldown = 300 - (time() - session('last_email_send'));
55
+        if (!empty(session('last_email_send'))) {
56
+            $email_cooldown=300-(time()-session('last_email_send'));
57 57
         }
58
-        $extraInfo = $accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'],100);
59
-        $socialiteInfo = $accountModel->getSocialiteInfo(Auth::user()->id,100);
58
+        $extraInfo=$accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'], 100);
59
+        $socialiteInfo=$accountModel->getSocialiteInfo(Auth::user()->id, 100);
60 60
         return view("account.dashboard", [
61 61
             'page_title'=>"Settings",
62 62
             'site_title'=>config("app.name"),
Please login to merge, or discard this patch.
app/Http/Middleware/Privileged.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@
 block discarded – undo
18 18
     public function handle($request, Closure $next)
19 19
     {
20 20
         if (Auth::check()) {
21
-            if(isset($request->gcode)){
21
+            if (isset($request->gcode)) {
22 22
                 //group privilege
23 23
                 $groupModel=new GroupModel();
24
-                if($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2){
24
+                if ($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2) {
25 25
                     return $next($request);
26 26
                 }
27
-            }elseif(isset($request->cid)) {
27
+            }elseif (isset($request->cid)) {
28 28
                 //contest privilege
29 29
                 $contestModel=new ContestModel();
30
-                if($contestModel->judgeClearance($request->cid, Auth::user()->id)==3){
30
+                if ($contestModel->judgeClearance($request->cid, Auth::user()->id)==3) {
31 31
                     return $next($request);
32 32
                 }
33 33
             }
Please login to merge, or discard this patch.
app/Console/Commands/Babel/Crawl.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @var string
16 16
      */
17
-    protected $signature = 'babel:crawl {extension : The package name of the extension} {--action=crawl_problem : The action of the Crawler} {--con=all : The target problemset of the Crawler} {--cached : Whether cached or not}';
17
+    protected $signature='babel:crawl {extension : The package name of the extension} {--action=crawl_problem : The action of the Crawler} {--con=all : The target problemset of the Crawler} {--cached : Whether cached or not}';
18 18
 
19 19
     /**
20 20
      * The console command description.
21 21
      *
22 22
      * @var string
23 23
      */
24
-    protected $description = 'Crawl problems for a given Babel Extension to NOJ';
24
+    protected $description='Crawl problems for a given Babel Extension to NOJ';
25 25
 
26 26
     /**
27 27
      * Create a new command instance.
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function handle()
42 42
     {
43
-        $extension = $this->argument('extension');
44
-        $action = $this->option('action');
45
-        $con = $this->option('con');
46
-        $cached = $this->option('cached');
43
+        $extension=$this->argument('extension');
44
+        $action=$this->option('action');
45
+        $con=$this->option('con');
46
+        $cached=$this->option('cached');
47 47
         $babel=new Babel();
48 48
         $babel->crawl([
49 49
             "name" => $extension,
Please login to merge, or discard this patch.
app/Models/AnnouncementModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
     public function fetch()
19 19
     {
20
-        $list=DB::table($this->table)->orderBy('post_date','desc')->get()->all();
20
+        $list=DB::table($this->table)->orderBy('post_date', 'desc')->get()->all();
21 21
         if (empty($list)) {
22 22
             return [];
23 23
         }
Please login to merge, or discard this patch.
app/Models/RankModel.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Illuminate\Support\Facades\DB;
8 8
 use Illuminate\Support\Arr;
9 9
 use App\Models\Rating\RatingCalculator;
10
-use Cache,Redis;
10
+use Cache, Redis;
11 11
 
12 12
 class RankModel extends Model
13 13
 {
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
 
66 66
     public static function getColor($rankTitle)
67 67
     {
68
-        if(is_null($rankTitle)) return "";
68
+        if (is_null($rankTitle)) return "";
69 69
         return self::$casualRanking[$rankTitle];
70 70
     }
71 71
 
72 72
     public static function getProfessionalColor($rankTitle)
73 73
     {
74
-        if(is_null($rankTitle)) return self::$professionalRanking["None"];
74
+        if (is_null($rankTitle)) return self::$professionalRanking["None"];
75 75
         return self::$professionalRanking[$rankTitle];
76 76
     }
77 77
 
78 78
     public function list($num)
79 79
     {
80 80
         $rankList=Cache::tags(['rank'])->get('general');
81
-        if($rankList==null) $rankList=[];
82
-        $rankList=array_slice($rankList,0,$num);
83
-        $userInfoRaw=DB::table("users")->select("id as uid","avatar","name")->get()->all();
81
+        if ($rankList==null) $rankList=[];
82
+        $rankList=array_slice($rankList, 0, $num);
83
+        $userInfoRaw=DB::table("users")->select("id as uid", "avatar", "name")->get()->all();
84 84
         $userInfo=[];
85
-        foreach($userInfoRaw as $u){
85
+        foreach ($userInfoRaw as $u) {
86 86
             $userInfo[$u["uid"]]=$u;
87 87
         }
88
-        foreach($rankList as &$r){
89
-            $r["details"]=isset($userInfo[$r["uid"]])?$userInfo[$r["uid"]]:[];
88
+        foreach ($rankList as &$r) {
89
+            $r["details"]=isset($userInfo[$r["uid"]]) ? $userInfo[$r["uid"]] : [];
90 90
         }
91 91
         // var_dump($rankList); exit();
92 92
         return $rankList;
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
                     $rankSolved=$rankItem["totValue"];
110 110
                 }
111 111
                 $rankTitle=$this->getRankTitle($rankValue);
112
-                Cache::tags(['rank',$rankItem["uid"]])->put("rank", $rankValue, 86400);
113
-                Cache::tags(['rank',$rankItem["uid"]])->put("title", $rankTitle, 86400);
112
+                Cache::tags(['rank', $rankItem["uid"]])->put("rank", $rankValue, 86400);
113
+                Cache::tags(['rank', $rankItem["uid"]])->put("title", $rankTitle, 86400);
114 114
                 $rankListCached[]=[
115 115
                     "uid"=>$rankItem["uid"],
116 116
                     "rank"=>$rankValue,
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function getProfessionalRanking()
129 129
     {
130
-        $professionalRankList = [];
131
-        $verifiedUsers = DB::table("users")->select("professional_rate","id as uid","avatar","name")->get()->all();
132
-        $rankIter = 0;
133
-        foreach($verifiedUsers as $user) {
134
-            $rankVal = $user['professional_rate'];
135
-            $rankTitle = self::getProfessionalTitle($rankVal);
136
-            $titleColor = self::getProfessionalColor($rankTitle);
137
-            $professionalRankList[$rankIter++] = [
130
+        $professionalRankList=[];
131
+        $verifiedUsers=DB::table("users")->select("professional_rate", "id as uid", "avatar", "name")->get()->all();
132
+        $rankIter=0;
133
+        foreach ($verifiedUsers as $user) {
134
+            $rankVal=$user['professional_rate'];
135
+            $rankTitle=self::getProfessionalTitle($rankVal);
136
+            $titleColor=self::getProfessionalColor($rankTitle);
137
+            $professionalRankList[$rankIter++]=[
138 138
                 "name"=>$user["name"],
139 139
                 "uid"=>$user["uid"],
140 140
                 "avatar"=>$user["avatar"],
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 $tot+=$c;
157 157
             }
158 158
             foreach ($this->casualRankingPer as &$c) {
159
-                $c=round($c*$totUsers/$tot);
159
+                $c=round($c * $totUsers / $tot);
160 160
                 $cur+=$c;
161 161
                 $c=$cur;
162 162
             }
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 
168 168
     public function getRankTitle($rankVal)
169 169
     {
170
-        foreach($this->casualRankingPer as $title=>$c){
171
-            if($rankVal<=$c) return $title;
170
+        foreach ($this->casualRankingPer as $title=>$c) {
171
+            if ($rankVal<=$c) return $title;
172 172
         }
173 173
         return Arr::last($this->casualRankingPer);
174 174
     }
175 175
 
176 176
     public static function getProfessionalTitle($rankVal)
177 177
     {
178
-        foreach(self::$professionalRankingPer as $title=>$point) {
179
-            if($rankVal >= $point) return $title;
178
+        foreach (self::$professionalRankingPer as $title=>$point) {
179
+            if ($rankVal>=$point) return $title;
180 180
         }
181 181
         return Arr::last(self::$professionalRankingPer);
182 182
     }
Please login to merge, or discard this patch.
app/Console/Commands/Babel/SyncContest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @var string
16 16
      */
17
-    protected $signature = 'babel:sync {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid=1 : The holding group}';
17
+    protected $signature='babel:sync {extension : The package name of the extension} {--vcid= : The target contest of the Crawler} {--gid=1 : The holding group}';
18 18
 
19 19
     /**
20 20
      * The console command description.
21 21
      *
22 22
      * @var string
23 23
      */
24
-    protected $description = 'Crawl contests for a given Babel Extension to NOJ';
24
+    protected $description='Crawl contests for a given Babel Extension to NOJ';
25 25
 
26 26
     /**
27 27
      * Create a new command instance.
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function handle()
42 42
     {
43
-        $extension = $this->argument('extension');
44
-        $vcid = $this->option('vcid');
45
-        $gid = $this->option('gid');
46
-        $className = "App\\Babel\\Extension\\$extension\\Synchronizer";
47
-        $all_data = [
43
+        $extension=$this->argument('extension');
44
+        $vcid=$this->option('vcid');
45
+        $gid=$this->option('gid');
46
+        $className="App\\Babel\\Extension\\$extension\\Synchronizer";
47
+        $all_data=[
48 48
             'oj'=>$extension,
49 49
             'vcid'=>$vcid,
50 50
             'gid'=>$gid,
51 51
         ];
52
-        $Sync = new $className($all_data);
52
+        $Sync=new $className($all_data);
53 53
         $Sync->crawlContest();
54 54
     }
55 55
 }
Please login to merge, or discard this patch.