public function indexAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $server = new Zend_XmlRpc_Server();
     $server->setClass('Application_Model_Data', 'cf');
     echo $server->handle();
 }
Example #2
0
 public function xmlrpcServerAction()
 {
     Zend_XmlRpc_Server_Fault::attachFaultException('Exception');
     $server = new Zend_XmlRpc_Server();
     $server->setClass('MyProject_BL_Member', 'member');
     header('Content-Type: text/xml');
     echo $server->handle();
     exit(0);
 }
Example #3
0
 /**
  * This is the XML-RPC server routine
  *
  * @access public
  * @return void
  */
 public function run()
 {
     Yii::import('application.helpers.remotecontrol.*');
     $oHandler = new remotecontrol_handle($this->controller);
     $RPCType = Yii::app()->getConfig("RPCInterface");
     if (Yii::app()->getRequest()->isPostRequest) {
         if ($RPCType == 'xml') {
             $cur_path = get_include_path();
             set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers');
             // Yii::import was causing problems for some odd reason
             require_once 'Zend/XmlRpc/Server.php';
             require_once 'Zend/XmlRpc/Server/Exception.php';
             require_once 'Zend/XmlRpc/Value/Exception.php';
             $this->xmlrpc = new Zend_XmlRpc_Server();
             $this->xmlrpc->sendArgumentsToAllMethods(false);
             Yii::import('application.libraries.LSZend_XmlRpc_Response_Http');
             $this->xmlrpc->setResponseClass('LSZend_XmlRpc_Response_Http');
             $this->xmlrpc->setClass($oHandler);
             $result = $this->xmlrpc->handle();
             if ($result instanceof LSZend_XmlRpc_Response_Http) {
                 $result->printXml();
             } else {
                 // a Zend_XmlRpc_Server_Fault with exception message from XMLRPC
                 echo $result;
             }
         } elseif ($RPCType == 'json') {
             Yii::app()->loadLibrary('LSjsonRPCServer');
             if (!isset($_SERVER['CONTENT_TYPE'])) {
                 $serverContentType = explode(';', $_SERVER['HTTP_CONTENT_TYPE']);
                 $_SERVER['CONTENT_TYPE'] = reset($serverContentType);
             }
             LSjsonRPCServer::handle($oHandler);
         }
         foreach (App()->log->routes as $route) {
             $route->enabled = $route->enabled && !$route instanceof CWebLogRoute;
         }
         exit;
     } else {
         // Disabled output of API methods for now
         if (Yii::app()->getConfig("rpc_publish_api") == true && in_array($RPCType, array('xml', 'json'))) {
             $reflector = new ReflectionObject($oHandler);
             foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
                 /* @var $method ReflectionMethod */
                 if (substr($method->getName(), 0, 1) !== '_') {
                     $list[$method->getName()] = array('description' => str_replace(array("\r", "\r\n", "\n"), "<br/>", $method->getDocComment()), 'parameters' => $method->getParameters());
                 }
             }
             ksort($list);
             $aData['method'] = $RPCType;
             $aData['list'] = $list;
             $aData['display']['menu_bars'] = false;
             // Hide normal menu bar
             $this->_renderWrappedTemplate('remotecontrol', array('index_view'), $aData);
         }
     }
 }
Example #4
0
 /**
  * Tests functionality of both get() and save()
  */
 public function testGetSave()
 {
     if (!is_writeable('./')) {
         $this->markTestIncomplete('Directory no writable');
     }
     $this->assertTrue(Server\Cache::save($this->_file, $this->_server));
     $expected = $this->_server->listMethods();
     $server = new Server();
     $this->assertTrue(Server\Cache::get($this->_file, $server));
     $actual = $server->listMethods();
     $this->assertSame($expected, $actual);
 }
Example #5
0
 /**
  * Tests functionality of both get() and save()
  */
 public function testGetSave()
 {
     if (!is_writeable('./')) {
         throw new PHPUnit_Framework_IncompleteTestError('Directory not writeable');
     }
     $this->assertTrue(Zend_XmlRpc_Server_Cache::save($this->_file, $this->_server));
     $expected = $this->_server->listMethods();
     $server = new Zend_XmlRpc_Server();
     $this->assertTrue(Zend_XmlRpc_Server_Cache::get($this->_file, $server));
     $actual = $server->listMethods();
     $this->assertSame($expected, $actual);
 }
