当前位置: 首页>>代码示例>>PHP>>正文


PHP xmlrpcval::scalarval方法代码示例

本文整理汇总了PHP中xmlrpcval::scalarval方法的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpcval::scalarval方法的具体用法?PHP xmlrpcval::scalarval怎么用?PHP xmlrpcval::scalarval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpcval的用法示例。


在下文中一共展示了xmlrpcval::scalarval方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmlrpcmsg

include "xmlrpc.inc";
$f = new xmlrpcmsg('examples.getStateName');
print "<h3>Testing value serialization</h3>\n";
$v = new xmlrpcval(23, "int");
print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
$v = new xmlrpcval("What are you saying? >> << &&");
print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
$v = new xmlrpcval(array(new xmlrpcval("ABCDEFHIJ"), new xmlrpcval(1234, 'int'), new xmlrpcval(1, 'boolean')), "array");
print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
$v = new xmlrpcval(array("thearray" => new xmlrpcval(array(new xmlrpcval("ABCDEFHIJ"), new xmlrpcval(1234, 'int'), new xmlrpcval(1, 'boolean'), new xmlrpcval(0, 'boolean'), new xmlrpcval(true, 'boolean'), new xmlrpcval(false, 'boolean')), "array"), "theint" => new xmlrpcval(23, 'int'), "thestring" => new xmlrpcval("foobarwhizz"), "thestruct" => new xmlrpcval(array("one" => new xmlrpcval(1, 'int'), "two" => new xmlrpcval(2, 'int')), "struct")), "struct");
print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
$w = new xmlrpcval(array($v, new xmlrpcval("That was the struct!")), "array");
print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
$w = new xmlrpcval("Mary had a little lamb,\nWhose fleece was white as snow,\nAnd everywhere that Mary went\nthe lamb was sure to go.\n\nMary had a little lamb\nShe tied it to a pylon\nTen thousand volts went down its back\nAnd turned it into nylon", "base64");
print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
print "<PRE>Value of base64 string is: '" . $w->scalarval() . "'</PRE>";
$f->method('');
$f->addParam(new xmlrpcval("41", "int"));
print "<h3>Testing request serialization</h3>\n";
$op = $f->serialize();
print "<PRE>" . htmlentities($op) . "</PRE>";
print "<h3>Testing ISO date format</h3><pre>\n";
$t = time();
$date = iso8601_encode($t);
print "Now is {$t} --> {$date}\n";
print "Or in UTC, that is " . iso8601_encode($t, 1) . "\n";
$tb = iso8601_decode($date);
print "That is to say {$date} --> {$tb}\n";
print "Which comes out at " . iso8601_encode($tb) . "\n";
print "Which was the time in UTC at " . iso8601_decode($date, 1) . "\n";
print "</pre>\n";
开发者ID:5haman,项目名称:knowledgetree,代码行数:31,代码来源:vardemo.php

示例2: php_xmlrpc_decode

/**
 * Takes an xmlrpc value in PHP xmlrpcval object format
 * and translates it into native PHP types.
 *
 * @author Dan Libby (dan@libby.com)
 *
 * @param  xmlrpcval $xmlrpc_val
 * @param  array     $options    if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects
 * @return mixed
 */
function php_xmlrpc_decode($xmlrpc_val, $options = '')
{
    $kind = $xmlrpc_val->kindOf();
    if ($kind == 'scalar') {
        return $xmlrpc_val->scalarval();
    } elseif ($kind == 'array') {
        $size = $xmlrpc_val->arraysize();
        $arr = array();
        for ($i = 0; $i < $size; $i++) {
            $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options);
        }
        return $arr;
    } elseif ($kind == 'struct') {
        $xmlrpc_val->structreset();
        // If user said so, try to rebuild php objects for specific struct vals.
        /// @todo should we raise a warning for class not found?
        // shall we check for proper subclass of xmlrpcval instead of
        // presence of _php_class to detect what we can do?
        if (@in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != '' && class_exists($xmlrpc_val->_php_class)) {
            $obj = @new $xmlrpc_val->_php_class();
            while (list($key, $value) = $xmlrpc_val->structeach()) {
                $obj->{$key} = php_xmlrpc_decode($value, $options);
            }
            return $obj;
        } else {
            $arr = array();
            while (list($key, $value) = $xmlrpc_val->structeach()) {
                $arr[$key] = php_xmlrpc_decode($value, $options);
            }
            return $arr;
        }
    }
}
开发者ID:pudney,项目名称:hellaphone,代码行数:43,代码来源:xmlrpc.php

示例3: php_xmlrpc_decode

