diff --git a/www/fragments/panel_euler.php b/www/fragments/panel_euler.php
index 294880d..143859a 100644
--- a/www/fragments/panel_euler.php
+++ b/www/fragments/panel_euler.php
@@ -1,7 +1,19 @@
+
+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;
diff --git a/www/fragments/panel_programs.php b/www/fragments/panel_programs.php
index c0b15ce..63ab45b 100644
--- a/www/fragments/panel_programs.php
+++ b/www/fragments/panel_programs.php
@@ -1,7 +1,19 @@
+
+modules->Programs();
+
+ $allprograms = $PROGRAMS->listAllNewestFirst();
?>
diff --git a/www/frames/default_frame.php b/www/frames/default_frame.php
index 713a2a0..73167ac 100644
--- a/www/frames/default_frame.php
+++ b/www/frames/default_frame.php
@@ -20,7 +20,7 @@ require_once (__DIR__ . '/../internals/website.php');
foreach ($FRAME_OPTIONS->stylesheets as $cssfile) echo '
';
foreach ($FRAME_OPTIONS->scripts as $scriptfile)
{
- if ($scriptfile[1]) echo '';
+ if ($scriptfile[1]) echo '';
else echo '';
}
?>
diff --git a/www/frames/error_frame.php b/www/frames/error_frame.php
new file mode 100644
index 0000000..fc390a3
--- /dev/null
+++ b/www/frames/error_frame.php
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
title; ?>
+
+
+
+
+
+
+
+
+
+
+ raw; ?>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/www/internals/alephnoteStatistics.php b/www/internals/alephnoteStatistics.php
deleted file mode 100644
index 1f1be2b..0000000
--- a/www/internals/alephnoteStatistics.php
+++ /dev/null
@@ -1,34 +0,0 @@
-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');
- }
-}
\ No newline at end of file
diff --git a/www/internals/fragments.php b/www/internals/fragments.php
new file mode 100644
index 0000000..20d7059
--- /dev/null
+++ b/www/internals/fragments.php
@@ -0,0 +1,48 @@
+ $year, 'nav'=>$shownav, 'linkheader'=>$linkheader, 'ajax'=>$ajax, 'frame'=>$frame, 'frameid'=>$frameid ];
+ include (__DIR__ . '/../fragments/panel_aoc_calendar.php');
+ }
+}
\ No newline at end of file
diff --git a/www/internals/modules.php b/www/internals/modules.php
new file mode 100644
index 0000000..ac5288c
--- /dev/null
+++ b/www/internals/modules.php
@@ -0,0 +1,86 @@
+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;
+ }
+
+}
\ No newline at end of file
diff --git a/www/internals/adventofcode.php b/www/internals/modules/adventofcode.php
similarity index 98%
rename from www/internals/adventofcode.php
rename to www/internals/modules/adventofcode.php
index 6727462..7348973 100644
--- a/www/internals/adventofcode.php
+++ b/www/internals/modules/adventofcode.php
@@ -1,7 +1,5 @@
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');
+ }
+}
\ No newline at end of file
diff --git a/www/internals/blog.php b/www/internals/modules/blog.php
similarity index 89%
rename from www/internals/blog.php
rename to www/internals/modules/blog.php
index dfc6173..9d589c2 100644
--- a/www/internals/blog.php
+++ b/www/internals/modules/blog.php
@@ -1,7 +1,5 @@
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;
diff --git a/www/internals/books.php b/www/internals/modules/books.php
similarity index 98%
rename from www/internals/books.php
rename to www/internals/modules/books.php
index 7265e58..6206f96 100644
--- a/www/internals/books.php
+++ b/www/internals/modules/books.php
@@ -1,7 +1,5 @@
staticData = array_map(function($a){return self::readSingle($a);}, $all);
}
diff --git a/www/internals/database.php b/www/internals/modules/database.php
similarity index 98%
rename from www/internals/database.php
rename to www/internals/modules/database.php
index 70327e9..e19ed6c 100644
--- a/www/internals/database.php
+++ b/www/internals/modules/database.php
@@ -1,7 +1,5 @@
staticData = array_map(function($a){return self::readSingle($a);}, $all);
}
diff --git a/www/internals/mikeschergitgraph.php b/www/internals/modules/mikeschergitgraph.php
similarity index 80%
rename from www/internals/mikeschergitgraph.php
rename to www/internals/modules/mikeschergitgraph.php
index 86e55ad..78259c2 100644
--- a/www/internals/mikeschergitgraph.php
+++ b/www/internals/modules/mikeschergitgraph.php
@@ -1,7 +1,6 @@
getPathRenderedData();
+ $p = $this->getPathRenderedData();
if (!file_exists($p)) return ['result'=>'err', 'message' => 'Rendered data not found'];
diff --git a/www/internals/programs.php b/www/internals/modules/programs.php
similarity index 98%
rename from www/internals/programs.php
rename to www/internals/modules/programs.php
index 83bea9d..231d4ff 100644
--- a/www/internals/programs.php
+++ b/www/internals/modules/programs.php
@@ -1,7 +1,5 @@
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()
diff --git a/www/internals/updateslog.php b/www/internals/modules/updateslog.php
similarity index 55%
rename from www/internals/updateslog.php
rename to www/internals/modules/updateslog.php
index 01ee07d..9c7f3da 100644
--- a/www/internals/updateslog.php
+++ b/www/internals/modules/updateslog.php
@@ -1,7 +1,5 @@
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],
diff --git a/www/internals/webapps.php b/www/internals/modules/webapps.php
similarity index 83%
rename from www/internals/webapps.php
rename to www/internals/modules/webapps.php
index b310749..0f9c53e 100644
--- a/www/internals/webapps.php
+++ b/www/internals/modules/webapps.php
@@ -1,7 +1,5 @@
staticData = array_map(function($a){return self::readSingle($a);}, $all);
}
@@ -30,6 +28,4 @@ class WebApps
usort($data, function($a, $b) { return strcasecmp($b['date'], $a['date']); });
return $data;
}
-}
-
-
+}
\ No newline at end of file
diff --git a/www/internals/ruleengine.php b/www/internals/ruleengine.php
index 1f96f5a..35e27ad 100644
--- a/www/internals/ruleengine.php
+++ b/www/internals/ruleengine.php
@@ -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();
diff --git a/www/internals/urlroute.php b/www/internals/urlroute.php
index 0ba3f79..d8f1583 100644
--- a/www/internals/urlroute.php
+++ b/www/internals/urlroute.php
@@ -44,22 +44,28 @@ class URLRoute
*/
public function getDirect(Website $site, PageFrameOptions $pfo): PageFrameOptions
{
- @ob_end_clean();
- ob_start();
+ try
+ {
+ ob_start();
- global $ROUTE;
- global $FRAME_OPTIONS;
- global $SITE;
- $ROUTE = $this;
- $FRAME_OPTIONS = $pfo;
- $SITE = $site;
+ global $ROUTE;
+ global $FRAME_OPTIONS;
+ global $SITE;
+ $ROUTE = $this;
+ $FRAME_OPTIONS = $pfo;
+ $SITE = $site;
- /** @noinspection PhpIncludeInspection */
- require $this->targetpath;
+ /** @noinspection PhpIncludeInspection */
+ require $this->targetpath;
- $FRAME_OPTIONS->raw = ob_get_clean();
+ $FRAME_OPTIONS->raw = ob_get_contents();
- return $FRAME_OPTIONS;
+ return $FRAME_OPTIONS;
+ }
+ finally
+ {
+ ob_end_clean();
+ }
}
/**
diff --git a/www/internals/utils.php b/www/internals/utils.php
index 431262a..0c0a993 100644
--- a/www/internals/utils.php
+++ b/www/internals/utils.php
@@ -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('
', "\n", $xdbg);
$xdbg = str_replace('
', "\n", $xdbg);
$xdbg = str_replace('
', "\n", $xdbg);
+ $xdbg = str_replace('><', "> <", $xdbg);
$xdbg = strip_tags($xdbg);
$xdbg = htmlspecialchars($xdbg);
$r .= $xdbg . "\n";
diff --git a/www/internals/website.php b/www/internals/website.php
index 3c18f5c..cee7047 100644
--- a/www/internals/website.php
+++ b/www/internals/website.php
@@ -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
*/
diff --git a/www/pages/error_servererror.php b/www/pages/error_servererror.php
index 72e4527..0a3d289 100644
--- a/www/pages/error_servererror.php
+++ b/www/pages/error_servererror.php
@@ -1,34 +1,26 @@
-
-
-
-
-
Mikescher.com -
-
-
-
-
-
-
+title = 'Mikescher.com - Error';
+$FRAME_OPTIONS->canonical_url = null;
+$FRAME_OPTIONS->activeHeader = null;
+$FRAME_OPTIONS->contentCSSClasses []= 'content-fullheight';
-
+$message = $ROUTE->parameter['message'];
+$debuginfo = $ROUTE->parameter['debuginfo'];
+?>
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
500
+
asdasd
+ 0 && ($SITE != null && !$SITE->isProd())): ?>
+
+
+
\ No newline at end of file
diff --git a/www/pages/main.php b/www/pages/main.php
index ea37c14..3bda4c9 100644
--- a/www/pages/main.php
+++ b/www/pages/main.php
@@ -6,12 +6,18 @@ require_once (__DIR__ . '/../internals/website.php');
/** @var Website $SITE */ global $SITE;
?>
-
+title = 'Mikescher.com';
+$FRAME_OPTIONS->canonical_url = 'https://www.mikescher.com';
+$FRAME_OPTIONS->activeHeader = 'home';
+?>
-
+fragments->PanelEuler(); ?>
-
+fragments->PanelPrograms(); ?>
-
+fragments->PanelBlog(); ?>
-
\ No newline at end of file
+fragments->PanelBooks(); ?>
+
+fragments->PanelAdventOfCode(); ?>