Ejemplo n.º 1
0
 public function isNecessary()
 {
     if (version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<')) {
         throw new AbortStageException(__f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', array(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION)));
     }
     // make sure selected language is installed
     if (!in_array(\ZLanguage::getLanguageCode(), \ZLanguage::getInstalledLanguages())) {
         \System::setVar('language_i18n', 'en');
         \System::setVar('language', 'eng');
         \System::setVar('locale', 'en');
         \ZLanguage::setLocale('en');
     }
     return true;
 }
Ejemplo n.º 2
0
 public function processRecoveryPHPIDS()
 {
     if (!System::setVar('useids', false)) {
         $this->setError(__('Error disabling PHPIDS'));
         return false;
     }
     // Set a status message.
     $this->setStatus(__('Recovery Successful'));
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Check for updates
  *
  * @return data or false
  */
 private function _updatecheck($force = false)
 {
     if (!\System::getVar('updatecheck')) {
         return array('update_show' => false);
     }
     $now = time();
     $lastChecked = (int) \System::getVar('updatelastchecked');
     $checkInterval = (int) \System::getVar('updatefrequency') * 86400;
     $updateversion = \System::getVar('updateversion');
     if ($force == false && $now - $lastChecked < $checkInterval) {
         // dont get an update because TTL not expired yet
         $onlineVersion = $updateversion;
     } else {
         $s = extension_loaded('openssl') ? 's' : '';
         $onlineVersion = trim($this->_zcurl("http{$s}://update.zikula.org/cgi-bin/engine/checkcoreversion13.cgi"));
         if ($onlineVersion === false) {
             return array('update_show' => false);
         }
         \System::setVar('updateversion', $onlineVersion);
         \System::setVar('updatelastchecked', (int) time());
     }
     // if 1 then there is a later version available
     if (version_compare($onlineVersion, \Zikula\Core\Core::VERSION_NUM) == 1) {
         return array('update_show' => true, 'update_version' => $onlineVersion);
     } else {
         return array('update_show' => false);
     }
 }
Ejemplo n.º 4
0
    /**
     * Update configuration
     *
     */
    public function updateconfig($args)
    {
        $this->checkCsrfToken();

        // security check
        if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_EDIT)) {
            return LogUtil::registerPermissionError();
        }

        // check if the theme cache was disabled and clean it if so
        $enablecache = (bool)FormUtil::getPassedValue('enablecache', isset($args['enablecache']) ? $args['enablecache'] : false, 'POST');

        if ($this->getVar('enablecache') && !$enablecache) {
            $theme = Zikula_View_Theme::getInstance();
            $theme->clear_all_cache();
        }

        // set our module variables
        $this->setVar('enablecache', $enablecache);

        $modulesnocache = FormUtil::getPassedValue('modulesnocache', isset($args['modulesnocache']) ? $args['modulesnocache'] : array(), 'POST');
        $modulesnocache = implode(',', $modulesnocache);
        $this->setVar('modulesnocache', $modulesnocache);

        $compile_check = (bool)FormUtil::getPassedValue('compile_check', isset($args['compile_check']) ? $args['compile_check'] : false, 'POST');
        $this->setVar('compile_check', $compile_check);

        $cache_lifetime = (int)FormUtil::getPassedValue('cache_lifetime', isset($args['cache_lifetime']) ? $args['cache_lifetime'] : 3600, 'POST');
        if ($cache_lifetime < -1) $cache_lifetime = 3600;
        $this->setVar('cache_lifetime', $cache_lifetime);

        $cache_lifetime_mods = (int)FormUtil::getPassedValue('cache_lifetime_mods', isset($args['cache_lifetime_mods']) ? $args['cache_lifetime_mods'] : 3600, 'POST');
        if ($cache_lifetime_mods < -1) $cache_lifetime_mods = 3600;
        $this->setVar('cache_lifetime_mods', $cache_lifetime_mods);

        $force_compile = (bool)FormUtil::getPassedValue('force_compile', isset($args['force_compile']) ? $args['force_compile'] : false, 'POST');
        $this->setVar('force_compile', $force_compile);

        $trimwhitespace = (bool)FormUtil::getPassedValue('trimwhitespace', isset($args['trimwhitespace']) ? $args['trimwhitespace'] : false, 'POST');
        $this->setVar('trimwhitespace', $trimwhitespace);

        $maxsizeforlinks = (int)FormUtil::getPassedValue('maxsizeforlinks', isset($args['maxsizeforlinks']) ? $args['maxsizeforlinks'] : 30, 'POST');
        $this->setVar('maxsizeforlinks', $maxsizeforlinks);

        $theme_change = (bool)FormUtil::getPassedValue('theme_change', isset($args['theme_change']) ? $args['theme_change'] : false, 'POST');
        System::setVar('theme_change', $theme_change);
        
        $enable_mobile_theme = (bool)FormUtil::getPassedValue('enable_mobile_theme', isset($args['enable_mobile_theme']) ? $args['enable_mobile_theme'] : false, 'POST');
        $this->setVar('enable_mobile_theme', $enable_mobile_theme);

        $itemsperpage = (int)FormUtil::getPassedValue('itemsperpage', isset($args['itemsperpage']) ? $args['itemsperpage'] : 25, 'POST');
        if ($itemsperpage < 1) $itemsperpage = 25;
        $this->setVar('itemsperpage', $itemsperpage);

        $cssjscombine = (bool)FormUtil::getPassedValue('cssjscombine', isset($args['cssjscombine']) ? $args['cssjscombine'] : false, 'POST');
        $this->setVar('cssjscombine', $cssjscombine);

        $cssjsminify = (bool)FormUtil::getPassedValue('cssjsminify', isset($args['cssjsminify']) ? $args['cssjsminify'] : false, 'POST');
        $this->setVar('cssjsminify', $cssjsminify);

        $cssjscompress = (bool)FormUtil::getPassedValue('cssjscompress', isset($args['cssjscompress']) ? $args['cssjscompress'] : false, 'POST');
        $this->setVar('cssjscompress', $cssjscompress);

        $cssjscombine_lifetime = (int)FormUtil::getPassedValue('cssjscombine_lifetime', isset($args['cssjscombine_lifetime']) ? $args['cssjscombine_lifetime'] : 3600, 'POST');
        if ($cssjscombine_lifetime < -1) $cssjscombine_lifetime = 3600;
        $this->setVar('cssjscombine_lifetime', $cssjscombine_lifetime);


        // render
        $render_compile_check = (bool)FormUtil::getPassedValue('render_compile_check', isset($args['render_compile_check']) ? $args['render_compile_check'] : false, 'POST');
        $this->setVar('render_compile_check', $render_compile_check);

        $render_force_compile = (bool)FormUtil::getPassedValue('render_force_compile', isset($args['render_force_compile']) ? $args['render_force_compile'] : false, 'POST');
        $this->setVar('render_force_compile', $render_force_compile);

        $render_cache = (int)FormUtil::getPassedValue('render_cache', isset($args['render_cache']) ? $args['render_cache'] : false, 'POST');
        $this->setVar('render_cache', $render_cache);

        $render_lifetime = (int)FormUtil::getPassedValue('render_lifetime', isset($args['render_lifetime']) ? $args['render_lifetime'] : 3600, 'POST');
        if ($render_lifetime < -1) $render_lifetime = 3600;
        $this->setVar('render_lifetime', $render_lifetime);

        $render_expose_template = (bool)FormUtil::getPassedValue('render_expose_template', isset($args['render_expose_template']) ? $args['render_expose_template'] : false, 'POST');
        $this->setVar('render_expose_template', $render_expose_template);

        // The configuration has been changed, so we clear all caches for this module.
        $this->view->clear_compiled();
        $this->view->clear_all_cache();

        // the module configuration has been updated successfuly
        LogUtil::registerStatus($this->__('Done! Saved module configuration.'));

        $this->redirect(ModUtil::url('Theme', 'admin', 'modifyconfig'));
    }