Example #6
0
 /**
  * Ping should be called when new content is created
  */
 public function pingAction()
 {
     //Do not render anything, otherwise there will be an xml parse error
     $this->getHelper('viewRenderer')->setNoRender();
     $this->_helper->layout->disableLayout();
     try {
         //set up a new factory Zend xmlrpc server and add classes
         $server = new Zend_XmlRpc_Server();
         $server->setClass('Ifphp_Ping_XmlRpc', 'pingback');
         //success
         echo $server->handle();
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #7
0
 public function testMulticallReturnsFaultsWithBadData()
 {
     // bad method array
     $try = array('system.listMethods', array('name' => 'system.listMethods'), array('methodName' => 'system.listMethods'), array('methodName' => 'system.listMethods', 'params' => ''), array('methodName' => 'system.multicall', 'params' => array()));
     $returned = $this->_server->multicall($try);
     $this->assertTrue(is_array($returned));
     $this->assertEquals(5, count($returned));
     $response = $returned[0];
     $this->assertTrue(is_array($response));
     $this->assertTrue(isset($response['faultCode']));
     $this->assertEquals(601, $response['faultCode']);
     $response = $returned[1];
     $this->assertTrue(is_array($response));
     $this->assertTrue(isset($response['faultCode']));
     $this->assertEquals(602, $response['faultCode']);
     $response = $returned[2];
     $this->assertTrue(is_array($response));
     $this->assertTrue(isset($response['faultCode']));
     $this->assertEquals(603, $response['faultCode']);
     $response = $returned[3];
     $this->assertTrue(is_array($response));
     $this->assertTrue(isset($response['faultCode']));
     $this->assertEquals(604, $response['faultCode']);
     $response = $returned[4];
     $this->assertTrue(is_array($response));
     $this->assertTrue(isset($response['faultCode']));
     $this->assertEquals(605, $response['faultCode']);
 }
 /**
  * Run webservice
  *
  * @param Mage_Api_Controller_Action $controller
  * @return Mage_Api_Model_Server_Adapter_Xmlrpc
  */
 public function run()
 {
     $this->_xmlRpc = new Zend_XmlRpc_Server();
     $this->_xmlRpc->setClass($this->getHandler());
     $this->getController()->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($this->_xmlRpc->handle());
     return $this;
 }
Example #9
0
 public function xmlrpcServerAction()
 {
     // disable layout and view
     $this->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     // set output format
     header('Content-Type: text/xml');
     // handle server request
     Zend_XmlRpc_Server_Fault::attachFaultException('Exception');
     $server = new Zend_XmlRpc_Server();
     $server->setClass('MyProject_Service_XmlRpc_Example', 'example');
     $response = $server->handle();
     // display response
     echo $response;
     exit(0);
 }
Example #10
0
 /**
  * Run webservice
  *
  * @return Mage_Api_Model_Server_Adapter_Xmlrpc
  */
 public function run()
 {
     $apiConfigCharset = Mage::getStoreConfig("api/config/charset");
     $this->_xmlRpc = new Zend_XmlRpc_Server();
     $this->_xmlRpc->setEncoding($apiConfigCharset)->setClass($this->getHandler());
     $this->getController()->getResponse()->clearHeaders()->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)->setBody($this->_xmlRpc->handle());
     return $this;
 }
Example #11
0
 /**
  * Test request/response encoding (alternate encoding)
  */
 public function testRequestResponseEncoding2()
 {
     $this->_server->setEncoding('ISO-8859-1');
     $response = $this->_server->handle();
     $request = $this->_server->getRequest();
     $this->assertEquals('ISO-8859-1', $request->getEncoding());
     $this->assertEquals('ISO-8859-1', $response->getEncoding());
 }
Example #12
0
 /**
  * Add dispatch table from a file
  *
  * Unserializes a stored dispatch table. Returns false if it
  * fails in any way, true on success.
  *
  * Useful to prevent needing to build the dispatch list on each XMLRPC
  * request. Sample usage:
  *
  * <code>
  * if (!Zym_XmlRpc_Server_Cache::get($id, $coreCache, $server)) {
  *     require_once 'Some/Service/Class.php';
  *     require_once 'Another/Service/Class.php';
  *
  *     // Attach Some_Service_Class with namespace 'some'
  *     $server->setClass('Some_Service_Class', 'some');
  *
  *     // Attach Another_Service_Class with namespace 'another'
  *     $server->setClass('Another_Service_Class', 'another');
  *
  *     Zym_XmlRpc_Server_Cache::save($id, $coreCache, $server);
  * }
  *
  * $response = $server->handle();
  * echo $response;
  * </code>
  *
  * @param string             $id
  * @param Zend_Cache_Core    $coreCache
  * @param Zend_XmlRpc_Server $server
  *
  * @return boolean
  */
 public static function get($id, Zend_Cache_Core $coreCache, Zend_XmlRpc_Server $server)
 {
     $dispatchArray = @unserialize($coreCache->load($id, false, true));
     try {
         $server->loadFunctions($dispatchArray);
     } catch (Zend_XmlRpc_Server_Exception $e) {
         return false;
     }
     return true;
 }
Example #13
0
 /**
  * @see ZF-2872
  */
 public function testCanMarshalBase64Requests()
 {
     $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test');
     $data = base64_encode('this is the payload');
     $param = array('type' => 'base64', 'value' => $data);
     $request = new Zend_XmlRpc_Request('test.base64', array($param));
     $response = $this->_server->handle($request);
     $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
     $this->assertEquals($data, $response->getReturnValue());
 }
 /**
  * Raise an xmlrpc server fault
  *
  * Moodle note: the difference with the Zend server is that we throw a plain PHP Exception
  * with the debuginfo integrated to the exception message when DEBUG >= NORMAL
  *
  * @param string|Exception $fault
  * @param int $code
  * @return Zend_XmlRpc_Server_Fault
  */
 public function fault($fault = null, $code = 404)
 {
     //intercept any exceptions with debug info and transform it in Moodle exception
     if ($fault instanceof Exception) {
         //add the debuginfo to the exception message if debuginfo must be returned
         if (debugging() and isset($fault->debuginfo)) {
             $fault = new Exception($fault->getMessage() . ' | DEBUG INFO: ' . $fault->debuginfo, 0);
         }
     }
     return parent::fault($fault, $code);
 }
Example #15
0
 /**
  * This is the XML-RPC server routine
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $RPCType = Yii::app()->getConfig("RPCInterface");
     if ($RPCType == 'xml') {
         $cur_path = get_include_path();
         set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers');
         // Yii::import was causing problems for some odd reason
         require_once 'Zend/XmlRpc/Server.php';
         require_once 'Zend/XmlRpc/Server/Exception.php';
         require_once 'Zend/XmlRpc/Value/Exception.php';
         $this->xmlrpc = new Zend_XmlRpc_Server();
         $this->xmlrpc->sendArgumentsToAllMethods(false);
         $this->xmlrpc->setClass('remotecontrol_handle', '', $this->controller);
         echo $this->xmlrpc->handle();
     } elseif ($RPCType == 'json') {
         Yii::app()->loadLibrary('jsonRPCServer');
         $oHandler = new remotecontrol_handle($this->controller);
         jsonRPCServer::handle($oHandler);
     }
     exit;
 }
Example #16
0
 /**
  * Tests functionality of both get() and save()
  *
  * @return void
  */
 public function testGetSave()
 {
     if (!is_writeable(dirname(__FILE__))) {
         $this->markTestIncomplete('Directory no writable');
     }
     $this->assertTrue(Zym_XmlRpc_Server_Cache::save('cache', $this->_cache, $this->_server));
     $expected = $this->_server->listMethods();
     $server = new Zend_XmlRpc_Server();
     $this->assertTrue(Zym_XmlRpc_Server_Cache::get('cache', $this->_cache, $server));
     $actual = $server->listMethods();
     $this->assertSame($expected, $actual);
 }
Example #17
0
 /**
  * This is the XML-RPC server routine
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $oHandler = new remotecontrol_handle($this->controller);
     $RPCType = Yii::app()->getConfig("RPCInterface");
     if (Yii::app()->getRequest()->isPostRequest) {
         if ($RPCType == 'xml') {
             $cur_path = get_include_path();
             set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers');
             // Yii::import was causing problems for some odd reason
             require_once 'Zend/XmlRpc/Server.php';
             require_once 'Zend/XmlRpc/Server/Exception.php';
             require_once 'Zend/XmlRpc/Value/Exception.php';
             $this->xmlrpc = new Zend_XmlRpc_Server();
             $this->xmlrpc->sendArgumentsToAllMethods(false);
             $this->xmlrpc->setClass($oHandler);
             echo $this->xmlrpc->handle();
         } elseif ($RPCType == 'json') {
             Yii::app()->loadLibrary('jsonRPCServer');
             jsonRPCServer::handle($oHandler);
         }
         exit;
     } else {
         // Disabled output of API methods for now
         if (1 == 2 && in_array($RPCType, array('xml', 'json'))) {
             $reflector = new ReflectionObject($oHandler);
             foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
                 /* @var $method ReflectionMethod */
                 if (substr($method->getName(), 0, 1) !== '_') {
                     $list[$method->getName()] = array('description' => str_replace(array("\r", "\r\n", "\n"), "<br/>", $method->getDocComment()), 'parameters' => $method->getParameters());
                 }
             }
             ksort($list);
             $aData['method'] = $RPCType;
             $aData['list'] = $list;
             $aData['display']['menu_bars'] = false;
             // Hide normal menu bar
             $this->_renderWrappedTemplate('remotecontrol', array('index_view'), $aData);
         }
     }
 }
