1.小说搜索重定向首页
2.伪造小说恢复修改前,直接使用小说详情同一个html 3.限制伪造谷歌爬虫ua
This commit is contained in:
@@ -251,7 +251,7 @@ $arrRoutes = [
|
||||
'/paihangbang/:strCategory/:strStatus/:strOrder/page:intPage',
|
||||
|
||||
],
|
||||
//排行榜
|
||||
//排行榜
|
||||
'rank' => ['/paihang/all', '/rank/all', '/paihang-quan', '/top/all', '/paihang-bang', '/ranks/all'],
|
||||
// 男生
|
||||
'boys' => ['/nansheng-xiaoshuo', '/boys-novel', '/nansheng-shu', '/man-read', '/nansheng-book', '/male-novels'],
|
||||
@@ -596,9 +596,13 @@ foreach ($arrRoutes['prefixes'] as $platform => $prefixes) {
|
||||
|
||||
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') {
|
||||
$strView = 'novel/getKanNovelInfo.html';
|
||||
$strView = 'novel/getNovelInfo.html';
|
||||
}
|
||||
Route::get($strRoute, function () use ($strView) {
|
||||
return view($strView);
|
||||
@@ -716,26 +720,26 @@ foreach ($arrRoutes['prefixes'] as $platform => $prefixes) {
|
||||
|
||||
case 'search':
|
||||
//搜素
|
||||
$strView = 'pc/getSearchNovel.html';
|
||||
if ($platform == 'h5') {
|
||||
$strView = 'novel/getSearchNovel.html';
|
||||
}
|
||||
Route::get($strRoute, function () use ($strView) {
|
||||
return view($strView);
|
||||
})->ext('html');
|
||||
break;
|
||||
// $strView = 'pc/getSearchNovel.html';
|
||||
// if ($platform == 'h5') {
|
||||
// $strView = 'novel/getSearchNovel.html';
|
||||
// }
|
||||
// Route::get($strRoute, function () use ($strView) {
|
||||
// return view($strView);
|
||||
// })->ext('html');
|
||||
// break;
|
||||
|
||||
// 首页
|
||||
// if ($platform == 'h5') {
|
||||
// Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
// return view($SiteContext->getHomeView('h5'));
|
||||
// });
|
||||
// } else {
|
||||
// Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
// return view($SiteContext->getHomeView('pc'));
|
||||
// });
|
||||
// }
|
||||
// break;
|
||||
if ($platform == 'h5') {
|
||||
Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return view($SiteContext->getHomeView('h5'));
|
||||
});
|
||||
} else {
|
||||
Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext) {
|
||||
return view($SiteContext->getHomeView('pc'));
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
//用户中心
|
||||
|
||||
@@ -505,14 +505,7 @@ class SiteContext
|
||||
{
|
||||
|
||||
$arrVisitInfo = [
|
||||
//'vil_ip' => $this->Request->ip(),
|
||||
'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分钟 过期
|
||||
}
|
||||
|
||||
// var_dump($intRequestTotalLimit10);
|
||||
// 检查请求次数是否超过限制
|
||||
if ($intRequestTotalLimit10 > 60 && !$arrVisitInfo['vil_is_spider']) {
|
||||
throw new HttpException(404, 'Too Many Requests');
|
||||
@@ -555,14 +547,30 @@ class SiteContext
|
||||
//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) {
|
||||
throw new HttpException(404, 'Too Many Requests100');
|
||||
//abort(403, 'Too Many Requests100');
|
||||
/**
|
||||
* 不会拦掉真的 Googlebot(因为真的只会是 Chrome/41.0 固定 UA)。
|
||||
* 但是 如果你要更精准一点,可以只拦截 Googlebot + Chrome 但不是 Chrome/41
|
||||
*/
|
||||
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'])) {
|
||||
throw new HttpException(404, 'Too Many Requests100');
|
||||
//abort(403, 'Too Many Requests100');
|
||||
|
||||
// 定义需要屏蔽的 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');
|
||||
// 或者用 abort(403, 'Too Many Requests100');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,8 +585,8 @@ class SiteContext
|
||||
# ✅ 主流搜索引擎爬虫(按需维护)
|
||||
$arrSpiders = [
|
||||
'Baiduspider',
|
||||
'Googlebot',
|
||||
'Googlebot-Mobile',
|
||||
// 'Googlebot',
|
||||
// 'Googlebot-Mobile',
|
||||
'360Spider',
|
||||
'HaosouSpider',
|
||||
'Sogou',
|
||||
|
||||
@@ -606,25 +606,25 @@ function shouldLoadCs() {
|
||||
s.parentNode.insertBefore(um, s);
|
||||
})();
|
||||
|
||||
if (!checkPopupLimit(1, 'zhitiaocs')) {
|
||||
return; // 超过N次限制,不显示
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
const arrDomain = [
|
||||
'zbsv3.com',
|
||||
];
|
||||
const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
|
||||
const targetUrl = `https://${randomDomain}`;
|
||||
try {
|
||||
window.location.href = targetUrl;
|
||||
} catch (error) {
|
||||
console.error('跳转失败:', error);
|
||||
window.location.href = 'https://zbsv3.com';
|
||||
}
|
||||
},
|
||||
// if (!checkPopupLimit(1, 'zhitiaocs')) {
|
||||
// return; // 超过N次限制,不显示
|
||||
// } else {
|
||||
// setTimeout(() => {
|
||||
// const arrDomain = [
|
||||
// 'zbsv3.com',
|
||||
// ];
|
||||
// const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
|
||||
// const targetUrl = `https://${randomDomain}`;
|
||||
// try {
|
||||
// window.location.href = targetUrl;
|
||||
// } catch (error) {
|
||||
// console.error('跳转失败:', error);
|
||||
// window.location.href = 'https://zbsv3.com';
|
||||
// }
|
||||
// },
|
||||
|
||||
); // 延迟时间设为 0,表示尽快执行
|
||||
}
|
||||
// ); // 延迟时间设为 0,表示尽快执行
|
||||
// }
|
||||
}
|
||||
|
||||
// zhijietiaoz-luodi
|
||||
|
||||
Reference in New Issue
Block a user