diff --git a/www/data/css/styles.css b/www/data/css/styles.css index 1e1868d..1b9fed8 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -102,6 +102,19 @@ body { .boxedcontent .bc_data { padding: 8px; } +.button { + color: #DDD; + text-decoration: none; + background-color: #222; + font-size: 1rem; + border: 1px solid black; + height: 36px; + line-height: 36px; + padding: 2px 2rem; } + +.button:hover { + background-color: #555; } + /* 400px */ #headerdiv { z-index: 999; @@ -887,6 +900,41 @@ html, body { text-decoration: none; color: #22F; } +/* 400px */ +.admincontent { + display: block; + width: 100%; } + +.admincontent .boxedcontent { + margin-bottom: 20px; } + +.egh_ajaxOutput { + display: flex; + box-sizing: border-box; + width: 100%; + align-self: center; + justify-self: center; + margin-left: auto; + margin-right: auto; + resize: none; + height: 300px; } + +/* 400px */ +#loginform div { + display: flex; + flex-direction: column; } + +#loginform div button { + margin: 10px 0; + padding: 0; } + +.loginerror { + display: flex; + background: #FF4444; + font-weight: bold; + padding: 0 5px; + margin: 5px 0 20px 0; } + /* 400px */ .euler_pnl_base { display: inline-flex; diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index 2922168..73f94ec 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -21,6 +21,8 @@ body{background-color:#EEE;color:#CCC;font-family:serif} .boxedcontent{color:#333;border:1px solid black;background-color:#e0e0e0;width:100%;margin-left:auto;margin-right:auto} .boxedcontent .bc_header{background-color:#BBB;padding:0 4px} .boxedcontent .bc_data{padding:8px} +.button{color:#DDD;text-decoration:none;background-color:#222;font-size:1rem;border:1px solid black;height:36px;line-height:36px;padding:2px 2rem} +.button:hover{background-color:#555} #headerdiv{z-index:999;background-color:#333;display:flex;border-bottom:1px solid #111;box-shadow:0 0 8px #000;position:fixed;width:100%} #headerdiv .logowrapper{flex:initial;margin:0;padding:0;height:42px} #headerdiv .logowrapper .logo{height:30px;margin:4px 0 8px 6px;flex:initial} @@ -221,6 +223,12 @@ html,body{margin:0;padding:0;height:100%} .egg_footer{margin-top:5px;text-align:right;margin-right:5px;margin-bottom:5px;color:#888} .egg_footer>a{text-decoration:none;color:inherit} .egg_footer>a:hover{text-decoration:none;color:#22F} +.admincontent{display:block;width:100%} +.admincontent .boxedcontent{margin-bottom:20px} +.egh_ajaxOutput{display:flex;box-sizing:border-box;width:100%;align-self:center;justify-self:center;margin-left:auto;margin-right:auto;resize:none;height:300px} +#loginform div{display:flex;flex-direction:column} +#loginform div button{margin:10px 0;padding:0} +.loginerror{display:flex;background:#f44;font-weight:bold;padding:0 5px;margin:5px 0 20px 0} .euler_pnl_base{display:inline-flex;flex-direction:column;border:1px solid #AAA;border-radius:5px 5px 0 0;margin:15px} .euler_pnl_header{display:flex;align-items:center;justify-content:center;padding:4px;background:#AAA} .euler_pnl_header a{color:#222;text-decoration:none;font-family:Lato,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:22px;font-weight:900} diff --git a/www/data/css/styles.scss b/www/data/css/styles.scss index 9e062be..23d97f0 100644 --- a/www/data/css/styles.scss +++ b/www/data/css/styles.scss @@ -10,6 +10,8 @@ @import 'styles_programslist'; @import 'styles_programsview'; @import 'styles_about'; +@import 'styles_admin'; +@import 'styles_login'; @import 'styles_eulerpanel'; @import 'styles_programspanel'; diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss new file mode 100644 index 0000000..933ab02 --- /dev/null +++ b/www/data/css/styles_admin.scss @@ -0,0 +1,23 @@ +@import 'styles_config'; + +.admincontent { + display: block; + width: 100%; +} + +.admincontent .boxedcontent{ + margin-bottom: 20px; +} + +.egh_ajaxOutput { + display: flex; + box-sizing: border-box; + + width: 100%; + align-self: center; + justify-self: center; + margin-left: auto; + margin-right: auto; + resize: none; + height: 300px; +} \ No newline at end of file diff --git a/www/data/css/styles_global.scss b/www/data/css/styles_global.scss index fef109e..cee0f97 100644 --- a/www/data/css/styles_global.scss +++ b/www/data/css/styles_global.scss @@ -103,4 +103,20 @@ body { .bc_data { padding: 8px; } +} + +.button { + + color: #DDD; + text-decoration: none; + background-color: #222; + font-size: 1rem; + border: 1px solid black; + height: 36px; + line-height: 36px; + padding: 2px 2rem; +} + +.button:hover { + background-color: #555; } \ No newline at end of file diff --git a/www/data/css/styles_login.scss b/www/data/css/styles_login.scss new file mode 100644 index 0000000..af1440c --- /dev/null +++ b/www/data/css/styles_login.scss @@ -0,0 +1,19 @@ +@import 'styles_config'; + +#loginform div { + display: flex; + flex-direction: column; +} + +#loginform div button { + margin: 10px 0; + padding: 0; +} + +.loginerror { + display: flex; + background: #FF4444; + font-weight: bold; + padding: 0 5px; + margin: 5px 0 20px 0; +} \ No newline at end of file diff --git a/www/data/javascript/admin.js b/www/data/javascript/admin.js new file mode 100644 index 0000000..80738bc --- /dev/null +++ b/www/data/javascript/admin.js @@ -0,0 +1,55 @@ +function queryStatus(appendix, secret) +{ + jQuery.ajax({ + url: '/admin/egh/status?secret='+secret, + success: function(result) + { + let ajaxOutput = $('#egh_ajaxOutput'); + ajaxOutput.val(result + '\r\n' + appendix); + ajaxOutput.scrollTop(ajaxOutput[0].scrollHeight); + }, + async: true + }); +} + +function startAjaxRefresh(secret) +{ + $('#egh_ajaxOutput').val("Started."); + val = setInterval(function(){ queryStatus('', secret); }, 500); + + jQuery.ajax({ + url: '/admin/egh/reload?secret='+secret, + success: function(result) + { + clearInterval(val); + queryStatus('Finished.', secret); + }, + error: function( jqXHR, textStatus, errorThrown) + { + clearInterval(val); + queryStatus('AN ERROR OCCURED:' + '\r\n' + textStatus, secret); + }, + async: true + }); +} + +function startAjaxRedraw(secret) +{ + $('#egh_ajaxOutput').val("Started."); + val = setInterval(function(){ queryStatus('', secret); }, 500); + + jQuery.ajax({ + url: '/admin/egh/redraw?secret='+secret, + success: function(result) + { + clearInterval(val); + queryStatus('Finished.', secret); + }, + error: function( jqXHR, textStatus, errorThrown) + { + clearInterval(val); + queryStatus('AN ERROR OCCURED:' + '\r\n' + textStatus, secret); + }, + async: true + }); +} \ No newline at end of file diff --git a/www/extern/egh/ExtendedGitGraph.php b/www/extern/egh/ExtendedGitGraph.php index 9e16726..4f7e5a8 100644 --- a/www/extern/egh/ExtendedGitGraph.php +++ b/www/extern/egh/ExtendedGitGraph.php @@ -66,11 +66,9 @@ class ExtendedGitGraph $_SESSION[self::PROGRESS_SESSION_COOKIE] .= $txt . "\r\n"; session_commit(); } - else if ($this->outputMode === self::OUT_STDOUT) - { - print $txt; - print "\r\n"; - } + + print $txt; + print "\r\n"; $logfile = Utils::sharpFormat($this->logFilePath, ['num'=>'']); file_put_contents($logfile, $txt.PHP_EOL , FILE_APPEND | LOCK_EX); @@ -181,4 +179,11 @@ class ExtendedGitGraph { return $this->renderedHTML; } + + public function getAll() + { + $all = ''; + foreach ($this->get() as $year => $html) $all .= $html . "\n"; + return $all; + } } \ No newline at end of file diff --git a/www/index.php b/www/index.php index aa7e224..f85257c 100644 --- a/www/index.php +++ b/www/index.php @@ -10,7 +10,8 @@ $URL_RULES = [ 'url' => ['msmain', 'index'], 'target' => 'pages/main.php', 'options' => [], ], [ 'url' => ['about'], 'target' => 'pages/about.php', 'options' => [], ], [ 'url' => ['msmain', 'about'], 'target' => 'pages/about.php', 'options' => [], ], - + [ 'url' => ['login'], 'target' => 'pages/login.php', 'options' => [ 'login_target' => '/' ], ], + [ 'url' => ['programs'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ], [ 'url' => ['programs', 'index'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '%GET%' ], ], [ 'url' => ['programs', 'index'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ], @@ -33,9 +34,9 @@ $URL_RULES = [ 'url' => ['api', 'test'], 'target' => 'pages/api_test.php', 'options' => [], ], [ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api_setselfadress.php', 'options' => [], ], [ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ], - - [ 'url' => ['msmain', 'admin', 'egh', '?{commandcode}'], 'target' => 'pages/admin_egh.php', 'options' => [ 'commandcode' => '%URL%' ], ], - [ 'url' => ['msmain', 'adminEGH'], 'target' => 'pages/admin_egh.php', 'options' => [ 'commandcode' => '%GET%' ], ], + + [ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ], + [ 'url' => ['admin', 'egh', '?{cmd}'], 'target' => 'pages/admin_egh.php', 'options' => [ 'cmd' => '%URL%', 'secret' => '%GET%' ], ], [ 'url' => ['blog'], 'target' => 'pages/blog_list.php', 'options' => [], ], [ 'url' => ['log'], 'target' => 'pages/blog_list.php', 'options' => [], ], @@ -94,6 +95,8 @@ try { if ($partcount !== count($rule['url'])) continue; $urlparams = []; + $opt = key_exists('_opt', $rule['options']) ? explode($rule['options']['_opt'], '|') : []; + $target = $rule['target']; $match = true; for($i = 0; $i < $partcount; $i++) @@ -136,8 +139,26 @@ try { } if (!$match) continue; + if (in_array('disabled', $opt)) continue; + + if (in_array('password', $opt)) + { + $auth = hash('sha256', $CONFIG['admin_username'] . ';' . $CONFIG['admin_password']); + + if (!key_exists('mikescher_auth', $_COOKIE)) + { + $opt['login_target'] = $path; + $target = 'pages/login.php'; + } + else if ($auth !== $_COOKIE['mikescher_auth']) + { + $opt['login_target'] = $path; + $target = 'pages/login.php'; + } + } + $OPTIONS = $opt; - include $rule['target']; + include $target; return; } @@ -174,5 +195,4 @@ try { //TODO optimize image sizes for display/download (? - auto?) //TODO send cache header (?) //TODO programs add [license] -//TODO admin //TODO last 3 blog entries on /index/ (?) \ No newline at end of file diff --git a/www/pages/about.php b/www/pages/about.php index 0eb4a4a..347d72c 100644 --- a/www/pages/about.php +++ b/www/pages/about.php @@ -1,5 +1,9 @@ + Mikescher.com - About diff --git a/www/pages/admin.php b/www/pages/admin.php new file mode 100644 index 0000000..a6de7da --- /dev/null +++ b/www/pages/admin.php @@ -0,0 +1,59 @@ + + + + + + Mikescher.com - About + + + + + + + +
+ + + +
+ +
+ +

Admin


+ +
+
Version
+ +
+
Branch: 
+
Commit: 
+
Date: 
+
Message: 
+
+ +
+ +
+
ExtendedGitGraph
+ +
+ + + Update + Redraw + +
+ +
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/www/pages/admin_egh.php b/www/pages/admin_egh.php new file mode 100644 index 0000000..3f3d852 --- /dev/null +++ b/www/pages/admin_egh.php @@ -0,0 +1,70 @@ +addRemote('github-user', null, 'Mikescher', 'Mikescher'); + //$v->addRemote('github-user', null, 'Mikescher', 'Sam-Development'); + //$v->addRemote('github-repository', null, 'Mikescher', 'Anastron/ColorRunner'); + $v->addRemote('gitea-repository', null, 'Mikescher', 'Mikescher/server-scripts'); + $v->addRemote('gitea-repository', null, 'Mikescher', 'Mikescher/apache-sites'); + $v->addRemote('gitea-repository', null, 'Mikescher', 'Mikescher/MVU_API'); + + $v->setColorScheme($CONFIG['egh_theme']); + + $v->ConnectionGithub->setAPIToken($CONFIG['egh_token']); + + $v->ConnectionGitea->setURL('https://gogs.mikescher.com'); + + return $v; +} + +if ($cmd === 'status') +{ + if (session_status() !== PHP_SESSION_ACTIVE) session_start(); + + if (key_exists('ajax_progress_egh_refresh', $_SESSION)) + echo $_SESSION['ajax_progress_egh_refresh']; + else + echo '[[ NO SESSION STARTED ]]'; + + return; +} +else if ($cmd === 'refresh') +{ + set_time_limit(900); // 15min + + $v = create(); + $v->init(); + $v->updateFromRemotes(); + $v->generate(); + + file_put_contents(__DIR__ . '/../dynamic/egh.html', $v->getAll()); +} +else if ($cmd === 'redraw') +{ + set_time_limit(900); // 15min + + $v = create(); + $v->init(); + $v->updateFromCache(); + $v->generate(); + + file_put_contents(__DIR__ . '/../dynamic/egh.html', $v->getAll()); +} +else +{ + die('Wrong command.'); +} \ No newline at end of file diff --git a/www/pages/login.php b/www/pages/login.php new file mode 100644 index 0000000..3c563f5 --- /dev/null +++ b/www/pages/login.php @@ -0,0 +1,92 @@ + + + + + + Mikescher.com - Login + + + + + +
+ + + +
+ +
+ +
+
Mikescher.com - Login
+ +
+ +
+
+ + + Wrong username or password + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ + +
+ +
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/www/temp/.gitignore b/www/temp/.gitignore new file mode 100644 index 0000000..0318876 --- /dev/null +++ b/www/temp/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!.gitkeep \ No newline at end of file diff --git a/www/temp/.gitkeep b/www/temp/.gitkeep new file mode 100644 index 0000000..e69de29