Beispiel #1
0
 public static function run()
 {
     !defined('APPROOT') && define('APPROOT', '../App/');
     sc(['debug' => dc('debug'), 'error_reporting' => dc('error_reporting'), 'mcaroot' => dc('mcaroot')]);
     // 应用到类
     //            set_error_handler(array('App\Application', 'my_error_handler'));
     //            示例的做法
     /*
     |------------------------------------------------
     | 错误抑制
     |------------------------------------------------
     */
     if (sc('debug')) {
         //错误报告
         ini_set('error_reporting', sc('error_reporting'));
     } else {
         //不报告任何错误
         error_reporting(0);
     }
     /*
     |------------------------------------------------
     | 初始化 App/Config/Config.php
     |------------------------------------------------
     */
     sapp('ap')->Middleware(['SysMiddlewareConfigini' => \Grace\Middleware\SysMiddlewareConfigini::class, 'SysMiddlewareEnvini' => \Grace\Middleware\SysMiddlewareEnvini::class, 'SysMiddlewareRouter' => \Grace\Middleware\SysMiddlewareRouter::class, 'SysMiddlewareBusbuild' => \Grace\Middleware\SysMiddlewareBusbuild::class]);
     //D(sc());
     //D(dc());          //debug = false 的时候置空
     /* -> 获得底层数据sc
        |------------------------------------------------
        | 初始化 App/Config/Config.php
        |------------------------------------------------
        |            开始释放控制权
        */
     self::DoController();
 }
Beispiel #2
0
 public function terminate($request = null)
 {
     $dc = dc();
     unset($dc['debug']);
     unset($dc['error_reporting']);
     unset($dc['App']);
     unset($dc['Env']);
     unset($dc['Module']['App']);
     unset($dc['Module']['Env']);
     unset($dc['Middleware']);
     unset($dc['Module']['Middleware']);
     unset($dc['Modulelist']);
     unset($dc['ActionExt']);
     unset($dc['Req']);
     unset($dc['Vo']);
     unset($dc['Usertable']);
     unset($dc['mcaroot']);
     unset($dc['Environment']);
     unset($dc['_page']);
     sc('Lb', $dc);
     //ok 完成了sc 的建立
     //unset(dc());
     //注销dc
     if (sc('debug')) {
         $this->res['end'] = $request;
         //记录结果数据
     } else {
         \Sham\Wise\Wise::getInstance()->_configdc = array();
         //值置空
     }
     //return $request;
 }
 public function handle($request, \Closure $next)
 {
     //初步建立bus
     bus('root', sc('Router')['m'] ? rtrim(APPROOT, '/') . '/Modules/' . sc('Modulelist')[sc('Router')['m']] . '/' : rtrim(APPROOT, '/') . '/');
     $m = sc('Router')['m'] ?: 'N';
     $c = sc('Router')['c'] ?: 'N';
     $a = sc('Router')['a'] ?: 'N';
     $e = sc('Router')['e'] ?: 'N';
     $t = sc('Router')['type'] ?: 'N';
     bus('mc', "{$m}.{$c}");
     bus('mca', "{$m}.{$c}.{$a}");
     bus('mcaet', "{$m}.{$c}.{$a}.{$e}.{$t}");
     bus('mcaroot', sc('mcaroot'));
     //bus('page', sc('Router')['m']."_".sc('Router')['c']."_".sc('Router')['a']);
     // bus('pageex', sc('Router')['m']."_".sc('Router')['c']."_".sc('Router')['a']."_".sc('Router')['e']."_".sc('Router')['type']);
     bus('app', sc('App'));
     bus('router', sc('Router'));
     bus('env', sc('Env'));
     bus('get', sapp('Req')->get);
     bus('post', sapp('Req')->post);
     bus('view', []);
     bus('_page', sc('_page'));
     // Perform action
     return $next($request);
 }
Beispiel #4
0
 public function _vv($middlewarekey = null)
 {
     if (!sc('debug')) {
         return null;
     }
     if ($middlewarekey) {
         return $this->middlewarelist[$middlewarekey]->view();
     } else {
         return $this->middlewarelist;
     }
 }
Beispiel #5
0
 public function handle($request, \Closure $next)
 {
     //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);
 }
 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);
 }
Beispiel #7
0
 public function handle($request, \Closure $next)
 {
     $action = 'do' . ucfirst(sc('Get')['a'] ?: sc('App')['default_controller_method']);
     if (sc('Get')['e']) {
         $action .= '_' . ucfirst(sc('Get')['e']);
     }
     if (sc('Environment')['REQUEST_METHOD'] != 'GET') {
         $action .= ucfirst(strtolower(sc('Environment')['REQUEST_METHOD']));
     }
     $tpl = sc('Get')['a'] ?: sc('App')['default_controller_method'];
     if (sc('Get')['e']) {
         $tpl .= '_' . sc('Get')['e'];
     }
     if (sc('Environment')['REQUEST_METHOD'] != 'GET') {
         $tpl .= strtolower(sc('Environment')['REQUEST_METHOD']);
     }
     //echo $action;
     sc('Router', ['type' => sc('Environment')['REQUEST_METHOD'], 'm' => sc('Get')['m'], 'c' => sc('Get')['c'] ?: sc('App')['default_controller'], 'a' => sc('Get')['a'] ?: sc('App')['default_controller_method'], 'e' => sc('Get')['e'], 'Prefix' => sc('App')['default_controller_method_prefix'], 'param' => sc('Get')['_param'], 'params' => sc('Get'), 'action' => $action, 'tpl' => $tpl]);
     // Perform action
     //建立router信息
     return $next($request);
 }
