路由方案：
(1) / -> Main.php::index()
(2) /aaa -> Aaa.php::index()
(3) /aaa/bbb/ccc -> aaa/bbb.php::ccc() -> aaa/bbb/Ccc.php::index()
183637
private static function route()
    {
        // Interceptor
        $interceptor = BLConfig::get('interceptor');
        if (!empty($interceptor)) {
            $interceptorClass = self::getClass($interceptor);
            if (!is_null($interceptorClass) && $interceptorClass->implementsInterface(BLInterceptor::class)) {
                $interceptor = $interceptorClass->newInstance();
            }
            $interceptor->before();
        }

        $path = isset($_SERVER['PATH_INFO']) ? explode('/', trim($_SERVER['PATH_INFO'], '/')) : [];
        BLLog::log(var_export($path, true));
        $size = sizeof($path);
        if ($size <= 0) {
            // (1)
            $result = self::tryInvoke(DEFAULT_CONTROLLER, DEFAULT_METHOD);
        } elseif ($size == 1) {
            // (2)
            $result = self::tryInvoke($path[0] ?: DEFAULT_CONTROLLER, DEFAULT_METHOD);
        } else {
            // (3)
            $result = self::tryInvoke($path[$size - 2], $path[$size - 1], join('/', array_slice($path, 0, $size - 2)));
            if (is_null($result)) {
                $result = self::tryInvoke($path[$size - 1], DEFAULT_METHOD, join('/', array_slice($path, 0, $size - 1)));
            }
        }

        if (!empty($interceptor)) {
            $interceptor->after();
        }

        // check again
        if ($result === false) {
            BLLog::log('Cannot find callable for path ' . $_SERVER['REQUEST_URI']);
            http_response_code(404);
            include 'template/not_found.php';
        }
        // output
        if ($result instanceof BLResponse) {
            http_response_code($result->getStatus());
            header('Content-Type:' . $result->getContentType());
            echo $result->getBody();
        } elseif ($result instanceof \Exception) {
            http_response_code(500);
            include 'template/exception.php';
        } else {
            echo $result;
        }
    }
307860
public function checkSinglePages()
    {
        $sg_pgs = @$this->config['single_pages'] ?: [];
        $sg_pgs = array_values($sg_pgs);
        // 检查需要剔除的页面
        $home_page = @$this->config['home_page'] ?: '';
        if (!empty($home_page)) {
            array_push($sg_pgs, $home_page);
        }
        if (!empty($sg_pgs)) {
            array_walk($sg_pgs, function(&$d){
                $source_dir = str_replace('\\', '/', $this->source_dir);
                $d = md5($source_dir . '/' . $d);
            });
        }
        $this->single_pages = $sg_pgs;
    }
738309
public function createHome()
    {
        // 检查是否设置了主页
        $home_page = @$this->config['home_page'] ?: '';
        if ( !empty($home_page) && file_exists($this->source_dir.DIRECTORY_SEPARATOR . $home_page) ) {
            // 渲染html
            $home_page = $this->source_dir.DIRECTORY_SEPARATOR . $home_page;
            $html = $this->renderArticle($home_page, true);
            // 创建文件
            $file_path = $this->public_dir . '/index.html';
            $this->fileSys->create($file_path, $html);
        }else{
            $files = $this->files;
            // 单页文件不解析
            foreach ($files as $key => $file) {
                if (in_array($file['page_uuid'], $this->single_pages)) {
                    unset($files[$key]);
                    continue;
                }
            }
            // 根据分页渲染
            $limit = $this->page_limit;
            $pages = ceil(count($files) / $limit);
            for ($i=1; $i <= $pages; $i++) {
                $repo = [];
                $path_key = '';
                if ($i == 1) {
                    $repo = array_slice($files, 0, $limit);
                    $path_key = '';
                }else{
                    $start = $limit * ($i-1);
                    $repo = array_slice($files, $start, $limit);
                    $path_key = 'page'.'-'.$i;
                }
                $html = $this->renderHome($repo, $pages, $i);

                // 处理路由
                $path_key = array_filter(explode('-', $path_key));
                $path = empty($path_key)? '' : implode('/', $path_key) . '/';
                $file_path = $this->public_dir .DIRECTORY_SEPARATOR. $path .'index.html';
                $this->fileSys->create($file_path, $html);
            }
        }
    }
