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)); }
session_save_path('./tmp/'); session_set_cookie_params(0, null, null, false, true); //make sure that garbage collector is running! ini_set('session.gc_probability', 1); $__startTime = microtime(true); $__startMemory = memory_get_usage(); try { //Load bootstrap script require './' . SYSTEM_DIR . '/' . BOOT_DIR . '/Bootstrap.php'; //Startup Bootstrap::init(); $__endBootstrapTime = microtime(true); $__endBootstrapMemory = memory_get_usage(); //Process incoming request through MMap $request = new MMapRequest(); MMapManager::getInstance()->processRequest($request, new MMapResponse()); // Temporary - Should be moved into a function $__endRequestTime = microtime(true); $__endRequestMemory = memory_get_usage(); $logger = Logger::getLogger('root.metrics'); if ($logger->isInfoEnabled()) { $logger->info('Time: ' . sprintf('%01.2f', $__endRequestTime - $__startTime) . 's / Mem.: ' . sprintf('%01.2f', ($__endRequestMemory - $__startMemory) / 1024) . 'KB (Bootstrap Time: ' . sprintf('%01.2f', $__endBootstrapTime - $__startTime) . 's / Mem: ' . sprintf('%01.2f', ($__endBootstrapMemory - $__startMemory) / 1024) . 'KB) [' . $request->getUrl() . ']'); } } catch (Exception $e) { // Log and display the exception that reached this section // (this should normally *not* happen in a fully set-up production environment) // Log with log4php if available if (class_exists('Logger')) { $logger = Logger::getRootLogger(); $logger->fatal('Uncaught exception detected in the root page! It is likely to come from the bootstrap.'); $logger->fatal(ExceptionStackUtil::getStackTrace($e, false));
public function __construct() { $this->myMMapManager = MMapManager::getInstance(); }