コード例 #1
0
ファイル: Server.php プロジェクト: jyxo/php
 /**
  * Destroys a class instance.
  */
 public function __destruct()
 {
     parent::__destruct();
     if (is_resource($this->server)) {
         xmlrpc_server_destroy($this->server);
     }
 }
コード例 #2
0
ファイル: pingback.php プロジェクト: bashrc/gnusocial-debian
 function handlePost()
 {
     $server = xmlrpc_server_create();
     xmlrpc_server_register_method($server, 'pingback.ping', array($this, 'ping'));
     echo xmlrpc_server_call_method($server, file_get_contents('php://input'), null, array('encoding' => 'utf-8'));
     xmlrpc_server_destroy($server);
     return true;
 }
コード例 #3
0
 /**
  * Processes an incoming request, executes it and builds a response.
  *
  * @since 5.1
  * @param ModuleServerRequest $request Incoming request.
  * @param ModuleServerResponse $response Outcoming response.
  * @return void
  */
 public function process(ModuleServerRequest $request, ModuleServerResponse $response)
 {
     $command = explode(' ', $request->getCommand());
     $module_location = $command[1];
     if (!strlen($module_location)) {
         $response->sendWarning(ModuleServerResponse::SC_NOT_FOUND, 'Module location not defined.', ModuleServerRsponse::ERROR_CLASSNAME_MISSING);
         return;
     }
     try {
         $locator = new ModuleLocator('module://' . $request->getHeader('User') . ':' . $request->getHeader('Password') . '@/' . $module_location);
         $sessionId = $request->getHeader('Session');
         if ($sessionId) {
             $this->module = ModuleFactory::getSessionModule($locator, $sessionId);
         } else {
             $this->module = ModuleFactory::getModule($locator);
         }
     } catch (ModuleException $e) {
         $response->sendWarning(ModuleServerResponse::SC_INTERNAL_SERVER_ERROR, $e->__toString());
         return;
     } catch (\Exception $e) {
         $response->sendWarning(ModuleServerResponse::SC_INTERNAL_SERVER_ERROR, $e->__toString());
         return;
     }
     if (!($xmlrpc_server = xmlrpc_server_create())) {
         $response->sendWarning(ModuleServerResponse::SC_INTERNAL_SERVER_ERROR, 'Internal error: Could not create an XML-RPC server.', ModuleServerResponse::ERROR_XMLRPC_ERROR);
         return;
     }
     $theClass = new \ReflectionObject($this->module);
     $methods = $theClass->getMethods();
     foreach ($methods as $method) {
         // Ignore private methods
         $theMethod = new \ReflectionMethod($theClass->getName(), $method->getName());
         if (!$theMethod->isPublic()) {
             continue;
         }
         // Expose only methods beginning with "module" prefix
         if (!(substr($method->getName(), 0, 6) == 'module')) {
             continue;
         }
         xmlrpc_server_register_method($xmlrpc_server, strtolower($method->getName()), array($this, 'xmlrpcGateway'));
     }
     xmlrpc_server_register_introspection_callback($xmlrpc_server, array($this, 'introspectionGateway'));
     try {
         $buffer = xmlrpc_server_call_method($xmlrpc_server, $request->getPayload(), '', array('output_type' => 'xml'));
         $response->addHeader('Module/1.0 ' . ModuleServerResponse::SC_OK);
         $response->setBuffer($buffer);
     } catch (\Exception $e) {
         $response->addHeader('Module/1.0 ' . ModuleServerResponse::SC_INTERNAL_ERROR);
         $response->setBuffer($buffer);
     }
     xmlrpc_server_destroy($xmlrpc_server);
     $context = new ModuleContext($module_location);
     $session = new \Innomatic\Module\Session\ModuleSession($context, $sessionId);
     $session->save($this->module);
     $response->addHeader('Session: ' . $session->getId());
 }
