Пример #1
0
 /**
  * initialize the custom logger.
  * add usefull info for us.
  */
 private function initNewProps()
 {
     // add the identity
     $auth = Sydney_Auth::getInstance();
     $identity = null;
     if ($auth->hasIdentity()) {
         $identity = $auth->getIdentity();
     }
     $this->setEventItem('identity', $identity);
     if (isset($_SERVER['HTTP_REFERER'])) {
         $referer = $_SERVER['HTTP_REFERER'];
     } else {
         $referer = '';
     }
     $this->setEventItem('HTTP_REFERER', $referer);
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $remoteAddr = $_SERVER['REMOTE_ADDR'];
     } else {
         $remoteAddr = '127.0.0.1';
     }
     $this->setEventItem('REMOTE_ADDR', $remoteAddr);
     if (isset($_SERVER['REQUEST_METHOD'])) {
         $requestMethod = $_SERVER['REQUEST_METHOD'];
     } else {
         $requestMethod = 'none';
     }
     $this->setEventItem('REQUEST_METHOD', $requestMethod);
     $this->setEventItem('REQUEST_TIME', $_SERVER['REQUEST_TIME']);
 }
Пример #2
0
 /**
  * Authentication with JSON
  * @return void
  */
 public function jsonprocessAction()
 {
     if (is_array($this->jsonr) && isset($this->jsonr['login']) && isset($this->jsonr['password'])) {
         $adapter = $this->getAuthAdapter($this->getRequest(), true);
         $auth = Sydney_Auth::getInstance();
         $result = $auth->authenticate($adapter);
         if (!$result->isValid()) {
             $this->view->ResultSet = $this->getEmptyArray(0, 0, 1, 'Error! Authentication failed.', 1);
         } else {
             $this->view->ResultSet = $this->view->ResultSet = $this->getEmptyArray(0, 0, 0, 'Authentication successful.', 0);
         }
     } else {
         $this->view->ResultSet = $this->getEmptyArray(0, 0, 1, 'Error! Authentication failed.', 1);
     }
 }
Пример #3
0
 /**
  * Execute all the default method.
  * This is the quick mode to make the bootstrapper work.
  */
 public function run()
 {
     // Common initialisation
     $this->registry = Zend_Registry::getInstance();
     $this->_setConfigToRegistry(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'general');
     $this->_setPaths();
     $this->frontController = Zend_Controller_Front::getInstance();
     if (!Zend_Session::sessionExists()) {
         Zend_Session::start();
     }
     $this->auth = Sydney_Auth::getInstance();
     // set default timezone (could be useful)
     date_default_timezone_set($this->config->general->defaulttimezone);
     // set this in the registry so we can change the translations according to the page content if needed
     $this->registry->set('bootstrapper', $this);
     $this->setRoutes();
     $this->setErrorMode($this->config->general->env);
     $this->setDebugMode();
     $this->setCacheGlobalParams();
     $this->setLanguageSettings();
     $this->setTranslationObject();
     $this->setLocalization();
     $this->_setRegistredHelpersToRegistry();
     try {
         $this->setDatabaseConnection();
     } catch (Exception $e) {
         header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/index.php');
         exit;
     }
     try {
         $this->initCustomModules();
     } catch (Exception $e) {
         echo 'ERROR initCustomModules', '<br>';
         echo $e->getMessage();
         header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/index.php');
     }
     try {
         $this->registerAuthPlugin();
     } catch (Exception $e) {
         echo 'ERROR registerAuthPlugin', '<br>';
     }
     try {
         $this->initModules();
     } catch (Exception $e) {
         echo 'ERROR initModules', '<br>';
     }
     $this->setLayout();
     // set frontController plugins
     $this->registerFriendlyurlsPlugin();
     $this->registerCachePlugin();
     $this->dispatch();
 }
Пример #4
0
 /**
  *
  */
 protected function init()
 {
     $auth = Sydney_Auth::getInstance();
     self::$useridentity = 'NotAuthenticated';
     if ($auth->hasIdentity()) {
         self::$useridentity = $auth->getIdentity();
     }
     self::$date = new Zend_Date();
     self::$logger = new Sydney_Log();
     self::$logger->setEventItem('className', get_class($this));
     $writers = self::$logger->getWriters();
     self::$log = $writers[0];
     self::$config = Zend_Registry::get('config');
     self::$db = Zend_Db::factory(self::$config->db);
 }
