1
0

errorview

This commit is contained in:
Mike Schwörer 2018-01-03 17:28:08 +01:00
parent 9bc4267c6a
commit 04a798bfa1
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
12 changed files with 209 additions and 69 deletions

View File

@ -25,6 +25,9 @@ body {
@media (min-width: 1200px) {
.content-responsive {
width: 1170px; } }
.content-fullheight {
flex-grow: 1; }
.contentheader {
width: 100%;
color: #333;
@ -134,6 +137,8 @@ html, body {
height: 100%; }
#mastercontainer {
display: flex;
flex-direction: column;
min-height: 100%;
position: relative; }
@ -448,6 +453,27 @@ html, body {
.bce_pag05 {
flex-direction: row; } }
.ev_master {
align-self: center; }
@media (min-width: 850px) {
.ev_master {
padding-bottom: 80px; } }
.ev_master .ev_code {
color: #000;
text-align: center;
font-size: 150pt;
font-weight: 500;
font-family: Consolas, Monaco, "Courier New", Menlo, monospace; }
.ev_master .ev_msg {
color: #888;
text-align: center;
font-size: 25pt; }
@media (max-width: 767px) {
.ev_master .ev_code {
font-size: 75pt; }
.ev_master .ev_msg {
font-size: 15pt; } }
.euler_pnl_base {
display: inline-flex;
flex-direction: column;

View File

@ -6,6 +6,7 @@
@import 'styles_bloglist';
@import 'styles_blogview';
@import 'styles_blogview_befunge';
@import 'styles_errorview';
@import 'styles_eulerpanel';
@import 'styles_bfjoustrunner';

View File

@ -0,0 +1,28 @@
@import 'styles_config';
.ev_master {
align-self: center;
@media(min-width:850px) {padding-bottom: 80px;}
.ev_code {
color: #000;
text-align: center;
font-size: 150pt;
font-weight: 500;
font-family: $FONT_CODE;
}
.ev_msg {
color: #888;
text-align: center;
font-size: 25pt;
}
@media(max-width:767px) {
.ev_code { font-size: 75pt; }
.ev_msg { font-size: 15pt; }
}
}

View File

@ -9,6 +9,8 @@ html, body {
// https://stackoverflow.com/a/19723677/1761622
#mastercontainer {
display:flex;
flex-direction: column;
min-height:100%;
position:relative;
}
@ -18,6 +20,7 @@ html, body {
#content {
padding-bottom:60px; /* Height of the footer */
}
#footerdiv {
position:absolute;
bottom:0;

View File

@ -24,6 +24,8 @@ body {
@media(min-width:992px) { .content-responsive { width: 724px; } }
@media(min-width:1200px){ .content-responsive { width: 1170px; } }
.content-fullheight { flex-grow: 1;}
.contentheader {
width: 100%;
color: $COL_TEXT_DARK;

View File

@ -9,7 +9,7 @@ $subview = $OPTIONS['subview'];
$euler = Euler::listAll();
$problem = Euler::getEulerProblemFromStrIdent($subview);
if ($post === NULL) httpError(404, 'problem not found');
if ($problem === NULL) httpError(404, 'Project Euler entry not found');
$pd = new ParsedownCustom();

View File

@ -70,17 +70,20 @@ $URL_RULES =
//#############################################################################
$path = strtolower(parse_url($_SERVER['REQUEST_URI'])['path']);
$pathparts = preg_split('@/@', $path, NULL, PREG_SPLIT_NO_EMPTY);
$partcount = count($pathparts);
try {
InitPHP();
global $OPTIONS;
global $HEADER_ACTIVE;
$path = strtolower(parse_url($_SERVER['REQUEST_URI'])['path']);
$pathparts = preg_split('@/@', $path, NULL, PREG_SPLIT_NO_EMPTY);
$partcount = count($pathparts);
$HEADER_ACTIVE = 'none';
global $OPTIONS;
global $HEADER_ACTIVE;
foreach ($URL_RULES as $rule)
{
$HEADER_ACTIVE = 'none';
foreach ($URL_RULES as $rule)
{
if ($partcount !== count($rule['url'])) continue;
$urlparams = [];
@ -130,13 +133,26 @@ foreach ($URL_RULES as $rule)
include $rule['target'];
return;
}
}
{
{
// [404] - Page Not Found
$OPTIONS = [];
include 'pages/error_404.php';
httpError('404', 'Page not found');
return;
}
} catch (Exception $e) {
if (isProd())
{
httpError('500 ', 'Internal server error');
}
else
{
echo '<table class="xdebug-error xe-uncaught-exception" dir="ltr" border="1" cellspacing="0" cellpadding="1">'.$e->xdebug_message.'</table>';
}
}

View File

@ -3,11 +3,28 @@
global $CONFIG;
$CONFIG = require 'config.php';
$CSS_BASE = ($CONFIG['prod']) ? ('styles.min.css') : ('styles.css');
global $CSS_BASE;
$CSS_BASE = ($CONFIG['prod']) ? ('/data/css/styles.min.css') : ('/data/css/styles.css');
global $REGISTERED_SCRIPTS;
$REGISTERED_SCRIPTS = [];
function InitPHP() {
set_error_handler("exception_error_handler"); // errors as exceptions for global catch
ob_start(); // buffer outpt so it can be discarded in httpError
}
function exception_error_handler($severity, $message, $file, $line) {
if (!(error_reporting() & $severity)) {
// This error code is not included in error_reporting
return;
}
throw new ErrorException($message, 0, $severity, $file, $line);
}
function startsWith($haystack, $needle)
{
$length = strlen($needle);
@ -22,7 +39,12 @@ function endsWith($haystack, $needle)
function httpError($errorcode, $message)
{
die($message);//TODO errorcode
ob_clean();
global $OPTIONS;
$OPTIONS = [ 'code' => $errorcode, 'message' => $message ];
require (__DIR__ . '/../pages/errorview.php');
die();
}
function destructiveUrlEncode($str) {
@ -82,3 +104,13 @@ function includeScriptOnce($script, $echo = true)
return "<script src=\"$script\" type=\"text/javascript\"></script>";
}
}
function printCSS() {
global $CSS_BASE;
echo '<link rel="stylesheet" href="' . $CSS_BASE . '"/>';
}
function isProd() {
global $CONFIG;
return $CONFIG['prod'];
}

View File

@ -12,7 +12,7 @@ $allposts = Blog::listAllOrderedDescending();
<title>Mikescher.com - Blog</title>
<meta name="google-site-verification" content="pZOhmjeJcQbRMNa8xRLam4dwJ2oYwMwISY1lRKreSSs"/>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<link rel="stylesheet" href="/data/css/styles.css"/>
<link rel="stylesheet" href="<?php printCSS(); ?>"/>
</head>
<body>
<div id="mastercontainer">

View File

@ -10,7 +10,7 @@ $subview = $OPTIONS['subview'];
$post = Blog::getBlogpost($id);
if ($post === NULL) httpError(404, 'blogpost not found');
if ($post === NULL) httpError(404, 'Blogpost not found');
?>
<head>
@ -18,7 +18,7 @@ if ($post === NULL) httpError(404, 'blogpost not found');
<title>Mikescher.com - Blog</title>
<meta name="google-site-verification" content="pZOhmjeJcQbRMNa8xRLam4dwJ2oYwMwISY1lRKreSSs"/>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<link rel="stylesheet" href="/data/css/styles.css"/>
<?php printCSS(); ?>
<?php
if ($post['type'] === 'euler' && $subview !== '')
{

32
www/pages/errorview.php Normal file
View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<?php
require_once (__DIR__ . '/../internals/base.php');
global $OPTIONS;
$errorcode = $OPTIONS['code'];
$errormsg = $OPTIONS['message'];
?>
<head>
<meta charset="utf-8">
<title>Mikescher.com - <?php echo $errormsg; ?></title>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<?php printCSS(); ?>
</head>
<body>
<div id="mastercontainer">
<?php $HEADER_ACTIVE='none'; include (__DIR__ . '/../fragments/header.php'); ?>
<div id="content" class="content-responsive content-fullheight">
<div class="ev_master">
<div class="ev_code"><?php echo $errorcode; ?></div>
<div class="ev_msg"><?php echo $errormsg; ?></div>
</div>
</div>
</div>
</body>
</html>

View File

@ -6,7 +6,7 @@
<title>Mikescher.com</title>
<meta name="google-site-verification" content="pZOhmjeJcQbRMNa8xRLam4dwJ2oYwMwISY1lRKreSSs"/>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<link rel="stylesheet" href="/data/css/styles.css"/>
<?php printCSS(); ?>
</head>
<body>
<div id="mastercontainer">