1
0

ndex route works again

This commit is contained in:
Mike Schwörer 2020-01-15 02:50:23 +01:00
parent f9a692e635
commit 588e9b089a
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
30 changed files with 427 additions and 258 deletions

View File

@ -1900,6 +1900,7 @@ html, body {
/* 400px */
.ev_master {
align-self: center;
width: 100%;
}
@media (min-width: 851px) {
.ev_master {
@ -1918,6 +1919,15 @@ html, body {
text-align: center;
font-size: 25pt;
}
.ev_master .ev_statusmore {
color: #333333;
background-color: #BBBBBB;
text-align: left;
padding: 4px;
overflow-x: auto;
white-space: nowrap;
width: 100%;
}
@media (max-width: 767px) {
.ev_master .ev_code {
font-size: 75pt;

View File

@ -360,10 +360,11 @@ html,body{margin:0;padding:0;height:100%}
.wle_date{border-bottom:1px solid transparent;padding:2px;font-size:.8em;font-style:italic}
.wle_title{font-weight:bold;font-size:1.2em;text-align:left;margin:2px 0 2px 10px}
@media(max-width:767px){.wle_title{font-size:1.25em}}
.ev_master{align-self:center}
.ev_master{align-self:center;width:100%}
@media(min-width:851px){.ev_master{padding-bottom:80px}}
.ev_master .ev_code{color:#333;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}
.ev_master .ev_statusmore{color:#333;background-color:#bbb;text-align:left;padding:4px;overflow-x:auto;white-space:nowrap;width:100%}
@media(max-width:767px){
.ev_master .ev_code{font-size:75pt}
.ev_master .ev_msg{font-size:15pt}

View File

@ -3,6 +3,7 @@
.ev_master {
align-self: center;
width: 100%;
@include rdmedia_range(2,4) {padding-bottom: 80px;}
@ -20,6 +21,18 @@
font-size: 25pt;
}
.ev_statusmore {
color: $LAYER1_FG;
background-color: $LAYER1_BG_DARKER;
text-align: left;
padding: 4px;
overflow-x: auto;
white-space: nowrap;
width: 100%;
}
@include rdmedia(0) {
.ev_code { font-size: 75pt; }
.ev_msg { font-size: 15pt; }

View File

@ -1,22 +1,28 @@
<?php
require_once(__DIR__ . '/../internals/adventofcode.php');
require_once (__DIR__ . '/../internals/website.php');
$years = AdventOfCode::listYears();
$year = end($years);
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
<?php
$years = $SITE->modules->AdventOfCode()->listYears();
$year = intval(end($years));
?>
<div class="index_pnl_base">
<div class="index_pnl_header">
<a href="<?php echo AdventOfCode::getURLForYear($year); ?>">Advent of Code</a>
<a href="<?php echo $SITE->modules->AdventOfCode()->getURLForYear($year); ?>">Advent of Code</a>
</div>
<div class="index_pnl_content">
<?php
global $PARAM_AOCCALENDAR;
$PARAM_AOCCALENDAR = ['year' => $year, 'nav'=>true, 'linkheader'=>true, 'ajax'=>true];
require (__DIR__ . '/../fragments/panel_aoc_calendar.php')
?>
<?php $SITE->fragments->PanelAdventOfCodeCalendar($year, true, true, true); ?>
</div>

View File

@ -1,19 +1,30 @@
<?php
require_once (__DIR__ . '/../internals/website.php');
global $PARAM_AOCCALENDAR;
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
$year = $PARAM_AOCCALENDAR['year'];
$shownav = $PARAM_AOCCALENDAR['nav'];
$linkheader = $PARAM_AOCCALENDAR['linkheader'];
$ajax = $PARAM_AOCCALENDAR['ajax'];
$frame = isset($PARAM_AOCCALENDAR['frame']) ? $PARAM_AOCCALENDAR['frame'] : true;
$frameid = isset($PARAM_AOCCALENDAR['frameid']) ? $PARAM_AOCCALENDAR['frameid'] : ('aoc_frame_' . getRandomToken(16));
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
$assocdays = AdventOfCode::listSingleYearAssociative($year);
$prev_year = $shownav ? AdventOfCode::getPrevYear($year) : null;
$next_year = $shownav ? AdventOfCode::getNextYear($year) : null;
<?php
$year = $parameter['year'];
$shownav = $parameter['nav'];
$linkheader = $parameter['linkheader'];
$ajax = $parameter['ajax'];
$frame = $parameter['frame'];
$frameid = $parameter['frameid'];
if ($ajax) includeAdditionalScript("/data/javascript/aoc_panel_interactive.js", 'defer', true);
$AOC = $SITE->modules->AdventOfCode();
$assocdays = $AOC->listSingleYearAssociative($year);
$prev_year = $shownav ? $AOC->getPrevYear($year) : null;
$next_year = $shownav ? $AOC->getNextYear($year) : null;
if ($ajax) $FRAME_OPTIONS->addScript("/data/javascript/aoc_panel_interactive.js", true);
?>
@ -26,14 +37,14 @@ if ($ajax) includeAdditionalScript("/data/javascript/aoc_panel_interactive.js",
if ($ajax)
echo '<a href="javascript:void();" onclick="javascript:changeAOCPanel(' . $prev_year . ', ' . ($shownav?'true':'false') . ', ' . ($linkheader?'true':'false') . ', ' . ($ajax?'true':'false') . ', \'' . $frameid . '\')" class="aoc_calendar_header_link aoc_prev" >&lt;</a>';
else
echo '<a href="' . AdventOfCode::getURLForYear($prev_year) . '" class="aoc_calendar_header_link aoc_prev" >&lt;</a>';
echo '<a href="' . $AOC->getURLForYear($prev_year) . '" class="aoc_calendar_header_link aoc_prev" >&lt;</a>';
}
else
{
echo '<a href="#" class="aoc_calendar_header_link aoc_prev aoc_link_hidden" >&lt;</a>';
}
if ($linkheader) echo '<span class="aoc_calendar_header_title"><a href="' . AdventOfCode::getURLForYear($year) . '">'.$year.'</a></span>';
if ($linkheader) echo '<span class="aoc_calendar_header_title"><a href="' . $AOC->getURLForYear($year) . '">'.$year.'</a></span>';
else echo '<span class="aoc_calendar_header_title">'.$year.'</span>';
if ($next_year !== null)
@ -41,7 +52,7 @@ if ($ajax) includeAdditionalScript("/data/javascript/aoc_panel_interactive.js",
if ($ajax)
echo '<a href="javascript:void();" onclick="javascript:changeAOCPanel(' . $next_year . ', ' . ($shownav?'true':'false') . ', ' . ($linkheader?'true':'false') . ', ' . ($ajax?'true':'false') . ', \'' . $frameid . '\')" class="aoc_calendar_header_link aoc_next" >&gt;</a>';
else
echo '<a href="' . AdventOfCode::getURLForYear($next_year) . '" class="aoc_calendar_header_link aoc_next" >&gt;</a>';
echo '<a href="' . $AOC->getURLForYear($next_year) . '" class="aoc_calendar_header_link aoc_next" >&gt;</a>';
}
else
{

View File

@ -1,7 +1,19 @@
<?php
require_once(__DIR__ . '/../internals/blog.php');
require_once (__DIR__ . '/../internals/website.php');
$allposts = Blog::listAllNewestFirst();
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
<?php
$BLOG = $SITE->modules->Blog();
$allposts = $BLOG->listAllNewestFirst();
?>
<div class="index_pnl_base">

View File

@ -1,7 +1,19 @@
<?php
require_once(__DIR__ . '/../internals/books.php');
require_once (__DIR__ . '/../internals/website.php');
$allbooks = Books::listAllNewestFirst();
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
<?php
$BOOKS = $SITE->modules->Books();
$allbooks = $BOOKS->listAllNewestFirst();
?>
<div class="index_pnl_base">

View File

@ -1,7 +1,19 @@
<?php
require_once(__DIR__ . '/../internals/euler.php');
require_once (__DIR__ . '/../internals/website.php');
$euler = Euler::listAll();
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
<?php
$EULER = $SITE->modules->Euler();
$data = $EULER->listAll();
$RATING_CLASSES = ['euler_pnl_celltime_perfect', 'euler_pnl_celltime_good', 'euler_pnl_celltime_ok', 'euler_pnl_celltime_bad', 'euler_pnl_celltime_fail'];
?>
@ -18,7 +30,7 @@
$arr = [];
$max = 0;
foreach ($euler as $problem)
foreach ($data as $problem)
{
$max = max($max, $problem['number']);
$arr[$problem['number']] = $problem;

View File

@ -1,7 +1,19 @@
<?php
require_once(__DIR__ . '/../internals/programs.php');
require_once (__DIR__ . '/../internals/website.php');
$allprograms = Programs::listAllNewestFirst();
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
<?php
$PROGRAMS = $SITE->modules->Programs();
$allprograms = $PROGRAMS->listAllNewestFirst();
?>
<div class="index_pnl_base">

View File

@ -20,7 +20,7 @@ require_once (__DIR__ . '/../internals/website.php');
foreach ($FRAME_OPTIONS->stylesheets as $cssfile) echo '<link rel="stylesheet" href="' . $cssfile . '"/>';
foreach ($FRAME_OPTIONS->scripts as $scriptfile)
{
if ($scriptfile[1]) echo '<script src="' . $scriptfile[0] . '" defer/>';
if ($scriptfile[1]) echo '<script src="' . $scriptfile[0] . '" defer></script>';
else echo '<script src="' . $scriptfile[0] . '" type="text/javascript" ></script>';
}
?>

View File

@ -0,0 +1,52 @@
<!DOCTYPE html>
<?php
require_once (__DIR__ . '/../internals/website.php');
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
?>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo $FRAME_OPTIONS->title; ?></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" />
</head>
<body>
<div id="mastercontainer">
<div id="headerdiv">
<div class="logowrapper">
<a href="/"><img class="logo" src="/data/images/logo.png" alt="Mikescher.com Logo" /></a>
</div>
<div class="tabrow">
<a class="tab" href="/">Home</a>
<a class="tab" href="/blog/1/Project_Euler_with_Befunge">Project Euler</a>
<a class="tab" href="/blog">Blog</a>
<a class="tab" href="/programs">Programs</a>
<a class="tab" href="/webapps">Tools</a>
<a class="tab" href="/about">About</a>
<div class="tab_split" ></div>
<a class="tab tab_github" href="https://github.com/Mikescher/">Github</a>
</div>
</div>
<div id="content" class="<?php echo join(' ', $FRAME_OPTIONS->contentCSSClasses); ?>">
<?php echo $FRAME_OPTIONS->raw; ?>
</div>
<div id="footerdiv" class="content-responsive">
<hr />
made with vanilla PHP and MySQL<span class="footerspan2">, no frameworks, no bootstrap, no unnecessary* javascript</span>
</div>
</div>
</body>
</html>

View File

@ -1,34 +0,0 @@
<?php
require_once 'website.php';
class AlephNoteStatistics
{
/** @var Website */
private $site;
public function __construct(Website $site)
{
$this->site = $site;
}
public function getTotalUserCount()
{
return $this->site->Database()->sql_query_num('SELECT COUNT(*) FROM an_statslog WHERE NoteCount>0');
}
public function getUserCountFromLastVersion()
{
return $this->site->Database()->sql_query_num('SELECT COUNT(*) FROM an_statslog WHERE NoteCount>0 GROUP BY Version ORDER BY INET_ATON(Version) DESC LIMIT 1');
}
public function getActiveUserCount($days)
{
return $this->site->Database()->sql_query_num('SELECT COUNT(*) FROM an_statslog WHERE NoteCount>0 AND LastChanged > NOW() - INTERVAL '.$days.' DAY');
}
public function getAllActiveEntriesOrdered()
{
return $this->site->Database()->sql_query_assoc('SELECT * FROM an_statslog WHERE NoteCount>0 ORDER BY LastChanged DESC');
}
}

View File

@ -0,0 +1,48 @@
<?php
class Fragments
{
public function PanelEuler()
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ ];
include (__DIR__ . '/../fragments/panel_euler.php');
}
public function PanelPrograms()
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ ];
include (__DIR__ . '/../fragments/panel_programs.php');
}
public function PanelBlog()
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ ];
include (__DIR__ . '/../fragments/panel_blog.php');
}
public function PanelBooks()
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ ];
include (__DIR__ . '/../fragments/panel_books.php');
}
public function PanelAdventOfCode()
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ ];
include (__DIR__ . '/../fragments/panel_aoc.php');
}
public function PanelAdventOfCodeCalendar(int $year, bool $shownav, bool $linkheader, bool $ajax, bool $frame=true, $frameid=null)
{
if ($frameid == null) $frameid = 'aoc_frame_' . getRandomToken(16);
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ 'year' => $year, 'nav'=>$shownav, 'linkheader'=>$linkheader, 'ajax'=>$ajax, 'frame'=>$frame, 'frameid'=>$frameid ];
include (__DIR__ . '/../fragments/panel_aoc_calendar.php');
}
}

