serialize() public method

public serialize ( )
Ejemplo n.º 1
0
function mobi_parse_requrest()
{
    global $request_method, $request_params, $params_num;
    $ver = phpversion();
    if ($ver[0] >= 5) {
        $data = file_get_contents('php://input');
    } else {
        $data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
    }
    if (count($_SERVER) == 0) {
        $r = new xmlrpcresp('', 15, 'XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
        echo $r->serialize('UTF-8');
        exit;
    }
    if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) {
        $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']);
    } else {
        $content_encoding = '';
    }
    if ($content_encoding != '' && strlen($data)) {
        if ($content_encoding == 'deflate' || $content_encoding == 'gzip') {
            // if decoding works, use it. else assume data wasn't gzencoded
            if (function_exists('gzinflate')) {
                if ($content_encoding == 'deflate' && ($degzdata = @gzuncompress($data))) {
                    $data = $degzdata;
                } elseif ($degzdata = @gzinflate(substr($data, 10))) {
                    $data = $degzdata;
                }
            } else {
                $r = new xmlrpcresp('', 106, 'Received from client compressed HTTP request and cannot decompress');
                echo $r->serialize('UTF-8');
                exit;
            }
        }
    }
    $parsers = php_xmlrpc_decode_xml($data);
    $request_method = $parsers->methodname;
    $request_params = php_xmlrpc_decode(new xmlrpcval($parsers->params, 'array'));
    $params_num = count($request_params);
}
Ejemplo n.º 2
0
 /**
  * A debugging routine: just echoes back the input packet as a string value
  * DEPRECATED!
  */
 function echoInput()
 {
     $r = new xmlrpcresp(new xmlrpcval("'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string'));
     print $r->serialize();
 }
Ejemplo n.º 3
0
 /**
  * output error/success message
  *
  * @param  String  $message
  * @param  Boolean  $result
  * @patam  Integer  $errorCode
  * @return string default as xmlrpc
  */
 public static function alert($message, $result = false, $errorCode = NULL, $error_detail = '')
 {
     header('Content-Type: text/xml');
     self::resetGlobals();
     $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval($result, 'boolean'), 'result_text' => new xmlrpcval($message, 'base64'), 'error' => new xmlrpcval($error_detail, 'base64')), 'struct'));
     if (ob_get_length()) {
         ob_end_clean();
     }
     echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . $response->serialize('UTF-8');
     exit;
 }
Ejemplo n.º 4
0
}
// Disable Cookies
$_COOKIE = array();
if (!isset($HTTP_RAW_POST_DATA)) {
    $HTTP_RAW_POST_DATA = implode("\r\n", file('php://input'));
}
// Trim requests (used by XML-RPC library); fix for mozBlog and other cases where '<?xml' isn't on the very first line
$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
require_once dirname(__FILE__) . '/../conf/_config.php';
require_once $inc_path . '_main.inc.php';
load_funcs('xmlrpc/model/_xmlrpc.funcs.php');
if (CANUSEXMLRPC !== TRUE || !$Settings->get('general_xmlrpc')) {
    // We cannot use XML-RPC: send an error response ( "17 Internal server error" ).
    $errMessage = CANUSEXMLRPC !== TRUE ? 'Cannot use XML-RPC. Probably the server is missing the XML extension. Error: ' . CANUSEXMLRPC : 'XML-RPC services are disabled on this system.';
    $errResponse = new xmlrpcresp(0, 17, $errMessage);
    die($errResponse->serialize());
}
// We can't display standard error messages. We must return XMLRPC responses.
$DB->halt_on_error = false;
$DB->show_errors = false;
$post_default_title = '';
// posts submitted via the xmlrpc interface get that title
/**
 * Array defining the available Remote Procedure Calls:
 */
