1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php namespace Maze\Routing;
- use Maze\Template\View;
- use Maze\Http\Output;
- use Maze\Security\Api;
- use Maze\Debug\Process as Debug;
- use Maze\Config\Load as Config;
- class Route
- {
- /**
- * Run the route service
- *
- * @return mixed
- */
- public function runing()
- {
- $uri = Uri::get();
- # 直接读取数据库或者类
- //if(strpos($uri, '-') !== false || strpos($uri, '.') !== false)
- # 更新只允许数据库中的带有*前缀的方法接口访问
- if(strpos($uri, '.') !== false || strpos($uri, '-*') !== false)
- {
- # 不允许带有_的直接浏览器访问
- if(strpos($uri, '._') !== false)
- {
- Output::abert('error_page');
- }
- Api::check($uri);
- $this->content = Load::get($uri, array());
-
- Api::out($this->content);
- }
- # 直接读取模板
- else
- {
- $this->content = View::getInstance(Uri::file())->runing();
- }
- return $this;
- }
- /**
- * out
- *
- * @return mixed
- */
- public function output()
- {
- if(!$this->content)
- {
- Output::abert('error_page');
- }
- $this->debug();
-
- Output::result($this->content, true, false);
- }
-
- /**
- * debug
- *
- * @return mixed
- */
- private function debug()
- {
- if(Debug::init() && is_string($this->content))
- {
- if(strpos($this->content, '</body>') >= 0)
- {
- $this->content = str_replace('</body>', Debug::html() . '</body>', $this->content);
- }
- else
- {
- $this->content = $this->content . Debug::html('');
- }
- }
- }
- }
|