@@ -121,7 +121,9 @@ discard block |
||
| 121 | 121 | public function details($gcode) |
| 122 | 122 | { |
| 123 | 123 | $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first(); |
| 124 | - if (empty($basic_info)) return []; |
|
| 124 | + if (empty($basic_info)) { |
|
| 125 | + return []; |
|
| 126 | + } |
|
| 125 | 127 | $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]); |
| 126 | 128 | $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]); |
| 127 | 129 | $basic_info["create_time_foramt"]=date_format(date_create($basic_info["created_at"]), 'M jS, Y'); |
@@ -169,7 +171,9 @@ discard block |
||
| 169 | 171 | foreach ($user_list as &$u) { |
| 170 | 172 | $u["role_parsed"]=$this->role[$u["role"]]; |
| 171 | 173 | $u["role_color"]=$this->role_color[$u["role"]]; |
| 172 | - if (is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
| 174 | + if (is_null($u["sub_group"])) { |
|
| 175 | + $u["sub_group"]="None"; |
|
| 176 | + } |
|
| 173 | 177 | } |
| 174 | 178 | return $user_list; |
| 175 | 179 | } |
@@ -300,7 +304,9 @@ discard block |
||
| 300 | 304 | public function judgeEmailClearance($gid, $email) |
| 301 | 305 | { |
| 302 | 306 | $user=DB::table("users")->where(["email"=>$email])->first(); |
| 303 | - if (empty($user)) return -4; |
|
| 307 | + if (empty($user)) { |
|
| 308 | + return -4; |
|
| 309 | + } |
|
| 304 | 310 | $ret=DB::table("group_member")->where([ |
| 305 | 311 | "gid"=>$gid, |
| 306 | 312 | "uid"=>$user["id"], |
@@ -454,7 +454,9 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | if (!empty($data["sample"])) { |
| 456 | 456 | foreach ($data["sample"] as $d) { |
| 457 | - if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
| 457 | + if (!isset($d['sample_note'])) { |
|
| 458 | + $d['sample_note']=null; |
|
| 459 | + } |
|
| 458 | 460 | DB::table("problem_sample")->insert([ |
| 459 | 461 | 'pid'=>$pid, |
| 460 | 462 | 'sample_input'=>$d['sample_input'], |
@@ -503,7 +505,9 @@ discard block |
||
| 503 | 505 | |
| 504 | 506 | if (!empty($data["sample"])) { |
| 505 | 507 | foreach ($data["sample"] as $d) { |
| 506 | - if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
| 508 | + if (!isset($d['sample_note'])) { |
|
| 509 | + $d['sample_note']=null; |
|
| 510 | + } |
|
| 507 | 511 | DB::table("problem_sample")->insert([ |
| 508 | 512 | 'pid'=>$pid, |
| 509 | 513 | 'sample_input'=>$d['sample_input'], |
@@ -80,7 +80,9 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | $ret=[]; |
| 82 | 82 | $marketspaceRaw=self::getRemote(); |
| 83 | - if (empty($marketspaceRaw)) return []; |
|
| 83 | + if (empty($marketspaceRaw)) { |
|
| 84 | + return []; |
|
| 85 | + } |
|
| 84 | 86 | foreach ($marketspaceRaw["packages"] as $extension) { |
| 85 | 87 | $temp=[ |
| 86 | 88 | "details"=>$extension, |
@@ -136,7 +138,9 @@ discard block |
||
| 136 | 138 | foreach ($dirs as $d) { |
| 137 | 139 | $extension=basename($d); |
| 138 | 140 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$extension/babel.json")), true); |
| 139 | - if ($extension==$BabelConfig["code"]) $ret[]=$BabelConfig; |
|
| 141 | + if ($extension==$BabelConfig["code"]) { |
|
| 142 | + $ret[]=$BabelConfig; |
|
| 143 | + } |
|
| 140 | 144 | } |
| 141 | 145 | return $ret; |
| 142 | 146 | } |
@@ -153,10 +157,14 @@ discard block |
||
| 153 | 157 | public static function remoteDetail($code) |
| 154 | 158 | { |
| 155 | 159 | $babelConfig=self::getRemote(); |
| 156 | - if (empty($babelConfig)) return []; |
|
| 160 | + if (empty($babelConfig)) { |
|
| 161 | + return []; |
|
| 162 | + } |
|
| 157 | 163 | $babelConfigPackages=$babelConfig["packages"]; |
| 158 | 164 | foreach ($babelConfigPackages as $package) { |
| 159 | - if ($package["code"]==$code) return $package; |
|
| 165 | + if ($package["code"]==$code) { |
|
| 166 | + return $package; |
|
| 167 | + } |
|
| 160 | 168 | } |
| 161 | 169 | return []; |
| 162 | 170 | } |
@@ -67,7 +67,9 @@ |
||
| 67 | 67 | public function fetchServer($oid=0) |
| 68 | 68 | { |
| 69 | 69 | $serverList=DB::table("judge_server"); |
| 70 | - if ($oid) $serverList=$serverList->where(["oid"=>$oid]); |
|
| 70 | + if ($oid) { |
|
| 71 | + $serverList=$serverList->where(["oid"=>$oid]); |
|
| 72 | + } |
|
| 71 | 73 | $serverList=$serverList->get()->all(); |
| 72 | 74 | foreach ($serverList as &$server) { |
| 73 | 75 | $server["status_parsed"]=is_null($server["status"]) ?self::$status["-1"] : self::$status[$server["status"]]; |
@@ -9,7 +9,9 @@ |
||
| 9 | 9 | { |
| 10 | 10 | public static function info($ltxsource, $type="png") |
| 11 | 11 | { |
| 12 | - if (!in_array($type, ['png', 'svg'])) return []; |
|
| 12 | + if (!in_array($type, ['png', 'svg'])) { |
|
| 13 | + return []; |
|
| 14 | + } |
|
| 13 | 15 | $url=route("latex.$type", ['ltxsource' => $ltxsource]); |
| 14 | 16 | $image=new Imagick(); |
| 15 | 17 | $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg')); |
@@ -42,8 +42,12 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $precondition=[]; |
| 44 | 44 | foreach (explode(',', $value) as $dojo_id) { |
| 45 | - if (blank($dojo_id)) continue; |
|
| 46 | - if (!is_null(Dojo::find($dojo_id))) $precondition[]=$dojo_id; |
|
| 45 | + if (blank($dojo_id)) { |
|
| 46 | + continue; |
|
| 47 | + } |
|
| 48 | + if (!is_null(Dojo::find($dojo_id))) { |
|
| 49 | + $precondition[]=$dojo_id; |
|
| 50 | + } |
|
| 47 | 51 | } |
| 48 | 52 | return $precondition; |
| 49 | 53 | } |
@@ -66,7 +70,9 @@ discard block |
||
| 66 | 70 | public function getAvailabilityAttribute() |
| 67 | 71 | { |
| 68 | 72 | foreach ($this->precondition as $dojo_id) { |
| 69 | - if (!DojoPass::isPassed($dojo_id)) return 'locked'; |
|
| 73 | + if (!DojoPass::isPassed($dojo_id)) { |
|
| 74 | + return 'locked'; |
|
| 75 | + } |
|
| 70 | 76 | } |
| 71 | 77 | return $this->passed ? 'passed' : 'available'; |
| 72 | 78 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - }elseif ($config['type']==2) { //to a leader that member agree to join the group |
|
| 38 | + } elseif ($config['type']==2) { //to a leader that member agree to join the group |
|
| 39 | 39 | $messages=Message::where([ |
| 40 | 40 | 'receiver' => $config['receiver'], |
| 41 | 41 | 'type' => $config['type'], |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | - }elseif ($config['type']==3) { //to a person that solution was passed |
|
| 55 | + } elseif ($config['type']==3) { //to a person that solution was passed |
|
| 56 | 56 | $message=Message::where([ |
| 57 | 57 | 'receiver' => $config['receiver'], |
| 58 | 58 | 'type' => $config['type'], |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $message->save(); |
| 66 | 66 | return true; |
| 67 | 67 | } |
| 68 | - }elseif ($config['type']==4) { //to a person that solution was blocked |
|
| 68 | + } elseif ($config['type']==4) { //to a person that solution was blocked |
|
| 69 | 69 | $message=Message::where([ |
| 70 | 70 | 'receiver' => $config['receiver'], |
| 71 | 71 | 'type' => $config['type'], |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $content=substr($content, 0, strlen($content)-2); |
| 224 | 224 | $content.=" want to join your group [{$data['group']['name']}]({$data['group']['url']})"; |
| 225 | 225 | return $content; |
| 226 | - }elseif ($this->type==2) { |
|
| 226 | + } elseif ($this->type==2) { |
|
| 227 | 227 | foreach ($data['user'] as $user) { |
| 228 | 228 | $content.="[{$user['name']}]({$user['url']}), "; |
| 229 | 229 | } |
@@ -18,11 +18,31 @@ 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"])) { |
|
| 22 | + $url=$all_data["url"]; |
|
| 23 | + } else { |
|
| 24 | + throw new Exception("url is not exist in all_data"); |
|
| 25 | + } |
|
| 26 | + if (isset($all_data["data"])) { |
|
| 27 | + $data=$all_data["data"]; |
|
| 28 | + } else { |
|
| 29 | + throw new Exception("data is not exist in all_data"); |
|
| 30 | + } |
|
| 31 | + if (isset($all_data["oj"])) { |
|
| 32 | + $oj=$all_data["oj"]; |
|
| 33 | + } else { |
|
| 34 | + throw new Exception("oj is not exist in all_data"); |
|
| 35 | + } |
|
| 36 | + if (isset($all_data["ret"])) { |
|
| 37 | + $ret=$all_data["ret"]; |
|
| 38 | + } else { |
|
| 39 | + $ret='false'; |
|
| 40 | + } |
|
| 41 | + if (isset($all_data["handle"])) { |
|
| 42 | + $handle=$all_data["handle"]; |
|
| 43 | + } else { |
|
| 44 | + $handle="default"; |
|
| 45 | + } |
|
| 26 | 46 | |
| 27 | 47 | $datapost=curl_init(); |
| 28 | 48 | $headers=array("Expect:"); |
@@ -54,12 +74,36 @@ discard block |
||
| 54 | 74 | |
| 55 | 75 | public function grab_page($all_data) |
| 56 | 76 | { |
| 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=""; |
|
| 77 | + if (isset($all_data["site"])) { |
|
| 78 | + $site=$all_data["site"]; |
|
| 79 | + } else { |
|
| 80 | + throw new Exception("site is not exist in all_data"); |
|
| 81 | + } |
|
| 82 | + if (isset($all_data["oj"])) { |
|
| 83 | + $oj=$all_data["oj"]; |
|
| 84 | + } else { |
|
| 85 | + throw new Exception("oj is not exist in all_data"); |
|
| 86 | + } |
|
| 87 | + if (isset($all_data["headers"])) { |
|
| 88 | + $headers=$all_data["headers"]; |
|
| 89 | + } else { |
|
| 90 | + $headers=[]; |
|
| 91 | + } |
|
| 92 | + if (isset($all_data["handle"])) { |
|
| 93 | + $handle=$all_data["handle"]; |
|
| 94 | + } else { |
|
| 95 | + $handle="default"; |
|
| 96 | + } |
|
| 97 | + if (isset($all_data["follow"])) { |
|
| 98 | + $follow=$all_data["follow"]; |
|
| 99 | + } else { |
|
| 100 | + $follow=false; |
|
| 101 | + } |
|
| 102 | + if (isset($all_data["vcid"])) { |
|
| 103 | + $vcid=$all_data["vcid"]."_"; |
|
| 104 | + } else { |
|
| 105 | + $vcid=""; |
|
| 106 | + } |
|
| 63 | 107 | |
| 64 | 108 | $handle=urlencode($handle); |
| 65 | 109 | |
@@ -86,16 +130,56 @@ discard block |
||
| 86 | 130 | |
| 87 | 131 | public function post_data($all_data) |
| 88 | 132 | { |
| 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=""; |
|
| 133 | + if (isset($all_data["site"])) { |
|
| 134 | + $site=$all_data["site"]; |
|
| 135 | + } else { |
|
| 136 | + throw new Exception("site is not exist in all_data"); |
|
| 137 | + } |
|
| 138 | + if (isset($all_data["data"])) { |
|
| 139 | + $data=$all_data["data"]; |
|
| 140 | + } else { |
|
| 141 | + throw new Exception("data is not exist in all_data"); |
|
| 142 | + } |
|
| 143 | + if (isset($all_data["oj"])) { |
|
| 144 | + $oj=$all_data["oj"]; |
|
| 145 | + } else { |
|
| 146 | + throw new Exception("oj is not exist in all_data"); |
|
| 147 | + } |
|
| 148 | + if (isset($all_data["ret"])) { |
|
| 149 | + $ret=$all_data["ret"]; |
|
| 150 | + } else { |
|
| 151 | + $ret=false; |
|
| 152 | + } |
|
| 153 | + if (isset($all_data["follow"])) { |
|
| 154 | + $follow=$all_data["follow"]; |
|
| 155 | + } else { |
|
| 156 | + $follow=true; |
|
| 157 | + } |
|
| 158 | + if (isset($all_data["returnHeader"])) { |
|
| 159 | + $returnHeader=$all_data["returnHeader"]; |
|
| 160 | + } else { |
|
| 161 | + $returnHeader=true; |
|
| 162 | + } |
|
| 163 | + if (isset($all_data["postJson"])) { |
|
| 164 | + $postJson=$all_data["postJson"]; |
|
| 165 | + } else { |
|
| 166 | + $postJson=false; |
|
| 167 | + } |
|
| 168 | + if (isset($all_data["extraHeaders"])) { |
|
| 169 | + $extraHeaders=$all_data["extraHeaders"]; |
|
| 170 | + } else { |
|
| 171 | + $extraHeaders=[]; |
|
| 172 | + } |
|
| 173 | + if (isset($all_data["handle"])) { |
|
| 174 | + $handle=$all_data["handle"]; |
|
| 175 | + } else { |
|
| 176 | + $handle="default"; |
|
| 177 | + } |
|
| 178 | + if (isset($all_data["vcid"])) { |
|
| 179 | + $vcid=$all_data["vcid"]."_"; |
|
| 180 | + } else { |
|
| 181 | + $vcid=""; |
|
| 182 | + } |
|
| 99 | 183 | |
| 100 | 184 | $handle=urlencode($handle); |
| 101 | 185 | |