/**
  * @desc Buils a ContentFormattingParser object.
  */
 public function __construct()
 {
     parent::__construct();
     $content_formatting_config = ContentFormattingConfig::load();
     $this->forbidden_tags = $content_formatting_config->get_forbidden_tags();
     $this->html_auth = $content_formatting_config->get_html_tag_auth();
 }
 private function init()
 {
     $this->lang = LangLoader::get('admin-contents-common');
     $this->content_formatting_config = ContentFormattingConfig::load();
     $this->content_management_config = ContentManagementConfig::load();
     $this->user_accounts_config = UserAccountsConfig::load();
 }
 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;
 }
Exemplo n.º 4
0
 public function __construct(SessionData $session)
 {
     $this->id = $session->get_user_id();
     $this->level = $session->get_cached_data('level', -1);
     $this->is_admin = $this->level == 2;
     $this->display_name = $session->get_cached_data('display_name', SessionData::DEFAULT_VISITOR_DISPLAY_NAME);
     $this->email = $session->get_cached_data('email', null);
     $this->show_email = $session->get_cached_data('show_email', false);
     $this->unread_pm = $session->get_cached_data('unread_pm', 0);
     $this->timestamp = $session->get_cached_data('timestamp', time());
     $this->warning_percentage = $session->get_cached_data('warning_percentage', 0);
     $this->delay_banned = $session->get_cached_data('delay_banned', 0);
     $this->delay_readonly = $session->get_cached_data('delay_readonly', 0);
     $user_accounts_config = UserAccountsConfig::load();
     $this->locale = $session->get_cached_data('locale', $user_accounts_config->get_default_lang());
     $this->theme = $session->get_cached_data('theme', $user_accounts_config->get_default_theme());
     $this->timezone = $session->get_cached_data('timezone', GeneralConfig::load()->get_site_timezone());
     $this->editor = $session->get_cached_data('editor', ContentFormattingConfig::load()->get_default_editor());
     $this->build_groups($session);
 }
    private function build_form()
    {
        $security_config = SecurityConfig::load();
        $form = new HTMLForm(__CLASS__);
        $this->member_extended_fields_service = new MemberExtendedFieldsService($form);
        $fieldset = new FormFieldsetHTML('registration', $this->lang['registration']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldHTML('validation_method', $this->get_accounts_validation_method_explain()));
        $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], '', array('maxlength' => 100, 'required' => true, 'description' => $this->lang['display_name.explain'], 'events' => array('blur' => '
				if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") {
					HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\'));
					HTMLForms.getField("login").enableValidationMessage();
					HTMLForms.getField("login").liveValidate();
				}')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists())));
        $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], '', array('required' => true), array(new FormFieldConstraintMailExist())));
        $fieldset->add_field(new FormFieldCheckbox('user_hide_mail', $this->lang['email.hide'], FormFieldCheckbox::CHECKED));
        $fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], false, array('description' => $this->lang['login.custom.explain'], 'events' => array('click' => '
				if (HTMLForms.getField("custom_login").getValue()) {
					HTMLForms.getField("login").enable();
				} else { 
					HTMLForms.getField("login").disable();
				}'))));
        $fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], '', array('hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists())));
        $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
        if ($security_config->are_login_and_email_forbidden_in_password()) {
            $form->add_constraint(new FormConstraintFieldsInequality($email, $password));
            $form->add_constraint(new FormConstraintFieldsInequality($login, $password));
        }
        $options_fieldset = new FormFieldsetHTML('options', LangLoader::get_message('options', 'main'));
        $form->add_fieldset($options_fieldset);
        $options_fieldset->add_field(new FormFieldTimezone('timezone', $this->lang['timezone.choice'], GeneralConfig::load()->get_site_timezone(), array('description' => $this->lang['timezone.choice.explain'])));
        if (count(ThemesManager::get_activated_and_authorized_themes_map()) > 1) {
            $options_fieldset->add_field(new FormFieldThemesSelect('theme', $this->lang['theme'], $this->user_accounts_config->get_default_theme(), array('check_authorizations' => true, 'events' => array('change' => $this->build_javascript_picture_themes()))));
            $options_fieldset->add_field(new FormFieldFree('preview_theme', $this->lang['theme.preview'], '<img id="img_theme" src="' . $this->get_picture_theme() . '" title="' . $this->lang['theme.preview'] . '" alt="' . $this->lang['theme.preview'] . '" class="preview-img" />'));
        }
        $options_fieldset->add_field(new FormFieldEditors('text-editor', $this->lang['text-editor'], ContentFormattingConfig::load()->get_default_editor()));
        $options_fieldset->add_field(new FormFieldLangsSelect('lang', $this->lang['lang'], $this->user_accounts_config->get_default_lang(), array('check_authorizations' => true)));
        $this->member_extended_fields_service->display_form_fields();
        $agreement_text = FormatingHelper::second_parse($this->user_accounts_config->get_registration_agreement());
        if (!empty($agreement_text)) {
            $agreement_fieldset = new FormFieldsetHTML('agreement_fieldset', $this->lang['agreement']);
            $form->add_fieldset($agreement_fieldset);
            $agreement = new FormFieldHTML('agreement.required', $this->lang['agreement.agree.required'] . '<br /><br />');
            $agreement_fieldset->add_field($agreement);
            $agreement = new FormFieldHTML('agreement', '<div id="id-message-helper" class="notice user-agreement">' . $agreement_text . '</div>');
            $agreement_fieldset->add_field($agreement);
            $agreement_fieldset->add_field(new FormFieldCheckbox('agree', $this->lang['agreement.agree'], FormFieldCheckbox::UNCHECKED, array('required' => $this->lang['agreement.agree.required'])));
        }
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
 /**
  * @param string $id_module
  */
 public function uninstall_editor($id_module)
 {
     $editors = $this->get_available_editors();
     if (count($editors) > 1) {
         $default_editor = ContentFormattingConfig::load()->get_default_editor();
         if ($default_editor !== $id_module) {
             PersistenceContext::get_querier()->update(DB_TABLE_MEMBER, array('editor' => $default_editor), 'WHERE editor=:old_editor', array('old_editor' => $id_module));
             return null;
         } else {
             return LangLoader::get_message('is_default_editor', 'editor-common');
         }
     }
     return LangLoader::get_message('last_editor_installed', 'editor-common');
 }
Exemplo n.º 7
0
 public static function update_module($module_id, $activated)
 {
     $error = '';
     if (!$activated) {
         MenuService::delete_mini_module($module_id);
         MenuService::delete_module_feeds_menus($module_id);
         $general_config = GeneralConfig::load();
         $module_home_page_selected = $general_config->get_module_home_page();
         if ($module_home_page_selected == $module_id) {
             $general_config->set_module_home_page('');
             $general_config->set_other_home_page('index.php');
         }
         $editors = AppContext::get_content_formatting_service()->get_available_editors();
         if (in_array($module_id, $editors)) {
             if (count($editors) > 1) {
                 $default_editor = ContentFormattingConfig::load()->get_default_editor();
                 if ($default_editor !== $module_id) {
                     PersistenceContext::get_querier()->update(DB_TABLE_MEMBER, array('editor' => $default_editor), 'WHERE editor=:old_editor', array('old_editor' => 'bbcode'));
                 } else {
                     $error = LangLoader::get_message('is_default_editor', 'editor-common');
                 }
             } else {
                 $error = LangLoader::get_message('last_editor_installed', 'editor-common');
             }
         }
     } else {
         $module = self::get_module($module_id);
         if ($module->get_configuration()->get_compatibility() != GeneralConfig::load()->get_phpboost_major_version()) {
             $error = LangLoader::get_message('modules.not_compatible', 'admin-modules-common');
         }
     }
     if (empty($error)) {
         $module = self::get_module($module_id);
         $module->set_activated($activated);
         ModulesConfig::load()->update($module);
         ModulesConfig::save();
         MenuService::generate_cache();
         Feed::clear_cache($module_id);
         if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
             HtaccessFileCache::regenerate();
         }
     }
     return $error;
 }
Exemplo n.º 8
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
define('PATH_TO_ROOT', '../../..');
include_once PATH_TO_ROOT . '/kernel/begin.php';
AppContext::get_session()->no_session_location();
//Permet de ne pas mettre jour la page dans la session.
include_once PATH_TO_ROOT . '/kernel/header_no_display.php';
$page_path_to_root = retrieve(REQUEST, 'path_to_root', '');
$page_path = retrieve(REQUEST, 'page_path', '');
//Quel éditeur utiliser ? Si ce n'est pas précisé on prend celui par défaut de l'utilisateur
$editor = retrieve(REQUEST, 'editor', ContentFormattingConfig::load()->get_default_editor());
$contents = TextHelper::htmlentities(retrieve(POST, 'contents', ''), ENT_COMPAT, 'UTF-8');
$contents = TextHelper::htmlspecialchars_decode(stripslashes(TextHelper::html_entity_decode($contents)));
$ftags = retrieve(POST, 'ftags', TSTRING_UNCHANGE);
$forbidden_tags = explode(',', $ftags);
$formatting_factory = AppContext::get_content_formatting_service()->create_factory($editor);
//On prend le bon parseur avec la bonne configuration
$parser = $formatting_factory->get_parser();
$parser->set_content($contents);
$parser->set_path_to_root($page_path_to_root);
$parser->set_page_path($page_path);
if (!empty($forbidden_tags)) {
    $parser->set_forbidden_tags($forbidden_tags);
}
$parser->parse();
//On parse la deuxième couche (code, math etc) pour afficher
Exemplo n.º 9
0
 public function __construct()
 {
     $content_formatting_config = ContentFormattingConfig::load();
     $this->forbidden_tags = $content_formatting_config->get_forbidden_tags();
 }
Exemplo n.º 10
0
 public static function get_visitor_properties($display_name = null)
 {
     return array('user_id' => Session::VISITOR_SESSION_ID, 'display_name' => $display_name !== null ? $display_name : LangLoader::get_message('guest', 'main'), 'level' => self::VISITOR_LEVEL, 'email' => null, 'show_email' => false, 'locale' => UserAccountsConfig::load()->get_default_lang(), 'theme' => UserAccountsConfig::load()->get_default_theme(), 'timezone' => GeneralConfig::load()->get_site_timezone(), 'editor' => ContentFormattingConfig::load()->get_default_editor(), 'unread_pm' => 0, 'registration_date' => 0, 'last_connection_date' => time(), 'groups' => '', 'warning_percentage' => 0, 'delay_banned' => 0, 'delay_readonly' => 0);
 }