示例#1
0
 /**
  * Constructor
  * 
  * @param mixed $subject Dispatcher
  * @param array $config  Array of configuration
  * 
  * @return void
  */
 public function __construct($subject, $config = array())
 {
     // Command line fixes for Joomla
     if (PHP_SAPI === 'cli') {
         if (!isset($_SERVER['HTTP_HOST'])) {
             $_SERVER['HTTP_HOST'] = '';
         }
         if (!isset($_SERVER['REQUEST_METHOD'])) {
             $_SERVER['REQUEST_METHOD'] = '';
         }
     }
     // Check for suhosin
     if (in_array('suhosin', get_loaded_extensions())) {
         //Attempt setting the whitelist value
         @ini_set('suhosin.executor.include.whitelist', 'tmpl://, file://');
         //Checking if the whitelist is ok
         if (!@ini_get('suhosin.executor.include.whitelist') || strpos(@ini_get('suhosin.executor.include.whitelist'), 'tmpl://') === false) {
             $url = KService::get('application')->getRouter()->getBaseUrl();
             $url .= '/templates/system/error_suhosin.html';
             KService::get('application.dispatcher')->getResponse()->setRedirect($url);
             KService::get('application.dispatcher')->getResponse()->send();
             return;
         }
     }
     //Safety Extender compatibility
     if (extension_loaded('safeex') && strpos('tmpl', ini_get('safeex.url_include_proto_whitelist')) === false) {
         $whitelist = ini_get('safeex.url_include_proto_whitelist');
         $whitelist = (strlen($whitelist) ? $whitelist . ',' : '') . 'tmpl';
         ini_set('safeex.url_include_proto_whitelist', $whitelist);
     }
     if (!JFactory::getApplication()->getCfg('caching') || JFactory::getUser()->usertype == 'Super Administrator' && KRequest::get('get.clearapc', 'cmd')) {
         //clear apc cache for components
         //@NOTE If apc is shared across multiple services
         //this causes the caceh to be cleared for all of them
         //since all of them starts with the same prefix. Needs to be fix
         clean_apc_with_prefix('cache_mod');
         clean_apc_with_prefix('cache_com');
         clean_apc_with_prefix('cache_plg');
         clean_apc_with_prefix('cache_system');
         clean_apc_with_prefix('cache__system');
         $jconfig = new JConfig();
         clean_apc_with_prefix(md5($jconfig->secret) . '-cache-');
     }
     KService::get('plg:storage.default');
     JFactory::getLanguage()->load('overwrite', JPATH_ROOT);
     JFactory::getLanguage()->load('lib_anahita', JPATH_ROOT);
     parent::__construct($subject, $config);
 }
示例#2
0
 /**
  * Constructor
  *
  * Prevent creating instances of this class by making the contructor private
  *
  * @param  array  An optional array with configuration options.
  */
 private final function __construct($config = array())
 {
     //store the path
     $this->_path = dirname(__FILE__);
     //instantiate koowa
     Koowa::getInstance(array('cache_prefix' => $config['cache_prefix'], 'cache_enabled' => $config['cache_enabled']));
     //if caching is not enabled then reset the apc cache to
     //to prevent corrupt identifier
     if (!$config['cache_enabled']) {
         clean_apc_with_prefix($config['cache_prefix']);
     }
     require_once dirname(__FILE__) . '/loader/adapter/anahita.php';
     KLoader::addAdapter(new AnLoaderAdapterAnahita(array('basepath' => dirname(__FILE__))));
     KLoader::addAdapter(new AnLoaderAdapterDefault(array('basepath' => JPATH_LIBRARIES . '/default')));
     AnServiceClass::getInstance();
     KServiceIdentifier::addLocator(new AnServiceLocatorAnahita());
     KServiceIdentifier::addLocator(new AnServiceLocatorRepository());
     //register an empty path for the application
     //a workaround to remove the applicaiton path from an identifier
     KServiceIdentifier::setApplication('', '');
     //create a central event dispatcher
     KService::set('anahita:event.dispatcher', KService::get('koowa:event.dispatcher'));
 }
示例#3
0
 /**
  * Load all the existing key/value into the memory.
  */
 public function deleteAll()
 {
     clean_apc_with_prefix($this->getCachePrefix());
 }