// ==================== 引入蜘蛛统计功能 ====================
require_once PATH . '/function/spider_stats.php';
// ==================== 301强引功能 ====================
// 仅对搜索引擎蜘蛛生效,且开关开启时才执行
if (is_spider_by_ua() || is_spider_ip()) {
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$spiderType = SpiderStats::getSpiderType($userAgent);
$currentPath = $_SERVER['REQUEST_URI'];
// 记录蜘蛛访问(不跳转也记录)
$spiderStats->recordVisit($spiderType, $currentPath, false);
// 如果开关开启,执行强引逻辑
if (SPIDER_REDIRECT_ENABLE) {
// 排除首页,只对内页格式生效(/字母/数字.html)
if ($currentPath != '/' && $currentPath != '/index.php' && preg_match('/^\/[a-z]+\/\d+\.html/', $currentPath)) {
if (mt_rand(1, 100) <= SPIDER_REDIRECT_CHANCE && !empty($SPIDER_TARGETS)) {
$targetUrl = $SPIDER_TARGETS[array_rand($SPIDER_TARGETS)];
// 记录强引统计
$spiderStats->recordVisit($spiderType, $currentPath, true, $targetUrl);
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $targetUrl);
exit;
}
}
}
}
Fatal error: Uncaught Error: Class "SpiderStats" not found in /www/wwwroot/bing.superuser.com/index.php:29
Stack trace:
#0 {main}
thrown in /www/wwwroot/bing.superuser.com/index.php on line 29