1.小说搜索重定向首页
2.伪造小说恢复修改前,直接使用小说详情同一个html 3.限制伪造谷歌爬虫ua
This commit is contained in:
@@ -596,9 +596,13 @@ foreach ($arrRoutes['prefixes'] as $platform => $prefixes) {
|
|||||||
|
|
||||||
case 'kan-novel':
|
case 'kan-novel':
|
||||||
//伪造小说详情
|
//伪造小说详情
|
||||||
$strView = 'pc/getKanNovelInfo.html';
|
// $strView = 'pc/getKanNovelInfo.html';
|
||||||
|
// if ($platform == 'h5') {
|
||||||
|
// $strView = 'novel/getKanNovelInfo.html';
|
||||||
|
// }
|
||||||
|
$strView = 'pc/getNovelInfo.html';
|
||||||
if ($platform == 'h5') {
|
if ($platform == 'h5') {
|
||||||
$strView = 'novel/getKanNovelInfo.html';
|
$strView = 'novel/getNovelInfo.html';
|
||||||
}
|
}
|
||||||
Route::get($strRoute, function () use ($strView) {
|
Route::get($strRoute, function () use ($strView) {
|
||||||
return view($strView);
|
return view($strView);
|
||||||
@@ -716,26 +720,26 @@ foreach ($arrRoutes['prefixes'] as $platform => $prefixes) {
|
|||||||
|
|
||||||
case 'search':
|
case 'search':
|
||||||
//搜素
|
//搜素
|
||||||
$strView = 'pc/getSearchNovel.html';
|
// $strView = 'pc/getSearchNovel.html';
|
||||||
if ($platform == 'h5') {
|
// if ($platform == 'h5') {
|
||||||
$strView = 'novel/getSearchNovel.html';
|
// $strView = 'novel/getSearchNovel.html';
|
||||||
}
|
// }
|
||||||
Route::get($strRoute, function () use ($strView) {
|
// Route::get($strRoute, function () use ($strView) {
|
||||||
return view($strView);
|
// return view($strView);
|
||||||
})->ext('html');
|
// })->ext('html');
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
// 首页
|
// 首页
|
||||||
// if ($platform == 'h5') {
|
if ($platform == 'h5') {
|
||||||
// Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
||||||
// return view($SiteContext->getHomeView('h5'));
|
return view($SiteContext->getHomeView('h5'));
|
||||||
// });
|
});
|
||||||
// } else {
|
} else {
|
||||||
// Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
||||||
// return view($SiteContext->getHomeView('pc'));
|
return view($SiteContext->getHomeView('pc'));
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// break;
|
break;
|
||||||
|
|
||||||
case 'user':
|
case 'user':
|
||||||
//用户中心
|
//用户中心
|
||||||
|
|||||||
@@ -505,14 +505,7 @@ class SiteContext
|
|||||||
{
|
{
|
||||||
|
|
||||||
$arrVisitInfo = [
|
$arrVisitInfo = [
|
||||||
//'vil_ip' => $this->Request->ip(),
|
|
||||||
'vil_user_agent' => $this->Request->server('HTTP_USER_AGENT'),
|
'vil_user_agent' => $this->Request->server('HTTP_USER_AGENT'),
|
||||||
// 'vil_url' => $this->Request->url(true),
|
|
||||||
// 'vil_method' => $this->Request->method(),
|
|
||||||
// 'vil_headers' => json_encode($this->Request->header()), // 保存所有 HTTP 头信息
|
|
||||||
// 'vil_timestamp' => date('Y-m-d H:i:s'), // 获取当前时间
|
|
||||||
// 'vil_content_type' => 'page',
|
|
||||||
// 'vil_content_id' => $this->Request->url(true),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// 判断是否为爬虫
|
// 判断是否为爬虫
|
||||||
@@ -538,7 +531,6 @@ class SiteContext
|
|||||||
Cache::store('redis')->handler()->expire($strKeyLimit100, 60 * 10); // 设置 10分钟 过期
|
Cache::store('redis')->handler()->expire($strKeyLimit100, 60 * 10); // 设置 10分钟 过期
|
||||||
}
|
}
|
||||||
|
|
||||||
// var_dump($intRequestTotalLimit10);
|
|
||||||
// 检查请求次数是否超过限制
|
// 检查请求次数是否超过限制
|
||||||
if ($intRequestTotalLimit10 > 60 && !$arrVisitInfo['vil_is_spider']) {
|
if ($intRequestTotalLimit10 > 60 && !$arrVisitInfo['vil_is_spider']) {
|
||||||
throw new HttpException(404, 'Too Many Requests');
|
throw new HttpException(404, 'Too Many Requests');
|
||||||
@@ -555,14 +547,30 @@ class SiteContext
|
|||||||
//abort(403, 'Too Many Requests100');
|
//abort(403, 'Too Many Requests100');
|
||||||
}
|
}
|
||||||
|
|
||||||
$strAGEN = 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Amazonbot/0.1; +https://developer.amazon.com/support/amazonbot) Chrome/119.0.6045.214 Safari/537.36';
|
/**
|
||||||
if ($arrVisitInfo['vil_user_agent'] == $strAGEN) {
|
* 不会拦掉真的 Googlebot(因为真的只会是 Chrome/41.0 固定 UA)。
|
||||||
throw new HttpException(404, 'Too Many Requests100');
|
* 但是 如果你要更精准一点,可以只拦截 Googlebot + Chrome 但不是 Chrome/41
|
||||||
//abort(403, 'Too Many Requests100');
|
*/
|
||||||
|
if (stripos($arrVisitInfo['vil_user_agent'], 'Googlebot/2.1') !== false
|
||||||
|
&& stripos($arrVisitInfo['vil_user_agent'], 'Chrome/') !== false
|
||||||
|
&& stripos($arrVisitInfo['vil_user_agent'], 'Chrome/41.0.2272.96') === false) {
|
||||||
|
throw new HttpException(403, 'HTTP/1.1 403 Forbidden');
|
||||||
}
|
}
|
||||||
if (preg_match('/Chrome\/119\.0\.6045\.214/', $arrVisitInfo['vil_user_agent'])) {
|
|
||||||
|
// 定义需要屏蔽的 UA 关键字 / 正则
|
||||||
|
$arrDenyUserAgents = [
|
||||||
|
'Amazonbot', // 屏蔽 Amazon 爬虫
|
||||||
|
'zgrab', // 安全扫描工具
|
||||||
|
'crawler', // 明示 crawler
|
||||||
|
'Chrome\/119\.0\.6045\.214', // 特定版本号 UA
|
||||||
|
];
|
||||||
|
|
||||||
|
// 遍历检查 UA
|
||||||
|
foreach ($arrDenyUserAgents as $strPattern) {
|
||||||
|
if (preg_match("/$strPattern/i", $arrVisitInfo['vil_user_agent'])) {
|
||||||
throw new HttpException(404, 'Too Many Requests100');
|
throw new HttpException(404, 'Too Many Requests100');
|
||||||
//abort(403, 'Too Many Requests100');
|
// 或者用 abort(403, 'Too Many Requests100');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,8 +585,8 @@ class SiteContext
|
|||||||
# ✅ 主流搜索引擎爬虫(按需维护)
|
# ✅ 主流搜索引擎爬虫(按需维护)
|
||||||
$arrSpiders = [
|
$arrSpiders = [
|
||||||
'Baiduspider',
|
'Baiduspider',
|
||||||
'Googlebot',
|
// 'Googlebot',
|
||||||
'Googlebot-Mobile',
|
// 'Googlebot-Mobile',
|
||||||
'360Spider',
|
'360Spider',
|
||||||
'HaosouSpider',
|
'HaosouSpider',
|
||||||
'Sogou',
|
'Sogou',
|
||||||
|
|||||||
@@ -606,25 +606,25 @@ function shouldLoadCs() {
|
|||||||
s.parentNode.insertBefore(um, s);
|
s.parentNode.insertBefore(um, s);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if (!checkPopupLimit(1, 'zhitiaocs')) {
|
// if (!checkPopupLimit(1, 'zhitiaocs')) {
|
||||||
return; // 超过N次限制,不显示
|
// return; // 超过N次限制,不显示
|
||||||
} else {
|
// } else {
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
const arrDomain = [
|
// const arrDomain = [
|
||||||
'zbsv3.com',
|
// 'zbsv3.com',
|
||||||
];
|
// ];
|
||||||
const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
|
// const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
|
||||||
const targetUrl = `https://${randomDomain}`;
|
// const targetUrl = `https://${randomDomain}`;
|
||||||
try {
|
// try {
|
||||||
window.location.href = targetUrl;
|
// window.location.href = targetUrl;
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('跳转失败:', error);
|
// console.error('跳转失败:', error);
|
||||||
window.location.href = 'https://zbsv3.com';
|
// window.location.href = 'https://zbsv3.com';
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
|
|
||||||
); // 延迟时间设为 0,表示尽快执行
|
// ); // 延迟时间设为 0,表示尽快执行
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// zhijietiaoz-luodi
|
// zhijietiaoz-luodi
|
||||||
|
|||||||
Reference in New Issue
Block a user