Ejemplo n.º 5
0
    /**
     * update ML settings
     *
     * @return mixed true if successful, false if unsuccessful, error string otherwise
     */
    public function updatemultilingual()
    {
        $this->checkCsrfToken();

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

        $url = ModUtil::url('Settings', 'admin', 'multilingual');

        $settings = array('mlsettings_language_i18n' => 'language_i18n',
                'mlsettings_timezone_offset' => 'timezone_offset',
                'mlsettings_timezone_server' => 'timezone_server',
                'mlsettings_multilingual' => 'multilingual',
                'mlsettings_language_detect' => 'language_detect',
                'mlsettings_languageurl' => 'languageurl');

        // we can't detect language if multilingual feature is off so reset this to false
        if (FormUtil::getPassedValue('mlsettings_multilingual', null, 'POST') == 0) {
            if (System::getVar('language_detect')) {
                System::setVar('language_detect', 0);
                unset($settings['mlsettings_language_detect']);
                LogUtil::registerStatus($this->__('Notice: Language detection is automatically disabled when multi-lingual features are disabled.'));
            }

            $deleteLangUrl = true;
        }

        if (isset($deleteLangUrl)) {
            // reset language settings
            SessionUtil::delVar('language');
            $url = preg_replace('#(.*)(&lang=[a-z-]{2,5})(.*)#i', '$1$3', $url);
        }

        // Write the vars
        $configvars = ModUtil::getVar(ModUtil::CONFIG_MODULE);
        foreach ($settings as $formname => $varname) {
            $newvalue = FormUtil::getPassedValue($formname, null, 'POST');
            $oldvalue = System::getVar($varname);
            if ($newvalue != $oldvalue) {
                System::setVar($varname, $newvalue);
            }
        }

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

        // all done successfully
        LogUtil::registerStatus($this->__('Done! Saved localisation settings.'));

        $this->redirect($url);
    }
