From acc6443b5500c6b6d5e729472750a514bed4d227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 27 Jan 2018 00:28:32 +0100 Subject: [PATCH] /admin/ alephnote --- www/ajax/.htaccess | 1 + www/ajax/an_activeusers.php | 36 ++++++++++++++ www/ajax/egh_redraw.php | 14 ++++++ www/ajax/egh_refresh.php | 15 ++++++ www/ajax/egh_status.php | 10 ++++ www/data/css/styles.css | 29 +++++++++++ www/data/css/styles.min.css | 10 ++++ www/data/css/styles_global.scss | 46 ++++++++++++++++++ www/data/javascript/admin.js | 17 +++++++ www/index.php | 5 +- www/internals/alephnoteStatistics.php | 26 ++++++++++ www/internals/mikeschergitgraph.php | 29 +++++++++++ www/pages/admin.php | 11 +++-- www/pages/admin_egh.php | 70 --------------------------- www/pages/su_ajax.php | 20 ++++++++ 15 files changed, 263 insertions(+), 76 deletions(-) create mode 100644 www/ajax/.htaccess create mode 100644 www/ajax/an_activeusers.php create mode 100644 www/ajax/egh_redraw.php create mode 100644 www/ajax/egh_refresh.php create mode 100644 www/ajax/egh_status.php create mode 100644 www/internals/alephnoteStatistics.php create mode 100644 www/internals/mikeschergitgraph.php delete mode 100644 www/pages/admin_egh.php create mode 100644 www/pages/su_ajax.php diff --git a/www/ajax/.htaccess b/www/ajax/.htaccess new file mode 100644 index 0000000..14249c5 --- /dev/null +++ b/www/ajax/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/www/ajax/an_activeusers.php b/www/ajax/an_activeusers.php new file mode 100644 index 0000000..ee98d25 --- /dev/null +++ b/www/ajax/an_activeusers.php @@ -0,0 +1,36 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ClientIDVersionProviderNoteCountLastChangedCreatedAtComment
+
\ No newline at end of file diff --git a/www/ajax/egh_redraw.php b/www/ajax/egh_redraw.php new file mode 100644 index 0000000..b7d6597 --- /dev/null +++ b/www/ajax/egh_redraw.php @@ -0,0 +1,14 @@ +init(); +$v->updateFromCache(); +$v->generate(); + +file_put_contents(__DIR__ . '/../dynamic/egh.html', $v->getAll()); \ No newline at end of file diff --git a/www/ajax/egh_refresh.php b/www/ajax/egh_refresh.php new file mode 100644 index 0000000..e67a198 --- /dev/null +++ b/www/ajax/egh_refresh.php @@ -0,0 +1,15 @@ +init(); +$v->updateFromRemotes(); +$v->generate(); + +file_put_contents(__DIR__ . '/../dynamic/egh.html', $v->getAll()); + diff --git a/www/ajax/egh_status.php b/www/ajax/egh_status.php new file mode 100644 index 0000000..c8cc1af --- /dev/null +++ b/www/ajax/egh_status.php @@ -0,0 +1,10 @@ +' + textStatus); + }, + async: true + }); } \ No newline at end of file diff --git a/www/index.php b/www/index.php index 86b0c74..c2078c0 100644 --- a/www/index.php +++ b/www/index.php @@ -37,7 +37,10 @@ $URL_RULES = [ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%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' => ['admin', 'egh', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => 'egh', 'cmd' => '%URL%', 'secret' => '%GET%' ], ], + [ 'url' => ['su_ajax', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%URL%', 'secret' => '%GET%' ], ], + [ 'url' => ['su_ajax'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%GET%', 'secret' => '%GET%' ], ], [ 'url' => ['blog'], 'target' => 'pages/blog_list.php', 'options' => [], ], [ 'url' => ['log'], 'target' => 'pages/blog_list.php', 'options' => [], ], diff --git a/www/internals/alephnoteStatistics.php b/www/internals/alephnoteStatistics.php new file mode 100644 index 0000000..ee0e878 --- /dev/null +++ b/www/internals/alephnoteStatistics.php @@ -0,0 +1,26 @@ +0'); + } + + public static function getUserCountFromLastVersion() + { + return Database::sql_query_num('SELECT COUNT(*) FROM ms4_an_statslog WHERE NoteCount>0 AND Version = (SELECT Version FROM ms4_an_statslog ORDER BY Version DESC LIMIT 1)'); + } + + public static function getActiveUserCount($days) + { + return Database::sql_query_num('SELECT COUNT(*) FROM ms4_an_statslog WHERE NoteCount>0 AND LastChanged > NOW() - INTERVAL '.$days.' DAY'); + } + + public static function getAllActiveEntriesOrdered() + { + return Database::sql_query_assoc('SELECT * FROM ms4_an_statslog WHERE NoteCount>0 ORDER BY LastChanged DESC'); + } +} \ No newline at end of file diff --git a/www/internals/mikeschergitgraph.php b/www/internals/mikeschergitgraph.php new file mode 100644 index 0000000..02e74c5 --- /dev/null +++ b/www/internals/mikeschergitgraph.php @@ -0,0 +1,29 @@ +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; + } +} \ No newline at end of file diff --git a/www/pages/admin.php b/www/pages/admin.php index 707c7db..109c586 100644 --- a/www/pages/admin.php +++ b/www/pages/admin.php @@ -62,14 +62,15 @@ Database::connect();
-
Total users:
-
Users on latest version:
-
Active users:
+
Total users:
+
Users on latest version:
+
Active users:
- +
+
- Show + Show
diff --git a/www/pages/admin_egh.php b/www/pages/admin_egh.php deleted file mode 100644 index 3f3d852..0000000 --- a/www/pages/admin_egh.php +++ /dev/null @@ -1,70 +0,0 @@ -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/su_ajax.php b/www/pages/su_ajax.php new file mode 100644 index 0000000..f08af7b --- /dev/null +++ b/www/pages/su_ajax.php @@ -0,0 +1,20 @@ +