329289
public function actionFilemanager()
    {
        //根目录路径，可以指定绝对路径，比如 /var/www/attached/
        $root_path = $this->getUploadPath() . '/';
        //根目录URL，可以指定绝对路径，比如 http://www.yoursite.com/attached/
        $root_url = $this->getUploadUrl() . '/';
        if (!file_exists($root_path)) {
            mkdir($root_path, 0755, true);
        }
        //图片扩展名
        $ext_arr = array('gif', 'jpg', 'jpeg', 'png', 'bmp');

        //目录名
        $dir_name = empty($_GET['dir']) ? '' : trim($_GET['dir']);
        if (!in_array($dir_name, array('', 'image', 'flash', 'media', 'file'))) {
            echo "Invalid Directory name.";
            exit;
        }
        if ($dir_name !== '') {
            $root_path .= $dir_name . "/";
            $root_url .= $dir_name . "/";
            if (!file_exists($root_path)) {
                mkdir($root_path, 0755);
            }
        }

        //根据path参数，设置各路径和URL
        if (empty($_GET['path'])) {
            $current_path = realpath($root_path) . '/';
            $current_url = $root_url;
            $current_dir_path = '';
            $moveup_dir_path = '';
        } else {
            $current_path = realpath($root_path) . '/' . $_GET['path'];
            $current_url = $root_url . $_GET['path'];
            $current_dir_path = $_GET['path'];
            $moveup_dir_path = preg_replace('/(.*?)[^\/]+\/$/', '$1', $current_dir_path);
        }
        //echo realpath($root_path);
        //排序形式，name or size or type
        $this->order = empty($_GET['order']) ? 'name' : strtolower($_GET['order']);

        //不允许使用..移动到上一级目录
        if (preg_match('/\.\./', $current_path)) {
            echo 'Access is not allowed.';
            exit;
        }
        //最后一个字符不是/
        if (!preg_match('/\/$/', $current_path)) {
            echo 'Parameter is not valid.';
            exit;
        }
        //目录不存在或不是目录
        if (!file_exists($current_path) || !is_dir($current_path)) {
            echo 'Directory does not exist.';
            exit;
        }

        //遍历目录取得文件信息
        $file_list = array();
        if ($handle = opendir($current_path)) {
            $i = 0;
            while (false !== ($filename = readdir($handle))) {
                if ($filename{0} == '.') continue;
                $file = $current_path . $filename;
                if (is_dir($file)) {
                    $file_list[$i]['is_dir'] = true; //是否文件夹
                    $file_list[$i]['has_file'] = (count(scandir($file)) > 2); //文件夹是否包含文件
                    $file_list[$i]['filesize'] = 0; //文件大小
                    $file_list[$i]['is_photo'] = false; //是否图片
                    $file_list[$i]['filetype'] = ''; //文件类别，用扩展名判断
                } else {
                    $file_list[$i]['is_dir'] = false;
                    $file_list[$i]['has_file'] = false;
                    $file_list[$i]['filesize'] = filesize($file);
                    $file_list[$i]['dir_path'] = '';
                    $file_ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                    $file_list[$i]['is_photo'] = in_array($file_ext, $ext_arr);
                    $file_list[$i]['filetype'] = $file_ext;
                }
                $file_list[$i]['filename'] = $filename; //文件名，包含扩展名
                $file_list[$i]['datetime'] = date('Y-m-d H:i:s', filemtime($file)); //文件最后修改时间
                $i++;
            }
            closedir($handle);
        }

        usort($file_list, array($this, 'cmp_func'));

        $result = array();
        //相对于根目录的上一级目录
        $result['moveup_dir_path'] = $moveup_dir_path;
        //相对于根目录的当前目录
        $result['current_dir_path'] = $current_dir_path;
        //当前目录的URL
        $result['current_url'] = $current_url;
        //文件数
        $result['total_count'] = count($file_list);
        //文件列表数组
        $result['file_list'] = $file_list;

        //输出JSON字符串
        header('Content-type: application/json; charset=UTF-8');
        echo json_encode($result);
        exit;
    }
