Exemple #1
0
    $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
    //Запомним время выполнения (index.php + new Zend_Application)
    $_startTime2 = microtime(1);
    $totalTime_StartApplication = $_startTime2 - $_startTime;
    // Obtain used memory at the beginning of the Application
    $memoryUsage_StartApplication = memory_get_usage();
    $memoryUsage_StartApplication = round($memoryUsage_StartApplication / 1024, 3);
    $memoryUsage_StartApplication = number_format($memoryUsage_StartApplication, 3, '.', ' ');
    // Perform bootstrap
    $application->bootstrap();
    //------------ An execution time Bootstrap -------------
    // Get total time of bootstrap
    $_startTime3 = microtime(1);
    $totalTime_Bootstrap = $_startTime3 - $_startTime2;
    // Get used memory after bootstrap
    $memoryUsage_Bootstrap = Default_Plugin_SysBox::showMemoryUsage('kb');
    // Save time performing different parts of the script in the register
    Zend_Registry::set("Duration_StartApplication", $totalTime_StartApplication);
    Zend_Registry::set("Duration_Bootstrap", $totalTime_Bootstrap);
    Zend_Registry::set("MemoryUsage_StartIndexPHP", $memoryUsage_StartIndexPHP);
    Zend_Registry::set("MemoryUsage_StartApplication", $memoryUsage_StartApplication);
    Zend_Registry::set("MemoryUsage_Bootstrap", $memoryUsage_Bootstrap);
    // Perform dispatch loop
    $application->run();
} catch (Zend_Exception $e) {
    // Intercept exceptions
    Default_Plugin_Error::catchException($e);
} catch (Exception $e) {
    // Intercept exceptions
    Default_Plugin_Error::catchException($e);
}
Exemple #2
0
 /**
  * Initialization controller
  */
 function init()
 {
     //Начало времени выполнения диспечеризации
     $this->_startTimeDispatch = microtime(1);
     $request = $this->getRequest();
     $params = $request->getParams();
     // Get cofig
     $config = Zend_Registry::get('config');
     //$request->
     //Получим адаптер базы данных
     $this->db = Zend_Registry::get('db');
     //Зарегистрируем плагин FlashMessenger
     $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
     //$this->initView();
     // Создадим обьект breadcrumbs и добавим начальную точку отсчета
     $this->_breadcrumbs = new Default_Plugin_Breadcrumbs();
     if ($params['module'] == 'default') {
         $this->_breadcrumbs->addStep($this->Translate('Главная'), $this->getUrl(null, 'index'));
     } elseif ($params['module'] == 'admin') {
         $this->_breadcrumbs->addStep($this->Translate('Администрирование'), $this->getUrl(null, 'index'));
     } elseif ($params['module'] == 'hr') {
         $this->_breadcrumbs->addStep($this->Translate('Персонал'), $this->getUrl(null, 'index'));
     }
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->view->authenticated = true;
         $this->_authenticated = true;
         $this->_identity = $auth->getIdentity();
         $this->view->identity = $this->_identity;
         $this->_isAdmin = $this->_identity->user_type == 'administrator';
         $this->view->isAdmin = $this->_isAdmin;
         $this->_isEditor = $this->_identity->user_type == 'editor';
         $this->view->isEditor = $this->_isEditor;
         $this->_isMember = $this->_identity->user_type == 'member';
         $this->view->isMember = $this->_isMember;
         $this->_isCommentator = $this->_identity->user_type == 'commentator';
         $this->view->isCommentator = $this->_isCommentator;
     } else {
         $this->_authenticated = false;
         $this->view->authenticated = false;
         $this->_isGuest = true;
         $this->view->isGuest = true;
     }
     // Получим url_mvc
     $this->_url_mvc = Default_Plugin_SysBox::getRouterURL();
     $this->view->url_mvc = $this->_url_mvc;
     // Получим обьект сессии
     $this->_sessZendAuth = Zend_Registry::get("Zend_Auth");
     // Получим обьект userAgent
     $bootstrap = $this->getInvokeArg('bootstrap');
     $this->_userAgent = $bootstrap->getResource('useragent');
     $this->view->userAgent = $this->_userAgent;
     // Определим текущий броузер
     $this->_isIE = Default_Plugin_SysBox::isIE();
     $this->view->isIE = $this->_isIE;
     $this->_browser = Default_Plugin_SysBox::getBrowser();
     $this->view->browser = $this->_browser;
     $this->_isCompatibleBrowser = Default_Plugin_SysBox::checkBrowser($config['user']['incompatible_browsers']);
     $this->view->isCompatibleBrowser = $this->_isCompatibleBrowser;
     $this->_isForbiddenBrowser = !Default_Plugin_SysBox::checkBrowser($config['user']['forbidden_browsers']);
     $this->view->isForbiddenBrowser = $this->_isForbiddenBrowser;
     //Создадим обьект Redirector
     $this->_redirector = $this->_helper->getHelper('Redirector');
     // Получим обьект сериализатора
     $this->_serializer = Zend_Serializer::factory('PhpSerialize');
     // Получим обьекты для логирования
     $this->_logMsg = Zend_Registry::get('Zend_Log');
     $this->_logStat = Zend_Registry::get('Zend_LogStat');
     $this->_logEx = Zend_Registry::get('Zend_LogEx');
     // Получим доступные модули для приложения
     $strModules = trim($config['user']['modules']['enable']);
     $strModules = str_replace(' ', '', $strModules);
     $strModules = strtolower($strModules);
     $modules = explode(';', $strModules);
     $this->_modules = $modules;
     $this->view->modules = $modules;
     // Пользовательские параметры
     $Zend_Auth = Zend_Registry::get('Zend_Auth');
     $this->view->scheme = $Zend_Auth->user_scheme;
     $this->view->user_main_name = trim($config['user']['main']['name']);
     $this->view->logo_url = trim($config['user']['main']['logo_url']);
     // Check forbidden browser
     if ($this->_isForbiddenBrowser) {
         Default_Plugin_Error::catchException(new Zend_Exception($this->Translate('Данная версия браузера запрещена к использованию! Установите более новую версию браузера.'), 403));
     }
 }