Exemplo n.º 1
0
 /**
  * 规范访问重写请求Url
  */
 protected function formatRequestURI()
 {
     //访问主域名
     if ($this->scriptUrl == '/') {
         return true;
     }
     //双//等处理
     if (String::exist($this->scriptUrl, '//')) {
         $this->scriptUrl = preg_replace('/\\/+/is', '/', $this->scriptUrl);
     }
     // 重写请求Url以横杠结尾时处理
     if (String::substr($this->scriptUrl, -1, 1) == '/') {
         $this->scriptUrl = String::substr($this->scriptUrl, 0, -1);
     }
     //有更改过scriptUrl,重新定位
     if ($this->scriptUrl != Param::getScriptUrl()) {
         $queryString = Param::getQueryString();
         Header::redirect($this->scriptUrl . ($queryString ? '?' . $queryString : ''));
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * 测试执行入口
  */
 public function runTest()
 {
     if (!\HuiLib\App\Request\RequestBase::isCli() && (APP_ENV == \HuiLib\Bootstrap::ENV_PRODUCTION || APP_ENV == \HuiLib\Bootstrap::ENV_STAGING)) {
         exit('not support.');
     }
     //bin运行
     if (RUN_METHOD == \HuiLib\Bootstrap::RUN_BIN) {
         if (!empty($_SERVER['argv'][1])) {
             $class = trim($_SERVER['argv'][1]);
         } else {
             exit('empty bin param.');
         }
         echo 'RUN_EVN:' . APP_ENV . PHP_EOL;
     } else {
         //web运行
         $queryString = \HuiLib\Helper\Param::getQueryString();
         parse_str($queryString, $info);
         if (empty($info)) {
             exit('empty web param.');
         }
         //获取类名
         $class = key($info);
     }
     //初始化测试库
     $instance = $class::getInstance();
     //执行
     $instance->run();
 }