/** * 构造函数 * @param $file 文件路径 * @param $cache_time 缓存时间,秒为单位(默认不用缓存) */ public function __construct($file, $cache_time = false) { $this->cache_time = intval($cache_time); if (!is_file($file)) { echo_('file ' . $file . ' not exists...', true); } if ($this->cache_time <= 0) { $this->handle = fopen($file, 'r'); if (!$this->handle) { echo_('can not read file ' . $file, true); } } }
/** * 处理外部接口 */ private static function action() { //模式选择 switch (self::$mode) { case 1: //普通模式 $request_param = explode('.', $GLOBALS['_GET']['action']); break; case 2: //伪静态模式 $application_dir = str_replace('\\', '/', self::$application_dir); $application_base_root = str_replace($_SERVER['DOCUMENT_ROOT'], '', $application_dir); $parse_url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $request_param = explode('/', substr(str_replace($application_base_root, '', $parse_url), 1)); break; case 3: //纯静态模式 redirect(self::$base_url . 'index.html'); break; default: if (DEBUG === true) { echo_('share can not run in no mode !!!', true); } else { die; } break; } if ($request_param[0] && $request_param[1]) { //如果有定义类和方法的覆盖默认的 self::set_class(strtolower($request_param[0])); self::set_method(strtolower($request_param[1])); } $class = self::$class . 'controller'; $obj = new $class(); if (!class_exists($class)) { if (DEBUG === true) { echo_('class ' . $class . ' is not exists...', true); } else { error404(); die; } } if (!method_exists($obj, self::$method)) { if (DEBUG === true) { echo_('action ' . self::$method . ' is not exists...', true); } else { error404(); die; } } $method = self::$method; $obj->{$method}(); }
/** * 打印所有session */ public static function show() { echo_($GLOBALS['_SESSION']); }
/** * 打印所有cookie */ public static function show() { echo_($GLOBALS['_COOKIE']); }
function detect_video($d, $t, $r) { if (preg_match('@jisu\\.cf@', $d) || preg_match('@juhe\\.ml@', $d) || preg_match('@iptvlinks\\.tk@', $d)) { echo_(" >>> generic" . PHP_EOL); generic($d, $t, $r); } elseif (preg_match('@youtube\\.com@', $d)) { echo_(" >>> youtube.com" . PHP_EOL); youtube($d, $t, $r); } else { echo "Url:{$d}\r\nChannel:{$t}\r\nNOT SUPPORTED YET.\r\n"; stf($d); } }
?> ' style='width:150px;'/> <?php } else { echo $loginID; } ?> </td></tr> <tr><td><label for='firstName'><b><?php echo _("First Name"); ?> </b></label></td><td><input type='text' id='firstName' name='firstName' value="<?php echo $user->firstName; ?> " style='width:150px;'/></td></tr> <tr><td><label for='lastName'><b><?php echo_("Last Name"); ?> </b></label></td><td><input type='text' id='lastName' name='lastName' value="<?php echo $user->lastName; ?> " style='width:150px;'/></td></tr> <tr><td><label for='privilegeID'><b><?php echo _("Privilege"); ?> </b></label></td> <td> <select name='privilegeID' id='privilegeID' style='width:155px'> <option value=''></option> <?php foreach ($privilegeArray as $privilege) { if ($privilege['privilegeID'] == $user->privilegeID) {
/** * 处理外部接口 */ private static function action() { $application_dir = str_replace('\\', '/', self::$application_dir); $application_base_root = str_replace($_SERVER['DOCUMENT_ROOT'], '', $application_dir); $parse_url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $request_param = trim(str_replace(str_replace('index.php', '', $_SERVER['SCRIPT_NAME']), '', $parse_url)); // 无url if (empty($request_param)) { echo 'no url mapping'; die; } // 约定一个规则 http://xxx.com/controller/method // 只做两层,后面不加参数 $request_param = explode('/', $request_param); $count = count($request_param); $class = trim(strtolower($request_param[$count - 2])); $method = trim(strtolower($request_param[$count - 1])); $class = $class . 'controller'; $obj = new $class(); if (!class_exists($class)) { if (DEBUG === true) { echo_('class ' . $class . ' is not exists...', true); } else { error404(); die; } } if (!method_exists($obj, $method)) { if (DEBUG === true) { echo_('action ' . $method . ' is not exists...', true); } else { error404(); die; } } // 约定,输出json echo trim(json_encode($obj->{$method}())); }