@@ -15,26 +15,26 @@ |
||
15 | 15 | |
16 | 16 | public function search($key) |
17 | 17 | { |
18 | - $result = []; |
|
18 | + $result=[]; |
|
19 | 19 | //contest name find |
20 | - if(strlen($key) >= 2){ |
|
21 | - $ret = self::whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key]) |
|
20 | + if (strlen($key)>=2) { |
|
21 | + $ret=self::whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key]) |
|
22 | 22 | ->select('cid', 'gid', 'name', 'rule', 'public', 'verified', 'practice', 'rated', 'anticheated', 'begin_time', 'end_time') |
23 | - ->orderBy('end_time','DESC') |
|
23 | + ->orderBy('end_time', 'DESC') |
|
24 | 24 | ->limit(120) |
25 | 25 | ->get()->all(); |
26 | - $user_id = Auth::user()->id; |
|
27 | - $contestModel = new ContestModel(); |
|
28 | - foreach($ret as $c_index => $c){ |
|
29 | - if(!$contestModel->judgeClearance($c['cid'],$user_id)){ |
|
26 | + $user_id=Auth::user()->id; |
|
27 | + $contestModel=new ContestModel(); |
|
28 | + foreach ($ret as $c_index => $c) { |
|
29 | + if (!$contestModel->judgeClearance($c['cid'], $user_id)) { |
|
30 | 30 | unset($ret[$c_index]); |
31 | 31 | } |
32 | 32 | } |
33 | - if(!empty($ret)){ |
|
34 | - $result += $ret; |
|
33 | + if (!empty($ret)) { |
|
34 | + $result+=$ret; |
|
35 | 35 | } |
36 | 36 | } |
37 | - if(!empty($result)) { |
|
37 | + if (!empty($result)) { |
|
38 | 38 | foreach ($result as &$contest) { |
39 | 39 | $contest["rule_parsed"]=$this->rule[$contest["rule"]]; |
40 | 40 | $contest["date_parsed"]=[ |
@@ -10,16 +10,16 @@ |
||
10 | 10 | |
11 | 11 | public function search($key) |
12 | 12 | { |
13 | - $result = []; |
|
14 | - if(strlen($key) >= 2){ |
|
15 | - $ret = self::where('email',$key) |
|
16 | - ->orWhereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key]) |
|
17 | - ->select('id','avatar', 'name', 'describes', 'professional_rate') |
|
18 | - ->orderBy('professional_rate','DESC') |
|
13 | + $result=[]; |
|
14 | + if (strlen($key)>=2) { |
|
15 | + $ret=self::where('email', $key) |
|
16 | + ->orWhereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key]) |
|
17 | + ->select('id', 'avatar', 'name', 'describes', 'professional_rate') |
|
18 | + ->orderBy('professional_rate', 'DESC') |
|
19 | 19 | ->limit(120) |
20 | 20 | ->get()->all(); |
21 | - if(!empty($ret)){ |
|
22 | - $result += $ret; |
|
21 | + if (!empty($ret)) { |
|
22 | + $result+=$ret; |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | return $result; |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | { |
22 | 22 | $ret=[]; |
23 | 23 | $marketspaceRaw=self::getRemote(); |
24 | - if(empty($marketspaceRaw)) return []; |
|
25 | - foreach($marketspaceRaw["packages"] as $extension){ |
|
24 | + if (empty($marketspaceRaw)) return []; |
|
25 | + foreach ($marketspaceRaw["packages"] as $extension) { |
|
26 | 26 | $temp=[ |
27 | 27 | "details"=>$extension, |
28 | 28 | "status"=>0, |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | "settings"=>null, |
32 | 32 | "available"=>null |
33 | 33 | ]; |
34 | - $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge"; |
|
34 | + $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge"; |
|
35 | 35 | try { |
36 | 36 | try { |
37 | 37 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true); |
38 | - }catch (Throwable $e){ |
|
38 | + } catch (Throwable $e) { |
|
39 | 39 | $BabelConfig=[]; |
40 | 40 | } |
41 | 41 | if (!empty($BabelConfig)) { |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion); |
48 | 48 | |
49 | 49 | $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first(); |
50 | - if (is_null($installedConfig)){ |
|
50 | + if (is_null($installedConfig)) { |
|
51 | 51 | $temp["status"]=1; |
52 | 52 | } else { |
53 | 53 | $temp["version"]=$installedConfig->version; // local installed version |
54 | 54 | $installedVersion=new Version($temp["version"]); |
55 | - if ($downloadedVersion->isGreaterThan($installedVersion)){ |
|
55 | + if ($downloadedVersion->isGreaterThan($installedVersion)) { |
|
56 | 56 | $temp["status"]=1; |
57 | 57 | } else { |
58 | 58 | $temp["status"]=2; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $temp["available"]=$installedConfig->status; |
62 | 62 | } |
63 | 63 | } |
64 | - }catch (Throwable $e){ |
|
64 | + } catch (Throwable $e) { |
|
65 | 65 | $temp["status"]=-1; |
66 | 66 | } |
67 | 67 | $ret[]=$temp; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | try { |
76 | 76 | return json_decode(file_get_contents(env("BABEL_MIRROR", "https://acm.njupt.edu.cn/babel")."/babel.json"), true); |
77 | - }catch(Throwable $e){ |
|
77 | + } catch (Throwable $e) { |
|
78 | 78 | return []; |
79 | 79 | } |
80 | 80 | } |
@@ -21,7 +21,9 @@ discard block |
||
21 | 21 | { |
22 | 22 | $ret=[]; |
23 | 23 | $marketspaceRaw=self::getRemote(); |
24 | - if(empty($marketspaceRaw)) return []; |
|
24 | + if(empty($marketspaceRaw)) { |
|
25 | + return []; |
|
26 | + } |
|
25 | 27 | foreach($marketspaceRaw["packages"] as $extension){ |
26 | 28 | $temp=[ |
27 | 29 | "details"=>$extension, |
@@ -35,7 +37,7 @@ discard block |
||
35 | 37 | try { |
36 | 38 | try { |
37 | 39 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true); |
38 | - }catch (Throwable $e){ |
|
40 | + } catch (Throwable $e){ |
|
39 | 41 | $BabelConfig=[]; |
40 | 42 | } |
41 | 43 | if (!empty($BabelConfig)) { |
@@ -61,7 +63,7 @@ discard block |
||
61 | 63 | $temp["available"]=$installedConfig->status; |
62 | 64 | } |
63 | 65 | } |
64 | - }catch (Throwable $e){ |
|
66 | + } catch (Throwable $e){ |
|
65 | 67 | $temp["status"]=-1; |
66 | 68 | } |
67 | 69 | $ret[]=$temp; |
@@ -74,7 +76,7 @@ discard block |
||
74 | 76 | { |
75 | 77 | try { |
76 | 78 | return json_decode(file_get_contents(env("BABEL_MIRROR", "https://acm.njupt.edu.cn/babel")."/babel.json"), true); |
77 | - }catch(Throwable $e){ |
|
79 | + } catch(Throwable $e){ |
|
78 | 80 | return []; |
79 | 81 | } |
80 | 82 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | "name"=>$versionInfo[0]["name"], |
25 | 25 | "updatable"=>$updatable |
26 | 26 | ]; |
27 | - }catch(Throwable $e){ |
|
27 | + } catch (Throwable $e) { |
|
28 | 28 | return null; |
29 | 29 | } |
30 | 30 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | "name"=>$versionInfo[0]["name"], |
25 | 25 | "updatable"=>$updatable |
26 | 26 | ]; |
27 | - }catch(Throwable $e){ |
|
27 | + } catch(Throwable $e){ |
|
28 | 28 | return null; |
29 | 29 | } |
30 | 30 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | } catch (ErrorException $e) { |
24 | 24 | } catch (Exception $e) { |
25 | 25 | } |
26 | - $className = "App\\Babel\\Extension\\$oj\\$synchronizerProvider"; |
|
26 | + $className="App\\Babel\\Extension\\$oj\\$synchronizerProvider"; |
|
27 | 27 | if (class_exists($className)) { |
28 | 28 | return new $className($all_data); |
29 | 29 | } else { |
@@ -51,7 +51,7 @@ |
||
51 | 51 | } catch (ErrorException $e) { |
52 | 52 | } catch (Exception $e) { |
53 | 53 | } |
54 | - $className = "App\\Babel\\Extension\\$oj\\$submitterProvider"; |
|
54 | + $className="App\\Babel\\Extension\\$oj\\$submitterProvider"; |
|
55 | 55 | if (class_exists($className)) { |
56 | 56 | return new $className($sub, $all_data); |
57 | 57 | } else { |
@@ -56,7 +56,7 @@ |
||
56 | 56 | } catch (ErrorException $e) { |
57 | 57 | } catch (Exception $e) { |
58 | 58 | } |
59 | - $className = "App\\Babel\\Extension\\$name\\$judgerProvider"; |
|
59 | + $className="App\\Babel\\Extension\\$name\\$judgerProvider"; |
|
60 | 60 | if (class_exists($className)) { |
61 | 61 | return new $className(); |
62 | 62 | } else { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | //writing database |
39 | 39 | $this->transactionDB(); |
40 | 40 | |
41 | - }catch(Throwable $e){ |
|
41 | + } catch(Throwable $e){ |
|
42 | 42 | if ($e->getMessage()!==""){ |
43 | 43 | $this->command->line("\n <bg=red;fg=white> {$e->getMessage()} </>\n"); |
44 | 44 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | DB::commit(); |
222 | 222 | |
223 | - }catch(Throwable $e){ |
|
223 | + } catch(Throwable $e){ |
|
224 | 224 | DB::rollback(); |
225 | 225 | if ($e->getMessage()!=="") { |
226 | 226 | $this->command->line("\n <bg=red;fg=white> {$e->getMessage()} </>\n"); |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | //writing database |
40 | 40 | $this->transactionDB(); |
41 | 41 | |
42 | - }catch(Throwable $e){ |
|
43 | - if ($e->getMessage()!==""){ |
|
42 | + } catch (Throwable $e) { |
|
43 | + if ($e->getMessage()!=="") { |
|
44 | 44 | $this->command->line("\n <bg=red;fg=white> {$e->getMessage()} </>\n"); |
45 | 45 | } |
46 | 46 | } |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | public function __construct($class) |
60 | 60 | { |
61 | 61 | $this->command=$class; |
62 | - $this->versionParser = new VersionConstraintParser(); |
|
62 | + $this->versionParser=new VersionConstraintParser(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | private function parseVersion() |
66 | 66 | { |
67 | - if(empty($this->babelConfig)){ |
|
67 | + if (empty($this->babelConfig)) { |
|
68 | 68 | throw new Exception('Missing babel.json Config file.'); |
69 | 69 | } |
70 | 70 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | DB::commit(); |
136 | 136 | |
137 | - }catch(Throwable $e){ |
|
137 | + } catch (Throwable $e) { |
|
138 | 138 | DB::rollback(); |
139 | 139 | if ($e->getMessage()!=="") { |
140 | 140 | $this->command->line("\n <bg=red;fg=white> {$e->getMessage()} </>\n"); |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | if (!isset($data["ori"]) || !isset($data["path"]) || !isset($data["baseurl"]) || !isset($data["space_deli"]) || !isset($data["cookie"])) { |
89 | 89 | throw new Exception("data is not completely exist in cacheImage"); |
90 | 90 | } |
91 | - $ori = $data["ori"]; |
|
92 | - $path = $data["path"]; |
|
93 | - $baseurl = $data["baseurl"]; |
|
94 | - $space_deli = $data["space_deli"]; |
|
95 | - $cookie = $data["cookie"]; |
|
91 | + $ori=$data["ori"]; |
|
92 | + $path=$data["path"]; |
|
93 | + $baseurl=$data["baseurl"]; |
|
94 | + $space_deli=$data["space_deli"]; |
|
95 | + $cookie=$data["cookie"]; |
|
96 | 96 | |
97 | 97 | $para["path"]=$path; |
98 | 98 | $para["base"]=$baseurl; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $reg="/< *im[a]?g[^>]*src *= *[\"\\']?([^\"\\'>]*)[^>]*>/si"; |
106 | 106 | } |
107 | 107 | |
108 | - return preg_replace_callback($reg, function ($matches) use ($para) { |
|
108 | + return preg_replace_callback($reg, function($matches) use ($para) { |
|
109 | 109 | global $config; |
110 | 110 | $url=trim($matches[1]); |
111 | 111 | if (stripos($url, "http://")===false && stripos($url, "https://")===false) { |
@@ -138,24 +138,24 @@ discard block |
||
138 | 138 | public function procInfo($data) |
139 | 139 | { |
140 | 140 | if (isset($data["path"])) { |
141 | - $path = $data["path"]; |
|
141 | + $path=$data["path"]; |
|
142 | 142 | } else { |
143 | 143 | throw new Exception("path is not exist in data"); |
144 | 144 | } |
145 | 145 | if (isset($data["baseurl"])) { |
146 | - $baseurl = $data["baseurl"]; |
|
146 | + $baseurl=$data["baseurl"]; |
|
147 | 147 | } else { |
148 | 148 | throw new Exception("baseurl is not exist in data"); |
149 | 149 | } |
150 | 150 | if (isset($data["space_deli"])) { |
151 | - $space_deli = $data["space_deli"]; |
|
151 | + $space_deli=$data["space_deli"]; |
|
152 | 152 | } else { |
153 | - $space_deli = true; |
|
153 | + $space_deli=true; |
|
154 | 154 | } |
155 | 155 | if (isset($data["cookie"])) { |
156 | - $cookie = $data["cookie"]; |
|
156 | + $cookie=$data["cookie"]; |
|
157 | 157 | } else { |
158 | - $cookie = ""; |
|
158 | + $cookie=""; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $this->pro["description"]=$this->_cacheImage($this->pro["description"], $path, $baseurl, $space_deli, $cookie); |