⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rpc.php

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PHP
📖 第 1 页 / 共 4 页
字号:
    case 'PARAM':        $XML_RPC_xh[$parser]['params'][] = $XML_RPC_xh[$parser]['value'];        break;    case 'METHODNAME':    case 'RPCMETHODNAME':        $XML_RPC_xh[$parser]['method'] = ereg_replace("^[\n\r\t ]+", '',                                                      $XML_RPC_xh[$parser]['ac']);        break;    }    // if it's a valid type name, set the type    if (isset($XML_RPC_Types[strtolower($name)])) {        $XML_RPC_xh[$parser]['vt'] = strtolower($name);    }}/** * Character data handler for the XML parser * * @return void */function XML_RPC_cd($parser_resource, $data){    global $XML_RPC_xh, $XML_RPC_backslash;    $parser = (int) $parser_resource;    if ($XML_RPC_xh[$parser]['lv'] != 3) {        // "lookforvalue==3" means that we've found an entire value        // and should discard any further character data        if ($XML_RPC_xh[$parser]['lv'] == 1) {            // if we've found text and we're just in a <value> then            // turn quoting on, as this will be a string            $XML_RPC_xh[$parser]['qt'] = 1;            // and say we've found a value            $XML_RPC_xh[$parser]['lv'] = 2;        }        // replace characters that eval would        // do special things with        if (!isset($XML_RPC_xh[$parser]['ac'])) {            $XML_RPC_xh[$parser]['ac'] = '';        }        $XML_RPC_xh[$parser]['ac'] .= $data;    }}/** * The common methods and properties for all of the XML_RPC classes * * @category   Web Services * @package    XML_RPC * @author     Edd Dumbill <edd@usefulinc.com> * @author     Stig Bakken <stig@php.net> * @author     Martin Jansen <mj@php.net> * @author     Daniel Convissor <danielc@php.net> * @copyright  1999-2001 Edd Dumbill, 2001-2005 The PHP Group * @version    Release: 1.4.4 * @link       http://pear.php.net/package/XML_RPC */class XML_RPC_Base {    /**     * PEAR Error handling     *     * @return object  PEAR_Error object     */    function raiseError($msg, $code)    {        include_once 'PEAR.php';        if (is_object(@$this)) {            return PEAR::raiseError(get_class($this) . ': ' . $msg, $code);        } else {            return PEAR::raiseError('XML_RPC: ' . $msg, $code);        }    }    /**     * Tell whether something is a PEAR_Error object     *     * @param mixed $value  the item to check     *     * @return bool  whether $value is a PEAR_Error object or not     *     * @access public     */    function isError($value)    {        return is_a($value, 'PEAR_Error');    }}/** * The methods and properties for submitting XML RPC requests * * @category   Web Services * @package    XML_RPC * @author     Edd Dumbill <edd@usefulinc.com> * @author     Stig Bakken <stig@php.net> * @author     Martin Jansen <mj@php.net> * @author     Daniel Convissor <danielc@php.net> * @copyright  1999-2001 Edd Dumbill, 2001-2005 The PHP Group * @version    Release: 1.4.4 * @link       http://pear.php.net/package/XML_RPC */class XML_RPC_Client extends XML_RPC_Base {    /**     * The path and name of the RPC server script you want the request to go to     * @var string     */    var $path = '';    /**     * The name of the remote server to connect to     * @var string     */    var $server = '';    /**     * The protocol to use in contacting the remote server     * @var string     */    var $protocol = 'http://';    /**     * The port for connecting to the remote server     *     * The default is 80 for http:// connections     * and 443 for https:// and ssl:// connections.     *     * @var integer     */    var $port = 80;    /**     * A user name for accessing the RPC server     * @var string     * @see XML_RPC_Client::setCredentials()     */    var $username = '';    /**     * A password for accessing the RPC server     * @var string     * @see XML_RPC_Client::setCredentials()     */    var $password = '';    /**     * The name of the proxy server to use, if any     * @var string     */    var $proxy = '';    /**     * The protocol to use in contacting the proxy server, if any     * @var string     */    var $proxy_protocol = 'http://';    /**     * The port for connecting to the proxy server     *     * The default is 8080 for http:// connections     * and 443 for https:// and ssl:// connections.     *     * @var integer     */    var $proxy_port = 8080;    /**     * A user name for accessing the proxy server     * @var string     */    var $proxy_user = '';    /**     * A password for accessing the proxy server     * @var string     */    var $proxy_pass = '';    /**     * The error number, if any     * @var integer     */    var $errno = 0;    /**     * The error message, if any     * @var string     */    var $errstr = '';    /**     * The current debug mode (1 = on, 0 = off)     * @var integer     */    var $debug = 0;    /**     * The HTTP headers for the current request.     * @var string     */    var $headers = '';    /**     * Sets the object's properties     *     * @param string  $path        the path and name of the RPC server script     *                              you want the request to go to     * @param string  $server      the URL of the remote server to connect to.     *                              If this parameter doesn't specify a     *                              protocol and $port is 443, ssl:// is     *                              assumed.     * @param integer $port        a port for connecting to the remote server.     *                              Defaults to 80 for http:// connections and     *                              443 for https:// and ssl:// connections.     * @param string  $proxy       the URL of the proxy server to use, if any.     *                              If this parameter doesn't specify a     *                              protocol and $port is 443, ssl:// is     *                              assumed.     * @param integer $proxy_port  a port for connecting to the remote server.     *                              Defaults to 8080 for http:// connections and     *                              443 for https:// and ssl:// connections.     * @param string  $proxy_user  a user name for accessing the proxy server     * @param string  $proxy_pass  a password for accessing the proxy server     *     * @return void     */    function XML_RPC_Client($path, $server, $port = 0,                            $proxy = '', $proxy_port = 0,                            $proxy_user = '', $proxy_pass = '')    {        $this->path       = $path;        $this->proxy_user = $proxy_user;        $this->proxy_pass = $proxy_pass;        preg_match('@^(http://|https://|ssl://)?(.*)$@', $server, $match);        if ($match[1] == '') {            if ($port == 443) {                $this->server   = $match[2];                $this->protocol = 'ssl://';                $this->port     = 443;            } else {                $this->server = $match[2];                if ($port) {                    $this->port = $port;                }            }        } elseif ($match[1] == 'http://') {            $this->server = $match[2];            if ($port) {                $this->port = $port;            }        } else {            $this->server   = $match[2];            $this->protocol = 'ssl://';            if ($port) {                $this->port = $port;            } else {                $this->port = 443;            }        }        if ($proxy) {            preg_match('@^(http://|https://|ssl://)?(.*)$@', $proxy, $match);            if ($match[1] == '') {                if ($proxy_port == 443) {                    $this->proxy          = $match[2];                    $this->proxy_protocol = 'ssl://';                    $this->proxy_port     = 443;                } else {                    $this->proxy = $match[2];                    if ($proxy_port) {                        $this->proxy_port = $proxy_port;                    }                }            } elseif ($match[1] == 'http://') {                $this->proxy = $match[2];                if ($proxy_port) {                    $this->proxy_port = $proxy_port;                }            } else {                $this->proxy          = $match[2];                $this->proxy_protocol = 'ssl://';                if ($proxy_port) {                    $this->proxy_port = $proxy_port;                } else {                    $this->proxy_port = 443;                }            }        }    }    /**     * Change the current debug mode     *     * @param int $in  where 1 = on, 0 = off     *     * @return void     */    function setDebug($in)    {        if ($in) {            $this->debug = 1;        } else {            $this->debug = 0;        }    }    /**     * Set username and password properties for connecting to the RPC server     *     * @param string $u  the user name     * @param string $p  the password     *     * @return void     *     * @see XML_RPC_Client::$username, XML_RPC_Client::$password     */    function setCredentials($u, $p)    {        $this->username = $u;        $this->password = $p;    }    /**     * Transmit the RPC request via HTTP 1.0 protocol     *     * @param object $msg       the XML_RPC_Message object     * @param int    $timeout   how many seconds to wait for the request     *     * @return object  an XML_RPC_Response object.  0 is returned if any     *                  problems happen.     *     * @see XML_RPC_Message, XML_RPC_Client::XML_RPC_Client(),     *      XML_RPC_Client::setCredentials()     */    function send($msg, $timeout = 0)    {        if (!is_a($msg, 'XML_RPC_Message')) {            $this->errstr = 'send()\'s $msg parameter must be an'                          . ' XML_RPC_Message object.';            $this->raiseError($this->errstr, XML_RPC_ERROR_PROGRAMMING);            return 0;        }        $msg->debug = $this->debug;        return $this->sendPayloadHTTP10($msg, $this->server, $this->port,                                        $timeout, $this->username,                                        $this->password);    }    /**     * Transmit the RPC request via HTTP 1.0 protocol     *     * Requests should be sent using XML_RPC_Client send() rather than     * calling this method directly.     *     * @param object $msg       the XML_RPC_Message object     * @param string $server    the server to send the request to     * @param int    $port      the server port send the request to     * @param int    $timeout   how many seconds to wait for the request     *                           before giving up     * @param string $username  a user name for accessing the RPC server     * @param string $password  a password for accessing the RPC server     *     * @return object  an XML_RPC_Response object.  0 is returned if any     *                  problems happen.     *     * @access protected     * @see XML_RPC_Client::send()     */    function sendPayloadHTTP10($msg, $server, $port, $timeout = 0,                               $username = '', $password = '')    {        /*         * If we're using a proxy open a socket to the proxy server         * instead to the xml-rpc server         */        if ($this->proxy) {            if ($this->proxy_protocol == 'http://') {                $protocol = '';            } else {                $protocol = $this->proxy_protocol;            }            if ($timeout > 0) {                $fp = @fsockopen($protocol . $this->proxy, $this->proxy_port,                                 $this->errno, $this->errstr, $timeout);            } else {                $fp = @fsockopen($protocol . $this->proxy, $this->proxy_port,                                 $this->errno, $this->errstr);            }        } else {            if ($this->protocol == 'http://') {                $protocol = '';            } else {                $protocol = $this->protocol;            }            if ($timeout > 0) {                $fp = @fsockopen($protocol . $server, $port,                                 $this->errno, $this->errstr, $timeout);            } else {                $fp = @fsockopen($protocol . $server, $port,                                 $this->errno, $this->errstr);            }        }        /*         * Just raising the error without returning it is strange,         * but keep it here for backwards compatibility.         */        if (!$fp && $this->proxy) {            $this->raiseError('Connection to proxy server '                              . $this->proxy . ':' . $this->proxy_port                              . ' failed. ' . $this->errstr,                              XML_RPC_ERROR_CONNECTION_FAILED);            return 0;        } elseif (!$fp) {            $this->raiseError('Connection to RPC server '                              . $server . ':' . $port                              . ' failed. ' . $this->errstr,                              XML_RPC_ERROR_CONNECTION_FAILED);            return 0;        }        if ($timeout) {            /*             * Using socket_set_timeout() because stream_set_timeout()             * was introduced in 4.3.0, but we need to support 4.2.0.             */            socket_set_timeout($fp, $timeout);        }        // Pre-emptive BC hacks for fools calling sendPayloadHTTP10() directly        if ($username != $this->username) {            $this->setCredentials($username, $password);        }        // Only create the payload if it was not created previously        if (empty($msg->payload)) {            $msg->createPayload();        }        $this->createHeaders($msg);        $op  = $this->headers . "\r\n\r\n";        $op .= $msg->payload;        if (!fputs($fp, $op, strlen($op))) {            $this->errstr = 'Write error';            return 0;        }        $resp = $msg->parseResponseFile($fp);        $meta = socket_get_status($fp);        if ($meta['timed_out']) {            fclose($fp);            $this->errstr = 'RPC server did not send response before timeout.';            $this->raiseError($this->errstr, XML_RPC_ERROR_CONNECTION_FAILED);            return 0;        }        fclose($fp);        return $resp;    }    /**     * Determines the HTTP headers and puts it in the $headers property     *     * @param object $msg       the XML_RPC_Message object     *     * @return boolean  TRUE if okay, FALSE if the message payload isn't set.     *     * @access protected     */    function createHeaders($msg)    {        if (empty($msg->payload)) {            return false;        }        if ($this->proxy) {            $this->headers = 'POST ' . $this->protocol . $this->server;            if ($this->proxy_port) {                $this->headers .= ':' . $this->port;            }        } else {           $this->headers = 'POST ';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -