protected static function parseUrl() { // 通过Rewrite得到,实现index.php单一入口 $url = Request::getGET('_sys_url_path', ''); $paths = explode('/', trim($url, '/')); foreach ($paths as $key => $value) { if ('' === $value) { unset($paths[$key]); continue; } } $paths = array_slice($paths, 0, 2); if (count($paths) == 0) { $paths[] = 'index'; } if (count($paths) == 1) { $paths[] = 'default'; } self::$CONTROLLER = $paths[0]; self::$ACTION = $paths[1]; // 校验controller if (!preg_match('/^[a-z][a-zA-z0-9_]*$/', self::$CONTROLLER)) { throw new FrameworkException('Url不合法1!'); } // 校验action if (!preg_match('/^[a-zA-z_][a-zA-z0-9_]*$/', self::$ACTION)) { throw new FrameworkException('Url不合法2!'); } self::$IS_AJAX = 0 === strpos(self::$ACTION, 'ajax') ? true : false; self::$IS_IFRAME = 0 === strpos(self::$ACTION, 'iframe') ? true : false; self::$CONTENT_TYPE = self::$IS_AJAX ? 'json' : 'html'; self::$CALLBACK = Request::getGET('callback', ''); // DIR & CLASS $pos = strrpos(self::$CONTROLLER, '_'); if ($pos === strlen(self::$CONTROLLER) - 1) { throw new FrameworkException('Url不合法!'); } self::$CLASS_DIR = false === $pos ? '' : str_replace('_', '/', substr(self::$CONTROLLER, 0, $pos - strlen(self::$CONTROLLER))); self::$CLASS_NAME = false === $pos ? ucfirst(self::$CONTROLLER) . 'Controller' : ucfirst(substr(self::$CONTROLLER, $pos + 1)) . 'Controller'; }