private function build_form() { $form = new HTMLForm(__CLASS__); $fieldset = new FormFieldsetHTML('advanced-config', $this->lang['advanced-config']); $form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldUrlEditor('site_url', $this->lang['advanced-config.site_url'], $this->general_config->get_site_url(), array('description' => $this->lang['advanced-config.site_url-explain'], 'required' => true))); $fieldset->add_field(new FormFieldTextEditor('site_path', $this->lang['advanced-config.site_path'], $this->general_config->get_site_path(), array('description' => $this->lang['advanced-config.site_path-explain']))); $fieldset->add_field(new FormFieldTimezone('site_timezone', $this->lang['advanced-config.site_timezone'], $this->general_config->get_site_timezone(), array('description' => $this->lang['advanced-config.site_timezone-explain']))); $url_rewriting_fieldset = new FormFieldsetHTML('url_rewriting', $this->lang['advanced-config.url-rewriting']); $form->add_fieldset($url_rewriting_fieldset); $url_rewriting_fieldset->set_description($this->lang['advanced-config.url-rewriting.explain']); $server_configuration = new ServerConfiguration(); try { if ($server_configuration->has_url_rewriting()) { $url_rewriting_fieldset->add_field(new FormFieldCheckbox('url_rewriting_enabled', $this->lang['advanced-config.url-rewriting'], $this->server_environment_config->is_url_rewriting_enabled(), array('description' => '<span class="text-strong color-available">' . $this->lang['advanced-config.config.available'] . '</span>'))); } else { $url_rewriting_fieldset->add_field(new FormFieldCheckbox('url_rewriting_enabled', $this->lang['advanced-config.url-rewriting'], FormFieldCheckbox::UNCHECKED, array('disabled' => true, 'description' => '<span class="text-strong color-notavailable">' . $this->lang['advanced-config.config.not-available'] . '</span>'))); } } catch (UnsupportedOperationException $ex) { $url_rewriting_fieldset->add_field(new FormFieldCheckbox('url_rewriting_enabled', $this->lang['advanced-config.url-rewriting'], $this->server_environment_config->is_url_rewriting_enabled(), array('description' => '<span class="text-strong color-unknown">' . $this->lang['advanced-config.config.unknown'] . '</span>'))); } $htaccess_manual_content_fieldset = new FormFieldsetHTML('htaccess_manual_content', $this->lang['advanced-config.htaccess-manual-content']); $form->add_fieldset($htaccess_manual_content_fieldset); $htaccess_manual_content_fieldset->add_field(new FormFieldMultiLineTextEditor('htaccess_manual_content', $this->lang['advanced-config.htaccess-manual-content'], $this->server_environment_config->get_htaccess_manual_content(), array('rows' => 7, 'description' => $this->lang['advanced-config.htaccess-manual-content.explain']))); $robots_file = new File(PATH_TO_ROOT . '/robots.txt'); $robots_content = $robots_file->exists() ? $robots_file->read() : ''; $robots_content_fieldset = new FormFieldsetHTML('robots_content', $this->lang['advanced-config.robots-content']); $form->add_fieldset($robots_content_fieldset); $robots_content_fieldset->add_field(new FormFieldMultiLineTextEditor('robots_content', $this->lang['advanced-config.robots-content'], $robots_content, array('rows' => 7, 'description' => $this->lang['advanced-config.robots-content.explain']))); $sessions_config_fieldset = new FormFieldsetHTML('sessions_config', $this->lang['advanced-config.sessions-config']); $form->add_fieldset($sessions_config_fieldset); $sessions_config_fieldset->add_field(new FormFieldTextEditor('cookie_name', $this->lang['advanced-config.cookie-name'], $this->sessions_config->get_cookie_name(), array('required' => true), array(new FormFieldConstraintRegex('`^[A-Za-z0-9]+$`i', '', $this->lang['advanced-config.cookie-name.style-wrong'])))); $sessions_config_fieldset->add_field(new FormFieldNumberEditor('session_duration', $this->lang['advanced-config.cookie-duration'], $this->sessions_config->get_session_duration(), array('description' => $this->lang['advanced-config.cookie-duration.explain'], 'required' => true), array(new FormFieldConstraintRegex('`^[0-9]+$`i', '', $this->lang['advanced-config.integer-required'])))); $sessions_config_fieldset->add_field(new FormFieldNumberEditor('active_session_duration', $this->lang['advanced-config.active-session-duration'], $this->sessions_config->get_active_session_duration(), array('description' => $this->lang['advanced-config.active-session-duration.explain'], 'required' => true), array(new FormFieldConstraintRegex('`^[0-9]+$`i', '', $this->lang['advanced-config.integer-required'])))); $miscellaneous_fieldset = new FormFieldsetHTML('miscellaneous', $this->lang['advanced-config.miscellaneous']); $form->add_fieldset($miscellaneous_fieldset); if (function_exists('ob_gzhandler') && @extension_loaded('zlib')) { $miscellaneous_fieldset->add_field(new FormFieldCheckbox('output_gziping_enabled', $this->lang['advanced-config.output-gziping-enabled'], $this->server_environment_config->is_output_gziping_enabled(), array('description' => '<span class="text-strong color-available">' . $this->lang['advanced-config.config.available'] . '</span>'))); } else { $miscellaneous_fieldset->add_field(new FormFieldCheckbox('output_gziping_enabled', $this->lang['advanced-config.output-gziping-enabled'], FormFieldCheckbox::UNCHECKED, array('description' => '<span class="text-strong color-notavailable">' . $this->lang['advanced-config.config.not-available'] . '</span>', 'disabled' => true))); } $miscellaneous_fieldset->add_field(new FormFieldCheckbox('debug_mode_enabled', $this->lang['advanced-config.debug-mode'], Debug::is_debug_mode_enabled(), array('description' => $this->lang['advanced-config.debug-mode.explain'], 'events' => array('change' => ' if (HTMLForms.getField("debug_mode_enabled").getValue()) { HTMLForms.getField("debug_mode_type").enable(); HTMLForms.getField("display_database_query_enabled").enable(); } else { HTMLForms.getField("debug_mode_type").disable(); HTMLForms.getField("display_database_query_enabled").disable(); }')))); $miscellaneous_fieldset->add_field(new FormFieldSimpleSelectChoice('debug_mode_type', $this->lang['advanced-config.debug-mode.type'], Debug::is_strict_mode_enabled(), array(new FormFieldSelectChoiceOption($this->lang['advanced-config.debug-mode.type.normal'], '0'), new FormFieldSelectChoiceOption($this->lang['advanced-config.debug-mode.type.strict'], '1')), array('hidden' => !Debug::is_debug_mode_enabled()))); $miscellaneous_fieldset->add_field(new FormFieldCheckbox('display_database_query_enabled', $this->lang['advanced-config.debug-display-database-query-enabled'], Debug::is_display_database_query_enabled(), array('hidden' => !Debug::is_debug_mode_enabled()))); $this->submit_button = new FormButtonDefaultSubmit(); $form->add_button($this->submit_button); $form->add_button(new FormButtonReset()); $this->form = $form; }
public function run() { DB::table('server_configuration')->delete(); ServerConfiguration::create(array('key' => 'Private.Association.Lifetime', 'value' => '240')); ServerConfiguration::create(array('key' => 'Session.Association.Lifetime', 'value' => '21600')); ServerConfiguration::create(array('key' => 'MaxFailed.Login.Attempts', 'value' => '10')); ServerConfiguration::create(array('key' => 'MaxFailed.LoginAttempts.2ShowCaptcha', 'value' => '3')); ServerConfiguration::create(array('key' => 'Nonce.Lifetime', 'value' => '360')); ServerConfiguration::create(array('key' => 'Assets.Url', 'value' => 'http://www.openstack.org/')); //blacklist policy config values ServerConfiguration::create(array('key' => 'BannedIpLifeTimeSeconds', 'value' => '21600')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.MinutesWithoutExceptions', 'value' => '5')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.ReplayAttackExceptionInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.MaxInvalidNonceAttempts', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.InvalidNonceInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.MaxInvalidOpenIdMessageExceptionAttempts', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.InvalidOpenIdMessageExceptionInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.MaxOpenIdInvalidRealmExceptionAttempts', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.OpenIdInvalidRealmExceptionInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.MaxInvalidOpenIdMessageModeAttempts', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.InvalidOpenIdMessageModeInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.MaxInvalidOpenIdAuthenticationRequestModeAttempts', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.InvalidOpenIdAuthenticationRequestModeInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.MaxAuthenticationExceptionAttempts', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.AuthenticationExceptionInitialDelay', 'value' => '20')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.OAuth2.MaxAuthCodeReplayAttackAttempts', 'value' => '3')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.OAuth2.AuthCodeReplayAttackInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.OAuth2.MaxInvalidAuthorizationCodeAttempts', 'value' => '3')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.OAuth2.InvalidAuthorizationCodeInitialDelay', 'value' => '10')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.OAuth2.MaxInvalidBearerTokenDisclosureAttempt', 'value' => '3')); ServerConfiguration::create(array('key' => 'BlacklistSecurityPolicy.OAuth2.BearerTokenDisclosureAttemptInitialDelay', 'value' => '10')); }
private function build_view() { $this->view = new FileTemplate('update/server-config.tpl'); $this->view->put_all(array('MIN_PHP_VERSION' => ServerConfiguration::MIN_PHP_VERSION, 'PHP_VERSION_OK' => $this->server_conf->is_php_compatible(), 'HAS_GD_LIBRARY' => $this->server_conf->has_gd_library())); if (!PHPBoostFoldersPermissions::validate()) { $this->view->put('ERROR', $this->lang['folders.chmod.error']); } try { $this->view->put('URL_REWRITING_KNOWN', true); $this->view->put('URL_REWRITING_AVAILABLE', $this->server_conf->has_url_rewriting()); } catch (UnsupportedOperationException $ex) { $this->view->put('URL_REWRITING_KNOWN', false); } $this->check_folders_permissions(); $this->view->put('CONTINUE_FORM', $this->form->display()); }
private function chech_php_version() { CLIOutput::writeln("\t" . 'php version'); if (!$this->server_configuration->is_php_compatible()) { CLIOutput::writeln('PHP version (' . ServerConfiguration::get_phpversion() . ') is not compatible with PHPBoost.'); CLIOutput::writeln('PHP ' . ServerConfiguration::MIN_PHP_VERSION . ' is needed!'); return false; } return true; }
/** * @desc Parses the content of the parser. The result will be ready to be displayed. */ public function parse() { //Balise code if (strpos($this->content, '[[CODE') !== false) { $this->content = preg_replace_callback('`\\[\\[CODE(?:=([A-Za-z0-9#+-]+))?(?:,(0|1)(?:,(0|1))?)?\\]\\](.+)\\[\\[/CODE\\]\\]`sU', array($this, 'callbackhighlight_code'), $this->content); } //Media if (strpos($this->content, '[[MEDIA]]') !== false) { $this->process_media_insertion(); } //Balise latex. if (strpos($this->content, '[[MATH]]') !== false) { $server_config = new ServerConfiguration(); if ($server_config->has_gd_library()) { require_once PATH_TO_ROOT . '/kernel/lib/php/mathpublisher/mathpublisher.php'; $this->content = preg_replace_callback('`\\[\\[MATH\\]\\](.+)\\[\\[/MATH\\]\\]`sU', array($this, 'math_code'), $this->content); } } $this->parse_feed_tag(); $this->content = Url::html_convert_root_relative2absolute($this->content, $this->path_to_root, $this->page_path); }
/** * @desc Check Repository for Update Notification */ private function check_repositories() { if (ServerConfiguration::get_phpversion() > self::PHP_MIN_VERSION_UPDATES) { foreach ($this->apps as $app) { $result = $this->repositories[$app->get_repository()]->check($app); if ($result !== null) { // processing to the update notification $this->add_update_alert($result); } } } }
/** * @static * @desc Installs a module. * @param string $module_identifier Module identifier (name of its folder) * @param bool $enable_module true if you want the module to be enabled, otherwise false. * @return int One of the following error codes: * <ul> * <li>MODULE_INSTALLED: the installation succeded</li> * <li>MODULE_ALREADY_INSTALLED: the module is already installed</li> * <li>UNEXISTING_MODULE: the module you want to install doesn't exist</li> * <li>PHP_VERSION_CONFLICT: the server PHP version is two old to be able to run the module code (config set in the config.ini module file)</li> * <li>CONFIG_CONFLICT: the configuration field is already used</i> * </ul> */ public static function install_module($module_identifier, $enable_module = true, $generate_cache = true) { self::update_class_list(); if (empty($module_identifier) || !is_dir(PATH_TO_ROOT . '/' . $module_identifier)) { return self::UNEXISTING_MODULE; } if (self::is_module_installed($module_identifier)) { return self::MODULE_ALREADY_INSTALLED; } $module = new Module($module_identifier, $enable_module); $configuration = $module->get_configuration(); $phpversion = ServerConfiguration::get_phpversion(); if (version_compare($phpversion, $configuration->get_php_version(), 'lt')) { return self::PHP_VERSION_CONFLICT; } $phpboost_version = GeneralConfig::load()->get_phpboost_major_version(); if (version_compare($phpboost_version, $configuration->get_compatibility(), '>')) { return self::PHPBOOST_VERSION_CONFLICT; } self::execute_module_installation($module_identifier); ModulesConfig::load()->add_module($module); ModulesConfig::save(); // TODO Force initialization ExtensionProviderService for PHPBoost installation AppContext::init_extension_provider_service(); MenuService::add_mini_module($module_identifier, $generate_cache); if ($generate_cache) { MenuService::generate_cache(); if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) { HtaccessFileCache::regenerate(); } } return self::MODULE_INSTALLED; }
public function save_server_environnement_config() { $server_configuration = new ServerConfiguration(); $server_environment_config = ServerEnvironmentConfig::load(); try { if ($server_configuration->has_url_rewriting()) { $server_environment_config->set_url_rewriting_enabled(true); } } catch (UnsupportedOperationException $ex) { $server_environment_config->set_url_rewriting_enabled(false); } if (function_exists('ob_gzhandler') && @extension_loaded('zlib')) { $server_environment_config->set_output_gziping_enabled(true); } if (DataStoreFactory::is_apc_available()) { DataStoreFactory::set_apc_enabled(true); } ServerEnvironmentConfig::save(); }
public static function get_advises(HTMLForm $html_form) { $lang = LangLoader::get('admin-server-common'); $server_configuration = new ServerConfiguration(); $maintenance_config = MaintenanceConfig::load(); $general_config = GeneralConfig::load(); $server_environment_config = ServerEnvironmentConfig::load(); $security_config = SecurityConfig::load(); $url_rewriting_available = false; try { $url_rewriting_available = $server_configuration->has_url_rewriting(); } catch (UnsupportedOperationException $ex) { } $fieldset = new FormFieldsetHTML('advises', $lang['advises']); $fieldset->add_field(new FormFieldFree('modules_management', '', MessageHelper::display($lang['advises.modules_management'], MessageHelper::SUCCESS)->render())); if ($maintenance_config->is_under_maintenance()) { $fieldset->add_field(new FormFieldFree('check_modules_authorizations', '', MessageHelper::display($lang['advises.check_modules_authorizations'], MessageHelper::SUCCESS)->render())); } if (!strstr($general_config->get_site_url(), 'localhost') && !strstr($general_config->get_site_url(), '127.0.0.1') && !$maintenance_config->is_under_maintenance() && Debug::is_debug_mode_enabled()) { $fieldset->add_field(new FormFieldFree('disable_debug_mode', '', MessageHelper::display($lang['advises.disable_debug_mode'], MessageHelper::WARNING)->render())); } if ($url_rewriting_available && !$server_environment_config->is_url_rewriting_enabled()) { $fieldset->add_field(new FormFieldFree('enable_url_rewriting', '', MessageHelper::display($lang['advises.enable_url_rewriting'], MessageHelper::NOTICE)->render())); } if (function_exists('ob_gzhandler') && @extension_loaded('zlib') && !$server_environment_config->is_output_gziping_enabled()) { $fieldset->add_field(new FormFieldFree('enable_output_gz', '', MessageHelper::display($lang['advises.enable_output_gz'], MessageHelper::NOTICE)->render())); } if (DataStoreFactory::is_apc_available() && !DataStoreFactory::is_apc_enabled()) { $fieldset->add_field(new FormFieldFree('enable_apcu_cache', '', MessageHelper::display($lang['advises.enable_apcu_cache'], MessageHelper::NOTICE)->render())); } $fieldset->add_field(new FormFieldFree('save_database', '', MessageHelper::display($lang['advises.save_database'], MessageHelper::SUCCESS)->render())); if (!DatabaseConfig::load()->is_database_tables_optimization_enabled()) { $fieldset->add_field(new FormFieldFree('optimize_database_tables', '', MessageHelper::display($lang['advises.optimize_database_tables'], MessageHelper::SUCCESS)->render())); } if ($security_config->get_internal_password_min_length() == 6 && $security_config->get_internal_password_strength() == SecurityConfig::PASSWORD_STRENGTH_WEAK && !$security_config->are_login_and_email_forbidden_in_password()) { $fieldset->add_field(new FormFieldFree('password_security', '', MessageHelper::display($lang['advises.password_security'], MessageHelper::NOTICE)->render())); } if (ServerConfiguration::get_phpversion() < '5.6') { $fieldset->add_field(new FormFieldFree('upgrade_php_version', '', MessageHelper::display($lang['advises.upgrade_php_version'], MessageHelper::NOTICE)->render())); } if (count($fieldset->get_fields())) { $html_form->add_fieldset($fieldset); } }
/** * @throws Exception if the GD extension is not loaded */ private function assert_gd_extension_is_loaded() { $server_configuration = new ServerConfiguration(); if (!$server_configuration->has_gd_library()) { throw new Exception('The GD extension is required but not loaded.'); } }
require_once PATH_TO_ROOT . '/admin/admin_begin.php'; define('TITLE', $LANG['administration']); require_once PATH_TO_ROOT . '/admin/admin_header.php'; $check_updates = retrieve(GET, 'check', false); $update_type = retrieve(GET, 'type', ''); if (!in_array($update_type, array('', 'kernel', 'module', 'template'))) { $update_type = ''; } if ($check_updates === true) { AppContext::get_session()->csrf_get_protect(); new Updates(); AppContext::get_response()->redirect('updates.php' . (!empty($update_type) ? '?type=' . $update_type : '')); } $tpl = new FileTemplate('admin/updates/updates.tpl'); $updates_availables = 0; if (ServerConfiguration::get_phpversion() > Updates::PHP_MIN_VERSION_UPDATES) { $update_alerts = AdministratorAlertService::find_by_criteria(null, 'updates'); $updates = array(); foreach ($update_alerts as $update_alert) { // Builds the asked updates (kernel updates, module updates, theme updates or all of them) $update = unserialize($update_alert->get_properties()); if ($update_type == '' || $update->get_type() == $update_type) { if ($update->check_compatibility()) { $updates[] = $update; } else { // Like the update is incompatible (or has been applied) // We set the alert status to processed $update_alert->set_status(Event::EVENT_STATUS_PROCESSED); AdministratorAlertService::save_alert($update_alert); } }
/** * @return true if php version fits to phpboost's requirements. */ public function is_php_compatible() { return ServerConfiguration::get_phpversion() >= self::MIN_PHP_VERSION; }
public function is_google_auth_available() { $server_configuration = new ServerConfiguration(); return $this->get_property(self::GOOGLE_AUTH_ENABLED) && $server_configuration->has_curl_library(); }
/** * {@inheritdoc} */ public function get_default_values() { $server_configuration = new ServerConfiguration(); return array(self::REGISTRATION_ENABLED_PROPERTY => FormFieldCheckbox::CHECKED, self::MEMBER_ACCOUNTS_VALIDATION_METHOD_PROPERTY => self::AUTOMATIC_USER_ACCOUNTS_VALIDATION, self::WELCOME_MESSAGE_PROPERTY => LangLoader::get_message('site_config_msg_mbr', 'main'), self::REGISTRATION_AGREEMENT_PROPERTY => LangLoader::get_message('register_agreement', 'main'), self::UNACTIVATED_ACCOUNTS_TIMEOUT_PROPERTY => 20, self::ENABLE_AVATAR_UPLOAD_PROPERTY => FormFieldCheckbox::CHECKED, self::ENABLE_AVATAR_AUTO_RESIZING => $server_configuration->has_gd_library() ? FormFieldCheckbox::CHECKED : FormFieldCheckbox::UNCHECKED, self::DEFAULT_AVATAR_ENABLED_PROPERTY => FormFieldCheckbox::CHECKED, self::DEFAULT_AVATAR_URL_PROPERTY => 'no_avatar.png', self::MAX_AVATAR_WIDTH_PROPERTY => 120, self::MAX_AVATAR_HEIGHT_PROPERTY => 120, self::MAX_AVATAR_WEIGHT_PROPERTY => 20, self::AUTH_READ_MEMBERS => array('r0' => 1, 'r1' => 1), self::DEFAULT_LANG => 'english', self::DEFAULT_THEME => 'base', self::MAX_PRIVATE_MESSAGES_NUMBER => 50); }