Example #18
0
 /**
  * multicall() test
  *
  * Call as method call 
  *
  * Expects:
  * - methods: 
  * 
  * Returns: array 
  */
 public function testMulticall()
 {
     $struct = array(array('methodName' => 'system.listMethods', 'params' => array()), array('methodName' => 'system.methodHelp', 'params' => array('system.multicall')));
     $request = new Zend_XmlRpc_Request();
     $request->setMethod('system.multicall');
     $request->addParam($struct);
     $response = $this->_server->handle($request);
     $this->assertTrue($response instanceof Zend_XmlRpc_Response, $response->__toString());
     $returns = $response->getReturnValue();
     $this->assertTrue(is_array($returns));
     $this->assertEquals(2, count($returns));
     $this->assertTrue(is_array($returns[0]), var_export($returns[0], 1));
     $this->assertTrue(is_string($returns[1]), var_export($returns[1], 1));
 }
 /**
  * receive a ping
  */
 public function pingAction()
 {
     $owApp = OntoWiki::getInstance();
     $logger = $owApp->logger;
     $logger->debug('Pingback Server Init.');
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $this->_owApp->appendMessage(new OntoWiki_Message('Ping received.', OntoWiki_Message::INFO));
     $post = $this->_request->getPost();
     if (isset($post['source']) && isset($post['target'])) {
         // Simplified Semantic Pingback
         // read config and put it into options
         $options = array();
         $config = $this->_privateConfig;
         if (isset($config->rdfa->enabled)) {
             $options['rdfa'] = $config->rdfa->enabled;
         }
         if (isset($config->titleProperties)) {
             $options['title_properties'] = $config->titleProperties->toArray();
         }
         if (isset($config->genericRelation)) {
             $options['generic_relation'] = $config->genericRelation;
         }
         $ping = new Erfurt_Ping($options);
         echo $ping->receive($post['source'], $post['target']);
         return;
     } else {
         // Create XML RPC Server
         $server = new Zend_XmlRpc_Server();
         $server->setClass($this, 'pingback');
         // Let the server handle the RPC calls.
         $response = $this->getResponse();
         $response->setBody($server->handle());
         return;
     }
 }
