/** * Helper function to get and validate server functions * * @param string $strServerCall * @return ezjscServerRouter|null */ static function serverCallHelper($strServerCall) { $server = ezjscServerRouter::getInstance($strServerCall); if (!$server instanceof ezjscServerRouter) { eZDebug::writeError('Not a valid ezjscServer function: ' . implode('::', $strServerCall), __METHOD__); return null; } // Make sure the function is present on the class if (!$server->hasFunction()) { eZDebug::writeError('Could not find function: ' . $server->getName() . '()', __METHOD__); return null; } return $server; }
if ($contentType === 'json') { header('Content-Type: application/json; charset=utf-8'); } } } // abort if no calls where found if (!$callList) { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); $response = array('error_text' => 'No server call defined', 'content' => ''); echo ezjscAjaxContent::autoEncode($response, $contentType); eZExecution::cleanExit(); return; } // prepare calls foreach ($callList as $call) { $temp = ezjscServerRouter::getInstance(explode('::', $call), true, true); $callFnList[] = $temp === null ? $call : $temp; } $callFnListCount = count($callFnList) - 1; // do calls if ($callType === 'stream') { if (isset($Params['interval']) && is_numeric($Params['interval']) && $Params['interval'] > 49) { // intervall in milliseconds, minimum is 0.05 seconds $callInterval = $Params['interval'] * 1000; } else { // default interval is every 0.5 seconds $callInterval = 500 * 1000; } $endTime = time() + 29; while (@ob_end_clean()) { }
// Error: access denied. We respond using an answer which is correct according // to the protocol used by the caller, instead of going through the standard // eZ access denied error handler, which displays in general an html page // with a 200 OK http return code $server->showResponse($functionName, $namespaceURI, new ggWebservicesFault(ggWebservicesServer::INVALIDAUTHERROR, ggWebservicesServer::INVALIDAUTHSTRING)); eZExecution::cleanExit(); die; // $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' ); } } // if integration with jscore is enabled, look up function there // NB: ezjscServerRouter::getInstance does internally perms checking, but // it does not return to us different values for method not found / perms not accorded if ($wsINI->variable('GeneralSettings', 'JscoreIntegration') == 'enabled' && class_exists('ezjscServerRouter')) { if (strpos($functionName, '::') !== false) { $jscserver = ezjscServerRouter::getInstance(array_merge(explode('::', $functionName), $params)); if ($jscserver != null) { $jscresponse = $jscserver->call(); $server->showResponse($functionName, $namespaceURI, $jscresponse); eZExecution::cleanExit(); die; } } } // if jscore did not answer yet, process request the standard way // check perms $user = eZUser::currentUser(); $access = ggeZWebservices::checkAccess($functionName, $user); if (!$access) { $server->showResponse($functionName, $namespaceURI, new ggWebservicesFault(ggWebservicesServer::INVALIDAUTHERROR, ggWebservicesServer::INVALIDAUTHSTRING)); eZExecution::cleanExit();