diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000..321c4ea
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/www.mikescher.de.iml b/.idea/www.mikescher.de.iml
index 547ac33..d7f562b 100644
--- a/.idea/www.mikescher.de.iml
+++ b/.idea/www.mikescher.de.iml
@@ -8,5 +8,6 @@
+
\ No newline at end of file
diff --git a/www/data/css/styles.css b/www/data/css/styles.css
index 0ac3e26..fd3e460 100644
--- a/www/data/css/styles.css
+++ b/www/data/css/styles.css
@@ -1,3 +1,4 @@
+@charset "UTF-8";
/* 400px */
body {
background-color: #EEEEEE;
@@ -852,7 +853,7 @@ html, body {
min-width: 300px;
}
-.consistency_result_ok, .consistency_result_warn, .consistency_result_err, .consistency_result_intermed, .consistency_result_running {
+.consistency_result {
min-width: 400px;
color: #222222;
border: 1px solid #888;
@@ -860,6 +861,10 @@ html, body {
margin: 1px 0;
}
+.consistency_result:after {
+ content: " ";
+}
+
.consistency_result_ok {
background: #00FF00;
}
diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css
index 622d24c..5ee24b8 100644
--- a/www/data/css/styles.min.css
+++ b/www/data/css/styles.min.css
@@ -1,4 +1,4 @@
-body{background-color:#eee;color:#333;font-family:"Times New Roman",serif}
+@charset "UTF-8";body{background-color:#eee;color:#333;font-family:"Times New Roman",serif}
#content{padding-top:64px;display:flex;justify-content:center;line-height:1.4;flex-direction:column;align-items:center}
.content-responsive{margin-left:auto;margin-right:auto}
@media(max-width:767px){.content-responsive{width:95%;width:calc(100% - 20px);margin-left:auto;margin-right:auto}}
@@ -167,7 +167,8 @@ html,body{margin:0;padding:0;height:100%}
.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}
-.consistency_result_ok,.consistency_result_warn,.consistency_result_err,.consistency_result_intermed,.consistency_result_running{min-width:400px;color:#222;border:1px solid #888;padding:0 5px;margin:1px 0}
+.consistency_result{min-width:400px;color:#222;border:1px solid #888;padding:0 5px;margin:1px 0}
+.consistency_result:after{content:" "}
.consistency_result_ok{background:#0f0}
.consistency_result_warn{background:#ff0}
.consistency_result_err{background:red}
diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss
index f02bf4f..cdc741b 100644
--- a/www/data/css/styles_admin.scss
+++ b/www/data/css/styles_admin.scss
@@ -41,7 +41,7 @@
.kvl_200 div span:first-child { min-width: 200px; }
.kvl_300 div span:first-child { min-width: 300px; }
-.consistency_result_ok, .consistency_result_warn, .consistency_result_err, .consistency_result_intermed, .consistency_result_running {
+.consistency_result {
min-width: 400px;
color: $COL_ADMIN_STATUS_FG;
border: $COL_ADMIN_STATUS_BORDER;
@@ -49,6 +49,8 @@
margin: 1px 0;
}
+.consistency_result:after { content: '\00a0' }
+
.consistency_result_ok { background: $COL_ADMIN_OK; }
.consistency_result_warn { background: $COL_ADMIN_WARN; }
.consistency_result_err { background: $COL_ADMIN_ERROR; }
diff --git a/www/data/javascript/admin.js b/www/data/javascript/admin.js
index b4ab0e4..47c5fdd 100644
--- a/www/data/javascript/admin.js
+++ b/www/data/javascript/admin.js
@@ -90,23 +90,14 @@ function refreshConsistencyDisplay(skip)
$(apibutton).removeClass('consistency_result_intermed');
$(apibutton).removeClass('consistency_result_running');
- if (json.result === 0)
- {
- $(apibutton).addClass('consistency_result_ok');
- $(apibutton).text(json.message+" ");
- }
- else if (json.result === 1)
- {
- $(apibutton).addClass('consistency_result_warn');
- $(apibutton).text(json.message+" ");
- }
- else if (json.result === 2)
- {
- $(apibutton).addClass('consistency_result_err');
- $(apibutton).text(json.message+" ");
- }
+ if (json.result === 0) $(apibutton).addClass('consistency_result_ok');
+ if (json.result === 1) $(apibutton).addClass('consistency_result_warn');
+ if (json.result === 2) $(apibutton).addClass('consistency_result_err');
- setTimeout(() => refreshConsistencyDisplay(skip+1), 300);
+ $(apibutton).text(json.message);
+ $(apibutton).attr('title', json.long);
+
+ setTimeout(() => refreshConsistencyDisplay(skip+1), 10);
})
.fail((xhr, status, err) =>
{
@@ -114,9 +105,9 @@ function refreshConsistencyDisplay(skip)
$(apibutton).removeClass('consistency_result_running');
$(apibutton).addClass('consistency_result_err');
- $(apibutton).text(err+" ");
+ $(apibutton).text(err);
- setTimeout(() => refreshConsistencyDisplay(skip+1), 300);
+ setTimeout(() => refreshConsistencyDisplay(skip+1), 10);
});
}
diff --git a/www/internals/iwebsitemodule.php b/www/internals/iwebsitemodule.php
new file mode 100644
index 0000000..0fd065f
--- /dev/null
+++ b/www/internals/iwebsitemodule.php
@@ -0,0 +1,6 @@
+site->modules->Database()->sql_query_assoc('SELECT * FROM an_statslog WHERE NoteCount>0 ORDER BY LastChanged DESC');
}
+
+ public function checkConsistency()
+ {
+ return ['result'=>'ok', 'message' => ''];
+ }
}
\ No newline at end of file
diff --git a/www/internals/modules/blog.php b/www/internals/modules/blog.php
index 095c2c7..0f07d6d 100644
--- a/www/internals/modules/blog.php
+++ b/www/internals/modules/blog.php
@@ -1,6 +1,6 @@
rowCount();
}
+
+ public function checkConsistency()
+ {
+ return ['result'=>'ok', 'message' => ''];
+ }
}
\ No newline at end of file
diff --git a/www/internals/modules/euler.php b/www/internals/modules/euler.php
index d3b91eb..9a03f7b 100644
--- a/www/internals/modules/euler.php
+++ b/www/internals/modules/euler.php
@@ -1,6 +1,6 @@
'ok', 'message' => ''];
+ }
}
\ No newline at end of file
diff --git a/www/internals/modules/mikeschergitgraph.php b/www/internals/modules/mikeschergitgraph.php
index b3fac93..06220c7 100644
--- a/www/internals/modules/mikeschergitgraph.php
+++ b/www/internals/modules/mikeschergitgraph.php
@@ -2,7 +2,7 @@
require_once (__DIR__ . '/../../extern/egg/ExtendedGitGraph2.php');
-class MikescherGitGraph
+class MikescherGitGraph implements IWebsiteModule
{
/** @var ExtendedGitGraph2 */
private $extgitgraph;
diff --git a/www/internals/modules/programs.php b/www/internals/modules/programs.php
index 7c1f577..ba2e338 100644
--- a/www/internals/modules/programs.php
+++ b/www/internals/modules/programs.php
@@ -1,6 +1,6 @@
'err', 'message' => 'Extra-Image not found ' . $prog['title_short']];
+ if (!file_exists($eipath)) return ['result'=>'err', 'message' => 'Extra-Image not found ' . $prog['name'], 'long' => $eipath];
}
}
diff --git a/www/internals/modules/selftest.php b/www/internals/modules/selftest.php
index 2d8e3b7..77acdbe 100644
--- a/www/internals/modules/selftest.php
+++ b/www/internals/modules/selftest.php
@@ -1,6 +1,6 @@
isProd()) return
+ [
+ 'result' => self::STATUS_WARN,
+ 'message' => '{'.$xname.'} not executed: curl requests in dev mode prohibited',
+ 'long' => null,
+ 'exception' => null,
+ ];
+
+ $r = curl_http_request($_SERVER['HTTP_HOST'] . $path);
if ($r['statuscode'] == $status) return
[
'result' => self::STATUS_OK,
@@ -191,7 +198,7 @@ class SelfTest
[
'result' => self::STATUS_ERROR,
'message' => "{$xname} failed: " . $e->getMessage(),
- 'long' => formatException($e),
+ 'long' => str_max_len($e->getMessage(), 48),
'exception' => $e,
];
}
@@ -206,7 +213,58 @@ class SelfTest
private function addCheckConsistency(string $name, Closure $moduleSupplier)
{
- //TODO
+ $this->methods []=
+ [
+ 'name' => $name,
+ 'func' => function() use ($name, $moduleSupplier)
+ {
+ $xname = explode('::', $name)[2];
+
+ try
+ {
+ /** @var IWebsiteModule $module */
+ $module = $moduleSupplier();
+
+ $consistency = $module->checkConsistency();
+
+ if ($consistency['result'] === 'err') return
+ [
+ 'result' => self::STATUS_ERROR,
+ 'message' => $consistency['message'],
+ 'long' => isset($consistency['long']) ? $consistency['long'] : null,
+ 'exception' => null,
+ ];
+
+ if ($consistency['result'] === 'warn') return
+ [
+ 'result' => self::STATUS_WARN,
+ 'message' => $consistency['message'],
+ 'long' => isset($consistency['long']) ? $consistency['long'] : null,
+ 'exception' => null,
+ ];
+
+ if ($consistency['result'] === 'ok') return
+ [
+ 'result' => self::STATUS_OK,
+ 'message' => 'OK',
+ 'long' => isset($consistency['long']) ? $consistency['long'] : null,
+ 'exception' => null,
+ ];
+
+ throw new Exception("Unknown result: " . print_r($consistency, true));
+ }
+ catch (Exception $e)
+ {
+ return
+ [
+ 'result' => self::STATUS_ERROR,
+ 'message' => str_max_len($e->getMessage(), 48),
+ 'long' => formatException($e),
+ 'exception' => $e,
+ ];
+ }
+ }
+ ];
}
private function addMethodPathResponse(string $name, int $statuscode, string $json_expected, string $path)
@@ -239,25 +297,53 @@ class SelfTest
$rex = '/^' . str_replace('*', '([^:]*)', $filter) . '$/';
$fullmessage = '';
+ $fullwarnmessage = '';
+ $warnings = 0;
$count = 0;
+ $lastresult = null;
foreach ($this->methods as $method)
{
if (!preg_match($rex, $method['name'])) continue;
- $r = $method['func']();
- if ($r['result'] !== self::STATUS_OK) return $r;
- $fullmessage = $fullmessage . $method['message'] . "\n";
+ $lastresult = $r = $method['func']();
+ if ($r['result'] === self::STATUS_ERROR) return $r;
+ if ($r['result'] === self::STATUS_WARN) { $warnings++; $fullwarnmessage .= $r['message'] . "\n"; }
+ $fullmessage .= $r['message'] . "\n";
$count++;
}
+ if ($warnings > 0)
+ {
+ return
+ [
+ 'result' => self::STATUS_WARN,
+ 'message' => "$warnings/$count methods had warnings",
+ 'long' => $fullwarnmessage,
+ 'exception' => null,
+ ];
+ }
+
+ if ($count === 0) return
+ [
+ 'result' => self::STATUS_WARN,
+ 'message' => "No methods matched filter",
+ 'long' => null,
+ 'exception' => null,
+ ];
+
return
[
'result' => self::STATUS_OK,
- 'message' => "{$count} methods succeeded",
- 'long' => $fullmessage,
+ 'message' => "OK",
+ 'long' => "$count methods succeeded\n\n" . $fullmessage,
'exception' => null,
];
}
+
+ public function checkConsistency()
+ {
+ return ['result'=>'ok', 'message' => ''];
+ }
}
\ No newline at end of file
diff --git a/www/internals/modules/updateslog.php b/www/internals/modules/updateslog.php
index 781c44f..ea720ab 100644
--- a/www/internals/modules/updateslog.php
+++ b/www/internals/modules/updateslog.php
@@ -1,6 +1,6 @@
load();
+
+ foreach ($this->staticData as $name => $data)
+ {
+ if (!key_exists('version', $data)) return ['result'=>'err', 'message' => 'Missing value [version]'];
+ if (!key_exists('url', $data)) return ['result'=>'err', 'message' => 'Missing value [url]'];
+ }
+
+ if ($warn != null) return $warn;
+ return ['result'=>'ok', 'message' => ''];
+ }
}
\ No newline at end of file
diff --git a/www/internals/modules/webapps.php b/www/internals/modules/webapps.php
index 0f9c53e..3320cdb 100644
--- a/www/internals/modules/webapps.php
+++ b/www/internals/modules/webapps.php
@@ -1,6 +1,6 @@
load();
+
+ $ids = [];
+
+ foreach ($this->staticData as $prog)
+ {
+ if (in_array($prog['id'], $ids)) return ['result'=>'err', 'message' => 'Duplicate id ' . $prog['id']];
+ $ids []= $prog['id'];
+ }
+
+ if ($warn != null) return $warn;
+ return ['result'=>'ok', 'message' => ''];
+ }
}
\ No newline at end of file
diff --git a/www/internals/utils.php b/www/internals/utils.php
index db0b7d0..1099894 100644
--- a/www/internals/utils.php
+++ b/www/internals/utils.php
@@ -220,6 +220,13 @@ function isHTTPRequest()
return (!isset($_SERVER['HTTPS'])) || empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off";
}
+function str_max_len(string $str, int $max)
+{
+ if (strlen($str) < $max) return $str;
+
+ return substr($str, 0, $max-3)."...";
+}
+
function formatException($e)
{
if ($e === null) return "NULL";
diff --git a/www/internals/website.php b/www/internals/website.php
index bd3175d..e1ac8fa 100644
--- a/www/internals/website.php
+++ b/www/internals/website.php
@@ -3,6 +3,7 @@
require_once 'ruleengine.php';
require_once 'urlroute.php';
require_once 'pageframeoptions.php';
+require_once 'iwebsitemodule.php';
require_once 'modules.php';
require_once 'fragments.php';
diff --git a/www/pages/admin.php b/www/pages/admin.php
index 548e663..a9d9d92 100644
--- a/www/pages/admin.php
+++ b/www/pages/admin.php
@@ -56,7 +56,7 @@ $connected = true; try { $SITE->modules->Database(); } catch (Exception $e) { $c
modules->SelfTest()->listMethodGroups() as $group): ?>
-
+