Example #20
0
 public function run()
 {
     $enable = $this->get_enable();
     if (empty($enable)) {
         die;
     }
     include "Zend/Loader.php";
     Zend_Loader::registerAutoload();
     Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception');
     // retrieve the token from the url
     // if the token doesn't exist, set a class containing only get_token()
     $token = optional_param('token', null, PARAM_ALPHANUM);
     if (empty($token)) {
         $server = new Zend_XmlRpc_Server();
         $server->setClass("ws_authentication", "authentication");
         echo $server->handle();
     } else {
         // if token exist, do the authentication here
         /// TODO: following function will need to be modified
         $user = webservice_lib::mock_check_token($token);
         if (empty($user)) {
             throw new moodle_exception('wrongidentification');
         } else {
             /// TODO: probably change this
             global $USER;
             $USER = $user;
         }
         //retrieve the api name
         $classpath = optional_param(classpath, null, PARAM_ALPHA);
         require_once dirname(__FILE__) . '/../../' . $classpath . '/external.php';
         /// run the server
         $server = new Zend_XmlRpc_Server();
         $server->setClass($classpath . "_external", $classpath);
         echo $server->handle();
     }
 }
Example #21
0
    /**
     * Multicall - boxcar feature of XML-RPC for calling multiple methods
     * in a single request.
     *
     * Expects a an array of structs representing method calls, each element
     * having the keys:
     * - methodName
     * - params
     *
     * Returns an array of responses, one for each method called, with the value
     * returned by the method. If an error occurs for a given method, returns a
     * struct with a fault response.
     *
     * @see http://www.xmlrpc.com/discuss/msgReader$1208
     * @param  array $methods
     * @return array
     */
    public function multicall($methods)
    {
        $responses = array();
        foreach ($methods as $method) {
            $fault = false;
            if (!is_array($method)) {
                $fault = $this->_server->fault('system.multicall expects each method to be a struct', 601);
            } elseif (!isset($method['methodName'])) {
                $fault = $this->_server->fault('Missing methodName: ' . var_export($methods, 1), 602);
            } elseif (!isset($method['params'])) {
                $fault = $this->_server->fault('Missing params', 603);
            } elseif (!is_array($method['params'])) {
                $fault = $this->_server->fault('Params must be an array', 604);
            } else {
                if ('system.multicall' == $method['methodName']) {
                    // don't allow recursive calls to multicall
                    $fault = $this->_server->fault('Recursive system.multicall forbidden', 605);
                }
            }

            if (!$fault) {
                try {
                    $request = new Zend_XmlRpc_Request();
                    $request->setMethod($method['methodName']);
                    $request->setParams($method['params']);
                    $response = $this->_server->handle($request);
                    if ($response instanceof Zend_XmlRpc_Fault
                        || $response->isFault()
                    ) {
                        $fault = $response;
                    } else {
                        $responses[] = $response->getReturnValue();
                    }
                } catch (Exception $e) {
                    $fault = $this->_server->fault($e);
                }
            }

            if ($fault) {
                $responses[] = array(
                    'faultCode'   => $fault->getCode(),
                    'faultString' => $fault->getMessage()
                );
            }
        }

        return $responses;
    }