$xmlrpc_procs = array();
// Load APIs:
include_once $inc_path . 'xmlrpc/apis/_blogger.api.php';
include_once $inc_path . 'xmlrpc/apis/_b2.api.php';
include_once $inc_path . 'xmlrpc/apis/_metaweblog.api.php';
include_once $inc_path . 'xmlrpc/apis/_mt.api.php';
Ejemplo n.º 5
0
                    $output['Number of Tokens:'] = new xmlrpcval(number_format($regs[1]));
                    break;
                case 'oldest atime':
                    $output['Oldest Token:'] = new xmlrpcval(date('r', $regs[1]));
                    break;
                case 'newest atime':
                    $output['Newest Token:'] = new xmlrpcval(date('r', $regs[1]));
                    break;
                case 'last journal sync atime':
                    $output['Last Journal Sync:'] = new xmlrpcval(date('r', $regs[1]));
                    break;
                case 'last expiry atime':
                    $output['Last Expiry:'] = new xmlrpcval(date('r', $regs[1]));
                    break;
                case 'last expire reduction count':
                    $output['Last Expiry Reduction Count:'] = new xmlrpcval(number_format($regs[1]));
                    break;
            }
        }
    }
    return new xmlrpcresp(new xmlrpcval($output, 'struct'));
}
$s = new xmlrpc_server(array('get_quarantine' => array('function' => 'rpc_get_quarantine', 'signature' => array(array('array', 'string')), 'docstring' => 'This service returns a listing of files in the relative quarantine directory.'), 'return_quarantined_file' => array('function' => 'rpc_return_quarantined_file', 'signature' => array(array('base64', 'string')), 'docstring' => 'This service returns the contents of a quarantined file.'), 'quarantine_list_items' => array('function' => 'rpc_quarantine_list_items', 'signature' => array(array('array', 'string')), 'docstring' => 'This service lists the files quarantined for a given message.'), 'quarantine_release' => array('function' => 'rpc_quarantine_release', 'signature' => array(array('string', 'array', 'array', 'string')), 'docstring' => 'This service release a message from the quarantine.'), 'quarantine_learn' => array('function' => 'rpc_quarantine_learn', 'signature' => array(array('string', 'array', 'array', 'string')), 'docstring' => 'This service runs sa-learn on a message in the quarantine.'), 'quarantine_delete' => array('function' => 'rpc_quarantine_delete', 'signature' => array(array('string', 'array', 'array')), 'docstring' => 'This service deltes one or more items from the quarantine.'), 'sophos_status' => array('function' => 'rpc_sophos_status', 'signature' => array(array('string')), 'docstring' => 'This service returns the Sophos version and IDE information.'), 'get_conf_var' => array('function' => 'rpc_get_conf_var', 'signature' => array(array('string', 'string')), 'docstring' => 'This service returns a named configuration value from MailScanner.conf.'), 'dump_mailscanner_conf' => array('function' => 'rpc_dump_mailscanner_conf', 'signature' => array(array('struct')), 'docstring' => 'This service returns all configuration values and settings from MailScanner.conf.'), 'get_bayes_info' => array('function' => 'rpc_bayes_info', 'signature' => array(array('struct')), 'docstring' => 'This service return information about the bayes database.')), false);
// Check that the client is authorised to connect
if (is_rpc_client_allowed()) {
    $s->service();
} else {
    global $xmlrpcerruser;
    $output = new xmlrpcresp(0, $xmlrpcerruser + 1, "Client {$_SERVER['SERVER_ADDR']} is not authorized to connect.");
    print $output->serialize();
}
 function echoInput()
 {
     global $HTTP_RAW_POST_DATA;
     // a debugging routine: just echos back the input
     // packet as a string value
     $r = new xmlrpcresp();
     $r->xv = new xmlrpcval("'Aha said I: '" . $HTTP_RAW_POST_DATA, 'string');
     print $r->serialize();
 }
