コード例 #1
0
ファイル: Configuration.php プロジェクト: Silwereth/core
 /**
  * Fetch and render the configuration template.
  *
  * @return string The rendered template.
  */
 public function configure()
 {
     $modVars = $this->plugin->getVars();
     $options = array('mode' => array('inset', 'outbound'), 'extension' => array('jpg', 'png', 'gif'));
     $this->getView()->assign('vars', $modVars)->assign('thumb_full_dir', CacheUtil::getLocalDir($modVars['thumb_dir']))->assign('options', $options);
     return $this->getView()->fetch('configuration.tpl');
 }
コード例 #2
0
 /**
  * Initialise.
  *
  * Runs at plugin init time.
  *
  * @return void
  */
 public function initialize(GenericEvent $event)
 {
     // register namespace
     // Because the standard kernel classloader already has Doctrine registered as a namespace
     // we have to add a new loader onto the spl stack.
     $autoloader = new UniversalClassLoader();
     $autoloader->register();
     $autoloader->registerNamespaces(array('DoctrineProxy' => 'ztemp/doctrinemodels'));
     $container = $event->getDispatcher()->getContainer();
     $config = $GLOBALS['ZConfig']['DBInfo']['databases']['default'];
     $dbConfig = array('host' => $config['host'], 'user' => $config['user'], 'password' => $config['password'], 'dbname' => $config['dbname'], 'driver' => 'pdo_' . $config['dbdriver']);
     $r = new \ReflectionClass('Doctrine\\Common\\Cache\\' . $container['dbcache.type'] . 'Cache');
     $dbCache = $r->newInstance();
     $ORMConfig = new \Doctrine\ORM\Configuration();
     $container->set('doctrine.configuration', $ORMConfig);
     $ORMConfig->setMetadataCacheImpl($dbCache);
     // create proxy cache dir
     \CacheUtil::createLocalDir('doctrinemodels');
     // setup annotations base
     include_once \ZLOADER_PATH . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
     // setup annotation reader
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
     $container->set('doctrine.annotationreader', $cacheReader);
     // setup annotation driver
     $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader);
     $container->set('doctrine.annotationdriver', $annotationDriver);
     // setup driver chains
     $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $container->set('doctrine.driverchain', $driverChain);
     // configure Doctrine ORM
     $ORMConfig->setMetadataDriverImpl($annotationDriver);
     $ORMConfig->setQueryCacheImpl($dbCache);
     $ORMConfig->setProxyDir(\CacheUtil::getLocalDir('doctrinemodels'));
     $ORMConfig->setProxyNamespace('DoctrineProxy');
     if (isset($container['log.enabled']) && $container['log.enabled']) {
         $ORMConfig->setSQLLogger(new \Zikula\Core\Doctrine\Logger\ZikulaSqlLogger());
     }
     // setup doctrine eventmanager
     $dispatcher = new \Doctrine\Common\EventManager();
     $container->set('doctrine.eventmanager', $dispatcher);
     // setup MySQL specific listener (storage engine and encoding)
     if ($config['dbdriver'] == 'mysql') {
         $mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']);
         $dispatcher->addEventSubscriber($mysqlSessionInit);
     }
     // setup the doctrine entitymanager
     $entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $dispatcher);
     $container->set('doctrine.entitymanager', $entityManager);
 }
コード例 #3
0
ファイル: SimplePieFeed.php プロジェクト: projectesIF/Sirius
 /**
  * Class constructor.
  *
  * @param string  $feed_url       The URL to the feed (optional).
  * @param integer $cache_duration The duration (in seconds) that the feed contents will be retained in cache.
  */
 public function __construct($feed_url = null, $cache_duration = null, $cache_dir = null)
 {
     parent::__construct();
     if (isset($cache_dir)) {
         $this->set_cache_location($cache_dir);
     } else {
         $this->set_cache_location(CacheUtil::getLocalDir('feeds'));
     }
     if (isset($cache_duration)) {
         $this->set_cache_duration($cache_duration);
     }
     if (isset($feed_url)) {
         $this->set_feed_url($feed_url);
     }
 }
コード例 #4
0
ファイル: Categorisable.php プロジェクト: Silwereth/core
 /**
  * Generates an subclass of the Zikula_Doctrine_Model_EntityCategory class and caches the generated class in a file.
  *
  * @param string $module     Name of the Module to that the model belongs to.
  * @param string $modelClass Classname of the model.
  *
  * @return void
  * @throws Exception Throws when the create of the cache directory fails.
  */
 private static function _generateSubclassForCategorisableTemplate($module, $modelClass)
 {
     $table = Doctrine::getTable($modelClass);
     sscanf($table->getTableName(), Doctrine_Manager::getInstance()->getAttribute(Doctrine::ATTR_TBLNAME_FORMAT), $tableName);
     $dir = 'doctrinemodels/GeneratedDoctrineModel/' . str_replace('_', DIRECTORY_SEPARATOR, $modelClass);
     if (CacheUtil::createLocalDir($dir, ServiceUtil::getManager()->getParameter('system.chmod_dir'))) {
         $subclassName = 'GeneratedDoctrineModel_' . $modelClass . '_EntityCategory';
         $fileContents = '<?php class ' . $subclassName . ' extends Zikula_Doctrine_Model_EntityCategory { }';
         $fileName = 'EntityCategory.php';
         // save new model
         file_put_contents(CacheUtil::getLocalDir() . '/' . $dir . '/' . $fileName, $fileContents);
         // save required data for later use
         $modelsInfo = ModUtil::getVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', array());
         $modelsInfo[$subclassName] = array('module' => $module, 'table' => $tableName);
         ModUtil::setVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', $modelsInfo);
     } else {
         throw new Exception('Creation of the cache directory ' . $dir . ' failed');
     }
 }
コード例 #5
0
 /**
  * upgrade the SecurityCenter module from an old version
  *
  * @param        string   $oldVersion   version number string to upgrade from
  * @return       mixed    true on success, last valid version string or false if fails
  */
 public function upgrade($oldversion)
 {
     switch ($oldversion) {
         case '1.3':
             // create cache directory for HTML Purifier
             $purifierCacheDir = CacheUtil::getLocalDir() . '/purifierCache';
             if (!file_exists($purifierCacheDir)) {
                 CacheUtil::clearLocalDir('purifierCache');
             }
             // create ids intrusions table
             if (!DBUtil::createTable('sc_intrusion')) {
                 return false;
             }
             // create vars for phpids usage
             System::setVar('useids', 0);
             System::setVar('idsmail', 0);
             System::setVar('idsrulepath', 'config/phpids_zikula_default.xml');
             System::setVar('idssoftblock', 1);
             // do not block requests, but warn for debugging
             System::setVar('idsfilter', 'xml');
             // filter type
             System::setVar('idsimpactthresholdone', 1);
             // db logging
             System::setVar('idsimpactthresholdtwo', 10);
             // mail admin
             System::setVar('idsimpactthresholdthree', 25);
             // block request
             System::setVar('idsimpactthresholdfour', 75);
             // kick user, destroy session
             System::setVar('idsimpactmode', 1);
             // per request per default
             System::setVar('idshtmlfields', array('POST.__wysiwyg'));
             System::setVar('idsjsonfields', array('POST.__jsondata'));
             // Location of HTML Purifier
             System::setVar('idsrulepath', 'config/phpids_zikula_default.xml');
             System::setVar('idsexceptions', array('GET.__utmz', 'GET.__utmc', 'REQUEST.linksorder', 'POST.linksorder', 'REQUEST.fullcontent', 'POST.fullcontent', 'REQUEST.summarycontent', 'POST.summarycontent', 'REQUEST.filter.page', 'POST.filter.page', 'REQUEST.filter.value', 'POST.filter.value'));
             System::delVar('htmlpurifierConfig');
             // HTML Purifier default settings
             $purifierDefaultConfig = SecurityCenter_Util::getpurifierconfig(array('forcedefault' => true));
             $this->setVar('htmlpurifierConfig', serialize($purifierDefaultConfig));
             if (!DBUtil::changeTable('sc_intrusion')) {
                 return false;
             }
             System::setVar('sessioncsrftokenonetime', 0);
         case '1.4.4':
             // future upgrade routines
     }
     // Update successful
     return true;
 }
