Passed
Push — master ( bc03d4...3c12ae )
by Chenyi
07:50 queued 03:46
created
app/Models/GroupModel.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     public function details($gcode)
80 80
     {
81 81
         $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first();
82
-        if(empty($basic_info)) return [];
82
+        if (empty($basic_info)) return [];
83 83
         $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]);
84 84
         $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]);
85 85
         $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y');
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         foreach ($user_list as &$u) {
121 121
             $u["role_parsed"]=$this->role[$u["role"]];
122 122
             $u["role_color"]=$this->role_color[$u["role"]];
123
-            if(is_null($u["sub_group"])) $u["sub_group"]="None";
123
+            if (is_null($u["sub_group"])) $u["sub_group"]="None";
124 124
         }
125 125
         return $user_list;
126 126
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@  discard block
 block discarded – undo
79 79
     public function details($gcode)
80 80
     {
81 81
         $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first();
82
-        if(empty($basic_info)) return [];
82
+        if(empty($basic_info)) {
83
+            return [];
84
+        }
83 85
         $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]);
84 86
         $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]);
85 87
         $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y');
@@ -120,7 +122,9 @@  discard block
 block discarded – undo
120 122
         foreach ($user_list as &$u) {
121 123
             $u["role_parsed"]=$this->role[$u["role"]];
122 124
             $u["role_color"]=$this->role_color[$u["role"]];
123
-            if(is_null($u["sub_group"])) $u["sub_group"]="None";
125
+            if(is_null($u["sub_group"])) {
126
+                $u["sub_group"]="None";
127
+            }
124 128
         }
125 129
         return $user_list;
126 130
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/GroupController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@
 block discarded – undo
