コード例 #1
0
ファイル: POJ_Record.php プロジェクト: huguangAOA/sk_vjudge
 public function getInfo()
 {
     if ($this->res['result'] != 'N/A' && $this->res['result'] != 'Running & Judging' && $this->res['result'] != 'Waiting' && $this->res['result'] != 'Compiling') {
         return $this->res;
     }
     //Patch
     if ($this->res['rid'] == '__') {
         return $this->res;
     }
     require_once dirname(__FILE__) . "/HTMLParser.php";
     //Infomation
     $cookie_file = tempnam("./cookie", "cookie");
     $login_url = "http://poj.org/login";
     $post_fields = "user_id1=" . $this->res['oj_u'] . "&password1=" . $this->res['oj_p'] . "&url=/";
     //Login
     $curl = curl_init($login_url);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file);
     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $post_fields);
     $this->data = curl_exec($curl);
     //Get Source
     $curl = curl_init("http://poj.org/showsource?solution_id=" . $this->res['rid']);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);
     $src = curl_exec($curl);
     @unlink($cookie_file);
     $th = new HTMLParser();
     $th->loadHTML($src);
     $this->res['memory'] = $th->innerHTML('<td><b>Memory:</b> ', '</td>');
     $this->res['long'] = $th->innerHTML('<td><b>Time:</b> ', '</td>');
     $this->res['lang'] = $th->innerHTML('<td><b>Language:</b> ', '</td>');
     $th->loadHTML($th->startString('<td><b>Result:</b> '));
     $th->loadHTML($th->startString('<font '));
     $this->res['result'] = $th->innerHTML('>', '</font>');
     if ($this->res['memory'] == "N/A") {
         $this->res['memory'] = "0K";
     }
     if ($this->res['long'] == "N/A") {
         $this->res['long'] = "0MS";
     }
     $this->db->set(array('memory' => $this->res['memory'], 'long' => $this->res['long'], 'lang' => $this->res['lang'], 'result' => $this->res['result']))->where("`id` = '" . $this->id . "'")->update("Record");
     return $this->res;
 }
コード例 #2
0
ファイル: HDOJ_Record.php プロジェクト: huguangAOA/sk_vjudge
 public function getInfo()
 {
     if ($this->res['result'] != 'N/A' && $this->res['result'] != 'Running & Judging' && $this->res['result'] != 'Running' && $this->res['result'] != 'Queuing' && $this->res['result'] != 'Compiling' && $this->res['result'] != 'Pending') {
         return $this->res;
     }
     //Patch
     if ($this->res['rid'] == '__') {
         return $this->res;
     }
     require_once dirname(__FILE__) . "/HTMLParser.php";
     $th = new HTMLParser("http://acm.hdu.edu.cn/status.php?first=" . $this->res['rid'] . "&user="******"<td height=22px>" . $this->res['rid'] . "</td>", "</tr>"));
     $th->loadHTML($th->startString("<td>" . $th->innerHTML("<td>", "</td>") . "</td>"));
     $this->res['result'] = $th->innerHTML(">", "</", $th->innerHTML("<font", "font>", $th->innerHTML("<td>", "</td>")));
     $th->loadHTML($th->startString("<td>" . $th->innerHTML("<td>", "</td>") . "</td>"));
     $th->loadHTML($th->startString("<td>" . $th->innerHTML("<td>", "</td>") . "</td>"));
     $this->res['long'] = $th->innerHTML("<td>", "</td>");
     $th->loadHTML($th->startString("<td>" . $th->innerHTML("<td>", "</td>") . "</td>"));
     $this->res['memory'] = $th->innerHTML("<td>", "</td>");
     $th->loadHTML($th->startString("<td>" . $th->innerHTML("<td>", "</td>") . "</td>"));
     $th->loadHTML($th->startString("<td>" . $th->innerHTML("<td>", "</td>") . "</td>"));
     $this->res['lang'] = $th->innerHTML("<td>", "</td>");
     $this->db->set(array('memory' => $this->res['memory'], 'long' => $this->res['long'], 'lang' => $this->res['lang'], 'result' => $this->res['result']))->where("`id` = '" . $this->id . "'")->update("Record");
     return $this->res;
 }
コード例 #3
0
ファイル: POJ_Problem.php プロジェクト: huguangAOA/sk_vjudge
 public function POJ_Problem($id = 1000)
 {
     require_once dirname(__FILE__) . "/HTMLParser.php";
     $html = new HTMLParser("http://poj.org/problem?id=" . $id);
     $html->optHTMLLink();
     $pro_info = array('title' => $html->innerHTML('<div class="ptt" lang="en-US">', '</div>'));
     $prefix = $html->startString('<div class="ptt" lang="en-US">' . $pro_info['title']);
     $pro_info['time'] = intval($html->innerHTML('<div class="plm"><table align="center"><tr><td><b>Time Limit:</b> ', 'MS</td>', $prefix));
     $pro_info['memory'] = intval($html->innerHTML('MS</td><td width="10px"></td><td><b>Memory Limit:</b> ', 'K</td>'));
     $pro_info['submissions'] = intval($html->innerHTML('Total Submissions:</b> ', '</td>'));
     $pro_info['accepted'] = intval($html->innerHTML('</td><td><b>Accepted:</b> ', '</td>'));
     $pro_info['description'] = $html->innerHTML('<p class="pst">Description</p><div class="ptx" lang="en-US">', '</div>');
     $pro_info['input'] = $html->innerHTML('<p class="pst">Input</p><div class="ptx" lang="en-US">', '</div>');
     $pro_info['output'] = $html->innerHTML('<p class="pst">Output</p><div class="ptx" lang="en-US">', '</div>');
     $pro_info['sample_input'] = $html->innerHTML('<p class="pst">Sample Input</p><pre class="sio">', '</pre>');
     $pro_info['sample_output'] = $html->innerHTML('<p class="pst">Sample Output</p><pre class="sio">', '</pre>');
     $pro_info['hint'] = $html->innerHTML('<p class="pst">Hint</p><div class="ptx" lang="en-US">', '</div><p class="pst">Source</p>');
     $pro_info['source'] = $html->innerHTML('<p class="pst">Source</p><div class="ptx" lang="en-US">', '</div>');
     $this->pro_info = $pro_info;
 }