PHP xml-rpc远程调用
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-05-25
ists($tag, $this->parent)){ #echo "There''s already an instance of ''$tag'' at the current level ($level)<br>\n"; if(is_array($this->parent[$tag]) and array_key_exists(0, $this->parent[$tag])){ #if the keys are numeric #need to make sure they''re numeric (account for attributes) $key = count_numeric_items($this->parent[$tag]); #echo "There are $key instances: the keys are numeric.<br>\n"; }else{ #echo "There is only one instance. Shifting everything around<br>\n"; $temp = $this->parent[$tag]; unset($this->parent[$tag]); $this->parent[$tag][0] = $temp; if(array_key_exists("$tag attr", $this->parent)){ #shift the attributes around too if they exist $temp = $this->parent["$tag attr"]; unset($this->parent["$tag attr"]); $this->parent[$tag]["0 attr"] = $temp; } $key = 1; } $this->parent = $this->parent[$tag]; }else{ $key = $tag; } if($attributes){ $this->parent["$key attr"] = $attributes; } $this->parent[$key] = array(); $this->parent = $this->parent[$key]; array_unshift($this->parents, $this->parent); } function data($parser, $data){ #echo "Data is ''", htmlspecialchars($data), "''<br>\n"; if($this->last_opened_tag != NULL){ $this->data .= $data; } } function close($parser, $tag){ #echo "Close tag $tag<br>\n"; if($this->last_opened_tag == $tag){ $this->parent = $this->data; $this->last_opened_tag = NULL; } array_shift($this->parents); $this->parent = $this->parents[0]; } } function & XML_unserialize($xml){ $xml_parser = new XML(); $data = $xml_parser->parse($xml); $xml_parser->destruct(); return $data; } function & XMLRPC_parse($request){ if(defined(''XMLRPC_DEBUG'') and XMLRPC_DEBUG){ XMLRPC_debug(''XMLRPC_parse'', "<p>Received the following raw request:</p>" . XMLRPC_show($request, ''print_r'', true)); } $data = &XML_unserialize($request); if(defined(''XMLRPC_DEBUG'') and XMLRPC_DEBUG){ XMLRPC_debug(''XMLRPC_parse'', "<p>Returning the following parsed request:</p>" . XMLRPC_show($data, ''print_r'', true)); } return $data; } function & XMLRPC_prepare($data, $type = NULL){ if(is_array($data)){ $num_elements = count($data); if((array_key_exists(0, $data) or !$num_elements) and $type != ''struct''){ #it''s an array if(!$num_elements){ #if the array is emptyempty $returnvalue = array(''array'' => array(''data'' => NULL)); }else{ $returnvalue[''array''][''data''][''value''] = array(); $temp = $returnvalue[''array''][''data''][''value'']; $count = count_numeric_items($data); for($n=0; $n<$count; $n++){ $type = NULL; if(array_key_exists("$n type", $data)){ $type = $data["$n type"]; } $temp[$n] = XMLRPC_prepare($data[$n], $type); } } }else{ #it''s a struct if(!$num_elements){ #if the struct is emptyempty $returnvalue = array(''struct'' => NULL); }else{ $returnvalue[''struct''][''member''] = array(); $temp = $returnvalue[''struct''][''member'']; while(list($key, $value) = each($data)){ if(substr($key, -5) != '' type''){ #if it''s not a type specifier $type = NULL; if(array_key |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: PHP如何禁止图片文件的被盗链下一篇: PHP中使用FCKeditor2.3.2配置
关于PHP xml-rpc远程调用的所有评论