415464
public static function getSupport()
    {
        //如果指定访问方式，则按指定的方式去访问
        if (isset(self::$way) && in_array(self::$way, [1, 2, 3]))
            return self::$way;

        //自动获取最佳访问方式
        if (function_exists('curl_init')) {//curl方式
            return 1;
        } else if (function_exists('fsockopen')) {//socket
            return 2;
        } else if (function_exists('file_get_contents')) {//php系统函数file_get_contents
            return 3;
        } else {
            return 0;
        }
    }
447858
protected function parseOptions()
    {
        $options = $this->getOptions();

        // 获取数据表
        if (empty($options['table'])) {
            $options['table'] = $this->getTable();
        }

        if (!isset($options['where'])) {
            $options['where'] = [];
        } elseif (isset($options['view'])) {
            // 视图查询条件处理
            $this->parseView($options);
        }

        if (!isset($options['field'])) {
            $options['field'] = '*';
        }

        foreach (['data', 'order'] as $name) {
            if (!isset($options[$name])) {
                $options[$name] = [];
            }
        }

        if (!isset($options['strict'])) {
            $options['strict'] = $this->getConfig('fields_strict');
        }

        foreach (['master', 'lock', 'fetch_pdo', 'distinct'] as $name) {
            if (!isset($options[$name])) {
                $options[$name] = false;
            }
        }

        if (isset(static::$readMaster['*']) || (is_string($options['table']) && isset(static::$readMaster[$options['table']]))) {
            $options['master'] = true;
        }

        foreach (['join', 'union', 'group', 'having', 'limit', 'force', 'comment'] as $name) {
            if (!isset($options[$name])) {
                $options[$name] = '';
            }
        }

        if (isset($options['page'])) {
            // 根据页数计算limit
            list($page, $listRows) = $options['page'];
            $page                  = $page > 0 ? $page : 1;
            $listRows              = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20);
            $offset                = $listRows * ($page - 1);
            $options['limit']      = $offset . ',' . $listRows;
        }

        $this->options = $options;

        return $options;
    }
549904
private function parseNetwork()
    {
        // 用户名密码认证处理
        $username = $this->request->getAttribute('username');
        if(null != $username)
        {
            $auth = base64_encode($username . ':' . $this->request->getAttribute('password', ''));
            $this->request = $this->request->withAddedHeader('Authorization', 'Basic ' . $auth);
        }
        // 超时
        $this->settings['timeout'] = $this->request->getAttribute('timeout', 30000) / 1000;
    }
