<?php
/**
 *
 *****************************************************************************************************
 *    如果您通过浏览器访问网站时看到了这个提示，那么我们很遗憾地通知您，您的空间不支持 PHP 。
 *    也就是说，您的空间可能是静态空间，或没有安装PHP，或没有为 Web 服务器打开 PHP 支持。
 *    Sorry, PHP is not installed on your web hosting if you see this prompt.
 *    Please check out the PHP configuration.
 *
 *    版权所有 2020 四平市九州易通科技有限公司，并保留所有权利。
 *
 *    这不是一个自由软件！也不是一个开源软件！您不能在任何目的的前提下对程序代码进行破解、修改；
 *    不允许对程序代码以任何形式任何目的的再发布。
 *    您可以免费应用与商业网站，但需要保留软件版权文字及链接。
 *****************************************************************************************************
 */
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'); //支持页面回跳
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.4.0','<'))  die('<div style="width:300px;margin:0px auto;margin-top:50px;padding:20px;border:5px solid #ccc;border-radius: 5px 5px 5px 5px;text-align:left;">本系统要求PHP版本至少为5.4.0，<br>当前PHP版本为：'.PHP_VERSION . '，<br>请到虚拟主机控制面板里切换PHP版本，或联系空间商协助切换。<br><br><center><a href="https://www.cmseasy.cn/chm/quick/idc-user.html" target="_blank">点击查看安装教程!</a></center></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;
            }
        }
        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,['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');

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));
}

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());
    }
}


stats::getbot();
