[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/feitianyiren/textpattern/dev/rpc/TXP_RPCServer.php [Back]  [Original]

/m';

            // First, handle the known UAs in order to serve proper content.
            if (strpos('w.bloggar', $_SERVER['HTTP_USER_AGENT']) !== false) {
                $encoding = 'iso-8859-1';
            }
            // Find for supplied encoding before to try other things.
            elseif (preg_match($rx, $HTTP_RAW_POST_DATA, $xml_enc)) {
                $encoding = strtolower($xml_enc[1]);
            }
            // Try UTF-8 detect.
            elseif (preg_match('/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xec][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf]|[\xee-\xef][\x80-\xbf]{2}|f0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2})*$/', $HTTP_RAW_POST_DATA) === 1) {
                $encoding = 'utf-8';
            }
            // Otherwise, use ISO-8859-1.
            else {
                $encoding = 'iso-8859-1';
            }

            switch ($encoding) {
                case 'utf-8':
                    $data = $HTTP_RAW_POST_DATA;
                    break;

                case 'iso-8859-1':
// TODO: if utf8 conversion fails, throw: 32701 ---> parse error. unsupported encoding?
// see: http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php & https://github.com/textpattern/textpattern/issues/1051
                    // This will fail on parser if utf8_encode is unavailiable.
                    $data = (function_exists('utf8_encode') && is_callable('utf8_encode'))
                        ? utf8_encode($HTTP_RAW_POST_DATA)
                        : $HTTP_RAW_POST_DATA;
                    break;

                default:
// TODO: if utf8 conversion fails, throw: 32701 ---> parse error. unsupported encoding? See https://github.com/textpattern/textpattern/issues/1051
                    // This will fail on parser if mb_convert_encoding is unavailiable.
                    $data = (function_exists('mb_convert_encoding') && is_callable('mb_convert_encoding'))
                        ? mb_convert_encoding($HTTP_RAW_POST_DATA, 'utf-8', $encoding)
                        : $HTTP_RAW_POST_DATA;
                    break;
            }
        }

        $this->message = new IXR_Message($data);

        if (!$this->message->parse()) {
            $this->error(-32700, 'parse error. not well formed');
        }

        if ($this->message->messageType != 'methodCall') {
            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
        }

        $result = $this->call($this->message->methodName, $this->message->params);

        // Is the result an error?
        if (is_a($result, 'IXR_Error')) {
            $this->error($result);
        }

        // Encode the result.
        $r = new IXR_Value($result);
        $resultxml = $r->getXml();

        // Create the XML.
        $xml = 

Web Proxy Viewer  |  New URL  |  Original Page