|
|
|
|
|
|
| |
This is a server implementation of the new XMLRPC extension in PHP 4x. that can dynamically call a class and a specific class method based on the XML methodName parameter request.
Type: application
Version: 1.0
Requires: XMLRPC extensions
Author: the mighty Indian
| <?PHP
/*
What: Sample XMLRPC implementation server, that calls a defined function, object method, or includes a object on call. It uses the format ClassName.MethodName The '.' dot in a XML request methodName parameter separates a classname and a methodname.
Requires: http://www.weberdev.com/Manuals/PHP/ref.xmlrpc.html
Example:
$args=array(
xml => $HTTP_RAW_POST_DATA
);
if($REQUEST_METHOD=="POST" && !strncmp($CONTENT_TYPE,"text/xml",8)){
$xmlrpc = new XPC_xmlrpc($args);
Header("Content-Type: text/xml");
echo$xmlrpc->_RET;exit;
}else{
echo'GET Method not allowed!';exit;
}
include_once("test.php");
Class test{
function tester($args=''){
if(is_array($args)){
foreach($args as $k => $v){
$arr[$k]=$v;
}
}else{
$arr=array("Hello World!",time());
}
return $arr;
}
}
*/
Class XPC_xmlrpc{
var $_XML,$_RET,$_TYPE='xml',$_NAME='xmlrpc',$_ARGS=array();
function XPC_xmlrpc($args=''){
$this->_XML=$args['xml'];
$this->run($args);
}//end XPC_xmlrpc constructor method
function run($args=''){
$xmlrpc_server = xmlrpc_server_create();
$arr = xmlrpc_parse_method_descriptions($this->_XML);
if($xmlrpc_server){
if(!xmlrpc_server_register_method($xmlrpc_server,$arr['methodName'],'handler')){
die("<h2>method registration failed.</h2>");
}
$this->_RET = xmlrpc_server_call_method($xmlrpc_server,$this->_XML,array(you,love,me),array(output_type=>$this->_TYPE));
$success = xmlrpc_server_destroy($xmlrpc_server);
}
}//end run method
}//End XPC_xmlrpc Class
function handler($method_name,$params,$app_data){
if(preg_match("/^(.+)\.(.+)$/",$method_name,$match)){
$class = str_replace(".","_",$match[1]);
$name = strtolower($match[2]);
if(!class_exists($class)){
return array("3","unable to find class '$class'");
}elseif(array_search($name,get_class_methods($class))===null){
return array("4","unable to find method '$name' in class '$class'");
}else{
$handler = array(new $class, $match[2]);
}
}else{
$handler = $method_name;
}
if(is_array($handler)){
$ret = call_user_func_array($handler,array(arra=>array_merge($app_data,$params)));
}else{
$ret = call_user_func_array($handler,array(arra=>array_merge($app_data,$params)));
}
return $ret;
}//End handler method
?> | | |
|
| RSS parser.
Parses RSS into an array. Quick and nasty but does the job.
No checking is done for correct Tags, only correct XML.
PHP4 needed to display result (uses print_r). Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS) | | | A very basic and fast XML parser Categories : PHP, PHP Classes, XML | | | XML Menu Categories : PHP, PHP Classes, Navigation, XML, XSL | | | Directory Listing To XML : Outputs XML File of a Given Directory Listing Categories : PHP, PHP Classes, XML, Directories | | | Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects. Categories : PHP, PHP Classes, XML, Web Services | | | DBXML- A Class to backup databases in XML Format using web interface Categories : PHP, PHP Classes, Databases, MySQL, XML | | | TAB_STRUCT Class: Is supporting Class for the DBXML Class Categories : PHP, PHP Classes, MySQL, XML, Databases | | | logger class (PHP5 +) Categories : PHP, PHP Classes, Log Files, XML | | | XML easy parser Categories : PHP, XML, PHP Classes | | | [PHP5] PHP Debugger and Helper Categories : PHP, PHP Classes, Errors and Logging, Debugging, XML | | | XPath for PHP without the DOM XML extension Categories : DOM XML, XML, XSLT, PHP Classes, PHP | | | XML To Array Categories : PHP, PHP Classes, XML, Arrays | | | very simple ftp class Categories : PHP, PHP Classes, FTP | | | PHP Paypal IPN Integration Class v1.0.0 Categories : PHP, PHP Classes, Payment Gateways | | | A Timing Class Categories : PHP, PHP Classes, Date Time | |
|
|
|