ZBlogException::SuspendErrorHook PHP Method

SuspendErrorHook() public static method

暂停错误调度
public static SuspendErrorHook ( )
    public static function SuspendErrorHook()
    {
        if (self::$_isdisable !== null) {
            return;
        }
        self::$_isdisable = self::$isdisable;
        self::$isdisable = true;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param string $varBody
  * @return mixed|void
  */
 public function send($varBody = '')
 {
     $data = $varBody;
     if (is_array($data)) {
         $data = http_build_query($data);
     }
     if ($this->option['method'] == 'POST') {
         if ($data == '') {
             $data = $this->__buildPostData();
             //http_build_query($this->postdata);
         }
         $this->option['content'] = $data;
         if (!isset($this->httpheader['Content-Type'])) {
             if ($this->__isBinary) {
                 $this->httpheader['Content-Type'] = 'Content-Type: multipart/form-data; boundary=' . $this->__boundary;
             } else {
                 $this->httpheader['Content-Type'] = 'Content-Type: application/x-www-form-urlencoded';
             }
         }
         $this->httpheader['Content-Length'] = 'Content-Length: ' . strlen($data);
     }
     $this->httpheader[] = 'Host: ' . $this->parsed_url['host'];
     //$this->httpheader[] = 'Referer: ' . 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     $this->httpheader[] = 'Connection: close';
     if (!isset($this->httpheader['Accept'])) {
         if (isset($_SERVER['HTTP_ACCEPT'])) {
             $this->httpheader['Accept'] = 'Accept:' . $_SERVER['HTTP_ACCEPT'];
         }
     }
     if (!isset($this->httpheader['Accept-Language'])) {
         if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             $this->httpheader['Accept-Language'] = 'Accept-Language: ' . $_SERVER['HTTP_ACCEPT_LANGUAGE'];
         }
     }
     if ($this->isgzip == true) {
         $this->httpheader['Accept-Encoding'] = 'Accept-Encoding: gzip';
     }
     $this->option['header'] = implode("\r\n", $this->httpheader);
     ZBlogException::SuspendErrorHook();
     $socket = fsockopen(($this->scheme == 'https' ? 'ssl://' : '') . $this->parsed_url['host'], $this->port, $this->errno, $this->errstr, $this->timeout);
     ZBlogException::SuspendErrorHook();
     if (!$socket) {
         return;
     }
     $url = $this->option['method'] . ' ' . ($this->parsed_url['path'] == '' ? '/' : $this->parsed_url['path']);
     if (isset($this->parsed_url["query"])) {
         $url .= "?" . $this->parsed_url["query"];
     }
     fwrite($socket, $url . ' HTTP/1.0' . "\r\n");
     fwrite($socket, $this->option['header'] . "\r\n");
     fwrite($socket, "\r\n");
     if (isset($this->option['content'])) {
         fwrite($socket, $this->option['content'] . "\r\n");
         fwrite($socket, "\r\n");
     }
     while (!feof($socket)) {
         $this->responseText .= fgets($socket, 128);
     }
     $this->responseHeader = substr($this->responseText, 0, strpos($this->responseText, "\r\n\r\n"));
     $this->responseText = substr($this->responseText, strpos($this->responseText, "\r\n\r\n") + 4);
     $this->responseHeader = explode("\r\n", $this->responseHeader);
     $i = $this->maxredirs;
     if ($this->maxredirs > 0) {
         if (strstr($this->responseHeader[0], ' 301 ') || strstr($this->responseHeader[0], ' 302 ') || strstr($this->responseHeader[0], ' 303 ') || strstr($this->responseHeader[0], ' 307 ')) {
             fclose($socket);
             $url = $this->getResponseHeader('Location');
             $this->canreinit = false;
             $this->open('Get', $url);
             $this->setMaxRedirs($i - 1);
             $this->canreinit = true;
             return $this->send();
         }
     }
     if ($this->getResponseHeader('Transfer-Encoding') == 'chunked') {
         if (!function_exists('http_chunked_decode')) {
             $this->responseText = $this->http_chunked_decode($this->responseText);
         } else {
             $this->responseText = http_chunked_decode($this->responseText);
         }
     }
     if ($this->getResponseHeader('Content-Encoding') == 'gzip') {
         if (!function_exists('gzdecode')) {
             $this->responseText = $this->gzdecode($this->responseText);
         } else {
             $this->responseText = gzdecode($this->responseText);
         }
     }
     if (isset($this->responseHeader[0])) {
         $this->statusText = $this->responseHeader[0];
         $a = explode(' ', $this->statusText);
         if (isset($a[0])) {
             $this->responseVersion = $a[0];
         }
         if (isset($a[1])) {
             $this->status = $a[1];
         }
         unset($this->responseHeader[0]);
     }
     fclose($socket);
 }
All Usage Examples Of ZBlogException::SuspendErrorHook