[eluser]Schotte[/eluser]
Hi all,
I have started to work with CI 2.0 and been trying to port an XML-RPC server of mine across to the new version.
My thoughts are that it would be easiest to create a driver called Api for example. Then for each additional module that one creates one can simply dump one file into the Api/drivers folder that handles the API requests for that module.
Now for the XMLRPCS class. Some adaptations are necessary for it to work:
1) When defining the callback functions in the controller do it in this way (assuming driver is $api->module->function() ):
Code:
$config['functions']['mymodule.myfunction'] = array('function' => 'api.module.function');
2) In the _execute() method of xmlrpcs:
lines 285 - 292 replaced by this (in MY_Xmlrpcs)
Code:
if (($num_parts = count($method_parts)) <= 2 || $num_parts > 3)
{
if ($objectCall && ! is_callable(array($method_parts['0'],$method_parts['1'])))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
elseif ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
}
lines 346 - 349 replaced by this
Code:
if (count($method_parts) <= 2)
{
return $this->object->$method_parts['1']($m);
//return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
}
else
{
return $this->object->$method_parts['0']->$method_parts['1']->$method_parts['2']($m);
//return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
}
Now to my problem. I basically circumvent the security check whether the requested method is callable or not (HUGE flaw). As I believe that I need to change this I have looked on the internet whether it would somehow be possible to get PHP's is_callable() working with 3 parts (driver, object, method) as opposed to 2 (object & method), but haven't turned up anything just yet.
Anyone of you bright guys got an idea on how this could be tackled?
Furthermore I am open to change my approach from drivers to a better architecture if you have one. I want the system to be easily scalable without having to manually edit the code when a new module is installed.
Regards,
Schotte