Example #1
0
 /**
  * 初始化网址
  */
 public static function initUrl(\firegit\http\Request $req)
 {
     $url = $req->url;
     if (preg_match('#^\\/([a-zA-Z][a-zA-Z0-9\\-\\_]{2,19})(?:\\/([a-zA-Z][a-zA-Z0-9\\-\\_\\.]+)(\\/.*)?)?$#', $url, $ms)) {
         if (!isset($ms[2])) {
             $dir = GIT_REPO . $ms[1];
             if (is_dir($dir)) {
                 $req->url = '/group/' . $ms[1];
             }
             return;
         } else {
             if (substr($ms[2], -4) == '.git') {
                 header('Location: /' . $ms[1] . '/' . substr($ms[2], 0, -4) . (isset($ms[3]) ? $ms[3] : ''));
                 exit;
             }
         }
         $dir = GIT_REPO . $ms[1] . '/' . $ms[2] . '.git';
         if (is_dir($dir)) {
             $req->setData('gitGroup', $ms[1]);
             $req->setData('gitName', $ms[2]);
             $arr = explode('/', $url);
             $req->url = '/git/' . implode('/', array_slice($arr, 3));
             if (substr($dir, -9) == '.wiki.git' && isset($arr[3]) && $arr[3] == 'blob' && substr($arr[count($arr) - 1], -9) != '.markdown') {
                 $req->url .= '.markdown';
                 $req->ext = 'markdown';
             }
         }
     }
 }
Example #2
0
 /**
  * 内部跳转
  * @param string $uri
  * @param array $datas
  * @param array $headers
  */
 public static function innerDispatch($uri, $datas = array(), $headers = array())
 {
     $req = new Request($uri);
     foreach ($datas as $k => $v) {
         $req->setData($k, $v);
     }
     $res = new Response();
     $res->setHeader($headers);
     $ctl = self::getController($req, $res);
     if (method_exists($ctl, '_before')) {
         call_user_func(array($ctl, '_before'));
     }
     call_user_func_array(array($ctl, $ctl->method . self::METHOD_EXTENSION), $ctl->args);
     if (method_exists($ctl, '_after')) {
         call_user_func(array($ctl, '_after'));
     }
     // 清理掉所有的输出
     while (ob_get_clean()) {
         //
     }
     $res->output($req);
 }