86
www/internals/modules.php Normal file
View File

@ -0,0 +1,86 @@
<?php
require_once 'website.php';
class Modules
{
/** @var Database|null */ private $database = null;
/** @var AdventOfCode|null */ private $adventOfCode = null;
/** @var Blog|null */ private $blog = null;
/** @var Books|null */ private $books = null;
/** @var Euler|null */ private $euler = null;
/** @var Programs|null */ private $programs = null;
/** @var AlephNoteStatistics|null */ private $anstats = null;
/** @var UpdatesLog|null */ private $updateslog = null;
/** @var WebApps|null */ private $webapps = null;
/** @var MikescherGitGraph|null */ private $extendedgitgraph = null;
/** @var Website */
private $site;
public function __construct(Website $site)
{
$this->site = $site;
}
public function Database()
{
if ($this->database === null) { require_once 'modules/database.php'; $this->database = new Database($this->site); }
return $this->database;
}
public function AdventOfCode(): AdventOfCode
{
if ($this->adventOfCode === null) { require_once 'modules/adventofcode.php'; $this->adventOfCode = new AdventOfCode(); }
return $this->adventOfCode;
}
public function Blog(): Blog
{
if ($this->blog === null) { require_once 'modules/blog.php'; $this->blog = new Blog(); }
return $this->blog;
}
public function Books(): Books
{
if ($this->books === null) { require_once 'modules/books.php'; $this->books = new Books(); }
return $this->books;
}
public function Euler(): Euler
{
if ($this->euler === null) { require_once 'modules/euler.php'; $this->euler = new Euler(); }
return $this->euler;
}
public function Programs(): Programs
{
if ($this->programs === null) { require_once 'modules/programs.php'; $this->programs = new Programs(); }
return $this->programs;
}
public function AlephNoteStatistics(): AlephNoteStatistics
{
if ($this->anstats === null) { require_once 'modules/alephnoteStatistics.php'; $this->anstats = new AlephNoteStatistics($this->site); }
return $this->anstats;
}
public function UpdatesLog(): UpdatesLog
{
if ($this->updateslog === null) { require_once 'modules/updateslog.php'; $this->updateslog = new UpdatesLog($this->site); }
return $this->updateslog;
}
public function WebApps(): WebApps
{
if ($this->webapps === null) { require_once 'modules/webapps.php'; $this->webapps = new WebApps(); }
return $this->webapps;
}
public function ExtendedGitGraph(): MikescherGitGraph
{
if ($this->extendedgitgraph === null) { require_once 'modules/mikeschergitgraph.php'; $this->extendedgitgraph = new MikescherGitGraph($this->site); }
return $this->extendedgitgraph;
}
}

