Added HTTP error support
This commit is contained in:
parent
aa20b81229
commit
a4f7c80fe2
4 changed files with 15 additions and 11 deletions
|
@ -1,11 +1,11 @@
|
||||||
DirectorySlash Off
|
DirectorySlash Off
|
||||||
Options -Indexes
|
Options -Indexes
|
||||||
|
|
||||||
RewriteEngine On
|
ErrorDocument 403 /fatal-error/403
|
||||||
ErrorDocument 403 /dispatch.php?request=error/http&code=403
|
ErrorDocument 404 /fatal-error/404
|
||||||
ErrorDocument 404 /dispatch.php?request=error/http&code=404
|
ErrorDocument 500 /fatal-error/500
|
||||||
ErrorDocument 500 /dispatch.php?request=error/http&code=500
|
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
RewriteCond %{DOCUMENT_ROOT}/thumbs/$1.thumb -f
|
RewriteCond %{DOCUMENT_ROOT}/thumbs/$1.thumb -f
|
||||||
RewriteRule ^/?post/(.*)/thumb/?$ /thumbs/$1.thumb
|
RewriteRule ^/?post/(.*)/thumb/?$ /thumbs/$1.thumb
|
||||||
RewriteRule ^/?thumbs/(.*).thumb - [L,T=image/jpeg]
|
RewriteRule ^/?thumbs/(.*).thumb - [L,T=image/jpeg]
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
require_once '../src/core.php';
|
require_once '../src/core.php';
|
||||||
|
|
||||||
$query = rtrim($_SERVER['REQUEST_URI'], '/');
|
if (isset($_SERVER['REDIRECT_URL']))
|
||||||
|
$query = rtrim($_SERVER['REDIRECT_URL'], '/');
|
||||||
|
else
|
||||||
|
$query = rtrim($_SERVER['REQUEST_URI'], '/');
|
||||||
$context = Core::getContext();
|
$context = Core::getContext();
|
||||||
$context->query = $query;
|
$context->query = $query;
|
||||||
|
|
||||||
|
@ -70,12 +73,6 @@ try
|
||||||
throw new SimpleNotFoundException($query . ' not found.');
|
throw new SimpleNotFoundException($query . ' not found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (\Chibi\MissingViewFileException $e)
|
|
||||||
{
|
|
||||||
$context->json = true;
|
|
||||||
$context->layoutName = 'layout-json';
|
|
||||||
renderView();
|
|
||||||
}
|
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
if ($e instanceof SimpleNotFoundException)
|
if ($e instanceof SimpleNotFoundException)
|
||||||
|
|
|
@ -35,4 +35,9 @@ class StaticPagesController
|
||||||
$context->path = TextHelper::absolutePath($config->help->paths[$tab]);
|
$context->path = TextHelper::absolutePath($config->help->paths[$tab]);
|
||||||
$context->tab = $tab;
|
$context->tab = $tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fatalErrorView($code = null)
|
||||||
|
{
|
||||||
|
throw new SimpleException('Error ' . $code . ' while retrieving ' . $_SERVER['REQUEST_URI']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
\Chibi\Router::register(['StaticPagesController', 'mainPageView'], 'GET', '/index');
|
\Chibi\Router::register(['StaticPagesController', 'mainPageView'], 'GET', '/index');
|
||||||
\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help');
|
\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help');
|
||||||
\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help/{tab}');
|
\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help/{tab}');
|
||||||
|
\Chibi\Router::register(['StaticPagesController', 'fatalErrorView'], 'POST', '/fatal-error/{code}');
|
||||||
|
\Chibi\Router::register(['StaticPagesController', 'fatalErrorView'], 'GET', '/fatal-error/{code}');
|
||||||
|
|
||||||
\Chibi\Router::register(['AuthController', 'loginView'], 'GET', '/auth/login');
|
\Chibi\Router::register(['AuthController', 'loginView'], 'GET', '/auth/login');
|
||||||
\Chibi\Router::register(['AuthController', 'loginAction'], 'POST', '/auth/login');
|
\Chibi\Router::register(['AuthController', 'loginAction'], 'POST', '/auth/login');
|
||||||
|
|
Loading…
Reference in a new issue