gym_sitemaps('google');
// init output
$this->output_data['showstats'] = $this->gym_config['gym_showstats'] && $this->gym_config['google_showstats'];
$this->output_data['last_mod_time'] = intval($this->set_module_option('last_mod_time'));
// Check the main vars
$this->init_get_vars();
$this->gym_init_output();
// Setup the output
$this->cache_config = array_merge(
// Global
$this->cache_config,
// Other stuff required here
array(
'cache_enable' => $this->set_module_option('cache_on', $this->override['cache']),
'cache_auto_regen' => $this->set_module_option('cache_auto_regen', $this->override['cache']),
'cache_force_gzip' => $this->set_module_option('cache_force_gzip', $this->override['cache']),
'cache_born' => intval($this->set_module_option('cache_born')),
'cache_max_age' => round($this->set_module_option('cache_max_age', $this->override['cache']),2) * 3600,
'cache_file_ext' => ( $this->gym_output->gzip_config['gzip'] || $this->set_module_option('cache_force_gzip', $this->override['cache']) ) ? '.xml.gz' : '.xml',
)
);
// Can you believe it, sprintf is faster than straight parsing.
$this->style_config = array('Sitemap_tpl' => "\n\t" . '' . "\n\t\t" . '%s%s' . "\n\t\t" . '%s' . "\n\t\t" . '%s' . "\n\t" . '',
'SitmIndex_tpl' => "\n\t" . '' . "\n\t\t" . '%s%s' . "\n\t" . '',
'lastmod_tpl' => "\n\t\t" . '%s',
'xslt_style' => '',
'stats_genlist' => "\n" . '',
'stats_start' => "\n" . '',
'stats_nocache' => "\n" . '',
'stats_end' => "\n" . '',
);
// Check cache
$this->gym_output->setup_cache(); // Will exit if the cache is sent
$this->google_config = array(
'google_default_priority' => sprintf('%.1f', $this->set_module_option('default_priority', $this->gym_config['google_override'])),
'google_url' => $this->gym_config['google_url'],
// module specific settings we should often need in module
'google_modrewrite' => intval($this->set_module_option('modrewrite', $this->override['modrewrite'])),
'google_modrtype' => intval($this->set_module_option('modrtype', $this->override['modrewrite'])),
'google_pagination' => $this->set_module_option('pagination', $this->override['pagination']),
'google_limitdown' => intval($this->set_module_option('limitdown', $this->override['pagination'])),
'google_limitup'=> intval($this->set_module_option('limitup', $this->override['pagination'])),
'google_sql_limit' => intval($this->set_module_option('sql_limit', $this->override['limit'])),
'google_url_limit' => intval($this->set_module_option('url_limit', $this->override['limit'])),
'google_sort' => ($this->set_module_option('sort', $this->override['sort']) === 'DESC') ? 'DESC' : 'ASC',
'google_ping' => $this->set_module_option('ping', $this->gym_config['google_override']),
);
if ($this->gym_config['google_xslt']) {
$this->style_config['xslt_style'] = "\n" . 'seo_path['phpbb_url'] . 'gym_sitemaps/gym_style.' . $phpEx . '?action-google,type-xsl,lang-' . $config['default_lang'] . ',theme_id-' . $config['default_style'] . '" ?>';
}
if ( empty($this->actions['module_main']) ) { // SitemapIndex
$this->google_sitemapindex();
} else { // Sitemap
$this->google_sitemap();
}
if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
{
$db->sql_report('display');
}
$this->gym_output->do_output();
return;
}
/**
* GGs_sitemapindex() will build our sitemapIndex
* Listing all available sitemaps
* @access private
*/
function google_sitemapindex() {
global $phpEx, $phpbb_seo, $db;
$sitemapindex_url = $this->gym_config['google_url'] . ( $this->google_config['google_modrewrite'] ? 'sitemapindex.xml' . $this->url_config['gzip_ext_out'] : 'sitemap.'.$phpEx);
$this->seo_kill_dupes($sitemapindex_url);
$this->output_data['data'] = "" . $this->style_config['xslt_style'] . "\n" . '' . "\n" . '' . "\n";
// start the modules
$this->load_modules('sitemapindex');
// Grabb the total
$this->output_data['url_sofar'] = $this->output_data['url_sofar_total'];
$this->output_data['data'] .= "\n" . '';
return;
}
/**
* GGs_sitemap() will build the actual Google sitemaps, all cases
* @access private
*/
function google_sitemap() {
global $phpEx, $phpbb_seo, $db;
// Initialize SQL cycling : do not query for more than required
$this->gym_config['google_sql_limit'] = ($this->gym_config['google_sql_limit'] > $this->gym_config['google_url_limit']) ? $this->gym_config['google_url_limit'] : $this->gym_config['google_sql_limit'];
$this->output_data['data'] = "" . $this->style_config['xslt_style'] . "\n" . '' . "\n" . '' . "\n";
// start the module
$module_class = $this->actions['action_type'] . '_' . $this->actions['module_main'];
$this->load_module($module_class, 'sitemap');
$this->output_data['data'] .= "\n" . '';
return;
}
/**
* parse_sitemap($url, $lastmodtime = 0)
* adds the module sitemaps to the sitemapindex
*/
function parse_sitemap($url, $lastmodtime = 0) {
global $config, $user;
$lastmodtime = $lastmodtime > $config['board_startdate'] ? sprintf($this->style_config['lastmod_tpl'], gmdate('D, d M Y H:i:s \G\M\T', intval($lastmodtime))) : '';
$this->output_data['data'] .= sprintf($this->style_config['SitmIndex_tpl'], $url, $lastmodtime);
$this->output_data['url_sofar']++;
}
/**
* parse_item() adds the item info to the output
*/
function parse_link($url, $priority = 1.0, $changefreq = 'always', $lastmodtime = 0) {
global $config, $user;
static $freq_values = array('always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never');
$changefreq = in_array($changefreq, $freq_values) ? $changefreq : 'always';
$priority = $priority >= 1 ? '1.0' : ( $priority <= 0 ? '0.0' : sprintf('%.2f', $priority) );
$lastmodtime = $lastmodtime > $config['board_startdate'] ? sprintf($this->style_config['lastmod_tpl'], gmdate('D, d M Y H:i:s \G\M\T', intval($lastmodtime))) : '';
$this->output_data['data'] .= sprintf($this->style_config['Sitemap_tpl'], $url, $lastmodtime, $changefreq, $priority);
$this->output_data['url_sofar']++;
}
/**
* parse_sitemap($url, $lastmodtime = 0)
* adds the module sitemaps to the sitemapindex
*/
function google_ping($url) {
global $config, $user;
$se_urls = array('http://www.google.com/', 'http://www.yahoo.com/', 'http://www.live.com/');
$not_curl= true;
foreach ($se_urls as $se_url) {
$request = $se_url . 'ping?sitemap=' . urlencode($url);
if (function_exists('curl_exec')) {
$not_curl= FALSE;
// Initialize the session
$session = curl_init($request);
// Set curl options
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Make the request
$response = curl_exec($session);
// Close the curl session
curl_close($session);
// Get HTTP Status code from the response
$status_codes = array();
preg_match('/\d\d\d/', $response, $status_code);
$status_code = $status_codes[0];
// Get the the response, bypassing the header
if ($status_code != 200) {
$not_curl= TRUE;
}
} elseif ( $not_curl && function_exists('file_get_contents') ) {
// Make the request
if (file_get_contents($request)) {
// Retrieve HTTP status code
list($version,$status_code,$msg) = explode(' ',$http_response_header[0], 3);
}
if ($status_code != 200) {
$this->gym_error(500, 'GYM_ERROR_PING', __FILE__, __LINE__);
}
} else {
$this->gym_error(500, 'GYM_ERROR_PING', __FILE__, __LINE__);
}
}
return;
}
}
?>