Пример #1
0
function wiki_no_rewrite($var)
{
    if (!ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
        //Pas de rewriting
        return preg_replace('`<a href="/wiki/([a-z0-9+#-]+)">(.*)</a>`sU', '<a href="/wiki/wiki.php?title=$1">$2</a>', $var);
    } else {
        return $var;
    }
}
 public function execute(array $args)
 {
     $this->arg_reader = new CLIArgumentsReader($args);
     if ($this->arg_reader->has_arg('add')) {
         $server_environment_config = ServerEnvironmentConfig::load();
         $content = $server_environment_config->get_htaccess_manual_content();
         $content .= $this->arg_reader->get('add');
         $server_environment_config->set_htaccess_manual_content($content);
         ServerEnvironmentConfig::save();
         $this->regenerate_htaccess_file();
         CLIOutput::writeln('success');
     } else {
         $this->help(array());
     }
 }
Пример #3
0
 /**
  * @desc Returns an url object from the dispatcher path with the $url param
  * dispatcher must be in the index.php file
  * @param string $path the url to apply the rewrite form on
  * @param string $url the url to apply the rewrite form on
  * @param boolean $not_rewriting_url_forced forced to have a non-rewritten url
  * @return Url an url object relative to the current script path
  */
 public static function get_url($path, $url, $not_rewriting_url_forced = false)
 {
     $dispatcher_url = new Url(rtrim($path, '/'));
     $url = ltrim($url, '/');
     if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled() && !$not_rewriting_url_forced) {
         return new Url(self::get_dispatcher_path($dispatcher_url->relative()) . '/' . $url);
     } else {
         $dispatcher = $dispatcher_url->relative();
         if (!preg_match('`(?:\\.php)|/$`', $dispatcher)) {
             $dispatcher .= '/';
         }
         if (strpos($url, '?') !== false) {
             $exploded = explode('?', $url, 2);
             $exploded[1] = str_replace('?', '&', $exploded[1]);
             return new Url($dispatcher . '?' . Dispatcher::URL_PARAM_NAME . '=/' . $exploded[0] . '&' . $exploded[1]);
         } else {
             return new Url($dispatcher . '?' . Dispatcher::URL_PARAM_NAME . '=/' . $url);
         }
     }
 }
