Since: 2.4.0
Author: Michael Slusarz (slusarz@horde.org)
Esempio n. 1
0
 /**
  */
 public function start()
 {
     // We must start a session to ensure that session_id() is available,
     // but since we don't actually need to write to it, close it at once
     // to avoid session lock issues.
     session_start();
     session_write_close();
     Horde_Shutdown::add($this);
 }
Esempio n. 2
0
 /**
  * Return the IMP_Mailbox_SessionCache instance.
  *
  * @return IMP_Mailbox_SessionCache  Cache instance.
  */
 public function create(Horde_Injector $injector)
 {
     global $session;
     if (!($this->_instance = $session->get('imp', self::STORAGE_KEY))) {
         $this->_instance = new IMP_Mailbox_SessionCache();
     }
     Horde_Shutdown::add($this);
     return $this->_instance;
 }
Esempio n. 3
0
 /**
  */
 public function offsetSet($offset, $value)
 {
     if (!$this->locked && $this[$offset] != $value) {
         if ($value) {
             $this->_data[strval($offset)] = true;
         } else {
             unset($this->_data[strval($offset)]);
         }
         Horde_Shutdown::add($this);
     }
 }
Esempio n. 4
0
 /**
  * Return the IMP_Search instance.
  *
  * @return IMP_Search  The singleton instance.
  */
 public function create(Horde_Injector $injector)
 {
     try {
         $this->_instance = $GLOBALS['session']->get('imp', 'search');
     } catch (Exception $e) {
         Horde::log('Could not unserialize stored IMP_Search object.', 'DEBUG');
     }
     if (!$this->_instance) {
         $this->_instance = new IMP_Search();
     }
     Horde_Shutdown::add($this);
     return $this->_instance;
 }
Esempio n. 5
0
 /**
  * Return the IMP_Contacts instance.
  *
  * @return IMP_Contacts  The singleton instance.
  */
 public function create(Horde_Injector $injector)
 {
     try {
         $this->_instance = $GLOBALS['session']->get('imp', self::SESS_KEY);
     } catch (Exception $e) {
         Horde::log('Could not unserialize stored IMP_Contacts object.', 'DEBUG');
     }
     if (is_null($this->_instance)) {
         $this->_instance = new IMP_Contacts();
     }
     Horde_Shutdown::add($this);
     return $this->_instance;
 }
Esempio n. 6
0
 /**
  */
 public function start()
 {
     /* Limit session ID to 32 bytes. Session IDs are NOT cryptographically
      * secure hashes. Instead, they are nothing more than a way to
      * generate random strings. */
     ini_set('session.hash_function', 0);
     ini_set('session.hash_bits_per_character', 5);
     // We must start a session to ensure that session_id() is available,
     // but since we don't actually need to write to it, close it at once
     // to avoid session lock issues.
     session_start();
     session_write_close();
     Horde_Shutdown::add($this);
 }
Esempio n. 7
0
 /**
  * Return the IMP_Ftree object.
  *
  * @return IMP_Ftree  The singleton instance.
  */
 public function create(Horde_Injector $injector)
 {
     global $registry, $session;
     $this->_instance = $session->get('imp', self::STORAGE_KEY);
     if (!$this->_instance instanceof IMP_Ftree) {
         $this->_instance = new IMP_Ftree();
     }
     switch ($registry->getView()) {
         case $registry::VIEW_DYNAMIC:
         case $registry::VIEW_SMARTMOBILE:
             $this->_instance->eltdiff->track = true;
             break;
     }
     Horde_Shutdown::add($this);
     return $this->_instance;
 }