コード例 #4
0
 function __construct($payload, $payload_signed, $payload_encrypted)
 {
     $this->payload = $payload;
     // xmlrpc_decode_request is defined such that the '$method' string is
     // passed in by reference.
     $this->params = xmlrpc_decode_request($this->payload, $this->method, 'UTF-8');
     // The method name is not allowed to have a dot, except for a single dot
     // which preceeds the php extension. It can have slashes but it cannot
     // begin with a slash. We specifically don't want .. to be possible.
     if (0 == preg_match("@^[A-Za-z0-9]+/[A-Za-z0-9/_-]+(\\.php/)?[A-Za-z0-9_-]+\$@", $this->method)) {
         throw new XmlrpcServerException('The function does not exist', 6010);
     }
     if ($payload_signed && $payload_encrypted || $this->method == 'system/keyswap') {
         // The remote server's credentials checked out.
         // You might want to enable some methods for unsigned/unencrypted
         // transport
     } else {
         // For now, we throw an exception
         throw new XmlrpcServerException('The signature on your message was not valid', 6005);
     }
     // The system methods are treated differently.
     if (array_key_exists($this->method, $this->system_methods)) {
         $xmlrpcserver = xmlrpc_server_create();
         xmlrpc_server_register_method($xmlrpcserver, $this->method, array(&$this, $this->system_methods[$this->method]));
     } else {
         // Security: I'm thinking that we should not return separate errors for
         //           the file not existing, the file not being readable, etc. as
         //           it might provide an opportunity for outsiders to scan the
         //           server for random files. So just a single message/code for
         //           all failures here kthxbye.
         if (strpos($this->method, '/') !== false) {
             $this->callstack = explode('/', $this->method);
         } else {
             throw new XmlrpcServerException('The function does not exist', 6011);
         }
         // Read custom xmlrpc functions from local
         if (function_exists('local_xmlrpc_services')) {
             foreach (local_xmlrpc_services() as $name => $localservices) {
                 $this->services[$name] = array_merge($this->services[$name], $localservices);
             }
         }
         foreach ($this->services as $container) {
             if (array_key_exists($this->method, $container)) {
                 $xmlrpcserver = xmlrpc_server_create();
                 $bool = xmlrpc_server_register_method($xmlrpcserver, $this->method, 'api_dummy_method');
                 $this->response = xmlrpc_server_call_method($xmlrpcserver, $payload, $container[$this->method], array("encoding" => "utf-8"));
                 $bool = xmlrpc_server_destroy($xmlrpcserver);
                 return $this->response;
             }
         }
         throw new XmlrpcServerException('No such method: ' . $this->method);
     }
     $temp = '';
     $this->response = xmlrpc_server_call_method($xmlrpcserver, $payload, $temp, array("encoding" => "utf-8"));
     return $this->response;
 }