Пример #4
0
 $row = PersistenceContext::get_querier()->select_single_row_query("SELECT COUNT(*) as nbr_msg\n\tFROM " . PREFIX . "forum_msg msg\n\tLEFT JOIN " . PREFIX . "forum_topics t ON msg.idtopic = t.id\n\tWHERE msg.user_id = :user_id AND t.idcat IN :authorized_categories", array('authorized_categories' => $authorized_categories, 'user_id' => $view_msg));
 $nbr_msg = $row['nbr_msg'];
 $page = AppContext::get_request()->get_getint('p', 1);
 $pagination = new ModulePagination($page, $nbr_msg, $_NBR_ELEMENTS_PER_PAGE, Pagination::LIGHT_PAGINATION);
 $pagination->set_url(new Url('/forum/membermsg.php?id=' . $view_msg . '&amp;p=%d'));
 if ($pagination->current_page_is_empty() && $page > 1) {
     $error_controller = PHPBoostErrors::unexisting_page();
     DispatchManager::redirect($error_controller);
 }
 $tpl->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'FORUM_NAME' => $config->get_forum_name() . ' : ' . $LANG['show_member_msg'], 'PAGINATION' => $pagination->display(), 'L_BACK' => $LANG['back'], 'L_VIEW_MSG_USER' => $LANG['show_member_msg'], 'L_FORUM_INDEX' => $LANG['forum_index'], 'U_FORUM_VIEW_MSG' => url('.php?id=' . $view_msg)));
 $result = PersistenceContext::get_querier()->select("SELECT msg.id, msg.user_id, msg.idtopic, msg.timestamp, msg.timestamp_edit, m.groups, t.title, t.status, t.idcat, c.name, m.display_name, m.level, m.email, m.show_email, m.registration_date AS registered, m.posted_msg, m.warning_percentage, m.delay_banned, s.user_id AS connect, msg.contents, ext_field.user_avatar, m.posted_msg, ext_field.user_sign, " . $extended_fields_to_recover_list . "m.warning_percentage, m.delay_readonly, m.delay_banned \n\tFROM " . PREFIX . "forum_msg msg\n\tLEFT JOIN " . PREFIX . "forum_topics t ON msg.idtopic = t.id\n\tLEFT JOIN " . ForumSetup::$forum_cats_table . " c ON c.id = t.idcat\n\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = :user_id\n\tLEFT JOIN " . DB_TABLE_MEMBER_EXTENDED_FIELDS . " ext_field ON ext_field.user_id = msg.user_id\n\tLEFT JOIN " . DB_TABLE_SESSIONS . " s ON s.user_id = msg.user_id AND s.timestamp > :timestamp\n\tWHERE msg.user_id = :id AND t.idcat IN :authorized_categories\n\tORDER BY msg.id DESC\n\tLIMIT :number_items_per_page OFFSET :display_from", array('id' => $view_msg, 'user_id' => $view_msg, 'timestamp' => time() - SessionsConfig::load()->get_active_session_duration(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
 while ($row = $result->fetch()) {
     //On encode l'url pour un éventuel rewriting, c'est une opération assez gourmande
     $rewrited_cat_title = ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? '+' . Url::encode_rewrite($row['name']) : '';
     //On encode l'url pour un éventuel rewriting, c'est une opération assez gourmande
     $rewrited_title = ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? '+' . Url::encode_rewrite($row['title']) : '';
     //Ajout du marqueur d'édition si activé.
     $edit_mark = $row['timestamp_edit'] > 0 && $config->is_edit_mark_enabled() ? '<span class="edit-pseudo">' . $LANG['edit_by'] . ' <a href="' . UserUrlBuilder::profile($row['user_id_edit'])->rel() . '">' . $row['login_edit'] . '</a> ' . $LANG['on'] . ' ' . Date::to_format($row['timestamp_edit'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '</span><br />' : '';
     $group_color = User::get_group_color($row['groups'], $row['level']);
     //Rang de l'utilisateur.
     $user_rank = $row['level'] === '0' ? $LANG['member'] : $LANG['guest'];
     $user_group = $user_rank;
     $user_rank_icon = '';
     if ($row['level'] === '2') {
         $user_rank = $ranks_cache[-2]['name'];
         $user_group = $user_rank;
         $user_rank_icon = $ranks_cache[-2]['icon'];
     } elseif ($row['level'] === '1') {
         $user_rank = $ranks_cache[-1]['name'];
         $user_group = $user_rank;
         $user_rank_icon = $ranks_cache[-1]['icon'];
Пример #5
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;
 }
 private function install_modules(array $modules_to_install)
 {
     foreach ($modules_to_install as $module_name) {
         ModulesManager::install_module($module_name, true, false);
     }
     if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
         HtaccessFileCache::regenerate();
     }
 }
 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);
     }
 }
    private function build_view()
    {
        global $LANG, $MEDIA_LANG;
        require_once PATH_TO_ROOT . '/media/media_constant.php';
        load_module_lang('media');
        $config = MediaConfig::load();
        $category = $this->get_category();
        $authorized_categories = MediaService::get_authorized_categories($category->get_id());
        //Contenu de la catégorie
        $page = AppContext::get_request()->get_getint('p', 1);
        $subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1);
        $get_sort = retrieve(GET, 'sort', '');
        $get_mode = retrieve(GET, 'mode', '');
        $mode = $get_mode == 'asc' ? 'ASC' : 'DESC';
        $unget = !empty($get_sort) && !empty($mode) ? '?sort=' . $get_sort . '&amp;mode=' . $get_mode : '';
        //On crée une pagination si le nombre de sous-catégories est trop important.
        $subcategories_number = count(MediaService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id()));
        $pagination = new ModulePagination($subcategories_page, $subcategories_number, $config->get_categories_number_per_page());
        $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&amp;' : '?') . 'cat=' . $category->get_id() . '&amp;p=' . $page . '&amp;subcategories_page=%d'));
        if ($pagination->current_page_is_empty() && $subcategories_page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        //Children categories
        $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= media_cats.id, media_cats.*,
		(SELECT COUNT(*) FROM ' . MediaSetup::$media_table . '
			WHERE idcat IN (
				@id_cat,
				(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' WHERE id_parent = @id_cat), 
				(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' parents
				INNER JOIN ' . MediaSetup::$media_cats_table . ' childs ON parents.id = childs.id_parent
				WHERE parents.id_parent = @id_cat)
			)
			AND infos = :status
		) AS mediafiles_number
		FROM ' . MediaSetup::$media_cats_table . ' media_cats
		WHERE id_parent = :id_category
		AND id IN :authorized_categories
		ORDER BY id_parent, c_order
		LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED, 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
        $nbr_cat_displayed = 0;
        while ($row = $result->fetch()) {
            $category_image = new Url($row['image']);
            $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'MEDIAFILES_NUMBER' => sprintf($row['mediafiles_number'] > 1 ? $MEDIA_LANG['num_medias'] : $MEDIA_LANG['num_media'], $row['mediafiles_number']), 'U_CATEGORY' => MediaUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
            $nbr_cat_displayed++;
        }
        $result->dispose();
        $nbr_column_cats = $nbr_cat_displayed > $config->get_columns_number_per_line() ? $config->get_columns_number_per_line() : $nbr_cat_displayed;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $cats_columns_width = floor(100 / $nbr_column_cats);
        $category_description = FormatingHelper::second_parse($category->get_description());
        $this->tpl->put_all(array('C_CATEGORIES' => true, 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_MODO' => MediaAuthorizationsService::check_authorizations($category->get_id())->moderation(), 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'L_BY' => $MEDIA_LANG['media_added_by'], 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'CATEGORY_NAME' => $category->get_id() == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : $category->get_name(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($category->get_id())->rel(), 'ID_CAT' => $category->get_id()));
        $selected_fields = array('alpha' => '', 'date' => '', 'nbr' => '', 'note' => '', 'com' => '', 'asc' => '', 'desc' => '');
        switch ($get_sort) {
            case 'alpha':
                $sort = 'name';
                $selected_fields['alpha'] = ' selected="selected"';
                break;
            default:
            case 'date':
                $sort = 'timestamp';
                $selected_fields['date'] = ' selected="selected"';
                break;
            case 'nbr':
                $sort = 'counter';
                $selected_fields['nbr'] = ' selected="selected"';
                break;
            case 'note':
                $sort = 'average_notes';
                $selected_fields['note'] = ' selected="selected"';
                break;
            case 'com':
                $sort = 'com.number_comments';
                $selected_fields['com'] = ' selected="selected"';
                break;
        }
        if ($mode == 'ASC') {
            $selected_fields['asc'] = ' selected="selected"';
        } else {
            $selected_fields['desc'] = ' selected="selected"';
        }
        $this->tpl->put_all(array('C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'L_ALPHA' => $MEDIA_LANG['sort_title'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_NBR' => $MEDIA_LANG['sort_popularity'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_DESC' => $LANG['desc'], 'L_ASC' => $LANG['asc'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common'), 'SELECTED_ALPHA' => $selected_fields['alpha'], 'SELECTED_DATE' => $selected_fields['date'], 'SELECTED_NBR' => $selected_fields['nbr'], 'SELECTED_NOTE' => $selected_fields['note'], 'SELECTED_COM' => $selected_fields['com'], 'SELECTED_ASC' => $selected_fields['asc'], 'SELECTED_DESC' => $selected_fields['desc']));
        $condition = 'WHERE idcat = :idcat AND infos = :status';
        $parameters = array('idcat' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED);
        //On crée une pagination si le nombre de fichiers est trop important.
        $mediafiles_number = MediaService::count($condition, $parameters);
        $pagination = new ModulePagination($page, $mediafiles_number, $config->get_items_number_per_page());
        $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&amp;' : '?') . 'cat=' . $category->get_id() . '&amp;p=%d&amp;subcategories_page=' . $subcategories_page));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        $notation = new Notation();
        $notation->set_module_name('media');
        $notation->set_notation_scale($config->get_notation_scale());
        $result = PersistenceContext::get_querier()->select("SELECT v.id, v.iduser, v.name, v.timestamp, v.counter, v.infos, v.contents, mb.display_name, mb.groups, mb.level, notes.average_notes, com.number_comments\n\t\t\tFROM " . PREFIX . "media AS v\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " AS mb ON v.iduser = mb.user_id\n\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON v.id = notes.id_in_module AND notes.module_name = 'media'\n\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON v.id = com.id_in_module AND com.module_id = 'media'\n\t\t\t" . $condition . "\n\t\t\tORDER BY " . $sort . " " . $mode . "\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
        $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_DISPLAY_NO_FILE_MSG' => $result->get_rows_count() == 0 && $category->get_id() != Category::ROOT_CATEGORY, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TARGET_ON_CHANGE_ORDER' => ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? 'media-0-' . $category->get_id() . '.php?' : 'media.php?cat=' . $category->get_id() . '&'));
        while ($row = $result->fetch()) {
            $notation->set_id_in_module($row['id']);
            $group_color = User::get_group_color($row['groups'], $row['level']);
            $this->tpl->assign_block_vars('file', array('ID' => $row['id'], 'NAME' => $row['name'], 'IMG_NAME' => str_replace('"', '\\"', $row['name']), 'C_DESCRIPTION' => !empty($row['contents']), 'DESCRIPTION' => stripslashes(FormatingHelper::second_parse($row['contents'])), 'POSTER' => $MEDIA_LANG['media_added_by'] . ' : ' . !empty($row['display_name']) ? '<a href="' . UserUrlBuilder::profile($row['iduser'])->rel() . '" class="' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['display_name'] . '</a>' : $LANG['guest'], 'DATE' => sprintf($MEDIA_LANG['add_on_date'], Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR)), 'COUNT' => sprintf($MEDIA_LANG['view_n_times'], $row['counter']), 'NOTE' => NotationService::display_static_image($notation), 'U_MEDIA_LINK' => PATH_TO_ROOT . '/media/' . url('media.php?id=' . $row['id'], 'media-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php'), 'U_ADMIN_UNVISIBLE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?unvisible=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token()), 'U_ADMIN_EDIT_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?edit=' . $row['id']), 'U_ADMIN_DELETE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?del=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token()), 'U_COM_LINK' => '<a href="' . PATH_TO_ROOT . '/media/media' . url('.php?id=' . $row['id'] . '&amp;com=0', '-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php?com=0') . '">' . CommentsService::get_number_and_lang_comments('media', $row['id']) . '</a>'));
        }
        $result->dispose();
    }
Пример #9
0
/**
 * @deprecated
 * @desc Adds the session ID to an URL if the user doesn't accepts cookies.
 * This functions allows you to generate an URL according to the site configuration concerning the URL rewriting.
 * @param string $url URL if the URL rewriting is disabled
 * @param string $mod_rewrite URL if the URL rewriting is enabled
 * @param string $ampersand In a redirection you mustn't put the & HTML entity (&amp;). In this case set that parameter to &.
 * @return string The URL to use.
 */
function url($url, $mod_rewrite = '', $ampersand = '&amp;')
{
    if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled() && !empty($mod_rewrite)) {
        return $mod_rewrite;
    } else {
        return $url;
    }
}
Пример #10
0
 public static function init_output_bufferization()
 {
     if (ServerEnvironmentConfig::load()->is_output_gziping_enabled() && !in_array('ob_gzhandler', ob_list_handlers())) {
         ob_start('ob_gzhandler');
     } else {
         ob_start();
     }
 }