Example #22
0
 /**
  * Generate a server fault
  *
  * Note that the arguments are reverse to those of Zend_XmlRpc_Server_Fault.
  *
  * note: the difference with the Zend server is that we throw a Zend_XmlRpc_Server_Fault exception
  * with the debuginfo integrated to the exception message when DEBUG >= NORMAL
  *
  * If an exception is passed as the first argument, its message and code
  * will be used to create the fault object if it has been registered via
  * {@Link registerFaultException()}.
  *
  * @param  string|Exception $fault
  * @param  string $code XMLRPC Fault Codes
  * @return Zend_XmlRpc_Server_Fault
  */
 public function fault($fault = null, $code = 404)
 {
     //run the zend code that clean/create a xmlrpcfault
     $xmlrpcfault = parent::fault($fault, $code);
     //intercept any exceptions and add the errorcode and debuginfo (optional)
     $actor = null;
     $details = null;
     if ($fault instanceof Exception) {
         //add the debuginfo to the exception message if debuginfo must be returned
         if (ws_debugging() and isset($fault->debuginfo)) {
             $details = $fault->debuginfo;
         }
     }
     $fault = new Zend_XmlRpc_Server_Fault($xmlrpcfault);
     $fault->setCode($xmlrpcfault->getCode());
     $fault->setMessage($xmlrpcfault->getMessage() . ' | ERRORCODE: ' . $xmlrpcfault->getCode() . ' | DETAILS: ' . $details);
     return $fault;
 }