Beispiel #8
0
 public function terminate($request = null)
 {
     //处理结束后做一些操作
     // Store the session data...
     if (sc('debug')) {
         $this->res['end'] = $request;
     }
     //记录结果数据
     return $request;
 }
Beispiel #9
0
    // eenheden
    co('c33', '3025', 'BMI', '{"br" : "302505"}');
    //medisch develop
    ra('99', 'medisch rekenen');
    ra('9910', 'eenheden');
    ra('991010', 'inhoud');
    // medisch / eenheden / liter
    br('99101005', 'percentage van is', '{ "wd" : 10, "sm": "pc3", "as" : 8, "vr" : "ov", "t1" : "v1|t99", "t2" : "v1|t14", "bd" : "rk", "ku" : "991010a" }');
    ui('991010a', ' 1 procent (%) is 1 honderdste deel. bv 5 procent (%) = 10? 1% is dan 10 / 5 = 2. 100% = 100 x 2 = 200');
    co('c99', '9910', 'is percentage van', '{"br" : "99101005"}');
    // boodschappen
    bd('ovuh', 'bereken uit het hoofd en geef het juiste antwoord in');
    bd('ovpp', 'bereken op papier en geef het juiste antwoord in');
    bd('ovrk', 'bereken met rekenmachine  en geef het juiste antwoord in');
    bd('mkuh', 'bereken uit het hoofd en kies het juiste antwoord');
    bd('mkpp', 'bereken op papier en kies het juiste antwoord');
    bd('mkrk', 'bereken met rekenmachine  en kies het juiste antwoord');
    // schalen	stap | eenheid | metrische stap | factor om naar metrische stap te komen bv 20 om van druppels  naar ml
    // liters inhoud
    sc('l1', 'liter', '1|ml|1|1;2|cl|2|1;3|dl|3|1;4|l|4|1;di|1');
    sc('l2', 'liter en druppels', '1|druppels|1|20;2|ml|1|1;3|cl|2|1;4|dl|3|1;di|1');
    sc('l3', 'liter, cm³, cc, dm³', '1|cm³|1|1;2|cc|1|1;3|ml|1|1;4|cl|2|1;5|dl|3|1;6|l|4|1;7|dm³|4|1;di|1');
    sc('g1', 'gram', '1|microgram (µg = mcg)|1|1;2|milligram (mg)|4|1;3|gram(g)|7|1;4|kilogram (kg)|10|1;di|1');
    sc('g2', 'gram', '1|milligram (mg)|1|1;2|centigram(g)|2|1;3|decigram(g)|3|1;4|gram(g)|4|1;5|decagram(dag)|5|1;6|hectogram(hg)|6|1;7|kilogram (kg)|7|1;di|1');
    sc('m1', 'meter', '1|millimeter (mm)|1|1;2|centimeter (cm)|2|1;3|decimeter (dm)|3|1;4|meter (m)|4|1;5|decameter (dam)|5|1;6|hectometer (hm)|6|1;7|kilometer (km)|7|1;di|1');
    sc('m2', 'meter', '1|millimeter (mm²)|1|1;2|centimeter (cm²)|2|1;3|decimeter (dm²)|3|1;4|meter (m²)|4|1;5|decameter (dam²)|5|1;6|hectometer (hm²)|6|1;7|kilometer (km²)|7|1;di|2');
    sc('m3', 'meter', '1|millimeter (mm³)|1|1;2|centimeter (cm³)|2|1;3|decimeter (dm³)|3|1;4|meter (m³)|4|1;5|decameter (dam³)|5|1;6|hectometer (hm³)|6|1;7|kilometer (km³)|7|1;di|3');
    echo 'het zou erin moeten zitten<br>';
} else {
    echo "deze functie is niet voor iedereen";
}
Beispiel #10
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');
 }
Beispiel #11
0
/**
 * 终止程序运行
 * @param string $str 终止原因
 * @param bool $display 是否显示调用栈,默认不显示
 * @return void
 */
function halt($str)
{
    //Log::fatal($str.' debug_backtrace:'.var_export(debug_backtrace(), true));
    header("Content-Type:text/html; charset=utf-8");
    if (sc('debug')) {
        echo "<pre>";
        debug_print_backtrace();
        echo "</pre>";
    }
    echo $str;
    exit;
}