public function checkRequest(MMapRequest $request) { if ($request->getGET() != null && $request->issetGET('mobile') && $request->issetGET('getApplication') && $request->issetGET('checknum')) { return true; } return false; }
public function processRequest(MMapRequest $request, MMapResponse $response) { $oauth_verifier = null; $oauth_token = null; if ($request->issetGET('oauth_verifier')) { $oauth_verifier = $request->getGET('oauth_verifier'); } if ($request->issetGET('oauth_token')) { $oauth_token = $request->getGET('oauth_token'); } if ($oauth_verifier && $oauth_token) { $response->getHeaders()->append('Content-type: text/html'); $body = '<html> <div id="logo_eyeos" style="margin: 0 auto;width:350"> <img src="eyeos/extern/images/logo-eyeos.jpg"/></div> <div style="margin: 0 auto;width:350;text-align:center"><span style="font-family:Verdana;font-size:20px;">Successful authentication.<br>Back to Eyeos.</span></div> </html>'; $response->getHeaders()->append('Content-Length: ' . strlen($body)); $response->getHeaders()->append('Accept-Ranges: bytes'); $response->getHeaders()->append('X-Pad: avoid browser bug'); $response->getHeaders()->append('Cache-Control: '); $response->getHeaders()->append('pragma: '); $response->setBody($body); try { $userRoot = UMManager::getInstance()->getUserByName('root'); } catch (EyeNoSuchUserException $e) { throw new EyeFailedLoginException('Unknown user root"' . '". Cannot proceed to login.', 0, $e); } $subject = new Subject(); $loginContext = new LoginContext('eyeos-login', $subject); $cred = new EyeosPasswordCredential(); $cred->setUsername('root'); $cred->setPassword($userRoot->getPassword(), false); $subject->getPrivateCredentials()->append($cred); $loginContext->login(); Kernel::enterSystemMode(); $appProcess = new Process('stacksync'); $appProcess->setPid('31338'); $mem = MemoryManager::getInstance(); $processTable = $mem->get('processTable', array()); $processTable[31338] = $appProcess; $mem->set('processTable', $processTable); $appProcess->setLoginContext($loginContext); ProcManager::getInstance()->setCurrentProcess($appProcess); kernel::exitSystemMode(); $token = new stdClass(); $token->oauth_verifier = $oauth_verifier; $token->oauth_token = $oauth_token; $group = UMManager::getInstance()->getGroupByName('users'); $users = UMManager::getInstance()->getAllUsersFromGroup($group); foreach ($users as $user) { $NetSyncMessage = new NetSyncMessage('cloud', 'token', $user->getId(), $token); NetSyncController::getInstance()->send($NetSyncMessage); } } }
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 checkRequest(MMapRequest $request) { if ($request->issetGET('externLogin')) { return true; } return false; }
public function checkRequest(MMapRequest $request) { if ($request->issetGET('getSUHandler')) { return true; } return false; }
public function checkRequest(MMapRequest $request) { if ($request->issetGET('downloadFile')) { return true; } return false; }
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) { $urlName = $request->getGET('download'); if (is_array($urlName)) { exit; } $urlShare = new UrlShare(); $urlShare->setName($urlName); $urlShareController = UrlShareController::getInstance(); $urlShare = current($urlShareController->searchUrl($urlShare)); if ($urlShare) { if ($urlShare->getExpirationDate() < time()) { self::renderErrorMessage($response, 'Url Expired'); return; } $file = new UrlFile(); $file->setId($urlShare->getFileId()); $urlShareController->readFile($file); 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]; if ($request->issetGET('wrongPassword')) { $wrongPassword = $request->getGET('wrongPassword'); } else { $wrongPassword = 0; } Kernel::exitSystemMode(); self::renderFoundFile($fileName, $size, $urlName, $response, $urlShare->getPassword(), $wrongPassword); } else { self::renderErrorMessage($response, 'File not available'); } } else { self::renderErrorMessage($response, 'File not available'); } }
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)); } }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); $extern = EYE_ROOT . '/' . EXTERN_DIR . '/' . $request->getGET('extern'); $type = $request->issetGET('type') ? $request->getGET('type') : ''; // Check if an extern file is called if (strpos(realpath($extern), realpath(EYE_ROOT . '/' . EXTERN_DIR . '/')) === 0) { $info = pathinfo($extern); $myExt = strtolower($info['extension']); if (is_readable($extern)) { $len = filesize($extern); if ($type == 'text') { $response->getHeaders()->append('Content-type: text/plain'); } else { if ($type == 'js' || $myExt == 'js') { $response->getHeaders()->append('Content-type: text/javascript'); } else { if ($myExt == 'htm' || $myExt == 'html' || $myExt == 'xhtml') { Logger::getLogger('debug')->debug($extern); $response->getHeaders()->append('Content-type: text/html'); } else { if ($type == 'image' || $myExt == 'png' || $myExt == 'jpg' || $myExt == 'gif') { $response->getHeaders()->append('Content-Type: image/' . $myExt); } else { if ($type == 'download') { $response->getHeaders()->append('Content-Type: application/force-download'); $response->getHeaders()->append('Content-Description: File Transfer'); $response->getHeaders()->append('Content-Disposition: attachment; filename="' . basename($extern) . '"'); } else { if ($type == 'css' || $myExt == 'css') { $response->getHeaders()->append(array('Content-type: text/css', true)); } else { if ($type == 'xml' || $myExt == 'xml' || $myExt == 'xsl') { $response->getHeaders()->append('Content-type: text/xml'); } else { if ($type == 'swf' || $myExt == 'swf') { $response->getHeaders()->append('Content-type: application/x-shockwave-flash'); } else { if ($type == 'mp3' || $myExt == 'mp3') { $response->getHeaders()->append('Content-type: audio/mpeg3'); } } } } } } } } } $response->getHeaders()->append('Content-Length: ' . $len); $response->getHeaders()->append('Accept-Ranges: bytes'); $response->getHeaders()->append('X-Pad: avoid browser bug'); //FIXME: we really need cache here, its absolutely needed because if not //the system gets really slow, so, I remove this form the headers because its preventing the //browser from caching. //however, maybe there is a better method to avoid this? PHP directive? $response->getHeaders()->append('Cache-Control: '); $response->getHeaders()->append('pragma: '); if (self::$Logger->isDebugEnabled()) { self::$Logger->debug('Preparing to output file: ' . $extern); } $response->setBodyRenderer(new FileReaderBodyRenderer(new FileInputStream($extern))); } } else { self::$Logger->warn('Specified path does not point a valid file: ' . $extern . '. Operation cancelled.'); } }
public function getParentProcess() { if ($this->parentProcess === null) { if ($this->request->issetGET('checknum')) { $checknum = (int) $this->request->getGET('checknum'); if ($checknum !== self::ANONYMOUS_CHECKNUM) { $procFather = ProcManager::getInstance()->getProcessByChecknum($checknum); $this->parentProcess = $procFather; } } } return $this->parentProcess; }
public function checkRequest(MMapRequest $request) { // return true; return self::isMobileBrowser() && !$request->issetGET('mobile'); }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); // restore process context $myProcManager = ProcManager::getInstance(); $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum')); $myProcManager->setCurrentProcess($myProcess); // process request $externFile = FSI::getFile('sys:///' . APPS_DIR . '/' . $request->getGET('appName') . '/' . $request->getGET('appFile')); $type = $request->issetGET('type') ? $request->getGET('type') : ''; if (strpos($externFile->getAbsolutePath(), 'sys:///' . APPS_DIR . '/') === 0) { $myExt = $externFile->getExtension(); if ($externFile->isReadable()) { $len = $externFile->getSize(); if ($type == 'text') { $response->getHeaders()->append('Content-type: text/plain'); } else { if ($type == 'js' || $myExt == 'js') { $response->getHeaders()->append('Content-type: text/javascript'); } else { if ($myExt == 'htm' || $myExt == 'html' || $myExt == 'xhtml') { $response->getHeaders()->append('Content-type: text/html'); } else { if ($type == 'image' && !empty($myExt) || $myExt == 'png' || $myExt == 'jpg' || $myExt == 'gif') { $response->getHeaders()->append('Content-Type: image/' . $myExt); } else { if ($type == 'download') { $response->getHeaders()->append('Content-Type: application/force-download'); $response->getHeaders()->append('Content-Description: File Transfer'); $response->getHeaders()->append('Content-Disposition: attachment; filename="' . $externFile->getName() . '"'); } else { if ($type == 'css' || $myExt == 'css') { $response->getHeaders()->append(array('Content-type: text/css', true)); } else { if ($type == 'xml' || $myExt == 'xml' || $myExt == 'xsl') { $response->getHeaders()->append('Content-type: text/xml'); } else { if ($type == 'swf' || $myExt == 'swf') { $response->getHeaders()->append('Content-type: application/x-shockwave-flash'); } else { if ($type == 'mp3' || $myExt == 'mp3') { $response->getHeaders()->append('Content-type: audio/mpeg3'); } else { if ($type == 'mp4' || $myExt == 'mp4') { $response->getHeaders()->append('Content-type: video/mp4'); } else { if ($type == 'flv' || $myExt == 'flv') { $response->getHeaders()->append('Content-type: video/x-flv'); } } } } } } } } } } } $response->getHeaders()->append('Content-Length: ' . $len); $response->getHeaders()->append('Accept-Ranges: bytes'); $response->getHeaders()->append('X-Pad: avoid browser bug'); $response->getHeaders()->append('Cache-Control: '); $response->getHeaders()->append('pragma: '); if (self::$Logger->isDebugEnabled()) { self::$Logger->debug('Preparing to output file: ' . $externFile->getAbsolutePath()); } $response->setBodyRenderer(new FileReaderBodyRenderer($externFile->getInputStream())); } } else { self::$Logger->warn('Illegal path given: ' . $externFile->getAbsolutePath() . '. Operation cancelled.'); } }