Example #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;
    }