262104
public function show() {
        if(0 == $this->totalRows) return '';

        /* 生成URL */
        $this->parameter[$this->p] = '[PAGE]';
        $this->url = U(ACTION_NAME, $this->parameter);
        /* 计算分页信息 */
        $this->totalPages = ceil($this->totalRows / $this->listRows); //总页数
        if(!empty($this->totalPages) && $this->nowPage > $this->totalPages) {
            $this->nowPage = $this->totalPages;
        }

        /* 计算分页临时变量 */
        $now_cool_page      = $this->rollPage/2;
		$now_cool_page_ceil = ceil($now_cool_page);
		$this->lastSuffix && $this->config['last'] = $this->totalPages;

        //上一页
        $up_row  = $this->nowPage - 1;
        $up_page = $up_row > 0 ? '<a class="prev" href="' . $this->url($up_row) . '">' . $this->config['prev'] . '</a>' : '';

        //下一页
        $down_row  = $this->nowPage + 1;
        $down_page = ($down_row <= $this->totalPages) ? '<a class="next" href="' . $this->url($down_row) . '">' . $this->config['next'] . '</a>' : '';

        //第一页
        $the_first = '';
        if($this->totalPages > $this->rollPage && ($this->nowPage - $now_cool_page) >= 1){
            $the_first = '<a class="first" href="' . $this->url(1) . '">' . $this->config['first'] . '</a>';
        }

        //最后一页
        $the_end = '';
        if($this->totalPages > $this->rollPage && ($this->nowPage + $now_cool_page) < $this->totalPages){
            $the_end = '<a class="end" href="' . $this->url($this->totalPages) . '">' . $this->config['last'] . '</a>';
        }

        //数字连接
        $link_page = "";
        for($i = 1; $i <= $this->rollPage; $i++){
			if(($this->nowPage - $now_cool_page) <= 0 ){
				$page = $i;
			}elseif(($this->nowPage + $now_cool_page - 1) >= $this->totalPages){
				$page = $this->totalPages - $this->rollPage + $i;
			}else{
				$page = $this->nowPage - $now_cool_page_ceil + $i;
			}
            if($page > 0 && $page != $this->nowPage){

                if($page <= $this->totalPages){
                    $link_page .= '<a class="num" href="' . $this->url($page) . '">' . $page . '</a>';
                }else{
                    break;
                }
            }else{
                if($page > 0 && $this->totalPages != 1){
                    $link_page .= '<span class="current">' . $page . '</span>';
                }
            }
        }

        //替换分页内容
        $page_str = str_replace(
            array('%HEADER%', '%NOW_PAGE%', '%UP_PAGE%', '%DOWN_PAGE%', '%FIRST%', '%LINK_PAGE%', '%END%', '%TOTAL_ROW%', '%TOTAL_PAGE%'),
            array($this->config['header'], $this->nowPage, $up_page, $down_page, $the_first, $link_page, $the_end, $this->totalRows, $this->totalPages),
            $this->config['theme']);
        return "<div>{$page_str}</div>";
    }
669657
public function run()
    {
        if ($this->is_route == true) {
            if ($this->segments instanceof \Closure) {
                echo call_user_func($this->segments);
                die();
            } else {
                $class = $this->getBundleUrl();
            }
        } else {
            $class = $this->getUnBundleUrl();

            if (!class_exists($class)) {

                $this->initDefaultRoute();

                $class = $this->getBundleUrl();
            }
        }

        if (!class_exists($class)) {
            $message = sprintf('No route found for "%s %s"', Zilf::$container['request']->getMethod(), Zilf::$container['request']->getPathInfo());

            if ($referer = Zilf::$container['request']->headers->get('referer')) {
                $message .= sprintf(' (from "%s")', $referer);
            }
            throw new NotFoundHttpException($message);
        }

        unset($this->segments);

        //将参数追加到GET里面
        if (!empty($this->params)) {
            foreach ($this->params as $key => $row) {
                if (is_string($key)) {
                    $_GET[$key] = $row;
                } else {
                    $_GET['zget' . $key] = $row;
                }
            }
            Zilf::$container->getShare('request')->query->add($_GET);
        }

        $object = Zilf::$container->build($class, []);
        if (method_exists($object, $this->action)) {

            $response = call_user_func_array(array($object, $this->action), $this->params);
            if (!$response instanceof Response) {
                $msg = sprintf('The controller must return a response (%s given).', $this->varToString($response));

                // the user may have forgotten to return something
                if (null === $response) {
                    $msg .= ' Did you forget to add a return statement somewhere in your controller?';
                }
                throw new \LogicException($msg);
            }
            $response->send();

        } else {
            throw new \Exception('类: ' . $class . ' 调用的方法：' . $this->action . ' 不存在！');
        }
    }