Пример #5
0
 /**
  * Start caching
  *
  * Determine if we have a cache hit. If so, return the response; else,
  * start caching.
  *
  * @param  Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $request = $this->getRequest();
     // $request = new Zend_Controller_Request_Http();
     $moduleName = $request->getModuleName();
     $params = $request->getParams();
     /**
      * On récupère la homeId uniquement si on arrive à la racine du site
      * @author GDE
      * @project Belgium Telecom
      * @since 10/01/2013
      */
     $pagstrDB = new Pagstructure();
     if (count($params) == 3 && $params['module'] == 'publicms' && $params['controller'] == 'index' && $params['action'] == 'view') {
         $params['page'] = $pagstrDB->getHomeId(Sydney_Tools_Sydneyglobals::getSafinstancesId());
     }
     if ($moduleName == 'publicms' && isset($params['page'])) {
         $pagstr = $pagstrDB->find($params['page']);
         if (count($pagstr) == 1) {
             /**
              * Enregistre en session le rootid courant
              * Utilisé pour savoir quel index de recherche utiliser
              * FAR: Utile aussi pour la séparation par langue
              * @author GDE
              * @project Belgium Telecom
              * @since 10/01/2013
              */
             $breadCrumData = $pagstrDB->getBreadCrumData(Sydney_Tools_Sydneyglobals::getSafinstancesId(), $this->_treatPageData($params['page']));
             $rootid = $breadCrumData[0]['id'];
             $lucenesearch = new Zend_Session_Namespace('current-page-rootid');
             if (!empty($rootid)) {
                 $lucenesearch->rootid = $rootid;
             }
             $struct = $pagstr[0];
             $struct->hits++;
             $struct->save();
             if (!Sydney_Auth::getInstance()->hasIdentity() && $struct->iscachable != 0 && $struct->cachetime > 0) {
                 $this->cache->setLifetime($struct->cachetime);
                 if (!$request->isGet()) {
                     self::$doNotCache = true;
                     return;
                 }
                 $path = $request->getPathInfo();
                 $this->key = $moduleName . '_' . md5($path);
                 if (false !== ($response = $this->getCache())) {
                     $response->sendResponse();
                     exit;
                 }
             }
         }
     }
 }
Пример #6
0
 /**
  * Auto initialization of important params for sydney
  * @return void
  */
 public function init()
 {
     // register general sydney helpers
     $this->view->addHelperPath(Sydney_Tools_Paths::getCorePath() . '/library/Sydney/View/Helper', 'Sydney_View_Helper');
     $this->_initWebInstanceHelpers();
     // setup the basics
     $this->_registry = Zend_Registry::getInstance();
     $this->_config = $this->_registry->get('config');
     $this->_db = $this->_registry->get('db');
     $this->safinstancesId = $this->_config->db->safinstances_id;
     $this->_translate = $this->_registry->get('Zend_Translate');
     $this->view->translate = $this->_registry->get('Zend_Translate');
     $this->_auth = Sydney_Auth::getInstance();
     // Auto Login if identity and credentials stored in cookie
     $u = $this->getRequest()->getParam('username');
     $p = $this->getRequest()->getParam('password');
     if (!$this->_auth->hasIdentity() && $this->_getParam('action') != 'login' && $this->_getParam('action') != 'logout' && empty($u) && empty($p)) {
         $adapter = Sydney_Auth_Adaptater_DbTable::getAuthAdapter($this->getRequest());
         if ($adapter instanceof Zend_Auth_Adapter_Interface) {
             $auth = Sydney_Auth::getInstance();
             if ($auth->authenticate($adapter)->isValid()) {
                 $this->_helper->redirector->gotoUrl($this->getRequest()->getRequestUri());
                 exit;
             }
         }
     }
     // Init list secured pages
     $this->setAuthPagelist();
     // setup user
     $udata = new Zend_Session_Namespace('userdata');
     if (isset($udata->user)) {
         $this->usersData = $udata->user;
     }
     if (isset($this->usersData['users_id'])) {
         $this->usersId = $this->usersData['users_id'];
     }
     // sets some interesting vars in the view
     $this->view->config = $this->_config;
     $this->view->cdn = $this->_config->general->cdn;
     $this->view->users_data = $this->usersData;
     $this->view->safinstances_id = $this->safinstancesId;
     $this->view->auth = $this->_auth;
     $this->view->siteTitle = $this->_config->general->siteTitle;
     $this->view->printme = $this->_getParam('printme', 'no');
     // @todo TODO change this ...
     $llg = 'en';
     if (isset($this->_config->general->lang) && $this->_config->general->lang != '') {
         $llg = $this->_config->general->lang;
     }
     $this->view->headScript()->appendFile($this->view->cdn . '/sydneyassets/scripts/i18n/' . $llg . '.js', 'text/javascript');
     // setup some layout vars
     if ($this->layout !== null) {
         $this->layout->registry = $this->_registry;
         $this->layout->auth = $this->_auth;
         $this->layout->translate = $this->_registry->get('Zend_Translate');
         $this->layout->avmodules = $this->availableModules;
     }
     $this->view->moduleName = $this->_getParam('module');
     $this->view->controllerName = $this->_getParam('controller');
     $this->view->actionName = $this->_getParam('action');
     // set up the log
     $this->logger = new Sydney_Log();
     $this->logger->setEventItem('className', get_class($this));
     $this->logger->addFilterDatabase();
     if (isset($this->getRequest()->sydneylayout) && $this->getRequest()->sydneylayout == 'no') {
         $this->_helper->layout->disableLayout();
         $this->sydneyLayout = 'no';
     }
     if (isset($this->getRequest()->sydneylayout) && $this->getRequest()->sydneylayout != 'no' && $this->getRequest()->sydneylayout != 'yes') {
         $this->_helper->layout->setLayout('layout-' . $this->getRequest()->sydneylayout);
     }
     $this->view->sydneylayout = $this->sydneyLayout;
     /**
      * load structure if not exist
      */
     if (!is_array($this->view->structure) && $this->getRequest()->layout != 'no') {
         $this->structure = new Pagstructure();
         $this->view->adminmode = false;
         // if identified then get structure from database
         if (Sydney_Auth::getInstance()->hasIdentity()) {
             $this->structure->setFilter('status', 'published');
             $this->view->structure = $this->structure->toArray($this->safinstancesId);
         } else {
             // else use structure cached or build cache
             $cache = Zend_Registry::get('cache');
             $cn = PagstructureOp::getCacheNames($this->safinstancesId);
             $this->view->structure = $cache->load($cn[0]);
             //cn[0] > cachename
             $this->structure->stringNodes = $cache->load($cn[1]);
             //cn[1] > cachename2
             if (!is_array($this->view->structure)) {
                 $this->structure->setFilter('status', 'published');
                 $this->view->structure = $this->structure->toArray($this->safinstancesId);
                 $cache->save($this->view->structure, $cn[0]);
                 $cache->save($this->structure->getStringNodes(), $cn[1]);
             }
         }
         $r = $this->getRequest();
         if (isset($r->layout) && $r->layout == 'no') {
             Zend_Layout::getMvcInstance()->disableLayout(true);
         }
         $pages = $this->_getPageId();
         $this->view->breadCrumData = $this->structure->getBreadCrumData($this->safinstancesId, $pages[0]);
     }
     // change language if necessary
     $settingsNms = new Zend_Session_Namespace('appSettings');
     $curLang = $this->getCurrentLangCode();
     if ($settingsNms->ApplicationLanguage != $curLang) {
         $settingsNms->ApplicationLanguage = $curLang;
         $bootstrapper = Zend_Registry::get('bootstrapper');
         $bootstrapper->setRequestLang($curLang);
         $bootstrapper->setTranslationObject();
     }
     $this->view->lang = $settingsNms->ApplicationLanguage;
     $pages = isset($pages) ? $pages : $this->_getPageId();
     $this->_manageCanonicalLinks($pages[0]);
 }