Пример #11
0
 private function add_manual_content()
 {
     $manual_content = ServerEnvironmentConfig::load()->get_htaccess_manual_content();
     if (!empty($manual_content)) {
         $this->add_section('Manual content');
         $this->add_line($manual_content);
     }
 }
Пример #12
0
function pages_second_parse($contents)
{
    if (!ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
        $contents = preg_replace('`<a href="/pages/([a-z0-9+#-]+)">(.*)</a>`sU', '<a href="/pages/pages.php?title=$1">$2</a>', $contents);
    }
    $contents = FormatingHelper::second_parse(stripslashes($contents));
    return $contents;
}
 private function disable_urls_rewriting()
 {
     $this->server_environment_config->set_url_rewriting_enabled(false);
     ServerEnvironmentConfig::save();
 }
Пример #14
0
 /**
  *  @desc Return the string to print the result
  *  @param &string[] $result_data the result's data
  *  @return string[] The string to print the result of a search element
  */
 public function parse_search_result($result_data)
 {
     global $LANG;
     load_module_lang('forum');
     //Chargement de la langue du module.
     $tpl = new FileTemplate('forum/forum_generic_results.tpl');
     $tpl->put_all(array('L_ON' => $LANG['on'], 'L_TOPIC' => $LANG['topic']));
     $rewrited_title = ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? '+' . Url::encode_rewrite($result_data['title']) : '';
     $tpl->put_all(array('USER_ONLINE' => '<i class="fa ' . (!empty($result_data['connect']) && $result_data['user_id'] !== -1 ? 'fa-online' : 'fa-offline') . '"></i>', 'U_USER_PROFILE' => !empty($result_data['user_id']) ? UserUrlBuilder::profile($result_data['user_id'])->rel() : '', 'USER_PSEUDO' => !empty($result_data['display_name']) ? TextHelper::wordwrap_html($result_data['display_name'], 13) : $LANG['guest'], 'U_TOPIC' => PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $result_data['topic_id'], '-' . $result_data['topic_id'] . $rewrited_title . '.php') . '#m' . $result_data['msg_id'], 'TITLE' => stripslashes($result_data['title']), 'DATE' => Date::to_format($result_data['date'], 'd/m/y'), 'CONTENTS' => FormatingHelper::second_parse(stripslashes($result_data['contents'])), 'USER_AVATAR' => '<img src="' . (UserAccountsConfig::load()->is_default_avatar_enabled() && !empty($result_data['avatar']) ? $result_data['avatar'] : PATH_TO_ROOT . '/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . UserAccountsConfig::load()->get_default_avatar_name()) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" class="message-avatar"/>'));
     return $tpl->render();
 }
 private function save()
 {
     $this->general_config->set_site_url($this->form->get_value('site_url'));
     $this->general_config->set_site_path($this->form->get_value('site_path'));
     $this->general_config->set_site_timezone($this->form->get_value('site_timezone')->get_raw_value());
     GeneralConfig::save();
     $this->sessions_config->set_cookie_name($this->form->get_value('cookie_name'));
     $this->sessions_config->set_session_duration($this->form->get_value('session_duration'));
     $this->sessions_config->set_active_session_duration($this->form->get_value('active_session_duration'));
     SessionsConfig::save();
     if (!$this->form->field_is_disabled('url_rewriting_enabled')) {
         $this->server_environment_config->set_url_rewriting_enabled($this->form->get_value('url_rewriting_enabled'));
     }
     $this->server_environment_config->set_htaccess_manual_content($this->form->get_value('htaccess_manual_content'));
     $robots_file = new File(PATH_TO_ROOT . '/robots.txt');
     $robots_file->write($this->form->get_value('robots_content'));
     if (!$this->form->field_is_disabled('output_gziping_enabled')) {
         $this->server_environment_config->set_output_gziping_enabled($this->form->get_value('output_gziping_enabled'));
     }
     ServerEnvironmentConfig::save();
     $this->clear_cache();
     if ($this->form->get_value('debug_mode_enabled')) {
         $options = array();
         if ($this->form->get_value('debug_mode_type')->get_raw_value() == '1') {
             $options[Debug::STRICT_MODE] = true;
         }
         if ($this->form->get_value('display_database_query_enabled')) {
             $options[Debug::DISPLAY_DATABASE_QUERY] = true;
         }
         Debug::enabled_debug_mode($options);
     } else {
         Debug::disable_debug_mode();
     }
     HtaccessFileCache::regenerate();
 }