コード例 #6
0
ファイル: Theme.php プロジェクト: rmaiwald/core
 /**
  * Clears the Theme configuration located on the temporary directory.
  *
  * @return boolean True on success, false otherwise.
  */
 public function clear_theme_config()
 {
     $configdir = CacheUtil::getLocalDir('Theme_Config');
     return $this->clear_folder($configdir, null, null, null);
 }
コード例 #7
0
ファイル: View.php プロジェクト: Silwereth/core
 /**
  * Constructor.
  *
  * @param Zikula_ServiceManager $serviceManager ServiceManager.
  * @param string                $moduleName     Module name ("zikula" for system plugins).
  * @param integer|null          $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  */
 public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
 {
     $this->serviceManager = $serviceManager;
     $this->eventManager = $this->serviceManager->get('event_dispatcher');
     $this->request = \ServiceUtil::get('request');
     // set the error reporting level
     $this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
     $this->error_reporting &= ~E_USER_DEPRECATED;
     $this->allow_php_tag = true;
     // get variables from input
     $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
     $type = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     $func = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     // set vars based on the module structures
     $this->homepage = PageUtil::isHomepage();
     $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
     $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
     // Initialize the module property with the name of
     // the topmost module. For Hooks, Blocks, API Functions and others
     // you need to set this property to the name of the respective module!
     $this->toplevelmodule = ModUtil::getName();
     if (!$moduleName) {
         $moduleName = $this->toplevelmodule;
     }
     $this->modinfo = ModUtil::getInfoFromName($moduleName);
     $this->module = array($moduleName => $this->modinfo);
     // initialise environment vars
     $this->language = ZLanguage::getLanguageCode();
     $this->baseurl = System::getBaseUrl();
     $this->baseuri = System::getBaseUri();
     // system info
     $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
     $this->theme = $theme = $this->themeinfo['directory'];
     $themeBundle = ThemeUtil::getTheme($this->themeinfo['name']);
     //---- Plugins handling -----------------------------------------------
     // add plugin paths
     switch ($this->modinfo['type']) {
         case ModUtil::TYPE_MODULE:
             $mpluginPathNew = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         case ModUtil::TYPE_SYSTEM:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         default:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
     }
     // add standard plugin search path
     $this->plugins_dir = array();
     $this->addPluginDir('config/plugins');
     // Official override
     $this->addPluginDir('lib/legacy/viewplugins');
     // Core plugins
     $this->addPluginDir(isset($themeBundle) ? $themeBundle->getRelativePath() . '/plugins' : "themes/{$theme}/plugins");
     // Theme plugins
     $this->addPluginDir('plugins');
     // Smarty core plugins
     $this->addPluginDir($mpluginPathNew);
     // Plugins for current module
     $this->addPluginDir($mpluginPath);
     // Plugins for current module
     // check if the 'type' parameter in the URL is admin or adminplugin
     $legacyControllerType = FormUtil::getPassedValue('lct', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     if ($type === 'admin' || $type === 'adminplugin' || $legacyControllerType === 'admin') {
         // include plugins of the Admin module to the plugins_dir array
         if (!$this instanceof Zikula_View_Theme) {
             $this->addPluginDir('system/AdminModule/Resources/views/plugins');
         } else {
             $this->load_filter('output', 'admintitle');
         }
     }
     // theme plugins module overrides
     $themePluginsPath = isset($themeBundle) ? $themeBundle->getRelativePath() . '/modules/$moduleName/plugins' : "themes/{$theme}/templates/modules/{$moduleName}/plugins";
     $this->addPluginDir($themePluginsPath);
     //---- Cache handling -------------------------------------------------
     if ($caching && in_array((int) $caching, array(0, 1, 2))) {
         $this->caching = (int) $caching;
     } else {
         $this->caching = (int) ModUtil::getVar('ZikulaThemeModule', 'render_cache');
     }
     $this->compile_id = '';
     $this->cache_id = '';
     // template compilation
     $this->compile_dir = CacheUtil::getLocalDir('view_compiled');
     $this->compile_check = ModUtil::getVar('ZikulaThemeModule', 'render_compile_check');
     $this->force_compile = ModUtil::getVar('ZikulaThemeModule', 'render_force_compile');
     // template caching
     $this->cache_dir = CacheUtil::getLocalDir('view_cache');
     $this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'render_lifetime');
     $this->expose_template = ModUtil::getVar('ZikulaThemeModule', 'render_expose_template') == true ? true : false;
     // register resource type 'z' this defines the way templates are searched
     // during {include file='my_template.tpl'} this enables us to store selected module
     // templates in the theme while others can be kept in the module itself.
     $this->register_resource('z', array('Zikula_View_Resource', 'z_get_template', 'z_get_timestamp', 'z_get_secure', 'z_get_trusted'));
     // set 'z' as default resource type
     $this->default_resource_type = 'z';
     // process some plugins specially when Render cache is enabled
     if (!$this instanceof Zikula_View_Theme && $this->caching) {
         $this->register_nocache_plugins();
     }
     // register the 'nocache' block to allow dynamic zones caching templates
     $this->register_block('nocache', array('Zikula_View_Resource', 'block_nocache'), false);
     // For ajax requests we use the short urls filter to 'fix' relative paths
     if ($this->serviceManager->get('zikula')->getStage() & Zikula_Core::STAGE_AJAX && System::getVar('shorturls')) {
         $this->load_filter('output', 'shorturls');
     }
     // register prefilters
     $this->register_prefilter('z_prefilter_add_literal');
     $this->register_prefilter('z_prefilter_gettext_params');
     //$this->register_prefilter('z_prefilter_notifyfilters');
     // assign some useful settings
     $this->assign('homepage', $this->homepage)->assign('modinfo', $this->modinfo)->assign('module', $moduleName)->assign('toplevelmodule', $this->toplevelmodule)->assign('type', $this->type)->assign('func', $this->func)->assign('lang', $this->language)->assign('themeinfo', $this->themeinfo)->assign('themepath', isset($themeBundle) ? $themeBundle->getRelativePath() : $this->baseurl . 'themes/' . $theme)->assign('baseurl', $this->baseurl)->assign('baseuri', $this->baseuri)->assign('moduleBundle', ModUtil::getModule($moduleName))->assign('themeBundle', $themeBundle);
     if (isset($themeBundle)) {
         $stylePath = $themeBundle->getRelativePath() . "/Resources/public/css";
         $javascriptPath = $themeBundle->getRelativePath() . "/Resources/public/js";
         $imagePath = $themeBundle->getRelativePath() . "/Resources/public/images";
         $imageLangPath = $themeBundle->getRelativePath() . "/Resources/public/images/" . $this->language;
     } else {
         $stylePath = $this->baseurl . "themes/{$theme}/style";
         $javascriptPath = $this->baseurl . "themes/{$theme}/javascript";
         $imagePath = $this->baseurl . "themes/{$theme}/images";
         $imageLangPath = $this->baseurl . "themes/{$theme}/images/" . $this->language;
     }
     $this->assign('stylepath', $stylePath)->assign('scriptpath', $javascriptPath)->assign('imagepath', $imagePath)->assign('imagelangpath', $imageLangPath);
     // for {gt} template plugin to detect gettext domain
     if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
         $this->domain = ZLanguage::getModuleDomain($this->modinfo['name']);
     }
     // make render object available to modifiers
     parent::assign('zikula_view', $this);
     // add ServiceManager, EventManager and others to all templates
     parent::assign('serviceManager', $this->serviceManager);
     parent::assign('eventManager', $this->eventManager);
     parent::assign('zikula_core', $this->serviceManager->get('zikula'));
     parent::assign('request', $this->request);
     $modvars = ModUtil::getModvars();
     // Get all modvars from any modules that have accessed their modvars at least once.
     // provide compatibility 'alias' array keys
     // @todo remove after v1.4.0
     if (isset($modvars['ZikulaAdminModule'])) {
         $modvars['Admin'] = $modvars['ZikulaAdminModule'];
     }
     if (isset($modvars['ZikulaBlocksModule'])) {
         $modvars['Blocks'] = $modvars['ZikulaBlocksModule'];
     }
     if (isset($modvars['ZikulaCategoriesModule'])) {
         $modvars['Categories'] = $modvars['ZikulaCategoriesModule'];
     }
     if (isset($modvars['ZikulaExtensionsModule'])) {
         $modvars['Extensions'] = $modvars['ZikulaExtensionsModule'];
     }
     if (isset($modvars['ZikulaGroupsModule'])) {
         $modvars['Groups'] = $modvars['ZikulaGroupsModule'];
     }
     if (isset($modvars['ZikulaMailerModule'])) {
         $modvars['Mailer'] = $modvars['ZikulaMailerModule'];
     }
     if (isset($modvars['ZikulaPageLockModule'])) {
         $modvars['PageLock'] = $modvars['ZikulaPageLockModule'];
     }
     if (isset($modvars['ZikulaPermissionsModule'])) {
         $modvars['Permissions'] = $modvars['ZikulaPermissionsModule'];
     }
     if (isset($modvars['ZikulaSearchModule'])) {
         $modvars['Search'] = $modvars['ZikulaSearchModule'];
     }
     if (isset($modvars['ZikulaSecurityCenterModule'])) {
         $modvars['SecurityCenter'] = $modvars['ZikulaSecurityCenterModule'];
     }
     if (isset($modvars['ZikulaSettingsModule'])) {
         $modvars['Settings'] = $modvars['ZikulaSettingsModule'];
     }
     if (isset($modvars['ZikulaThemeModule'])) {
         $modvars['Theme'] = $modvars['ZikulaThemeModule'];
     }
     if (isset($modvars['ZikulaUsersModule'])) {
         $modvars['Users'] = $modvars['ZikulaUsersModule'];
     }
     // end compatibility aliases
     parent::assign('modvars', $modvars);
     $this->add_core_data();
     // metadata for SEO
     if (!$this->serviceManager->hasParameter('zikula_view.metatags')) {
         $this->serviceManager->setParameter('zikula_view.metatags', new ArrayObject(array()));
     }
     parent::assign('metatags', $this->serviceManager->getParameter('zikula_view.metatags'));
     if (isset($themeBundle) && $themeBundle->isTwigBased()) {
         // correct asset urls when smarty output is wrapped by twig theme
         $this->load_filter('output', 'asseturls');
     }
     $event = new \Zikula\Core\Event\GenericEvent($this);
     $this->eventManager->dispatch('view.init', $event);
 }
