protected function _initParams()
 {
     global $HTTP_RAW_POST_DATA;
     if (isset($HTTP_RAW_POST_DATA)) {
         $request = $HTTP_RAW_POST_DATA;
     } else {
         $request = file('php://input');
         $request = implode("\n", $request);
     }
     $requestobj = jJsonRpc::decodeRequest($request);
     if ($requestobj['method']) {
         list($module, $action) = explode('~', $requestobj['method']);
     } else {
         $module = '';
         $action = '';
     }
     if (isset($requestobj['id'])) {
         $this->jsonRequestId = $requestobj['id'];
     }
     if (is_array($requestobj['params'])) {
         $this->params = $requestobj['params'];
     }
     $this->params['params'] = $requestobj['params'];
     $this->params['module'] = $module;
     $this->params['action'] = $action;
 }
 public function outputErrors()
 {
     global $gJCoord;
     if (count($gJCoord->errorMessages)) {
         $e = $gJCoord->errorMessages[0];
         $errorCode = $e[1];
         $errorMessage = '[' . $e[0] . '] ' . $e[2] . ' (file: ' . $e[3] . ', line: ' . $e[4] . ')';
     } else {
         $errorMessage = 'Unknown error';
         $errorCode = -1;
     }
     $this->clearHttpHeaders();
     $this->_httpStatusCode = '500';
     $this->_httpStatusMsg = 'Internal Server Error';
     $this->_httpHeaders['Content-Type'] = "application/json";
     $content = jJsonRpc::encodeFaultResponse($errorCode, $errorMessage, $gJCoord->request->jsonRequestId);
     $this->_httpHeaders['Content-length'] = strlen($content);
     $this->sendHttpHeaders();
     echo $content;
 }
 public function outputErrors()
 {
     global $gJCoord;
     $e = $gJCoord->getErrorMessage();
     if ($e) {
         $errorCode = $e->getCode();
         if ($errorCode > 5000) {
             $errorMessage = $e->getMessage();
         } else {
             $errorMessage = $gJCoord->getGenericErrorMessage();
         }
     } else {
         $errorCode = -1;
         $errorMessage = $gJCoord->getGenericErrorMessage();
     }
     $this->clearHttpHeaders();
     $this->_httpStatusCode = '500';
     $this->_httpStatusMsg = 'Internal Server Error';
     $this->_httpHeaders['Content-Type'] = "application/json";
     $content = jJsonRpc::encodeFaultResponse($errorCode, $errorMessage, $gJCoord->request->jsonRequestId);
     $this->_httpHeaders['Content-length'] = strlen($content);
     $this->sendHttpHeaders();
     echo $content;
 }