Changed condition for displaying robots/sitemap

This commit is contained in:
zeldaroot 2021-06-26 00:26:48 +03:00
parent fddbdef4db
commit 75ca114c8e
3 changed files with 47 additions and 39 deletions

View file

@ -3332,8 +3332,10 @@ while [ "${WHILE}" -lt "2" ]; do
exit 0
;;
"bot"|"bot_https"|"domain"|"domain_https" )
_br "${2}"
read_domain "${2}"
sh_not
_s "${2}"
read_bomain "${3}"
if [ "${1}" = "bot_https" ] || [ "${1}" = "domain_https" ]; then
read_cloudflare_email "${4}"
@ -3398,6 +3400,7 @@ while [ "${WHILE}" -lt "2" ]; do
_line
fi
post_commands "${CP_BOMAIN}"
_br
exit 0
;;
"bench"|"benchmark"|"speedtest" )

View file

@ -55,14 +55,20 @@ router.get('/?', function(req, res) {
var host = req.get('host');
var host_domain = url.parse(protocol + '://' + host).hostname;
if (!config.user_bot) {
if (!req.userinfo.bot.main) {
return res.send('User-agent: *\nDisallow: /');
}
if (
(config.bomain && host_domain === config.subdomain + config.domain) ||
(config.bomain && host_domain === config.ru.subdomain + config.ru.domain) ||
(config.bomain && config.mirrors.indexOf(host_domain) + 1) ||
(!req.userinfo.bot.main && !config.user_bot)
(config.bomain || config.ru.bomain) &&
(host_domain === config.subdomain + config.domain ||
host_domain === config.ru.subdomain + config.ru.domain ||
config.mirrors.indexOf(host_domain) + 1)
) {
res.send('User-agent: *\nDisallow: /');
} else {
return res.send('User-agent: *\nDisallow: /');
}
}
res.send(
config.codes.robots +
'\n\n' +
@ -73,7 +79,6 @@ router.get('/?', function(req, res) {
'/' +
config.urls.sitemap
);
}
});
module.exports = router;

View file

@ -574,23 +574,22 @@ router.get('/:level1?/:level2?/:level3?/:level4?', function(req, res, next) {
}
}
if (!req.userinfo.bot.main && !config.user_bot && template === 'sitemap') {
if (template === 'sitemap') {
if (!config.user_bot) {
if (!req.userinfo.bot.main) {
return next({
status: 404,
message: 'The sitemap is available only to search bots.'
});
}
if (template === 'sitemap') {
var host = req.get('host');
var host_domain = url_parse.parse(config.protocol + '://' + host)
.hostname;
if (
(config.bomain && host_domain === config.subdomain + config.domain) ||
(config.bomain &&
host_domain === config.ru.subdomain + config.ru.domain) ||
(config.bomain && config.mirrors.indexOf(host_domain) + 1) ||
(!req.userinfo.bot.main && !config.user_bot)
(config.bomain || config.ru.bomain) &&
(host_domain === config.subdomain + config.domain ||
host_domain === config.ru.subdomain + config.ru.domain ||
config.mirrors.indexOf(host_domain) + 1)
) {
return next({
status: 404,
@ -598,6 +597,7 @@ router.get('/:level1?/:level2?/:level3?/:level4?', function(req, res, next) {
});
}
}
}
if (req.userinfo.bot.main) {
res.header('X-Robots-Tag', 'noarchive');