コード例 #8
0
ファイル: Admin.php プロジェクト: projectesIF/Sirius
    /**
     * Running config checker
     */
    private function checkRunningConfig($themeinfo)
    {
        $ostemp = CacheUtil::getLocalDir();
        $zpath  = $ostemp.'/Theme_Config/'.DataUtil::formatForOS($themeinfo['directory']);
        $tpath  = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/templates/config';

        // check if we can edit the theme and, if not, create the running config
        if (!is_writable($tpath.'/pageconfigurations.ini')) {
            if (!file_exists($zpath) || is_writable($zpath)) {
                ModUtil::apiFunc('Theme', 'admin', 'createrunningconfig', array('themename' => $themeinfo['name']));

                LogUtil::registerStatus($this->__f('Notice: The changes made via Admin Panel will be saved on \'%1$s\' because it seems that the .ini files on \'%2$s\' are not writable.', array($zpath, $tpath)));

            } else {
                LogUtil::registerError($this->__f('Error! Cannot write any configuration changes. Make sure that the .ini files on \'%1$s\' or \'%2$s\', and the folder itself, are writable.', array($tpath, $zpath)));
            }
        } else {
            LogUtil::registerStatus($this->__f('Notice: Seems that your %1$s\'s .ini files are writable. Be sure that there are no .ini files on \'%2$s\' because if so, the Theme Engine will consider them and not your %1$s\'s ones.', array($themeinfo['name'], $zpath)));
        }

        LogUtil::registerStatus($this->__f("If the system cannot write on any .ini file, the changes will be saved on '%s' and the Theme Engine will use it.", $zpath));
    }
コード例 #9
0
ファイル: User.php プロジェクト: projectesIF/Sirius
 /**
  * Check to see if file is cached and current
  * return false if !exists or !current
  * return full filepath if exists and current
  *
  * @param string $title
  * @return mixed boolean/string
  */
 private function pdfIsCached($title)
 {
     $dir = CacheUtil::getLocalDir('NewsPDF');
     if (!is_dir($dir)) {
         CacheUtil::createLocalDir('NewsPDF', 0755, true);
     }
     $title = $title . '.pdf';
     // modify title like the tcpdf::Output() method does
     $title = preg_replace('/[\s]+/', '_', $title);
     $title = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $title);
     $fullpath = $dir . '/' . $title;
     if (file_exists($fullpath)) {
         // check if expired
         if ((time() - filemtime($fullpath)) > ModUtil::getVar('Theme', 'render_lifetime')) {
             return false;
         }
     } else {
         return false;
     }
     return $fullpath;
 }
