private function setupRPC() { /*** * We support JSONP for all services */ $isJSONP = false; $hasJSONP = true; if ($hasJSONP) { $isJSONP = XApp_Service_Entry_Utils::isJSONP(); } $method = $_SERVER['REQUEST_METHOD']; if ($method === 'POST') { $hasJSONP = false; } /*** * Filtered methods */ $ignoredRPCMethods = array('load', 'getObject', 'init', 'setup', 'log', 'onBeforeCall', 'onAfterCall', 'dumpObject', 'applyFilter', 'getLastJSONError', 'cleanUrl', 'rootUrl', 'siteUrl', 'getXCOption', 'getIndexer', 'getIndexOptions', 'getIndexOptions', 'indexDocument', 'onBeforeSearch', 'toDSURL', 'searchTest'); if (xapp_get_option(self::IGNORED_RPC_METHODS, $this)) { $ignoredRPCMethods = array_merge(xapp_get_option(self::IGNORED_RPC_METHODS, $this), $ignoredRPCMethods); } elseif (xapp_has_option(self::AUTH_DELEGATE, $this)) { /*** * Additional security here, mark each service method which has not been authorized by the * auth delegate as ignored! */ $authDelegate = xapp_get_option(self::AUTH_DELEGATE, $this); if (method_exists($authDelegate, 'authorize')) { $xCommanderFunctionTable = XApp_Service_Entry_Utils::getXCommanderFuncTable(); foreach ($xCommanderFunctionTable as $key => $value) { if (!$authDelegate::authorize($value)) { array_push($ignoredRPCMethods, $value); } } } } $server = null; if ($hasJSONP && $isJSONP) { //Options for SMD based JSONP-RPC classes $opt = array(Xapp_Rpc_Smd::IGNORE_METHODS => $ignoredRPCMethods, Xapp_Rpc_Smd::IGNORE_PREFIXES => array('_', '__')); $smd = new Xapp_Rpc_Smd_Jsonp($opt); //Options for RPC server $opt = array(Xapp_Rpc_Server::ALLOW_FUNCTIONS => true, Xapp_Rpc_Server::APPLICATION_ERROR => false, Xapp_Rpc_Server::METHOD_AS_SERVICE => true, Xapp_Rpc_Server::DEBUG => XApp_Service_Entry_Utils::isDebug(), Xapp_Rpc_Server::SMD => $smd); $server = Xapp_Rpc::server(XApp_Service_Entry_Utils::isRaw() ? 'raw' : 'jsonp', $opt); } else { //Options for SMD based RPC classes $opt = array(Xapp_Rpc_Smd_Json::IGNORE_METHODS => $ignoredRPCMethods, Xapp_Rpc_Smd_Json::IGNORE_PREFIXES => array('_', '__'), Xapp_Rpc_Smd_Json::METHOD_TARGET => false, Xapp_Rpc_Smd_Json::SERVICE_OVER_GET => true, Xapp_Rpc_Smd_Json::TARGET => xapp_get_option(self::RPC_TARGET, $this)); $smd = new Xapp_Rpc_Smd_Json($opt); //Options for RPC server $opt = array(Xapp_Rpc_Server::ALLOW_FUNCTIONS => true, Xapp_Rpc_Server::APPLICATION_ERROR => false, Xapp_Rpc_Server::METHOD_AS_SERVICE => false, Xapp_Rpc_Server::ALLOW_BATCHED_REQUESTS => true, Xapp_Rpc_Server::SERVICE_OVER_GET => true, Xapp_Rpc_Server::DEBUG => XApp_Service_Entry_Utils::isDebug(), Xapp_Rpc_Server::VALIDATE => !XApp_Service_Entry_Utils::isUpload(), Xapp_Rpc_Server::SMD => $smd); $server = Xapp_Rpc::server('json', $opt); } if ($server) { xapp_set_option(self::RPC_SERVER, $server, $this); } }