Example #23
0
 /**
  * Raise an xmlrpc server fault
  *
  * Moodle note: the difference with the Zend server is that we throw a plain PHP Exception
  * with the debuginfo integrated to the exception message when DEBUG >= NORMAL
  *
  * @param string|Exception $fault
  * @param int $code
  * @return Zend_XmlRpc_Server_Fault
  */
 public function fault($fault = null, $code = 404)
 {
     // Intercept any exceptions with debug info and transform it in Moodle exception.
     if ($fault instanceof Exception) {
         // Code php exception must be a long
         // we obtain a hash of the errorcode, and then to get an integer hash.
         $code = base_convert(md5($fault->errorcode), 16, 10);
         // Code php exception being a long, it has a maximum number of digits.
         // we strip the $code to 8 digits, and hope for no error code collisions.
         // Collisions should be pretty rare, and if needed the client can retrieve
         // the accurate errorcode from the last | in the exception message.
         $code = substr($code, 0, 8);
         // Add the debuginfo to the exception message if debuginfo must be returned.
         if (debugging() and isset($fault->debuginfo)) {
             $fault = new Exception($fault->getMessage() . ' | DEBUG INFO: ' . $fault->debuginfo . ' | ERRORCODE: ' . $fault->errorcode, $code);
         } else {
             $fault = new Exception($fault->getMessage() . ' | ERRORCODE: ' . $fault->errorcode, $code);
         }
     }
     return parent::fault($fault, $code);
 }
Example #24
0
<?php

require 'startzend.php';
require 'Hp12c.php';
$server = new Zend_XmlRpc_Server();
$server->setClass('Hp12c', 'calculadora');
echo $server->handle();
Example #25
0
 /**
  * Add dispatch table from a file
  *
  * Unserializes a stored dispatch table from $filename. Returns false if it
  * fails in any way, true on success.
  *
  * Useful to prevent needing to build the dispatch list on each XMLRPC
  * request. Sample usage:
  *
  * <code>
  * if (!Zend_XmlRpc_Server_Cache::get($filename, $server)) {
  *     require_once 'Some/Service/Class.php';
  *     require_once 'Another/Service/Class.php';
  *
  *     // Attach Some_Service_Class with namespace 'some'
  *     $server->attach('Some_Service_Class', 'some');
  *
  *     // Attach Another_Service_Class with namespace 'another'
  *     $server->attach('Another_Service_Class', 'another');
  *
  *     Zend_XmlRpc_Server_Cache::save($filename, $server);
  * }
  *
  * $response = $server->handle();
  * echo $response;
  * </code>
  *
  * @param string $filename
  * @param Zend_XmlRpc_Server $server
  * @return bool
  */
 public static function get($filename, Zend_XmlRpc_Server $server)
 {
     if (!is_string($filename) || !file_exists($filename) || !is_readable($filename)) {
         return false;
     }
     if (false === ($dispatch = @file_get_contents($filename))) {
         return false;
     }
     if (false === ($dispatchArray = @unserialize($dispatch))) {
         return false;
     }
     $server->loadFunctions($dispatchArray);
     return true;
 }
Example #26
0
 * $vacation = $xmlrpc->getProxy('vacation');
 *
 * if($vacation->checkVacation()) {
 *     echo "Vacation turned on for user";
 * }
 *
 * Note, the requirement that your XmlRpc client provides cookies with each request.
 * If it does not do this, then your authentication details will not persist across requests, and 
 * this XMLRPC interface will not work.
 */