Esempio n. 8
0
 /**
  * Return the Horde_Themes_Cache:: instance.
  *
  * @param string $app    The application name.
  * @param string $theme  The theme name.
  *
  * @return Horde_Themes_Cache  The singleton instance.
  */
 public function create($app, $theme)
 {
     $sig = implode('|', array($app, $theme));
     if (!isset($this->_instances[$sig])) {
         $cache = empty($GLOBALS['conf']['cachethemes']) ? null : $this->_injector->getInstance('Horde_Cache');
         if (!$cache || $cache instanceof Horde_Cache_Null) {
             $instance = new Horde_Themes_Cache($app, $theme);
         } else {
             try {
                 $instance = @unserialize($cache->get($sig, $GLOBALS['conf']['cachethemesparams']['lifetime']));
             } catch (Exception $e) {
                 $instance = null;
             }
             if (!$instance instanceof Horde_Themes_Cache) {
                 $instance = new Horde_Themes_Cache($app, $theme);
                 $instance->build();
             }
             Horde_Shutdown::add($this);
         }
         $this->_instances[$sig] = $instance;
     }
     return $this->_instances[$sig];
 }
Esempio n. 9
0
 /**
  */
 public function __construct(Horde_Injector $injector)
 {
     parent::__construct($injector);
     Horde_Shutdown::add($this);
 }
