From 3f4cc7875d5061d4c88dcf685e4e10d3d1c15e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 28 Dec 2019 23:52:19 +0100 Subject: [PATCH] Show admin page even without db connection --- www/data/css/styles.css | 7 +++ www/data/css/styles.min.css | 3 +- www/data/css/styles_about.scss | 6 ++ www/data/css/styles_admin.scss | 1 + www/data/javascript/admin.js | 2 +- www/internals/database.php | 10 +++ www/pages/admin.php | 109 ++++++++++++++++++++++----------- www/pages/login.php | 1 + 8 files changed, 101 insertions(+), 38 deletions(-) diff --git a/www/data/css/styles.css b/www/data/css/styles.css index 81dbbb9..197e1be 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -782,6 +782,12 @@ html, body { text-align: left; } +.boxedcontent.alertbox { + background-color: #F52; + font-weight: bold; + text-align: center; +} + .egg_col_x5_0 { fill: #eeeeee; } @@ -837,6 +843,7 @@ html, body { .keyvaluelist div span:first-child { font-weight: bold; min-width: 500px; + align-self: start; } .kvl_100 div span:first-child { diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index 3fe2531..8f534c1 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -152,6 +152,7 @@ html,body{margin:0;padding:0;height:100%} .about_circles{display:flex;flex-direction:column} .about_circles a{margin:5px 0} .about_circles .iconbutton_light span{text-align:left} +.boxedcontent.alertbox{background-color:#F52;font-weight:bold;text-align:center} .egg_col_x5_0{fill:#eee} .egg_col_x5_1{fill:#6bcdff} .egg_col_x5_2{fill:#00a1f3} @@ -163,7 +164,7 @@ html,body{margin:0;padding:0;height:100%} .keyvaluelist{display:flex;flex-direction:column} .keyvaluelist div{display:flex;flex-direction:row} .keyvaluelist div span{align-self:center} -.keyvaluelist div span:first-child{font-weight:bold;min-width:500px} +.keyvaluelist div span:first-child{font-weight:bold;min-width:500px;align-self:start} .kvl_100 div span:first-child{min-width:100px} .kvl_200 div span:first-child{min-width:200px} .kvl_300 div span:first-child{min-width:300px} diff --git a/www/data/css/styles_about.scss b/www/data/css/styles_about.scss index 6c6acbc..24a1bdb 100644 --- a/www/data/css/styles_about.scss +++ b/www/data/css/styles_about.scss @@ -112,6 +112,12 @@ } +.boxedcontent.alertbox { + background-color: #F52; + font-weight: bold; + text-align: center; +} + @if $CFG_EGG_THEME == 'standard' { // ==== STANDARD ==== diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss index d581245..43495f4 100644 --- a/www/data/css/styles_admin.scss +++ b/www/data/css/styles_admin.scss @@ -32,6 +32,7 @@ span:first-child { font-weight: bold; min-width: 500px; + align-self: start; } } } diff --git a/www/data/javascript/admin.js b/www/data/javascript/admin.js index cf0e325..0a54c76 100644 --- a/www/data/javascript/admin.js +++ b/www/data/javascript/admin.js @@ -4,7 +4,7 @@ function queryStatus(appendix, secret) url: '/api/extendedgitgraph::status?secret='+secret, success: function(result) { - let ajaxOutput = $('#egh_ajaxOutput'); + let ajaxOutput = $('#egg_ajaxOutput'); ajaxOutput.val(result + '\r\n' + appendix); ajaxOutput.scrollTop(ajaxOutput[0].scrollHeight); }, diff --git a/www/internals/database.php b/www/internals/database.php index 20e48f0..ea4e5f9 100644 --- a/www/internals/database.php +++ b/www/internals/database.php @@ -21,6 +21,16 @@ class Database self::$PDO = new PDO($dsn, $CONFIG['user'], $CONFIG['password'], $opt); } + public static function tryconnect() + { + try { + self::connect(); + return true; + } catch (exception $e) { + return false; + } + } + public static function sql_query_num($query) { $r = self::$PDO->query($query)->fetch(PDO::FETCH_NUM)[0]; diff --git a/www/pages/admin.php b/www/pages/admin.php index a44477b..776cf2b 100644 --- a/www/pages/admin.php +++ b/www/pages/admin.php @@ -13,7 +13,7 @@ require_once (__DIR__ . '/../internals/programs.php'); require_once (__DIR__ . '/../internals/books.php'); require_once (__DIR__ . '/../internals/updateslog.php'); -Database::connect(); +$connected = Database::tryconnect(); $consistency_blog = Blog::checkConsistency(); $consistency_prog = Programs::checkConsistency(); @@ -54,6 +54,12 @@ function dumpConsistency($c) {

Admin


+ +
+
Could not connect to database
+
+ +
@@ -128,16 +134,20 @@ function dumpConsistency($c) {
AlephNote
-
-
-
Total users:
-
Users on latest version:
-
Active users:
+ +
+
+
Total users:
+
Users on latest version:
+
Active users:
+
+
+
+ Show
-
-
- Show -
+ +
Database not connected.
+
@@ -160,16 +170,20 @@ function dumpConsistency($c) {
UpdatesLog
-
- -
-
-
-
- -
-
-
+ +
+ +
+
+
+
+ +
+
+
+ +
Database not connected.
+
@@ -177,22 +191,26 @@ function dumpConsistency($c) {
Highscores
-
+ +
- + -
-
-
+
+
+
-
+
- + -
+
+ +
Database not connected.
+
@@ -200,15 +218,34 @@ function dumpConsistency($c) {
Configuration
-
+ $value) + { + if ($key === 'extendedgitgraph') continue; - $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']
+
+ $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"; + } + ?> +
diff --git a/www/pages/login.php b/www/pages/login.php index 51bc891..0e2688e 100644 --- a/www/pages/login.php +++ b/www/pages/login.php @@ -21,6 +21,7 @@ if (key_exists('username', $_GET) && key_exists('password', $_GET) && key_exists } $redirect = $OPTIONS['login_target']; +if (($redirect === '/' || $redirect === '') && isset($_GET['redirect'])) $redirect = $_GET['redirect']; ?>