コード例 #10
0
ファイル: Admin.php プロジェクト: projectesIF/Sirius
    /**
     * delete ini file
     */
    public function deleteinifile($args)
    {
        if (!isset($args['themename']) || empty($args['themename'])) {
            return LogUtil::registerArgsError();
        } else {
            $themename = $args['themename'];
        }

        // Security check
        if (!SecurityUtil::checkPermission('Theme::', "$themename", ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        if (!isset($args['file']) || empty($args['file'])) {
            return LogUtil::registerArgsError();
        }

        $ostemp  = CacheUtil::getLocalDir();
        $ostheme = DataUtil::formatForOS($themename);
        $osfile  = $ostemp.'/Theme_Config/'.$ostheme.'/'.DataUtil::formatForOS($args['file']);

        if (file_exists($osfile) && is_writable($osfile)) {
            unlink($osfile);
        }
    }
コード例 #11
0
ファイル: User.php プロジェクト: projectesIF/Sirius
    /**
     * Get Feeds via SimplePie
     *
     * @param integer fid feed id (not required if feed url is present)
     * @param string  furl feed url or urls for Multifeed request (not requred if feed id is present)
     * @param integer limit set how many items are returned per feed with Multifeeds (default is all)
     * @param integer cron  set to 1 to update all caches right now (default is 0, update cache only if needed)
     * @return mixed item array containing total item count, error information, and object with all the requested feeds
     */
    public function getfeed($args)
    {
        if (!PluginUtil::isAvailable('systemplugin.simplepie')) {
            throw new Exception(__('<strong>Fatal error: The required SimplePie system plugin is not available.</strong>'));
        }

        // Argument check
        if ((!isset($args['fid']) || !is_numeric($args['fid']))
                && (!isset($args['furl']) || (!is_string($args['furl']) && (!is_array($args['furl']))))) {
            return LogUtil::registerArgsError();
        }

        // Optional arguments.
        if (!isset($args['limit']) || !is_numeric($args['limit'])) {
            $args['limit'] = 0;  // 0 = don't set a limit
        }
        if (!isset($args['cron']) || !is_numeric($args['cron'])) {
            $args['cron'] = 0;  // not a cron job update
        } else {
            $args['cron'] = 1;  // it is a cron job update
        }

        // get all module vars for later use
        $modvars = $this->getVars();

        // check if the feed id is set, grab the feed from the db
        if (isset($args['fid'])) {
            $feed = ModUtil::apiFunc('Feeds', 'user', 'get', array('fid' => $args['fid']));
            $url = $feed['url'];
        } elseif(isset($args['furl'])) {
            $url = $args['furl'];
        }

        // Now setup SimplePie for the feed
        $theFeed = new SimplePieFeed();
        $theFeed->set_feed_url($url);
        $theFeed->set_cache_location(CacheUtil::getLocalDir($modvars['cachedirectory']));
        $theFeed->enable_order_by_date(true);

        // Get the charset used for the output, and tell SimplePie about it so it will try to use the same for its output
        $charset = ZLanguage::getDBCharset();
        if ($charset != '') {
            $theFeed->set_output_encoding($charset);
        }

        // Set the feed limits (note: this is a per feed limit that applies if multiple feeds are used)
        if ($args['limit'] > 0) {
            $theFeed->set_item_limit($args['limit']);
        }

        // Set Cache Duration
        if ($args['cron'] == 1) {
            $theFeed->set_cache_duration(0);          // force cache to update immediately (a cron job needs to do that)

        } elseif ($modvars['usingcronjob'] == 1) {   // Using a cron job to update the cache (but not this time), so per SimplePie docs...
            $theFeed->set_cache_duration(999999999);  // set to 999999999 to not update the cache with this request
            $theFeed->set_timeout(-1);                // set timeout to -1 to prevent SimplePie from retrying previous failed feeds

        } else {
            $theFeed->set_cache_duration($modvars['cacheinterval']);  // Use the specified cache interval.
        }

        // tell SimplePie to go and do its thing
        $theFeed->init();

        $returnFeed['count'] = $theFeed->get_item_quantity(); // total items returned
        $returnFeed['error'] = $theFeed->error();             // Return any errors
        $returnFeed['feed']  = $theFeed;                      // The feed information

        // Per SimplePie documentation, there is a bug in versions of PHP older than 5.3 where PHP doesn't release memory properly in certain cases.
        // This is the workaround
        $theFeed->__destruct();
        unset($theFeed);

        return $returnFeed;
    }
コード例 #12
0
ファイル: Plugin.php プロジェクト: rmaiwald/core
 /**
  * Setup or restore storage directory.
  *
  * @param string $dir Storage directory (inside Zikula "ztemp" dir)
  *
  * @return bool
  */
 public function setupThumbDir($dir = null)
 {
     if (is_null($dir)) {
         $dir = $this->getVar('thumb_dir');
     }
     if (!($result = file_exists(CacheUtil::getLocalDir($dir)))) {
         $result = CacheUtil::createLocalDir($dir);
     }
     if ($result) {
         $dir = CacheUtil::getLocalDir($dir);
         $htaccess = "{$dir}/.htaccess";
         if (!file_exists($htaccess)) {
             $template = "{$this->getBaseDir()}/templates/default.htaccess";
             $result = copy($template, $htaccess);
         }
     }
     return $result;
 }
コード例 #13
0
    /**
     * Constructor.
     *
     * @param Zikula_ServiceManager $serviceManager ServiceManager.
     * @param string                $moduleName     Module name ("zikula" for system plugins).
     * @param integer|null          $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
     */
    public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
    {
        $this->serviceManager = $serviceManager;
        $this->eventManager = $this->serviceManager->getService('zikula.eventmanager');
        $this->request = $this->serviceManager->getService('request');

        // set the error reporting level
        $this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
        $this->allow_php_tag = true;

        // get variables from input
        $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
        $type   = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
        $func   = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);

        // set vars based on the module structures
        $this->homepage = empty($module) ? true : false;
        $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
        $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));

        // Initialize the module property with the name of
        // the topmost module. For Hooks, Blocks, API Functions and others
        // you need to set this property to the name of the respective module!
        $this->toplevelmodule = ModUtil::getName();

        if (!$moduleName) {
            $moduleName = $this->toplevelmodule;
        }
        $this->modinfo = ModUtil::getInfoFromName($moduleName);
        $this->module  = array($moduleName => $this->modinfo);

        // initialise environment vars
        $this->language = ZLanguage::getLanguageCode();
        $this->baseurl = System::getBaseUrl();
        $this->baseuri = System::getBaseUri();

        // system info
        $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
        $this->theme = $theme = $this->themeinfo['directory'];

        //---- Plugins handling -----------------------------------------------
        // add plugin paths
        switch ($this->modinfo['type'])
        {
            case ModUtil::TYPE_MODULE :
                $mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
                $mpluginPathOld = "modules/" . $this->modinfo['directory'] . "/pntemplates/plugins";
                break;
            case ModUtil::TYPE_SYSTEM :
                $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
                $mpluginPathOld = "system/" . $this->modinfo['directory'] . "/pntemplates/plugins";
                break;
            default:
                $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
                $mpluginPathOld = "system/" . $this->modinfo['directory'] . "/pntemplates/plugins";
        }

        // add standard plugin search path
        $this->plugins_dir = array();
        $this->addPluginDir('config/plugins'); // Official override
        $this->addPluginDir('lib/viewplugins'); // Core plugins
        $this->addPluginDir("themes/$theme/plugins"); // Theme plugins
        $this->addPluginDir('plugins'); // Smarty core plugins
        $this->addPluginDir($mpluginPath); // Plugins for current module

        // check if the 'type' parameter in the URL is admin and if yes,
        // include system/Admin/templates/plugins to the plugins_dir array
        if ($type === 'admin') {
            if (!$this instanceof Zikula_View_Theme) {
                $this->addPluginDir('system/Admin/templates/plugins');
            } else {
                $this->load_filter('output', 'admintitle');
            }
        }

        // adds legacy plugin paths if needed
        if (System::isLegacyMode()) {
            $this->addPluginDir('lib/legacy/plugins'); // Core legacy plugins
            $this->addPluginDir($mpluginPathOld); // Module plugins (legacy paths)
            $this->addPluginDir("themes/$theme/templates/modules/$moduleName/plugins"); // Module override in themes
        }

        //---- Cache handling -------------------------------------------------
        if ($caching && in_array((int)$caching, array(0, 1, 2))) {
            $this->caching = (int)$caching;
        } else {
            $this->caching = (int)ModUtil::getVar('Theme', 'render_cache');
        }

        // write actions should not be cached or weird things happen
        if (isset($_POST) && count($_POST) != 0) {
            $this->caching = Zikula_View::CACHE_DISABLED;
        }

        $this->compile_id  = '';
        $this->cache_id    = '';

        // template compilation
        $this->compile_dir    = CacheUtil::getLocalDir('view_compiled');
        $this->compile_check  = ModUtil::getVar('Theme', 'render_compile_check');
        $this->force_compile  = ModUtil::getVar('Theme', 'render_force_compile');
        // template caching
        $this->cache_dir      = CacheUtil::getLocalDir('view_cache');
        $this->cache_lifetime = ModUtil::getVar('Theme', 'render_lifetime');

        $this->expose_template = (ModUtil::getVar('Theme', 'render_expose_template') == true) ? true : false;

        // register resource type 'z' this defines the way templates are searched
        // during {include file='my_template.tpl'} this enables us to store selected module
        // templates in the theme while others can be kept in the module itself.
        $this->register_resource('z', array('Zikula_View_Resource',
                                            'z_get_template',
                                            'z_get_timestamp',
                                            'z_get_secure',
                                            'z_get_trusted'));

        // set 'z' as default resource type
        $this->default_resource_type = 'z';

        // process some plugins specially when Render cache is enabled
        if (!$this instanceof Zikula_View_Theme && $this->caching) {
            $this->register_nocache_plugins();
        }

        // register the 'nocache' block to allow dynamic zones caching templates
        $this->register_block('nocache', array('Zikula_View_Resource', 'block_nocache'), false);

        // For ajax requests we use the short urls filter to 'fix' relative paths
        if (($this->serviceManager->getService('zikula')->getStage() & Zikula_Core::STAGE_AJAX) && System::getVar('shorturls')) {
            $this->load_filter('output', 'shorturls');
        }

        // register prefilters
        $this->register_prefilter('z_prefilter_add_literal');

        if ($GLOBALS['ZConfig']['System']['legacy_prefilters']) {
            $this->register_prefilter('z_prefilter_legacy');
        }

        $this->register_prefilter('z_prefilter_gettext_params');
        //$this->register_prefilter('z_prefilter_notifyfilters');

        // assign some useful settings
        $this->assign('homepage', $this->homepage)
             ->assign('modinfo', $this->modinfo)
             ->assign('module', $moduleName)
             ->assign('toplevelmodule', $this->toplevelmodule)
             ->assign('type', $this->type)
             ->assign('func', $this->func)
             ->assign('lang', $this->language)
             ->assign('themeinfo', $this->themeinfo)
             ->assign('themepath', $this->baseurl . 'themes/' . $theme)
             ->assign('baseurl', $this->baseurl)
             ->assign('baseuri', $this->baseuri);

        if (System::isLegacyMode()) {
            $this->assign('stylepath', $this->baseurl . 'themes/' . $theme . '/style')
                 ->assign('scriptpath', $this->baseurl . 'themes/' . $theme . '/javascript')
                 ->assign('imagepath', $this->baseurl . 'themes/' . $theme . '/images')
                 ->assign('imagelangpath', $this->baseurl . 'themes/' . $theme . '/images/' . $this->language);
        }

        // for {gt} template plugin to detect gettext domain
        if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
            $this->domain = ZLanguage::getModuleDomain($this->modinfo['name']);
        }

        // make render object available to modifiers
        parent::assign('zikula_view', $this);

        // add ServiceManager, EventManager and others to all templates
        parent::assign('serviceManager', $this->serviceManager);
        parent::assign('eventManager', $this->eventManager);
        parent::assign('zikula_core', $this->serviceManager->getService('zikula'));
        parent::assign('request', $this->request);
        parent::assign('modvars', ModUtil::getModvars()); // Get all modvars from any modules that have accessed their modvars at least once.

        $this->add_core_data();

        // metadata for SEO
        if (!isset($this->serviceManager['zikula_view.metatags'])) {
            $this->serviceManager['zikula_view.metatags'] = new ArrayObject(array());
        }

        parent::assign('metatags', $this->serviceManager['zikula_view.metatags']);

        $event = new Zikula_Event('view.init', $this);
        $this->eventManager->notify($event);
    }