Esempio n. 10
0
 /**
  * Create a new Horde_Registry instance.
  *
  * @param integer $session_flags  Any session flags.
  * @param array $args             See appInit().
  *
  * @throws Horde_Exception
  */
 public function __construct($session_flags = 0, array $args = array())
 {
     /* Set a valid timezone. */
     date_default_timezone_set(ini_get('date.timezone') ?: getenv('TZ') ?: 'UTC');
     /* Save arguments. */
     $this->_args = $args;
     /* Define factories. By default, uses the 'create' method in the given
      * classname (string). If other function needed, define as the second
      * element in an array. */
     $factories = array('Horde_ActiveSyncBackend' => 'Horde_Core_Factory_ActiveSyncBackend', 'Horde_ActiveSyncServer' => 'Horde_Core_Factory_ActiveSyncServer', 'Horde_ActiveSyncState' => 'Horde_Core_Factory_ActiveSyncState', 'Horde_Alarm' => 'Horde_Core_Factory_Alarm', 'Horde_Browser' => 'Horde_Core_Factory_Browser', 'Horde_Cache' => 'Horde_Core_Factory_Cache', 'Horde_Controller_Request' => 'Horde_Core_Factory_Request', 'Horde_Controller_RequestConfiguration' => array('Horde_Core_Controller_RequestMapper', 'getRequestConfiguration'), 'Horde_Core_Auth_Signup' => 'Horde_Core_Factory_AuthSignup', 'Horde_Core_CssCache' => 'Horde_Core_Factory_CssCache', 'Horde_Core_JavascriptCache' => 'Horde_Core_Factory_JavascriptCache', 'Horde_Core_Perms' => 'Horde_Core_Factory_PermsCore', 'Horde_Dav_Server' => 'Horde_Core_Factory_DavServer', 'Horde_Dav_Storage' => 'Horde_Core_Factory_DavStorage', 'Horde_Db_Adapter' => 'Horde_Core_Factory_DbBase', 'Horde_Editor' => 'Horde_Core_Factory_Editor', 'Horde_ElasticSearch_Client' => 'Horde_Core_Factory_ElasticSearch', 'Horde_Group' => 'Horde_Core_Factory_Group', 'Horde_HashTable' => 'Horde_Core_Factory_HashTable', 'Horde_History' => 'Horde_Core_Factory_History', 'Horde_Kolab_Server_Composite' => 'Horde_Core_Factory_KolabServer', 'Horde_Kolab_Session' => 'Horde_Core_Factory_KolabSession', 'Horde_Kolab_Storage' => 'Horde_Core_Factory_KolabStorage', 'Horde_Lock' => 'Horde_Core_Factory_Lock', 'Horde_Log_Logger' => 'Horde_Core_Factory_Logger', 'Horde_Mail' => 'Horde_Core_Factory_MailBase', 'Horde_Memcache' => 'Horde_Core_Factory_Memcache', 'Horde_Nosql_Adapter' => 'Horde_Core_Factory_NosqlBase', 'Horde_Notification' => 'Horde_Core_Factory_Notification', 'Horde_Perms' => 'Horde_Core_Factory_Perms', 'Horde_Queue_Storage' => 'Horde_Core_Factory_QueueStorage', 'Horde_Routes_Mapper' => 'Horde_Core_Factory_Mapper', 'Horde_Routes_Matcher' => 'Horde_Core_Factory_Matcher', 'Horde_Secret' => 'Horde_Core_Factory_Secret', 'Horde_Secret_Cbc' => 'Horde_Core_Factory_Secret_Cbc', 'Horde_Service_Facebook' => 'Horde_Core_Factory_Facebook', 'Horde_Service_Twitter' => 'Horde_Core_Factory_Twitter', 'Horde_Service_UrlShortener' => 'Horde_Core_Factory_UrlShortener', 'Horde_SessionHandler' => 'Horde_Core_Factory_SessionHandler', 'Horde_Template' => 'Horde_Core_Factory_Template', 'Horde_Timezone' => 'Horde_Core_Factory_Timezone', 'Horde_Token' => 'Horde_Core_Factory_Token', 'Horde_Variables' => 'Horde_Core_Factory_Variables', 'Horde_View' => 'Horde_Core_Factory_View', 'Horde_View_Base' => 'Horde_Core_Factory_View', 'Horde_Weather' => 'Horde_Core_Factory_Weather', 'Net_DNS2_Resolver' => 'Horde_Core_Factory_Dns', 'Text_LanguageDetect' => 'Horde_Core_Factory_LanguageDetect');
     /* Define implementations. */
     $implementations = array('Horde_Controller_ResponseWriter' => 'Horde_Controller_ResponseWriter_Web');
     /* Setup injector. */
     $GLOBALS['injector'] = $injector = new Horde_Injector(new Horde_Injector_TopLevel());
     foreach ($factories as $key => $val) {
         if (is_string($val)) {
             $val = array($val, 'create');
         }
         $injector->bindFactory($key, $val[0], $val[1]);
     }
     foreach ($implementations as $key => $val) {
         $injector->bindImplementation($key, $val);
     }
     $GLOBALS['registry'] = $this;
     $injector->setInstance(__CLASS__, $this);
     /* Setup autoloader instance. */
     $injector->setInstance('Horde_Autoloader', $GLOBALS['__autoloader']);
     /* Import and global Horde's configuration values. */
     $this->importConfig('horde');
     $conf = $GLOBALS['conf'];
     /* Set the umask according to config settings. */
     if (isset($conf['umask'])) {
         umask($conf['umask']);
     }
     /* Set the error reporting level in accordance with the config
      * settings. */
     error_reporting($conf['debug_level']);
     /* Set the maximum execution time in accordance with the config
      * settings, but only if not running from the CLI */
     if (!isset($GLOBALS['cli'])) {
         set_time_limit($conf['max_exec_time']);
     }
     /* The basic framework is up and loaded, so set the init flag. */
     $this->hordeInit = true;
     /* Initial Horde-wide settings. */
     /* Initialize browser object. */
     $GLOBALS['browser'] = $injector->getInstance('Horde_Browser');
     /* Get modified time of registry files. */
     $regfiles = array(HORDE_BASE . '/config/registry.php', HORDE_BASE . '/config/registry.d');
     if (file_exists(HORDE_BASE . '/config/registry.local.php')) {
         $regfiles[] = HORDE_BASE . '/config/registry.local.php';
     }
     if (!empty($conf['vhosts'])) {
         $vhost = HORDE_BASE . '/config/registry-' . $conf['server']['name'] . '.php';
         if (file_exists($vhost)) {
             $regfiles[] = $this->vhost = $vhost;
         }
     }
     $this->_regmtime = max(array_map('filemtime', $regfiles));
     /* Start a session. */
     if ($session_flags & self::SESSION_NONE) {
         /* Never start a session if the session flags include
            SESSION_NONE. */
         $GLOBALS['session'] = $session = new Horde_Session_Null();
         $session->setup(true, $args['session_cache_limiter']);
     } elseif (PHP_SAPI === 'cli' || empty($_SERVER['SERVER_NAME']) && (PHP_SAPI === 'cgi' || PHP_SAPI === 'cgi-fcgi')) {
         $GLOBALS['session'] = $session = new Horde_Session();
         $session->setup(false, $args['session_cache_limiter']);
     } else {
         $GLOBALS['session'] = $session = new Horde_Session();
         $session->setup(true, $args['session_cache_limiter']);
         if ($session_flags & self::SESSION_READONLY) {
             /* Close the session immediately so no changes can be made but
                values are still available. */
             $session->close();
         }
     }
     $injector->setInstance('Horde_Session', $session);
     /* Always need to load applications information. */
     $this->_loadApplications();
     /* Stop system if Horde is inactive. */
     if ($this->applications['horde']['status'] == 'inactive') {
         throw new Horde_Exception(Horde_Core_Translation::t("This system is currently deactivated."));
     }
     /* Initialize language configuration object. */
     $this->nlsconfig = new Horde_Registry_Nlsconfig();
     /* Initialize the localization routines and variables. */
     $this->setLanguageEnvironment(null, 'horde');
     /* Initialize global page output object. */
     $GLOBALS['page_output'] = $injector->getInstance('Horde_PageOutput');
     /* Initialize notification object. Always attach status listener by
      * default. */
     $nclass = null;
     switch ($this->getView()) {
         case self::VIEW_DYNAMIC:
             $nclass = 'Horde_Core_Notification_Listener_DynamicStatus';
             break;
         case self::VIEW_SMARTMOBILE:
             $nclass = 'Horde_Core_Notification_Listener_SmartmobileStatus';
             break;
     }
     $GLOBALS['notification'] = $injector->getInstance('Horde_Notification');
     if (empty($args['nonotificationinit'])) {
         $GLOBALS['notification']->attachAllAppHandlers();
     }
     $GLOBALS['notification']->attach('status', null, $nclass);
     Horde_Shutdown::add($this);
 }
