@@ -61,8 +61,8 @@ |
||
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 |
@@ -80,53 +80,53 @@ |
||
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) { |
@@ -56,11 +56,11 @@ |
||
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 | } |
@@ -11,14 +11,14 @@ discard block |
||
11 | 11 | * |
12 | 12 | * @var string |
13 | 13 | */ |
14 | - protected $signature = 'upgrade'; |
|
14 | + protected $signature='upgrade'; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * The console command description. |
18 | 18 | * |
19 | 19 | * @var string |
20 | 20 | */ |
21 | - protected $description = 'Upgrade to the Latest of NOJ'; |
|
21 | + protected $description='Upgrade to the Latest of NOJ'; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Create a new command instance. |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function handle() |
39 | 39 | { |
40 | - $bar = $this->output->createProgressBar(8); |
|
40 | + $bar=$this->output->createProgressBar(8); |
|
41 | 41 | $bar->setFormat("%current%/%max% [%bar%] %percent:3s%%\n<info>%message%</info>"); |
42 | 42 | |
43 | 43 | $bar->setMessage("Enable Maintenance Mode."); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | 'WRONG_ANSWER'=>"Wrong Answer", |
109 | 109 | ]; |
110 | 110 | |
111 | - $hdu_v = [ |
|
111 | + $hdu_v=[ |
|
112 | 112 | 'Accepted'=>"Accepted", |
113 | 113 | "Presentation Error"=>"Presentation Error", |
114 | 114 | 'Time Limit Exceeded'=>"Time Limit Exceed", |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | } catch (Exception $e) { |
346 | 346 | } |
347 | 347 | } elseif ($row['oid']==7 || $row['oid']==9) { |
348 | - $host = [7=>'uva.onlinejudge.org', 9=>'icpcarchive.ecs.baylor.edu'][$row['oid']]; |
|
349 | - $handle = [7=>'uva', 9=>'uvalive'][$row['oid']]; |
|
350 | - $list = [7=>$uvaList, 9=>$uvalList][$row['oid']]; |
|
348 | + $host=[7=>'uva.onlinejudge.org', 9=>'icpcarchive.ecs.baylor.edu'][$row['oid']]; |
|
349 | + $handle=[7=>'uva', 9=>'uvalive'][$row['oid']]; |
|
350 | + $list=[7=>$uvaList, 9=>$uvalList][$row['oid']]; |
|
351 | 351 | var_dump($host); |
352 | 352 | var_dump($handle); |
353 | 353 | var_dump($list); |
@@ -372,23 +372,23 @@ discard block |
||
372 | 372 | ]; |
373 | 373 | $this->MODEL->updateSubmission($row['sid'], $sub); |
374 | 374 | } |
375 | - }else if($row['oid']==8) { |
|
375 | + } else if ($row['oid']==8) { |
|
376 | 376 | try { |
377 | - $sub = []; |
|
378 | - $response = Requests::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']); |
|
379 | - preg_match ('/<\/td><td>[\\s\\S]*?<\/td><td>[\\s\\S]*?<\/td><td>([\\s\\S]*?)<\/td><td>[\\s\\S]*?<\/td><td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/', $response->body, $match); |
|
380 | - if(strpos(trim(strip_tags($match[1])), 'Runtime Error')!==false) $sub['verdict'] = 'Runtime Error'; |
|
381 | - else $sub['verdict'] = $hdu_v[trim(strip_tags($match[1]))]; |
|
382 | - preg_match ("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response->body, $matches); |
|
383 | - $sub['remote_id'] = $row['remote_id']; |
|
384 | - $sub['time'] = intval($matches[1]); |
|
385 | - $sub['memory'] = intval($matches[2]); |
|
377 | + $sub=[]; |
|
378 | + $response=Requests::get("http://acm.hdu.edu.cn/status.php?first=".$row['remote_id']); |
|
379 | + preg_match('/<\/td><td>[\\s\\S]*?<\/td><td>[\\s\\S]*?<\/td><td>([\\s\\S]*?)<\/td><td>[\\s\\S]*?<\/td><td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/', $response->body, $match); |
|
380 | + if (strpos(trim(strip_tags($match[1])), 'Runtime Error')!==false) $sub['verdict']='Runtime Error'; |
|
381 | + else $sub['verdict']=$hdu_v[trim(strip_tags($match[1]))]; |
|
382 | + preg_match("/<td>(\\d*?)MS<\/td><td>(\\d*?)K<\/td>/", $response->body, $matches); |
|
383 | + $sub['remote_id']=$row['remote_id']; |
|
384 | + $sub['time']=intval($matches[1]); |
|
385 | + $sub['memory']=intval($matches[2]); |
|
386 | 386 | // $sub['score'] = ($sub['verdict'] == 'Accepted')?100:0; |
387 | 387 | |
388 | - if($sub['verdict'] == 'Compile Error') { |
|
389 | - $ret = Requests::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']); |
|
390 | - preg_match ("/<pre>([\\s\\S]*?)<\/pre>/", $ret->body, $match); |
|
391 | - $sub['compile_info'] = trim(strip_tags($match[0])); |
|
388 | + if ($sub['verdict']=='Compile Error') { |
|
389 | + $ret=Requests::get("http://acm.hdu.edu.cn/viewerror.php?rid=".$row['remote_id']); |
|
390 | + preg_match("/<pre>([\\s\\S]*?)<\/pre>/", $ret->body, $match); |
|
391 | + $sub['compile_info']=trim(strip_tags($match[0])); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | $this->MODEL->updateSubmission($row['sid'], $sub); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | private function get_last_uva($earliest, $host, $handle) |
442 | 442 | { |
443 | - $ret = []; |
|
443 | + $ret=[]; |
|
444 | 444 | if (!$earliest) { |
445 | 445 | return $ret; |
446 | 446 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $groupModel=new GroupModel(); |
83 | 83 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
84 | - if ($clearance < 2){ |
|
84 | + if ($clearance<2) { |
|
85 | 85 | return ResponseModel::err(2001); |
86 | 86 | } |
87 | 87 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | return ResponseModel::success(200); |
90 | 90 | } |
91 | 91 | |
92 | - public function changeJoinPolicy(Request $request){ |
|
92 | + public function changeJoinPolicy(Request $request) { |
|
93 | 93 | $request->validate([ |
94 | 94 | 'gid' => 'required|integer', |
95 | 95 | 'join_policy' => 'required|integer', |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | |
100 | 100 | $groupModel=new GroupModel(); |
101 | 101 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
102 | - if ($clearance < 2){ |
|
102 | + if ($clearance<2) { |
|
103 | 103 | return ResponseModel::err(2001); |
104 | 104 | } |
105 | 105 | |
106 | - if ($all_data["join_policy"] < 1 || $all_data["join_policy"] > 3){ |
|
106 | + if ($all_data["join_policy"]<1 || $all_data["join_policy"]>3) { |
|
107 | 107 | return ResponseModel::err(1007); |
108 | 108 | } |
109 | 109 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
189 | 189 | $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]); |
190 | 190 | if ($clearance>1) { |
191 | - if($targetClearance!=0) { |
|
191 | + if ($targetClearance!=0) { |
|
192 | 192 | return ResponseModel::err(7003); |
193 | 193 | } |
194 | 194 | $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1); |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | |
79 | 79 | public function changeGroupName($gid, $GroupName) |
80 | 80 | { |
81 | - return DB::table("group")->where('gid',$gid)->update([ |
|
81 | + return DB::table("group")->where('gid', $gid)->update([ |
|
82 | 82 | "name"=>$GroupName |
83 | 83 | ]); |
84 | 84 | } |
85 | 85 | |
86 | - public function changeJoinPolicy($gid, $JoinPolicy){ |
|
87 | - return DB::table("group")->where('gid',$gid)->update([ |
|
86 | + public function changeJoinPolicy($gid, $JoinPolicy) { |
|
87 | + return DB::table("group")->where('gid', $gid)->update([ |
|
88 | 88 | "join_policy"=>$JoinPolicy |
89 | 89 | ]); |
90 | 90 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function details($gcode) |
93 | 93 | { |
94 | 94 | $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first(); |
95 | - if(empty($basic_info)) return []; |
|
95 | + if (empty($basic_info)) return []; |
|
96 | 96 | $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]); |
97 | 97 | $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]); |
98 | 98 | $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y'); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | foreach ($user_list as &$u) { |
134 | 134 | $u["role_parsed"]=$this->role[$u["role"]]; |
135 | 135 | $u["role_color"]=$this->role_color[$u["role"]]; |
136 | - if(is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
136 | + if (is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
137 | 137 | } |
138 | 138 | return $user_list; |
139 | 139 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | set_time_limit(0); // Pandora's box, engage! |
24 | 24 | if ($action=='judge_level') { |
25 | 25 | $this->judge_level(); |
26 | - } else if($con=="all"){ |
|
26 | + } else if ($con=="all") { |
|
27 | 27 | $this->getSpojProblem(); |
28 | - }else{ |
|
28 | + } else { |
|
29 | 29 | //TODO |
30 | 30 | } |
31 | 31 | } |
@@ -71,90 +71,90 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | public function getProblemDetail($pid) { |
74 | - $cate = []; |
|
74 | + $cate=[]; |
|
75 | 75 | |
76 | - $url = "https://www.spoj.com/problems/".$pid; |
|
77 | - $res = Requests::get($url); |
|
78 | - if (strpos("<h1>Not Found</h1>",$res->body) !== false) { |
|
76 | + $url="https://www.spoj.com/problems/".$pid; |
|
77 | + $res=Requests::get($url); |
|
78 | + if (strpos("<h1>Not Found</h1>", $res->body)!==false) { |
|
79 | 79 | header('HTTP/1.1 404 Not Found'); |
80 | 80 | die(); |
81 | - }else{ |
|
82 | - $this->pro['title'] = trim(self::find('/<h2 id="problem-name".* - (.*)<\/h2>/sU',$res->body)); |
|
83 | - $temp = $res->body; |
|
84 | - $temp = explode('<tr><td>Time limit:</td><td>', $temp)[1]; |
|
81 | + } else { |
|
82 | + $this->pro['title']=trim(self::find('/<h2 id="problem-name".* - (.*)<\/h2>/sU', $res->body)); |
|
83 | + $temp=$res->body; |
|
84 | + $temp=explode('<tr><td>Time limit:</td><td>', $temp)[1]; |
|
85 | 85 | $this->pro['time_limit']=trim(explode('s </td></tr>', $temp)[0]); //as for html arrange |
86 | - $temp = $res->body; |
|
87 | - $temp = explode('<tr><td>Memory limit:</td><td>', $temp)[1]; |
|
88 | - $this->pro['memory_limit']=trim(explode('MB</td></tr>' , $temp)[0]); |
|
89 | - $temp = $res->body; |
|
90 | - $temp = explode('<tr><td>Languages:</td><td>', $temp)[1]; |
|
91 | - $this->pro['note'] = "Languages Limit:".explode('</td></tr>', $temp)[0]; |
|
92 | - |
|
93 | - if(strpos($res->body, "<tr><td>Resource:</td><td>")!==false) |
|
86 | + $temp=$res->body; |
|
87 | + $temp=explode('<tr><td>Memory limit:</td><td>', $temp)[1]; |
|
88 | + $this->pro['memory_limit']=trim(explode('MB</td></tr>', $temp)[0]); |
|
89 | + $temp=$res->body; |
|
90 | + $temp=explode('<tr><td>Languages:</td><td>', $temp)[1]; |
|
91 | + $this->pro['note']="Languages Limit:".explode('</td></tr>', $temp)[0]; |
|
92 | + |
|
93 | + if (strpos($res->body, "<tr><td>Resource:</td><td>")!==false) |
|
94 | 94 | { |
95 | - $temp = $res->body; |
|
96 | - $temp = explode('<tr><td>Resource:</td><td>', $temp)[1]; |
|
97 | - $this->pro['source'] = strip_tags(explode('</td></tr>', $temp)[0]); |
|
98 | - }else { |
|
99 | - $this->pro['source'] = "SPOJ-".$pid; |
|
95 | + $temp=$res->body; |
|
96 | + $temp=explode('<tr><td>Resource:</td><td>', $temp)[1]; |
|
97 | + $this->pro['source']=strip_tags(explode('</td></tr>', $temp)[0]); |
|
98 | + } else { |
|
99 | + $this->pro['source']="SPOJ-".$pid; |
|
100 | 100 | } |
101 | 101 | |
102 | - if(strpos($res->body,"No tags")===false) |
|
102 | + if (strpos($res->body, "No tags")===false) |
|
103 | 103 | { |
104 | - $temp = $res->body; |
|
105 | - $temp = explode('<div id="problem-tags" class="col-lg-12 text-center">', $temp)[1]; |
|
106 | - $temp = explode('</div>', $temp)[0]; |
|
107 | - $cat = explode('<a href="/problems/tag/', $temp); |
|
108 | - for($i = 1;$i < count($cat); $i++) |
|
104 | + $temp=$res->body; |
|
105 | + $temp=explode('<div id="problem-tags" class="col-lg-12 text-center">', $temp)[1]; |
|
106 | + $temp=explode('</div>', $temp)[0]; |
|
107 | + $cat=explode('<a href="/problems/tag/', $temp); |
|
108 | + for ($i=1; $i<count($cat); $i++) |
|
109 | 109 | { |
110 | - $temp = $cat[$i]; |
|
111 | - $temp = explode('">', $temp)[0]; |
|
112 | - array_push($cate,$temp); |
|
110 | + $temp=$cat[$i]; |
|
111 | + $temp=explode('">', $temp)[0]; |
|
112 | + array_push($cate, $temp); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - $temp = $res->body; |
|
117 | - $temp = explode('<div id="problem-body">', $temp)[1]; |
|
118 | - $content = explode('<div class="text-center">', $temp)[0]; |
|
116 | + $temp=$res->body; |
|
117 | + $temp=explode('<div id="problem-body">', $temp)[1]; |
|
118 | + $content=explode('<div class="text-center">', $temp)[0]; |
|
119 | 119 | |
120 | - $this->pro['description'] = $this->cacheImage(HtmlDomParser::str_get_html(explode('<h3>Input</h3>', $content)[0], true, true, DEFAULT_TARGET_CHARSET, false)); |
|
121 | - $content = explode('<h3>Input</h3>', $content)[1]; |
|
122 | - $this->pro['input'] = explode('<h3>Output</h3>', $content)[0]; |
|
123 | - $content = explode('<h3>Output</h3>', $content)[1]; |
|
124 | - $tgis->pro['output'] = explode('<h3>Example</h3>', $content)[0]; |
|
125 | - $content = explode('<h3>Example</h3>', $content)[1]; |
|
120 | + $this->pro['description']=$this->cacheImage(HtmlDomParser::str_get_html(explode('<h3>Input</h3>', $content)[0], true, true, DEFAULT_TARGET_CHARSET, false)); |
|
121 | + $content=explode('<h3>Input</h3>', $content)[1]; |
|
122 | + $this->pro['input']=explode('<h3>Output</h3>', $content)[0]; |
|
123 | + $content=explode('<h3>Output</h3>', $content)[1]; |
|
124 | + $tgis->pro['output']=explode('<h3>Example</h3>', $content)[0]; |
|
125 | + $content=explode('<h3>Example</h3>', $content)[1]; |
|
126 | 126 | |
127 | 127 | //TODO: Get compiler of each problem. |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | 131 | public function getSpojProblem() { |
132 | - $types = ['classical','challenge','partial','tutorial','riddle','basics']; |
|
133 | - |
|
134 | - foreach($types as $type) { |
|
135 | - $iterator = 0; |
|
136 | - $endPos = false; |
|
137 | - while($endPos == false) { |
|
138 | - $url = "https://www.spoj.com/problems/".$type."/sort=0,start=".$iterator*50; |
|
139 | - $res = Requests::get($url); |
|
140 | - $problemTable = explode('<td align="left">', $res->body); |
|
141 | - for($cnt = 1; $cnt < count($problemTable); $cnt++) { |
|
142 | - $problemLink = $problemTable[$cnt]; |
|
143 | - $problemLink = explode('<a href="/problems/', $problemLink)[1]; |
|
132 | + $types=['classical', 'challenge', 'partial', 'tutorial', 'riddle', 'basics']; |
|
133 | + |
|
134 | + foreach ($types as $type) { |
|
135 | + $iterator=0; |
|
136 | + $endPos=false; |
|
137 | + while ($endPos==false) { |
|
138 | + $url="https://www.spoj.com/problems/".$type."/sort=0,start=".$iterator * 50; |
|
139 | + $res=Requests::get($url); |
|
140 | + $problemTable=explode('<td align="left">', $res->body); |
|
141 | + for ($cnt=1; $cnt<count($problemTable); $cnt++) { |
|
142 | + $problemLink=$problemTable[$cnt]; |
|
143 | + $problemLink=explode('<a href="/problems/', $problemLink)[1]; |
|
144 | 144 | $pid=explode('">', $problemLink)[0]; |
145 | 145 | |
146 | - $problemLink = $problemTable[$cnt]; |
|
147 | - $problemLink = explode('See the best solutions.">', $problemLink)[1]; |
|
146 | + $problemLink=$problemTable[$cnt]; |
|
147 | + $problemLink=explode('See the best solutions.">', $problemLink)[1]; |
|
148 | 148 | $solved_count=explode('</a></td>', $problemLink)[0]; |
149 | 149 | |
150 | - $problemLink = $problemTable[$cnt]; |
|
151 | - $index = self::find('/<td align="center">([\s]*?)<\/td>/',$problemLink); |
|
150 | + $problemLink=$problemTable[$cnt]; |
|
151 | + $index=self::find('/<td align="center">([\s]*?)<\/td>/', $problemLink); |
|
152 | 152 | |
153 | - $this->pro['pcode'] = "SPOJ-".$pid; |
|
154 | - $this->pro['OJ'] = 10; |
|
155 | - $this->pro['contest_id'] = null; |
|
156 | - $this->pro['index_id'] = $index; |
|
157 | - $this->pro['origin'] = "https://www.spoj.com/problems/".$pid; |
|
153 | + $this->pro['pcode']="SPOJ-".$pid; |
|
154 | + $this->pro['OJ']=10; |
|
155 | + $this->pro['contest_id']=null; |
|
156 | + $this->pro['index_id']=$index; |
|
157 | + $this->pro['origin']="https://www.spoj.com/problems/".$pid; |
|
158 | 158 | $this->pro['input_type']='standard input'; |
159 | 159 | $this->pro['output_type']='standard output'; |
160 | 160 | $this->getProblemDetail($pid); |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | if ($problem) { |
165 | 165 | $problemModel->clearTags($problem); |
166 | 166 | $new_pid=$this->update_problem($this->oid); |
167 | - }else { |
|
167 | + } else { |
|
168 | 168 | $new_pid=$this->insert_problem($this->oid); |
169 | 169 | } |
170 | 170 | } |
171 | - if(count($table) < 50) $endPos = true; |
|
171 | + if (count($table)<50) $endPos=true; |
|
172 | 172 | $iterator++; |
173 | 173 | } |
174 | 174 | } |