function domain_route($file) { if (PtLib\is_cli()) { return; } $file = str_replace(PATH_WEBROOT, "", $file); if (substr($file, 0, 1) == "/") { $file = substr($file, 1); } $admin = "admin"; $tools = "tools"; if (substr($file, 0, strlen($admin)) == $admin) { if (!in_array($_SERVER['HTTP_HOST'], array("product.jzw.la", "admin.jzw.la", "demo.jzw.la", "2.dev.jzw.la", "2.dev.jzw.com"))) { throw new Exception("not found", 101404); } } elseif (substr($file, 0, strlen($tools)) == $tools) { if (!in_array($_SERVER['HTTP_HOST'], array("service.easytee.me", "2.dev.jzw.com"))) { throw new Exception("not found", 101404); } } else { if (!in_array($_SERVER['HTTP_HOST'], array("service.easytee.me", "product.jzw.la", "www.easytee.me", "demo.jzw.la", "lxm.jzw.la", "2.dev.jzw.la", "2.dev.jzw.com"))) { throw new Exception("not found", 102404); } } if (PtApp::$ENV == "product" && substr($file, 0, strlen("test")) == "test") { throw new Exception("not found", 102404); } }
function set_setting() { $GLOBALS['setting'] = parse_ini_file(PATH_CONFIG . "/setting.ini", true); $_PT_ENV = PtLib\get_pt_env("PT_ENV"); PtApp::$ENV = $_PT_ENV; if (is_file(PATH_CONFIG . "/setting/{$_PT_ENV}.ini")) { $GLOBALS['setting'] = array_merge($GLOBALS['setting'], parse_ini_file(PATH_CONFIG . "/setting/{$_PT_ENV}.ini", true)); } require PATH_CONFIG . "/base.php"; if (is_file(PATH_CONFIG . "/base/{$_PT_ENV}.php")) { require PATH_CONFIG . "/base/{$_PT_ENV}.php"; } if (!PtLib\is_cli()) { require PATH_CONFIG . "/web.php"; if (is_file(PATH_CONFIG . "/web/{$_PT_ENV}.php")) { require PATH_CONFIG . "/web/{$_PT_ENV}.php"; } } //print_josn($GLOBALS['setting']); PtApp::$setting = $GLOBALS['setting']; //return $setting; }
static function is_logined() { if (PtLib\is_cli()) { return true; } $cookie_auth_key = self::get_cookie_auth_key(); $logined = false; if (!isset($_COOKIE[$cookie_auth_key])) { return $logined; } $auth_info = PtLib\secure_cookie_decode($cookie_auth_key, $_COOKIE[$cookie_auth_key]); if ($auth_info) { $auth_info = json_decode($auth_info, true); } if ($auth_info && !empty($auth_info['uid'])) { PtApp::$auth = $auth_info; $logined = True; } else { $logined = false; } return $logined; }
<?php include_once __DIR__ . "/init.php"; include_once __DIR__ . "/include/common.php"; if (PtLib\is_cli()) { cli_route(); }