Example #1
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);
         }
     }
 }
 /**
  * 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;
 }
 public function indexAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $server = new Zend_XmlRpc_Server();
     $server->setClass('Application_Model_Data', 'cf');
     echo $server->handle();
 }
Example #4
0
 public function testHandleClassStaticMethod()
 {
     $this->_server->setClass('Zend_XmlRpc_Server_testClass');
     $request = new Zend_XmlRpc_Request();
     $request->setMethod('test2');
     $request->addParam(array('value1', 'value2'));
     $response = $this->_server->handle($request);
     $this->assertEquals('value1; value2', $response->getReturnValue());
 }
Example #5
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 #6
0
 /**
  * setClass() test
  */
 public function testSetClass()
 {
     $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test');
     $methods = $this->_server->listMethods();
     $this->assertTrue(in_array('test.test1', $methods));
     $this->assertTrue(in_array('test.test2', $methods));
     $this->assertFalse(in_array('test._test3', $methods));
     $this->assertFalse(in_array('test.__construct', $methods));
 }
Example #7
0
 /**
  * @group ZF-2872
  */
 public function testCanMarshalBase64Requests()
 {
     $this->_server->setClass('ZendTest\\XmlRpc\\TestClass', 'test');
     $data = base64_encode('this is the payload');
     $param = array('type' => 'base64', 'value' => $data);
     $request = new Request('test.base64', array($param));
     $response = $this->_server->handle($request);
     $this->assertFalse($response instanceof XmlRpc\Fault);
     $this->assertEquals($data, $response->getReturnValue());
 }
Example #8
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 #9
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 #10
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 #11
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);
 }
 /**
  * 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 #13
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 #14
0
<?php

require_once dirname(__FILE__) . '/bootstrap.php';
$plugin = Zend_Registry::get('init');
$request = $plugin->getRequest();
if ($request->isGet()) {
    header('HTTP/1.0 501 Not Supported');
    echo "<h1>501 - Not Supported</h1>";
    exit;
}
$plugin->initDb();
$loader = new My_Controller_Helper_ResourceLoader();
$loader->initModule('spindle');
$paste = $loader->getService('Paste');
$server = new Zend_XmlRpc_Server();
$server->setClass($paste);
echo $server->handle();
Example #15
0
#!/usr/bin/env php
<?php 
chdir(dirname(__FILE__));
require_once '../php/setup.php';
// map errors to exceptions
function errorHandler($errno, $errstr, $errfile, $errline)
{
    if (error_reporting()) {
        throw new Exception($errstr);
        // internal error not to be mapped to fault
    }
    return true;
}
error_reporting(E_ALL & ~E_NOTICE);
set_error_handler('errorHandler', E_ALL & ~E_NOTICE);
// construct facade objects
$server = new Zend_XmlRpc_Server();
$server->setClass(new Wikidot_Facade_User(), 'user');
$server->setClass(new Wikidot_Facade_Site(), 'site');
$server->setClass(new Wikidot_Facade_Page(), 'page');
$server->setClass(new Wikidot_Facade_Forum(), 'forum');
Zend_XmlRpc_Server_Cache::save('/tmp/xmlrpcapi.cache', $server);
// map Wikidot_Facade_Exception to XML-RPC faults
Zend_XmlRpc_Server_Fault::attachFaultException('Wikidot_Facade_Exception');
Zend_XmlRpc_Server_Fault::attachFaultException('WDPermissionException');
// run XML-RPC server
echo $server->handle(new Zend_XmlRpc_Request_Stdin());
    $server->setClass('CnCNet_Api');
    if ($type == 'jsonp') {
        $server->setRequest(new CnCNet_Json_Server_Request_Http_Jsonp());
        $server->setResponse(new CnCNet_Json_Server_Response_Http_Jsonp());
    } else {
        if ($_SERVER['REQUEST_METHOD'] == 'GET') {
            echo $server->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2)->getServiceMap();
            return;
        }
    }
    $server->handle();
} else {
    if ($type == 'xml') {
        header('Content-type: text/xml');
        $server = new Zend_XmlRpc_Server();
        $server->setClass('CnCNet_Api');
        echo $server->handle();
    } else {
        if ($type == 'dumb') {
            header('Content-type: text/plain; charset=UTF-8');
            $server = new CnCNet_Api();
            if (isset($_GET['method']) && method_exists($server, $_GET['method'])) {
                try {
                    @($ret = call_user_func_array(array($server, $_GET['method']), isset($_GET['params']) ? is_array($_GET['params']) ? $_GET['params'] : array($_GET['params']) : array()));
                } catch (Exception $e) {
                    header('HTTP/1.0 500 Internal Server Error');
                    echo '500 Internal Server Error (Exception from API)';
                    exit;
                }
                function to_dumb_string($var)
                {
Example #17
0
<?php

require 'startzend.php';
require 'Hp12c.php';
$server = new Zend_XmlRpc_Server();
$server->setClass('Hp12c', 'calculadora');
echo $server->handle();
Example #18
0
 /**
  * Setup environment
  *
  * @return void
  */
 public function setUp()
 {
     $this->_server = new Zend_XmlRpc_Server();
     $this->_server->setClass('Zym_XmlRpc_Server_Cache', 'cache');
     $this->_cache = Zend_Cache::factory('Core', 'File', array(), array('cache_dir' => dirname(__FILE__)));
 }
