Exemplo n.º 1
0
    /**
     * Displays the 403 page. User should write a 403 template and set it in the config file.
     *
     * @param string  $template
     * @param string $c_type
     * @return bool
     */
    public function display403($template = null, $c_type = self::TYPE_HTML)
    {
        if ($template) {
            $content = $this->environment - $this->render($template);
        } elseif (isset(Config::get($this->app->cfile)->page403) && ($tpl = Config::get($this->app->cfile)->page403)) {
            $content = $this->environment->render($tpl);
        } else {
            $content = <<<EOC
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>Forbidden area</title>
    </head>
    <body>
        <p>You shall not pass!</p>
    </body>
</html>
EOC;
        }
        ob_clean();
        ob_start();
        header("HTTP/1.1 . " . self::STATUS_FORBIDDEN);
        header("Content-Type: " . $c_type);
        echo $content;
        ob_end_flush();
        $this->app->end();
        exit;
    }
Exemplo n.º 2
0
 /**
  * Searches a matching route for the given uri
  *
  * @param string $uri
  * @return bool|\Calma\Mf\Routing\Route
  */
 public function search($uri)
 {
     foreach ($this->routes as $route) {
         if ($route->check($uri)) {
             $this->app->coreLogger()->addNotice("Found matching route {name}", array('name' => $route->getName()));
             return $route;
         }
         $this->app->coreLogger()->addDebug("Route {name} does't match.", array('name' => $route->getName()));
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * Emergency: system is unusable.
  *
  * @param string $msg
  * @param array $context
  */
 protected function emergency($msg, $context = array())
 {
     $this->app->appLogger()->addEmergency($msg, $context);
 }