424624
function run()
    {
        // Set default error level, In dev env show all errors
        // ini_set('display_errors', Config::get('show_errors') ? 'Off' : 'Off');
        ini_set('display_errors', 'Off');
        error_reporting(E_ALL | E_STRICT);

        if (!defined('SERVER_MODE')) {
            // Mark server mode
            define('SERVER_MODE', 'fpm');
        }

        try {
            $route = (\ePHP\Core\Route::init())->findRoute();
            // dumpdie($route);

            if (empty($route)) {
                \show_404();
            }

            // 整理参数
            $_GET['controller'] = $route[0];
            $_GET['action']     = $route[1];

            $controller_name = $route[2];
            $action_name     = $_GET['action'];

            $_REQUEST  = array_merge($_COOKIE, $_GET, $_POST);

            // 检查ACTION是否存在
            if ( !method_exists($controller_name, $action_name) ) {
                if (defined('RUN_ENV') && RUN_ENV == 'prod') {
                    \show_404();
                } else {
                    \show_error("method {$action_name}() is not defined in {$controller_name}");
                }
            }

            if (SERVER_MODE === 'fpm') {
                call_user_func([new $controller_name(), $action_name]);
            } else if (SERVER_MODE === 'swoole') {
                try {
                    // $c_init = new $controller_name();
                    // // $c_init->request = $request;
                    // // $c_init->response = $response;

                    // $c_init->{$action_name}();
                    call_user_func([new $controller_name(), $action_name]);
                } catch (\Swoole\ExitException $e) {
                    // 屏蔽exit异常，不输出任何信息
                    return ;
                }
            }
        } catch (\ePHP\Exception\CommonException $e) {
            // ExitException don't show error message
            if ($e->getCode() === -99) {
                return ;
            }
            echo $e;
        }
    }
724842
static public function init() {
        // 加载动态应用公共文件和配置
        load_ext_file(COMMON_PATH);

        // 日志目录转换为绝对路径 默认情况下存储到公共模块下面
        C('LOG_PATH',   realpath(LOG_PATH).'/Common/');

        // 定义当前请求的系统常量
        define('NOW_TIME',      $_SERVER['REQUEST_TIME']);
        define('REQUEST_METHOD',$_SERVER['REQUEST_METHOD']);
        define('IS_GET',        REQUEST_METHOD =='GET' ? true : false);
        define('IS_POST',       REQUEST_METHOD =='POST' ? true : false);
        define('IS_PUT',        REQUEST_METHOD =='PUT' ? true : false);
        define('IS_DELETE',     REQUEST_METHOD =='DELETE' ? true : false);

        // URL调度
        Dispatcher:: ();

        if(C('REQUEST_VARS_FILTER')){
			// 全局安全过滤
			array_walk_recursive($_GET,		'think_filter');
			array_walk_recursive($_POST,	'think_filter');
			array_walk_recursive($_REQUEST,	'think_filter');
		}

        // URL调度结束标签
        Hook::listen('url_dispatch');

        define('IS_AJAX',       ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')])) ? true : false);

        // TMPL_EXCEPTION_FILE 改为绝对地址
        C('TMPL_EXCEPTION_FILE',realpath(C('TMPL_EXCEPTION_FILE')));
        return ;
    }
271991
public function gc()
    {
        $hasGC = false;
        $maxActiveTime = $this->config->getMaxActiveTime();
        $maxUsedTime = $this->config->getMaxUsedTime();
        foreach($this->pool as $key => $item)
        {
            if(
                (null !== $maxActiveTime && $item->isFree() && time() - $item->getCreateTime() >= $maxActiveTime) // 最大存活时间
                || (null !== $maxUsedTime && $item->getLastReleaseTime() < $item->getLastUseTime() && time() - $item->getLastUseTime() >= $maxUsedTime) // 每次获取资源最长使用时间
                )
            {
                $item->getResource()->close();
                unset($this->pool[$key]);
                $hasGC = true;
            }
        }
        if($hasGC)
        {
            $this->fillMinResources();
            $this->buildQueue();
        }
    }
562139
public function boot()
    {
        // 发布配置文件
        $this->publishes([
            __DIR__.'/../config/laravel-ddoc.php' => config_path('laravel-ddoc.php'),
        ]);
        // 发布视图文件
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'ddoc');
        $this->publishes([
            __DIR__.'/../resources/views' => base_path('resources/views/vendor/laravel-ddoc'),
        ]);
        // 发布资源文件
        $this->publishes([
            __DIR__.'/../public/' => public_path(''),
        ]);
        // 注册路由
        if ((method_exists($this->app, 'routesAreCached') && !$this->app->routesAreCached())
           || $this->isLumen()) {
            require __DIR__.'/routes.php';
        }
    }