コード例 #14
0
 /**
  * @Route("/download/{slug}.zip", requirements={"slug"=".+"})
  * @ParamConverter("entity", class="Cmfcmf\Module\MediaModule\Entity\Collection\CollectionEntity", options={"slug" = "slug"})
  *
  * @param Request          $request
  * @param CollectionEntity $entity
  *
  * @return array
  */
 public function downloadAction(CollectionEntity $entity)
 {
     if (!$this->get('cmfcmf_media_module.security_manager')->hasPermission($entity, 'download')) {
         throw new AccessDeniedException();
     }
     \CacheUtil::createLocalDir('CmfcmfMediaModule');
     $dir = \CacheUtil::getLocalDir('CmfcmfMediaModule');
     $path = $dir . '/' . uniqid(time(), true) . '.zip';
     $zip = new \ZipArchive();
     if ($zip->open($path, \ZipArchive::CREATE) !== true) {
         throw new ServiceUnavailableHttpException('Could not create zip archive!');
     }
     $mediaTypeCollection = $this->get('cmfcmf_media_module.media_type_collection');
     $hasContent = false;
     $usedFileNames = [];
     foreach ($entity->getMedia() as $media) {
         if ($media instanceof AbstractFileEntity && $media->isDownloadAllowed()) {
             /** @var UploadableMediaTypeInterface $mediaType */
             $mediaType = $mediaTypeCollection->getMediaTypeFromEntity($media);
             $filename = $media->getBeautifiedFileName();
             $originalFileExtension = pathinfo($filename, PATHINFO_EXTENSION);
             $originalFilename = pathinfo($filename, PATHINFO_BASENAME);
             for ($i = 1; in_array($filename, $usedFileNames, true); ++$i) {
                 $filename = "{$originalFilename} ({$i})" . (empty($originalFileExtension) ?: ".{$originalFileExtension}");
             }
             $zip->addFile($mediaType->getOriginalWithWatermark($media, 'path', false), $filename);
             $hasContent = true;
         }
     }
     if (!$hasContent) {
         $zip->addFromString('Empty Collection.txt', $this->__('Sorry, the collection appears to be empty or does not have any downloadable files.'));
     }
     $zip->close();
     $response = new BinaryFileResponse($path);
     $response->deleteFileAfterSend(true);
     return $response;
 }
コード例 #15
0
ファイル: Plugin.php プロジェクト: projectesIF/Sirius
    /**
     * Initialise.
     *
     * Runs at plugin init time.
     *
     * @return void
     */
    public function initialize()
    {
        // register namespace
        // Because the standard kernel classloader already has Doctrine registered as a namespace
        // we have to add a new loader onto the spl stack.
        $autoloader = new Zikula_KernelClassLoader();
        $autoloader->spl_autoload_register();
        include 'lib/DoctrineHelper.php';
        $autoloader->register('Doctrine', dirname(__FILE__) . '/lib/vendor', '\\');
        $autoloader->register('DoctrineProxy', 'ztemp/doctrinemodels', '\\');

        $serviceManager = $this->eventManager->getServiceManager();
        $config = $GLOBALS['ZConfig']['DBInfo']['databases']['default'];
        $dbConfig = array('host' => $config['host'],
                          'user' => $config['user'],
                          'password' => $config['password'],
                          'dbname' => $config['dbname'],
                          'driver' => 'pdo_' . $config['dbdriver'],
                          );
        $r = new \ReflectionClass('Doctrine\Common\Cache\\' . $serviceManager['dbcache.type'] . 'Cache');
        $dbCache = $r->newInstance();
        $ORMConfig = new \Doctrine\ORM\Configuration;
        $serviceManager->attachService('doctrine.configuration', $ORMConfig);
        $ORMConfig->setMetadataCacheImpl($dbCache);

        // create proxy cache dir
        CacheUtil::createLocalDir('doctrinemodels');

        // setup annotations base
        include_once 'lib/vendor/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';

        // setup annotation reader
        $reader = new \Doctrine\Common\Annotations\AnnotationReader();
        $cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
        $serviceManager->attachService('doctrine.annotationreader', $cacheReader);

        // setup annotation driver
        $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader);
        $serviceManager->attachService('doctrine.annotationdriver', $annotationDriver);

        // setup driver chains
        $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
        $serviceManager->attachService('doctrine.driverchain', $driverChain);

        // configure Doctrine ORM
        $ORMConfig->setMetadataDriverImpl($annotationDriver);
        $ORMConfig->setQueryCacheImpl($dbCache);
        $ORMConfig->setProxyDir(CacheUtil::getLocalDir('doctrinemodels'));
        $ORMConfig->setProxyNamespace('DoctrineProxy');
        //$ORMConfig->setAutoGenerateProxyClasses(System::isDevelopmentMode());

        if (isset($serviceManager['log.enabled']) && $serviceManager['log.enabled']) {
            $ORMConfig->setSQLLogger(new SystemPlugin_Doctrine_ZikulaSqlLogger());
        }

        // setup doctrine eventmanager
        $eventManager = new \Doctrine\Common\EventManager;
        $serviceManager->attachService('doctrine.eventmanager', $eventManager);

         // setup MySQL specific listener (storage engine and encoding)
        if ($config['dbdriver'] == 'mysql') {
            $mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']);
            $eventManager->addEventSubscriber($mysqlSessionInit);

            $mysqlStorageEvent = new SystemPlugin_Doctrine_MySqlGenerateSchemaListener($eventManager);
        }

        // setup the doctrine entitymanager
        $entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $eventManager);
        $serviceManager->attachService('doctrine.entitymanager', $entityManager);
    }