Ejemplo n.º 6
0
function installmodules($lang = 'en')
{
    // This is a temporary hack for release 1.3.x to be able to install modules
    // load DoctrineExtensions plugin
    include_once __DIR__ . '/../plugins/DoctrineExtensions/Plugin.php';
    PluginUtil::loadPlugin('SystemPlugin_DoctrineExtensions_Plugin');
    // Lang validation
    $lang = DataUtil::formatForOS($lang);
    // create a result set
    $results = array();
    $sm = ServiceUtil::getManager();
    $coremodules = array('Extensions', 'Settings', 'Theme', 'Admin', 'Permissions', 'Groups', 'Blocks', 'Users');
    // manually install the modules module
    foreach ($coremodules as $coremodule) {
        $modpath = 'system';
        ZLoader::addModule($coremodule, $modpath);
        $bootstrap = __DIR__ . "/../{$modpath}/{$coremodule}/bootstrap.php";
        if (file_exists($bootstrap)) {
            include_once $bootstrap;
        }
        ModUtil::dbInfoLoad($coremodule, $coremodule);
        $className = "{$coremodule}_Installer";
        $instance = new $className($sm);
        if ($instance->install()) {
            $results[$coremodule] = true;
        }
    }
    // regenerate modules list
    $filemodules = ModUtil::apiFunc('ExtensionsModule', 'admin', 'getfilemodules');
    ModUtil::apiFunc('ExtensionsModule', 'admin', 'regenerate', array('filemodules' => $filemodules));
    // set each of the core modules to active
    reset($coremodules);
    foreach ($coremodules as $coremodule) {
        $mid = ModUtil::getIdFromName($coremodule, true);
        ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $mid, 'state' => ModUtil::STATE_INACTIVE));
        ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $mid, 'state' => ModUtil::STATE_ACTIVE));
    }
    // Add them to the appropriate category
    reset($coremodules);
    $coremodscat = array('Extensions' => __('System'), 'Permissions' => __('Users'), 'Groups' => __('Users'), 'Blocks' => __('Layout'), 'Users' => __('Users'), 'Theme' => __('Layout'), 'Admin' => __('System'), 'Settings' => __('System'));
    $categories = ModUtil::apiFunc('AdminModule', 'admin', 'getall');
    $modscat = array();
    foreach ($categories as $category) {
        $modscat[$category['name']] = $category['cid'];
    }
    foreach ($coremodules as $coremodule) {
        $category = $coremodscat[$coremodule];
        ModUtil::apiFunc('AdminModule', 'admin', 'addmodtocategory', array('module' => $coremodule, 'category' => $modscat[$category]));
    }
    // create the default blocks.
    $blockInstance = new Blocks_Installer($sm);
    $blockInstance->defaultdata();
    // install all the basic modules
    $modules = array(array('module' => 'SecurityCenter', 'category' => __('Security')), array('module' => 'Tour', 'category' => __('Content')), array('module' => 'Categories', 'category' => __('Content')), array('module' => 'Legal', 'category' => __('Content')), array('module' => 'Mailer', 'category' => __('System')), array('module' => 'Errors', 'category' => __('System')), array('module' => 'Theme', 'category' => __('Layout')), array('module' => 'Search', 'category' => __('Content')));
    foreach ($modules as $module) {
        // sanity check - check if module is already installed
        if (ModUtil::available($module['module'])) {
            continue;
        }
        $modpath = 'modules';
        //        ZLoader::addModule($module, $modpath);
        ZLoader::addAutoloader($module, "{$modpath}");
        $bootstrap = __DIR__ . "/../{$modpath}/{$module}/bootstrap.php";
        if (file_exists($bootstrap)) {
            include_once $bootstrap;
        }
        ZLanguage::bindModuleDomain($module);
        $results[$module['module']] = false;
        // #6048 - prevent trying to install modules which are contained in an install type, but are not available physically
        if (!file_exists('system/' . $module['module'] . '/') && !file_exists('modules/' . $module['module'] . '/')) {
            continue;
        }
        $mid = ModUtil::getIdFromName($module['module']);
        // init it
        if (ModUtil::apiFunc('ExtensionsModule', 'admin', 'initialise', array('id' => $mid)) == true) {
            // activate it
            if (ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $mid, 'state' => ModUtil::STATE_ACTIVE))) {
                $results[$module['module']] = true;
            }
            // Set category
            ModUtil::apiFunc('AdminModule', 'admin', 'addmodtocategory', array('module' => $module['module'], 'category' => $modscat[$module['category']]));
        }
    }
    System::setVar('language_i18n', $lang);
    return $results;
}
Ejemplo n.º 7
0
    /**
     * Upgrade the settings module from an old version.
     *
     * This function must consider all the released versions of the module!
     * If the upgrade fails at some point, it returns the last upgraded version.
     *
     * @param string $oldVersion version number string to upgrade from.
     *
     * @return boolean|string True on success, last valid version string or false if fails.
     */
    public function upgrade($oldversion)
    {
        // always ensure that the version info is upgraded
        System::setVar('Version_Num', Zikula_Core::VERSION_NUM);
        System::setVar('Version_ID', Zikula_Core::VERSION_ID);
        System::setVar('Version_Sub', Zikula_Core::VERSION_SUB);

        // Upgrade dependent on old version number
        switch ($oldversion) {
            case '2.5':
                System::delVar('jsquicktags');
                System::delVar('backend_title');
                System::delVar('refereronprint');
                System::delVar('storyorder');
                System::delVar('backend_language');
                System::delVar('site_logo');

            case '2.6':
                System::setVar('updatelastchecked', 0);
                System::setVar('updatefrequency', 7);
                System::setVar('updatecheck', true);

            case '2.7':
                System::setVar('language_i18n', 'en');
                System::setVar('language_bc', 1);
                System::setVar('languageurl', 0);
                System::setVar('ajaxtimeout', 5000);
                //! this is a comma-separated list of special characters to search for in permalinks
                System::setVar('permasearch',  $this->$this->__('À,Á,Â,Ã,Å,à,á,â,ã,å,Ò,Ó,Ô,Õ,Ø,ò,ó,ô,õ,ø,È,É,Ê,Ë,è,é,ê,ë,Ç,ç,Ì,Í,Î,Ï,ì,í,î,ï,Ù,Ú,Û,ù,ú,û,ÿ,Ñ,ñ,ß,ä,Ä,ö,Ö,ü,Ü'));
                //! this is a comma-separated list of special characters to replace in permalinks
                System::setVar('permareplace', $this->$this->__('A,A,A,A,A,a,a,a,a,a,O,O,O,O,O,o,o,o,o,o,E,E,E,E,e,e,e,e,C,c,I,I,I,I,i,i,i,i,U,U,U,u,u,u,y,N,n,ss,ae,Ae,oe,Oe,ue,Ue'));

            case '2.8':
                System::delVar('dyn_keywords');
            case '2.9':
            case '2.9.1':
                System::delVar('timezone_info');
            case '2.9.2':
                $tables = DBUtil::getTables();
                $modulesTable = $tables['modules'];
                $name = $tables['modules_column']['name'];
                $sql = "DELETE FROM $modulesTable WHERE $name = 'ObjectData' OR $name = 'Workflow'";
                DBUtil::executeSQL($sql);
            case '2.9.3':
                // This may have been set by the Users module upgrade already, so only set it if it does not exist.
                $systemIdnSetting = System::getVar('idnnames', null);
                if (isset($systemIdnSetting)) {
                    if (ModUtil::available('Users')) {
                        $usersIdnSetting = ModUtil::getVar('Users', 'idnnames', null);
                    }
                    System::setVar('idnnames', isset($usersIdnSetting) ? (bool)$usersIdnSetting : true);
                }
                System::delVar('language_bc');
            case '2.9.4':
                System::setVar('defaultpagetitle', $this->__('Site name'));
                System::setVar('defaultmetadescription', $this->__('Site description'));
            case '2.9.5':
                System::delVar('shorturlsext');
            case '2.9.6':
                DBUtil::changeTable('objectdata_attributes');
                // future upgrade routines
        }

        // Update successful
        return true;
    }
