Exemple #1
0
 public function __construct($config = array())
 {
     $this->_config = $config;
     //对ap 进行一些基础设置
     $this->routeMiddleware = ['beforeController' => \App\Middleware\BeforeController::class];
     /*
     |-------------------------------------------
     | 建立信息sc
     |-------------------------------------------
     | 主要是配置信息
     | App/config.php + C() + Struct;
     */
     // print_r(sc());
     sc(C());
     sc('Struct', sapp('struct')->all());
     /*
     |-------------------------------------------
     | 建立信息bus
     |-------------------------------------------
     | 主要是运行过程中的信息,和运算结果
     | bus 初始化执行
     */
     bus('modules', C('Router')['method_modules']);
     //模块
     bus('controller', C('Router')['method_controller']);
     //控制器
     bus('method', C('Router')['method_action']);
     //行为
     bus('ext', C('Router')['method_action_ext']);
     //行为扩展
     //添加Middleware 进入bus
     //          bus('Middleware', sc('Middleware'));                  //中间件定义
     bus('router', C('Router'));
     //路由
     bus('user', geter('user.info'));
     //用户相关
     bus('usergroup', geter('user.group'));
     //用户组信息
     bus('userrulelib', geter('user.rulelib'));
     //用户组权限信息
     bus('menu', []);
     //后台菜单
     bus('page', []);
     //页面信息
     bus('rules', sc('rules'));
     //rbacrules
     bus('app', sc('app'));
     //app相关
     //req -> request
     bus('req', ['get' => C('Router')['params'], 'post' => $_POST, 'cookies' => $_COOKIE, 'session' => $_SESSION, 'server' => $_SERVER]);
     bus('display', []);
     //页面信息
     bus('touchlist', []);
     //接触日志
     sapp('Mmc')->set('demo1', null, 10000);
     $ms1 = sapp('Mmc')->get('demo1');
 }
Exemple #2
0
 public function handle($request, \Closure $next)
 {
     bus('user', geter('user.info'));
     bus('group', geter('user.group'));
     //bus('menu', geter('menu.my'));
     assign('get', sc('Get'));
     assign('post', sc('Post'));
     assign('router', sc('Router'));
     //            assign('v3',[
     //            'routerv3'=>'v33',
     //            ]);
     // Perform action
     return $next($request);
 }
Exemple #3
0
 public function handle($request, \Closure $next)
 {
     if (!geter('user.islogin')) {
         R('/admin/auth/login/');
     }
     bus('user', geter('user.info'));
     bus('group', geter('user.group'));
     bus('menu', geter('menu.menu'));
     //返回菜单数组
     bus('mymca', geter('menu.mymca'));
     //当前的mca信息
     bus('mypath', geter('menu.mypath'));
     return $next($request);
 }
 public function handle($request, \Closure $next)
 {
     //建立中间件 & 行为
     //根据路由执行系列操作
     $basepath = sc('Router')['m'] ? rtrim(APPROOT, '/') . '/Modules/' . sc('Modulelist')[sc('Router')['m']] . '/' : rtrim(APPROOT, '/') . '/';
     //|-----------------------------------------------
     $controller = '\\Controller\\' . sc('Router')['c'];
     $action = sc('Router')['action'];
     $params = sc('Router')['param'];
     if (sc('Router')['m']) {
         $basepath = rtrim(APPROOT, '/') . '/Modules/' . sc('Modulelist')[sc('Router')['m']] . '/Controller/';
     } else {
         $basepath = rtrim(APPROOT, '/') . '/' . 'Controller/';
     }
     $basecontrollerpath = $basepath . 'BaseController.php';
     $controllerextpath = $basepath . sc('Router')['c'] . '.' . sc('Router')['a'] . '.php';
     $controllerpath = $basepath . sc('Router')['c'] . '.php';
     //加载基类 - 如果基类存在,则加载
     includeIfExist($basecontrollerpath);
     //尝试扩展控制器 - 尝试控制器
     includeIfExist($controllerextpath);
     if (!class_exists($controller)) {
         includeIfExist($controllerpath);
     }
     //--------------------------------------------------------
     if (!class_exists($controller)) {
         //控制器还没有找到,则报错
         //404
         bus('e', ['msg' => '404 controller miss']);
         geter('e.e404');
         //                  echo $controller.'404 controller miss';
     }
     //实例化
     bus('controller', new $controller());
     //这里已经正常了
     bus('middlewareBefore', bus('controller')->middlewareBefore());
     bus('middlewareAfter', bus('controller')->middlewareAfter());
     bus('behavior', bus('controller')->behaviors());
     //寻找扩展方法
     if (!method_exists(bus('controller'), $action)) {
         bus('e', ['msg' => '404 method miss']);
         geter('e.e404');
         //                  echo $action.'404 method miss';
     }
     // Perform action
     return $next($request);
 }
Exemple #5
0
 public function doLoginPOST()
 {
     $password = bus('post')['password'];
     $userlogin = bus('post')['userlogin'];
     $user = geter('user.login.' . $userlogin);
     if (empty($user)) {
         echo json_encode(['code' => -200, 'msg' => '该用户不存在']);
         exit;
     }
     if (!$user['active']) {
         echo json_encode(['code' => -200, 'msg' => '不是有效用户']);
         exit;
     }
     //成功记录数据进入cookie
     //记录信息
     $tm = time();
     $sccheck = shamhash($userlogin, $tm);
     sapp('cookies')->set('userlogin', $userlogin);
     sapp('cookies')->set('logintime', $tm);
     sapp('cookies')->set('sccheck', $sccheck);
     echo json_encode(['code' => 200, 'msg' => 'ok']);
 }
Exemple #6
0
 public function doGet()
 {
     $geterlist = ['group.all', 'group.id.1', 'group.chr.2', 'user.info', 'user.group', 'user.rulelib', 'user.cookies', 'user.all', 'user.id.1', 'user.login.1'];
     foreach ($geterlist as $key) {
         geter($key);
     }
 }
Exemple #7
0
 public function doIndex()
 {
     //ruleLib不再管理范围之内,交给专门的程序去处理
     $where = 1;
     //去除无效的
     if ($_COOKIE['set_get_list']) {
         $where .= " and user.active != 0";
     }
     $res = sapp('db')->getall("\tselect user.* from user\n\t\t\t\t\t\t\t\t\twhere {$where}\n\t\t\t\t\t\t\t\t\torder by user.userId desc\n\t\t\t\t\t\t\t\t\t");
     view('', ['res' => $res, 'group' => geter('group.KeyGroupidActiveTrue')]);
 }
Exemple #8
0
$de = sapp('geter');
$de->get('gs.demo.123');
//-----------------------------------------------------
//调试模式
$de->actions();       //返回出所有的方法
echo $de;
$de->demo();
$de();
//-----------------------------------------------------
*/
$bus = sapp('bus');
$bus['uuu'] = 9999999999.0;
print_r($bus->all());
$key = 'gs.demo.123';
//Sham\Vo\Vo::getInstance()->make('geter')->get($key);
$ms = geter('gs.demo.123');
echo '<br>';
print_r($ms);
echo '<br>';
exit;
//$db =  sapp('Db');
//print_r($db());
//    //手动添加相对应的配置
//    $config = [
//        'afds'=>'adsffsdafdsa',
//        'afds1'=>'adsffsdafdsa',
//        'afds2'=>'adsffsdafdsa',
//        'afds3'=>'adsffsdafdsa',
//        'afds4'=>'adsffsdafdsa',
//    ];
//    //设置初始参数