CI_Trackback::process PHP Метод

process() публичный Метод

Opens a socket connection and passes the data to the server. Returns TRUE on success, FALSE on failure
public process ( $url, $data ) : boolean
Результат boolean
    public function process($url, $data)
    {
        $target = parse_url($url);
        // Open the socket
        if (!($fp = @fsockopen($target['host'], 80))) {
            $this->set_error('Invalid Connection: ' . $url);
            return FALSE;
        }
        // Build the path
        $path = isset($target['path']) ? $target['path'] : $url;
        empty($target['query']) or $path .= '?' . $target['query'];
        // Add the Trackback ID to the data string
        if ($id = $this->get_id($url)) {
            $data = 'tb_id=' . $id . '&' . $data;
        }
        // Transfer the data
        fputs($fp, 'POST ' . $path . " HTTP/1.0\r\n");
        fputs($fp, 'Host: ' . $target['host'] . "\r\n");
        fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
        fputs($fp, 'Content-length: ' . strlen($data) . "\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
        fputs($fp, $data);
        // Was it successful?
        $this->response = '';
        while (!feof($fp)) {
            $this->response .= fgets($fp, 128);
        }
        @fclose($fp);
        if (stripos($this->response, '<error>0</error>') === FALSE) {
            $message = preg_match('/<message>(.*?)<\\/message>/is', $this->response, $match) ? trim($match[1]) : 'An unknown error was encountered';
            $this->set_error($message);
            return FALSE;
        }
        return TRUE;
    }