require_once dirname(__FILE__) . '/common.php';
if ($CONF['xmlrpc_enabled'] == false) {
    die("xmlrpc support disabled");
}
require_once 'Zend/XmlRpc/Server.php';
$server = new Zend_XmlRpc_Server();
/**
 * @param string $username
 * @param string $password
 * @return boolean true on success, else false.
 */
function login($username, $password)
{
    $h = new MailboxHandler();
    if ($h->login($username, $password)) {
        session_regenerate_id();
        $_SESSION['authenticated'] = true;
        $_SESSION['sessid'] = array();
        $_SESSION['sessid']['username'] = $username;
        return true;
    }
 public function testCreatingFaultWithEmptyMessageResultsInUnknownError()
 {
     $fault = $this->_server->fault('', 123);
     $this->assertSame('Unknown Error', $fault->getMessage());
     $this->assertSame(123, $fault->getCode());
 }
/** Test utility when calling the page from your HTTP browser */
function browserTestMessage()
{
    echo "<h1>Hello, This is the Magento/OpenERP Connector by <a href='http://www.smile.fr'>Smile.fr</a></h1> We will now perform some basic test about your installation.<br/> You should get and no error or warning here</br></br></br>";
    echo "1) Presence of connector file ---> YES<br/><br/>";
    echo "2) Bootsrapping Magento... <br/>";
    echo "- IF YOU GET AN ERROR HERE LIKE 'Uncaught exception 'Exception' with message 'Warning: Cannot modify header information' THEN CLEAR YOUR BROWSER COOKIES AND REFRESH THE PAGE TO TEST AGAIN -<br/>";
    require_once '../../../Mage.php';
    //Magento import
    Mage::app();
    echo "<br/>&nbsp; &nbsp; &nbsp; &nbsp; --->OK<br/><br/>";
    echo "3) minimal (but might not be enough) testing of your PHP XML/RPC lib ";
    require_once '../../../../lib/Zend/XmlRpc/Server.php';
    $server = new Zend_XmlRpc_Server();
    $server->setClass('OpenERPConnector');
    echo "--->OK<br/>";
    echo "4) SECURITY: DON'T FORGET TO SET UP YOUR APACHE PROPERLY (NOT TESTED HERE) TO AVOID CONNECTION TO THAT PAGE FROM ANY OTHER IP THAN YOU OPENERP!!!<br/><br/>";
    echo "5) Information about your PHP installation:<br/>";
    phpinfo();
}
Example #29
0
$application->bootstrap();
/**
 * Force the cache manager because for some reason it ends up empty without
 * setting the manager manually
 */
$cache = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache');
$cache->setManager($application->getBootstrap()->getResource('cachemanager'));
switch ($_GET['format']) {
    case 'json':
        $server = new Zend_Json_Server();
        // Indicate the URL endpoint, and the JSON-RPC version used:
        $server->setTarget('/api/jsonrpc/')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
        $contentTypeHeader = 'Content-Type: text/json';
        break;
    case 'xml':
        $server = new Zend_XmlRpc_Server();
        Zend_XmlRpc_Server_Fault::attachFaultException('FFR_Exception');
        Zend_XmlRpc_Server_Fault::attachFaultException('Zend_Exception');
        $contentTypeHeader = 'Content-Type: text/xml';
        break;
}
$apiList = Zym_Message_Dispatcher::get()->post('buildApi')->getResult('buildApi');
foreach ($apiList as $key => $services) {
    foreach ($services as $service => $class) {
        $server->setClass($class, $service);
    }
}
if ('GET' == $_SERVER['REQUEST_METHOD'] && $_GET['format'] == 'json') {
    // Grab the SMD
    $smd = $server->getServiceMap();
    // Return the SMD to the client
Example #30
0
<?php

error_reporting(E_ALL & ~E_WARNING);
ini_set('display_errors', true);
require_once 'Zend/XmlRpc/Server.php';
$server = new Zend_XmlRpc_Server();
$server->addFunction('getPhpInfo');
echo $server->handle();
/**
 * @return string
 */
function getPhpInfo()
{
    return file_get_contents('./phpinfo.html');
}