private function build_form() { $picture_yes = '<i class="fa fa-success fa-2x" title="' . LangLoader::get_message('yes', 'common') . '"></i>'; $picture_no = '<i class="fa fa-error fa-2x" title="' . LangLoader::get_message('no', 'common') . '"></i>'; $picture_unknown = '<i class="fa fa-question fa-2x" title="' . LangLoader::get_message('unknown', 'main') . '"></i>'; $default_lang_config = LangsManager::get_lang(LangsManager::get_default_lang())->get_configuration(); $default_theme_config = ThemesManager::get_theme(ThemesManager::get_default_theme())->get_configuration(); $editors = AppContext::get_content_formatting_service()->get_available_editors(); $default_editor = $editors[ContentFormattingConfig::load()->get_default_editor()]; $server_configuration = new ServerConfiguration(); $general_config = GeneralConfig::load(); $server_environment_config = ServerEnvironmentConfig::load(); $sessions_config = SessionsConfig::load(); $maintenance_config = MaintenanceConfig::load(); $url_rewriting_available = false; $url_rewriting_known = true; try { $url_rewriting_available = $server_configuration->has_url_rewriting(); } catch (UnsupportedOperationException $ex) { $url_rewriting_known = false; } $summerization = "---------------------------------System report---------------------------------\n-----------------------------generated by PHPBoost-----------------------------\nSERVER CONFIGURATION-----------------------------------------------------------\nphp version\t\t\t: " . ServerConfiguration::get_phpversion() . "\ndbms version\t\t\t: " . PersistenceContext::get_dbms_utils()->get_dbms_version() . "\ngd library\t\t\t: " . (int) $server_configuration->has_gd_library() . "\nurl rewriting\t\t\t: " . ($url_rewriting_known ? (int) $url_rewriting_available : 'N/A') . "\napcu cache\t\t\t: " . (int) DataStoreFactory::is_apc_available() . "\nPHPBOOST CONFIGURATION---------------------------------------------------------\nphpboost version\t\t: " . Environment::get_phpboost_version() . "\nserver url\t\t\t: " . $general_config->get_site_url() . "\nsite path\t\t\t: " . $general_config->get_site_path() . "\ndefault theme\t\t\t: " . $default_theme_config->get_name() . " (" . LangLoader::get_message('version', 'admin') . " " . $default_theme_config->get_version() . ")\ndefault language\t\t: " . $default_lang_config->get_name() . "\ndefault editor\t\t\t: " . $default_editor . "\nhome page\t\t\t: " . Environment::get_home_page() . "\nurl rewriting\t\t\t: " . (int) $server_environment_config->is_url_rewriting_enabled() . "\napcu cache\t\t\t: " . (int) DataStoreFactory::is_apc_enabled() . "\noutput gzip\t\t\t: " . (int) $server_environment_config->is_output_gziping_enabled() . "\nsession cookie name\t\t: " . $sessions_config->get_cookie_name() . "\nsession duration\t\t: " . $sessions_config->get_session_duration() . "\nactive session duration\t\t: " . $sessions_config->get_active_session_duration() . "\nDIRECTORIES AUTHORIZATIONS-----------------------------------------------------\n"; $form = new HTMLForm('system-report', '', false); $this->get_advises($form); $fieldset = new FormFieldsetHTML('report', $this->admin_lang['server']); $form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldFree('php_version', $this->admin_lang['php_version'], ServerConfiguration::get_phpversion())); $fieldset->add_field(new FormFieldFree('dbms_version', $this->admin_lang['dbms_version'], PersistenceContext::get_dbms_utils()->get_dbms_version())); $fieldset->add_field(new FormFieldFree('gd_library', $this->admin_lang['gd_library'], $server_configuration->has_gd_library() ? $picture_yes : $picture_no)); $fieldset->add_field(new FormFieldFree('url_rewriting', $this->admin_lang['url_rewriting'], $url_rewriting_known ? $url_rewriting_available ? $picture_yes : $picture_no : $picture_unknown)); $fieldset->add_field(new FormFieldFree('apcu_cache', LangLoader::get_message('apcu_cache', 'admin-cache-common'), DataStoreFactory::is_apc_available() ? $picture_yes : $picture_no)); $fieldset = new FormFieldsetHTML('report', $this->admin_lang['phpboost_config']); $form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldFree('kernel_version', $this->admin_lang['kernel_version'], Environment::get_phpboost_version())); $fieldset->add_field(new FormFieldFree('site_url', LangLoader::get_message('advanced-config.site_url', 'admin-config-common'), $general_config->get_site_url())); $fieldset->add_field(new FormFieldFree('site_path', LangLoader::get_message('advanced-config.site_path', 'admin-config-common'), $general_config->get_site_path())); $fieldset->add_field(new FormFieldFree('default_theme', LangLoader::get_message('general-config.default_theme', 'admin-config-common'), $default_theme_config->get_name() . " (" . LangLoader::get_message('version', 'admin') . " " . $default_theme_config->get_version() . ")")); $fieldset->add_field(new FormFieldFree('default_language', LangLoader::get_message('general-config.default_language', 'admin-config-common'), $default_lang_config->get_name())); $fieldset->add_field(new FormFieldFree('default_editor', LangLoader::get_message('content.config.default-formatting-language', 'admin-contents-common'), $default_editor)); $fieldset->add_field(new FormFieldFree('start_page', LangLoader::get_message('general-config.start_page', 'admin-config-common'), Environment::get_home_page())); $fieldset->add_field(new FormFieldFree('phpboost_url_rewriting', $this->admin_lang['url_rewriting'], $server_environment_config->is_url_rewriting_enabled() ? $picture_yes : $picture_no)); $fieldset->add_field(new FormFieldFree('phpboost_apcu_cache', LangLoader::get_message('apcu_cache', 'admin-cache-common'), DataStoreFactory::is_apc_enabled() ? $picture_yes : $picture_no)); $fieldset->add_field(new FormFieldFree('output_gz', $this->admin_lang['output_gz'], $server_environment_config->is_output_gziping_enabled() ? $picture_yes : $picture_no)); $fieldset->add_field(new FormFieldFree('cookie_name', LangLoader::get_message('advanced-config.cookie-name', 'admin-config-common'), $sessions_config->get_cookie_name())); $fieldset->add_field(new FormFieldFree('session_length', LangLoader::get_message('advanced-config.cookie-duration', 'admin-config-common'), $sessions_config->get_session_duration())); $fieldset->add_field(new FormFieldFree('session_guest_length', LangLoader::get_message('advanced-config.active-session-duration', 'admin-config-common'), $sessions_config->get_active_session_duration())); $fieldset = new FormFieldsetHTML('directories_auth', $this->admin_lang['directories_auth']); $form->add_fieldset($fieldset); $directories_summerization = ''; foreach (PHPBoostFoldersPermissions::get_permissions() as $key => $folder) { $fieldset->add_field(new FormFieldFree(str_replace('/', '_', $key), $key, $folder->is_writable() ? $picture_yes : $picture_no)); $directories_summerization .= $key . str_repeat(' ', 5 - strlen($key) / 8) . ": " . (int) $folder->is_writable() . "\n"; } $fieldset = new FormFieldsetHTML('summerization', $this->admin_lang['system_report_summerization']); $form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldLabel($this->admin_lang['system_report_summerization_explain'])); $fieldset->add_field(new FormFieldMultiLineTextEditor('summerization', '', $summerization . $directories_summerization, array('rows' => 20, 'cols' => 15, 'class' => 'system-report'))); $this->form = $form; }
public function get_content() { $user = AppContext::get_current_user(); $lang_id = AppContext::get_request()->get_string('switchlang', ''); if (!empty($lang_id)) { $lang = LangsManager::get_lang($lang_id); if ($lang !== null) { if ($lang->is_activated() && $lang->check_auth()) { $user->update_lang($lang->get_id()); } } $query_string = preg_replace('`switchlang=[^&]+`', '', QUERY_STRING); AppContext::get_response()->redirect(trim(HOST . SCRIPT . (!empty($query_string) ? '?' . $query_string : ''))); } $tpl = new FileTemplate('LangsSwitcher/langswitcher.tpl'); $tpl->add_lang(LangLoader::get('langswitcher_common', 'LangsSwitcher')); foreach (LangsManager::get_activated_and_authorized_langs_map() as $id => $lang) { $selected = $user->get_locale() == $id ? ' selected="selected"' : ''; $tpl->assign_block_vars('langs', array('NAME' => $lang->get_configuration()->get_name(), 'IDNAME' => $id, 'SELECTED' => $selected)); } $lang_identifier = str_replace('en', 'uk', LangLoader::get_message('xml_lang', 'main')); $tpl->put_all(array('DEFAULT_LANG' => UserAccountsConfig::load()->get_default_lang(), 'IMG_LANG_IDENTIFIER' => TPL_PATH_TO_ROOT . '/images/stats/countries/' . $lang_identifier . '.png')); return $tpl; }
public static function init_session() { Session::gc(); $session_data = Session::start(); AppContext::set_session($session_data); AppContext::init_current_user(); $current_user = AppContext::get_current_user(); $user_accounts_config = UserAccountsConfig::load(); $user_theme = ThemesManager::get_theme($current_user->get_theme()); $default_theme = $user_accounts_config->get_default_theme(); if ($user_theme === null || (!$user_theme->check_auth() || !$user_theme->is_activated()) && $user_theme->get_id() !== $default_theme) { AppContext::get_current_user()->update_theme($default_theme); } $user_lang = LangsManager::get_lang($current_user->get_locale()); $default_lang = $user_accounts_config->get_default_lang(); if ($user_lang === null || (!$user_lang->check_auth() || !$user_lang->is_activated()) && $user_lang->get_id() !== $default_lang) { AppContext::get_current_user()->update_lang($default_lang); } }