Passed
Pull Request — master (#216)
by Chenyi
04:17
created
app/Babel/Crawl/Crawler.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@
 block discarded – undo
26 26
         try {
27 27
             $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$name/babel.json")), true);
28 28
             $crawlerProvider=$BabelConfig["provider"]["crawler"];
29
-        } catch(ErrorException $e) {
30
-        } catch(Exception $e) {
29
+        } catch (ErrorException $e) {
30
+        } catch (Exception $e) {
31 31
         }
32
-        $className = "App\\Babel\\Extension\\$name\\$crawlerProvider";
33
-        if(class_exists($className)) {
32
+        $className="App\\Babel\\Extension\\$name\\$crawlerProvider";
33
+        if (class_exists($className)) {
34 34
             $temp=new $className();
35 35
             $temp->importCommandLine($commandLineObject);
36 36
             return $temp;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@
 block discarded – undo
17 17
     public function __construct($conf, $commandLineObject=null)
18 18
     {
19 19
         $crawler=self::create($conf, $commandLineObject);
20
-        if (!is_null($crawler) && isset($crawler)) $crawler->start($conf);
20
+        if (!is_null($crawler) && isset($crawler)) {
21
+            $crawler->start($conf);
22
+        }
21 23
     }
22 24
 
23 25
     public static function create($conf, $commandLineObject=null) {
Please login to merge, or discard this patch.
app/Helpers/functions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 if (!function_exists('emailVerified')) {
54 54
     function emailVerified()
55 55
     {
56
-        if(Auth::check()){
56
+        if (Auth::check()) {
57 57
             return !is_null(Auth::user()->email_verified_at);
58 58
         }
59 59
 
@@ -61,20 +61,20 @@  discard block
 block discarded – undo
61 61
     }
62 62
 }
63 63
 
64
-if (! function_exists('babel_path')) {
64
+if (!function_exists('babel_path')) {
65 65
     /**
66 66
      * Get the path to the application folder.
67 67
      *
68 68
      * @param  string  $path
69 69
      * @return string
70 70
      */
71
-    function babel_path($path = '')
71
+    function babel_path($path='')
72 72
     {
73 73
         return app('path').DIRECTORY_SEPARATOR.'Babel'.($path ? DIRECTORY_SEPARATOR.$path : $path);
74 74
     }
75 75
 }
76 76
 
77
-if (! function_exists('glob_recursive')) {
77
+if (!function_exists('glob_recursive')) {
78 78
     /**
79 79
      * Find pathnames matching a pattern recursively.
80 80
      *
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
      * @param  int     $flags   Valid flags: GLOB_MARK
83 83
      * @return array|false      an array containing the matched files/directories, an empty array if no file matched or false on error.
84 84
      */
85
-    function glob_recursive($pattern, $flags = 0)
85
+    function glob_recursive($pattern, $flags=0)
86 86
     {
87
-        $files = glob($pattern, $flags);
88
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
89
-            $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
87
+        $files=glob($pattern, $flags);
88
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
89
+            $files=array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
90 90
         }
91 91
         return $files;
92 92
     }
Please login to merge, or discard this patch.
app/Exports/AccountExport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
     public function __construct(array $data)
13 13
     {
14
-        $this->data = $data;
14
+        $this->data=$data;
15 15
     }
16 16
 
17 17
     public function array(): array
Please login to merge, or discard this patch.
app/Exports/GroupAnalysisExport.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     }
29 29
 
30 30
     /**
31
-    * @return array
32
-    */
31
+     * @return array
32
+     */
33 33
     public function registerEvents(): array
34 34
     {
35 35
         return [
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-    * @return \Illuminate\Support\Collection
50
-    */
49
+     * @return \Illuminate\Support\Collection
50
+     */
51 51
     public function collection()
52 52
     {
53 53
         $maxium = $this->config['maxium'] ?? false;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
     private $member_data;
16 16
     private $config;
17 17
 
18
-    public function __construct($data, $config = [])
18
+    public function __construct($data, $config=[])
19 19
     {
20
-        if($config['mode'] == 'contest'){
21
-            $this->contest_data = $data['contest_data'];
22
-            $this->member_data = $data['member_data'];
23
-        }else{
24
-            $this->member_data = $data['member_data'];
25
-            $this->tag_problems = $data['tag_problems'];
20
+        if ($config['mode']=='contest') {
21
+            $this->contest_data=$data['contest_data'];
22
+            $this->member_data=$data['member_data'];
23
+        } else {
24
+            $this->member_data=$data['member_data'];
25
+            $this->tag_problems=$data['tag_problems'];
26 26
         }
27
-        $this->config = $config;
27
+        $this->config=$config;
28 28
     }
29 29
 
30 30
     /**
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
     {
35 35
         return [
36 36
             AfterSheet::class => function(AfterSheet $event) {
37
-                if($this->config['mode'] === 'contest'){
38
-                    $mergeCell = ['A1:A2','B1:E1'];
37
+                if ($this->config['mode']==='contest') {
38
+                    $mergeCell=['A1:A2', 'B1:E1'];
39 39
                     foreach ($this->contest_data as $c) {
40
-                        array_push($mergeCell,$this->mergeCellColumnNext());
40
+                        array_push($mergeCell, $this->mergeCellColumnNext());
41 41
                     }
42 42
                     $event->sheet->getDelegate()->setMergeCells($mergeCell);
43 43
                 }
@@ -50,108 +50,108 @@  discard block
 block discarded – undo
50 50
     */
51 51
     public function collection()
52 52
     {
53
-        $maxium = $this->config['maxium'] ?? false;
54
-        $percent = $this->config['percent'] ?? false;
53
+        $maxium=$this->config['maxium'] ?? false;
54
+        $percent=$this->config['percent'] ?? false;
55 55
 
56
-        if($this->config['mode'] == 'contest'){
57
-            $row_1 = ['Member','Total','','',''];
58
-            $row_2 = ['','Elo','Rank','Solved','Penalty'];
56
+        if ($this->config['mode']=='contest') {
57
+            $row_1=['Member', 'Total', '', '', ''];
58
+            $row_2=['', 'Elo', 'Rank', 'Solved', 'Penalty'];
59 59
             foreach ($this->contest_data as $contest) {
60
-                array_push($row_1,$contest['name'],'');
61
-                array_push($row_2,'Solved','Penalty');
60
+                array_push($row_1, $contest['name'], '');
61
+                array_push($row_2, 'Solved', 'Penalty');
62 62
             }
63
-            $data = [$row_1,$row_2];
63
+            $data=[$row_1, $row_2];
64 64
             foreach ($this->member_data as $member) {
65
-                $display_name = $member['name'];
66
-                if(!empty($member['nick_name'])){
67
-                    $display_name .= ' ('.$member['nick_name'].')';
65
+                $display_name=$member['name'];
66
+                if (!empty($member['nick_name'])) {
67
+                    $display_name.=' ('.$member['nick_name'].')';
68 68
                 }
69
-                $row = [
69
+                $row=[
70 70
                     $display_name,
71 71
                     $member['elo'],
72
-                    !empty($member['rank_ave']) ? round($member['rank_ave'],1) : '-',
73
-                    $percent === 'true'  ? ($member['problem_all'] != 0 ? round( $member['solved_all'] / $member['problem_all'] * 100 , 1) : '-'). ' %'
74
-                            : ($maxium === 'true'  ? $member['solved_all'] . ' / ' . $member['problem_all'] : $member['solved_all']),
72
+                    !empty($member['rank_ave']) ? round($member['rank_ave'], 1) : '-',
73
+                    $percent==='true' ? ($member['problem_all']!=0 ? round($member['solved_all'] / $member['problem_all'] * 100, 1) : '-').' %'
74
+                            : ($maxium==='true' ? $member['solved_all'].' / '.$member['problem_all'] : $member['solved_all']),
75 75
                     round($member['penalty']),
76 76
                 ];
77 77
                 foreach ($this->contest_data as $contest) {
78
-                    if(in_array($contest['cid'] , array_keys($member['contest_detial']))){
79
-                        $contest_detial = $member['contest_detial'][$contest['cid']];
78
+                    if (in_array($contest['cid'], array_keys($member['contest_detial']))) {
79
+                        $contest_detial=$member['contest_detial'][$contest['cid']];
80 80
                         array_push(
81 81
                             $row,
82
-                            $percent === 'true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100,1) . ' %')
83
-                                    : ($maxium === 'true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']),
82
+                            $percent==='true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100, 1).' %')
83
+                                    : ($maxium==='true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']),
84 84
                             round($contest_detial['penalty'])
85 85
                         );
86
-                    }else{
86
+                    } else {
87 87
                         array_push(
88 88
                             $row,
89
-                            $percent === 'true' ? '- %'
90
-                                    : ($maxium === 'true' ? '- / -' : ' - '),
89
+                            $percent==='true' ? '- %'
90
+                                    : ($maxium==='true' ? '- / -' : ' - '),
91 91
                             0
92 92
                         );
93 93
                     }
94 94
                 }
95
-                array_push($data,$row);
95
+                array_push($data, $row);
96 96
             }
97
-        }else{
98
-            $row_1 = ['Member'];
99
-            $row_2 = [''];
97
+        } else {
98
+            $row_1=['Member'];
99
+            $row_2=[''];
100 100
             foreach ($this->tag_problems as $tag => $tag_problem_set) {
101
-                array_push($row_1,$tag);
102
-                array_push($row_2,'Solved');
101
+                array_push($row_1, $tag);
102
+                array_push($row_2, 'Solved');
103 103
             }
104
-            $data = [$row_1,$row_2];
104
+            $data=[$row_1, $row_2];
105 105
             foreach ($this->member_data as $member) {
106
-                $display_name = $member['name'];
107
-                if(!empty($member['nick_name'])){
108
-                    $display_name .= ' ('.$member['nick_name'].')';
106
+                $display_name=$member['name'];
107
+                if (!empty($member['nick_name'])) {
108
+                    $display_name.=' ('.$member['nick_name'].')';
109 109
                 }
110
-                $row = [
110
+                $row=[
111 111
                     $display_name,
112 112
                 ];
113
-                foreach($member['completion'] as $tag => $tag_completion){
114
-                    $count = count($tag_completion);
115
-                    $solved = eval('return '.join('+',array_values($tag_completion)).';');
113
+                foreach ($member['completion'] as $tag => $tag_completion) {
114
+                    $count=count($tag_completion);
115
+                    $solved=eval('return '.join('+', array_values($tag_completion)).';');
116 116
                     array_push(
117 117
                         $row,
118
-                        $percent === 'true' ? (round($solved / $count * 100,1) . ' %') : ($maxium  === 'true' ? $solved .' / '.$count : $solved)
118
+                        $percent==='true' ? (round($solved / $count * 100, 1).' %') : ($maxium==='true' ? $solved.' / '.$count : $solved)
119 119
                     );
120 120
                 }
121
-                array_push($data,$row);
121
+                array_push($data, $row);
122 122
             }
123 123
         }
124 124
         return collect($data);
125 125
     }
126 126
 
127
-    private function mergeCellColumnNext(){
128
-        static $columns = [
129
-            [3],[4]
127
+    private function mergeCellColumnNext() {
128
+        static $columns=[
129
+            [3], [4]
130 130
         ];
131
-        $columns_str = ['',''];
132
-        $chars = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
133
-        foreach($columns as $key => &$column){
134
-            $column[0] += 2;
135
-            if($column[0] > 25){
136
-                if(isset($column[1])){
137
-                    $column[1] += 1;
138
-                    if($column[1] > 25){
139
-                        if(isset($column[2])){
140
-                            $column[2] += 1;
141
-                        }else{
142
-                            $column[2] = 0;
131
+        $columns_str=['', ''];
132
+        $chars=str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
133
+        foreach ($columns as $key => &$column) {
134
+            $column[0]+=2;
135
+            if ($column[0]>25) {
136
+                if (isset($column[1])) {
137
+                    $column[1]+=1;
138
+                    if ($column[1]>25) {
139
+                        if (isset($column[2])) {
140
+                            $column[2]+=1;
141
+                        } else {
142
+                            $column[2]=0;
143 143
                         }
144 144
                     }
145
-                }else{
146
-                    $column[1] = 0;
145
+                } else {
146
+                    $column[1]=0;
147 147
                 }
148 148
             }
149
-            $columns_str[$key] = '';
150
-            $reverse_column = array_reverse($column);
149
+            $columns_str[$key]='';
150
+            $reverse_column=array_reverse($column);
151 151
             foreach ($reverse_column as $ord) {
152
-                $columns_str[$key] .= $chars[$ord];
152
+                $columns_str[$key].=$chars[$ord];
153 153
             }
154
-            $columns_str[$key] .= '1';
154
+            $columns_str[$key].='1';
155 155
         }
156 156
         return $columns_str[0].':'.$columns_str[1];
157 157
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         if($config['mode'] == 'contest'){
21 21
             $this->contest_data = $data['contest_data'];
22 22
             $this->member_data = $data['member_data'];
23
-        }else{
23
+        } else{
24 24
             $this->member_data = $data['member_data'];
25 25
             $this->tag_problems = $data['tag_problems'];
26 26
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                                     : ($maxium === 'true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']),
84 84
                             round($contest_detial['penalty'])
85 85
                         );
86
-                    }else{
86
+                    } else{
87 87
                         array_push(
88 88
                             $row,
89 89
                             $percent === 'true' ? '- %'
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
                 }
95 95
                 array_push($data,$row);
96 96
             }
97
-        }else{
97
+        } else{
98 98
             $row_1 = ['Member'];
99 99
             $row_2 = [''];
100 100
             foreach ($this->tag_problems as $tag => $tag_problem_set) {
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
                     if($column[1] > 25){
139 139
                         if(isset($column[2])){
140 140
                             $column[2] += 1;
141
-                        }else{
141
+                        } else{
142 142
                             $column[2] = 0;
143 143
                         }
144 144
                     }
145
-                }else{
145
+                } else{
146 146
                     $column[1] = 0;
147 147
                 }
148 148
             }
Please login to merge, or discard this patch.
app/Http/Controllers/OAuth/GithubController.php 2 patches
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.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     {
43 43
         try{
44 44
             $github_user = Socialite::driver('github')->user();
45
-        }catch(\Laravel\Socialite\Two\InvalidStateException $e){
45
+        } catch(\Laravel\Socialite\Two\InvalidStateException $e){
46 46
             return redirect('/');
47 47
         }
48 48
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                     ],
87 87
                 ]
88 88
             ]);
89
-        }else{
89
+        } else{
90 90
             $ret = $accountModel->findExtra('github_id',$github_user->id);
91 91
             if(!empty($ret)){
92 92
                 Auth::loginUsingId($ret['uid']);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                 $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
97 97
                 $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
98 98
                 return redirect('/');
99
-            }else{
99
+            } else{
100 100
                 return view('oauth.index',[
101 101
                     'page_title'=>"OAuth",
102 102
                     'site_title'=>config("app.name"),
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                     ],
144 144
                 ]
145 145
             ]);
146
-        }else{
146
+        } else{
147 147
             return view('oauth.index',[
148 148
                 'page_title'=>"OAuth",
149 149
                 'site_title'=>config("app.name"),
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                     ],
184 184
                 ]
185 185
             ]);
186
-        }else{
186
+        } else{
187 187
             return view('oauth.index',[
188 188
                 'page_title'=>"OAuth",
189 189
                 'site_title'=>config("app.name"),
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/Ajax/GroupController.php 2 patches
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -301,11 +301,17 @@  discard block
 block discarded – undo
301 301
 
302 302
         $groupModel=new GroupModel();
303 303
         $is_user=$groupModel->isUser($all_data["email"]);
304
-        if(!$is_user) return ResponseModel::err(2006);
304
+        if(!$is_user) {
305
+            return ResponseModel::err(2006);
306
+        }
305 307
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
306
-        if($clearance<2) return ResponseModel::err(7002);
308
+        if($clearance<2) {
309
+            return ResponseModel::err(7002);
310
+        }
307 311
         $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]);
308
-        if($targetClearance!=-3) return ResponseModel::err(7003);
312
+        if($targetClearance!=-3) {
313
+            return ResponseModel::err(7003);
314
+        }
309 315
         $groupModel->inviteMember($all_data["gid"], $all_data["email"]);
310 316
         return ResponseModel::success(200);
311 317
     }
@@ -323,9 +329,13 @@  discard block
 block discarded – undo
323 329
         $all_data=$request->all();
324 330
 
325 331
         $groupModel=new GroupModel();
326
-        if($all_data["gcode"]=="create") return ResponseModel::err(7005);
332
+        if($all_data["gcode"]=="create") {
333
+            return ResponseModel::err(7005);
334
+        }
327 335
         $is_group=$groupModel->isGroup($all_data["gcode"]);
328
-        if($is_group) return ResponseModel::err(7006);
336
+        if($is_group) {
337
+            return ResponseModel::err(7006);
338
+        }
329 339
 
330 340
         $allow_extension=['jpg', 'png', 'jpeg', 'gif', 'bmp'];
331 341
         if (!empty($request->file('img')) && $request->file('img')->isValid()) {
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
         $groupModel=new GroupModel();
86 86
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
87
-        if ($clearance < 2){
87
+        if ($clearance<2) {
88 88
             return ResponseModel::err(2001);
89 89
         }
90 90
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 
104 104
         $groupModel=new GroupModel();
105 105
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
106
-        if ($clearance < 2){
106
+        if ($clearance<2) {
107 107
             return ResponseModel::err(2001);
108 108
         }
109 109
 
110
-        if ($all_data["join_policy"] < 1 || $all_data["join_policy"] > 3){
110
+        if ($all_data["join_policy"]<1 || $all_data["join_policy"]>3) {
111 111
             return ResponseModel::err(1007);
112 112
         }
113 113
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             'gid' => 'required|integer',
122 122
         ]);
123 123
 
124
-        $all_data = $request->all();
124
+        $all_data=$request->all();
125 125
 
126 126
         if (!empty($request->file('img')) && $request->file('img')->isValid()) {
127 127
             $extension=$request->file('img')->extension();
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
         $groupModel=new GroupModel();
135 135
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
136
-        if ($clearance < 2){
136
+        if ($clearance<2) {
137 137
             return ResponseModel::err(2001);
138 138
         }
139 139
 
@@ -171,18 +171,18 @@  discard block
 block discarded – undo
171 171
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
172 172
         $target_clearance=$groupModel->judgeClearance($all_data["gid"], $all_data['uid']);
173 173
 
174
-        if($target_clearance == -3){
174
+        if ($target_clearance==-3) {
175 175
             return ResponseModel::err(7004);
176 176
         }
177 177
 
178
-        if($target_clearance >= $clearance || $clearance < 2 || $all_data['permission'] >= $clearance){
178
+        if ($target_clearance>=$clearance || $clearance<2 || $all_data['permission']>=$clearance) {
179 179
             return ResponseModel::err(2001);
180 180
         }
181 181
 
182 182
         $groupModel->changeClearance($all_data['uid'], $all_data["gid"], $all_data['permission']);
183 183
 
184
-        $result_info = $groupModel->userProfile($all_data['uid'],$all_data["gid"]);
185
-        return ResponseModel::success(200,null,$result_info);
184
+        $result_info=$groupModel->userProfile($all_data['uid'], $all_data["gid"]);
185
+        return ResponseModel::success(200, null, $result_info);
186 186
     }
187 187
 
188 188
     public function generateContestAccount(Request $request)
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
263 263
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
264 264
         if ($clearance>1) {
265
-            if($targetClearance!=0) {
265
+            if ($targetClearance!=0) {
266 266
                 return ResponseModel::err(7003);
267 267
             }
268 268
             $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1);
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 
302 302
         $groupModel=new GroupModel();
303 303
         $is_user=$groupModel->isUser($all_data["email"]);
304
-        if(!$is_user) return ResponseModel::err(2006);
304
+        if (!$is_user) return ResponseModel::err(2006);
305 305
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
306
-        if($clearance<2) return ResponseModel::err(7002);
306
+        if ($clearance<2) return ResponseModel::err(7002);
307 307
         $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]);
308
-        if($targetClearance!=-3) return ResponseModel::err(7003);
308
+        if ($targetClearance!=-3) return ResponseModel::err(7003);
309 309
         $groupModel->inviteMember($all_data["gid"], $all_data["email"]);
310 310
         return ResponseModel::success(200);
311 311
     }
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
         $all_data=$request->all();
324 324
 
325 325
         $groupModel=new GroupModel();
326
-        if($all_data["gcode"]=="create") return ResponseModel::err(7005);
326
+        if ($all_data["gcode"]=="create") return ResponseModel::err(7005);
327 327
         $is_group=$groupModel->isGroup($all_data["gcode"]);
328
-        if($is_group) return ResponseModel::err(7006);
328
+        if ($is_group) return ResponseModel::err(7006);
329 329
 
330 330
         $allow_extension=['jpg', 'png', 'jpeg', 'gif', 'bmp'];
331 331
         if (!empty($request->file('img')) && $request->file('img')->isValid()) {
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
         $groupModel=new GroupModel();
357 357
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
358
-        if ($clearance < 2){
358
+        if ($clearance<2) {
359 359
             return ResponseModel::err(2001);
360 360
         }
361 361
         $groupModel->createNotice($all_data["gid"], Auth::user()->id, $all_data["title"], $all_data["content"]);
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 
375 375
         $groupModel=new GroupModel();
376 376
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
377
-        if ($clearance < 2) {
377
+        if ($clearance<2) {
378 378
             return ResponseModel::err(7002);
379 379
         }
380
-        $tags = $groupModel->problemTags($all_data['gid'],$all_data['pid']);
381
-        if(in_array($all_data['tag'],$tags)){
380
+        $tags=$groupModel->problemTags($all_data['gid'], $all_data['pid']);
381
+        if (in_array($all_data['tag'], $tags)) {
382 382
             return ResponseModel::err(7007);
383 383
         }
384 384
 
@@ -416,20 +416,20 @@  discard block
 block discarded – undo
416 416
 
417 417
         $groupModel=new GroupModel();
418 418
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
419
-        if ($clearance > 0) {
420
-            switch($all_data['mode']){
419
+        if ($clearance>0) {
420
+            switch ($all_data['mode']) {
421 421
                 case 'contest':
422
-                    $ret = $groupModel->groupMemberPracticeContestStat($all_data["gid"]);
422
+                    $ret=$groupModel->groupMemberPracticeContestStat($all_data["gid"]);
423 423
                 break;
424 424
                 case 'tag':
425
-                    $ret = $groupModel->groupMemberPracticeTagStat($all_data["gid"]);
425
+                    $ret=$groupModel->groupMemberPracticeTagStat($all_data["gid"]);
426 426
                 break;
427 427
                 default:
428 428
                     return ResponseModel::err(1007);
429 429
                 break;
430 430
             }
431 431
 
432
-            return ResponseModel::success(200,null,$ret);
432
+            return ResponseModel::success(200, null, $ret);
433 433
         }
434 434
         return ResponseModel::err(7002);
435 435
     }
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
         $request->validate([
440 440
             'gid' => 'required|string',
441 441
         ]);
442
-        $gid = $request->input('gid');
442
+        $gid=$request->input('gid');
443 443
         $groupModel=new GroupModel();
444
-        if($groupModel->judgeClearance($gid,Auth::user()->id) < 2) {
444
+        if ($groupModel->judgeClearance($gid, Auth::user()->id)<2) {
445 445
             return ResponseModel::err(2001);
446 446
         }
447 447
         $groupModel->refreshElo($gid);
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/ContestController.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -187,7 +187,9 @@  discard block
 block discarded – undo
187 187
         }
188 188
 
189 189
         $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width');
190
-        if(empty($editor_left_width)) $editor_left_width='40';
190
+        if(empty($editor_left_width)) {
191
+            $editor_left_width='40';
192
+        }
191 193
 
192 194
         return view('contest.board.editor', [
193 195
             'page_title'=>"Problem Detail",
@@ -383,7 +385,7 @@  discard block
 block discarded – undo
383 385
         $account=$contestModel->getContestAccount($cid);
384 386
         if($account==null){
385 387
             return ;
386
-        }else{
388
+        } else{
387 389
             $AccountExport=new AccountExport($account);
388 390
             $filename="ContestAccount$cid";
389 391
             return Excel::download($AccountExport, $filename.'.xlsx');
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $filter["rated"]=isset($all_data["rated"]) ? $all_data["rated"] : null;
35 35
         $filter["anticheated"]=isset($all_data["anticheated"]) ? $all_data["anticheated"] : null;
36 36
         $filter["practice"]=isset($all_data["practice"]) ? $all_data["practice"] : null;
37
-        $return_list=$contestModel->list($filter,Auth::check()?Auth::user()->id:0);
37
+        $return_list=$contestModel->list($filter, Auth::check() ?Auth::user()->id : 0);
38 38
         $featured=$contestModel->featured();
39 39
         if (is_null($return_list)) {
40 40
             if (isset($all_data["page"]) && $all_data["page"]>1) {
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
             ];
189 189
         }
190 190
 
191
-        $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width');
192
-        if(empty($editor_left_width)) $editor_left_width='40';
191
+        $editor_left_width=$accountModel->getExtra(Auth::user()->id, 'editor_left_width');
192
+        if (empty($editor_left_width)) $editor_left_width='40';
193 193
 
194 194
         return view('contest.board.editor', [
195 195
             'page_title'=>"Problem Detail",
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         $contestModel=new ContestModel();
352 352
         $verified=$contestModel->isVerified($cid);
353 353
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
354
-        if ($clearance <= 2) {
354
+        if ($clearance<=2) {
355 355
             return Redirect::route('contest_detail', ['cid' => $cid]);
356 356
         }
357 357
         $contest_name=$contestModel->contestName($cid);
@@ -379,20 +379,20 @@  discard block
 block discarded – undo
379 379
     {
380 380
         $contestModel=new ContestModel();
381 381
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
382
-        if ($clearance <= 2) {
382
+        if ($clearance<=2) {
383 383
             return Redirect::route('contest_detail', ['cid' => $cid]);
384 384
         }
385 385
         $account=$contestModel->getContestAccount($cid);
386
-        if($account==null){
387
-            return ;
388
-        }else{
386
+        if ($account==null) {
387
+            return;
388
+        } else {
389 389
             $AccountExport=new AccountExport($account);
390 390
             $filename="ContestAccount$cid";
391 391
             return Excel::download($AccountExport, $filename.'.xlsx');
392 392
         }
393 393
     }
394 394
 
395
-    public function analysis($cid){
395
+    public function analysis($cid) {
396 396
         $contestModel=new ContestModel();
397 397
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
398 398
         if (!$clearance) {
@@ -413,17 +413,17 @@  discard block
 block discarded – undo
413 413
         ]);
414 414
     }
415 415
 
416
-    public function refreshContestRank($cid){
416
+    public function refreshContestRank($cid) {
417 417
         $contestModel=new ContestModel();
418 418
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
419
-        if ($clearance <= 2) {
419
+        if ($clearance<=2) {
420 420
             return Redirect::route('contest.detail', ['cid' => $cid]);
421 421
         }
422 422
         $contestRankRaw=$contestModel->contestRankCache($cid);
423 423
         Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
424 424
         Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
425 425
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
426
-        if(time() > $end_time){
426
+        if (time()>$end_time) {
427 427
             $contestModel->storeContestRankInMySQL($cid, $contestRankRaw);
428 428
         }
429 429
         return Redirect::route('contest.rank', ['cid' => $cid]);
Please login to merge, or discard this patch.