<?php use Engine\X; use Engine\Gvar; X::map('csrf', function () { echo "~~~~~~~~~~csrf~~~~~~~~~~~~~~"; }); //关闭csrf X::setEnv('csrf', false); //初始化session X::register('session', function () { $session = new libraries\session(); $session->start(); return $session; }); if (!X::session()->get('company_id') && X::getEnv('action') != 'signin' && X::getEnv('controller') != 'audit/index') { X::redirect('/audit/signin'); } // Gvar::set(['company_id' => X::session()->get('company_id'), 'company_name' => X::session()->get('company_name'), 'account' => X::session()->get('account')], 'audit');
<?php require "./X.php"; use Engine\X; use Engine\Gvar; use Engine\Mysql; require '__init__.php'; /********************************************/ /********************************************/ // Bottle::map('notFound', function(){ // echo("~~~~~~~~~~~~notFound~~~~~~~~~~~~"); // }); X::map('exception', function () { echo "~~~~~~~~~~error~~~~~~~~~~~~~~"; }); X::init(['online' => false, 'baseUrl' => dirname(__FILE__) . DIRECTORY_SEPARATOR, 'templateFuncFile' => 'function/template.php']); //连接数据库 X::register('db', function () { return new Mysql(X::getConfigVar('database')); }); Gvar::set(['ip' => ip()], 'global'); //csrf_token X::start(['audit']);