Ejemplo n.º 7
0
    begin_test('Data encoding (large array)', 'xmlrpc-epi encoding');
    for ($i = 0; $i < $num_tests; $i++) {
        for ($j = 0; $j < 10; $j++) {
            foreach ($keys as $k) {
                xmlrpc_set_type($data[$j][$k][4], 'datetime');
                xmlrpc_set_type($data[$j][$k][8], 'datetime');
            }
        }
        $out = xmlrpc_encode($data);
    }
    end_test('Data encoding (large array)', 'xmlrpc-epi encoding', $out);
}
// test 'old style' data decoding vs. 'automatic style' decoding
$dummy = new xmlrpcmsg('');
$out = new xmlrpcresp($value);
$in = '<?xml version="1.0" ?>' . "\n" . $out->serialize();
begin_test('Data decoding (large array)', 'manual decoding');
for ($i = 0; $i < $num_tests; $i++) {
    $response =& $dummy->ParseResponse($in, true);
    $value = $response->value();
    $result = array();
    for ($k = 0; $k < $value->arraysize(); $k++) {
        $val1 = $value->arraymem($k);
        $out = array();
        while (list($name, $val) = $val1->structeach()) {
            $out[$name] = array();
            for ($j = 0; $j < $val->arraysize(); $j++) {
                $data = $val->arraymem($j);
                $out[$name][] = $data->scalarval();
            }
        }
Ejemplo n.º 8
0
function mob_error($err_str)
{
    @ob_clean();
    $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(false, 'boolean'), 'result_text' => new xmlrpcval(processBody($err_str), 'base64')), 'struct'));
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . $response->serialize('UTF-8');
    exit;
}
Ejemplo n.º 9
0
 function testNilvalue()
 {
     // default case: we do not accept nil values received
     $v = new xmlrpcval('hello', 'null');
     $r = new xmlrpcresp($v);
     $s = $r->serialize();
     $m = new xmlrpcmsg('dummy');
     $r = $m->parseresponse($s);
     $this->assertequals(2, $r->faultCode());
     // enable reception of nil values
     $GLOBALS['xmlrpc_null_extension'] = true;
     $r = $m->parseresponse($s);
     $v = $r->value();
     $this->assertequals('null', $v->scalartyp());
 }
Ejemplo n.º 10
0
 function testNilvalue()
 {
     // default case: we do not accept nil values received
     $v = new xmlrpcval('hello', 'null');
     $r = new xmlrpcresp($v);
     $s = $r->serialize();
     $m = new xmlrpcmsg('dummy');
     $r = $m->parseresponse($s);
     $this->assertequals(2, $r->faultCode());
     // enable reception of nil values
     $GLOBALS['xmlrpc_null_extension'] = true;
     $r = $m->parseresponse($s);
     $v = $r->value();
     $this->assertequals('null', $v->scalartyp());
     // test with the apache version: EX:NIL
     $GLOBALS['xmlrpc_null_apache_encoding'] = true;
     // serialization
     $v = new xmlrpcval('hello', 'null');
     $s = $v->serialize();
     $this->assertequals(1, preg_match('#<value><ex:nil/></value>#', $s));
     // deserialization
     $r = new xmlrpcresp($v);
     $s = $r->serialize();
     $r = $m->parseresponse($s);
     $v = $r->value();
     $this->assertequals('null', $v->scalartyp());
     $GLOBALS['xmlrpc_null_extension'] = false;
     $r = $m->parseresponse($s);
     $this->assertequals(2, $r->faultCode());
 }