コード例 #5
0
ファイル: XMLRPC.php プロジェクト: difra-org/difra
 /**
  * Request processor
  * @param object $handler
  * @param array|bool $methodsList If omitted, handler should contain getMethods() method
  * @return string
  */
 public function processRequest($handler, $methodsList = false)
 {
     $server = xmlrpc_server_create();
     if (!$methodsList) {
         $methodsList = $handler->getMethods();
     }
     foreach ($methodsList as $method) {
         xmlrpc_server_register_method($server, $method, [$handler, $method]);
     }
     $request = (isset($HTTP_RAW_POST_DATA) and $HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents('php://input');
     $response = xmlrpc_server_call_method($server, $request, null);
     xmlrpc_server_destroy($server);
     return $response;
 }
コード例 #6
0
ファイル: XmlRpcTest.php プロジェクト: psagi/sdo
    private function setUpXmlRpcTypes($xmlrpc_das)
    {
        $typeList = <<<END
<introspection>
    <typeList>

        <typeDescription name='SimpleType' basetype='struct' desc='Simple type'>
    
            <value type='int' name='intValue'></value>
            <value type='double' name='doubleValue'></value>
            <value type='string' name='strValue'></value>

        </typeDescription>

        <typeDescription name='ComplexType' basetype='struct' desc='Complex type'>

            <value type='SimpleType []' name='objArrValue'></value>
            <value type='int []' name='intArrValue'></value>
            <value type='int' name='intValue'></value>
            <value type='double' name='doubleValue'></value>
            <value type='string' name='strValue'></value>
            <value type='SimpleType' name='objValue'></value>

        </typeDescription>
    </typeList>
</introspection>
END;
        $call = <<<END
<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
    <methodName>system.describeMethods</methodName>
    <params/>
</methodCall>
END;
        $xmlrpc_server = xmlrpc_server_create();
        $descArray = xmlrpc_parse_method_descriptions($typeList);
        xmlrpc_server_add_introspection_data($xmlrpc_server, $descArray);
        $response = xmlrpc_server_call_method($xmlrpc_server, $call, null);
        xmlrpc_server_destroy($xmlrpc_server);
        $methodDesc = xmlrpc_decode_request($response, $method);
        $this->xmlrpc_das->addTypesXmlRpc($methodDesc["typeList"]);
    }
コード例 #7
0
    /**
     * Generate
     *
     * @param string $service_description Service Description
     *
     * @return null
     */
    public function generate($service_description)
    {
        SCA::$logger->log("Entering");
        try {
            $xmlrpc_server = xmlrpc_server_create();
            $aliases = array();
            $this->addIntrospectionData($xmlrpc_server, $service_description, $aliases);
            $describeMethods = <<<END
<?xml version="1.0" ?>
<methodCall>
<methodName>system.describeMethods</methodName>
<params/>
</methodCall>
END;
            $desc = xmlrpc_server_call_method($xmlrpc_server, $describeMethods, null);
            xmlrpc_server_destroy($xmlrpc_server);
            header('Content-type: text/xml');
            echo $desc;
        } catch (Exception $se) {
            echo $se->exceptionString() . "\n";
        }
    }
コード例 #8
0
///////////////////////////////////////////////////////////////////////////////
// XML-RPC Server
$xmlrpc_server = xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpc_server, "login_to_simulator", "process_login");
// Read the request
$request_xml = file_get_contents("php://input");
// Check for a login capability
$authUserID = NULL;
if (!empty($_GET['cap'])) {
    $authUserID = get_capability($_GET['cap']);
}
// Build the response
$response = xmlrpc_server_call_method($xmlrpc_server, $request_xml, $authUserID);
header('Content-Type: text/xml');
echo $response;
xmlrpc_server_destroy($xmlrpc_server);
exit;
///////////////////////////////////////////////////////////////////////////////
function make_seed()
{
    list($usec, $sec) = explode(' ', microtime());
    return (double) $sec + (double) $usec * 100000;
}
function inform_scene_of_logout($sceneID, $userID)
{
    if ($sceneID == UUID::Zero) {
        return;
    }
    $scene = lookup_scene_by_id($sceneID);
    if (isset($scene)) {
        // FIXME: Implement this
コード例 #9
0
 function xmlrpc_error($error_number, $error_string)
 {
     $r = CreateObject('phpgwapi.xmlrpcresp', '', $error_number, $error_string . ': ' . $this->last_method);
     $this->service($r);
     xmlrpc_server_destroy($GLOBALS['xmlrpc_server']);
     exit;
 }
コード例 #10
0
        $server = new XML_RPC_Server(array('validatePDF_callback' => array('function' => 'pear_validatePDF_callback')), 1);
        return;
        // execution end here
    }
    if ($xmlrpc['internal']) {
        // use internal xml-rpc implementation (>php-4.1.0 experimental)
        // create server
        unset($GLOBALS['HTTP_RAW_POST_DATA']);
        // save memory
        $xmlrpc_server = xmlrpc_server_create();
        if ($xmlrpc_server) {
            xmlrpc_server_register_method($xmlrpc_server, "validatePDF_callback", "internal_validatePDF_callback");
            $response = '';
            echo xmlrpc_server_call_method($xmlrpc_server, $request_xml, $response, array('output_type' => "xml", 'version' => "auto"));
            // free server resources
            $success = xmlrpc_server_destroy($xmlrpc_server);
        }
        return;
        // execution end here
    }
    // no useable xml-rpc impl. found
    echo 'no useable xml-rpc impl. found';
    informAdmin("no useable xml-rpc impl. found");
}
// function for XML_RPC implementation
function pear_validatePDF_callback($params)
{
    $param = $params->getParam(0);
    $file_data = $param->scalarval();
    // binary
    $param = $params->getParam(1);
コード例 #11
0
ファイル: prettyxmlrpc.php プロジェクト: robbiet480/MineAdmin
 public function __destruct()
 {
     xmlrpc_server_destroy($this->server);
 }
コード例 #12
0
ファイル: server.php プロジェクト: JackCanada/moodle-hacks
/**
 * Initialize the object (if necessary), execute the method or function, and 
 * return the response
 *
 * @param  string  $includefile    The file that contains the object definition
 * @param  string  $methodname     The name of the method to execute
 * @param  string  $method         The full path to the method
 * @param  string  $payload        The XML-RPC request payload
 * @param  string  $class          The name of the class to instantiate (or false)
 * @return string                  The XML-RPC response
 */
function mnet_server_invoke_method($includefile, $methodname, $method, $payload, $class = false)
{
    $permission = mnet_permit_rpc_call($includefile, $methodname, $class);
    if (RPC_NOSUCHFILE == $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(705, 'nosuchfile', $includefile));
    }
    if (RPC_NOSUCHFUNCTION == $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(706, 'nosuchfunction'));
    }
    if (RPC_FORBIDDENFUNCTION == $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(707, 'forbidden-function'));
    }
    if (RPC_NOSUCHCLASS == $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(7013, 'nosuchfunction'));
    }
    if (RPC_NOSUCHMETHOD == $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(7014, 'nosuchmethod'));
    }
    if (RPC_NOSUCHFUNCTION == $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(7014, 'nosuchmethod'));
    }
    if (RPC_FORBIDDENMETHOD == $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(7015, 'nosuchfunction'));
    }
    if (0 < $permission) {
        // Generate error response - unable to locate function
        exit(mnet_server_fault(7019, 'unknownerror'));
    }
    if (RPC_OK == $permission) {
        $xmlrpcserver = xmlrpc_server_create();
        $bool = xmlrpc_server_register_method($xmlrpcserver, $method, 'mnet_server_dummy_method');
        $response = xmlrpc_server_call_method($xmlrpcserver, $payload, $methodname, array("encoding" => "utf-8"));
        $bool = xmlrpc_server_destroy($xmlrpcserver);
        return $response;
    }
}
コード例 #13
0
ファイル: xmlrpc.php プロジェクト: HaakonME/porticoestate
/**
 * Create an XML-RPC error
 *
 * @param integer $error_number
 * @param string $error_string
 * @todo FIXME! This needs to be expanded to handle PHP errors themselfs it will make debugging easier
 */
