function open_url($type, $params = array()) { $http = new http_class(); $http->request_method = 'POST'; $http->user_agent = "cesar-rodas/1.0 | Akismet-Class/" . CLASS_VERSION; $http->follow_redirect = 1; $http->redirection_limit = 5; $http->exclude_address = ""; $http->protocol_version = "1.1"; $http->GetRequestArguments($this->get_url($type), $arguments); $arguments['PostValues'] = $params; $this->err = $http->Open($arguments); if ($this->err != "") { return false; } $this->err = $http->SendRequest($arguments); if ($this->err != "") { return false; } $this->err = $http->ReadReplyHeaders($gHeaders); if ($this->err != "") { return false; } if ($http->response_status != 200) { $this->err = "Pages status: " . $http->response_status; $http->Close(); return false; } $response = ''; for (;;) { $this->error = $http->ReadReplyBody($body, 1000); if ($this->error != "" || strlen($body) == 0) { break; } $response .= $body; } $http->close(); return $response; }
function http_adv_get($qtype, $url, $extra = array(), $headers = array()) { $http = new http_class(); $http->debug = 0; $http->html_debug = 0; $http->request_method = $qtype; $http->GetRequestArguments($url, $args); $err = $http->Open($args); foreach ($extra as $key => $value) { $args[$key] = $value; } $body = ""; foreach ($headers as $key => $value) { $args['Headers'][$key] = $value; } if ($err == "") { $err = $http->Open($args); $err = $http->SendRequest($args); $http->ReadReplyHeaders($headers); if ($err == "") { if ($err == "") { for (;;) { $err = $http->ReadReplyBody($acc, 2000); if ($err != "" || $acc == "") { break; } $body .= $acc; } } } $http->close(); } return array($headers, $body); }