コード例 #16
0
ファイル: Admin.php プロジェクト: projectesIF/Sirius
    /**
     * This is a standard function to update the configuration parameters of the
     * module given the information passed back by the modification form
     * @see securitycenter_admin_modifyconfig()
     *
     * @param int enableanticracker
     * @param int itemsperpage
     * @param int emailhackattempt
     * @param int loghackattempttodb
     * @param int onlysendsummarybyemail
     * @param int updatecheck
     * @param int updatefrequency
     * @param int keyexpiry
     * @param int sessionauthkeyua
     * @param string secure_domain
     * @param int signcookies
     * @param string signingkey
     * @param string seclevel
     * @param int secmeddays
     * @param int secinactivemins
     * @param int sessionstoretofile
     * @param string sessionsavepath
     * @param int gc_probability
     * @param int anonymoussessions
     * @param int sessionrandregenerate
     * @param int sessionregenerate
     * @param int sessionregeneratefreq
     * @param int sessionipcheck
     * @param string sessionname
     * @param int filtergetvars
     * @param int filterpostvars
     * @param int filtercookievars
     * @param int outputfilter
     * @param string summarycontent
     * @param string fullcontent
     *
     * @return bool true if successful, false otherwise.
     */
    public function updateconfig()
    {
        $this->checkCsrfToken();

        // Security check
        if (!SecurityUtil::checkPermission('SecurityCenter::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        $validates = true;

        // Update module variables.
        $updatecheck = (int)FormUtil::getPassedValue('updatecheck', 0, 'POST');
        System::setVar('updatecheck', $updatecheck);

        // if update checks are disabled, reset values to force new update check if re-enabled
        if ($updatecheck == 0) {
            System::setVar('updateversion', Zikula_Core::VERSION_NUM);
            System::setVar('updatelastchecked', 0);
        }

        $updatefrequency = (int)FormUtil::getPassedValue('updatefrequency', 30, 'POST');
        System::setVar('updatefrequency', $updatefrequency);

        $keyexpiry = (int)FormUtil::getPassedValue('keyexpiry', 0, 'POST');
        if ($keyexpiry < 0 || $keyexpiry > 3600) {
            $keyexpiry = 0;
        }
        System::setVar('keyexpiry', $keyexpiry);

        $sessionauthkeyua = (int)FormUtil::getPassedValue('sessionauthkeyua', 0, 'POST');
        System::setVar('sessionauthkeyua', $sessionauthkeyua);

        $secure_domain = FormUtil::getPassedValue('secure_domain', '', 'POST');
        System::setVar('secure_domain', $secure_domain);

        $signcookies = (int)FormUtil::getPassedValue('signcookies', 1, 'POST');
        System::setVar('signcookies', $signcookies);

        $signingkey = FormUtil::getPassedValue('signingkey', '', 'POST');
        System::setVar('signingkey', $signingkey);

        $seclevel = FormUtil::getPassedValue('seclevel', 'High', 'POST');
        System::setVar('seclevel', $seclevel);

        $secmeddays = (int)FormUtil::getPassedValue('secmeddays', 7, 'POST');
        if ($secmeddays < 1 || $secmeddays > 365) {
            $secmeddays = 7;
        }
        System::setVar('secmeddays', $secmeddays);

        $secinactivemins = (int)FormUtil::getPassedValue('secinactivemins', 20, 'POST');
        if ($secinactivemins < 1 || $secinactivemins > 1440) {
            $secinactivemins = 7;
        }
        System::setVar('secinactivemins', $secinactivemins);

        $sessionstoretofile = (int)FormUtil::getPassedValue('sessionstoretofile', 0, 'POST');
        $sessionsavepath = FormUtil::getPassedValue('sessionsavepath', '', 'POST');

        // check session path config is writable (if method is being changed to session file storage)
        $cause_logout = false;
        $storeTypeCanBeWritten = true;
        if ($sessionstoretofile == 1 && !empty($sessionsavepath)) {
            // fix path on windows systems
            $sessionsavepath = str_replace('\\', '/', $sessionsavepath);
            // sanitize the path
            $sessionsavepath = trim(stripslashes($sessionsavepath));

            // check if sessionsavepath is a dir and if it is writable
            // if yes, we need to logout
            $cause_logout = (is_dir($sessionsavepath)) ? is_writable($sessionsavepath) : false;

            if ($cause_logout == false) {
                // an error occured - we do not change the way of storing session data
                LogUtil::registerStatus($this->__('Error! Session path not writeable!'));
                $storeTypeCanBeWritten = false;
            }
        }
        if ($storeTypeCanBeWritten == true) {
            System::setVar('sessionstoretofile', $sessionstoretofile);
            System::setVar('sessionsavepath', $sessionsavepath);
        }

        if ((bool)$sessionstoretofile != (bool)System::getVar('sessionstoretofile')) {
            // logout if going from one storage to another one
            $cause_logout = true;
        }

        $gc_probability = (int)FormUtil::getPassedValue('gc_probability', 100, 'POST');
        if ($gc_probability < 1 || $gc_probability > 10000) {
            $gc_probability = 7;
        }
        System::setVar('gc_probability', $gc_probability);

        $anonymoussessions = (int)FormUtil::getPassedValue('anonymoussessions', 1, 'POST');
        System::setVar('anonymoussessions', $anonymoussessions);

        $sessionrandregenerate = (int)FormUtil::getPassedValue('sessionrandregenerate', 1, 'POST');
        System::setVar('sessionrandregenerate', $sessionrandregenerate);

        $sessionregenerate = (int)FormUtil::getPassedValue('sessionregenerate', 1, 'POST');
        System::setVar('sessionregenerate', $sessionregenerate);

        $sessionregeneratefreq = (int)FormUtil::getPassedValue('sessionregeneratefreq', 10, 'POST');
        if ($sessionregeneratefreq < 1 || $sessionregeneratefreq > 100) {
            $sessionregeneratefreq = 10;
        }
        System::setVar('sessionregeneratefreq', $sessionregeneratefreq);

        $sessionipcheck = (int)FormUtil::getPassedValue('sessionipcheck', 0, 'POST');
        System::setVar('sessionipcheck', $sessionipcheck);

        $sessionname = FormUtil::getPassedValue('sessionname', 'ZSID', 'POST');
        if (strlen($sessionname) < 3) {
            $sessionname = 'ZSID';
        }

        $sessioncsrftokenonetime = (int)FormUtil::getPassedValue('sessioncsrftokenonetime', 0, 'POST');
        System::setVar('sessioncsrftokenonetime', $sessioncsrftokenonetime);

        // cause logout if we changed session name
        if ($sessionname != System::getVar('sessionname')) {
            $cause_logout = true;
        }

        System::setVar('sessionname', $sessionname);
        System::setVar('sessionstoretofile', $sessionstoretofile);

        $outputfilter = FormUtil::getPassedValue('outputfilter', 0, 'POST');
        System::setVar('outputfilter', $outputfilter);

        $useids = (bool)FormUtil::getPassedValue('useids', 0, 'POST');
        System::setVar('useids', $useids);

        // create tmp directory for PHPIDS
        if ($useids == 1) {
            $idsTmpDir = CacheUtil::getLocalDir() . '/idsTmp';
            if (!file_exists($idsTmpDir)) {
                CacheUtil::clearLocalDir('idsTmp');
            }
        }

        $idssoftblock = (bool)FormUtil::getPassedValue('idssoftblock', 1, 'POST');
        System::setVar('idssoftblock', $idssoftblock);

        $idsmail = (bool)FormUtil::getPassedValue('idsmail', 1, 'POST');
        System::setVar('idsmail', $idsmail);

        $idsfilter = FormUtil::getPassedValue('idsfilter', 'xml', 'POST');
        System::setVar('idsfilter', $idsfilter);

        $idsrulepath = FormUtil::getPassedValue('idsrulepath', 'config/zikula_default.xml', 'POST');
        $idsrulepath = DataUtil::formatForOS($idsrulepath);
        if (is_readable($idsrulepath)) {
            System::setVar('idsrulepath', $idsrulepath);
        } else {
            LogUtil::registerError($this->__f('Error! PHPIDS rule file %s does not exist or is not readable.', $idsrulepath));
            $validates = false;
        }

        $idsimpactthresholdone = (int)FormUtil::getPassedValue('idsimpactthresholdone', 1, 'POST');
        System::setVar('idsimpactthresholdone', $idsimpactthresholdone);

        $idsimpactthresholdtwo = (int)FormUtil::getPassedValue('idsimpactthresholdtwo', 10, 'POST');
        System::setVar('idsimpactthresholdtwo', $idsimpactthresholdtwo);

        $idsimpactthresholdthree = (int)FormUtil::getPassedValue('idsimpactthresholdthree', 25, 'POST');
        System::setVar('idsimpactthresholdthree', $idsimpactthresholdthree);

        $idsimpactthresholdfour = (int)FormUtil::getPassedValue('idsimpactthresholdfour', 75, 'POST');
        System::setVar('idsimpactthresholdfour', $idsimpactthresholdfour);

        $idsimpactmode = (int)FormUtil::getPassedValue('idsimpactmode', 1, 'POST');
        System::setVar('idsimpactmode', $idsimpactmode);

        $idshtmlfields = FormUtil::getPassedValue('idshtmlfields', '', 'POST');
        $idshtmlfields = explode(PHP_EOL, $idshtmlfields);
        $idshtmlarray = array();
        foreach ($idshtmlfields as $idshtmlfield) {
            $idshtmlfield = trim($idshtmlfield);
            if (!empty($idshtmlfield)) {
                $idshtmlarray[] = $idshtmlfield;
            }
        }
        System::setVar('idshtmlfields', $idshtmlarray);

        $idsjsonfields = FormUtil::getPassedValue('idsjsonfields', '', 'POST');
        $idsjsonfields = explode(PHP_EOL, $idsjsonfields);
        $idsjsonarray = array();
        foreach ($idsjsonfields as $idsjsonfield) {
            $idsjsonfield = trim($idsjsonfield);
            if (!empty($idsjsonfield)) {
                $idsjsonarray[] = $idsjsonfield;
            }
        }
        System::setVar('idsjsonfields', $idsjsonarray);

        $idsexceptions = FormUtil::getPassedValue('idsexceptions', '', 'POST');
        $idsexceptions = explode(PHP_EOL, $idsexceptions);
        $idsexceptarray = array();
        foreach ($idsexceptions as $idsexception) {
            $idsexception = trim($idsexception);
            if (!empty($idsexception)) {
                $idsexceptarray[] = $idsexception;
            }
        }
        System::setVar('idsexceptions', $idsexceptarray);

        // clear all cache and compile directories
        ModUtil::apiFunc('Settings', 'admin', 'clearallcompiledcaches');

        // the module configuration has been updated successfuly
        if ($validates) {
            $this->registerStatus($this->__('Done! Saved module configuration.'));
        }

        // we need to auto logout the user if they changed from DB to FILE
        if ($cause_logout == true) {
            UserUtil::logout();
            $this->registerStatus($this->__('Session handling variables have changed. You must log in again.'));
            $returnPage = urlencode(ModUtil::url('SecurityCenter', 'admin', 'modifyconfig'));
            $this->redirect(ModUtil::url('Users', 'user', 'login', array('returnpage' => $returnPage)));
        }

        // This function generated no output, and so now it is complete we redirect
        // the user to an appropriate page for them to carry on their work
        return $this->redirect(ModUtil::url('SecurityCenter', 'admin', 'modifyconfig'));
    }
コード例 #17
0
ファイル: SystemListeners.php プロジェクト: Silwereth/core
 /**
  * On an module remove hook call this listener deletes all cached (generated) doctrine models for the module.
  *
  * Listens for the 'installer.module.uninstalled' event.
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function deleteGeneratedCategoryModelsOnModuleRemove(Zikula_Event $event)
 {
     $moduleName = $event['name'];
     // remove generated category models for this record
     $dir = 'doctrinemodels/GeneratedDoctrineModel/' . $moduleName;
     if (file_exists(CacheUtil::getLocalDir($dir))) {
         CacheUtil::removeLocalDir($dir, true);
     }
     // remove saved data about the record
     $modelsInfo = ModUtil::getVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', array());
     foreach ($modelsInfo as $class => $info) {
         if ($info['module'] == $moduleName) {
             unset($modelsInfo[$class]);
         }
     }
     ModUtil::setVar('ZikulaCategoriesModule', 'EntityCategorySubclasses', $modelsInfo);
 }
コード例 #18
0
ファイル: Filter.php プロジェクト: projectesIF/Sirius
    /**
     * Retrieves configuration array for PHPIDS.
     *
     * @return array IDS configuration settings.
     */
    private function _getidsconfig()
    {
        $config = array();

        // General configuration settings
        $config['General'] = array();

        $config['General']['filter_type'] = System::getVar('idsfilter', 'xml');
        if (empty($config['General']['filter_type'])) {
            $config['General']['filter_type'] = 'xml';
        }

        $config['General']['base_path'] = PHPIDS_PATH_PREFIX;
        // we don't use the base path because the tmp directory is in zkTemp (see below)
        $config['General']['use_base_path'] = false;

        // path to the filters used
        $config['General']['filter_path'] = System::getVar('idsrulepath', 'config/phpids_zikula_default.xml');
        // path to (writable) tmp directory
        $config['General']['tmp_path'] = CacheUtil::getLocalDir() . '/idsTmp';
        $config['General']['scan_keys'] = false;

        // we use a different HTML Purifier source
        // by default PHPIDS does also contain those files
        // we do this more efficiently in boostrap (drak).
        $config['General']['HTML_Purifier_Path'] = ''; // this must be set or IDS/Monitor will never fill in the HTML_Purifier_Cache property (drak).
        $config['General']['HTML_Purifier_Cache'] = CacheUtil::getLocalDir() . '/purifierCache';

        // define which fields contain html and need preparation before hitting the PHPIDS rules
        $config['General']['html'] = System::getVar('idshtmlfields', array());

        // define which fields contain JSON data and should be treated as such for fewer false positives
        $config['General']['json'] = System::getVar('idsjsonfields', array());

        // define which fields shouldn't be monitored (a[b]=c should be referenced via a.b)
        $config['General']['exceptions'] = System::getVar('idsexceptions', array());

        // PHPIDS should run with PHP 5.1.2 but this is untested - set this value to force compatibilty with minor versions
        $config['General']['min_php_version'] = '5.1.6';


        // caching settings
        // @todo: add UI for those caching settings
        $config['Caching'] = array();

        // caching method (session|file|database|memcached|none), default file
        $config['Caching']['caching'] = 'none'; // deactivate caching for now
        $config['Caching']['expiration_time'] = 600;

        // file cache
        $config['Caching']['path'] = $config['General']['tmp_path'] . '/default_filter.cache';

        // database cache
        //$config['Caching']['wrapper'] = 'mysql:host=localhost;port=3306;dbname=phpids';
        //$config['Caching']['user'] = '******';
        //$config['Caching']['password'] = '******';
        //$config['Caching']['table'] = 'cache';

        // memcached
        //$config['Caching']['host'] = 'localhost';
        //$config['Caching']['port'] = 11211;
        //$config['Caching']['key_prefix'] = 'PHPIDS';
        //$config['Caching']['tmp_path'] = $config['General']['tmp_path'] . '/memcache.timestamp';

        return $config;
    }
コード例 #19
0
ファイル: View.php プロジェクト: rtznprmpftl/Zikulacore
 /**
  * Constructor.
  *
  * @param ContainerBuilder $container ServiceManager.
  * @param string           $moduleName     Module name ("zikula" for system plugins).
  * @param integer|null     $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  */
 public function __construct(ContainerBuilder $container, $moduleName = '', $caching = null)
 {
     $this->container = $container;
     $this->dispatcher = $this->container->get('event_dispatcher');
     $this->request = $this->container->get('request');
     // set the error reporting level
     $this->error_reporting = isset($container['error_reporting']) ? $container['error_reporting'] : E_ALL;
     $this->allow_php_tag = true;
     // get variables from input
     $module = $this->request->attributes->get('_module', null);
     $type = $this->request->attributes->get('_controller', 'user');
     $func = $this->request->attributes->get('_action', 'index');
     // set vars based on the module structures
     $this->homepage = empty($module) ? true : false;
     $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
     $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
     // Initialize the module property with the name of
     // the topmost module. For Hooks, Blocks, API Functions and others
     // you need to set this property to the name of the respective module!
     $this->toplevelmodule = ModUtil::getName();
     if (!$moduleName) {
         $moduleName = $this->toplevelmodule;
     }
     $this->modinfo = ModUtil::getInfoFromName($moduleName);
     $this->module = array($moduleName => $this->modinfo);
     // initialise environment vars
     $this->language = ZLanguage::getLanguageCode();
     $this->baseurl = System::getBaseUrl();
     $this->baseuri = System::getBaseUri();
     // system info
     $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
     $this->theme = $this->themeinfo['directory'];
     //---- Plugins handling -----------------------------------------------
     // add plugin paths
     switch ($this->modinfo['type']) {
         case ModUtil::TYPE_MODULE:
             $mpluginPath = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             break;
         case ModUtil::TYPE_SYSTEM:
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/Rsources/views/plugins";
             break;
         default:
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/Rsources/views/plugins";
     }
     // add standard plugin search path
     $this->plugins_dir = array();
     $this->addPluginDir('config/Resources/plugins');
     // Official override
     $this->addPluginDir('config/plugins');
     // Official override
     $this->addPluginDir(ZIKULA_ROOT . '/../src/legacy/viewplugins');
     // Core plugins
     $this->addPluginDir("themes/{$this->theme}/Resources/views/plugins");
     // Theme plugins
     $this->addPluginDir(SMARTY_DIR . 'plugins');
     // Smarty core plugins
     $this->addPluginDir($mpluginPath);
     // Plugins for current module
     // check if the 'type' parameter in the URL is admin and if yes,
     // include system/Admin/templates/plugins to the plugins_dir array
     if ($type === 'admin') {
         if (!$this instanceof Zikula_View_Theme) {
             $this->addPluginDir('system/AdminModule/Resources/views/plugins');
         } else {
             $this->load_filter('output', 'admintitle');
         }
     }
     //---- Cache handling -------------------------------------------------
     if ($caching && in_array((int) $caching, array(0, 1, 2))) {
         $this->caching = (int) $caching;
     } else {
         $this->caching = (int) ModUtil::getVar('Theme', 'render_cache');
     }
     $this->compile_id = '';
     $this->cache_id = '';
     // template compilation
     $this->compile_dir = CacheUtil::getLocalDir('view_compiled');
     $this->compile_check = ModUtil::getVar('Theme', 'render_compile_check');
     $this->force_compile = ModUtil::getVar('Theme', 'render_force_compile');
     // template caching
     $this->cache_dir = CacheUtil::getLocalDir('view_cache');
     $this->cache_lifetime = ModUtil::getVar('Theme', 'render_lifetime');
     $this->expose_template = ModUtil::getVar('Theme', 'render_expose_template') == true ? true : false;
     // register resource type 'z' this defines the way templates are searched
     // during {include file='my_template.tpl'} this enables us to store selected module
     // templates in the theme while others can be kept in the module itself.
     $this->register_resource('z', array('Zikula_View_Resource', 'z_get_template', 'z_get_timestamp', 'z_get_secure', 'z_get_trusted'));
     // set 'z' as default resource type
     $this->default_resource_type = 'z';
     // process some plugins specially when Render cache is enabled
     if (!$this instanceof Zikula_View_Theme && $this->caching) {
         $this->register_nocache_plugins();
     }
     // register the 'nocache' block to allow dynamic zones caching templates
     $this->register_block('nocache', array('Zikula_View_Resource', 'block_nocache'), false);
     // For ajax requests we use the short urls filter to 'fix' relative paths
     if ($this->container->get('zikula')->getStage() & \Zikula\Core\Core::STAGE_AJAX && System::getVar('shorturls')) {
         $this->load_filter('output', 'shorturls');
     }
     // register prefilters
     $this->register_prefilter('z_prefilter_add_literal');
     $this->register_prefilter('z_prefilter_gettext_params');
     // assign some useful settings
     $this->assign('homepage', $this->homepage)->assign('modinfo', $this->modinfo)->assign('module', $moduleName)->assign('toplevelmodule', $this->toplevelmodule)->assign('type', $this->type)->assign('func', $this->func)->assign('lang', $this->language)->assign('themeinfo', $this->themeinfo)->assign('themepath', $this->baseurl . 'themes/' . $this->theme)->assign('baseurl', $this->baseurl)->assign('baseuri', $this->baseuri);
     // for {gt} template plugin to detect gettext domain
     if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
         $this->domain = ZLanguage::getModuleDomain($this->modinfo['name']);
     }
     // make render object available to modifiers
     parent::assign('zikula_view', $this);
     // add ServiceManager, EventManager and others to all templates
     parent::assign('container', $this->container);
     parent::assign('dispatcher', $this->dispatcher);
     parent::assign('zikula_core', $this->container->get('zikula'));
     parent::assign('request', $this->request);
     parent::assign('modvars', ModUtil::getModvars());
     // Get all modvars from any modules that have accessed their modvars at least once.
     $this->add_core_data();
     // metadata for SEO
     if (!isset($this->container['zikula_view.metatags'])) {
         $this->container['zikula_view.metatags'] = new ArrayObject(array());
     }
     parent::assign('metatags', $this->container['zikula_view.metatags']);
     $event = new GenericEvent($this);
     $this->dispatcher->dispatch('view.init', $event);
 }
コード例 #20
0
ファイル: User.php プロジェクト: projectesIF/Sirius
    /**
     * write an ini file to the running configuration directory
     */
    public function writeinifile($args)
    {
        // check our input
        if (!isset($args['file']) || empty($args['file'])) {
            return LogUtil::registerArgsError();
        }

        if (!isset($args['theme']) || empty($args['theme'])) {
            return LogUtil::registerArgsError();
        }

        // get the theme info
        $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($args['theme']));

        $content = ModUtil::apiFunc('theme', 'user', 'createinifile', array('has_sections' => $args['has_sections'], 'assoc_arr' => $args['assoc_arr']));

        $ostemp  = CacheUtil::getLocalDir();
        $ostheme = DataUtil::formatForOS($themeinfo['directory']);
        $osfile  = DataUtil::formatForOS($args['file']);

        // verify the writable paths
        $tpath = 'themes/'.$ostheme.'/templates/config';

        if (is_writable($tpath.'/'.$osfile)) {
            $handle = fopen($tpath.'/'.$osfile, 'w+');

        } else {
            if (!file_exists($zpath = $ostemp.'/Theme_Config/'.$ostheme)) {
                mkdir($zpath, $this->serviceManager['system.chmod_dir'], true);
            }

            if (!file_exists($zpath.'/'.$osfile) || is_writable($zpath.'/'.$osfile)) {
                $handle = fopen($zpath.'/'.$osfile, 'w+');
            } else {
                return LogUtil::registerError($this->__f("Error! Cannot write in '%1$s' or '%2$s' to store the contents of '%3$s'.", array($tpath, $zpath, $osfile)));
            }
        }

        // validate the resulting handler and the write operation result
        if (!isset($handle) || !is_resource($handle)) {
            return LogUtil::registerError($this->__f('Error! Could not open file so that it could be written to: %s', $osfile));

        } else {
            if (fwrite($handle, $content) === false) {
                fclose($handle);

                return LogUtil::registerError($this->__f('Error! Could not write to file: %s', $osfile));
            }
            fclose($handle);

            return true;
        }
    }
コード例 #21
0
ファイル: Util.php プロジェクト: projectesIF/Sirius
    /**
     * Retrieves an instance of HTMLPurifier.
     *
     * The instance returned is either a newly created instance, or previously created instance
     * that has been cached in a static variable.
     *
     * @param array $args All arguments for the function.
     *                    bool $args['force'] If true, the HTMLPurifier instance will be generated anew, rather than using an
     *                                          existing instance from the static variable.
     *
     * @staticvar array $purifier The HTMLPurifier instance.
     *
     * @return HTMLPurifier The HTMLPurifier instance, returned by reference.
     */
    public static function getpurifier($args = null)
    {
        $force = (isset($args['force']) ? $args['force'] : false);

        // prepare htmlpurifier class
        static $purifier;

        if (!isset($purifier) || $force) {
            $config = self::getpurifierconfig(array('forcedefault' => false));

            $config['Cache']['SerializerPath'] = CacheUtil::getLocalDir() . '/purifierCache';

            $purifier = new HTMLPurifier($config);
        }

        return $purifier;
    }