function xmlrpc_error($error_number, $error_string)
{
    $values = array('faultString' => $error_string, 'faultCode' => $error_number);
    echo xmlrpc_encode_request(NULL, $values, array("encoding" => "utf-8"));
    xmlrpc_server_destroy($GLOBALS['xmlrpc_server']);
    exit;
}
コード例 #14
0
ファイル: XmlrpcServer.php プロジェクト: blar/xmlrpc
 public function __destruct()
 {
     xmlrpc_server_destroy($this->getHandle());
 }
コード例 #15
0
ファイル: server.php プロジェクト: aldegtyarev/vip-kvartira
<?php

/*
Функция-обработчик получаемых данных. $method_name – имя вызываемого метода, $params - параметры, $user_data – пользовательские данные. Подробнее – в документации к PHP.
*/
function local($method_name, $params, $user_data)
{
    /*возвращаем сериализованные входящие данные*/
    return serialize($params);
}
/*создаем сервер*/
$s = xmlrpc_server_create();
/*регистрируем метод-обработчик*/
xmlrpc_server_register_method($s, 'external', 'local');
/*вызываем обработчик, передаем ему входящие данные, если обработчик возвращает что-то – выводим это на экран*/
if ($data = xmlrpc_server_call_method($s, $HTTP_RAW_POST_DATA, null)) {
    echo $data;
}
/*уничтожаем сервер*/
xmlrpc_server_destroy($s);
コード例 #16
0
ファイル: serverlib.php プロジェクト: JP-Git/moodle
/**
 * Initialize the object (if necessary), execute the method or function, and
 * return the response
 *
 * @param  string  $includefile    The file that contains the object definition
 * @param  string  $methodname     The name of the method to execute
 * @param  string  $method         The full path to the method
 * @param  string  $payload        The XML-RPC request payload
 * @param  string  $class          The name of the class to instantiate (or false)
 *
 * @throws mnet_server_exception
 *
 * @return string                  The XML-RPC response
 */