Ejemplo n.º 8
0
/**
 * set a configuration variable
 *
 * @deprecated Deprecated since version 1.3.0.
 * @see System::setVar()
 *
 * @param name $ the name of the variable
 * @param value $ the value of the variable
 * @return bool true on success, false on failure
 */
function pnConfigSetVar($name, $value = '')
{
    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'System::setVar')), E_USER_DEPRECATED);
    return System::setVar($name, $value);
}
Ejemplo n.º 9
0
 private function finalizeParameters()
 {
     \ModUtil::initCoreVars(true);
     // initialize the modvars array (includes ZConfig (System) vars)
     // Set the System Identifier as a unique string.
     if (!\System::getVar('system_identifier')) {
         \System::setVar('system_identifier', str_replace('.', '', uniqid(rand(1000000000, 9999999999), true)));
     }
     // store the recent version in a config var for later usage. This enables us to determine the version we are upgrading from
     \System::setVar('Version_Num', \Zikula_Core::VERSION_NUM);
     \System::setVar('language_i18n', \ZLanguage::getLanguageCode());
     // add new configuration parameters
     $params = $this->yamlManager->getParameters();
     unset($params['username'], $params['password']);
     if (!isset($params['secret']) || $params['secret'] == 'ThisTokenIsNotSoSecretChangeIt') {
         $params['secret'] = \RandomUtil::getRandomString(50);
     }
     if (!isset($params['url_secret'])) {
         $params['url_secret'] = \RandomUtil::getRandomString(10);
     }
     // Configure the Request Context
     // see http://symfony.com/doc/current/cookbook/console/sending_emails.html#configuring-the-request-context-globally
     $params['router.request_context.host'] = isset($params['router.request_context.host']) ? $params['router.request_context.host'] : $this->container->get('request')->getHost();
     $params['router.request_context.scheme'] = isset($params['router.request_context.scheme']) ? $params['router.request_context.scheme'] : 'http';
     $params['router.request_context.base_url'] = isset($params['router.request_context.base_url']) ? $params['router.request_context.base_url'] : $this->container->get('request')->getBasePath();
     $this->yamlManager->setParameters($params);
     return true;
 }