Example #19
0
 /**
  * Setup environment
  */
 public function setUp()
 {
     $this->_file = realpath(dirname(__FILE__)) . '/xmlrpc.cache';
     $this->_server = new Zend_XmlRpc_Server();
     $this->_server->setClass('Zend_XmlRpc_Server_Cache', 'cache');
 }
/** 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 #21
0
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;
    }
    return false;
}
if (!isset($_SESSION['authenticated'])) {
    $server->addFunction('login', 'login');
} else {
    $server->setClass('UserProxy', 'user');
    $server->setClass('VacationProxy', 'vacation');
    $server->setClass('AliasProxy', 'alias');
}
echo $server->handle();
class UserProxy
{
    /**
     * @param string $old_password
     * @param string $new_password
     * @return boolean true on success
     */
    public function changePassword($old_password, $new_password)
    {
        $uh = new MailboxHandler();
        if (!$uh->init($_SESSION['sessid']['username'])) {
Example #22
0
 /**
  * Ping back for the site
  */
 public function pingBackAction()
 {
     $feeds = new Feeds();
     $feed = $feeds->getByToken($this->getRequest()->getParam('token'));
     $this->updateFeedPosts($feed);
     $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 #23
0
$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
    header($contentTypeHeader);
    echo $smd;
    return;
}
echo $server->handle();
Example #24
0
<?php

require 'startzend.php';
require 'Moeda.php';
$server = new Zend_XmlRpc_Server();
$server->setClass('Moeda');
echo $server->handle();
Example #25
0
<?php

require_once 'Zend/XmlRpc/Server.php';
class MyService
{
    public function sayHello($arg1)
    {
        return "Hi " . $arg1;
    }
}
$server = new Zend_XmlRpc_Server();
$server->setClass('MyService');
echo $server->handle();
 /**
  * @group ZF-6034
  */
 public function testPrototypeReturnValueMustReflectDocBlock()
 {
     $server = new Zend_XmlRpc_Server();
     $server->setClass('Zend_XmlRpc_Server_testClass');
     $table = $server->getDispatchTable();
     $method = $table->getMethod('test1');
     foreach ($method->getPrototypes() as $prototype) {
         $this->assertNotEquals('void', $prototype->getReturnType(), var_export($prototype, 1));
     }
 }
Example #27
0
 /**
  * Setup environment
  */
 public function setUp()
 {
     $this->_file = realpath(__DIR__) . '/xmlrpc.cache';
     $this->_server = new Server();
     $this->_server->setClass('Zend\\XmlRpc\\Server\\Cache', 'cache');
 }
Example #28
0
<?php

/**
 * Wikidot - free wiki collaboration software
 * Copyright (c) 2008, Wikidot Inc.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * For more information about licensing visit:
 * http://www.wikidot.org/license
 * 
 * @category Wikidot
 * @package Wikidot_Web
 * @version $Id$
 * @copyright Copyright (c) 2008, Wikidot Inc.
 * @license http://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License
 */
require_once '../php/setup.php';
require_once 'Zend/XmlRpc/Server.php';
$server = new Zend_XmlRpc_Server();
$server->setClass('PingBackServer', 'pingback');
echo $server->handle();