/** * constuctor */ function gym_sitemaps($action_type = '') { global $phpEx, $phpbb_seo, $user, $config, $phpbb_root_path, $_action_types, $_override_types, $auth; $start_time = $phpbb_seo->microtime_float(); // Set default values $this->gym_config = $this->actions = array(); $this->override_type = $_override_types; $this->actions['action_types'] = $_action_types; $this->actions['action_type'] = in_array($action_type, $this->actions['action_types']) ? $action_type : ''; $this->actions['extra_params'] = $this->actions['extra_params_full'] = $this->actions['auth_param'] = $this->actions['sql_report_msg'] = ''; $this->actions['auth_guest_list'] = $this->actions['auth_guest_read'] = $this->actions['auth_view_list'] = $this->actions['auth_read_list'] = array(); $this->actions['robots_patterns'] = array(); if (empty($this->actions['action_type'])) { $this->gym_error(403, '', __FILE__, __LINE__); } // Grab required config obtain_gym_config($this->actions['action_type'], $this->gym_config); if (empty($this->gym_config)) { $this->gym_error(404, '', __FILE__, __LINE__); } // Set the overidding options $this->set_override(); $this->path_config = array('gym_path' => $phpbb_root_path . 'gym_sitemaps/', 'gym_img_url' => $phpbb_seo->seo_path['phpbb_url'] . 'gym_sitemaps/images/'); // The main array $this->output_data = array('microtime' => $start_time, 'time' => time(), 'mem_usage' => 0, 'gen_data' => '', 'gen_out' => '', 'url_sofar' => 0, 'url_sofar_total' => 0, 'showstats' => 0, 'data' => '', 'expires_time' => 0); // Ceck the day interval and reset pinged if (@$config['gym_today'] < $this->output_data['time']) { set_config('gym_today', $this->output_data['time'] + 3600 * 24, 1); set_config('gym_pinged_today', 0, 1); } $this->url_config = array('start_default' => '&start=', 'google_default' => "sitemap.{$phpEx}", 'html_default' => "map.{$phpEx}", 'rss_default' => "gymrss.{$phpEx}", 'gzip_ext_out' => '', 'zero_dupe' => (bool) $this->gym_config['gym_zero_dupe'], 'uri' => $phpbb_seo->seo_path['uri'], 'current' => '', 'modrewrite' => false); $this->gzip_config = array('gzip_level' => (int) $this->gym_config['gym_gzip_level']); $this->cache_config = array('do_cache' => true, 'cached' => 'false', 'mod_since' => (bool) $this->gym_config['gym_mod_since']); // init $gym_auth $this->gym_auth = array('admin' => $auth->acl_gets('a_') ? true : false, 'globalmod' => $auth->acl_getf_global('m_') ? true : false, 'reg' => $user->data['is_registered'] ? true : false, 'guest' => $user->data['is_registered'] ? false : true, 'all' => true, 'none' => false); // Workaround for error message handling $phpbb_seo->file_hbase['map'] = $phpbb_seo->file_hbase['gymrss'] = $phpbb_seo->file_hbase['sitemap'] = $phpbb_seo->seo_path['phpbb_url']; // Clear buffer, just in case it was started elswhere while (@ob_end_clean()) { } return; }
} require $phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx; require $phpbb_root_path . 'includes/cache.' . $phpEx; require $phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx; require $phpbb_root_path . 'includes/constants.' . $phpEx; require_once $phpbb_root_path . 'gym_sitemaps/includes/gym_common.' . $phpEx; $db = new $sql_db(); $cache = new cache(); // Connect to DB if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) { exit; } unset($dbhost, $dbuser, $dbpasswd, $dbname, $dbport); $config = $cache->obtain_config(); $gym_config = array(); obtain_gym_config($action, $gym_config); // Do we load phpbb css ? $load_phpbb_css = isset($gym_config[$action . '_load_phpbb_css']) ? $gym_config[$action . '_load_phpbb_css'] : $load_phpbb_css; // Check if requested style does exists if ($theme_id > 0) { $sql = 'SELECT s.style_id, c.theme_path, c.theme_name, t.template_path FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c WHERE s.style_id = ' . $theme_id . ' AND t.template_id = s.template_id AND c.theme_id = s.theme_id'; $result = $db->sql_query($sql, 300); $theme = $db->sql_fetchrow($result); $db->sql_freeresult($result); } // Grabb the default one data instead if (!$theme) {
/** * obtain_gym_links(). * Builds the rss and sitemaps links */ function obtain_gym_links($gym_links = array()) { global $phpbb_root_path, $template, $cache, $config, $phpEx, $user, $phpbb_seo, $auth; if (empty($config['gym_installed'])) { return; } $_phpbb_seo = !empty($phpbb_seo); $board_url = $_phpbb_seo ? $phpbb_seo->seo_path['phpbb_url'] : generate_board_url() . '/'; $gym_config = array(); $cache_file = '_gym_links_' . $user->data['user_lang']; $gym_link_tpl = '<a href="%1$s" title="%3$s" class="gym"><img src="' . $board_url . 'gym_sitemaps/images/%2$s" alt="%3$s"/> %4$s</a> '; if (($links = $cache->get($cache_file)) === false) { obtain_gym_config('main', $gym_config); $user->add_lang('gym_sitemaps/gym_common'); if (!defined('GYM_RSS_FUNC_INC')) { require $phpbb_root_path . 'gym_sitemaps/includes/gym_rss_functions.' . $phpEx; } $links = get_gym_links($gym_config); $cache->put($cache_file, $links); } // In case one would want to manually fil the array in some file, like viewforum // Would be passed here from page_header() where $gym_links is global if (!empty($gym_links['main'])) { $links = array_merge($links['main'], $gym_links['main']); } // A bit dirty but lazy way to add forum maps and news pages everywhere ;-) $html_setup =& $links['setup']['html']; $rss_setup =& $links['setup']['rss']; $google_setup =& $links['setup']['google']; if (!empty($html_setup['forum_allow_cat_news']) || !empty($html_setup['forum_allow_cat_map']) || !empty($rss_setup['forum_rss']) || !empty($google_setup['forum_google'])) { $_f_sep = $_phpbb_seo ? $phpbb_seo->seo_delim['forum'] : ''; $display_main_index = !empty($links['setup']['main']['link_index']); if ($display_main_index && !empty($template->_tpldata['forumrow'])) { foreach ($template->_tpldata['forumrow'] as $k => $v) { $num_topics = !empty($v['TOPICS']) ? max(0, (int) $v['TOPICS']) : 0; if ($num_topics && empty($v['S_IS_LINK']) && empty($v['S_IS_CAT'])) { $link = ''; $forum_id = (int) $v['FORUM_ID']; $forum_name = $v['FORUM_NAME']; if (!empty($html_setup['link_index']) && (isset($html_setup['auth_guest'][$forum_id]) || !empty($html_setup['forum_allow_auth']) && !isset($html_setup['forum_exclude'][$forum_id]))) { if ($html_setup['forum_allow_cat_news']) { $url = sprintf($html_setup['forum_cat_news'], $_phpbb_seo ? $phpbb_seo->seo_url['forum'][$forum_id] : '', $forum_id); $link .= sprintf($gym_link_tpl, $url, 'html_news.gif', sprintf($html_setup['l_html_news_of'], $forum_name), $html_setup['l_html_news']); } if ($html_setup['forum_allow_cat_map']) { $url = sprintf($html_setup['forum_cat_map'], $_phpbb_seo ? $phpbb_seo->seo_url['forum'][$forum_id] : '', $forum_id); $link .= ' ' . sprintf($gym_link_tpl, $url, 'maps-icon.gif', sprintf($html_setup['l_html_map_of'], $forum_name), $html_setup['l_html_map']); } } if (!empty($rss_setup['link_index']) && (isset($rss_setup['auth_guest'][$forum_id]) || $rss_setup['forum_allow_auth'] && !isset($rss_setup['forum_exclude'][$forum_id]))) { $url = sprintf($rss_setup['forum_cat_rss'], $_phpbb_seo ? $phpbb_seo->seo_url['forum'][$forum_id] : '', $forum_id); $link .= ' ' . sprintf($gym_link_tpl, $url, 'feed-icon.png', sprintf($rss_setup['l_rss_feed_of'], $forum_name), $rss_setup['l_rss_feed']); } if (!empty($google_setup['link_index']) && isset($google_setup['auth_guest'][$forum_id]) && $num_topics >= $google_setup['threshold']) { $url = sprintf($google_setup['forum_cat_google'], $_phpbb_seo ? str_replace($_f_sep . $forum_id, '', $phpbb_seo->seo_url['forum'][$forum_id]) . $_f_sep . $forum_id : '', $forum_id); $link .= ' ' . sprintf($gym_link_tpl, $url, 'sitemap-icon.gif', sprintf($google_setup['l_google_sitemap_of'], $forum_name), $google_setup['l_google_sitemap']); } if ($link) { $template->_tpldata['forumrow'][$k]['FORUM_DESC'] .= "<br/>{$link}"; } } } } $display_main_cat = !empty($links['setup']['main']['link_cat']); if ($display_main_cat && !empty($template->_rootref['FORUM_NAME']) && !empty($template->_rootref['FORUM_ID'])) { $forum_id = (int) $template->_rootref['FORUM_ID']; $forum_name = $template->_rootref['FORUM_NAME']; $do_display = false; if (!empty($template->_tpldata['navlinks'])) { $forum_data = $template->_tpldata['navlinks'][count($template->_tpldata['navlinks']) - 1]; } if (!empty($forum_data)) { if ($_phpbb_seo && empty($phpbb_seo->seo_url['forum'][$forum_id])) { $phpbb_seo->seo_url['forum'][$forum_id] = $phpbb_seo->set_url($forum_name, $forum_id, $phpbb_seo->seo_static['forum']); } if (!empty($html_setup['link_cat']) && (isset($html_setup['auth_guest'][$forum_id]) || !empty($html_setup['forum_allow_auth']) && !isset($html_setup['forum_exclude'][$forum_id]))) { if ($html_setup['forum_allow_cat_news']) { $url = sprintf($html_setup['forum_cat_news'], $_phpbb_seo ? $phpbb_seo->seo_url['forum'][$forum_id] : '', $forum_id); $title = sprintf($html_setup['l_html_news_of'], $forum_name); $links['main']['GYM_HTML_FORUM_NEWS_LINK'] = sprintf($gym_link_tpl, $url, 'html_news.gif', $title, $html_setup['l_html_news']); $do_display = true; } if ($html_setup['forum_allow_cat_map']) { $url = sprintf($html_setup['forum_cat_map'], $_phpbb_seo ? $phpbb_seo->seo_url['forum'][$forum_id] : '', $forum_id); $title = sprintf($html_setup['l_html_map_of'], $forum_name); $links['main']['GYM_HTML_FORUM_MAP_LINK'] = sprintf($gym_link_tpl, $url, 'maps-icon.gif', $title, $html_setup['l_html_map']); $do_display = true; } } } if (!empty($forum_data['S_IS_POST'])) { if (!empty($rss_setup['link_cat']) && (isset($rss_setup['auth_guest'][$forum_id]) || $rss_setup['forum_allow_auth'] && !isset($rss_setup['forum_exclude'][$forum_id]))) { $url = sprintf($rss_setup['forum_cat_rss'], $_phpbb_seo ? $phpbb_seo->seo_url['forum'][$forum_id] : '', $forum_id); $title = sprintf($rss_setup['l_rss_feed_of'], $forum_name); $links['main']['GYM_RSS_FORUM_LINK'] = sprintf($gym_link_tpl, $url, 'feed-icon.png', $title, $rss_setup['l_rss_feed']); if (!empty($links['setup']['rss']['display_forum_alternate'])) { $links['alternate'][] = array('TITLE' => $title, 'URL' => $url); } $do_display = true; } if (!empty($google_setup['link_cat']) && isset($google_setup['auth_guest'][$forum_id])) { $url = sprintf($google_setup['forum_cat_google'], $_phpbb_seo ? str_replace($_f_sep . $forum_id, '', $phpbb_seo->seo_url['forum'][$forum_id]) . $_f_sep . $forum_id : '', $forum_id); $title = sprintf($google_setup['l_google_sitemap_of'], $forum_name); $links['main']['GYM_GOOGLE_FORUM_LINK'] = sprintf($gym_link_tpl, $url, 'sitemap-icon.gif', $title, $google_setup['l_google_sitemap']); $do_display = true; } } $links['main']['GYM_LINKS_CAT'] = $do_display; } } if (!empty($links['main'])) { $template->assign_vars($links['main']); } if (!empty($links['alternate'])) { foreach ($links['alternate'] as $alternate) { $template->assign_block_vars('gym_rsslinks', $alternate); } } return $links['setup']; }
/** * seo_htaccess The evil one ;-) */ function seo_htaccess($html = true) { global $phpbb_seo, $user, $error, $phpEx, $config, $phpbb_root_path, $config, $phpbb_admin_path; static $htaccess_code = ''; $htaccess_tpl = ''; // GYM Sitemaps & RSS $gym_installed = (bool) (!empty($config['gym_installed']) && file_exists($phpbb_root_path . 'gym_sitemaps/includes/gym_sitemaps.' . $phpEx)); $rss_path = $google_path = $html_path = ''; $rss_commpat_note = $google_commpat_note = $html_commpat_note = $compat_path_note = ''; $rss_commpat_pre = $html_commpat_pre = $google_commpat_pre = '<b style="color:blue"># RewriteRule'; $rss_commpat_post = $html_commpat_post = $google_commpat_post = '</b>'; $google_comp_path = $rss_comp_path = $html_comp_path = false; if ($gym_installed) { $compat_path_note = '<b style="color:red"># NOTE : THE FOLLOWING REWRITERULE IS LEFT COMMENTED BECAUSE IT CANNOT' . "\n"; $compat_path_note .= '# BE IMPLEMENTED IN THIS .HTACCESS, BUT RATHER IN AN ABOVE ONE' . "\n"; $compat_path_note .= '# WITH PROPER SLASHES AND PATHS</b>' . "\n"; $rss_commpat_note = $google_commpat_note = $html_commpat_note = $compat_path_note; require_once $phpbb_root_path . 'gym_sitemaps/includes/gym_common.' . $phpEx; obtain_gym_config('main', $gym_config); $google_url = trim($gym_config['google_url'], '/') . '/'; if (utf8_strpos($google_url, $phpbb_seo->seo_path['phpbb_url']) !== false) { $google_path = trim(str_replace($phpbb_seo->seo_path['root_url'], '', $google_url), '/'); $google_comp_path = true; $google_commpat_pre = '<b style="color:green">RewriteRule</b>'; $google_commpat_post = $google_commpat_note = ''; } $rss_url = trim($gym_config['rss_url'], '/') . '/'; if (utf8_strpos($rss_url, $phpbb_seo->seo_path['phpbb_url']) !== false) { $rss_path = trim(str_replace($phpbb_seo->seo_path['root_url'], '', $rss_url), '/'); $rss_comp_path = true; $rss_commpat_pre = '<b style="color:green">RewriteRule</b>'; $rss_commpat_post = $rss_commpat_note = ''; } $html_url = trim($gym_config['html_url'], '/') . '/'; if (utf8_strpos($html_url, $phpbb_seo->seo_path['phpbb_url']) !== false) { $html_path = trim(str_replace($phpbb_seo->seo_path['root_url'], '', $html_url), '/'); $html_comp_path = true; $html_commpat_pre = '<b style="color:green">RewriteRule</b>'; $html_commpat_post = $html_commpat_note = ''; } } if (empty($htaccess_code)) { // get mods .htaccess tpls $mods_ht = $this->get_mods_ht(); $default_slash = '/'; $wierd_slash = ''; $phpbb_path = trim($phpbb_seo->seo_path['phpbb_script'], '/'); $show_rewritebase_opt = false; $rewritebase = ''; $wierd_slash = $this->new_config['wslash'] ? '<b style="color:red">/</b>' : ''; $default_slash = $this->new_config['slash'] ? '' : '/'; if (!empty($phpbb_path)) { $phpbb_path = $phpbb_path . '/'; if ($this->new_config['rbase']) { $rewritebase = $phpbb_path; $default_slash = $this->new_config['slash'] ? '/' : ''; } $rewritebase = $this->new_config['rbase'] ? $phpbb_path : ''; $show_rewritebase_opt = $phpbb_seo->seo_opt['virtual_root'] ? false : true; } if (!empty($rewritebase)) { $rss_path = trim(str_replace(trim($phpbb_path, '/'), '', $rss_path), '/'); $google_path = trim(str_replace(trim($phpbb_path, '/'), '', $google_path), '/'); $html_path = trim(str_replace(trim($phpbb_path, '/'), '', $html_path), '/'); } $colors = array('color' => '<b style="color:%1$s">%2$s</b>', 'static' => '#A020F0', 'ext' => '#6A5ACD', 'delim' => '#FF00FF'); $tpl = array('paginpage' => '/?(<b style="color:' . $colors['static'] . '">%1$s</b>([0-9]+)<b style="color:' . $colors['ext'] . '">%2$s</b>)?', 'pagin' => '(<b style="color:' . $colors['delim'] . '">%1$s</b>([0-9]+))?<b style="color:' . $colors['ext'] . '">%2$s</b>', 'static' => sprintf($colors['color'], $colors['static'], '%1$s'), 'ext' => sprintf($colors['color'], $colors['ext'], '%1$s'), 'delim' => sprintf($colors['color'], $colors['delim'], '%1$s')); $modrtype = array(1 => 'SIMPLE', 2 => 'MIXED', 1 => 'SIMPLE', 3 => 'ADVANCED', 'type' => intval($phpbb_seo->modrtype)); // $htaccess_tpl = '<b style="color:blue"># Lines That should already be in your .htacess</b>' . "\n"; $htaccess_tpl .= '<b style="color:brown"><Files</b> <b style="color:#FF00FF">"config.{PHP_EX}"</b><b style="color:brown">></b>' . "\n"; $htaccess_tpl .= "\t" . 'Order Allow,Deny' . "\n"; $htaccess_tpl .= "\t" . 'Deny from All' . "\n"; $htaccess_tpl .= '<b style="color:brown"></Files></b>' . "\n"; $htaccess_tpl .= '<b style="color:brown"><Files</b> <b style="color:#FF00FF">"common.{PHP_EX}"</b><b style="color:brown">></b>' . "\n"; $htaccess_tpl .= "\t" . 'Order Allow,Deny' . "\n"; $htaccess_tpl .= "\t" . 'Deny from All' . "\n"; $htaccess_tpl .= '<b style="color:brown"></Files></b>' . "\n\n"; $htaccess_tpl .= '<b style="color:blue"># You may need to un-comment the following lines' . "\n"; $htaccess_tpl .= '# Options +FollowSymlinks' . "\n"; $htaccess_tpl .= '# To make sure that rewritten dir or file (/|.html) will not load dir.php in case it exist' . "\n"; $htaccess_tpl .= '# Options -MultiViews' . "\n"; $htaccess_tpl .= '# REMEBER YOU ONLY NEED TO STARD MOD REWRITE ONCE</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteEngine</b> <b style="color:#FF00FF">On</b>' . "\n"; $htaccess_tpl .= '<b style="color:blue"># Uncomment the statement below if you want to make use of' . "\n"; $htaccess_tpl .= '# HTTP authentication and it does not already work.' . "\n"; $htaccess_tpl .= '# This could be required if you are for example using PHP via Apache CGI.' . "\n"; $htaccess_tpl .= '# RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]</b>' . "\n"; $htaccess_tpl .= '<b style="color:blue"># REWRITE BASE</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteBase</b> <b>/{REWRITEBASE}</b>' . "\n"; $htaccess_tpl .= '<b style="color:blue"># HERE IS A GOOD PLACE TO FORCE CANONICAL DOMAIN</b>' . "\n"; $htaccess_tpl .= '<b style="color:blue"># RewriteCond %{HTTP_HOST} !^' . str_replace(array('https://', 'http://', '.'), array('', '', '\\.'), trim($phpbb_seo->seo_path['root_url'], '/ ')) . '$ [NC]</b>' . "\n"; $htaccess_tpl .= '<b style="color:blue"># RewriteRule ^(.*)$ ' . $phpbb_seo->seo_path['root_url'] . '{REWRITEBASE}$1 [QSA,L,R=301]</b>' . "\n\n"; $htaccess_tpl .= '<b style="color:blue"># DO NOT GO FURTHER IF THE REQUESTED FILE / DIR DOES EXISTS</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteCond</b> %{REQUEST_FILENAME} -f [OR]' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteCond</b> %{REQUEST_FILENAME} -d' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> . - [L]' . "\n"; $htaccess_tpl .= '<b style="color:blue">#####################################################' . "\n"; $htaccess_tpl .= '# PHPBB SEO REWRITE RULES ALL MODES' . "\n"; $htaccess_tpl .= '#####################################################' . "\n"; $htaccess_tpl .= '# AUTHOR : dcz www.phpbb-seo.com' . "\n"; $htaccess_tpl .= '# STARTED : 01/2006' . "\n"; $htaccess_tpl .= '#################################' . "\n"; $htaccess_tpl .= '# FORUMS PAGES' . "\n"; $htaccess_tpl .= '###############</b>' . "\n"; if (!empty($phpbb_seo->seo_static['index'])) { $htaccess_tpl .= '<b style="color:blue"># FORUM INDEX</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_INDEX}{EXT_INDEX}$ {DEFAULT_SLASH}{PHPBB_RPATH}index.{PHP_EX} [QSA,L,NC]' . "\n"; } else { $htaccess_tpl .= '<b style="color:blue"># FORUM INDEX REWRITERULE WOULD STAND HERE IF USED. "forum" REQUIRES TO BE SET AS FORUM INDEX' . "\n"; $htaccess_tpl .= '# RewriteRule ^{WIERD_SLASH}{PHPBB_LPATH}<b style="color:#A020F0">forum</b>\\.<b style="color:#6A5ACD">html</b>$ {DEFAULT_SLASH}{PHPBB_RPATH}index.{PHP_EX} [QSA,L,NC]</b>' . "\n"; } $htaccess_common_tpl = '<b style="color:blue"># PHPBB FILES ALL MODES</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_FILE_INDEX}{DELIM_FILE}[a-z0-9_-]+{DELIM_FILE}({STATIC_THUMB}{DELIM_FILE})?([0-9]+)$ {DEFAULT_SLASH}{PHPBB_RPATH}download/file.{PHP_EX}?id=$2&t=$1 [QSA,L,NC]' . "\n"; if ($phpbb_seo->seo_opt['profile_noids']) { $htaccess_common_tpl .= '<b style="color:blue"># PROFILES THROUGH USERNAME</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_USER}/([^/]+)/?$ {DEFAULT_SLASH}{PHPBB_RPATH}memberlist.{PHP_EX}?mode=viewprofile&un=$1 [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># USER MESSAGES THROUGH USERNAME</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_USER}/([^/]+)/(topics|posts){USER_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}search.{PHP_EX}?author=$1&sr=$2&start=$4 [QSA,L,NC]' . "\n"; } else { $htaccess_common_tpl .= '<b style="color:blue"># PROFILES ALL MODES WITH ID</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}({STATIC_USER}|[a-z0-9_-]*{DELIM_USER})([0-9]+){EXT_USER}$ {DEFAULT_SLASH}{PHPBB_RPATH}memberlist.{PHP_EX}?mode=viewprofile&u=$2 [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># USER MESSAGES ALL MODES WITH ID</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}({STATIC_USER}|[a-z0-9_-]*{DELIM_USER})([0-9]+){DELIM_SR}(topics|posts){USER_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}search.{PHP_EX}?author_id=$2&sr=$3&start=$5 [QSA,L,NC]' . "\n"; } $htaccess_common_tpl .= '<b style="color:blue"># GROUPS ALL MODES</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}({STATIC_GROUP}|[a-z0-9_-]*{DELIM_GROUP})([0-9]+){GROUP_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}memberlist.{PHP_EX}?mode=group&g=$2&start=$4 [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># POST</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_POST}([0-9]+){EXT_POST}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewtopic.{PHP_EX}?p=$1 [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># ACTIVE TOPICS</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_ATOPIC}{ATOPIC_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}search.{PHP_EX}?search_id=active_topics&start=$2&sr=topics [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># UNANSWERED TOPICS</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_UTOPIC}{UTOPIC_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}search.{PHP_EX}?search_id=unanswered&start=$2&sr=topics [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># NEW POSTS</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_NPOST}{NPOST_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}search.{PHP_EX}?search_id=newposts&start=$2&sr=topics [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># UNREAD POSTS</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_URPOST}{URPOST_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}search.{PHP_EX}?search_id=unreadposts&start=$2 [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># THE TEAM</b>' . "\n"; $htaccess_common_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_LEADERS}{EXT_LEADERS}$ {DEFAULT_SLASH}{PHPBB_RPATH}memberlist.{PHP_EX}?mode=leaders [QSA,L,NC]' . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES</b>' . "\n\n"; if ($gym_installed) { $htaccess_common_tpl .= '<b style="color:blue">#####################################################' . "\n"; // RSS $htaccess_common_tpl .= '# GYM Sitemaps & RSS' . "\n"; $htaccess_common_tpl .= '# Global channels</b>' . "\n"; $htaccess_common_tpl .= $rss_commpat_note; $htaccess_common_tpl .= $rss_commpat_pre . ' ^{WIERD_SLASH}{RSS_LPATH}rss(/(news)+)?(/(digest)+)?(/(short|long)+)?/?$ {DEFAULT_SLASH}{RSS_RPATH}gymrss.{PHP_EX}?channels&$2&$4&$6 [QSA,L,NC]' . $rss_commpat_post . "\n"; // HTML $htaccess_common_tpl .= '<b style="color:blue"># HTML Global news & maps</b>' . "\n"; $htaccess_common_tpl .= $html_commpat_note; $htaccess_common_tpl .= $html_commpat_pre . ' ^{WIERD_SLASH}{HTML_LPATH}(news|maps){PAGE_PAGINATION}$ {DEFAULT_SLASH}{HTML_RPATH}map.{PHP_EX}?$1&start=$3 [QSA,L,NC]' . $html_commpat_post . "\n"; $htaccess_common_tpl .= '<b style="color:blue"># END GYM Sitemaps & RSS' . "\n"; $htaccess_common_tpl .= '#####################################################</b>' . "\n\n"; } // We now handle all modes at once (simple / mixed / advanced) $htaccess_tpl .= '<b style="color:blue"># FORUM ALL MODES</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}({STATIC_FORUM}|[a-z0-9_-]*{DELIM_FORUM})([0-9]+){FORUM_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewforum.{PHP_EX}?f=$2&start=$4 [QSA,L,NC]' . "\n"; $htaccess_tpl .= '<b style="color:blue"># TOPIC WITH VIRTUAL FOLDER ALL MODES</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}({STATIC_FORUM}|[a-z0-9_-]*{DELIM_FORUM})([0-9]+)/({STATIC_TOPIC}|[a-z0-9_-]*{DELIM_TOPIC})([0-9]+){TOPIC_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewtopic.{PHP_EX}?f=$2&t=$4&start=$6 [QSA,L,NC]' . "\n"; // Not needed any more // $htaccess_tpl .= '<b style="color:blue"># GLOBAL ANNOUNCEMENTS WITH VIRTUAL FOLDER ALL MODES</b>' . "\n"; // $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}{STATIC_GLOBAL_ANNOUNCE}{EXT_GLOBAL_ANNOUNCE}({STATIC_TOPIC}|[a-z0-9_-]*{DELIM_TOPIC})([0-9]+){TOPIC_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewtopic.{PHP_EX}?t=$2&start=$4 [QSA,L,NC]' . "\n"; $htaccess_tpl .= '<b style="color:blue"># TOPIC WITHOUT FORUM ID & DELIM ALL MODES</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}([a-z0-9_-]*)/?({STATIC_TOPIC}|[a-z0-9_-]*{DELIM_TOPIC})([0-9]+){TOPIC_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewtopic.{PHP_EX}?forum_uri=$1&t=$3&start=$5 [QSA,L,NC]' . "\n"; $htaccess_tpl .= $htaccess_common_tpl; // mods .htaccess pos1 if (!empty($mods_ht['pos1'])) { $htaccess_tpl .= $mods_ht['pos1']; } $htaccess_tpl .= '<b style="color:blue"># FORUM WITHOUT ID & DELIM ALL MODES</b>' . "\n"; if (trim($phpbb_seo->seo_ext['forum'], '/')) { $htaccess_tpl .= '<b style="color:blue"># THESE FOUR LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteCond</b> %{REQUEST_FILENAME} !-f' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}([a-z0-9_-]+)(-([0-9]+)){EXT_FORUM}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewforum.{PHP_EX}?forum_uri=$1&start=$3 [QSA,L,NC]' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteCond</b> %{REQUEST_FILENAME} !-f' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}([a-z0-9_-]+){EXT_FORUM}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewforum.{PHP_EX}?forum_uri=$1 [QSA,L,NC]' . "\n"; } else { $htaccess_tpl .= '<b style="color:blue"># THESE THREE LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteCond</b> %{REQUEST_FILENAME} !-f' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteCond</b> %{REQUEST_FILENAME} !-d' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_LPATH}([a-z0-9_-]+){FORUM_PAGINATION}$ {DEFAULT_SLASH}{PHPBB_RPATH}viewforum.{PHP_EX}?forum_uri=$1&start=$3 [QSA,L,NC]' . "\n"; } // fix for dumb clients unable to deal with base href $htaccess_tpl .= '<b style="color:blue"># FIX RELATIVE PATHS : FILES</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_RPATH}.+/(style\\.{PHP_EX}|ucp\\.{PHP_EX}|mcp\\.{PHP_EX}|faq\\.{PHP_EX}|download/file.{PHP_EX})$ {DEFAULT_SLASH}{PHPBB_RPATH}$1 [QSA,L,NC,R=301]' . "\n"; $htaccess_tpl .= '<b style="color:blue"># FIX RELATIVE PATHS : IMAGES</b>' . "\n"; $htaccess_tpl .= '<b style="color:green">RewriteRule</b> ^{WIERD_SLASH}{PHPBB_RPATH}.+/(styles/.*|images/.*)/$ {DEFAULT_SLASH}{PHPBB_RPATH}$1 [QSA,L,NC,R=301]' . "\n"; $htaccess_tpl .= '<b style="color:blue"># END PHPBB PAGES' . "\n"; $htaccess_tpl .= '#####################################################</b>' . "\n\n"; // mods .htaccess pos2 if (!empty($mods_ht['pos2'])) { $htaccess_tpl .= $mods_ht['pos2']; } if ($gym_installed) { $htaccess_tpl .= '<b style="color:blue">#####################################################' . "\n"; $htaccess_tpl .= '# GYM Sitemaps & RSS</b>' . "\n"; // HTML $htaccess_tpl .= '<b style="color:blue"># HTML Module additional modes</b>' . "\n"; $htaccess_tpl .= $html_commpat_note; $htaccess_tpl .= $html_commpat_pre . ' ^{WIERD_SLASH}{HTML_LPATH}(news|maps)/([a-z0-9_-]+)(/([a-z0-9_-]+))?{PAGE_PAGINATION}$ {DEFAULT_SLASH}{HTML_RPATH}map.{PHP_EX}?$2=$4&$1&start=$6 [QSA,L,NC]' . $html_commpat_post . "\n"; // RSS $htaccess_tpl .= '<b style="color:blue"># Main feeds & channels</b>' . "\n"; $htaccess_tpl .= $rss_commpat_note; $htaccess_tpl .= $rss_commpat_pre . ' ^{WIERD_SLASH}{RSS_LPATH}rss(/(news)+)?(/(digest)+)?(/(short|long)+)?(/([a-z0-9_-]+))?/([a-z0-9_]+)\\.xml(\\.gz)?$ {DEFAULT_SLASH}{RSS_RPATH}gymrss.{PHP_EX}?$9=$8&$2&$4&$6&gzip=$10 [QSA,L,NC]' . $rss_commpat_post . "\n"; $htaccess_tpl .= '<b style="color:blue"># Module feeds</b>' . "\n"; $htaccess_tpl .= $rss_commpat_note; $htaccess_tpl .= $rss_commpat_pre . ' ^{WIERD_SLASH}{RSS_LPATH}[a-z0-9_-]*-[a-z]{1,2}([0-9]+)(/(news)+)?(/(digest)+)?(/(short|long)+)?/([a-z0-9_]+)\\.xml(\\.gz)?$ {DEFAULT_SLASH}{RSS_RPATH}gymrss.{PHP_EX}?$8=$1&$3&$5&$7&gzip=$9 [QSA,L,NC]' . $rss_commpat_post . "\n"; $htaccess_tpl .= '<b style="color:blue"># Module feeds without ids</b>' . "\n"; $htaccess_tpl .= $rss_commpat_note; $htaccess_tpl .= $rss_commpat_pre . ' ^{WIERD_SLASH}{RSS_LPATH}([a-z0-9_-]+)(/(news)+)?(/(digest)+)?(/(short|long)+)?/([a-z0-9_]+)\\.xml(\\.gz)?$ {DEFAULT_SLASH}{RSS_RPATH}gymrss.{PHP_EX}?nametoid=$1&$3&$5&$7&modulename=$8&gzip=$9 [QSA,L,NC]' . $rss_commpat_post . "\n"; // Google $htaccess_tpl .= '<b style="color:blue"># Google SitemapIndex</b>' . "\n"; $htaccess_tpl .= $google_commpat_note; $htaccess_tpl .= $google_commpat_pre . ' ^{WIERD_SLASH}{GOOGLE_LPATH}sitemapindex\\.xml(\\.gz)?$ {DEFAULT_SLASH}{GOOGLE_RPATH}sitemap.{PHP_EX}?gzip=$1 [QSA,L,NC]' . $google_commpat_post . "\n"; $htaccess_tpl .= '<b style="color:blue"># Module cat sitemaps</b>' . "\n"; $htaccess_tpl .= $google_commpat_note; $htaccess_tpl .= $google_commpat_pre . ' ^{WIERD_SLASH}{GOOGLE_LPATH}[a-z0-9_-]+-([a-z]{1,2})([0-9]+)\\.xml(\\.gz)?$ {DEFAULT_SLASH}{GOOGLE_RPATH}sitemap.{PHP_EX}?module_sep=$1&module_sub=$2&gzip=$3 [QSA,L,NC]' . $google_commpat_post . "\n"; $htaccess_tpl .= '<b style="color:blue"># Module sitemaps</b>' . "\n"; $htaccess_tpl .= $google_commpat_note; $htaccess_tpl .= $google_commpat_pre . ' ^{WIERD_SLASH}{GOOGLE_LPATH}([a-z0-9_]+)-([a-z0-9_-]+)\\.xml(\\.gz)?$ {DEFAULT_SLASH}{GOOGLE_RPATH}sitemap.{PHP_EX}?$1=$2&gzip=$3 [QSA,L,NC]' . $google_commpat_post . "\n"; $htaccess_tpl .= '<b style="color:blue"># END GYM Sitemaps & RSS' . "\n"; $htaccess_tpl .= '#####################################################</b>' . "\n"; } if (!empty($default_slash) && $this->new_config['more_options']) { $default_slash = '<b style="color:red">' . $default_slash . '</b>'; } // The tpl array $htaccess_tpl_vars = array(); // handle the suffixes proper in the RegEx // set up pagination reg ex // set up ext bits $seo_ext = array('pagination' => trim($phpbb_seo->seo_ext['pagination'], '/') ? str_replace('.', '\\.', $phpbb_seo->seo_ext['pagination']) : '/'); $reg_ex_page = sprintf($tpl['paginpage'], $phpbb_seo->seo_static['pagination'], $seo_ext['pagination'] . ($seo_ext['pagination'] === '/' ? '?' : '')); foreach ($phpbb_seo->seo_ext as $type => $value) { $_value = trim($value, '/'); // force '/' for both / and empty ext to add /? in RegEx (which allows both cases) $seo_ext[$type] = $_value ? str_replace('.', '\\.', $value) : '/'; $htaccess_tpl_vars['{' . strtoupper($type) . '_PAGINATION}'] = $_value ? sprintf($tpl['pagin'], $phpbb_seo->seo_delim['start'], $seo_ext[$type]) : $reg_ex_page; // use url/? to allow both url and url/ to work as expected $htaccess_tpl_vars['{EXT_' . strtoupper($type) . '}'] = sprintf($tpl['ext'], $seo_ext[$type]) . ($_value ? '' : '?'); } $htaccess_tpl_vars['{PAGE_PAGINATION}'] = $reg_ex_page; // static bits foreach ($phpbb_seo->seo_static as $type => $value) { if (!is_array($phpbb_seo->seo_static[$type])) { $htaccess_tpl_vars['{STATIC_' . strtoupper($type) . '}'] = sprintf($tpl['static'], $phpbb_seo->seo_static[$type]); } } // delim bits foreach ($phpbb_seo->seo_delim as $type => $value) { $htaccess_tpl_vars['{DELIM_' . strtoupper($type) . '}'] = sprintf($tpl['delim'], $phpbb_seo->seo_delim[$type]); } // common .htaccess vars $htaccess_tpl_vars += array('{REWRITEBASE}' => $rewritebase, '{PHP_EX}' => $phpEx, '{PHPBB_LPATH}' => $this->new_config['rbase'] || $phpbb_seo->seo_opt['virtual_root'] ? '' : $phpbb_path, '{PHPBB_RPATH}' => $this->new_config['rbase'] ? '' : $phpbb_path, '{RSS_LPATH}' => $rss_path ? $rss_path . '/' : '', '{RSS_RPATH}' => $rss_path ? $rss_path . '/' : '', '{GOOGLE_LPATH}' => $google_path ? $google_path . '/' : '', '{GOOGLE_RPATH}' => $google_path ? $google_path . '/' : '', '{HTML_LPATH}' => $html_path ? $html_path . '/' : '', '{HTML_RPATH}' => $html_path ? $html_path . '/' : '', '{DEFAULT_SLASH}' => $default_slash, '{WIERD_SLASH}' => $wierd_slash, '{MOD_RTYPE}' => $modrtype[$modrtype['type']]); // Parse .htaccess $htaccess_code = str_replace(array_keys($htaccess_tpl_vars), array_values($htaccess_tpl_vars), $htaccess_tpl); } // else the .htaccess is already generated if ($html) { // HTML output $htaccess_output = "\n" . '<script type="text/javascript">' . "\n"; $htaccess_output .= '// <![CDATA[' . "\n"; $htaccess_output .= 'function selectCode(a) {' . "\n"; $htaccess_output .= "\t" . 'var e = a.parentNode.parentNode.getElementsByTagName(\'CODE\')[0]; // Get ID of code block' . "\n"; $htaccess_output .= "\t" . 'if (window.getSelection) { // Not IE' . "\n"; $htaccess_output .= "\t\t" . 'var s = window.getSelection();' . "\n"; $htaccess_output .= "\t\t" . 'if (s.setBaseAndExtent) { // Safari' . "\n"; $htaccess_output .= "\t\t\t" . 's.setBaseAndExtent(e, 0, e, e.innerText.length - 1);' . "\n"; $htaccess_output .= "\t\t" . '} else { // Firefox and Opera' . "\n"; $htaccess_output .= "\t\t\t" . 'var r = document.createRange();' . "\n"; $htaccess_output .= "\t\t\t" . 'r.selectNodeContents(e);' . "\n"; $htaccess_output .= "\t\t\t" . 's.removeAllRanges();' . "\n"; $htaccess_output .= "\t\t\t" . 's.addRange(r);' . "\n"; $htaccess_output .= "\t\t" . '}' . "\n"; $htaccess_output .= "\t" . '} else if (document.getSelection) { // Some older browsers' . "\n"; $htaccess_output .= "\t\t" . 'var s = document.getSelection();' . "\n"; $htaccess_output .= "\t\t" . 'var r = document.createRange();' . "\n"; $htaccess_output .= "\t\t" . 'r.selectNodeContents(e);' . "\n"; $htaccess_output .= "\t\t" . 's.removeAllRanges();' . "\n"; $htaccess_output .= "\t\t" . 's.addRange(r);' . "\n"; $htaccess_output .= "\t" . '} else if (document.selection) { // IE' . "\n"; $htaccess_output .= "\t\t" . 'var r = document.body.createTextRange();' . "\n"; $htaccess_output .= "\t\t" . 'r.moveToElementText(e);' . "\n"; $htaccess_output .= "\t\t" . 'r.select();' . "\n"; $htaccess_output .= "\t" . '}' . "\n"; $htaccess_output .= '}' . "\n"; $htaccess_output .= '// ]]>' . "\n"; $htaccess_output .= '</script>' . "\n"; // build location message if ($show_rewritebase_opt && $this->new_config['rbase']) { $msg_loc = sprintf($user->lang['SEO_HTACCESS_FOLDER_MSG'], '<em style="color:#000">' . $phpbb_seo->seo_path['phpbb_url'] . '</em>'); } else { $msg_loc = sprintf($user->lang['SEO_HTACCESS_ROOT_MSG'], '<em style="color:#000">' . $phpbb_seo->seo_path['root_url'] . '</em>'); } $htaccess_output .= '</p><div class="content"><hr/>' . "\n" . '<b style="color:red">⇒ ' . $msg_loc . '</b><br/><br/><hr/>' . "\n"; $htaccess_output .= '<b>.htaccess : <a href="#" onclick="dE(\'htaccess_code\',1); return false;">' . $user->lang['SEO_SHOW'] . '</a> / <a href="#" onclick="dE(\'htaccess_code\',-1); return false;">' . $user->lang['SEO_HIDE'] . '</a></b>' . "\n"; $htaccess_output .= '<div id="htaccess_code"><dl style="padding:5px;background-color:#FFFFFF;border:1px solid #d8d8d8;font-size:12px;"><dt style="border-bottom:1px solid #CCCCCC;margin-bottom:3px;font-weight:bold;display:block;"> <a href="#" onclick="selectCode(this); return false;">' . $user->lang['SEO_SELECT_ALL'] . '</a></dt>' . "\n"; $htaccess_output .= '<dd ><code style="padding-top:5px;line-height:1.3em;color:#8b8b8b;font-weight:bold"><br/><br/>' . str_replace("\n", '<br/>', $htaccess_code) . '</code></dd>' . "\n"; $htaccess_output .= '</dl>' . "\n"; $htaccess_output .= '<div style="padding:5px;margin-top:10px;background-color:#FFFFFF;border:1px solid #d8d8d8;font-size:12px;"><b>' . $user->lang['SEO_HTACCESS_CAPTION'] . ':</b><ul style="margin-left:30px;margin-top:10px;font-weight:bold;font-size:12px;">' . "\n"; $htaccess_output .= '<li style="color:blue"> ' . $user->lang['SEO_HTACCESS_CAPTION_COMMENT'] . '</li>' . "\n"; $htaccess_output .= '<li style="color:#A020F0"> ' . $user->lang['SEO_HTACCESS_CAPTION_STATIC'] . '</li>' . "\n"; $htaccess_output .= '<li style="color:#6A5ACD"> ' . $user->lang['SEO_HTACCESS_CAPTION_SUFFIX'] . '</li>' . "\n"; $htaccess_output .= '<li style="color:#FF00FF"> ' . $user->lang['SEO_HTACCESS_CAPTION_DELIM'] . '</li>' . "\n"; if ($this->new_config['more_options']) { $htaccess_output .= '<li style="color:red"> ' . $user->lang['SEO_HTACCESS_CAPTION_SLASH'] . '</li> ' . "\n"; } $htaccess_output .= '</ul></div>' . "\n" . '</div></div><p>' . "\n"; } else { // File output $htaccess_output = str_replace(array('<', '>', '&'), array('<', '>', '&'), strip_tags($htaccess_code)); } return $htaccess_output; }
/** * Constructor */ function main($id, $mode) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $phpbb_seo, $_action_types; require_once $phpbb_root_path . 'gym_sitemaps/includes/gym_common.' . $phpEx; // Start the phpbb_seo class if (!is_object($phpbb_seo)) { if (file_exists($phpbb_root_path . 'phpbb_seo/phpbb_seo_class.' . $phpEx)) { require_once $phpbb_root_path . 'phpbb_seo/phpbb_seo_class.' . $phpEx; } else { require_once $phpbb_root_path . 'gym_sitemaps/includes/phpbb_seo_class_light.' . $phpEx; } $phpbb_seo = new phpbb_seo(); } $user->add_lang('gym_sitemaps/acp/gym_common'); // action=(module|cache|modrewrite...)&module=(main|forum| ...) $action = request_var('action', 'main'); $module = request_var('module', 'main'); // maction =(settings|maintenance|save)&action=(module|cache|modrewrite...)&module=(main|forum| ...) $maction = request_var('maction', ''); $mactions = array('settings', 'maintenance', 'install'); $maction = in_array($maction, $mactions) ? $maction : ''; $submit = isset($_POST['submit']) ? true : false; $this->modes = $_action_types; $this->override_type = $_override_types; $this->override = array(); // Filter allowed modes $this->mode = $mode; $this->module = $module; $this->action = $action; $this->maction = $maction; $this->set_phpbb_seo_links(); // Get gym config obtain_gym_config('main', $this->gym_config); $this->new_config = $this->gym_config; // define common validation arrays $this->dyn_select['modrtype'] = array(0 => 'GYM_MODREWRITE_NONE', 1 => 'GYM_MODREWRITE_SIMPLE', 2 => 'GYM_MODREWRITE_MIXED', 3 => 'GYM_MODREWRITE_ADVANCED'); $this->dyn_select['gzip_level'] = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9); $this->dyn_select['sort'] = array('DESC' => 'GYM_DESC', 'ASC' => 'GYM_ASC'); $this->dyn_select['override'] = array(OVERRIDE_GLOBAL => 'GYM_OVERRIDE_GLOBAL', OVERRIDE_OTYPE => 'GYM_OVERRIDE_OTYPE', OVERRIDE_MODULE => 'GYM_OVERRIDE_MODULE'); $this->dyn_select['sumarize_method'] = array('chars' => 'GYM_METHOD_CHARS', 'words' => 'GYM_METHOD_WORDS', 'lines' => 'GYM_METHOD_LINES'); $this->dyn_select['gym_auth'] = array('admin' => 'GYM_AUTH_ADMIN', 'globalmod' => 'GYM_AUTH_GLOBALMOD', 'reg' => 'GYM_AUTH_REG', 'guest' => 'GYM_AUTH_GUEST', 'all' => 'GYM_AUTH_ALL', 'none' => 'GYM_AUTH_NONE'); $this->dyn_select['rss_linking_types'] = array('n' => 'RSS_LINKING_NEWS', 'nd' => 'RSS_LINKING_NEWS_DIGEST', 'r' => 'RSS_LINKING_REGULAR', 'rd' => 'RSS_LINKING_REGULAR_DIGEST'); // Get the module list // Populate the $this->gym_modules[$mode][$module] array $this->gym_get_modules($mode); // Load the relevant modules acp options // Populate the $this->gym_modules_acp[$mode][$module] array $this->gym_module_acp($mode, $module); // Acp options array for this case $display_vars = $error = array(); // salt the form $form_key = 'acp_gym'; add_form_key($form_key); // check form salt if ($submit && !check_form_key($form_key)) { $error[] = $user->lang['FORM_INVALID']; $submit = false; } // Cache management if ($maction === 'maintenance') { $display_vars = $this->gym_maintenance($mode, $module, $action, $submit); $submit = false; } elseif ($maction === 'settings') { // settings management $display_vars = $this->gym_set_default($mode, $module, $action, $submit); $submit = false; } elseif ($maction === 'install') { // module install $display_vars = $this->gym_install($mode, $module, $action, $submit); $submit = false; } else { if (!in_array($mode, $this->modes) || !in_array($module, $this->gym_modules[$mode])) { trigger_error('NO_MODE', E_USER_ERROR); } else { $script_to_check = array(); if (empty($this->gym_modules_acp[$mode][$module][$action]['display_vars'])) { $action = $this->action = 'main'; } // here we'll check if the GYM script urls are consistent if (!$submit) { $this->check_scripts($error, $this->gym_config, $mode); } $display_vars = $this->gym_modules_acp[$mode][$module][$action]['display_vars']; // Check if we do not have a new module needing a new config key $clear_cache = false; foreach ($display_vars['vars'] as $key => $value) { if (!isset($this->gym_config[$key]) && strpos($key, 'legend') === false) { $clear_cache = true; if (isset($this->gym_modules_acp[$mode][$module][$action]['default'][$key])) { $this->new_config[$key] = $this->gym_modules_acp[$mode][$module][$action]['default'][$key]; set_gym_config($key, $this->new_config[$key], $mode, $this->gym_config); } } } if ($clear_cache) { $this->remove_cache('config'); } } } // Load the module's language files foreach ($this->gym_modules_acp[$mode] as $active_modules => $null) { if (!empty($this->gym_modules_acp[$mode][$active_modules]['info']['lang_file'])) { $user->add_lang('gym_sitemaps/acp/' . $this->gym_modules_acp[$mode][$active_modules]['info']['lang_file']); } } $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config; // We validate the complete config if whished validate_config_vars($display_vars['vars'], $cfg_array, $error); // check script urls if necessary if ($submit && isset($cfg_array[$mode . '_url'])) { // will enforce trailing slashes automatically $this->check_scripts($error, $cfg_array, $mode); } // Do not write values if there is an error if (sizeof($error)) { $submit = false; } // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $cfg_setup) { if (!isset($cfg_array[$config_name]) && @$cfg_setup['method'] != 'select_multiple_string' || strpos($config_name, 'legend') !== false) { continue; } // Handle multiple select options if (!empty($cfg_setup['method']) && $cfg_setup['method'] == 'select_multiple_string') { if (isset($_POST['multiple_' . $config_name])) { $m_values = utf8_normalize_nfc(request_var('multiple_' . $config_name, array('' => ''))); $validate_int = $cfg_setup['multiple_validate'] == 'int' ? true : false; foreach ($m_values as $k => $v) { if ($validate_int) { $v = (int) $v; } if (empty($v)) { unset($m_values[$k]); } else { $m_values[$k] = $v; } } sort($m_values); $this->new_config[$config_name] = $m_values; $config_value = implode(',', $m_values); if (strlen($config_value) > 255) { $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$cfg_setup['lang']], 255); } $submit = empty($error); } else { if ($submit) { $this->new_config[$config_name] = array(); $config_value = ''; } else { $config_value = $this->new_config[$config_name]; $this->new_config[$config_name] = !empty($config_value) ? explode(',', $config_value) : array(); } } } else { $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; } if ($submit) { set_gym_config($config_name, $config_value, $mode, $this->gym_config); } } if ($submit) { $this->remove_cache('config'); add_log('admin', 'GYM_LOG_CONFIG_' . strtoupper($mode)); trigger_error($user->lang['CONFIG_UPDATED'] . $this->back_to_prev()); } $this->tpl_name = 'acp_gym_sitemaps'; $this->page_title = $display_vars['title']; // add the maitenance links $maintenance_links = ''; $maintenance_links .= '<a href="' . $this->u_action . '&maction=maintenance&action=' . $action . '&module=' . $module . '"><b style="color:red;">' . $user->lang['GYM_MAINTENANCE'] . '</b></a><b> • </b>'; $maintenance_links .= '<a href="' . $this->u_action . '&maction=settings&action=' . $action . '&module=' . $module . '"><b style="color:red;">' . $user->lang['GYM_SETTINGS'] . '</b></a>'; $install_link = $mode !== 'main' ? '<b> • </b><a href="' . $this->u_action . '&maction=install&action=' . $action . '&module=' . $module . '"><b style="color:red;">' . $user->lang['GYM_INSTALL'] . '</b></a>' : ''; if ($action === 'gzip') { // Adjust language variable a bit $user->lang['GYM_GZIP_EXPLAIN'] = sprintf($user->lang['GYM_GZIP_EXPLAIN'], $config['gzip_compress'] ? $user->lang['GYM_GZIP_FORCED'] : $user->lang['GYM_GZIP_CONFIGURABLE']); } $lang_key = 'GYM_' . strtoupper($mode); $l_mode_title = $this->safe_lang($lang_key); $l_mode_title_explain = $this->safe_lang($lang_key . '_EXPLAIN'); $lang_key = $this->gym_modules_acp[$mode][$module]['info']['title_lang']; $l_module_title = $this->safe_lang($lang_key); $l_module_title_explain = $this->safe_lang($lang_key . '_EXPLAIN'); $l_title = $this->safe_lang($display_vars['title']); $l_title_explain = $this->safe_lang($display_vars['title'] . '_EXPLAIN'); $l_title_explain .= $action === 'cache' && $mode !== 'html' ? $this->check_cache_folder($phpbb_root_path . 'gym_sitemaps/cache') : ''; $template->assign_vars(array('L_MODE_TITLE' => $l_mode_title, 'L_MODE_ITLE_EXPLAIN' => $l_mode_title_explain, 'L_MODULE_TITLE' => $l_module_title, 'L_MODULE_ITLE_EXPLAIN' => $l_module_title_explain, 'L_TITLE' => $l_title, 'L_TITLE_EXPLAIN' => $l_title_explain, 'GYM_VERSION' => $this->gym_config['gym_version'], 'INSTALL_LINK' => $install_link, 'MAINTENANCE_LINKS' => $maintenance_links, 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'S_SUBMIT_BUTTON' => !empty($this->gym_modules_acp[$mode][$module][$action]['default']), 'U_ACTION' => $this->u_action . '&maction=' . $maction . '&action=' . $action . '&module=' . $module)); $this->gym_module_menu($mode, $module, $action); $this->gym_menu($mode, $module, $action); // Output relevant page foreach ($display_vars['vars'] as $config_key => $vars) { if (!is_array($vars) && strpos($config_key, 'legend') === false) { continue; } if (strpos($config_key, 'legend') !== false) { $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => $this->safe_lang($vars))); continue; } $type = explode(':', $vars['type']); $l_explain = ''; if ($vars['explain'] && isset($vars['lang_explain'])) { $l_explain = $this->safe_lang($vars['lang_explain']); } elseif ($vars['explain']) { $l_explain = $this->safe_lang($vars['lang'] . '_EXPLAIN'); } // Add overriding infos $form = true; if (isset($vars['overriding']) && $vars['overriding']) { $vars['append'] = $this->is_overriden($mode, $module, $action, $config_key, $vars); //$form = $vars['append'] == $this->safe_lang('GYM_COULD_OVERRIDE') ? true : false; } $content = ''; $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => $this->safe_lang($vars['lang']), 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $form ? build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars) : $vars['append'])); unset($display_vars['vars'][$config_key]); } }
function main($mode, $sub) { global $user, $template, $phpbb_root_path, $phpbb_seo, $phpEx, $cache, $db; switch ($mode) { case 'install_gym_sitemaps': $this->uninst_prefix = ''; break; case 'update_gym_sitemaps': obtain_gym_config('main', $this->old_config); if (!empty($this->old_config)) { $this->uninst_prefix = 'UPDATE_'; } else { $this->p_master->error($user->lang['SEO_ERROR_NOTINSTALLED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->p_master->module_url . '">', '</a>'), '', '', false, $user->lang['SEO_ERROR_INFO']); exit; } break; case 'uninstall_gym_sitemaps': $this->uninst_prefix = 'UN_'; break; } switch ($sub) { case 'intro': $this->page_title = $user->lang['SUB_INTRO']; $template->assign_vars(array('TITLE' => $user->lang[$this->uninst_prefix . 'SEO_INSTALL_INTRO'], 'BODY' => sprintf($user->lang[$this->uninst_prefix . 'SEO_INSTALL_INTRO_BODY'], @$this->modrtype_lang['link'], $this->version), 'L_SUBMIT' => $user->lang[$this->uninst_prefix . 'SEO_INSTALL'], 'S_LANG_SELECT' => '', 'U_ACTION' => $this->p_master->module_url . "?mode={$mode}&sub=final")); break; case 'final': if ($mode != 'uninstall_gym_sitemaps') { $update = $mode == 'update_gym_sitemaps' ? true : false; if (!$update) { $this->add_modules($mode, $sub); $this->install_tables($mode); } $gym_modules = $gym_modules_acp = array(); foreach ($this->action_types as $otype) { // List all output types (sitemaps, rss, html, yahoo ...) $dir = opendir($phpbb_root_path . 'gym_sitemaps/acp'); while (($file = readdir($dir)) !== FALSE) { // Look for available mocules if (preg_match('`^' . $otype . '_([a-z0-9_-]+)\\.' . $phpEx . '$`i', $file, $matches)) { $type_module = trim(str_replace('.' . $phpEx, '', $file), "/"); $_module = str_replace($otype . '_', '', $type_module); if ($matches[1] === 'main' || file_exists($phpbb_root_path . 'gym_sitemaps/modules/' . $file)) { $gym_modules[$otype][$_module] = $type_module; } } } closedir($dir); foreach ($gym_modules[$otype] as $_module => $type_module) { // List all available modules $module_file = $phpbb_root_path . 'gym_sitemaps/acp/' . $type_module . '.' . $phpEx; if (file_exists($module_file)) { if (!class_exists($type_module)) { require $module_file; } if (class_exists($type_module)) { $gym_module = new $type_module($this); if (method_exists($gym_module, 'acp_module')) { // Looks like we match $gym_modules_acp[$otype][$_module] = $gym_module->acp_module(); foreach ($gym_modules_acp[$otype][$_module]['info']['actions'] as $module_action) { // list the module's options sets foreach ($gym_modules_acp[$otype][$_module][$module_action]['default'] as $module_config => $default_value) { // In the end list possible options for this module for this module's options set if (!isset($this->old_config[$module_config])) { // Update config set_gym_config($module_config, $default_value, $otype, $this->old_config); $this->config_report[] = "SET <b>{$module_config}</b> to {$default_value}"; } } } if (!isset($this->old_config[$type_module . '_installed'])) { // Set the module as installed set_gym_config($type_module . '_installed', 1, 'main', $this->old_config); $this->config_report[] = "ACTIVATED <b>{$type_module} module</b>"; } } } } } } } else { $this->remove_modules($mode, $sub); $this->install_tables($mode); } if (@method_exists($cache, 'purge')) { $cache->purge(); } $this->final_stage($mode, $sub); break; } $this->tpl_name = 'install_install'; }