Ejemplo n.º 10
0
 /**
  * Upgrade all modules.
  *
  * @return array An array of upgrade results, indexed by module name.
  */
 public function upgradeall()
 {
     $upgradeResults = array();
     $usersModule = array();
     // regenerate modules list
     $filemodules = $this->getfilemodules();
     $this->regenerate(array('filemodules' => $filemodules));
     // get a list of modules needing upgrading
     if ($this->listmodules(array('state' => ModUtil::STATE_UPGRADED))) {
         $newmods = $this->listmodules(array('state' => ModUtil::STATE_UPGRADED));
         // Sort upgrade order according to this list.
         $priorities = array('Extensions', 'Users', 'Groups', 'Permissions', 'Admin', 'Blocks', 'Theme', 'Settings', 'Categories', 'SecurityCenter', 'Errors');
         $sortedList = array();
         foreach ($priorities as $priority) {
             foreach ($newmods as $key => $modinfo) {
                 if ($modinfo['name'] == $priority) {
                     $sortedList[] = $modinfo;
                     unset($newmods[$key]);
                 }
             }
         }
         $newmods = array_merge($sortedList, $newmods);
         foreach ($newmods as $mod) {
             $upgradeResults[$mod['name']] = $this->upgrade(array('id' => $mod['id']));
         }
         System::setVar('Version_Num', Zikula_Core::VERSION_NUM);
     }
     return $upgradeResults;
 }
