Beispiel #1
0
 function __construct()
 {
     $this->sysTags = [self::TAG_INIT, self::TAG_START, self::TAG_BEFORE, self::TAG_AFTER, self::TAG_ERROR, self::TAG_FINISH, self::TAG_SHUTDOWN];
     $options = Container::$config->get('debug.tracks');
     $enable = empty($options['enable']) ? false : $options['enable'];
     $this->enable = (bool) $enable;
     if (!$this->enable) {
         return;
     }
     $qauth = empty($options['qauth']) ? 'tracks' : $options['qauth'];
     $authval = Request::get($qauth);
     $this->enable = $options['secret'] == $authval;
 }
Beispiel #2
0
 /**
  * 生成 接口 模式的访问路径
  * 
  * @param  string $cmdId    命令标识
  * @param  array  $params   参数
  * 
  * @return string
  */
 public function jsonPathing($cmdId, $params = [])
 {
     $url = rtrim(Request::get_request_baseuri(), '\\/') . $this->config->get('app.mount');
     $url .= Cmd::build($cmdId, $params, Cmd::JSON);
     return $url;
 }
Beispiel #3
0
<?php

use Ws\Mvc\Request;
$sg = Request::get('sg', 500);
?>
<script src="//cdn.bootcss.com/jquery/1.11.2/jquery.js"></script>
<script>
    var ids = {};
    var calc_num = 0;
    var ii = 0;

    function setContent(json) {
        console.log(++ii);
        if (!json.id) return;
        var id = json.id;
        if (ids[id]) return;

        ids[id] = 1;
        calc_num++;

        $('#v-asdebug').prepend('<p>[' + calc_num + '] ' + json.create_at + '<br>' + json.content + '</p><hr>');

        if (calc_num == 500) {
            calc_num = 0;
            ids = {};
        }

    }

    function refresh() {
        $.ajax('<?php 
Beispiel #4
0
 /**
  * 解析请求并挂载到指定应用
  * 
  * @param  Request $request
  * 
  * @return \Ws\Mvc\App
  */
 private static function parseMointpoints(Request $request)
 {
     static $firstIs = true;
     $pathinfo = $request->pathinfo();
     \Ws\Debug\Tracks::instance()->track('sys:init', $pathinfo);
     $mounts = (array) self::$config->get('app.mounts');
     if ($firstIs) {
         // 格式化 $mounts
         foreach ($mounts as $appId => $options) {
             if (is_dir($options['dir'])) {
                 $options['dir'] = rtrim($options['dir'], '\\/');
                 $options['mount'] = rtrim($options['mount'], '\\/') . '/';
                 $options['len'] = strlen($options['mount']);
                 $mounts[$appId] = $options;
             } else {
                 unset($mounts[$appId]);
             }
         }
         $mounts = Arrays::sort_by_col($mounts, 'len', SORT_DESC);
         self::$config->set('app.mounts', $mounts);
         $firstIs = false;
     }
     $app = null;
     // 定位挂载点
     foreach ($mounts as $appId => $options) {
         $pa = $pathinfo;
         $idstr = '/^' . str_replace('/', '\\/', $options['mount']) . '/i';
         // 匹配pathinfo /a => /a/ 的区别
         if ($options['mount'] == "{$pa}/") {
             $pa = "{$pa}/";
         }
         if (preg_match($idstr, $pa)) {
             $app = self::loadApp($appId, $options);
             if (!empty($app)) {
                 $pathing = preg_replace($idstr, '', $pa);
                 $app->setPathing($pathing);
             }
             break;
         }
     }
     return $app;
 }
Beispiel #5
0
 public static function cmdBind(App $app)
 {
     Cmd::group([['id' => 'asdebug', 'event' => Request::GET, 'closure' => function ($a) {
         $f = Request::get('f');
         if ($f == 'json') {
             return AsDebug::instance()->cmdView($a, 'json');
         }
         return AsDebug::instance()->cmdView($a, 'ui');
     }]])->bindTo($app);
 }