Make sitemap sending configurable

This commit is contained in:
Roman Kelesidis 2023-03-09 22:39:07 +07:00
commit 1b443d6f6a
3 changed files with 17 additions and 11 deletions

View file

@ -34,17 +34,17 @@ switch ($mode) {
$map_link = make_url('sitemap/sitemap.xml');
if ($map->sendSitemap('http://google.com/webmasters/sitemaps/ping?sitemap=', $map_link)) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <span style="color: green;">' . $lang['SITEMAP_SENT'] . '</span>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <span style="color: red;">' . $lang['SITEMAP_ERROR'] . '</span> URL: <a href="http://google.com/webmasters/sitemaps/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://google.com/webmasters/sitemaps/ping?sitemap=' . $map_link . '</a>';
foreach ($bb_cfg['sitemap_sending'] as $source_name => $source_link) {
if ($map->sendSitemap($source_link, $map_link)) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . '&nbsp;' . $source_name . ' : <span style="color: green;">' . $lang['SITEMAP_SENT'] . '</span>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . '&nbsp;' . $source_name . ' : <span style="color: red;">' . $lang['SITEMAP_ERROR'] . '</span> URL: <a href="' . $source_link . urlencode($map_link) . '" target="_blank">' . $source_link . $map_link . '</a>';
}
}
break;
if ($map->sendSitemap('http://www.bing.com/ping?sitemap=', $map_link)) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <span style="color: green;">' . $lang['SITEMAP_SENT'] . '</span>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <span style="color: red;">' . $lang['SITEMAP_ERROR'] . '</span> URL: <a href="http://www.bing.com/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://www.bing.com/ping?sitemap=' . $map_link . '</a>';
}
default:
$this->ajax_die("Invalid mode: $mode");
}
$this->response['html'] = $html;

View file

@ -517,6 +517,11 @@ $bb_cfg['user_agreement_url'] = 'info.php?show=user_agreement';
$bb_cfg['copyright_holders_url'] = 'info.php?show=copyright_holders';
$bb_cfg['advert_url'] = 'info.php?show=advert';
$bb_cfg['sitemap_sending'] = [
# 'Source name' => 'http://ping_url'
'Google' => 'http://google.com/webmasters/sitemaps/ping?sitemap=',
];
// Extensions
$bb_cfg['file_id_ext'] = [
1 => 'gif',

View file

@ -17,6 +17,7 @@ $map->createSitemap();
if (file_exists(SITEMAP_DIR . '/sitemap.xml')) {
$map_link = make_url('sitemap/sitemap.xml');
$map->sendSitemap('http://google.com/webmasters/sitemaps/ping?sitemap=', $map_link);
$map->sendSitemap('http://www.bing.com/ping?sitemap=', $map_link);
foreach ($bb_cfg['sitemap_sending'] as $source_name => $source_link) {
$map->sendSitemap($source_link, $map_link);
}
}