本文整理汇总了PHP中wddx_deserialize函数的典型用法代码示例。如果您正苦于以下问题:PHP wddx_deserialize函数的具体用法?PHP wddx_deserialize怎么用?PHP wddx_deserialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wddx_deserialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sessionData
public function sessionData($key)
{
$data = $this->_store->get($key);
$data = wddx_deserialize($data);
$data['ttl'] = $this->_store->ttl($key);
return $data;
}
示例2: unserialize
/**
* @param string $value
* @return array
*/
public function unserialize($value, $defaultValue = array())
{
if (!empty($value)) {
return wddx_deserialize($value);
}
return $defaultValue;
}
示例3: loadConfigFile
/**
* load configuration from a file
*
* @access public
* @param string $configFile full path of the config file
* @param array $options various options, depending on the reader
* @return array $config complete configuration
*/
function loadConfigFile($configFile, $options = array())
{
if (!function_exists("wddx_add_vars")) {
return patErrorManager::raiseError(PATCONFIGURATION_ERROR_DRIVER_NOT_WORKING, "WDDX extension is not installed on your system.");
}
$fp = @fopen($configFile, "r");
$wddx = fread($fp, filesize($configFile));
$conf = wddx_deserialize($wddx);
if ($conf === NULL) {
return patErrorManager::raiseError(PATCONFIGURATION_ERROR_CONFIG_INVALID, "{$configFile} is no valid WDDX file.");
}
return array("config" => $conf, "externalFiles" => array(), "cacheAble" => true);
}
示例4: parse_response
function parse_response($data)
{
// skip HTTP header
$data = ltrim(strstr($data, "\r\n\r\n"));
$vars = wddx_deserialize($data);
if ($vars['login'] === TRUE) {
return TRUE;
} else {
// uh oh, hackers
printf("ERROR #%d: %s<br />\n", $vars['error'], $vars['error_str']);
return FALSE;
}
}
示例5: unserialize
public function unserialize($v)
{
if ($v === NULL) {
return NULL;
}
if (!is_scalar($v)) {
return $v;
}
if ($this->len < 1) {
return wddx_deserialize($v);
}
if (substr($v, 0, $this->len) != $this->prefix) {
return $v;
}
return wddx_deserialize(substr($v, $this->len));
}
示例6: unserialize
/**
* Unserialize from WDDX to PHP
*
* @param string $wddx
* @param array $opts
* @return mixed
* @throws RuntimeException on wddx error
*/
public function unserialize($wddx, array $opts = array())
{
$ret = wddx_deserialize($wddx);
if ($ret === null && class_exists('SimpleXMLElement', false)) {
// check if the returned NULL is valid
// or based on an invalid wddx string
try {
$simpleXml = new \SimpleXMLElement($wddx);
if (isset($simpleXml->data[0]->null[0])) {
return null;
// valid null
}
throw new RuntimeException('Invalid wddx');
} catch (\Exception $e) {
throw new RuntimeException($e->getMessage(), 0, $e);
}
}
return $ret;
}
示例7: _unserialize
/**
* Unserialize data.
*
* @param mixed $data The data to be unserialized.
* @param mixed $mode The mode of unserialization. Can be either a
* single mode or array of modes. If array, will be
* unserialized in the order provided.
* @param mixed $params Any additional parameters the unserialization
* method requires.
*
* @return mixed Unserialized data.
* @throws Horde_Serialize_Exception
*/
protected static function _unserialize(&$data, $mode, $params = null)
{
switch ($mode) {
case self::NONE:
break;
case self::RAW:
$data = rawurldecode($data);
break;
case self::URL:
$data = urldecode($data);
break;
case self::WDDX:
$data = wddx_deserialize($data);
break;
case self::BZIP:
// $params['small'] = Use bzip2 'small memory' mode?
$data = bzdecompress($data, isset($params['small']) ? $params['small'] : false);
break;
case self::IMAP8:
$data = quoted_printable_decode($data);
break;
case self::IMAPUTF7:
$data = Horde_String::convertCharset(Horde_Imap_Client_Utf7imap::Utf7ImapToUtf8($data), 'UTF-8', 'ISO-8859-1');
break;
case self::IMAPUTF8:
$data = Horde_Mime::encode($data);
break;
case self::BASIC:
$data2 = @unserialize($data);
// Unserialize can return false both on error and if $data is the
// false value.
if ($data2 === false && $data == serialize(false)) {
return $data2;
}
$data = $data2;
break;
case self::GZ_DEFLATE:
$data = gzinflate($data);
break;
case self::BASE64:
$data = base64_decode($data);
break;
case self::GZ_COMPRESS:
$data = gzuncompress($data);
break;
// $params = Output character set
// $params = Output character set
case self::UTF7:
$data = Horde_String::convertCharset($data, 'utf-7', $params);
break;
// $params = Output character set
// $params = Output character set
case self::UTF7_BASIC:
$data = self::unserialize($data, array(self::BASIC, self::UTF7), $params);
break;
case self::JSON:
$out = json_decode($data);
if (!is_null($out) || strcasecmp($data, 'null') === 0) {
return $out;
}
break;
case self::LZF:
$data = @lzf_decompress($data);
break;
}
if ($data === false) {
throw new Horde_Serialize_Exception('Unserialization failed.');
}
return $data;
}
示例8: unserialize
/**
* Unserialize from WDDX to PHP
*
* @param string $wddx
* @param array $opts
* @return mixed
* @throws Zend_Serializer_Exception on wddx error
*/
public function unserialize($wddx, array $opts = array())
{
$ret = wddx_deserialize($wddx);
if ($ret === null) {
// check if the returned NULL is valid
// or based on an invalid wddx string
try {
$oldLibxmlDisableEntityLoader = libxml_disable_entity_loader(true);
$dom = new DOMDocument();
$dom->loadXML($wddx);
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
#require_once 'Zend/Serializer/Exception.php';
throw new Zend_Serializer_Exception('Invalid XML: Detected use of illegal DOCTYPE');
}
}
$simpleXml = simplexml_import_dom($dom);
libxml_disable_entity_loader($oldLibxmlDisableEntityLoader);
if (isset($simpleXml->data[0]->null[0])) {
return null;
// valid null
}
$errMsg = 'Can\'t unserialize wddx string';
} catch (Exception $e) {
$errMsg = $e->getMessage();
}
#require_once 'Zend/Serializer/Exception.php';
throw new Zend_Serializer_Exception($errMsg);
}
return $ret;
}
示例9: array
<?php
// Our assoc array
$talk = array('id' => 4, 'title' => 'Dynamic Images in PHP - How and When to Use Them', 'date' => '2002-04-29', 'speaker' => 'Alison Gianotto', 'url' => 'http://www.sdphp.net/talks/ag_image');
// we can serialize the value and
// create the packet in one step
$ser1 = wddx_serialize_vars('talk');
echo format_packet($ser1, 'In one step');
// or we could serialize it in several steps
$packet = wddx_packet_start("One of Alison's talks at SDPHP");
wddx_add_vars($packet, 'talk');
$ser2 = wddx_packet_end($packet);
echo format_packet($ser2, 'Making the packet by hand');
// now let's deserialize the packet
$vars = wddx_deserialize($ser2);
echo "<pre>\n<small>\n";
print_r($vars);
echo "</small>\n</pre>\n";
function format_packet($pckt, $title = 'wddx packet')
{
$re = '/^[^<]/';
$pckt = str_replace('>', ">\n", $pckt);
$t = explode("\n", $pckt);
$s = "[ {$title} ]<br>\n<pre>\n";
foreach ($t as $line) {
if (trim($line) == '') {
continue;
} elseif (preg_match($re, $line)) {
$tmp = explode("\n", str_replace('<', "\n<", $line));
$s .= ' <span style="color: blue;">' . $tmp[0] . "</span>\n" . htmlspecialchars($tmp[1]) . "\n";
} else {
示例10: unserialize
/**
* Unserialize from WDDX to PHP
*
* @param string $wddx
* @return mixed
* @throws Exception\RuntimeException on wddx error
*/
public function unserialize($wddx)
{
$ret = wddx_deserialize($wddx);
if ($ret === null && class_exists('SimpleXMLElement', false)) {
// check if the returned NULL is valid
// or based on an invalid wddx string
try {
libxml_disable_entity_loader(true);
$simpleXml = new \SimpleXMLElement($wddx);
libxml_disable_entity_loader(false);
if (isset($simpleXml->data[0]->null[0])) {
return null;
// valid null
}
throw new Exception\RuntimeException('Unserialization failed: Invalid wddx packet');
} catch (\Exception $e) {
throw new Exception\RuntimeException('Unserialization failed: ' . $e->getMessage(), 0, $e);
}
}
return $ret;
}
示例11: unserialize
/**
* Unserialize from WDDX to PHP
*
* @param string $wddx
* @param array $opts
* @return mixed
* @throws Zend_Serializer_Exception on wddx error
*/
public function unserialize($wddx, array $opts = array())
{
$ret = wddx_deserialize($wddx);
if ($ret === null) {
// check if the returned NULL is valid
// or based on an invalid wddx string
try {
$simpleXml = new SimpleXMLElement($wddx);
if (isset($simpleXml->data[0]->null[0])) {
return null;
// valid null
}
$errMsg = 'Can\'t unserialize wddx string';
} catch (Exception $e) {
$errMsg = $e->getMessage();
}
//$1 'Zend/Serializer/Exception.php';
throw new Zend_Serializer_Exception($errMsg);
}
return $ret;
}
示例12: _wddx_decode
function _wddx_decode($data)
{
return wddx_deserialize($data);
}
示例13: var_dump
<var name="113301888545229100">
<struct>
<var name="max">
<number>10</number>
</var>
<var name="cache">
<number>4</number>
</var>
<var name="order">
<struct>
<var name="content_113300831086270200">
<struct>
<var name="CMS_BUILD">
<string>desc</string>
</var>
</struct>
</var>
</struct>
</var>
</struct>
</var>
</struct>
</var>
</struct>
</var>
</struct>
</data>
</wddxpacket>
WDX;
var_dump(wddx_deserialize($wddx));
示例14: print_r
<?php
$message = "<wddxPacket version='1.0'><header><comment>my_command</comment></header><data><struct><var name='handle'><number></number></var></struct></data></wddxPacket>";
print_r(wddx_deserialize($message));
print_r(wddx_deserialize($message));
示例15: file_get_contents
<?php
// Sample REST server - returns uptime information
// Jesus M. Castagnetto
//$host = 'www.example.com';
//$port = 80;
//$serverPath = '/xmlrpc/server.php'
$host = 'jmc.sdsc.edu';
$port = 6666;
$serverPath = '/misc/ws_rest_sample_server.php';
$packet = file_get_contents("http://{$host}:{$port}{$serverPath}");
$tmp = wddx_deserialize($packet);
extract($tmp);
$sep = str_repeat('*', 50);
echo <<<_END
{$sep}
Uptime for : {$host}
Timestamp (UTC) : {$timestamp}
Local time at host : {$uptime['time']}
Host has run for : {$uptime['duration']}
Number of current users : {$uptime['users']}
Average number of jobs in queue
1 minute : {$uptime['load1']}
5 minutes : {$uptime['load5']}
15 minutes : {$uptime['load15']}
{$sep}
_END;
?>