@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | public function login($all_data) |
20 | 20 | { |
21 | - if(isset($all_data["url"])) $url = $all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = 'false'; |
|
25 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
21 | + if (isset($all_data["url"])) $url=$all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | + if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | + if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret='false'; |
|
25 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
26 | 26 | |
27 | 27 | $datapost=curl_init(); |
28 | 28 | $headers=array("Expect:"); |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | |
55 | 55 | public function grab_page($all_data) |
56 | 56 | { |
57 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | - if(isset($all_data["headers"])) $headers = $all_data["headers"]; else $headers = []; |
|
60 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
61 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = false; |
|
62 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
57 | + if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | + if (isset($all_data["headers"])) $headers=$all_data["headers"]; else $headers=[]; |
|
60 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
61 | + if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=false; |
|
62 | + if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
63 | 63 | |
64 | 64 | $handle=urlencode($handle); |
65 | 65 | |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | |
87 | 87 | public function post_data($all_data) |
88 | 88 | { |
89 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = false; |
|
93 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = true; |
|
94 | - if(isset($all_data["returnHeader"])) $returnHeader = $all_data["returnHeader"]; else $returnHeader = true; |
|
95 | - if(isset($all_data["postJson"])) $postJson = $all_data["postJson"]; else $postJson = false; |
|
96 | - if(isset($all_data["extraHeaders"])) $extraHeaders = $all_data["extraHeaders"]; else $extraHeaders = []; |
|
97 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
98 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
89 | + if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | + if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | + if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret=false; |
|
93 | + if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=true; |
|
94 | + if (isset($all_data["returnHeader"])) $returnHeader=$all_data["returnHeader"]; else $returnHeader=true; |
|
95 | + if (isset($all_data["postJson"])) $postJson=$all_data["postJson"]; else $postJson=false; |
|
96 | + if (isset($all_data["extraHeaders"])) $extraHeaders=$all_data["extraHeaders"]; else $extraHeaders=[]; |
|
97 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
98 | + if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
99 | 99 | |
100 | 100 | $handle=urlencode($handle); |
101 | 101 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $filter["rated"]=isset($all_data["rated"]) ? $all_data["rated"] : null; |
28 | 28 | $filter["anticheated"]=isset($all_data["anticheated"]) ? $all_data["anticheated"] : null; |
29 | 29 | $filter["practice"]=isset($all_data["practice"]) ? $all_data["practice"] : null; |
30 | - $return_list=$contestModel->list($filter,Auth::check()?Auth::user()->id:0); |
|
30 | + $return_list=$contestModel->list($filter, Auth::check() ?Auth::user()->id : 0); |
|
31 | 31 | $featured=$contestModel->featured(); |
32 | 32 | if (is_null($return_list)) { |
33 | 33 | if (isset($all_data["page"]) && $all_data["page"]>1) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $contestModel=new ContestModel(); |
67 | 67 | $groupModel=new GroupModel(); |
68 | 68 | $clearance=Auth::check() ? $contestModel->judgeClearance($cid, Auth::user()->id) : 0; |
69 | - $basic = $contestModel->basic($cid); |
|
69 | + $basic=$contestModel->basic($cid); |
|
70 | 70 | if (Auth::check()) { |
71 | 71 | $contest_detail=$contestModel->detail($cid, Auth::user()->id); |
72 | 72 | $registration=$contestModel->registration($cid, Auth::user()->id); |
@@ -76,7 +76,7 @@ |
||
76 | 76 | "spj_version" => null, |
77 | 77 | "spj_config" => null |
78 | 78 | ]; |
79 | - if($probBasic["spj"] && $probBasic["spj_version"]){ |
|
79 | + if ($probBasic["spj"] && $probBasic["spj_version"]) { |
|
80 | 80 | $submit_data["spj_version"]=$probBasic["spj_version"]; |
81 | 81 | $submit_data["spj_config"]=$probBasic["spj_lang"]; |
82 | 82 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | } |
65 | 65 | public function getLanguageConfigByLanguage($language, $spj=false) |
66 | 66 | { |
67 | - return $this->getLanguageConfigByKey($language.($spj?'_lang_spj_config':'_lang_config')); |
|
67 | + return $this->getLanguageConfigByKey($language.($spj ? '_lang_spj_config' : '_lang_config')); |
|
68 | 68 | } |
69 | 69 | public function getLanguageConfigByKey($key) |
70 | 70 | { |
@@ -13,20 +13,20 @@ |
||
13 | 13 | |
14 | 14 | public function search($key) |
15 | 15 | { |
16 | - $result = []; |
|
17 | - if(strlen($key) >= 2){ |
|
18 | - $ret = self::where('pcode', $key) |
|
19 | - ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)',[$key]) |
|
16 | + $result=[]; |
|
17 | + if (strlen($key)>=2) { |
|
18 | + $ret=self::where('pcode', $key) |
|
19 | + ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)', [$key]) |
|
20 | 20 | ->select('pcode', 'title') |
21 | 21 | ->limit(120) |
22 | 22 | ->get()->all(); |
23 | - if(!empty($ret)){ |
|
24 | - $result += $ret; |
|
23 | + if (!empty($ret)) { |
|
24 | + $result+=$ret; |
|
25 | 25 | } |
26 | 26 | } |
27 | - $problemModel = new ProblemModel(); |
|
27 | + $problemModel=new ProblemModel(); |
|
28 | 28 | foreach ($result as $p_index => $p) { |
29 | - if($problemModel->isBlocked($p['pid']) || $problemModel->isHidden($p["pid"])){ |
|
29 | + if ($problemModel->isBlocked($p['pid']) || $problemModel->isHidden($p["pid"])) { |
|
30 | 30 | unset($result[$p_index]); |
31 | 31 | } |
32 | 32 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | class AccountModel extends Model |
13 | 13 | { |
14 | - private $user_extra = [ |
|
14 | + private $user_extra=[ |
|
15 | 15 | 0 => 'gender', |
16 | 16 | 1 => 'contact', |
17 | 17 | 2 => 'school', |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | 1004 => 'github_token', |
27 | 27 | ]; |
28 | 28 | |
29 | - private $socialite_support = [ |
|
29 | + private $socialite_support=[ |
|
30 | 30 | //use the form "platform_id" for unique authentication |
31 | 31 | //such as github_id |
32 | 32 | 'github' => [ |
33 | - 'email','nickname','homepage','token' |
|
33 | + 'email', 'nickname', 'homepage', 'token' |
|
34 | 34 | ], |
35 | 35 | ]; |
36 | 36 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | public function feed($uid=null) |
49 | 49 | { |
50 | 50 | $ret=[]; |
51 | - $solution=DB::table("problem_solution")->join("problem","problem.pid","=","problem_solution.pid")->where(["uid"=>$uid,"audit"=>1])->select("problem.pid as pid","pcode","title","problem_solution.created_at as created_at")->orderBy("problem_solution.created_at","DESC")->get()->all(); |
|
52 | - foreach($solution as &$s){ |
|
51 | + $solution=DB::table("problem_solution")->join("problem", "problem.pid", "=", "problem_solution.pid")->where(["uid"=>$uid, "audit"=>1])->select("problem.pid as pid", "pcode", "title", "problem_solution.created_at as created_at")->orderBy("problem_solution.created_at", "DESC")->get()->all(); |
|
52 | + foreach ($solution as &$s) { |
|
53 | 53 | $s["type"]="event"; |
54 | 54 | $s["color"]="wemd-orange"; |
55 | 55 | $s["icon"]="comment-check-outline"; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function generateContestAccount($cid, $ccode, $num) |
62 | 62 | { |
63 | 63 | $ret=[]; |
64 | - $starting=DB::table("users")->where('prefix','=',$ccode)->count(); |
|
64 | + $starting=DB::table("users")->where('prefix', '=', $ccode)->count(); |
|
65 | 65 | $contestModel=new ContestModel(); |
66 | 66 | for ($i=1; $i<=$num; $i++) { |
67 | 67 | $pass=$this->generatePassword(); |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | ])->join("problem", "problem.pid", "=", "submission.pid")->select('pcode')->distinct()->get()->all(); |
121 | 121 | $ret["solvedCount"]=count($ret["solved"]); |
122 | 122 | // Casual |
123 | - $ret["rank"]=Cache::tags(['rank',$ret["id"]])->get("rank", "N/A"); |
|
124 | - $ret["rankTitle"]=Cache::tags(['rank',$ret["id"]])->get("title", "Recruit"); |
|
123 | + $ret["rank"]=Cache::tags(['rank', $ret["id"]])->get("rank", "N/A"); |
|
124 | + $ret["rankTitle"]=Cache::tags(['rank', $ret["id"]])->get("title", "Recruit"); |
|
125 | 125 | $ret["rankTitleColor"]=RankModel::getColor($ret["rankTitle"]); |
126 | 126 | // Professional |
127 | 127 | $ret["professionalTitle"]=RankModel::getProfessionalTitle($ret["professional_rate"]); |
128 | 128 | $ret["professionalTitleColor"]=RankModel::getProfessionalColor($ret["professionalTitle"]); |
129 | 129 | // Administration Group |
130 | - $ret["admin"]=$uid==1?1:0; |
|
130 | + $ret["admin"]=$uid==1 ? 1 : 0; |
|
131 | 131 | if (Cache::tags(['bing', 'pic'])->get(date("Y-m-d"))==null) { |
132 | 132 | $bing=new BingPhoto([ |
133 | 133 | 'locale' => 'zh-CN', |
@@ -146,26 +146,26 @@ discard block |
||
146 | 146 | * @param string|array $need An array is returned when an array is passed in,Only one value is returned when a string is passed in. |
147 | 147 | * @return string|array $result |
148 | 148 | */ |
149 | - public function getExtra($uid,$need, $secret_level = 0){ |
|
150 | - $ret = DB::table('users_extra')->where('uid',$uid)->orderBy('key')->get()->all(); |
|
151 | - $result = []; |
|
152 | - if(!empty($ret)){ |
|
153 | - if(is_string($need)){ |
|
149 | + public function getExtra($uid, $need, $secret_level=0) { |
|
150 | + $ret=DB::table('users_extra')->where('uid', $uid)->orderBy('key')->get()->all(); |
|
151 | + $result=[]; |
|
152 | + if (!empty($ret)) { |
|
153 | + if (is_string($need)) { |
|
154 | 154 | foreach ($ret as $value) { |
155 | - if(empty($value['secret_level']) || $value['secret_level'] <= $secret_level){ |
|
156 | - $key_name = $this->user_extra[$value['key']] ?? 'unknown'; |
|
157 | - if($key_name == $need){ |
|
155 | + if (empty($value['secret_level']) || $value['secret_level']<=$secret_level) { |
|
156 | + $key_name=$this->user_extra[$value['key']] ?? 'unknown'; |
|
157 | + if ($key_name==$need) { |
|
158 | 158 | return $value['value']; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | return null; |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | foreach ($ret as $value) { |
165 | - if(empty($value['secret_level']) || $value['secret_level'] <= $secret_level){ |
|
166 | - $key_name = $this->user_extra[$value['key']] ?? 'unknown'; |
|
167 | - if(in_array($key_name,$need)){ |
|
168 | - $result[$key_name] = $value['value']; |
|
165 | + if (empty($value['secret_level']) || $value['secret_level']<=$secret_level) { |
|
166 | + $key_name=$this->user_extra[$value['key']] ?? 'unknown'; |
|
167 | + if (in_array($key_name, $need)) { |
|
168 | + $result[$key_name]=$value['value']; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * @param string|null $value the extra info will be delete when value is null |
183 | 183 | * @return mixed $result |
184 | 184 | */ |
185 | - public function setExtra($uid,$key_name,$value = null,$secret_level = -1){ |
|
186 | - $key = array_search($key_name,$this->user_extra); |
|
187 | - if($key === false){ |
|
185 | + public function setExtra($uid, $key_name, $value=null, $secret_level=-1) { |
|
186 | + $key=array_search($key_name, $this->user_extra); |
|
187 | + if ($key===false) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | - $ret = DB::table('users_extra')->where('uid',$uid)->where('key',$key)->first(); |
|
191 | - if(!empty($ret)){ |
|
190 | + $ret=DB::table('users_extra')->where('uid', $uid)->where('key', $key)->first(); |
|
191 | + if (!empty($ret)) { |
|
192 | 192 | unset($ret['id']); |
193 | - if(!is_null($value)){ |
|
194 | - $ret['value'] = $value; |
|
195 | - }else{ |
|
196 | - DB::table('users_extra')->where('uid',$uid)->where('key',$key)->delete(); |
|
193 | + if (!is_null($value)) { |
|
194 | + $ret['value']=$value; |
|
195 | + } else { |
|
196 | + DB::table('users_extra')->where('uid', $uid)->where('key', $key)->delete(); |
|
197 | 197 | return true; |
198 | 198 | } |
199 | - if($secret_level != -1){ |
|
200 | - $ret['secret_level'] = $secret_level; |
|
199 | + if ($secret_level!=-1) { |
|
200 | + $ret['secret_level']=$secret_level; |
|
201 | 201 | } |
202 | - return DB::table('users_extra')->where('uid',$uid)->where('key',$key)->update($ret); |
|
203 | - }else{ |
|
204 | - if($value === null){ |
|
202 | + return DB::table('users_extra')->where('uid', $uid)->where('key', $key)->update($ret); |
|
203 | + } else { |
|
204 | + if ($value===null) { |
|
205 | 205 | return true; |
206 | 206 | } |
207 | 207 | return DB::table('users_extra')->insertGetId( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | 'uid' => $uid, |
210 | 210 | 'key' => $key, |
211 | 211 | 'value' => $value, |
212 | - 'secret_level' => $secret_level == -1 ? 0 : $secret_level, |
|
212 | + 'secret_level' => $secret_level==-1 ? 0 : $secret_level, |
|
213 | 213 | ] |
214 | 214 | ); |
215 | 215 | } |
@@ -221,33 +221,33 @@ discard block |
||
221 | 221 | * @param string $value the value |
222 | 222 | * @return string $result |
223 | 223 | */ |
224 | - public function findExtra($key,$value) |
|
224 | + public function findExtra($key, $value) |
|
225 | 225 | { |
226 | - $key = array_search($key,$this->user_extra); |
|
227 | - if($key){ |
|
228 | - return DB::table('users_extra')->where('key',$key)->where('value',$value)->first(); |
|
229 | - }else{ |
|
226 | + $key=array_search($key, $this->user_extra); |
|
227 | + if ($key) { |
|
228 | + return DB::table('users_extra')->where('key', $key)->where('value', $value)->first(); |
|
229 | + } else { |
|
230 | 230 | return null; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | - public function getSocialiteInfo($uid,$secret_level = -1) |
|
234 | + public function getSocialiteInfo($uid, $secret_level=-1) |
|
235 | 235 | { |
236 | - $socialites = []; |
|
236 | + $socialites=[]; |
|
237 | 237 | foreach ($this->socialite_support as $key => $value) { |
238 | - $id_keyname = $key.'_id'; |
|
239 | - $id = $this->getExtra($uid,$id_keyname); |
|
240 | - if(!empty($id)){ |
|
241 | - $info = [ |
|
238 | + $id_keyname=$key.'_id'; |
|
239 | + $id=$this->getExtra($uid, $id_keyname); |
|
240 | + if (!empty($id)) { |
|
241 | + $info=[ |
|
242 | 242 | 'id' => $id, |
243 | 243 | ]; |
244 | 244 | foreach ($value as $info_name) { |
245 | - $info_temp = $this->getExtra($uid,$key.'_'.$info_name); |
|
246 | - if($info_temp !== null){ |
|
247 | - $info[$info_name] = $info_temp; |
|
245 | + $info_temp=$this->getExtra($uid, $key.'_'.$info_name); |
|
246 | + if ($info_temp!==null) { |
|
247 | + $info[$info_name]=$info_temp; |
|
248 | 248 | } |
249 | 249 | } |
250 | - $socialites[$key] = $info; |
|
250 | + $socialites[$key]=$info; |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | $grid->column('sid', "ID")->sortable(); |
84 | 84 | $grid->time("Time"); |
85 | 85 | $grid->memory("Memory"); |
86 | - $grid->verdict("Verdict")->display(function ($verdict) { |
|
86 | + $grid->verdict("Verdict")->display(function($verdict) { |
|
87 | 87 | return '<i class="fa fa-circle '.$this->color.'"></i> '.$verdict; |
88 | 88 | }); |
89 | 89 | $grid->language("Language"); |
90 | - $grid->submission_date("Submission Date")->display(function ($submission_date) { |
|
90 | + $grid->submission_date("Submission Date")->display(function($submission_date) { |
|
91 | 91 | return date("Y-m-d H:i:s", $submission_date); |
92 | 92 | }); |
93 | 93 | ; |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | $grid->jid("JID"); |
98 | 98 | $grid->coid("COID"); |
99 | 99 | $grid->score("Raw Score"); |
100 | - $grid->filter(function (Grid\Filter $filter) { |
|
101 | - $filter->column(6, function ($filter) { |
|
100 | + $grid->filter(function(Grid\Filter $filter) { |
|
101 | + $filter->column(6, function($filter) { |
|
102 | 102 | $filter->like('verdict'); |
103 | 103 | }); |
104 | - $filter->column(6, function ($filter) { |
|
104 | + $filter->column(6, function($filter) { |
|
105 | 105 | $filter->equal('cid', 'Contest ID'); |
106 | 106 | $filter->equal('uid', 'User ID'); |
107 | 107 | $filter->equal('pid', 'Problem ID'); |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | $show->coid('COID'); |
139 | 139 | $show->vcid('VCID'); |
140 | 140 | $show->score(); |
141 | - $show->share()->using(['No','Yes']); |
|
141 | + $show->share()->using(['No', 'Yes']); |
|
142 | 142 | return $show; |
143 | 143 | } |
144 | 144 | |
145 | 145 | private function codify($field, $lang=null) |
146 | 146 | { |
147 | - $field->unescape()->as(function ($value) use ($field,$lang) { |
|
148 | - $field->border = false; |
|
147 | + $field->unescape()->as(function($value) use ($field, $lang) { |
|
148 | + $field->border=false; |
|
149 | 149 | $hash=md5($value); |
150 | 150 | if (blank($value)) { |
151 | 151 | $value=" "; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $form=new Form(new EloquentSubmissionModel); |
188 | 188 | $form->model()->makeVisible('password'); |
189 | - $form->tab('Basic', function (Form $form) { |
|
189 | + $form->tab('Basic', function(Form $form) { |
|
190 | 190 | $form->display('sid'); |
191 | 191 | $form->text('time')->rules('required'); |
192 | 192 | $form->text('memory')->rules('required'); |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | $prob_detail["pdf"]=false; |
49 | 49 | $prob_detail["viewerShow"]=false; |
50 | 50 | $prob_detail["file_ext"]=null; |
51 | - if($prob_detail['file'] && !blank($prob_detail['file_url'])){ |
|
52 | - $prob_detail["file_ext"]=explode('.',basename($prob_detail['file_url'])); |
|
51 | + if ($prob_detail['file'] && !blank($prob_detail['file_url'])) { |
|
52 | + $prob_detail["file_ext"]=explode('.', basename($prob_detail['file_url'])); |
|
53 | 53 | $prob_detail["file_ext"]=end($prob_detail["file_ext"]); |
54 | 54 | $prob_detail["pdf"]=Str::is("*.pdf", basename($prob_detail['file_url'])); |
55 | - $prob_detail["viewerShow"]= blank($prob_detail["parsed"]["description"]) && |
|
55 | + $prob_detail["viewerShow"]=blank($prob_detail["parsed"]["description"]) && |
|
56 | 56 | blank($prob_detail["parsed"]["input"]) && |
57 | 57 | blank($prob_detail["parsed"]["output"]) && |
58 | 58 | blank($prob_detail["parsed"]["note"]); |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | |
195 | 195 | private function inteliAudit($uid, $content) |
196 | 196 | { |
197 | - if (strpos($content, '```')!==false){ |
|
197 | + if (strpos($content, '```')!==false) { |
|
198 | 198 | $userSolutionHistory=DB::table("problem_solution")->where(['uid'=>$uid])->orderByDesc('updated_at')->first(); |
199 | - if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1){ |
|
199 | + if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1) { |
|
200 | 200 | return 1; |
201 | 201 | } |
202 | 202 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | // $prob_list = DB::table($this->table)->select("pid","pcode","title")->get()->all(); // return a array |
294 | 294 | $submissionModel=new SubmissionModel(); |
295 | - $preQuery=DB::table($this->table)->where('hide','=',0); |
|
295 | + $preQuery=DB::table($this->table)->where('hide', '=', 0); |
|
296 | 296 | if ($filter['oj']) { |
297 | 297 | $preQuery=$preQuery->where(["OJ"=>$filter['oj']]); |
298 | 298 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | |
447 | 447 | if (!empty($data["sample"])) { |
448 | 448 | foreach ($data["sample"] as $d) { |
449 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
449 | + if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
450 | 450 | DB::table("problem_sample")->insert([ |
451 | 451 | 'pid'=>$pid, |
452 | 452 | 'sample_input'=>$d['sample_input'], |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | |
493 | 493 | if (!empty($data["sample"])) { |
494 | 494 | foreach ($data["sample"] as $d) { |
495 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
495 | + if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
496 | 496 | DB::table("problem_sample")->insert([ |
497 | 497 | 'pid'=>$pid, |
498 | 498 | 'sample_input'=>$d['sample_input'], |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | public function discussionList($pid) |
509 | 509 | { |
510 | - $paginator = DB::table('problem_discussion')->join( |
|
510 | + $paginator=DB::table('problem_discussion')->join( |
|
511 | 511 | "users", |
512 | 512 | "id", |
513 | 513 | "=", |
@@ -526,10 +526,10 @@ discard block |
||
526 | 526 | 'users.name', |
527 | 527 | 'users.id as uid' |
528 | 528 | ])->paginate(15); |
529 | - $list = $paginator->all(); |
|
530 | - foreach($list as &$l){ |
|
531 | - $l['updated_at'] = $this->formatTime($l['updated_at']); |
|
532 | - $l['comment_count'] = DB::table('problem_discussion_comment')->where('pdid','=',$l['pdid'])->count(); |
|
529 | + $list=$paginator->all(); |
|
530 | + foreach ($list as &$l) { |
|
531 | + $l['updated_at']=$this->formatTime($l['updated_at']); |
|
532 | + $l['comment_count']=DB::table('problem_discussion_comment')->where('pdid', '=', $l['pdid'])->count(); |
|
533 | 533 | } |
534 | 534 | return [ |
535 | 535 | 'paginator' => $paginator, |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | public function discussionDetail($pdid) |
574 | 574 | { |
575 | - $main = DB::table('problem_discussion')->join( |
|
575 | + $main=DB::table('problem_discussion')->join( |
|
576 | 576 | "users", |
577 | 577 | "id", |
578 | 578 | "=", |
@@ -591,12 +591,12 @@ discard block |
||
591 | 591 | 'users.name', |
592 | 592 | 'users.id as uid' |
593 | 593 | ])->get()->first(); |
594 | - $main['created_at'] = $this->formatTime($main['created_at']); |
|
594 | + $main['created_at']=$this->formatTime($main['created_at']); |
|
595 | 595 | $main['content']=clean(Markdown::convertToHtml($main["content"])); |
596 | 596 | |
597 | - $comment_count = DB::table('problem_discussion_comment')->where('pdid','=',$pdid)->count(); |
|
597 | + $comment_count=DB::table('problem_discussion_comment')->where('pdid', '=', $pdid)->count(); |
|
598 | 598 | |
599 | - $paginator = DB::table('problem_discussion_comment')->join( |
|
599 | + $paginator=DB::table('problem_discussion_comment')->join( |
|
600 | 600 | "users", |
601 | 601 | "id", |
602 | 602 | "=", |
@@ -615,11 +615,11 @@ discard block |
||
615 | 615 | 'users.name', |
616 | 616 | 'users.id as uid' |
617 | 617 | ])->paginate(10); |
618 | - $comment = $paginator->all(); |
|
619 | - foreach($comment as &$c){ |
|
618 | + $comment=$paginator->all(); |
|
619 | + foreach ($comment as &$c) { |
|
620 | 620 | $c['content']=clean(Markdown::convertToHtml($c["content"])); |
621 | - $c['created_at'] = $this->formatTime($c['created_at']); |
|
622 | - $c['reply'] = DB::table('problem_discussion_comment')->join( |
|
621 | + $c['created_at']=$this->formatTime($c['created_at']); |
|
622 | + $c['reply']=DB::table('problem_discussion_comment')->join( |
|
623 | 623 | "users", |
624 | 624 | "id", |
625 | 625 | "=", |
@@ -647,20 +647,20 @@ discard block |
||
647 | 647 | 'users.name', |
648 | 648 | 'users.id as uid' |
649 | 649 | ])->get()->all(); |
650 | - foreach($c['reply'] as $k=>&$cr){ |
|
650 | + foreach ($c['reply'] as $k=>&$cr) { |
|
651 | 651 | $cr['content']=clean(Markdown::convertToHtml($cr["content"])); |
652 | - $cr['reply_uid'] = DB::table('problem_discussion_comment')->where( |
|
652 | + $cr['reply_uid']=DB::table('problem_discussion_comment')->where( |
|
653 | 653 | 'pdcid', |
654 | 654 | '=', |
655 | 655 | $cr['reply_id'] |
656 | 656 | )->get()->first()['uid']; |
657 | - $cr['reply_name'] = DB::table('users')->where( |
|
657 | + $cr['reply_name']=DB::table('users')->where( |
|
658 | 658 | 'id', |
659 | 659 | '=', |
660 | 660 | $cr['reply_uid'] |
661 | 661 | )->get()->first()['name']; |
662 | - $cr['created_at'] = $this->formatTime($cr['created_at']); |
|
663 | - if($this->replyParent($cr['pdcid'])!=$c['pdcid']){ |
|
662 | + $cr['created_at']=$this->formatTime($cr['created_at']); |
|
663 | + if ($this->replyParent($cr['pdcid'])!=$c['pdcid']) { |
|
664 | 664 | unset($c['reply'][$k]); |
665 | 665 | } |
666 | 666 | } |
@@ -675,19 +675,19 @@ discard block |
||
675 | 675 | |
676 | 676 | public function replyParent($pdcid) |
677 | 677 | { |
678 | - $reply_id=DB::table('problem_discussion_comment')->where('pdcid','=',$pdcid)->get()->first()['reply_id']; |
|
679 | - $top=DB::table('problem_discussion_comment')->where('pdcid','=',$reply_id)->get()->first()['reply_id']; |
|
680 | - if(isset($top)){ |
|
678 | + $reply_id=DB::table('problem_discussion_comment')->where('pdcid', '=', $pdcid)->get()->first()['reply_id']; |
|
679 | + $top=DB::table('problem_discussion_comment')->where('pdcid', '=', $reply_id)->get()->first()['reply_id']; |
|
680 | + if (isset($top)) { |
|
681 | 681 | return $this->replyParent($reply_id); |
682 | - }else{ |
|
682 | + } else { |
|
683 | 683 | return $reply_id; |
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
687 | 687 | public function pcodeByPdid($dcode) |
688 | 688 | { |
689 | - $pid = DB::table('problem_discussion')->where('pdid','=',$dcode)->get()->first()['pid']; |
|
690 | - $pcode = $this->pcode($pid); |
|
689 | + $pid=DB::table('problem_discussion')->where('pdid', '=', $dcode)->get()->first()['pid']; |
|
690 | + $pcode=$this->pcode($pid); |
|
691 | 691 | return $pcode; |
692 | 692 | } |
693 | 693 | |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | |
709 | 709 | public function pidByPdid($pdid) |
710 | 710 | { |
711 | - $pid = DB::table('problem_discussion')->where('pdid','=',$pdid)->get()->first()['pid']; |
|
711 | + $pid=DB::table('problem_discussion')->where('pdid', '=', $pdid)->get()->first()['pid']; |
|
712 | 712 | return $pid; |
713 | 713 | } |
714 | 714 | |
715 | - public function addComment($uid,$pdid,$content,$reply_id) |
|
715 | + public function addComment($uid, $pdid, $content, $reply_id) |
|
716 | 716 | { |
717 | 717 | $pid=$this->pidByPdid($pdid); |
718 | 718 | $pdcid=DB::table('problem_discussion_comment')->insertGetId([ |
@@ -731,6 +731,6 @@ discard block |
||
731 | 731 | |
732 | 732 | public function isHidden($pid) |
733 | 733 | { |
734 | - return DB::table('problem')->where('pid','=',$pid)->get()->first()['hide']; |
|
734 | + return DB::table('problem')->where('pid', '=', $pid)->get()->first()['hide']; |
|
735 | 735 | } |
736 | 736 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | $ret=[]; |
23 | 23 | $marketspaceRaw=self::getRemote(); |
24 | 24 | $marketspace=[]; |
25 | - foreach($marketspaceRaw["packages"] as $extension){ |
|
25 | + foreach ($marketspaceRaw["packages"] as $extension) { |
|
26 | 26 | $marketspace[$extension["name"]]=$extension; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $localList=self::getLocal(); |
30 | 30 | |
31 | - foreach($localList as $extension){ |
|
31 | + foreach ($localList as $extension) { |
|
32 | 32 | $temp=[ |
33 | 33 | "details"=>$extension, |
34 | 34 | "status"=>0, |
@@ -37,30 +37,30 @@ discard block |
||
37 | 37 | "settings"=>null, |
38 | 38 | "available"=>null |
39 | 39 | ]; |
40 | - $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge"; |
|
40 | + $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge"; |
|
41 | 41 | try { |
42 | 42 | if ($extension["version"]=='__cur__') { |
43 | 43 | $extension["version"]=explode("-", version())[0]; |
44 | 44 | } |
45 | 45 | $downloadedVersion=new Version($extension["version"]); |
46 | 46 | |
47 | - if(isset($marketspace[$extension["name"]])){ |
|
47 | + if (isset($marketspace[$extension["name"]])) { |
|
48 | 48 | //remote extension, else is local extension |
49 | 49 | $remoteVersion=new Version($marketspace[$extension["name"]]["version"]); |
50 | 50 | $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion); |
51 | 51 | $temp["details"]["official"]=$marketspace[$extension["name"]]["official"]; |
52 | - } else{ |
|
52 | + } else { |
|
53 | 53 | $temp["updatable"]=false; |
54 | 54 | $temp["details"]["official"]=0; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first(); |
58 | - if (is_null($installedConfig)){ |
|
58 | + if (is_null($installedConfig)) { |
|
59 | 59 | $temp["status"]=1; |
60 | 60 | } else { |
61 | 61 | $temp["version"]=$installedConfig->version; // local installed version |
62 | 62 | $installedVersion=new Version($temp["version"]); |
63 | - if ($downloadedVersion->isGreaterThan($installedVersion)){ |
|
63 | + if ($downloadedVersion->isGreaterThan($installedVersion)) { |
|
64 | 64 | $temp["status"]=1; |
65 | 65 | } else { |
66 | 66 | $temp["status"]=2; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $temp["settings"]=false; |
69 | 69 | $temp["available"]=$installedConfig->status; |
70 | 70 | } |
71 | - }catch (Throwable $e){ |
|
71 | + } catch (Throwable $e) { |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | $ret[]=$temp; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | { |
81 | 81 | $ret=[]; |
82 | 82 | $marketspaceRaw=self::getRemote(); |
83 | - if(empty($marketspaceRaw)) return []; |
|
84 | - foreach($marketspaceRaw["packages"] as $extension){ |
|
83 | + if (empty($marketspaceRaw)) return []; |
|
84 | + foreach ($marketspaceRaw["packages"] as $extension) { |
|
85 | 85 | $temp=[ |
86 | 86 | "details"=>$extension, |
87 | 87 | "status"=>0, |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | "settings"=>null, |
91 | 91 | "available"=>null |
92 | 92 | ]; |
93 | - $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge"; |
|
93 | + $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge"; |
|
94 | 94 | try { |
95 | 95 | try { |
96 | 96 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true); |
97 | - }catch (Throwable $e){ |
|
97 | + } catch (Throwable $e) { |
|
98 | 98 | $BabelConfig=[]; |
99 | 99 | } |
100 | 100 | if (!empty($BabelConfig)) { |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion); |
107 | 107 | |
108 | 108 | $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first(); |
109 | - if (is_null($installedConfig)){ |
|
109 | + if (is_null($installedConfig)) { |
|
110 | 110 | $temp["status"]=1; |
111 | 111 | } else { |
112 | 112 | $temp["version"]=$installedConfig->version; // local installed version |
113 | 113 | $installedVersion=new Version($temp["version"]); |
114 | - if ($downloadedVersion->isGreaterThan($installedVersion)){ |
|
114 | + if ($downloadedVersion->isGreaterThan($installedVersion)) { |
|
115 | 115 | $temp["status"]=1; |
116 | 116 | } else { |
117 | 117 | $temp["status"]=2; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $temp["available"]=$installedConfig->status; |
121 | 121 | } |
122 | 122 | } |
123 | - }catch (Throwable $e){ |
|
123 | + } catch (Throwable $e) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | $ret[]=$temp; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | public static function getLocal() |
133 | 133 | { |
134 | 134 | $ret=[]; |
135 | - $dirs = array_filter(glob(babel_path("Extension/*")), 'is_dir'); |
|
136 | - foreach($dirs as $d){ |
|
135 | + $dirs=array_filter(glob(babel_path("Extension/*")), 'is_dir'); |
|
136 | + foreach ($dirs as $d) { |
|
137 | 137 | $extension=basename($d); |
138 | 138 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$extension/babel.json")), true); |
139 | - if($extension==$BabelConfig["code"]) $ret[]=$BabelConfig; |
|
139 | + if ($extension==$BabelConfig["code"]) $ret[]=$BabelConfig; |
|
140 | 140 | } |
141 | 141 | return $ret; |
142 | 142 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | try { |
147 | 147 | return json_decode(file_get_contents(config('babel.mirror')."/babel.json"), true); |
148 | - }catch(Throwable $e){ |
|
148 | + } catch (Throwable $e) { |
|
149 | 149 | return []; |
150 | 150 | } |
151 | 151 | } |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | public static function remoteDetail($code) |
154 | 154 | { |
155 | 155 | $babelConfig=self::getRemote(); |
156 | - if(empty($babelConfig)) return []; |
|
156 | + if (empty($babelConfig)) return []; |
|
157 | 157 | $babelConfigPackages=$babelConfig["packages"]; |
158 | - foreach($babelConfigPackages as $package) { |
|
159 | - if($package["code"]==$code) return $package; |
|
158 | + foreach ($babelConfigPackages as $package) { |
|
159 | + if ($package["code"]==$code) return $package; |
|
160 | 160 | } |
161 | 161 | return []; |
162 | 162 | } |