/**
 * Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types.
 *
 * Works with xmlrpc message objects as input, too.
 *
 * Given proper options parameter, can rebuild generic php object instances
 * (provided those have been encoded to xmlrpc format using a corresponding
 * option in php_xmlrpc_encode())
 * PLEASE NOTE that rebuilding php objects involves calling their constructor function.
 * This means that the remote communication end can decide which php code will
 * get executed on your server, leaving the door possibly open to 'php-injection'
 * style of attacks (provided you have some classes defined on your server that
 * might wreak havoc if instances are built outside an appropriate context).
 * Make sure you trust the remote server/client before eanbling this!
 *
 * @author Dan Libby (dan@libby.com)
 *
 * @param xmlrpcval $xmlrpc_val
 * @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects; if 'dates_as_objects' is set xmlrpc datetimes are decoded as php DateTime objects (standard is
 * @return mixed
 */
function php_xmlrpc_decode($xmlrpc_val, $options = array())
{
    switch ($xmlrpc_val->kindOf()) {
        case 'scalar':
            if (in_array('extension_api', $options)) {
                reset($xmlrpc_val->me);
                list($typ, $val) = each($xmlrpc_val->me);
                switch ($typ) {
                    case 'dateTime.iso8601':
                        $xmlrpc_val->scalar = $val;
                        $xmlrpc_val->xmlrpc_type = 'datetime';
                        $xmlrpc_val->timestamp = iso8601_decode($val);
                        return $xmlrpc_val;
                    case 'base64':
                        $xmlrpc_val->scalar = $val;
                        $xmlrpc_val->type = $typ;
                        return $xmlrpc_val;
                    default:
                        return $xmlrpc_val->scalarval();
                }
            }
            if (in_array('dates_as_objects', $options) && $xmlrpc_val->scalartyp() == 'dateTime.iso8601') {
                // we return a Datetime object instead of a string
                // since now the constructor of xmlrpcval accepts safely strings, ints and datetimes,
                // we cater to all 3 cases here
                $out = $xmlrpc_val->scalarval();
                if (is_string($out)) {
                    $out = strtotime($out);
                }
                if (is_int($out)) {
                    $result = new Datetime();
                    $result->setTimestamp($out);
                    return $result;
                } elseif (is_a($out, 'Datetime')) {
                    return $out;
                }
            }
            return $xmlrpc_val->scalarval();
        case 'array':
            $size = $xmlrpc_val->arraysize();
            $arr = array();
            for ($i = 0; $i < $size; $i++) {
                $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options);
            }
            return $arr;
        case 'struct':
            $xmlrpc_val->structreset();
            // If user said so, try to rebuild php objects for specific struct vals.
            /// @todo should we raise a warning for class not found?
            // shall we check for proper subclass of xmlrpcval instead of
            // presence of _php_class to detect what we can do?
            if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != '' && class_exists($xmlrpc_val->_php_class)) {
                $obj = @new $xmlrpc_val->_php_class();
                while (list($key, $value) = $xmlrpc_val->structeach()) {
                    $obj->{$key} = php_xmlrpc_decode($value, $options);
                }
                return $obj;
            } else {
                $arr = array();
                while (list($key, $value) = $xmlrpc_val->structeach()) {
                    $arr[$key] = php_xmlrpc_decode($value, $options);
                }
                return $arr;
            }
        case 'msg':
            $paramcount = $xmlrpc_val->getNumParams();
            $arr = array();
            for ($i = 0; $i < $paramcount; $i++) {
                $arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i));
            }
            return $arr;
    }
}
开发者ID:gggeek,项目名称:ggwebservices,代码行数:94,代码来源:xmlrpc.inc.php

