diff --git a/www/data/css/styles.css b/www/data/css/styles.css index 562b2e8..144d2d7 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -887,6 +887,10 @@ html, body { background: -webkit-radial-gradient(circle, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 100%); } +.admindberr { + color: #BB2222; +} + /* 400px */ #loginform div { display: flex; diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index 3245623..ebb23e3 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -173,6 +173,7 @@ html,body{margin:0;padding:0;height:100%} .consistency_result_warn{background:#ff0} .consistency_result_err{background:red} .admincontent .boxedcontent hr{width:95%;height:1px;border:0;color:#FFFFFF00;background:-moz-radial-gradient(circle,rgba(0,0,0,0.1),rgba(0,0,0,0));background:-webkit-radial-gradient(circle,rgba(0,0,0,0.1) 0,rgba(0,0,0,0) 100%)} +.admindberr{color:#b22} #loginform div{display:flex;flex-direction:column} #loginform div button{margin:10px 0;padding:0} .loginerror{display:flex;background:#f44;color:#222;border:1px solid #a44;border-radius:2px;font-weight:bold;padding:0 5px;margin:5px 0 20px 0} diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss index 43495f4..b8bce2f 100644 --- a/www/data/css/styles_admin.scss +++ b/www/data/css/styles_admin.scss @@ -61,4 +61,6 @@ color: $COL_TRANSPARENT; background: -moz-radial-gradient( circle, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.0)); background: -webkit-radial-gradient(circle, rgba(0, 0, 0, 0.1) 0%,rgba(0, 0, 0, 0.0) 100%); -} \ No newline at end of file +} + +.admindberr { color: $COL_ADMIN_STATUS_DB_ERROR; } \ No newline at end of file diff --git a/www/data/css/styles_config.scss b/www/data/css/styles_config.scss index 21e7ffd..bd47959 100644 --- a/www/data/css/styles_config.scss +++ b/www/data/css/styles_config.scss @@ -156,6 +156,8 @@ $COL_ADMIN_ERROR: #FF0000; $COL_ADMIN_STATUS_FG: #222222; $COL_ADMIN_STATUS_BORDER: 1px solid #888; +$COL_ADMIN_STATUS_DB_ERROR: #BB2222; + // ------------------------------------ ------------------------------------ diff --git a/www/internals/modules.php b/www/internals/modules.php index 08821ef..ef80514 100644 --- a/www/internals/modules.php +++ b/www/internals/modules.php @@ -44,7 +44,7 @@ class Modules public function Books(): Books { - if ($this->books === null) { require_once 'modules/books.php'; $this->books = new Books(); } + if ($this->books === null) { require_once 'modules/books.php'; $this->books = new Books($this->site); } return $this->books; } diff --git a/www/internals/modules/books.php b/www/internals/modules/books.php index 6206f96..ee5f2b6 100644 --- a/www/internals/modules/books.php +++ b/www/internals/modules/books.php @@ -2,11 +2,15 @@ class Books { + /** @var Website */ + private $site; + /** @var array */ private $staticData; - public function __construct() + public function __construct(Website $site) { + $this->site = $site; $this->load(); } @@ -104,12 +108,10 @@ class Books public function createPreview($prog) { - global $CONFIG; - $src = $prog['imgfront_path']; $dst = $prog['preview_path']; - if ($CONFIG['use_magick']) + if ($this->site->config['use_magick']) magick_resize_image($src, 200, 0, $dst); else smart_resize_image($src, 200, 0, true, $dst); diff --git a/www/internals/modules/programs.php b/www/internals/modules/programs.php index 6cf2738..0d23560 100644 --- a/www/internals/modules/programs.php +++ b/www/internals/modules/programs.php @@ -223,7 +223,7 @@ class Programs if (strpos($prog['internal_name'], ' ') !== FALSE) return ['result'=>'err', 'message' => 'Internal name contains spaces ' . $prog['name']]; - foreach (explode('|', $prog['ui_language']) as $lang) if (convertLanguageToFlag($lang) === null) return ['result'=>'err', 'message' => 'Unknown ui-lang ' . $prog['name']];; + foreach (explode('|', $prog['ui_language']) as $lang) if ($this->convertLanguageToFlag($lang) === null) return ['result'=>'err', 'message' => 'Unknown ui-lang ' . $prog['name']];; if (!in_array($prog['prog_language'], self::PROG_LANGS)) return ['result'=>'err', 'message' => 'Unknown prog-lang ' . $prog['name']]; @@ -232,11 +232,11 @@ class Programs if ($prog['license'] !== null && !array_key_exists($prog['license'], self::LICENSES)) return ['result'=>'err', 'message' => 'Unknown license ' . $prog['name']]; $isdl = false; - foreach (self::getURLs($prog) as $xurl) + foreach ($this->getURLs($prog) as $xurl) { if (!in_array($xurl['type'], self::URL_ORDER)) return ['result'=>'err', 'message' => 'Unknown url ' . $xurl['type']]; - if ($xurl['type']==='download' && $xurl['isdirect'] && !file_exists(self::getDirectDownloadPath($prog))) return ['result'=>'err', 'message' => 'Direct download not found ' . $prog['name']]; + if ($xurl['type']==='download' && $xurl['isdirect'] && !file_exists($this->getDirectDownloadPath($prog))) return ['result'=>'err', 'message' => 'Direct download not found ' . $prog['name']]; if ($xurl['type']==='download' || $xurl['type']==='playstore' || $xurl['type']==='itunesstore') $isdl = true; } diff --git a/www/internals/utils.php b/www/internals/utils.php index ef90b1d..c877e98 100644 --- a/www/internals/utils.php +++ b/www/internals/utils.php @@ -63,11 +63,6 @@ function formatMilliseconds($millis) } } -function isProd() { - global $CONFIG; - return $CONFIG['prod']; -} - /** * easy image resize function * @author http://www.nimrodstech.com/php-image-resize/ diff --git a/www/pages/admin.php b/www/pages/admin.php index 2736487..7026043 100644 --- a/www/pages/admin.php +++ b/www/pages/admin.php @@ -1,261 +1,238 @@ - - -title = 'Admin'; +$FRAME_OPTIONS->canonical_url = 'https://www.mikescher.com/admin'; +$FRAME_OPTIONS->activeHeader = 'admin'; + +$FRAME_OPTIONS->addScript('https://code.jquery.com/jquery-latest.min.js', true); +$FRAME_OPTIONS->addScript('/data/javascript/admin.js', true); + + +$connected = true; try { $SITE->modules->Database(); } catch (Exception $e) { $connected = false; } + +$rok = ['result'=>'ok','message'=>'']; + +$consistency_blog = $rok; try { $consistency_blog = $SITE->modules->Blog()->checkConsistency(); } catch (Exception $e) { $consistency_blog = ['result'=>'ok', 'message'=>"$e"]; } +$consistency_prog = $rok; try { $consistency_prog = $SITE->modules->Programs()->checkConsistency(); } catch (Exception $e) { $consistency_prog = ['result'=>'ok', 'message'=>"$e"]; } +$consistency_euler = $rok; try { $consistency_euler = $SITE->modules->Euler()->checkConsistency(); } catch (Exception $e) { $consistency_euler = ['result'=>'ok', 'message'=>"$e"]; } +$consistency_books = $rok; try { $consistency_books = $SITE->modules->Books()->checkConsistency(); } catch (Exception $e) { $consistency_books = ['result'=>'ok', 'message'=>"$e"]; } +$consistency_egg = $rok; try { $consistency_egg = $SITE->modules->ExtendedGitGraph()->checkConsistency(); } catch (Exception $e) { $consistency_egg = ['result'=>'ok', 'message'=>"$e"]; } +$consistency_progimg = $rok; try { $consistency_progimg = $SITE->modules->Programs()->checkThumbnails(); } catch (Exception $e) { $consistency_progimg = ['result'=>'ok', 'message'=>"$e"]; } +$consistency_bookimg = $rok; try { $consistency_bookimg = $SITE->modules->Books()->checkThumbnails(); } catch (Exception $e) { $consistency_bookimg = ['result'=>'ok', 'message'=>"$e"]; } +$consistency_aoc = $rok; try { $consistency_aoc = $SITE->modules->AdventOfCode()->checkConsistency(); } catch (Exception $e) { $consistency_aoc = ['result'=>'ok', 'message'=>"$e"]; } + +function dumpConsistency($c) +{ if ($c['result']==='ok') echo "OK"; else if ($c['result']==='warn') echo "".$c['message'].""; else echo "".$c['message'].""; } ?> - - - Mikescher.com - Admin - - - - - - - -
- +
-
+

Admin


-
+ +
+
Could not connect to database
+
+ -

Admin


+ - -
-
Could not connect to database
-
- - - - -
-
Version
- -
-
Branch:
-
Commit:
-
Date:
-
Message:
+
+
Version
+ +
+
Branch:
+
Commit:
+
Date:
+
Message:
+
+
+ + + +
+
Self test
+ +
+
+
Program thumbnails:
+
ExtendedGitGraph:
+
Book thumbnails:
+
Blog data:
+
Euler data:
+
AdventOfCode data:
+
Programs data:
+
Books data:
+
+
+ Update Program Thumbnails + Update Book Thumbnails + +
+
+ + + +
+
Self IP Addr
+ + + +
+
Registered IP:
+
Current IP:
+
+
+ + + +
+
ExtendedGitGraph
+ +
+ + + Update + Redraw + +
+ +
+ + + +
+
AlephNote
+ + +
+
+
Total users: modules->AlephNoteStatistics()->getTotalUserCount(); ?>
+
Users on latest version: modules->AlephNoteStatistics()->getUserCountFromLastVersion(); ?>
+
Active users: modules->AlephNoteStatistics()->getActiveUserCount(32); ?>
+
+
+ Show
+ +
Database not connected.
+ - +
-
-
Self test
+ -
-
-
Program thumbnails:
-
ExtendedGitGraph:
-
Book thumbnails:
-
Blog data:
-
Euler data:
-
AdventOfCode data:
-
Programs data:
-
Books data:
-
-
- Update Program Thumbnails - Update Book Thumbnails +
+
Statics
-
+
+
Blog entries: modules->Blog()->listAll()); ?>
+
Book entries: modules->Books()->listAll()); ?>
+
Euler entries: modules->Euler()->listAll()); ?>
+
Program entries: modules->Programs()->listAll()); ?>
+
Update entries: modules->UpdatesLog()->listUpdateData()); ?>
+
+
+ + + +
+
UpdatesLog
+ + +
+ modules->UpdatesLog()->listProgramsInformation() as $info): ?> +
+
+
+
+ +
+
+ +
Database not connected.
+ +
- + -
-
Self IP Addr
+
+
Highscores
- + +
-
-
Registered IP:
-
Current IP:
-
-
+ modules->Highscores()->getAllGames() as $game): ?> - + +
modules->Highscores()->getOrderedEntriesFromGame($game['ID'], 1)[0]; + echo $hs['POINTS'] . ' (' . $hs['PLAYER'] . ') @ ' . $hs['TIMESTAMP']; + ?>
+
modules->Highscores()->getNewestEntriesFromGame($game['ID'], 1)[0]['TIMESTAMP']; ?>
-
-
ExtendedGitGraph
+
-
- - - Update - Redraw - -
+
+ +
Database not connected.
+ - +
-
-
AlephNote
+ - -
-
-
Total users:
-
Users on latest version:
-
Active users:
-
-
-
- Show -
- -
Database not connected.
- +
+
Configuration
+
+ config as $key => $value) + { + if ($key === 'extendedgitgraph') continue; -
+ if (is_array($value)) + echo '
' . $key . ' ' . json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . '
' . "\n"; + else + echo '
' . $key . ' ' . nl2br(var_export($value, true)) . '
' . "\n"; + } + ?> +
+
- - -
-
Statics
- -
-
Blog entries:
-
Book entries:
-
Euler entries:
-
Program entries:
-
Update entries:
-
-
- - - -
-
UpdatesLog
- - -
- -
-
-
-
- -
-
-
- -
Database not connected.
- -
- - - -
-
Highscores
- - -
- - - -
-
-
- -
- - - -
- -
Database not connected.
- - -
- - - -
-
Configuration
-
- $value) - { - if ($key === 'extendedgitgraph') continue; - - if (is_array($value)) - echo '
' . $key . ' ' . json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . '
' . "\n"; - else - echo '
' . $key . ' ' . nl2br(var_export($value, true)) . '
' . "\n"; - } - ?> -
-
- -
-
Configuration['extendedgitgraph']
-
- $value) - { - if (is_array($value)) - echo '
' . $key . ' ' . json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . '
' . "\n"; - else - echo '
' . $key . ' ' . nl2br(var_export($value, true)) . '
' . "\n"; - } - ?> -
-
- -
- -
- - +
+
Configuration['extendedgitgraph']
+
+ config['extendedgitgraph'] as $key => $value) + { + if (is_array($value)) + echo '
' . $key . ' ' . json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . '
' . "\n"; + else + echo '
' . $key . ' ' . nl2br(var_export($value, true)) . '
' . "\n"; + } + ?> +
+
- - - - \ No newline at end of file diff --git a/www/pages/login.php b/www/pages/login.php index 8f6e94c..2c39ace 100644 --- a/www/pages/login.php +++ b/www/pages/login.php @@ -1,18 +1,29 @@ - - + +title = 'Login'; +$FRAME_OPTIONS->canonical_url = 'https://www.mikescher.com/login'; +$FRAME_OPTIONS->activeHeader = 'login'; + +$FRAME_OPTIONS->addScript('/data/javascript/ms_basic.js', true); +?> + +config['admin_username'] && $_GET['password'] === $SITE->config['admin_password']) + { + $SITE->setLoginCookie($_GET['username'], $_GET['password']); + $FRAME_OPTIONS->setForcedRedirect($_GET['redirect']); + return; } else { @@ -20,73 +31,49 @@ if (key_exists('username', $_GET) && key_exists('password', $_GET) && key_exists } } -$redirect = $OPTIONS['login_target']; +$redirect = $ROUTE->parameter['login_target']; if (($redirect === '/' || $redirect === '') && isset($_GET['redirect'])) $redirect = $_GET['redirect']; - +if (($redirect === '/' || $redirect === '')) $redirect = '/admin'; ?> - - - Mikescher.com - Login - - - - - -
- +
-
+
+
Mikescher.com - Login
-
+
-
-
Mikescher.com - Login
+
+
-
+ + Wrong username or password + -
- +
+ + +
- - Wrong username or password - +
+ + +
-
- - -
+
+ + +
-
- - -
+
+ +
-
- - -
+ +
-
- -
+
- -
- - -
- -
- -
- -
- - +
- - - - \ No newline at end of file diff --git a/www/pages/logout.php b/www/pages/logout.php index 116e98e..92826ac 100644 --- a/www/pages/logout.php +++ b/www/pages/logout.php @@ -1,27 +1,16 @@ - - - - - Mikescher.com - Logout - - - - - + + +parameter['logout_target']; +$SITE->clearLoginCookie(); +?> + You have been logged out - - - - - +