예제 #1
0
 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");
     }
 }
예제 #2
0
 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));
 }
예제 #3
0
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     $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');
         }
     }
     //login in the system and get a valid login context
     $subject = new Subject();
     $loginContext = new LoginContext('eyeos-login', $subject);
     $cred = new EyeosPasswordCredential();
     $cred->setUsername($_REQUEST['username']);
     $cred->setPassword($_REQUEST['password'], true);
     $subject->getPrivateCredentials()->append($cred);
     $loginContext->login();
     //now create fake process called api
     Kernel::enterSystemMode();
     $appProcess = new Process('api');
     $appProcess->setPid('31337');
     $mem = MemoryManager::getInstance();
     $processTable = $mem->get('processTable', array());
     $processTable[31337] = $appProcess;
     $mem->set('processTable', $processTable);
     $appProcess->setLoginContext($loginContext);
     ProcManager::getInstance()->setCurrentProcess($appProcess);
     kernel::exitSystemMode();
     $return = call_user_func_array(array('EyeosApplicationExecutable', '__callModule'), array($request->getPOST('module'), $request->getPOST('name'), $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));
     }
 }
예제 #4
0
 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)
 {
     $urlName = $request->getGET('downloadFile');
     $urlShare = new UrlShare();
     $urlShare->setName($urlName);
     $urlShareController = UrlShareController::getInstance();
     $urlShare = current($urlShareController->searchUrl($urlShare));
     if ($urlShare) {
         $passwordUrl = $urlShare->getPassword();
         if ($passwordUrl) {
             $file = new UrlFile();
             $file->setId($urlShare->getFileId());
             $urlShareController->readFile($file);
             $passwordRequest = $request->getPOST('password');
             if ($passwordRequest == $passwordUrl) {
                 if ($file) {
                     self::downloadFile($file->getPath(), $request, $response);
                     self::registerDownload($urlShare);
                 } else {
                     self::renderNotFoundFile($response);
                 }
             } else {
                 if ($file) {
                     $fileName = basename($file->getPath());
                     $currentFile = FSI::getFile($file->getPath());
                     $size = $currentFile->getSize();
                     $unim = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
                     $c = 0;
                     while ($size >= 1024) {
                         $c++;
                         $size = $size / 1024;
                     }
                     $size = number_format($size, $c ? 2 : 0, ',', '.') . ' ' . $unim[$c];
                     self::renderWrongPassword($fileName, $size, $urlName, $response, $urlShare->getPassword());
                 } else {
                     self::renderNotFoundFile($response);
                 }
             }
         } else {
             $file = new UrlFile();
             $file->setId($urlShare->getFileId());
             $urlShareController->readFile($file);
             if ($file) {
                 self::downloadFile($file->getPath(), $request, $response);
                 self::registerDownload($urlShare);
             } else {
                 self::renderNotFoundFile($response);
             }
         }
     } else {
         self::renderNotFoundFile($response);
     }
 }
예제 #6
0
 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));
     }
 }