示例4: jimport

 case 'list_methods':
     jimport('joomla.html.html');
     $msg = new xmlrpcmsg('system.listMethods');
     $xmlrpcdoc = $client->send($msg);
     //echo var_dump($xmlrpcdoc);
     //die;
     if ($xmlrpcdoc->faultCode() == 0) {
         $result = $xmlrpcdoc->value();
         $array = $result->scalarval();
     } else {
         print $xmlrpcdoc->faultString();
     }
     $methods = array();
     for ($i = 0; $i < sizeof($array); $i++) {
         $var = new xmlrpcval($array[$i]);
         $array_method = $var->scalarval();
         $methods[$i] = JHTML::_('select.option', $array_method->scalarval());
     }
     $output = 'Methods<br />';
     $output .= JHTML::_('select.genericlist', $methods, 'method', 'size="10"', 'value', 'text');
     $output .= ' <input name="args" type="text" />';
     $output .= ' <input name="task" type="submit" value="exec" />';
     break;
 case 'exec':
     $method = JRequest::getVar('method', '', '', 'cmd');
     $args = JRequest::getVar('args');
     $message = new xmlrpcmsg($method, array(new xmlrpcval(0, "int")));
     $xmlrpcdoc = $client->send($message);
     if ($xmlrpcdoc->faultCode() == 0) {
         $scalar_var = $xmlrpcdoc->value();
         $output = var_export($scalar_var->scalarval(), true);
开发者ID:Isabella570,项目名称:Hotel-Management-Selena-,代码行数:31,代码来源:client.php

示例5: testMinusOneString

 function testMinusOneString()
 {
     $v = new xmlrpcval('-1');
     $u = new xmlrpcval('-1', 'string');
     $this->assertEquals($u->scalarval(), $v->scalarval());
 }
开发者ID:RiquelmyMelara,项目名称:Awakened-Millionaire,代码行数:6,代码来源:testsuite.php

示例6: each

	/**
	* Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types.
	*
	* Works with xmlrpc message objects as input, too.
	*
	* Given proper options parameter, can rebuild generic php object instances
	* (provided those have been encoded to xmlrpc format using a corresponding
	* option in php_xmlrpc_encode())
	* PLEASE NOTE that rebuilding php objects involves calling their constructor function.
	* This means that the remote communication end can decide which php code will
	* get executed on your server, leaving the door possibly open to 'php-injection'
	* style of attacks (provided you have some classes defined on your server that
	* might wreak havoc if instances are built outside an appropriate context).
	* Make sure you trust the remote server/client before eanbling this!
	*
	* @author Dan Libby (dan@libby.com)
	*
	* @param xmlrpcval $xmlrpc_val
	* @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects
	* @return mixed
	*/
	function php_xmlrpc_decode($xmlrpc_val, $options=array())
	{
		switch($xmlrpc_val->kindOf())
		{
			case 'scalar':
				if (in_array('extension_api', $options))
				{
					reset($xmlrpc_val->me);
					list($typ,$val) = each($xmlrpc_val->me);
					switch ($typ)
					{
						case 'dateTime.iso8601':
							$xmlrpc_val->scalar = $val;
							$xmlrpc_val->xmlrpc_type = 'datetime';
							$xmlrpc_val->timestamp = iso8601_decode($val);
							return $xmlrpc_val;
						case 'base64':
							$xmlrpc_val->scalar = $val;
							$xmlrpc_val->type = $typ;
							return $xmlrpc_val;
						default:
							return $xmlrpc_val->scalarval();
					}
				}
				return $xmlrpc_val->scalarval();
			case 'array':
				$size = $xmlrpc_val->arraysize();
				$arr = array();
				for($i = 0; $i < $size; $i++)
				{
					$arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options);
				}
				return $arr;
			case 'struct':
				$xmlrpc_val->structreset();
				// If user said so, try to rebuild php objects for specific struct vals.
				/// @todo should we raise a warning for class not found?
				// shall we check for proper subclass of xmlrpcval instead of
				// presence of _php_class to detect what we can do?
				if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != ''
					&& class_exists($xmlrpc_val->_php_class))
				{
					$obj = @new $xmlrpc_val->_php_class;
					while(list($key,$value)=$xmlrpc_val->structeach())
					{
						$obj->$key = php_xmlrpc_decode($value, $options);
					}
					return $obj;
				}
				else
				{
					$arr = array();
					while(list($key,$value)=$xmlrpc_val->structeach())
					{
						$arr[$key] = php_xmlrpc_decode($value, $options);
					}
					return $arr;
				}
			case 'msg':
				$paramcount = $xmlrpc_val->getNumParams();
				$arr = array();
				for($i = 0; $i < $paramcount; $i++)
				{
					$arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i));
				}
				return $arr;
			}
	}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:89,代码来源:xmlrpc.php

示例7: TestLocale

 function TestLocale()
 {
     $locale = setlocale(LC_NUMERIC, 0);
     /// @todo on php 5.3/win setting locale to german does not seem to set decimal separator to comma...
     if (setlocale(LC_NUMERIC, 'deu', 'de_DE@euro', 'de_DE', 'de', 'ge') !== false) {
         $v = new xmlrpcval(1.1, 'double');
         if (strpos($v->scalarval(), ',') == 1) {
             $r = $v->serialize();
             $this->assertequals(false, strpos($r, ','));
         }
         setlocale(LC_NUMERIC, $locale);
     }
 }
开发者ID:hoangsoft90,项目名称:hw-hoangweb-plugin,代码行数:13,代码来源:testsuite.php

示例8: TestLocale

 function TestLocale()
 {
     $locale = setlocale(LC_NUMERIC, 0);
     if (setlocale(LC_NUMERIC, 'deu', 'de_DE@euro', 'de_DE', 'de', 'ge') !== false) {
         $v = new xmlrpcval(1.1, 'double');
         $r = $v->serialize();
         $this->assertequals(false, strpos($r, ','));
         $this->assertequals(1, strpos($v->scalarval(), ','));
         setlocale(LC_NUMERIC, $locale);
     }
 }
开发者ID:TravisSperry,项目名称:mpa_website,代码行数:11,代码来源:testsuite.php


注:本文中的xmlrpcval::scalarval方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。