function mnet_server_invoke_dangerous_method($includefile, $methodname, $method, $payload) {

    if (file_exists($CFG->dirroot . $includefile)) {
        require_once $CFG->dirroot . $includefile;
        // $callprefix matches the rpc convention
        // of not having a leading slash
        $callprefix = preg_replace('!^/!', '', $includefile);
    } else {
        throw new mnet_server_exception(705, "nosuchfile");
    }

    if ($functionname != clean_param($functionname, PARAM_PATH)) {
        throw new mnet_server_exception(7012, "nosuchfunction");
    }

    if (!function_exists($functionname)) {
        throw new mnet_server_exception(7012, "nosuchfunction");
    }
    $xmlrpcserver = xmlrpc_server_create();
    xmlrpc_server_register_method($xmlrpcserver, $method, 'mnet_server_dummy_method');
    $response = xmlrpc_server_call_method($xmlrpcserver, $payload, $methodname, array("encoding" => "utf-8"));
    xmlrpc_server_destroy($xmlrpcserver);
    return $response;
}
コード例 #17
0
ファイル: utils.php プロジェクト: gw-acadtech/VCL
function xmlrpcgetaffiliations()
{
    global $xmlrpc_handle, $HTTP_RAW_POST_DATA;
    # create xmlrpc handle
    $xmlrpc_handle = xmlrpc_server_create();
    # register functions available via rpc calls
    xmlrpc_server_register_method($xmlrpc_handle, "XMLRPCaffiliations", "xmlRPChandler");
    print xmlrpc_server_call_method($xmlrpc_handle, $HTTP_RAW_POST_DATA, '');
    xmlrpc_server_destroy($xmlrpc_handle);
    semUnlock();
    dbDisconnect();
    exit;
}
コード例 #18
0
ファイル: XmlRpcServer.php プロジェクト: nickl-/pecl-http
 /**
  * Destructor
  */
 public function __destruct()
 {
     if (self::$refcnt && !--self::$refcnt) {
         xmlrpc_server_destroy(self::$xmlrpc);
     }
 }
コード例 #19
0
ファイル: Server.php プロジェクト: arhe/pwak
 /**
  * Méthoode qui gère les requêtes effectuées par les clients xmlrpc.
  *
  * @access public
  * @return void
  */
 public function handleRequest()
 {
     // récupère le xml envoyé par le client
     $params = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents('php://input');
     // output_options
     // http://xmlrpc-epi.sourceforge.net/main.php?t=php_api#output_options
     $output_options = array('encoding' => $this->encoding, 'verbosity' => 'no_white_space');
     // sette la locale
     if (isset($_SESSION['locale'])) {
         I18N::setLocale($_SESSION['locale']);
     }
     // appelle la méthode
     $response = xmlrpc_server_call_method($this->_server, $params, null, $output_options);
     header('Content-Type: text/xml');
     header('Content-Length: ' . strlen($response));
     echo $response;
     // nettoyage
     xmlrpc_server_destroy($this->_server);
 }
コード例 #20
0
ファイル: xmlrpc.php プロジェクト: andrewhuang/webscheme
function processRequest(&$request_xml)
{
    // define XML-RPC server
    $server = xmlrpc_server_create();
    // log for debuggin
    $fp = fopen("/var/tmp/ws_request.log", "a");
    fwrite($fp, date("H:i") . "\n");
    fwrite($fp, $request_xml);
    fwrite($fp, "\n\n");
    fclose($fp);
    // register methods
    xmlrpc_server_register_method($server, "getQueueValues", "rpc_get_queue_values");
    xmlrpc_server_register_method($server, "pushValue", "rpc_push_value");
    xmlrpc_server_register_method($server, "getStateData", "rpc_get_state_data");
    xmlrpc_server_register_method($server, "setStateData", "rpc_set_state_data");
    xmlrpc_server_register_method($server, "helloWorld", "rpc_hello_world");
    xmlrpc_server_register_method($server, "noop", "rpc_hello_world");
    // call the method
    $response =& xmlrpc_server_call_method($server, $request_xml, '');
    // send back the respond
    print $response;
    // release resources
    xmlrpc_server_destroy($server);
}