Ejemplo n.º 11
0
    /**
     * Update allowed html settings.
     *
     * @return mixed true if successful, false if unsuccessful, error string otherwise.
     */
    public function updateallowedhtml($args)
    {
        $this->checkCsrfToken();

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

        // update the allowed html settings
        $allowedhtml = array();
        $htmltags = $this->_gethtmltags();
        foreach ($htmltags as $htmltag => $usagetag) {
            $tagval = (int)FormUtil::getPassedValue('htmlallow' . $htmltag . 'tag', 0, 'POST');
            if (($tagval != 1) && ($tagval != 2)) {
                $tagval = 0;
            }
            $allowedhtml[$htmltag] = $tagval;
        }

        System::setVar('AllowableHTML', $allowedhtml);

        // one additonal config var is set on this page
        $htmlentities = FormUtil::getPassedValue('xhtmlentities', 0, 'POST');
        System::setVar('htmlentities', $htmlentities);

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

        // all done successfully
        LogUtil::registerStatus($this->__('Done! Saved module configuration.'));

        $this->redirect(ModUtil::url('SecurityCenter', 'admin', 'allowedhtml'));
    }
Ejemplo n.º 12
0
    /**
     * set default site theme
     *
     * optionally reset user theme selections
     */
    public function setasdefault($args)
    {
        // Security check
        if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // Check our input arguments
        if (!isset($args['themename'])) {
            return LogUtil::registerArgsError();
        }
        if (!isset($args['resetuserselected'])) {
            $args['resetuserselected'] = false;
        }

        // if chosen reset all user theme selections
        if ($args['resetuserselected']) {
            $dbtables = DBUtil::getTables();
            $sql ="UPDATE $dbtables[users] SET theme = ''";
            if (!DBUtil::executeSQL($sql)) {
                return false;
            }
        }

        // change default theme
        if (!System::setVar('Default_Theme', $args['themename'])) {
            return false;
        }

        return true;
    }
Ejemplo n.º 13
0
 private function finalizeParameters()
 {
     \ModUtil::initCoreVars(true);
     // initialize the modvars array (includes ZConfig (System) vars)
     $params = $this->decodeParameters($this->yamlManager->getParameters());
     \System::setVar('language_i18n', $params['locale']);
     // Set the System Identifier as a unique string.
     \System::setVar('system_identifier', str_replace('.', '', uniqid(rand(1000000000, 9999999999.0), true)));
     // add admin email as site email
     \System::setVar('adminmail', $params['email']);
     // regenerate the theme list
     \Zikula\Module\ThemeModule\Util::regenerate();
     // add remaining parameters and remove unneeded ones
     unset($params['username'], $params['password'], $params['email'], $params['dbtabletype']);
     $params['datadir'] = !empty($params['datadir']) ? $params['datadir'] : 'userdir';
     $params['secret'] = \RandomUtil::getRandomString(50);
     $params['url_secret'] = \RandomUtil::getRandomString(10);
     // Configure the Request Context
     // see http://symfony.com/doc/current/cookbook/console/sending_emails.html#configuring-the-request-context-globally
     $params['router.request_context.host'] = isset($params['router.request_context.host']) ? $params['router.request_context.host'] : $this->container->get('request')->getHost();
     $params['router.request_context.scheme'] = isset($params['router.request_context.scheme']) ? $params['router.request_context.scheme'] : 'http';
     $params['router.request_context.base_url'] = isset($params['router.request_context.base_url']) ? $params['router.request_context.base_url'] : $this->container->get('request')->getBasePath();
     $this->yamlManager->setParameters($params);
     // clear the cache
     $this->container->get('zikula.cache_clearer')->clear('symfony.config');
     return true;
 }
Ejemplo n.º 14
0
/**
 * Generate the sanity check page.
 *
 * This function do and generate the stanity check page.
 *
 * @param string $username Username of the admin user.
 * @param string $password Password of the admin user.
 *
 * @return void
 */
