/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php require_once('HTTP/Client.php'); class HttpBot { private static $singleton; public static function singleton() { $c = __CLASS__; self::$singleton = new $c; } return self::$singleton; } private $http; private function __construct() { $shell = Shell::singleton(); $this->http = new HTTP_Client; $this->signature_purge(2); // debug codes, enabled for debug $this->signature_purge(0); } public function __clone() { } public function signature_exists($html) { $shell = Shell::singleton(); } public function signature_save($html) { $shell = Shell::singleton(); } public function signature_purge($days_old) { $shell = Shell::singleton(); $path = $shell->temp($file); } } } } } } private function assert_response($code, $text = false) { if ($code != 200) { return false; } return true; } private function assert_text($body, $chk, $text = false) { return false; } return true; } public function normalize_string($text) { } } public function response($encoding = false) { $shell = Shell::singleton(); $resp = $this->http->currentResponse(); $raw = $resp['body']; if ($encoding !== false) { $raw = $shell->concmd_utf8($raw, $encoding); } $dom = new DOMDocument; $dom->preserveWhiteSpace = false; @$dom->loadHTML($body); $xpath = new DOMXPath($dom); } public function geta($url, $error = false) { return $this->assert_response($this->http->get($url), $error); } public function posta($url, $data, $error = false) { return $this->assert_response($this->http->post($url, $data), $error); } public function contenta($chk, $text = false) { $resp = $this->http->currentResponse(); return $this->assert_text($resp['body'], $chk, $text); } } ?>