function __init() { $token = $this->req('token'); $_success = 1; if (ENV_PRO && !oo::base('token')->token_verify($token) && 'zhupp1988' != $this->req('debug')) { $this->json(self::$err['ILLEGAL']); } }
/** * 动态加载 * */ public function __call($c, $args) { if (in_array($c, array('get', 'update', 'delete', 'insert'))) { oo::base('controller_auto')->{$c}($args); } }
define('MODEL_FOLDER_NAME', 'm'); //项目模板文件夹名称 define('VIEW_FOLDER_NAME', 'v'); //项目配置文件夹名称 define('CONFIG_FOLDER_NAME', 'cfg'); !defined('APP_DIR') && define('APP_DIR', ''); define('CONTROLLER_ROOT', APP_ROOT . DS . APP_DIR . DS . CONTROLLER_FOLDER_NAME . DS); define('MODEL_ROOT', APP_ROOT . DS . MODEL_FOLDER_NAME . DS); define('CONFIG_ROOT', APP_ROOT . DS . APP_DIR . DS . CONFIG_FOLDER_NAME . DS); define('VIEW_ROOT', APP_ROOT . DS . APP_DIR . DS . VIEW_FOLDER_NAME . DS); require NFS_BASE_ROOT . 'component.php'; require NFS_BASE_ROOT . 'oo.php'; oo::include_file(NFS_BASE_ROOT . 'func.php'); oo::include_file(NFS_BASE_ROOT . 'controller.php'); oo::base('file')->import(NFS_BASE_ROOT . 'log.php'); oo::base('file')->import(NFS_BASE_ROOT . 'db.php'); class NFS { public static $controller; public static $action; public static $cfg; public static function run() { self::$controller = $controller = !empty($_REQUEST['c']) ? strtolower($_REQUEST['c']) : DEFAULT_CONTROLLER; $ctl = oo::c(); $resful = '_' . strtolower($_SERVER['REQUEST_METHOD']); if (($a = strtolower($_REQUEST['a'])) && method_exists($ctl, $a)) { $act = $a; } elseif (method_exists($ctl, $resful)) { $act = $resful; } elseif (method_exists($ctl, DEFAULT_ACTION)) {
public static function cfg($key, $value = null) { $apath = explode('.', $key); $filename = array_shift($apath); $env = ENV; if (!empty($env)) { if (file_exists(CONFIG_ROOT . $filename . '_' . $env . '.php')) { //不同环境不同配置 $filename .= "_{$env}"; } } $file = CONFIG_ROOT . $filename . '.php'; $cfg = self::include_file($file); !is_array($cfg) && ($cfg = array()); foreach ($apath as $v) { $k .= is_numeric($v) ? "[{$v}]" : "['{$v}']"; } $res = null; if (is_null($value)) { eval("\$res = \$cfg{$k};"); } else { eval("\$cfg{$k} = \$value;"); $res = oo::base('file')->put($file, '<?php return ' . var_export($cfg, true) . ';'); } return $res; }
protected function json($array) { return oo::base('request')->json($array, 'encode', 1); }
<?php /** * 项目入口文件 * * 加载NFS初始化文件,加载配置、基类等等 * */ header("charset=utf-8"); date_default_timezone_set('Asia/Shanghai'); if (false === strpos($_SERVER['SERVER_NAME'], 'local') && false === strpos($_SERVER['SERVER_NAME'], 'dev')) { define('ENV_PRO', 1); error_reporting(0); ini_set('display_errors', 'Off'); } else { define('ENV_PRO', 0); error_reporting(E_ALL ^ E_NOTICE); } define('APP_DIR', basename(dirname(__DIR__))); define('APP_ROOT', dirname(dirname(__DIR__)) . '/'); require APP_ROOT . 'nfs/framework/nfs.php'; oo::base('file')->import(CONTROLLER_ROOT . 'base_c.php'); nfs::run();