public static function __run(AppExecutionContext $context, MMapResponse $response) { $buffer = ''; $itemsPath = EYE_ROOT . '/' . APPS_DIR . '/files/mobile/'; $buffer .= file_get_contents($itemsPath . '/model/eyeosmobileFile.js'); $buffer .= file_get_contents($itemsPath . '/viewerManager/fileViewerManager.js'); // Load ViewManager Handlers $viewerHandlerPath = $itemsPath . 'viewerManager/handlers/'; $viewerHandlers = array(); $iterator = new DirectoryIterator($viewerHandlerPath); foreach ($iterator as $fileInfo) { if ($fileInfo->getFilename() == '.' || $fileInfo->getFilename() == '..' || $fileInfo->getFilename() == '.svn') { continue; } if ($fileInfo->isDir()) { continue; } // If is a file and is a js if ($fileInfo->isFile() && substr(strrchr($fileInfo->getFilename(), '.'), 1) == 'js') { $buffer .= file_get_contents($viewerHandlerPath . $fileInfo->getFilename()); $pathInfo = pathinfo($fileInfo->getFilename()); $handlerName = $pathInfo['filename']; $viewerHandlers[] = $handlerName; } } // Initialize fileViewManager and send handlers to it $buffer .= 'var fvm = fileViewerManager.getInstance();'; $buffer .= 'fvm.loadHandlers(' . json_encode($viewerHandlers) . ');'; $response->appendToBody($buffer); }
public static function __run(AppExecutionContext $context, MMapResponse $response) { //if ($context->getIncludeBody()) { $buffer = ''; // Internal components $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/interfaces.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/constants.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/model.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/Controller.js'); // Menu & Toolbar $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/Actions.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/menu/Items.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/toolbar/Items.js'); // Dialogs $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/dialogs/EditEvent.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/dialogs/Settings.js'); // GUI components $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/MiniGridCalendar.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/BlockCalendar.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/CalendarsList.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/ViewModeSelector.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/SimplePeriodDisplay.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/RibbonCalendar.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/Event.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/EventPopup.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/GridCalendar.js'); $buffer .= file_get_contents(EYE_ROOT . '/' . APPS_DIR . '/calendar/classes/view/GridCalendar.EventsContainer.js'); $response->appendToBody($buffer); //} }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start("ob_gzhandler"); define('EYEOS_MOBILE', true); // header $expires = 60 * 60 * 24 * 90; $response->getHeaders()->append("Pragma: public"); $response->getHeaders()->append("Cache-Control: max-age=" . $expires . ", must-revalidate"); $response->getHeaders()->append('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); $body = ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>eyeOS mobile version</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; foreach (self::$scripts as $script) { $body .= '<script type="text/javascript" src="eyeos/'; $body .= $script; $body .= '"></script>' . "\n"; } $body .= '<!-- Load jquery --> <script src="index.php?extern=js/jquery/jquery-1.5.1.min.js"></script> <!-- Load json support --> <script src="index.php?extern=js/jquery/lib/json/jquery.json-2.2.min.js"></script> <!-- Load eyeosmobile--> <script type="text/javascript" src="index.php?extern=js/eyeosmobile/eyeosmobile.js"></script> <!-- When jquery.mobile starts, we can call init method --> <script> $(document).bind("mobileinit", function () { eyeosmobile.start(); }); $invisibleBlockClicks = $(\'<div id="invisibleBlockClicks" style="background: rgba(0, 0, 0, 0.6);position: absolute;top: 0px;left: 0px;min-width: 100%;display: none;"></div>\'); $invisibleBlockClicks.bind(\'touchstart touchmove\', function(e) { e.preventDefault(); e.stopPropagation(); return false; }); </script> <!-- Load jquery mobile library, for testing not minified code--> <!-- <link rel="stylesheet" href="eyeos/extern/js/jquery/lib/jquerymobile/jquery.mobile-1.0a3.css" /> --> <!-- <script src="index.php?extern=js/jquery/lib/jquerymobile/jquery.mobile-1.0a3.js"></script> --> <link rel="stylesheet" href="eyeos/extern/js/jquery/lib/jquerymobile/jquery.mobile-1.0a3.min.css" /> <script src="index.php?extern=js/jquery/lib/jquerymobile/jquery.mobile-1.0a3.min.js"></script> <link rel="icon" type="image/png" href="index.php?extern=images/favicon.png" /> <link rel="apple-touch-icon" href="index.php?extern=images/touch-icon.png" /> </head> <body> <div data-role="page" id="main"> <div data-role="content"></div> </div> </body> </html>'; $response->setBody($body); }
public static function __run(AppExecutionContext $context, MMapResponse $response) { $buffer = ''; $basePath = EYE_ROOT . '/' . APPS_DIR . '/contactmanager/'; $buffer .= file_get_contents($basePath . 'contactmanager.js'); $response->appendToBody($buffer); }
public static function __run(AppExecutionContext $context, MMapResponse $response) { $buffer = ''; $basePath = EYE_ROOT . '/' . APPS_DIR . '/usermanagement/'; $buffer .= file_get_contents($basePath . 'usermanagement.js'); $buffer .= file_get_contents($basePath . 'pages/users/userpage.js'); $buffer .= file_get_contents($basePath . 'utils/userList.js'); $buffer .= file_get_contents($basePath . 'pages/groups/grouppage.js'); $buffer .= file_get_contents($basePath . 'utils/groupList.js'); $buffer .= file_get_contents($basePath . 'pages/groups/groupTabView.js'); $buffer .= file_get_contents($basePath . 'pages/groups/groupInfoPage.js'); $buffer .= file_get_contents($basePath . 'pages/groups/groupManagePage.js'); $buffer .= file_get_contents($basePath . 'pages/groups/assignWindow.js'); $buffer .= file_get_contents($basePath . 'pages/system/system.js'); $response->appendToBody($buffer); }
public static function __run(AppExecutionContext $context, MMapResponse $response) { //if ($context->getIncludeBody()) { $buffer = ''; $itemsPath = EYE_ROOT . '/' . APPS_DIR . '/viewer/library'; $dir = new DirectoryIterator($itemsPath); foreach ($dir as $file) { $fileName = $file->getBasename(); if (!$file->isDot() && $fileName[0] != '.' && strchr($fileName, '.js')) { $buffer .= file_get_contents($itemsPath . '/' . $fileName); } } $response->appendToBody($buffer); //} $instance = MemoryManager::getInstance(); $instance->set('playList', $context->getArgs()->getArrayCopy()); }
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 static function __run(AppExecutionContext $context, MMapResponse $response) { $memoryManager = MemoryManager::getInstance(); Kernel::enterSystemMode(); $isExternLogin = $memoryManager->get('isExternLogin'); Kernel::exitSystemMode(); $list = new ArrayList(); $list->append($isExternLogin); if ($isExternLogin) { Kernel::enterSystemMode(); $username = $memoryManager->get('username'); $password = $memoryManager->get('password'); Kernel::exitSystemMode(); $list->append($username); $list->append($password); } $context->setArgs($list); $response->appendToBody('eyeos.isRegisterActive=' . self::isRegisterActive() . ';'); }
public static function __run(AppExecutionContext $context, MMapResponse $response) { //if ($context->getIncludeBody()) { $buffer = ''; $itemsPath = EYE_ROOT . '/' . APPS_DIR . '/files'; $dir = new DirectoryIterator($itemsPath); foreach ($dir as $file) { $fileName = $file->getBasename(); if (!$file->isDot() && $fileName[0] != '.' && strchr($fileName, '.js') && $fileName != 'eyeos.js') { $buffer .= file_get_contents($itemsPath . '/' . $fileName); } } $buffer .= file_get_contents($itemsPath . '/SocialBarUpdater/interfaces.js'); $buffer .= file_get_contents($itemsPath . '/SocialBarUpdater/eyeos.files.ASocialBarHandler.js'); $buffer .= file_get_contents($itemsPath . '/SocialBarUpdater/eyeos.files.SUHandlerManager.js'); $buffer .= file_get_contents($itemsPath . '/SocialBarUpdater/eyeos.files.SUManager.js'); $buffer .= file_get_contents($itemsPath . '/SocialBarUpdater/eyeos.files.SUPathManager.js'); $response->appendToBody($buffer); //} }
public static function __run(AppExecutionContext $context, MMapResponse $response) { $currentUser = $context->getProcess()->getLoginContext()->getEyeosUser(); $files = EyeosApplicationExecutable::__callModule('FileSystem', 'browsePath', array('home:///Desktop/', null, null)); $context->getArgs()->offsetSet(0, $currentUser->getName()); $context->getArgs()->offsetSet(1, $files); if ($context->getIncludeBody()) { $buffer = ''; $itemsPath = EYE_ROOT . '/' . APPS_DIR . '/desktop/'; $buffer .= file_get_contents($itemsPath . '/desktop.WidgetManager.js'); $buffer .= file_get_contents($itemsPath . '/desktop.SelectionManager.js'); $buffer .= file_get_contents($itemsPath . '/desktop.actionManager.js'); $buffer .= file_get_contents($itemsPath . '/desktop.chatManager.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.events.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.favorites.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.files.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.groups.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.notes.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.desktop.js'); $response->appendToBody($buffer); } }
/** * program entrypoint * * @access public * @param AppExecutionContext $context * @param MMapResponse $response */ public static function __run(AppExecutionContext $context, MMapResponse $response) { $buffer = ''; $basePath = EYE_ROOT . '/' . APPS_DIR . '/netsync/'; $buffer .= file_get_contents($basePath . 'netsync.js'); $response->appendToBody($buffer); //notify users about my new online status, i'm inside netsync! $peopleController = PeopleController::getInstance(); //now we have the patch, lets apply it! $myProcManager = ProcManager::getInstance(); $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId(); $contacts = $peopleController->getAllContacts($currentUserId); $ids = array(); $myCometSender = new CometSenderLongPolling(); foreach ($contacts as $contact) { $id = $contact->getRelation()->getSourceId(); if ($id == $currentUserId) { $id = $contact->getRelation()->getTargetId(); } $message = new NetSyncMessage('status', 'online', $id, $currentUserId); $myCometSender->send($message); } }
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) { 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 static function __run(AppExecutionContext $context, MMapResponse $response) { //DEBUG $context->setIncludeBody(true); $response->appendToBody(file_get_contents('./extern/js/eyeos/ui/widgets/TextArea.js')); }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start("ob_gzhandler"); // header $expires = 60 * 60 * 24 * 90; $response->getHeaders()->append("Pragma: public"); $response->getHeaders()->append("Cache-Control: max-age=" . $expires . ", must-revalidate"); $response->getHeaders()->append('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); if (SYSTEM_TYPE == 'release') { $eyeosjs = file_get_contents('extern/js/eyeos.compressed.js'); if (!file_exists(SERVICE_MMAP_PATH . '/cache/basesystem.cache')) { $fileInputStreams = array(); foreach (self::$scripts as &$scriptPath) { $fileInputStreams[] = new FileInputStream($scriptPath); } $data = ""; foreach ($fileInputStreams as $file) { $reader = new BasicInputStreamReader($file); $data .= $reader->readAll(); } file_put_contents(SERVICE_MMAP_PATH . '/cache/basesystem.cache', JSMin::minify($data)); } } $body = '<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="icon" type="image/png" href="index.php?extern=images/favicon.png" /> <script type="text/javascript"'; if (SYSTEM_TYPE == 'release') { $body .= '>' . $eyeosjs; } else { $body .= ' src="index.php?extern=js/eyeos.js">'; } $body .= '</script> <script type="text/javascript"> ' . file_get_contents('extern/js/qx.js') . ' </script> '; if (SYSTEM_TYPE == 'release') { $body .= '<script>' . file_get_contents(SERVICE_MMAP_PATH . '/cache/basesystem.cache') . '</script>'; } else { foreach (self::$scripts as $script) { $body .= '<script type="text/javascript" src="eyeos/'; $body .= $script; $body .= '"></script>' . "\n"; } } $body .= '<script src="eyeos/extern/js/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js"></script> <script type="text/javascript"> if (document.addEventListener) { document.addEventListener("DOMContentLoaded", eyeos.bootstrap, false); } else if (document.attachEvent) { document.attachEvent("onreadystatechange", function () { if (document.readyState == "complete") { eyeos.bootstrap(); } }); } else { window.onload = eyeos.bootstrap; } </script> <title>Welcome to eyeOS ' . EYE_VERSION . '</title> </head> <body></body> </html>'; $response->setBody($body); }
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.'); } }
/** * insert required JavaScript to the stdout * * @author Jordi Rubio * @access private * @package eyeDocs * @param MMapResponse $response * @since 1.0 */ private static function insertNeededJS(MMapResponse $response) { // output buffer $buffer = ''; // initial path for inclusion $itemsPath = EYE_ROOT . '/' . APPS_DIR; // list of files to include $filesToInclude = array('/documents/conf/genericbar.both.Actions.js', '/documents/conf/genericbar.menubar.Items.js', '/documents/conf/genericbar.toptoolbar.Items.js', '/documents/conf/genericbar.bottomtoolbar.basic.Items.js', '/documents/conf/genericbar.bottomtoolbar.advanced.Items.js', '/documents/libs/diff_match_patch.js', '/documents/libs/utils.js', '/documents/libs/file.js', '/documents/libs/edit.js', '/documents/libs/view.js', '/documents/libs/insert.js', '/documents/libs/format.js', '/documents/libs/table.js', '/documents/libs/tools.js', '/documents/libs/help.js', '/documents/libs/updates.js', '/documents/libs/windows_dialogs.js'); // include all foreach ($filesToInclude as $file) { $buffer .= file_get_contents($itemsPath . $file); } $response->appendToBody($buffer); }
private function renderResponse(MMapResponse $response) { if (!$response->isValid()) { if (self::$Logger->isInfoEnabled()) { self::$Logger->info('Skipping invalid response: ' . $response); } return; } try { // headers foreach ($response->getHeaders() as $headerField) { self::$Logger->info($headerField); if (is_array($headerField)) { if (isset($headerField[1])) { if (isset($headerField[2])) { header($headerField[0], $headerField[1], $headerField[2]); } else { header($headerField[0], $headerField[1]); } } else { header($headerField[0]); } } else { //if ( !ob_get_status() ) { header($headerField); //} } } // body $bodyRenderer = $response->getBodyRenderer(); if ($bodyRenderer !== null) { self::$Logger->info('Using BodyRenderer: ' . $bodyRenderer); $bodyRenderer->doRender(); } else { self::$Logger->info('Using raw body'); echo $response->getBody(); } } catch (Exception $e) { self::$Logger->error('Exception caught while rendering response!'); self::$Logger->error('Exception message: ' . $e->getMessage()); if (self::$Logger->isDebugEnabled()) { self::$Logger->debug(ExceptionStackUtil::getStackTrace($e, false)); self::$Logger->debug((string) $response); } // the exception will be finally caught by the general try/catch block in index.php throw $e; } }
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 executeJavascript(AppExecutionContext $context, MMapResponse $response) { if (!is_readable($this->getJavascriptPath())) { throw new EyeIOException('Unable to read applications\'s Javascript file at ' . $this->getJavascriptPath()); } $response->getHeaders()->append('Content-type: text/plain'); // Avoid cache $response->getHeaders()->append('Last-Modified: ' . gmdate('D, j M Y H:i:s') . ' GMT'); $response->getHeaders()->append('Expires: ' . gmdate('D, j M Y H:i:s') . ' GMT'); $response->getHeaders()->append('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 $response->getHeaders()->append('Pragma: no-cache'); // HTTP/1.0 //IMPORTANT: this was fixed twice. If you don't knwo what you are doing, don't touch anything. if ($context->getIncludeBody()) { $buffer = $this->loadTranslations($context, $response) . "\n"; $response->appendToBody($buffer); } $buffer = ""; // 2nd step: call MyApplication::__run() if (class_exists($this->getApplicationClassName())) { call_user_func(array($this->getApplicationClassName(), '__run'), $context, $response); } $buffer .= "\n"; // 3rd step: include the main javascript file of the application if ($context->getIncludeBody()) { $buffer .= file_get_contents($this->getJavascriptPath()); } // 4th and final step: add a call to myapplication_application() to the returned JS buffer // that will execute the application code on the client side once loaded if ($context->getExecuteJavascript()) { // We need to pass an _Array_ (numerically-indexed) as argument, and not a JSON object $jsArgs = $context->getArgs()->getArrayCopy(); self::checkArgsValidity($jsArgs); $jsArgs = json_encode(array_values($jsArgs)); // Append $buffer .= "\n" . $this->getName() . '_application(' . $context->getProcess()->getChecknum() . ', ' . $context->getProcess()->getPid() . ', ' . $jsArgs . ');'; } $response->appendToBody($buffer); }
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); }