function _upg_sanity_check($username, $password)
{
    _upg_header();
    $validupgrade = true;
    if (version_compare(_ZINSTALLEDVERSION, _ZINSTALLVER, '=')) {
        // Already installed the correct version
        $validupgrade = false;
        echo '<h2>' . __('Already up to date') . "</h2>\n";
        echo '<p class="z-errormsg">' . __f("It seems that you have already installed version %s. Please remove this upgrade script, you do not need it anymore.", _ZINSTALLEDVERSION) . "</p>\n";
    } elseif (version_compare(_ZINSTALLEDVERSION, _Z_MINUPGVER, '<')) {
        // Not on version _Z_MINUPGVER yet
        $validupgrade = false;
        echo '<h2>' . __('Possible incompatible version found.') . "</h2>\n";
        echo '<p class="z-warningmsg">' . __f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', array(_ZINSTALLEDVERSION, _Z_MINUPGVER)) . "</p>\n";
    } elseif (version_compare(PHP_VERSION, '5.3.0', '>=')) {
        if (ini_get('date.timezone') == '') {
            echo '<p class="z-errormsg"><strong>' . __('date.timezone is currently not set. Since PHP 5.3.0, it needs to be set to a valid timezone in your php.ini such as timezone like UTC, GMT+5, Europe/Berlin.') . "</strong></p>\n";
            echo _upg_continue('sanitycheck', __('Check again'), $username, $password);
            $validupgrade = false;
        }
    }
    if ($validupgrade) {
        $pcreUnicodePropertiesEnabled = @preg_match('/^\\p{L}+$/u', 'TheseAreLetters');
        if (!isset($pcreUnicodePropertiesEnabled) || !$pcreUnicodePropertiesEnabled) {
            // PCRE Unicode property support is not enabled.
            $validupgrade = false;
            echo '<h2>' . __('PCRE Unicode Property Support Needed.') . "</h2>\n";
            echo '<p class="z-errormsg">' . __('The PCRE (Perl Compatible Regular Expression) library being used with your PHP installation does not support Unicode properties. This is required to handle multi-byte character sets in regular expressions. The PCRE library used must be compiled with the \'--enable-unicode-properties\' option.') . "</p>\n";
        }
    }
    if ($validupgrade) {
        $defaultTheme = System::getVar('Default_Theme');
        if ($defaultTheme == 'andreas08') {
            System::setVar('Default_Theme', 'Andreas08');
            $defaultTheme = System::getVar('Default_Theme');
        }
        $dir = is_dir("themes/{$defaultTheme}");
        $casing = preg_match('/\\p{Lu}/u', substr($defaultTheme, 0, 1));
        // first letter is uppercase.
        $underscore = preg_match('/_/', $defaultTheme);
        // has underscore
        if (!$dir || !$casing || $underscore) {
            // The default theme must be installed!
            $validupgrade = false;
            echo '<h2>' . __f("Theme Check Failed", $defaultTheme) . "</h2>\n";
            if (!$dir) {
                echo '<p class="z-errormsg">' . __f("Your configuration specifies a theme called '%s' that doesn't exist.  Please ensure that theme exists in themes/%s", array($defaultTheme, $defaultTheme)) . "</p>\n";
            }
            if (!$casing) {
                echo '<p class="z-errormsg">' . __f("Your configuration specifies a theme called '%s' which begins with a lower case letter.  You must first upgrade the theme's name to start with a capital letter.  This should be done in your 1.2.x installation before attempting this upgrade again.", array($defaultTheme, $defaultTheme)) . "</p>\n";
            }
            if ($underscore) {
                echo '<p class="z-errormsg">' . __f("Your theme called '%s' contains an underscore, this is now deprecated.  You must first upgrade the theme's name so it does not contain any underscore character.  This should be done in your 1.2.x installation before attempting this upgrade again.", array($defaultTheme, $defaultTheme)) . "</p>\n";
            }
        }
    }
    if (!$validupgrade) {
        _upg_footer();
        System::shutdown();
    }
    _upg_continue('upgrademodules', __('Proceed to upgrade (click once and wait)'), $username, $password);
    _upg_footer();
}
Ejemplo n.º 15
0
    /**
     * Upgrade the users module from an older version.
     *
     * This function must consider all the released versions of the module!
     * If the upgrade fails at some point, it returns the last upgraded 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)
    {
        // $oldversion 1.9 and 1.10 handled by Zikula 1.2.
        if (version_compare($oldVersion, '1.11') === -1) {
            return $oldVersion;
        }
        // Versions 1.14 through 2.1.0 were development versions that were released only to developers, and many changes
        // over the course of those versions regarding database structure were radically modified. Upgrading from any of
        // those versions is not possible.
        if ((version_compare($oldVersion, '1.13') === 1) && (version_compare($oldVersion, '2.2.0') === -1)) {
            return $oldVersion;
        }

        // Upgrade dependent on old version number
        switch ($oldVersion) {
            case '1.11':
                // upgrade 1.11 to 1.12
                $this->upgrade_migrateSerialisedUserTemp();
            case '1.12':
                // upgrade 1.12 to 1.13

                // Do modvar renames and moves here, but new modvars and modvar removals are done below for all versions
                $this->setVar(Users_Constant::MODVAR_AVATAR_IMAGE_PATH, Users_Constant::MODVAR_AVATAR_IMAGE_PATH);
                // lowercaseuname Removed in 2.0.0
                //$this->setVar('lowercaseuname', 1);

                // **************************************************************
                // 1.12->1.13 is the last known upgrade of Users for Zikula 1.2.x
                // Users module 1.13 is the last known 1.2.x version released.
                // If the 1.2.x branch gets a new version, this must be updated.
                // **************************************************************
            case '1.13':
                // upgrade 1.13 to 2.2.0

                // Do modvar renames and moves here, but new modvars and modvar removals are done below for all versions

                // Check if the hash method is md5. If so, it is not used any more. Change it to the new default.
                if ($this->getVar(Users_Constant::MODVAR_HASH_METHOD, false) == 'md5') {
                    $this->setVar(Users_Constant::MODVAR_HASH_METHOD, Users_Constant::DEFAULT_HASH_METHOD);
                }

                // Convert the banned user names to a comma separated list.
                $bannedUnames = $this->getVar(Users_Constant::MODVAR_REGISTRATION_ILLEGAL_UNAMES, '');
                $bannedUnames = preg_split('/\s+/', $bannedUnames);
                $bannedUnames = implode(', ', $bannedUnames);
                $this->setVar(Users_Constant::MODVAR_REGISTRATION_ILLEGAL_UNAMES, $bannedUnames);

                // System-generated passwords are deprecated since 1.3.0. Change it to
                // User-generated passwords.
                $regVerifyEmail = $this->getVar(Users_Constant::MODVAR_REGISTRATION_VERIFICATION_MODE, Users_Constant::VERIFY_NO);
                if ($regVerifyEmail == Users_Constant::VERIFY_SYSTEMPWD) {
                    $this->setVar(Users_Constant::MODVAR_REGISTRATION_VERIFICATION_MODE, Users_Constant::VERIFY_USERPWD);
                }

                // IDN domains setting moving to system settings.
                System::setVar('idnnames', (bool)$this->getVar('idnnames', true));

                // Minimum age is moving to Legal
                ModUtil::setVar('Legal', 'minimumAge', $this->getVar('minage', 0));

                if (!$this->upgrade113XTablesTo220Tables($oldVersion)) {
                    return '1.13';
                }

                EventUtil::registerPersistentModuleHandler($this->name, 'get.pending_content', array('Users_Listener_PendingContent', 'pendingContentListener'));
                EventUtil::registerPersistentModuleHandler($this->name, 'user.login.veto', array('Users_Listener_ForcedPasswordChange', 'forcedPasswordChangeListener'));
                EventUtil::registerPersistentModuleHandler($this->name, 'user.logout.succeeded', array('Users_Listener_ClearUsersNamespace', 'clearUsersNamespaceListener'));
                EventUtil::registerPersistentModuleHandler($this->name, 'frontcontroller.exception', array('Users_Listener_ClearUsersNamespace', 'clearUsersNamespaceListener'));
                HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
                HookUtil::registerProviderBundles($this->version->getHookProviderBundles());
            case '2.2.0':
                // This s the current version: add 2.2.0 --> next when appropriate
        }

        $currentModVars = $this->getVars();
        $defaultModVars = $this->getDefaultModvars();

        // Remove modvars that are no longer defined.
        foreach ($currentModVars as $modVar => $currentValue) {
            if (!array_key_exists($modVar, $defaultModVars)) {
                $this->delVar($modVar);
            }
        }

        // Add modvars that are new to the version
        foreach ($defaultModVars as $modVar => $defaultValue) {
            if (!array_key_exists($modVar, $currentModVars)) {
                $this->setVar($modVar, $defaultValue);
            }
        }

        // Update successful
        return true;
    }
Ejemplo n.º 16
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;
 }
Ejemplo n.º 17
0
 /**
  * fix core start page settings if set to News
  * @return boolean
  */
 private function fixStartSettings()
 {
     if ((System::getVar('startpage') == 'News') && (System::getVar('entrypoint') == 'index.php')) {
         $starttype = System::getVar('starttype', '');
         if (empty($starttype)) {
             System::setVar('starttype', 'user');
         }
         $startfunc = System::getVar('startfunc', '');
         if (empty($startfunc) || ($startfunc == 'main')) {
             System::setVar('startfunc', 'view');
         }
         $startargs = System::getVar('startargs', '');
         if (empty($startargs)) {
             System::setVar('startargs', 'displayonindex=1');
         }
     }
     return true;
 }