public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); //check if the session has expired MMapManager::checkSessionExpiration(); $return = null; $dataManager = DataManager::getInstance(); $POST = $request->getPOST(); $params = array(); if (isset($POST['params'])) { $params = $dataManager->doInput($POST['params']); } else { if ($request->issetGET('params')) { $params = $request->getGET('params'); } } $return = array(); foreach ($params as $call) { $call[2] = json_encode($call[2]); $_POST['params'] = $call[2]; $request->setPost('params', $call[2]); $_GET['message'] = $call[1]; $request->setGET('message', $call[1]); $_GET['checknum'] = $call[0]; $request->setGET('checknum', $call[0]); MMapMsg::getInstance()->processRequest($request, $response); MMapManager::getInstance()->doResponse($response); $response->clear(); $content = ob_get_contents(); ob_clean(); $return[] = $content; } $response->setBodyRenderer(new DataManagerBodyRenderer($return)); }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); MMapManager::checkSessionExpiration(); $username = $request->issetPOST('username') ? $request->getPOST('username') : ''; $password = $request->issetPOST('password') ? $request->getPOST('password') : ''; $loginPage = $request->issetPOST('loginPage') ? $request->getPOST('loginPage') : ''; $subject = new Subject(); $loginContext = new LoginContext('eyeos-login', $subject); $cred = new EyeosPasswordCredential(); $cred->setUsername($username); $cred->setPassword($password, true); $subject->getPrivateCredentials()->append($cred); try { $loginContext->login(); $memoryManager = MemoryManager::getInstance(); Kernel::enterSystemMode(); $memoryManager->set('isExternLogin', 1); $memoryManager->set('username', $username); $memoryManager->set('password', $password); $memoryManager->set('loginPage', $loginPage); Kernel::exitSystemMode(); header("Location: index.php"); } catch (Exception $e) { header("Location:" . $loginPage . "?errorLogin=1"); } }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); //check if the session has expired MMapManager::checkSessionExpiration(); $return = null; $dataManager = DataManager::getInstance(); // restore current process using checknum $myProcManager = ProcManager::getInstance(); $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum')); $myProcManager->setCurrentProcess($myProcess); $appDesc = new EyeMobileApplicationDescriptor($myProcess->getName()); $POST = $request->getPOST(); $params = array(); if (isset($POST['params'])) { $params = $dataManager->doInput($POST['params']); } else { if ($request->issetGET('params')) { $params = $request->getGET('params'); } } $methodName = $request->getGET('message'); // calling an ExecModule if (strpos($methodName, '__') === 0) { $moduleName = explode('_', substr($methodName, 2)); $methodName = $moduleName[1]; //ex: "FileChooser" $moduleName = $moduleName[0]; //ex: "browsePath" $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params)); } else { if ($appDesc->isJavascriptOnlyApplication()) { $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params); } else { if (method_exists($appDesc->getApplicationClassName(), $methodName)) { $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params); } else { //If no function is present, call the NOT mobile function MMapMsg::getInstance()->processRequest($request, $response); return; } // try { // $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params); // } catch (Exception $e) { // //If no function is present, call the NOT mobile function // MMapMsg::getInstance()->processRequest($request, $response); // return; // } } } if ($response->getBodyRenderer() === null && $response->getBody() == '') { $response->setBodyRenderer(new DataManagerBodyRenderer($return)); } }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); //check if the session has expired MMapManager::checkSessionExpiration(); $return = null; $dataManager = DataManager::getInstance(); // restore current process using checknum $myProcManager = ProcManager::getInstance(); $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum')); $myProcManager->setCurrentProcess($myProcess); $appDesc = new EyeosApplicationDescriptor($myProcess->getName()); $POST = $request->getPOST(); $params = array(); if (isset($POST['params'])) { $params = $dataManager->doInput($POST['params']); } else { if ($request->issetGET('params')) { $params = $request->getGET('params'); } } $methodName = $request->getGET('message'); // calling an ExecModule if (strpos($methodName, '__') === 0) { $moduleName = explode('_', substr($methodName, 2)); $methodName = $moduleName[1]; //ex: "FileChooser" $moduleName = $moduleName[0]; //ex: "browsePath" $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params)); } else { if ($appDesc->isJavascriptOnlyApplication()) { $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params); } else { $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params); } } //try to force mime type. If there is a previous mime type defined at application level //this have no effect if (!headers_sent()) { $response->getHeaders()->append('Content-type:text/plain'); } if ($response->getBodyRenderer() === null && $response->getBody() == '') { $response->setBodyRenderer(new DataManagerBodyRenderer($return)); } }
public function processRequest(MMapRequest $request, MMapResponse $response, AppExecutionContext $appContext = null) { $status = ob_get_status(); $response->getHeaders()->append('Content-type:text/javascript'); if (isset($status['name']) && $status['name'] != 'ob_gzhandler') { ob_start("ob_gzhandler"); } try { MMapManager::startSession(); if (!$appContext instanceof AppExecutionContext) { $appContext = new AppExecutionContext(); $appContext->initFromRequest($request); } $appDesc = $appContext->getApplicationDescriptor(); // Check if the session has expired only if the application we want to execute is not "init" nor "logout" // FIXME: Not sure this way for checking session is the best here (maybe a flag in the metadata instead?) if ($appDesc->getName() != 'init' && $appDesc->getName() != 'logout') { MMapManager::checkSessionExpiration(); } // Restore parent process if available try { $checknum = (int) $request->getGET('checknum'); $procFather = ProcManager::getInstance()->getProcessByChecknum($checknum); ProcManager::getInstance()->setCurrentProcess($procFather); // Access control is based on current user, contained in the login context of // the current process, so we can only perform security checks when a process // is active. // In case no login context is defined, we can be sure that almost nothing unsafe // will be done, because this element is required in most of the operations. if ($procFather->getLoginContext() !== null) { SecurityManager::getInstance()->checkExecute($appDesc); } } catch (EyeProcException $e) { } // Start process (PHP) $this->startProcess($appContext); // Append necessary scripts and execute JS code (actually, only append it to the $response body) $appDesc->executeJavascript($appContext, $response); } catch (Exception $e) { self::$Logger->error('Uncaught exception while processing request: ' . $request); self::$Logger->error('Exception message: ' . $e->getMessage()); if (self::$Logger->isDebugEnabled()) { self::$Logger->debug(ExceptionStackUtil::getStackTrace($e, false)); } // Special processing on session expiration if ($e instanceof EyeSessionExpiredException) { $controlMessageBodyRenderer = new ControlMessageBodyRenderer(ControlMessageBodyRenderer::TYPE_SESSION_EXPIRED); } else { // Remove incomplete process $proc = $appContext->getProcess(); if ($proc instanceof Process) { try { ProcManager::getInstance()->kill($proc); } catch (Exception $e) { self::$Logger->error('Cannot kill incomplete process: ' . $proc); self::$Logger->error('Exception message: ' . $e->getMessage()); } } $controlMessageBodyRenderer = new ControlMessageBodyRenderer(ControlMessageBodyRenderer::TYPE_EXCEPTION, $e); } // When using qx.io.ScriptLoader on the JS side, no callback proxy is available // to intercept control messages, so we're using a little workaround here by // calling directly eyeos._callbackProxyWithContent() with the exception summary // in argument. $responseContent = $controlMessageBodyRenderer->getRenderedBody(); $response->setBody('eyeos._callbackProxyWithContent(null, null, null, ' . $responseContent . ');'); } $this->handleClientMessageQueue($response); }