Esempio n. 11
0
 /**
  * Return the proper cache object based on the mailbox type.
  *
  * @param IMP_Mailbox $mbox  Mailbox object.
  *
  * @return Horde_Core_Cache_Session  Session cache object.
  */
 protected function _getCache(IMP_Mailbox $mbox)
 {
     global $injector;
     $key = intval($mbox->search || !$mbox->is_imap);
     if (!isset($this->_cache[$key])) {
         if (empty($this->_cache)) {
             Horde_Shutdown::add($this);
         }
         /* Need to treat search/POP3 mailboxes differently than IMAP
          * mailboxes since BUIDs may NOT be the same if the mailbox is
          * regenerated on a cache miss (they are unique generated within a
          * session on-demand). */
         if ($key) {
             $cache = new Horde_Cache(new Horde_Cache_Storage_Hashtable(array('hashtable' => new Horde_Core_HashTable_PersistentSession())), array('compress' => true, 'logger' => $injector->getInstance('Horde_Core_Log_Wrapper')));
         } else {
             $cache = $injector->getInstance('Horde_Cache');
         }
         $this->_cache[$key] = new Horde_Core_Cache_Session(array('app' => 'imp', 'cache' => $cache, 'storage_key' => self::STORAGE_KEY));
     }
     return $this->_cache[$key];
 }
Esempio n. 12
0
 /**
  * Return the proper cache object based on the mailbox type.
  *
  * @param IMP_Mailbox $mbox  Mailbox object.
  *
  * @return Horde_Core_Cache_Session  Session cache object.
  */
 protected function _getCache(IMP_Mailbox $mbox)
 {
     global $injector;
     $key = intval($mbox->search || !$mbox->is_imap);
     if (!isset($this->_cache[$key])) {
         if (empty($this->_cache)) {
             Horde_Shutdown::add($this);
         }
         $this->_cache[$key] = new Horde_Core_Cache_Session(array('app' => 'imp', 'cache' => $injector->getInstance('Horde_Cache'), 'maxsize' => $key ? 0 : 5000, 'storage_key' => self::STORAGE_KEY));
     }
     return $this->_cache[$key];
 }
Esempio n. 13
0
 /**
  * Add session variables to the session.
  *
  * @param array $vars  Array of session variables to add to the session,
  *                     once it becomes available.
  */
 protected final function _addSessVars($vars)
 {
     if (!empty($vars)) {
         $this->_sessVars = array_merge($this->_sessVars, $vars);
         Horde_Shutdown::add($this);
     }
 }