View File

@ -1,7 +1,5 @@
<?php
require_once 'website.php';
class AdventOfCode
{
const YEARS =
@ -35,7 +33,7 @@ class AdventOfCode
private function load()
{
$all = require (__DIR__ . '/../statics/aoc/__all.php');
$all = require (__DIR__ . '/../../statics/aoc/__all.php');
array_walk($all, function(&$value, $year) { array_walk($value, function (&$innervalue) use ($year) { $innervalue = self::readSingle($year, $innervalue); }); });

View File

@ -0,0 +1,32 @@
<?php
class AlephNoteStatistics
{
/** @var Website */
private $site;
public function __construct(Website $site)
{
$this->site = $site;
}
public function getTotalUserCount()
{
return $this->site->modules->Database()->sql_query_num('SELECT COUNT(*) FROM an_statslog WHERE NoteCount>0');
}
public function getUserCountFromLastVersion()
{
return $this->site->modules->Database()->sql_query_num('SELECT COUNT(*) FROM an_statslog WHERE NoteCount>0 GROUP BY Version ORDER BY INET_ATON(Version) DESC LIMIT 1');
}
public function getActiveUserCount($days)
{
return $this->site->modules->Database()->sql_query_num('SELECT COUNT(*) FROM an_statslog WHERE NoteCount>0 AND LastChanged > NOW() - INTERVAL '.$days.' DAY');
}
public function getAllActiveEntriesOrdered()
{
return $this->site->modules->Database()->sql_query_assoc('SELECT * FROM an_statslog WHERE NoteCount>0 ORDER BY LastChanged DESC');
}
}

View File

@ -1,7 +1,5 @@
<?php
require_once 'website.php';
class Blog
{
/** @var array */
@ -14,7 +12,7 @@ class Blog
private function load()
{
$all = require (__DIR__ . '/../statics/blog/__all.php');
$all = require (__DIR__ . '/../../statics/blog/__all.php');
$this->staticData = array_map(function($a){return self::readSingle($a);}, $all);
}
@ -66,8 +64,7 @@ class Blog
$eulerproblem = null;
if ($isSubEuler)
{
require_once(__DIR__ . '/../internals/euler.php');
$eulerproblem = Website::inst()->Euler()->getEulerProblemFromStrIdent($subview);
$eulerproblem = Website::inst()->modules->Euler()->getEulerProblemFromStrIdent($subview);
if ($eulerproblem === null) { $error="Project Euler entry not found"; return null; }
$post['submodel'] = $eulerproblem;
$post['issubview'] = true;
@ -77,8 +74,7 @@ class Blog
$adventofcodeday = null;
if ($isSubAdventOfCode)
{
require_once(__DIR__ . '/../internals/adventofcode.php');
$adventofcodeday = Website::inst()->AdventOfCode()->getDayFromStrIdent($post['extras']['aoc:year'], $subview);
$adventofcodeday = Website::inst()->modules->AdventOfCode()->getDayFromStrIdent($post['extras']['aoc:year'], $subview);
if ($adventofcodeday === null) { $error="AdventOfCode entry not found"; return null; }
$post['submodel'] = $adventofcodeday;
$post['issubview'] = true;

View File

@ -1,7 +1,5 @@
<?php
require_once 'website.php';
class Books
{
/** @var array */
@ -14,7 +12,7 @@ class Books
private function load()
{
$all = require (__DIR__ . '/../statics/books/__all.php');
$all = require (__DIR__ . '/../../statics/books/__all.php');
$this->staticData = array_map(function($a){return self::readSingle($a);}, $all);
}

View File

@ -1,7 +1,5 @@
<?php
require_once 'website.php';
class Database
{
/* @var PDO $pdo */

View File

@ -1,7 +1,5 @@
<?php
require_once 'website.php';
class Euler
{
/** @var array */
@ -14,7 +12,7 @@ class Euler
private function load()
{
$all = require (__DIR__ . '/../statics/euler/__all.php');
$all = require (__DIR__ . '/../../statics/euler/__all.php');
$this->staticData = array_map(function($a){return self::readSingle($a);}, $all);
}

View File

@ -1,7 +1,6 @@
<?php
require_once 'website.php';
require_once (__DIR__ . '/../extern/egg/ExtendedGitGraph2.php');
require_once (__DIR__ . '/../../extern/egg/ExtendedGitGraph2.php');
class MikescherGitGraph
{
@ -16,7 +15,7 @@ class MikescherGitGraph
public function getPathRenderedData()
{
return __DIR__ . '/../dynamic/egg/cache_fullrenderer.html';
return __DIR__ . '/../../dynamic/egg/cache_fullrenderer.html';
}
/**
@ -32,7 +31,7 @@ class MikescherGitGraph
public function checkConsistency()
{
$p =$this->getPathRenderedData();
$p = $this->getPathRenderedData();
if (!file_exists($p)) return ['result'=>'err', 'message' => 'Rendered data not found'];

View File

@ -1,7 +1,5 @@
<?php
require_once 'website.php';
class Programs
{
const PROG_LANGS = [ 'Java', 'C#', 'Delphi', 'PHP', 'C++' ];
@ -43,7 +41,7 @@ class Programs
private function load()
{
$all = require (__DIR__ . '/../statics/programs/__all.php');
$all = require (__DIR__ . '/../../statics/programs/__all.php');
$this->staticData = array_map(function($a){return self::readSingle($a);}, $all);
}
@ -197,7 +195,7 @@ class Programs
public function getDirectDownloadPath($prog)
{
return (__DIR__ . '/../data/binaries/'.$prog['internal_name'].'.zip');
return (__DIR__ . '/../../data/binaries/'.$prog['internal_name'].'.zip');
}
public function checkConsistency()

View File

@ -1,7 +1,5 @@
<?php
require_once (__DIR__ . '/../internals/database.php');
class UpdatesLog
{
/** @var Website */
@ -18,7 +16,7 @@ class UpdatesLog
private function load()
{
$all = require (__DIR__ . '/../statics/blog/__all.php');
$all = require (__DIR__ . '/../../statics/blog/__all.php');
$this->staticData = array_map(function($a){return self::readSingle($a);}, $all);
}
@ -37,12 +35,12 @@ class UpdatesLog
{
$ip = get_client_ip();
$ippath = (__DIR__ . '/../dynamic/self_ip_address.auto.cfg');
$ippath = (__DIR__ . '/../../dynamic/self_ip_address.auto.cfg');
$self_ip = file_exists($ippath) ? file_get_contents($ippath) : 'N/A';
if ($self_ip === $ip) $ip = "self";
$this->site->Database()->sql_exec_prep("INSERT INTO updateslog (programname, ip, version, date) VALUES (:pn, :ip, :vn, NOW())",
$this->site->modules->Database()->sql_exec_prep("INSERT INTO updateslog (programname, ip, version, date) VALUES (:pn, :ip, :vn, NOW())",
[
[':pn', $name, PDO::PARAM_STR],
[':ip', $ip, PDO::PARAM_STR],
@ -52,12 +50,12 @@ class UpdatesLog
public function listProgramsInformation()
{
return $this->site->Database()->sql_query_assoc('SELECT programname AS name, Count(*) as count_total, MAX(date) AS last_query, (SELECT COUNT(*) FROM updateslog AS u1 WHERE u1.programname=u0.programname AND NOW() - INTERVAL 7 DAY < u1.date) AS count_week FROM updateslog AS u0 GROUP BY programname');
return $this->site->modules->Database()->sql_query_assoc('SELECT programname AS name, Count(*) as count_total, MAX(date) AS last_query, (SELECT COUNT(*) FROM updateslog AS u1 WHERE u1.programname=u0.programname AND NOW() - INTERVAL 7 DAY < u1.date) AS count_week FROM updateslog AS u0 GROUP BY programname');
}
public function getEntries($name, $limit)
{
return $this->site->Database()->sql_query_assoc_prep('SELECT * FROM updateslog WHERE programname = :pn ORDER BY date DESC LIMIT :lt',
return $this->site->modules->Database()->sql_query_assoc_prep('SELECT * FROM updateslog WHERE programname = :pn ORDER BY date DESC LIMIT :lt',
[
[':pn', $name, PDO::PARAM_STR],
[':lt', $limit, PDO::PARAM_INT],

View File

@ -1,7 +1,5 @@
<?php
require_once 'website.php';
class WebApps
{
/** @var array */
@ -14,7 +12,7 @@ class WebApps
private function load()
{
$all = require (__DIR__ . '/../statics/webapps/__all.php');
$all = require (__DIR__ . '/../../statics/webapps/__all.php');
$this->staticData = array_map(function($a){return self::readSingle($a);}, $all);
}
@ -31,5 +29,3 @@ class WebApps
return $data;
}
}

View File

@ -101,7 +101,6 @@ class RuleEngine
{
// enforce https
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
ob_end_clean();
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();

View File

@ -44,7 +44,8 @@ class URLRoute
*/
public function getDirect(Website $site, PageFrameOptions $pfo): PageFrameOptions
{
@ob_end_clean();
try
{
ob_start();
global $ROUTE;
@ -57,10 +58,15 @@ class URLRoute
/** @noinspection PhpIncludeInspection */
require $this->targetpath;
$FRAME_OPTIONS->raw = ob_get_clean();
$FRAME_OPTIONS->raw = ob_get_contents();
return $FRAME_OPTIONS;
}
finally
{
ob_end_clean();
}
}
/**
* @param URLRoute $route

View File

@ -23,25 +23,6 @@ function endsWith($haystack, $needle)
return $length === 0 || (substr($haystack, -$length) === $needle);
}
function httpError($errorcode, $message)
{
ob_clean();
http_response_code($errorcode);
global $OPTIONS;
$OPTIONS = [ 'code' => $errorcode, 'message' => $message ];
require (__DIR__ . '/../pages/errorview.php');
die();
}
function httpDie($errorcode, $message)
{
ob_flush();
http_response_code($errorcode);
die($message);
}
function destructiveUrlEncode($str) {
$str = str_replace(' ', '_', $str);
$str = str_replace('+', '_', $str);
@ -342,6 +323,7 @@ function formatException($e)
$xdbg = str_replace('<br />', "\n", $xdbg);
$xdbg = str_replace('<br/>', "\n", $xdbg);
$xdbg = str_replace('<br>', "\n", $xdbg);
$xdbg = str_replace('><', "> <", $xdbg);
$xdbg = strip_tags($xdbg);
$xdbg = htmlspecialchars($xdbg);
$r .= $xdbg . "\n";

View File

@ -3,6 +3,8 @@
require_once 'ruleengine.php';
require_once 'urlroute.php';
require_once 'pageframeoptions.php';
require_once 'modules.php';
require_once 'fragments.php';
require_once 'utils.php';
@ -17,16 +19,11 @@ class Website
/** @var bool|null */
public $isLoggedIn = null;
/** @var Database|null */ private $database = null;
/** @var AdventOfCode|null */ private $adventOfCode = null;
/** @var Blog|null */ private $blog = null;
/** @var Books|null */ private $books = null;
/** @var Euler|null */ private $euler = null;
/** @var Programs|null */ private $programs = null;
/** @var AlephNoteStatistics|null */ private $anstats = null;
/** @var UpdatesLog|null */ private $updateslog = null;
/** @var WebApps|null */ private $webapps = null;
/** @var MikescherGitGraph|null */ private $extendedgitgraph = null;
/** @var Modules */
public $modules;
/** @var Fragments */
public $fragments;
public function init()
{
@ -43,6 +40,10 @@ class Website
error_reporting(E_ALL);
}
$this->modules = new Modules($this);
$this->fragments = new Fragments();
self::$instance = $this;
}
catch (exception $e)
@ -70,16 +71,11 @@ class Website
exit();
}
if ($result->contentType !== null) header('Content-Type: ' . $result->contentType);
http_response_code($result->statuscode);
$this->output($result, $route);
exit();
}
catch (Exception $e)
{
$this->serveServerError(null, formatException($e), null);
$this->serveServerError("Internal Server Error", formatException($e), null);
}
}
@ -87,8 +83,6 @@ class Website
{
try
{
@ob_end_clean();
$frameOpt->statuscode = 404;
$frameOpt->title = 'Page not found';
@ -100,23 +94,21 @@ class Website
}
catch (Exception $e)
{
$this->serveServerError(null, formatException($e), null);
$this->serveServerError("Internal Server Error", formatException($e), null);
}
exit();
}
/**
* @param string|null $message
* @param string $message
* @param string|null $debugInfo
* @param PageFrameOptions|null $frameOpt
*/
private function serveServerError($message, $debugInfo, $frameOpt)
private function serveServerError(string $message, $debugInfo, $frameOpt)
{
try
{
@ob_end_clean();
if ($frameOpt === null) $frameOpt = new PageFrameOptions();
$frameOpt->statuscode = 500;
@ -157,66 +149,6 @@ class Website
require __DIR__ . '/../frames/' . $FRAME_OPTIONS->frame;
}
public function Database()
{
if ($this->database === null) { require_once 'database.php'; $this->database = new Database($this); }
return $this->database;
}
public function AdventOfCode(): AdventOfCode
{
if ($this->adventOfCode === null) { require_once 'adventofcode.php'; $this->adventOfCode = new AdventOfCode(); }
return $this->adventOfCode;
}
public function Blog(): Blog
{
if ($this->blog === null) { require_once 'blog.php'; $this->blog = new Blog(); }
return $this->blog;
}
public function Books(): Books
{
if ($this->books === null) { require_once 'books.php'; $this->books = new Books(); }
return $this->books;
}
public function Euler(): Euler
{
if ($this->euler === null) { require_once 'euler.php'; $this->euler = new Euler(); }
return $this->euler;
}
public function Programs(): Programs
{
if ($this->programs === null) { require_once 'programs.php'; $this->programs = new Programs(); }
return $this->programs;
}
public function AlephNoteStatistics(): AlephNoteStatistics
{
if ($this->anstats === null) { require_once 'alephnoteStatistics.php'; $this->anstats = new AlephNoteStatistics($this); }
return $this->anstats;
}
public function UpdatesLog(): UpdatesLog
{
if ($this->updateslog === null) { require_once 'updateslog.php'; $this->updateslog = new UpdatesLog($this); }
return $this->updateslog;
}
public function WebApps(): WebApps
{
if ($this->webapps === null) { require_once 'webapps.php'; $this->webapps = new WebApps(); }
return $this->webapps;
}
public function ExtendedGitGraph(): MikescherGitGraph
{
if ($this->extendedgitgraph === null) { require_once 'mikeschergitgraph.php'; $this->extendedgitgraph = new MikescherGitGraph($this); }
return $this->extendedgitgraph;
}
/**
* @return bool
*/

View File

@ -1,34 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<?php
require_once (__DIR__ . '/../internals/base.php');
global $OPTIONS;
require_once (__DIR__ . '/../internals/website.php');
$errorcode = $OPTIONS['code'];
$errormsg = $OPTIONS['message'];
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
?>
<head>
<meta charset="utf-8">
<title>Mikescher.com - <?php echo $errormsg; ?></title>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<?php printHeaderCSS(); ?>
</head>
<body>
<div id="mastercontainer">
<?php $HEADER_ACTIVE='none'; include (__DIR__ . '/../fragments/header.php'); ?>
<?php
$FRAME_OPTIONS->title = 'Mikescher.com - Error';
$FRAME_OPTIONS->canonical_url = null;
$FRAME_OPTIONS->activeHeader = null;
$FRAME_OPTIONS->contentCSSClasses []= 'content-fullheight';
<div id="content" class="content-responsive content-fullheight">
$message = $ROUTE->parameter['message'];
$debuginfo = $ROUTE->parameter['debuginfo'];
?>
<div class="ev_master">
<div class="ev_code"><?php echo $errorcode; ?></div>
<div class="ev_msg"><?php echo $errormsg; ?></div>
</div>
<div class="ev_master">
<div class="ev_code">500</div>
<div class="ev_msg">asdasd<?php echo $message; ?></div>
<?php if ($debuginfo !== null && strlen($debuginfo)>0 && ($SITE != null && !$SITE->isProd())): ?>
<p class="ev_statusmore"><?php echo nl2br($debuginfo); ?></p>
<?php endif; ?>
</div>
</div>
<?php printAdditionalScripts(); ?>
<?php printAdditionalStylesheets(); ?>
</body>
</html>

View File

@ -6,12 +6,18 @@ require_once (__DIR__ . '/../internals/website.php');
/** @var Website $SITE */ global $SITE;
?>
<?php include (__DIR__ . '/../fragments/panel_euler.php'); ?>
<?php
$FRAME_OPTIONS->title = 'Mikescher.com';
$FRAME_OPTIONS->canonical_url = 'https://www.mikescher.com';
$FRAME_OPTIONS->activeHeader = 'home';
?>
<?php include (__DIR__ . '/../fragments/panel_programs.php'); ?>
<?php $SITE->fragments->PanelEuler(); ?>
<?php include (__DIR__ . '/../fragments/panel_blog.php'); ?>
<?php $SITE->fragments->PanelPrograms(); ?>
<?php include (__DIR__ . '/../fragments/panel_books.php'); ?>
<?php $SITE->fragments->PanelBlog(); ?>
<?php include (__DIR__ . '/../fragments/panel_aoc.php'); ?>
<?php $SITE->fragments->PanelBooks(); ?>
<?php $SITE->fragments->PanelAdventOfCode(); ?>