Пример #7
0
 /**
  * Auto initialization of important params for sydney
  * @return void
  */
 public function init()
 {
     // add the general helper path for sydney
     $this->view->addHelperPath(Sydney_Tools_Paths::getCorePath() . '/library/Sydney/View/Helper', 'Sydney_View_Helper');
     $this->view->addHelperPath(Sydney_Tools_Paths::getCorePath() . '/application/modules/adminpages/views/helpers', 'Adminpages_View_Helper');
     $this->_initWebInstanceHelpers();
     $this->getResponse()->setHeader('Accept-encoding', 'gzip,deflate');
     // setup the basics
     $this->_registry = Zend_Registry::getInstance();
     $this->_config = $this->_registry->get('config');
     $this->_db = $this->_registry->get('db');
     $this->safinstancesId = $this->_config->db->safinstances_id;
     $this->view->safinstances_id = $this->_config->db->safinstances_id;
     $this->view->config = $this->_config;
     $this->_translate = $this->_registry->get('Zend_Translate');
     $this->_auth = Sydney_Auth::getInstance();
     $this->usersData = Sydney_Tools::getUserdata();
     if (isset($this->usersData['users_id'])) {
         $this->usersId = $this->usersData['users_id'];
         if (in_array(7, $this->usersData['member_of_groups'])) {
             $this->isDeveloper = true;
         }
     }
     $this->view->cdn = $this->_config->general->cdn;
     $this->view->isDeveloper = $this->isDeveloper;
     $this->view->moduleName = $this->_getParam('module');
     $this->view->controllerName = $this->_getParam('controller');
     $this->view->actionName = $this->_getParam('action');
     // On vérifie si on a un mapping entre le module courant et les tables qu'il utilise
     // ce mapping est utilisé pour charger ensuite automatiquement toutes les traductions de contenu de ce module
     if (!is_null($this->_config->general->modules->{$this->view->moduleName}) && !empty($this->_config->general->modules->{$this->view->moduleName}->tables)) {
         $translate = new Zend_Translate(array('adapter' => 'Sydney_Translate_Adapter_Db', 'tableName' => $this->_config->general->modules->{$this->view->moduleName}->tables, 'locale' => $this->config->general->locale));
         echo $translate->_('test');
         $this->_registry->set('Zend_Translate_Content', $translate);
     }
     // set up the log
     $this->logger = new Sydney_Log();
     $this->logger->setEventItem('className', get_class($this));
     $this->logger->addFilterDatabase();
     $safmodulesDB = new Safmodules();
     $this->availableModules = $safmodulesDB->getAvailableAvModules($this->safinstancesId, $this->usersData['member_of_groups'], true);
     if (!$this->_isService) {
         $this->setUpLayoutProps();
     }
     if (isset($this->getRequest()->sydneylayout) && $this->getRequest()->sydneylayout == 'no') {
         $this->_helper->layout->disableLayout();
         $this->view->sydneylayout = $this->getRequest()->sydneylayout;
     }
 }