Ejemplo n.º 11
0
function tapatalk_error($error)
{
    if (!strstr($_SERVER['PHP_SELF'], 'mobiquo.php')) {
        return;
    }
    if (defined('IN_MOBIQUO')) {
        global $lang, $include_topic_num, $search, $function_file_name;
        if ($error == $lang->error_nosearchresults) {
            if ($include_topic_num) {
                if ($search['resulttype'] != 'posts') {
                    $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'total_topic_num' => new xmlrpcval(0, 'int'), 'topics' => new xmlrpcval(array(), 'array')), 'struct'));
                } else {
                    $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'total_post_num' => new xmlrpcval(0, 'int'), 'posts' => new xmlrpcval(array(), 'array')), 'struct'));
                }
            } else {
                $response = new xmlrpcresp(new xmlrpcval(array(), 'array'));
            }
        } else {
            if ($function_file_name == 'thankyoulike' && strpos($error, $lang->tyl_redirect_back)) {
                $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean')), 'struct'));
            } else {
                $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(false, 'boolean'), 'result_text' => new xmlrpcval(trim(strip_tags($error)), 'base64')), 'struct'));
            }
        }
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . $response->serialize('UTF-8');
        exit;
    }
}
Ejemplo n.º 12
0
function error_status($status = 0, $result_text = '')
{
    @ob_clean();
    if (!headers_sent()) {
        header('200 OK');
        header('Mobiquo_is_login: false');
        header('Content-Type: text/xml');
    }
    $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(false, 'boolean'), 'status' => new xmlrpcval($status, 'string'), 'result_text' => new xmlrpcval($result_text, 'base64')), 'struct'));
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . $response->serialize('UTF-8');
    exit;
}
Ejemplo n.º 13
0
function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
{
    global $context, $settings, $modSettings, $txt, $smcFunc, $boarddir;
    static $header_done = false, $footer_done = false, $level = 0, $has_fatal_error = false;
    // tapatalk add
    if ($_GET['action'] == 'admin' || isset($context['kick_message'])) {
        @ob_clean();
        if (!headers_sent()) {
            header('Mobiquo_is_login:'******'user']['is_logged'] ? 'true' : 'false'));
            header('Content-Type: text/xml');
        }
        if ($_GET['action'] == 'admin') {
            $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(false, 'boolean'), 'is_login_mod' => new xmlrpcval(false, 'boolean')), 'struct'));
        } else {
            $response = new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(false, 'boolean'), 'result_text' => new xmlrpcval(basic_clean($context['kick_message']), 'base64')), 'struct'));
        }
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . $response->serialize('UTF-8');
        exit;
    }
    // Attempt to prevent a recursive loop.
    ++$level;
    if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
        exit;
    }
    if ($from_fatal_error) {
        $has_fatal_error = true;
    }
    // Clear out the stat cache.
    trackStats();
    // If we have mail to send, send it.
    if (!empty($context['flush_mail'])) {
        AddMailQueue(true);
    }
    $do_header = $header === null ? !$header_done : $header;
    if ($do_footer === null) {
        $do_footer = $do_header;
    }
    // Has the template/header been done yet?
    if ($do_header) {
        // Was the page title set last minute? Also update the HTML safe one.
        if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
            $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
        }
        //tapatalk add
        include_once $boarddir . '/mobiquo/smartbanner.php';
        // Start up the session URL fixer.
        ob_start('ob_sessrewrite');
        if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
            $buffers = explode(',', $settings['output_buffers']);
        } elseif (!empty($settings['output_buffers'])) {
            $buffers = $settings['output_buffers'];
        } else {
            $buffers = array();
        }
        if (isset($modSettings['integrate_buffer'])) {
            $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
        }
        if (!empty($buffers)) {
            foreach ($buffers as $function) {
                $function = trim($function);
                $call = strpos($function, '::') !== false ? explode('::', $function) : $function;
                // Is it valid?
                if (is_callable($call)) {
                    ob_start($call);
                }
            }
        }
        // Display the screen in the logical order.
        template_header();
        $header_done = true;
    }
    if ($do_footer) {
        if (WIRELESS && !isset($context['sub_template'])) {
            fatal_lang_error('wireless_error_notyet', false);
        }
        // Just show the footer, then.
        loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
        // Anything special to put out?
        if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
            echo $context['insert_after_template'];
        }
        // Just so we don't get caught in an endless loop of errors from the footer...
        if (!$footer_done) {
            $footer_done = true;
            template_footer();
            // (since this is just debugging... it's okay that it's after </html>.)
            if (!isset($_REQUEST['xml'])) {
                db_debug_junk();
            }
        }
    }
    // Remember this URL in case someone doesn't like sending HTTP_REFERER.
    if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
        $_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
    }
    // For session check verfication.... don't switch browsers...
    $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
    if (!empty($settings['strict_doctype'])) {
        // The theme author wants to use the STRICT doctype (only God knows why).
        $temp = ob_get_contents();
        if (function_exists('ob_clean')) {
            ob_clean();
        } else {
            ob_end_clean();
            ob_start('ob_sessrewrite');
        }
        echo strtr($temp, array('var smf_iso_case_folding' => 'var target_blank = \'_blank\'; var smf_iso_case_folding', 'target="_blank"' => 'onclick="this.target=target_blank"'));
    }
    // Hand off the output to the portal, etc. we're integrated with.
    call_integration_hook('integrate_exit', array($do_footer && !WIRELESS));
    // Don't exit if we're coming from index.php; that will pass through normally.
    if (!$from_index || WIRELESS) {
        exit;
    }
}
 /**
  * Takes the xmlrpc object and generates the response to be set back
  * @param {xmlrpc_server} $server XML-RPC Server instance
  * @param {xmlrpcresp} $r XML-RPC Response object to relay to client
  * @return {string} Response to be sent to the client
  */
 protected function generateErrorResponse(xmlrpc_server $server, xmlrpcresp $r)
 {
     $this->response->addHeader('Content-Type', $r->content_type);
     $this->response->addHeader('Vary', 'Accept-Charset');
     $payload = $server->xml_header();
     if (empty($r->payload)) {
         $r->serialize();
     }
     $payload = $payload . $r->payload;
     return $payload;
 }