1020686
private function startCommon(): void
    {
        if (self::$app !== null) {
            return;
        }
        self::$app = $this;
        // 加载框架配置文件
        $config = DataMap::loadFromPhpFile($this->mvcSourcePath . '/../config.inc.php');
        // 应用配置
        if ($this->config === null) {
            $appConfigFile = APP_CONFIG_PATH . '/./config.inc.php';
            if (is_file($appConfigFile)) {
                $appConfig = DataMap::loadFromPhpFile($appConfigFile);
                $config->mergeData($appConfig);
            }
        } else {
            $config->mergeData($this->config);
        }
        $this->config = $config;
        $this->loadContainer();
    }
677525
public function init(){
		$table_definition = $this->exdb->get_table_definition_all();
		// var_dump($table_definition);
		$error = array();
		foreach($table_definition->tables as $table_name=>$table_definition_row){
			// var_dump($table_definition_row);

			$sql_create_db = '';
			$sql_create_db .= 'CREATE TABLE '.$this->exdb->get_physical_table_name($table_definition_row->name).' (';
			$ary_table_columns = array();
			$ary_foreign_keys = array();
			foreach( $table_definition_row->columns as $column_definition ){
				$sql_column_definition = '';

				// セル名
				$sql_column_definition .= $column_definition->name;

				// 型
				switch(strtolower( $column_definition->type )){
					case 'email':
					case 'string':
					case 'password':
					case 'auto_id':
						$sql_column_definition .= ' VARCHAR';
						break;
					case 'create_date':
					case 'update_date':
					case 'delete_date':
						$sql_column_definition .= ' DATETIME';
						break;
					case 'int':
					case 'integer':
					case 'number':
					case 'auto_increment':
						$sql_column_definition .= ' INTEGER';
						break;
					case 'delete_flg':
						$sql_column_definition .= ' INTEGER';
						break;
					case 'text':
					case 'date':
					case 'datetime':
					default:
						$sql_column_definition .= ' '.strtoupper($column_definition->type);
						break;
				}

				// NOT NULL 制約
				if( @$column_definition->not_null ){
					$sql_column_definition .= ' NOT NULL';
				}

				// UNIQUE 制約
				if( @$column_definition->unique ){
					$sql_column_definition .= ' UNIQUE';
				}

				// FOREIGN KEY 制約
				if( @$column_definition->foreign_key ){
					$ary_foreign_keys[$column_definition->name] = $column_definition->foreign_key;
				}

				array_push($ary_table_columns, $sql_column_definition);
			}
			$sql_create_db .= implode($ary_table_columns, ',');

			if( count($ary_foreign_keys) ){
				// FOREIGN KEY 制約
				foreach($ary_foreign_keys as $colName=>$foreign_tbl_col){
					$sql_create_db .= ', FOREIGN KEY (';
					$sql_create_db .= $colName;
					$sql_create_db .= ')';
					$foreign_tbl_col = explode('.', $foreign_tbl_col);
					$sql_create_db .= ' REFERENCES '.$this->exdb->get_physical_table_name($foreign_tbl_col[0]).'('.$foreign_tbl_col[1].')';
				}
			}

			$sql_create_db .= ');';
			// var_dump($sql_create_db);
			$result = @$this->exdb->pdo()->query($sql_create_db);
			// var_dump($result);
			if( !$result ){
				array_push($error, '[ERROR] Failed to create table "'.$this->exdb->get_physical_table_name($table_definition_row->name).'"');
			}
		}
		// var_dump($error);
		$rtn = true;
		if(count($error)){$rtn = false;}
		return $rtn;
	}
885966
public function init($mains = null)
    {
        if(null === $mains)
        {
            $mains = MainHelper::getMains();
        }
        foreach($mains as $main)
        {
            // 扫描注解
            $this->loadModuleAnnotations($main->getNamespace());
        }
    }
1078362
public function run()
    {
        $option = $this->rule->getOption();

        // 检测路由after行为
        if (!empty($option['after'])) {
            $dispatch = $this->checkAfter($option['after']);

            if ($dispatch instanceof Response) {
                return $dispatch;
            }
        }

        // 数据自动验证
        if (isset($option['validate'])) {
            $this->autoValidate($option['validate']);
        }

        $data = $this->exec();

        return $this->autoResponse($data);
    }