From 1b443d6f6a724c3ae596d11a1f792c07a0aa8bca Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 9 Mar 2023 22:39:07 +0700 Subject: [PATCH] Make sitemap sending configurable --- library/ajax/sitemap.php | 18 +++++++++--------- library/config.php | 5 +++++ library/includes/cron/jobs/sitemap.php | 5 +++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/library/ajax/sitemap.php b/library/ajax/sitemap.php index 5478c490f..82be6174d 100644 --- a/library/ajax/sitemap.php +++ b/library/ajax/sitemap.php @@ -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 .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: ' . $lang['SITEMAP_SENT'] . ''; - } else { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: ' . $lang['SITEMAP_ERROR'] . ' URL: http://google.com/webmasters/sitemaps/ping?sitemap=' . $map_link . ''; + foreach ($bb_cfg['sitemap_sending'] as $source_name => $source_link) { + if ($map->sendSitemap($source_link, $map_link)) { + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' ' . $source_name . ' : ' . $lang['SITEMAP_SENT'] . ''; + } else { + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' ' . $source_name . ' : ' . $lang['SITEMAP_ERROR'] . ' URL: ' . $source_link . $map_link . ''; + } } + break; - if ($map->sendSitemap('http://www.bing.com/ping?sitemap=', $map_link)) { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: ' . $lang['SITEMAP_SENT'] . ''; - } else { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: ' . $lang['SITEMAP_ERROR'] . ' URL: http://www.bing.com/ping?sitemap=' . $map_link . ''; - } + default: + $this->ajax_die("Invalid mode: $mode"); } $this->response['html'] = $html; diff --git a/library/config.php b/library/config.php index 4415c8033..1143c6ac3 100644 --- a/library/config.php +++ b/library/config.php @@ -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', diff --git a/library/includes/cron/jobs/sitemap.php b/library/includes/cron/jobs/sitemap.php index b5faf8913..2f952dadf 100644 --- a/library/includes/cron/jobs/sitemap.php +++ b/library/includes/cron/jobs/sitemap.php @@ -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); + } }