Ejemplo n.º 15
0
/* include the libs */
include "xmlrpc-2.2.2/lib/xmlrpc.inc";
include "xmlrpc-2.2.2/lib/xmlrpcs.inc";
require_once 'common.inc.php';
if (preg_match('`bp_api\\.php`', $_SERVER['PHP_SELF'])) {
    db_connect();
    /* get xml */
    $sXml = file_get_contents('php://input');
    /* create md5 hash with XML and your secretKey */
    $sAuthHash = strtolower(md5($sXml . $sSecretKey));
    /* check authentication */
    if (strcmp($sAuthHash, $_GET['authHash']) != 0) {
        /* authentication failed - generate fault code and string */
        $aOutput = array('faultCode' => '-1', 'faultString' => 'authentication failed');
        $pResp = new xmlrpcresp(php_xmlrpc_encode($aOutput));
        echo $pResp->serialize();
    } else {
        /* authentication okay */
        /* set common signature for the methods */
        $aSignature = array(array($xmlrpcStruct, $xmlrpcStruct));
        $pMyGameClass = new TheGame();
        /* methods to be registered - $pMyGameClass is an instance of class TheGame */
        $aRegister = array('game.login' => array('function' => array($pMyGameClass, 'Login'), 'signature' => $aSignature), 'game.registerAndLogin' => array('function' => array($pMyGameClass, 'Register'), 'signature' => $aSignature), 'game.getUserStats' => array('function' => array($pMyGameClass, 'GetStats'), 'signature' => $aSignature), 'bookItem' => array('function' => array($pMyGameClass, 'BookItem'), 'signature' => $aSignature), 'blockedNotify' => array('function' => array($pMyGameClass, 'BlockedNotify'), 'signature' => $aSignature), 'getUserPaymentLanguage' => array('function' => array($pMyGameClass, 'GetUserPaymentLanguage'), 'signature' => $aSignature), 'getUserExchangeRate' => array('function' => array($pMyGameClass, 'GetUserExchangeRate'), 'signature' => $aSignature), 'currencySwap' => array('function' => array($pMyGameClass, 'CurrencySwap'), 'signature' => $aSignature));
        /* create server, set encoding and invoke */
        $pServer = new xmlrpc_server($aRegister, false);
        $pServer->response_charset_encoding = 'UTF-8';
        $pServer->service();
    }
}
/* example game class */
class TheGame