/** * html_index() * Add local links to the main site map * @access private */ function html_index() { global $user; // We need to take care about overrides $override = $this->gym_master->gym_config['html_override']; $forum_allow_cat_map = (bool) get_gym_option('html', 'forum', 'allow_cat_map', $override, $this->gym_master->gym_config); $forum_allow_cat_news = (bool) get_gym_option('html', 'forum', 'allow_cat_news', $override, $this->gym_master->gym_config); $forum_allow_map = (bool) get_gym_option('html', 'forum', 'allow_map', $override, $this->gym_master->gym_config); $forum_allow_news = (bool) get_gym_option('html', 'forum', 'allow_news', $override, $this->gym_master->gym_config); if (!$forum_allow_cat_map && !$forum_allow_cat_news && !$forum_allow_map && !$forum_allow_news) { return; } $this->outputs['module_data']['forum'] = array('title' => $this->gym_master->gym_config['html_forum_sitename'], 'desc' => $this->gym_master->gym_config['html_forum_site_desc'], 'img' => '', 'map_url' => $forum_allow_map && ($forum_allow_cat_map || $forum_allow_cat_news) ? $this->module_config['html_url'] . $this->url_settings['html_forum_map'] : false, 'news_url' => $forum_allow_news ? $this->module_config['html_url'] . $this->url_settings['html_forum_news'] : false, 'links' => array()); // Add other supported links such as global annoucements etc ... if ($forum_allow_map || $forum_allow_news) { $links =& $this->outputs['module_data']['forum']['links']; $linkables = array('html_forum', 'html_forum_global', 'html_forum_announce', 'html_forum_sticky'); foreach ($linkables as $type) { $links[$type] = array('map_title' => $forum_allow_news ? $user->lang[strtoupper($type . '_map')] : '', 'map_url' => $forum_allow_news ? $this->url_settings[$type . '_map'] : '', 'news_title' => $forum_allow_map ? $user->lang[strtoupper($type . '_news')] : '', 'news_url' => $forum_allow_map ? $this->url_settings[$type . '_news'] : ''); } } return; }
/** * get_gym_links($gym_config). * retunrs the link array */ function get_gym_links($gym_config) { global $phpbb_root_path, $config, $phpEx, $user, $cache, $db, $phpbb_seo; $links = array(); $_phpbb_seo = !empty($phpbb_seo); $board_url = $_phpbb_seo ? $phpbb_seo->seo_path['phpbb_url'] : generate_board_url() . '/'; $gym_link_tpl = '<a href="%1$s" title="%3$s" class="gym"><img src="' . $board_url . 'gym_sitemaps/images/%2$s" alt="%3$s" width="14" height="14"/> %3$s</a>'; $google_threshold = max(1, (int) $gym_config['google_threshold']); //compute guest auth $cache_file = '_gym_auth_guests_forum'; if (($auth_guest_list = $cache->get($cache_file)) === false) { $auth_guest_list = array('list' => array(), 'read' => array(), 'list_post' => array(), 'read_post' => array(), 'skip_pass' => array(), 'skip_cat' => array(), 'skip_all' => array(), 'skip_link' => array(), 'thresholded' => array(), 'empty' => array()); $guest_data = array('user_id' => ANONYMOUS, 'user_type' => USER_IGNORE, 'user_permissions' . (defined('XLANG_AKEY') ? XLANG_AKEY : '') => ''); $g_auth = new auth(); $g_auth->acl($guest_data); // the forum id array $forum_list_ary = $g_auth->acl_getf('f_list', true); foreach ($forum_list_ary as $forum_id => $null) { $auth_guest_list['list'][$forum_id] = (int) $forum_id; } $forum_read_ary = $g_auth->acl_getf('f_read', true); foreach ($forum_read_ary as $forum_id => $null) { $auth_guest_list['read'][$forum_id] = (int) $forum_id; } ksort($auth_guest_list['list']); ksort($auth_guest_list['read']); $sql = "SELECT forum_id, forum_type, forum_password\n\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\tWHERE\tforum_type <> " . FORUM_POST . " OR forum_password <> ''"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_id = (int) $row['forum_id']; if ($row['forum_password']) { $auth_guest_list['skip_pass'][$forum_id] = $forum_id; } if ($row['forum_type'] == FORUM_CAT) { $auth_guest_list['skip_cat'][$forum_id] = $forum_id; } else { if ($row['forum_type'] == FORUM_LINK) { $auth_guest_list['skip_link'][$forum_id] = $forum_id; } } $auth_guest_list['skip_all'][$forum_id] = $forum_id; } $db->sql_freeresult($result); // Now let's grabb the list of forum with not enough topics to have a sitemap // Only care about postable forum ;-) $sql = "SELECT forum_id, forum_topics\n\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\tWHERE\tforum_type = " . FORUM_POST . "\n\t\t\t\tAND forum_topics < {$google_threshold}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_id = (int) $row['forum_id']; $auth_guest_list['thresholded'][$forum_id] = $forum_id; if (empty($row['forum_topics'])) { $auth_guest_list['empty'][$forum_id] = $forum_id; } } ksort($auth_guest_list['skip_pass']); ksort($auth_guest_list['skip_all']); ksort($auth_guest_list['skip_link']); ksort($auth_guest_list['skip_cat']); // Never mind about forum links $auth_guest_list['read'] = array_diff_assoc($auth_guest_list['read'], $auth_guest_list['skip_link']); $auth_guest_list['list'] = array_diff_assoc($auth_guest_list['list'], $auth_guest_list['skip_link']); ksort($auth_guest_list['read']); ksort($auth_guest_list['list']); $auth_guest_list['list_post'] = array_diff_assoc($auth_guest_list['list'], $auth_guest_list['skip_all']); $auth_guest_list['read_post'] = array_diff_assoc($auth_guest_list['read'], $auth_guest_list['skip_all']); $cache->put($cache_file, $auth_guest_list); } $links = array(); $links['main'] = $links['setup']['google'] = $links['setup']['rss'] = $links['setup']['html'] = array(); // Find out about active modes $google_active = $rss_active = $html_active = false; $gym_modules = array('google' => array('forum', 'xml', 'txt'), 'rss' => array('forum'), 'html' => array('forum')); foreach ($gym_modules as $type => $modules) { foreach ($modules as $module) { if (!empty($gym_config[$type . '_' . $module . '_installed'])) { ${$type . '_active'} = true; break; } } } $do_display_cat = $do_display_main = $do_display_index = false; // Google sitemaps if ($google_active) { $display_google_main_links = (bool) get_gym_option('google', 'gym', 'link_main', OVERRIDE_MODULE, $gym_config); $display_google_index_links = (bool) get_gym_option('google', 'gym', 'link_index', OVERRIDE_MODULE, $gym_config); $display_google_cat_links = (bool) get_gym_option('google', 'gym', 'link_cat', OVERRIDE_MODULE, $gym_config); $override_google_mod_rewrite = get_override('google', 'modrewrite', $gym_config); $google_mod_rewrite = (bool) get_gym_option('google', 'gym', 'modrewrite', $override_google_mod_rewrite, $gym_config); $override_google_gzip = get_override('google', 'gzip', $gym_config); $google_gzip = (bool) get_gym_option('google', 'forum', 'gzip', $override_google_gzip, $gym_config); $google_gzip_ext = $google_gzip || $config['gzip_compress'] ? get_gym_option('google', 'forum', 'gzip_ext', $override_google_gzip, $gym_config) ? '.gz' : '' : ''; $google_url = $_phpbb_seo ? $phpbb_seo->sslify($gym_config['google_url'], $phpbb_seo->ssl['use'], false) : $gym_config['google_url']; $sitemap_url = $google_url . ($google_mod_rewrite ? 'sitemapindex.xml' . $google_gzip_ext : "sitemap.{$phpEx}"); $links['setup']['google'] = array('override_mod_rewrite' => $override_google_mod_rewrite, 'mod_rewrite' => $google_mod_rewrite, 'override_gzip' => $override_google_gzip, 'link_main' => $display_google_main_links, 'link_index' => $display_google_index_links, 'link_cat' => $display_google_cat_links, 'gzip' => $google_gzip, 'gzip_ext' => $google_gzip_ext, 'google_url' => $google_url, 'threshold' => max(1, (int) $gym_config['google_threshold']), 'l_google_sitemap' => $user->lang['GOOGLE_SITEMAP'], 'l_google_sitemap_of' => $user->lang['GOOGLE_MAP_OF']); // only publicly readable and not thresholded forums will be listed if (!empty($gym_config['google_forum_installed'])) { $google_forum_mod_rewrite = (bool) get_gym_option('google', 'forum', 'modrewrite', $override_google_mod_rewrite, $gym_config); $google_auth_guest = array_diff_assoc($auth_guest_list['read_post'], set_exclude_list($gym_config['google_forum_exclude']), $auth_guest_list['thresholded']); $google_forum_exclude = set_exclude_list($gym_config['google_forum_exclude']) + $auth_guest_list['skip_all']; $links['setup']['google'] = array_merge($links['setup']['google'], array('forum_google' => true, 'forum_cat_google' => $google_url . ($google_forum_mod_rewrite && $_phpbb_seo ? "%1\$s.xml{$google_gzip_ext}" : "sitemap.{$phpEx}?forum=%2\$s"), 'auth_guest' => $google_auth_guest, 'forum_exclude' => $google_forum_exclude)); } $links['main'] = array_merge($links['main'], array('GYM_GOOGLE_TITLE' => $user->lang['GOOGLE_SITEMAPINDEX'], 'GYM_GOOGLE_URL' => $sitemap_url, 'GYM_GOOGLE_LINK' => $display_google_main_links ? sprintf($gym_link_tpl, $sitemap_url, 'sitemap-icon.gif', $user->lang['GOOGLE_SITEMAPINDEX']) : '', 'GYM_GOOGLE_THRESOLD' => (int) $links['setup']['google']['threshold'])); $do_display_main = $display_google_main_links ? true : $do_display_main; $do_display_index = $display_google_index_links ? true : $do_display_index; $do_display_cat = $display_google_cat_links ? true : $do_display_cat; } // RSS if ($rss_active) { $display_rss_main_links = (bool) get_gym_option('rss', 'gym', 'link_main', OVERRIDE_MODULE, $gym_config); $display_rss_index_links = (bool) get_gym_option('rss', 'gym', 'link_index', OVERRIDE_MODULE, $gym_config); $display_rss_cat_links = (bool) get_gym_option('rss', 'gym', 'link_cat', OVERRIDE_MODULE, $gym_config); $override_rss_mod_rewrite = get_override('rss', 'modrewrite', $gym_config); $rss_mod_rewrite = (bool) get_gym_option('rss', 'gym', 'modrewrite', $override_rss_mod_rewrite, $gym_config); $rss_modrtype = max(0, (int) get_gym_option('rss', 'gym', 'modrtype', $override_rss_mod_rewrite, $gym_config)); $override_rss_gzip = get_override('rss', 'gzip', $gym_config); $rss_gzip = (bool) get_gym_option('rss', 'forum', 'gzip', $override_rss_gzip, $gym_config); $rss_gzip_ext = $rss_gzip || $config['gzip_compress'] ? get_gym_option('rss', 'forum', 'gzip_ext', $override_rss_gzip, $gym_config) ? '.gz' : '' : ''; // Take car of linking type $link_type_sep = $rss_mod_rewrite ? '/' : '&'; $link_type_to_options = array('n' => 'news', 'nd' => 'news' . $link_type_sep . 'digest', 'r' => '', 'rd' => 'digest'); $link_type_bit = isset($link_type_to_options[$gym_config['rss_linking_type']]) ? $link_type_to_options[$gym_config['rss_linking_type']] : ''; $rss_url = $_phpbb_seo ? $phpbb_seo->sslify($gym_config['rss_url'], $phpbb_seo->ssl['use'], false) : $gym_config['rss_url']; $rss_main_url = $rss_url . ($rss_mod_rewrite ? 'rss/' . ($link_type_bit ? $link_type_bit . '/' : '') . 'rss.xml' . $rss_gzip_ext : "gymrss.{$phpEx}" . ($link_type_bit ? '?' . $link_type_bit : '')); $rss_chan_url = $rss_url . ($rss_mod_rewrite ? 'rss/' . ($link_type_bit ? $link_type_bit . '/' : '') : "gymrss.{$phpEx}?channels" . ($link_type_bit ? '&' . $link_type_bit : '')); $links['setup']['rss'] = array('display_alternate' => (int) $gym_config['rss_alternate'], 'link_main' => $display_rss_main_links, 'link_index' => $display_rss_index_links, 'link_cat' => $display_rss_cat_links, 'override_mod_rewrite' => $override_rss_mod_rewrite, 'mod_rewrite' => $rss_mod_rewrite, 'override_gzip' => $override_rss_gzip, 'gzip' => $rss_gzip, 'gzip_ext' => $rss_gzip_ext, 'rss_url' => $rss_url, 'l_rss_feed' => $user->lang['RSS_FEED'], 'l_rss_feed_of' => $user->lang['RSS_FEED_OF']); if (!empty($gym_config['rss_forum_installed'])) { $rss_forum_allow_auth = (bool) get_gym_option('rss', 'forum', 'allow_auth', $gym_config['rss_override'], $gym_config); // only readable forums can be listed $rss_auth_guest = array_diff_assoc($auth_guest_list['read_post'], set_exclude_list($gym_config['rss_forum_exclude']), $auth_guest_list['empty']); $rss_forum_exclude = set_exclude_list($gym_config['rss_forum_exclude']) + $auth_guest_list['skip_all'] + $auth_guest_list['empty']; $rss_forum_mod_rewrite = (bool) get_gym_option('rss', 'forum', 'modrewrite', $override_rss_mod_rewrite, $gym_config); $rss_forum_modrtype = max(0, (int) get_gym_option('rss', 'forum', 'modrtype', $override_rss_mod_rewrite, $gym_config)); $links['setup']['rss'] = array_merge($links['setup']['rss'], array('display_forum_alternate' => (int) $gym_config['rss_forum_alternate'], 'forum_rss' => !empty($gym_config['rss_forum_installed']), 'forum_cat_rss' => $rss_url . ($rss_forum_mod_rewrite && $_phpbb_seo ? $rss_forum_modrtype > 1 ? "%1\$s/" . ($link_type_bit ? $link_type_bit . '/' : '') . "forum.xml{$rss_gzip_ext}" : "forum" . $phpbb_seo->seo_delim['forum'] . "%2\$s/" . ($link_type_bit ? $link_type_bit . '/' : '') . "forum.xml{$rss_gzip_ext}" : "gymrss.{$phpEx}?forum=%2\$s" . ($link_type_bit ? '&' . $link_type_bit : '')), 'auth_guest' => $rss_auth_guest, 'forum_exclude' => $rss_forum_exclude, 'forum_allow_auth' => $rss_forum_allow_auth)); } $links['main'] = array_merge($links['main'], array('GYM_RSS_TITLE' => $user->lang['RSS_FEED'], 'GYM_RSS_URL' => $rss_main_url, 'GYM_RSS_LINK' => $display_rss_main_links ? sprintf($gym_link_tpl, $rss_main_url, 'feed-icon.png', $user->lang['RSS_FEED']) : '', 'GYM_RSS_CHAN_TITLE' => $user->lang['RSS_CHAN_LIST_TITLE'], 'GYM_RSS_CHAN_URL' => $rss_chan_url, 'GYM_RSS_CHAN_LINK' => $display_rss_main_links ? sprintf($gym_link_tpl, $rss_chan_url, 'feed-icon.png', $user->lang['RSS_CHAN_LIST_TITLE']) : '')); $do_display_main = $display_rss_main_links ? true : $do_display_main; $do_display_index = $display_rss_index_links ? true : $do_display_index; $do_display_cat = $display_rss_cat_links ? true : $do_display_cat; } // HTML if ($html_active) { $display_html_main_links = (bool) get_gym_option('html', 'gym', 'link_main', OVERRIDE_MODULE, $gym_config); $display_html_index_links = (bool) get_gym_option('html', 'gym', 'link_index', OVERRIDE_MODULE, $gym_config); $display_html_cat_links = (bool) get_gym_option('html', 'gym', 'link_cat', OVERRIDE_MODULE, $gym_config); $override_html_mod_rewrite = get_override('html', 'modrewrite', $gym_config); $html_mod_rewrite = (bool) get_gym_option('html', 'gym', 'modrewrite', $override_html_mod_rewrite, $gym_config); $html_allow_map = (bool) $gym_config['html_allow_map']; $html_allow_cat_map = (bool) $gym_config['html_allow_cat_map']; $html_allow_news = (bool) $gym_config['html_allow_news']; $html_allow_cat_news = (bool) $gym_config['html_allow_cat_news']; $html_url = $_phpbb_seo ? $phpbb_seo->sslify($gym_config['html_url'], $phpbb_seo->ssl['use'], false) : $gym_config['html_url']; $html_map_url = $gym_config['html_allow_map'] ? $html_url . ($html_mod_rewrite ? 'maps/' : "map.{$phpEx}") : ''; $html_news_url = $gym_config['html_allow_news'] ? $html_url . ($html_mod_rewrite ? 'news/' : "map.{$phpEx}?news") : ''; $links['setup']['html'] = array('link_main' => $display_html_main_links, 'link_index' => $display_html_index_links, 'link_cat' => $display_html_cat_links, 'override_mod_rewrite' => $override_html_mod_rewrite, 'mod_rewrite' => $html_mod_rewrite, 'html_url' => $html_url, 'allow_map' => $html_allow_map, 'allow_news' => $html_allow_news, 'allow_cat_map' => $html_allow_cat_map, 'allow_cat_news' => $html_allow_cat_news, 'l_html_news' => $user->lang['HTML_NEWS'], 'l_html_map' => $user->lang['HTML_MAP'], 'l_html_news_of' => $user->lang['HTML_NEWS_OF'], 'l_html_map_of' => $user->lang['HTML_MAP_OF']); if (!empty($gym_config['html_forum_installed'])) { $html_forum_mod_rewrite = (bool) get_gym_option('html', 'forum', 'modrewrite', $override_html_mod_rewrite, $gym_config); $html_forum_allow_map = (bool) get_gym_option('html', 'forum', 'allow_map', $gym_config['html_override'], $gym_config); $html_forum_allow_cat_map = (bool) get_gym_option('html', 'forum', 'allow_cat_map', $gym_config['html_override'], $gym_config); $html_forum_allow_news = (bool) get_gym_option('html', 'forum', 'allow_news', $gym_config['html_override'], $gym_config); $html_forum_allow_cat_news = (bool) get_gym_option('html', 'forum', 'allow_cat_news', $gym_config['html_override'], $gym_config); $html_auth_guest = array_diff_assoc($auth_guest_list['list'], set_exclude_list($gym_config['html_forum_exclude']), $auth_guest_list['empty']); $html_forum_allow_auth = (bool) get_gym_option('html', 'forum', 'allow_auth', $gym_config['html_override'], $gym_config); $html_forum_exclude = set_exclude_list($gym_config['html_forum_exclude']) + $auth_guest_list['skip_link'] + $auth_guest_list['empty']; $links['setup']['html'] = array_merge($links['setup']['html'], array('forum_allow_map' => $html_forum_allow_map, 'forum_map_url' => $html_allow_map ? $html_url . ($html_forum_mod_rewrite ? 'maps/forum/' : "map.{$phpEx}?forum") : '', 'forum_allow_news' => $html_forum_allow_news, 'forum_news_url' => $html_allow_news ? $html_url . ($html_forum_mod_rewrite ? 'news/forum/' : "map.{$phpEx}?forum=news") : '', 'forum_allow_cat_map' => $html_forum_allow_cat_map, 'forum_cat_map' => $html_url . ($html_forum_mod_rewrite && $_phpbb_seo ? 'maps/forum/%1$s/' : "map.{$phpEx}?forum=%2\$s"), 'forum_allow_cat_news' => $html_forum_allow_cat_news, 'forum_cat_news' => $html_url . ($html_forum_mod_rewrite && $_phpbb_seo ? 'news/forum/%1$s/' : "map.{$phpEx}?forum=%2\$s&news"), 'auth_guest' => $html_auth_guest, 'forum_exclude' => $html_forum_exclude, 'forum_allow_auth' => $html_forum_allow_auth)); } $links['main'] = array_merge($links['main'], array('GYM_HTML_NEWS_TITLE' => $user->lang['HTML_NEWS'], 'GYM_HTML_NEWS_URL' => $html_news_url, 'GYM_HTML_NEWS_LINK' => $display_html_main_links ? sprintf($gym_link_tpl, $html_news_url, 'html_news.gif', $user->lang['HTML_NEWS']) : '', 'GYM_HTML_MAP_TITLE' => $user->lang['HTML_MAP'], 'GYM_HTML_MAP_URL' => $html_map_url, 'GYM_HTML_MAP_LINK' => $display_html_main_links ? sprintf($gym_link_tpl, $html_map_url, 'maps-icon.gif', $user->lang['HTML_MAP']) : '', 'GYM_HTML_THEFORUM_NEWS_TITLE' => $user->lang['HTML_FORUM_NEWS'], 'GYM_HTML_THEFORUM_NEWS_URL' => $links['setup']['html']['forum_news_url'], 'GYM_HTML_THEFORUM_NEWS_LINK' => sprintf($gym_link_tpl, $links['setup']['html']['forum_news_url'], 'html_news.gif', $user->lang['HTML_FORUM_NEWS']), 'GYM_HTML_THEFORUM_MAP_TITLE' => $user->lang['HTML_FORUM_MAP'], 'GYM_HTML_THEFORUM_MAP_URL' => $links['setup']['html']['forum_map_url'], 'GYM_HTML_THEFORUM_MAP_LINK' => sprintf($gym_link_tpl, $links['setup']['html']['forum_map_url'], 'maps-icon.gif', $user->lang['HTML_FORUM_MAP']))); $do_display_main = $display_html_main_links ? true : $do_display_main; $do_display_index = $display_html_index_links ? true : $do_display_index; $do_display_cat = $display_html_cat_links ? true : $do_display_cat; } $links['setup']['main'] = array('link_main' => $gym_config['gym_link_main'] && $do_display_main ? 1 : 0, 'link_index' => $gym_config['gym_link_index'] && $do_display_index ? 1 : 0, 'link_cat' => $gym_config['gym_link_cat'] && $do_display_cat ? 1 : 0, 'f_public_read' => array_diff_assoc($auth_guest_list['read'], $auth_guest_list['skip_pass']) + array_intersect_assoc($auth_guest_list['skip_cat'], $auth_guest_list['list'])); $links['main'] = array_merge($links['main'], array('GYM_LINKS' => $links['setup']['main']['link_main'], 'GYM_LINKS_CAT' => $links['setup']['main']['link_cat'])); $links['alternate'] = array(); if (!empty($links['setup']['rss']['display_alternate'])) { $links['alternate'] = array(array('TITLE' => $user->lang['RSS_FEED'], 'URL' => $rss_main_url), array('TITLE' => $user->lang['RSS_CHAN_LIST_TITLE'], 'URL' => $rss_chan_url)); } return $links; }