147 147
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
148 148
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
149 149
         if ($clearance>1) {
150
-            if($targetClearance!=0) {
150
+            if ($targetClearance!=0) {
151 151
                 return ResponseModel::err(7003);
152 152
             }
153 153
             $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1);
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/AccountController.php 2 patches
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 class AccountController extends Controller
17 17
 {
18 18
 
19
-    public function updateAvatar(Request $request){
19
+    public function updateAvatar(Request $request) {
20 20
         $isValid=$request->file('avatar')->isValid();
21 21
         if ($isValid) {
22 22
             $extension=$request->file('avatar')->extension();
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
         }
44 44
     }
45 45
 
46
-    public function changeBasicInfo(Request $request){
46
+    public function changeBasicInfo(Request $request) {
47 47
         // if(!$request->has('username')){
48 48
         //     return ResponseModel::err(1003);
49 49
         // }
50 50
         // $username = $request->input('username');
51
-        $describes = $request->input('describes');
52
-        if(strlen($describes) > 255){
51
+        $describes=$request->input('describes');
52
+        if (strlen($describes)>255) {
53 53
             return ResponseModel::err(1006);
54 54
         }
55 55
         // $old_username=Auth::user()->name;
@@ -58,79 +58,79 @@  discard block
 block discarded – undo
58 58
         // }
59 59
         $user=Auth::user();
60 60
         // $user->name = $username;
61
-        $user->describes = $describes;
61
+        $user->describes=$describes;
62 62
         $user->save();
63 63
         return ResponseModel::success();
64 64
     }
65 65
 
66
-    public function changePassword(Request $request){
67
-        if(!$request->has('old_password') || !$request->has('new_password') || !$request->has('confirm_password')){
66
+    public function changePassword(Request $request) {
67
+        if (!$request->has('old_password') || !$request->has('new_password') || !$request->has('confirm_password')) {
68 68
             return ResponseModel::err(1003);
69 69
         }
70
-        $old_password = $request->input('old_password');
71
-        $new_password = $request->input('new_password');
72
-        $confirm_password = $request->input('confirm_password');
73
-        if($new_password != $confirm_password){
70
+        $old_password=$request->input('old_password');
71
+        $new_password=$request->input('new_password');
72
+        $confirm_password=$request->input('confirm_password');
73
+        if ($new_password!=$confirm_password) {
74 74
             return ResponseModel::err(2004);
75 75
         }
76
-        if(strlen($new_password) < 8 || strlen($old_password) < 8){
76
+        if (strlen($new_password)<8 || strlen($old_password)<8) {
77 77
             return ResponseModel::err(1006);
78 78
         }
79
-        $user = Auth::user();
80
-        if(!Hash::check($old_password, $user->password)){
79
+        $user=Auth::user();
80
+        if (!Hash::check($old_password, $user->password)) {
81 81
             return ResponseModel::err(2005);
82 82
         }
83
-        $user->password = Hash::make($new_password);
83
+        $user->password=Hash::make($new_password);
84 84
         $user->save();
85 85
         return ResponseModel::success();
86 86
     }
87 87
 
88
-    public function checkEmailCooldown(Request $request){
89
-        $last_send = $request->session()->get('last_email_send');
90
-        if(empty($last_send) || time() - $last_send >= 300){
91
-            $request->session()->put('last_email_send',time());
92
-            return ResponseModel::success(200,null,0);
93
-        }else{
94
-            $cooldown =  300 - (time() - $last_send);
95
-            return ResponseModel::success(200,null,$cooldown);
88
+    public function checkEmailCooldown(Request $request) {
89
+        $last_send=$request->session()->get('last_email_send');
90
+        if (empty($last_send) || time()-$last_send>=300) {
91
+            $request->session()->put('last_email_send', time());
92
+            return ResponseModel::success(200, null, 0);
93
+        } else {
94
+            $cooldown=300-(time()-$last_send);
95
+            return ResponseModel::success(200, null, $cooldown);
96 96
         }
97 97
     }
98 98
 
99
-    public function changeExtraInfo(Request $request){
100
-        $input = $request->input();
101
-        $allow_change = ['gender','contact','school','country','location'];
102
-        foreach($input as $key => $value){
103
-            if(!in_array($key,$allow_change)){
99
+    public function changeExtraInfo(Request $request) {
100
+        $input=$request->input();
101
+        $allow_change=['gender', 'contact', 'school', 'country', 'location'];
102
+        foreach ($input as $key => $value) {
103
+            if (!in_array($key, $allow_change)) {
104 104
                 return ResponseModel::error(1007);
105 105
             }
106 106
         }
107
-        $account_model = new AccountModel();
108
-        $user_id = Auth::user()->id;
107
+        $account_model=new AccountModel();
108
+        $user_id=Auth::user()->id;
109 109
         foreach ($input as $key => $value) {
110
-            if(strlen($value) != 0){
111
-                $account_model->setExtraInfo($user_id,$key,$value,0);
112
-            }else{
113
-                $account_model->unsetExtraInfoIfExist($user_id,$key);
110
+            if (strlen($value)!=0) {
111
+                $account_model->setExtraInfo($user_id, $key, $value, 0);
112
+            } else {
113
+                $account_model->unsetExtraInfoIfExist($user_id, $key);
114 114
             }
115 115
         }
116 116
         return ResponseModel::success();
117 117
     }
118 118
 
119
-    public function saveEditorWidth(Request $request){
120
-        $input = $request->input();
121
-        $allow_change = ['editor_left_width'];
122
-        foreach($input as $key => $value){
123
-            if(!in_array($key,$allow_change)){
119
+    public function saveEditorWidth(Request $request) {
120
+        $input=$request->input();
121
+        $allow_change=['editor_left_width'];
122
+        foreach ($input as $key => $value) {
123
+            if (!in_array($key, $allow_change)) {
124 124
                 return ResponseModel::error(1007);
125 125
             }
126 126
         }
127
-        $account_model = new AccountModel();
128
-        $user_id = Auth::user()->id;
127
+        $account_model=new AccountModel();
128
+        $user_id=Auth::user()->id;
129 129
         foreach ($input as $key => $value) {
130
-            if(strlen($value) != 0){
131
-                $account_model->setExtraInfo($user_id,$key,$value,0);
132
-            }else{
133
-                $account_model->unsetExtraInfoIfExist($user_id,$key);
130
+            if (strlen($value)!=0) {
131
+                $account_model->setExtraInfo($user_id, $key, $value, 0);
132
+            } else {
133
+                $account_model->unsetExtraInfoIfExist($user_id, $key);
134 134
             }
135 135
         }
136 136
         return ResponseModel::success();
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         if(empty($last_send) || time() - $last_send >= 300){
91 91
             $request->session()->put('last_email_send',time());
92 92
             return ResponseModel::success(200,null,0);
93
-        }else{
93
+        } else{
94 94
             $cooldown =  300 - (time() - $last_send);
95 95
             return ResponseModel::success(200,null,$cooldown);
96 96
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         foreach ($input as $key => $value) {
110 110
             if(strlen($value) != 0){
111 111
                 $account_model->setExtraInfo($user_id,$key,$value,0);
112
-            }else{
112
+            } else{
113 113
                 $account_model->unsetExtraInfoIfExist($user_id,$key);
114 114
             }
115 115
         }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         foreach ($input as $key => $value) {
130 130
             if(strlen($value) != 0){
131 131
                 $account_model->setExtraInfo($user_id,$key,$value,0);
132
-            }else{
132
+            } else{
133 133
                 $account_model->unsetExtraInfoIfExist($user_id,$key);
134 134
             }
135 135
         }
Please login to merge, or discard this patch.
app/Http/Controllers/ProblemController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
             ];
132 132
         }
133 133
 
134
-        $editor_left_width = $account->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
134
+        $editor_left_width=$account->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
135 135
 
136 136
         return is_null($prob_detail) ?  redirect("/problem") : view('problem.editor', [
137 137
                                             'page_title'=>$prob_detail["title"],
Please login to merge, or discard this patch.
app/Http/Controllers/ContestController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function index()
23 23
     {
24 24
         $contestModel=new ContestModel();
25
-        $return_list=$contestModel->list(Auth::check()?Auth::user()->id:0);
25
+        $return_list=$contestModel->list(Auth::check() ?Auth::user()->id : 0);
26 26
         $featured=$contestModel->featured();
27 27
         return view('contest.index', [
28 28
             'page_title'=>"Contest",
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             ];
158 158
         }
159 159
 
160
-        $editor_left_width = $accountModel->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
160
+        $editor_left_width=$accountModel->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
161 161
 
162 162
         return view('contest.board.editor', [
163 163
             'page_title'=>"Problem Detail",
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualJudge/HDU/HDU.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
         $this->post_data=$all_data;
20 20
         $judger=new JudgerModel();
21 21
         $judger_list=$judger->list(8);
22
-        $this->judgerAccount = $judger_list[array_rand($judger_list)];
22
+        $this->judgerAccount=$judger_list[array_rand($judger_list)];
23 23
     }
24 24
 
25 25
     private function hduLogin()
26 26
     {
27
-        $response=$this->grab_page('http://acm.hdu.edu.cn','hdu', [], $this->judgerAccount["handle"]);
27
+        $response=$this->grab_page('http://acm.hdu.edu.cn', 'hdu', [], $this->judgerAccount["handle"]);
28 28
         if (strpos($response, 'Sign In')!==false) {
29 29
             $params=[
30 30
                 'username' => $this->judgerAccount["handle"],
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
         $response=$this->post_data("http://acm.hdu.edu.cn/submit.php?action=submit", http_build_query($params), "hdu", true, false, true, false, [], $this->judgerAccount['handle']);
48 48
         // Log::debug($response);
49
-        $this->sub['jid'] = $this->judgerAccount['jid'];
49
+        $this->sub['jid']=$this->judgerAccount['jid'];
50 50
         $res=Requests::get('http://acm.hdu.edu.cn/status.php?user='.$this->judgerAccount['handle'].'&pid='.$this->post_data['iid']);
51 51
         if (!preg_match("/<td height=22px>([\s\S]*?)<\/td>/", $res->body, $match)) {
52 52
                 $this->sub['verdict']='Submission Error';
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualJudge/Core.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@
 block discarded – undo
61 61
             $UVa->submit();
62 62
         }
63 63
 
64
-        if($oj=='hdu') {
65
-            $HDU = new HDU($sub, $all_data);
64
+        if ($oj=='hdu') {
65
+            $HDU=new HDU($sub, $all_data);
66 66
             $HDU->submit();
67 67
         }
68 68
 
Please login to merge, or discard this patch.
app/Http/Controllers/VirtualCrawler/HDU/HDU.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -80,53 +80,53 @@
 block discarded – undo
80 80
 
81 81
     public function crawler($con)
82 82
     {
83
-        if($con == "all") {
84
-            return ;
83
+        if ($con=="all") {
84
+            return;
85 85
         }
86
-        $this->con = $con;
87
-        $this->imgi = 1;
88
-        $problemModel = new ProblemModel();
89
-        $res = Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}");
90
-        if (strpos("No such problem",$res->body) !== false) {
86
+        $this->con=$con;
87
+        $this->imgi=1;
88
+        $problemModel=new ProblemModel();
89
+        $res=Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}");
90
+        if (strpos("No such problem", $res->body)!==false) {
91 91
             header('HTTP/1.1 404 Not Found');
92 92
             die();
93 93
         }
94
-        else if(strpos("Invalid Parameter.",$res->body) !== false) {
94
+        else if (strpos("Invalid Parameter.", $res->body)!==false) {
95 95
             header('HTTP/1.1 404 Not Found');
96 96
             die();
97 97
         }
98 98
         else {
99
-            $res->body = iconv("gb2312","utf-8//IGNORE",$res->body);
100
-            $this->pro['pcode'] = "HDU".$con;
101
-            $this->pro['OJ'] = 8;
102
-            $this->pro['contest_id'] = null;
103
-            $this->pro['index_id'] = $con;
104
-            $this->pro['origin'] = "http://acm.hdu.edu.cn/showproblem.php?pid={$con}";
105
-            $this->pro['title'] = self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/",$res->body);
106
-            $this->pro['time_limit'] = self::find('/Time Limit:.*\/(.*) MS/',$res->body);
107
-            $this->pro['memory_limit'] = self::find('/Memory Limit:.*\/(.*) K/',$res->body);
108
-            $this->pro['solved_count'] = self::find("/Accepted Submission(s): ([\d+]*?)/",$res->body);
99
+            $res->body=iconv("gb2312", "utf-8//IGNORE", $res->body);
100
+            $this->pro['pcode']="HDU".$con;
101
+            $this->pro['OJ']=8;
102
+            $this->pro['contest_id']=null;
103
+            $this->pro['index_id']=$con;
104
+            $this->pro['origin']="http://acm.hdu.edu.cn/showproblem.php?pid={$con}";
105
+            $this->pro['title']=self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/", $res->body);
106
+            $this->pro['time_limit']=self::find('/Time Limit:.*\/(.*) MS/', $res->body);
107
+            $this->pro['memory_limit']=self::find('/Memory Limit:.*\/(.*) K/', $res->body);
108
+            $this->pro['solved_count']=self::find("/Accepted Submission(s): ([\d+]*?)/", $res->body);
109 109
             $this->pro['input_type']='standard input';
110 110
             $this->pro['output_type']='standard output';
111
-            $this->pro['description'] = $this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body), true, true, DEFAULT_TARGET_CHARSET, false));
111
+            $this->pro['description']=$this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body), true, true, DEFAULT_TARGET_CHARSET, false));
112 112
             $this->pro['description']=str_replace("$", "$$", $this->pro['description']);
113
-            $this->pro['input'] = self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body);
113
+            $this->pro['input']=self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body);
114 114
             $this->pro['input']=str_replace("$", "$$", $this->pro['input']);
115
-            $this->pro['output'] = self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body);
115
+            $this->pro['output']=self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body);
116 116
             $this->pro['output']=str_replace("$", "$$", $this->pro['output']);
117
-            $this->pro['sample'] = [];
118
-            $this->pro['sample'][] = [
119
-                'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body),
120
-                'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body)
117
+            $this->pro['sample']=[];
118
+            $this->pro['sample'][]=[
119
+                'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU", $res->body),
120
+                'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU", $res->body)
121 121
             ];
122 122
             // $this->pro['sample']['sample_input'] = self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body);
123 123
             // $this->pro['sample']['sample_output'] = self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body);
124
-            $this->pro['note'] = self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU",$res->body);
125
-            $this->pro['source'] = strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU",$res->body));
126
-            if($this->pro['source'] === "") {
127
-                $this->pro['source'] = $this->pro['pcode'];
124
+            $this->pro['note']=self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU", $res->body);
125
+            $this->pro['source']=strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU", $res->body));
126
+            if ($this->pro['source']==="") {
127
+                $this->pro['source']=$this->pro['pcode'];
128 128
             }
129
-            $this->pro['force_raw'] = 0;
129
+            $this->pro['force_raw']=0;
130 130
             $problem=$problemModel->pid($this->pro['pcode']);
131 131
 
132 132
             if ($problem) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,12 +90,10 @@
 block discarded – undo
90 90
         if (strpos("No such problem",$res->body) !== false) {
91 91
             header('HTTP/1.1 404 Not Found');
92 92
             die();
93
-        }
94
-        else if(strpos("Invalid Parameter.",$res->body) !== false) {
93
+        } else if(strpos("Invalid Parameter.",$res->body) !== false) {
95 94
             header('HTTP/1.1 404 Not Found');
96 95
             die();
97
-        }
98
-        else {
96
+        } else {
99 97
             $res->body = iconv("gb2312","utf-8//IGNORE",$res->body);
100 98
             $this->pro['pcode'] = "HDU".$con;
101 99
             $this->pro['OJ'] = 8;
Please login to merge, or discard this patch.
app/Http/Controllers/MainController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,11 +56,11 @@
 block discarded – undo
56 56
     public function oldRedirect(Request $request)
57 57
     {
58 58
         $all_data=$request->all();
59
-        $method=isset($all_data["method"])?$all_data["method"]:null;
60
-        $id=isset($all_data["id"])?$all_data["id"]:null;
61
-        if($method=="showdetail" && !is_null($id)){
59
+        $method=isset($all_data["method"]) ? $all_data["method"] : null;
60
+        $id=isset($all_data["id"]) ? $all_data["id"] : null;
61
+        if ($method=="showdetail" && !is_null($id)) {
62 62
             $problemModel=new ProblemModel();
63
-            return ($problemModel->existPCode("NOJ$id"))?Redirect::route('problem_detail', ['pcode' => "NOJ$id"]):Redirect::route('problem_index');
63
+            return ($problemModel->existPCode("NOJ$id")) ?Redirect::route('problem_detail', ['pcode' => "NOJ$id"]) : Redirect::route('problem_index');
64 64
         }
65 65
         return Redirect::route('home');
66 66
     }
Please login to merge, or discard this patch.