diff --git a/www/ajax/.htaccess b/www/commands/.htaccess
similarity index 100%
rename from www/ajax/.htaccess
rename to www/commands/.htaccess
diff --git a/www/ajax/an_activeusers.php b/www/commands/alephnote_show.php
similarity index 100%
rename from www/ajax/an_activeusers.php
rename to www/commands/alephnote_show.php
diff --git a/www/commands/alephnote_statsping.php b/www/commands/alephnote_statsping.php
new file mode 100644
index 0000000..2f566ff
--- /dev/null
+++ b/www/commands/alephnote_statsping.php
@@ -0,0 +1,42 @@
+".$data['version']."
-
+
diff --git a/www/pages/admin_cmd.php b/www/pages/admin_cmd.php
deleted file mode 100644
index 951fcce..0000000
--- a/www/pages/admin_cmd.php
+++ /dev/null
@@ -1,64 +0,0 @@
-';
- echo '';
- echo '';
- echo '
';
- echo '
Mikescher.com - AdminExec';
- echo '
';
- echo '
';
- echo '
';
- echo '';
- echo '';
-
- foreach (Programs::listAll() as $prog)
- {
- echo 'Create preview for ' . $prog['name'] . '
' . "\n";
- Programs::createPreview($prog);
- }
- echo 'Finished.' . '
' . "\n";
-
- echo '';
- echo '';
- echo '';
- exit;
-}
-
-if ($cmd === 'createBookThumbnails')
-{
- echo '';
- echo '';
- echo '';
- echo '
';
- echo '
Mikescher.com - AdminExec';
- echo '
';
- echo '
';
- echo '
';
- echo '';
- echo '';
-
- foreach (Books::listAll() as $book)
- {
- echo 'Create preview for ' . $book['title'] . '
' . "\n";
- Books::createPreview($book);
- }
- echo 'Finished.' . '
' . "\n";
-
- echo '';
- echo '';
- echo '';
- exit;
-}
-
-
-die('Wrong command.');
\ No newline at end of file
diff --git a/www/pages/api.php b/www/pages/api.php
new file mode 100644
index 0000000..836b768
--- /dev/null
+++ b/www/pages/api.php
@@ -0,0 +1,89 @@
+ [ 'src' => __DIR__.'/../commands/base_test.php', 'auth' => 'none' ],
+
+ 'progs::updatecheck' => [ 'src' => __DIR__.'/../commands/progs_updatecheck.php', 'auth' => 'none' ],
+
+ 'site::createProgramThumbnails' => [ 'src' => __DIR__.'/../commands/site_createProgramThumbnails.php', 'auth' => 'admin' ],
+ 'site::createBookThumbnails' => [ 'src' => __DIR__.'/../commands/site_createBookThumbnails.php', 'auth' => 'admin' ],
+
+ 'server::setselfaddress' => [ 'src' => __DIR__.'/../commands/server_setselfaddress.php', 'auth' => 'none' ],
+ 'server::gitwebhook' => [ 'src' => __DIR__.'/../commands/server_gitwebhook.php', 'auth' => 'webhook_secret' ],
+ 'server::backupupload' => [ 'src' => __DIR__.'/../commands/server_backupupload.php', 'auth' => 'upload_secret' ],
+
+ 'extendedgitgraph::status' => [ 'src' => __DIR__.'/../commands/extendedgitgraph_status.php', 'auth' => 'ajax_secret' ],
+ 'extendedgitgraph::redraw' => [ 'src' => __DIR__.'/../commands/extendedgitgraph_redraw.php', 'auth' => 'ajax_secret' ],
+ 'extendedgitgraph::refresh' => [ 'src' => __DIR__.'/../commands/extendedgitgraph_refresh.php', 'auth' => 'ajax_secret' ],
+
+ 'alephnote::statsping' => [ 'src' => __DIR__.'/../commands/alephnote_statsping.php', 'auth' => 'none' ],
+ 'alephnote::show' => [ 'src' => __DIR__.'/../commands/alephnote_show.php', 'auth' => 'ajax_secret' ],
+
+ 'updates::show' => [ 'src' => __DIR__.'/../commands/updates_show.php', 'auth' => 'ajax_secret' ],
+];
+
+$cmd = strtolower($OPTIONS['cmd']);
+
+if (!array_key_exists($cmd, $API_COMMANDS))
+{
+ print(" \n");
+ print(" \n");
+ print(" ... \n");
+ print(" ;::::; \n");
+ print(" ;::::; :; \n");
+ print(" ;:::::' :; \n");
+ print(" ;:::::; ;. \n");
+ print(" ,:::::' ; OOO\\ \n");
+ print(" ::::::; ; OOOOO\\ \n");
+ print(" ;:::::; ; OOOOOOOO \n");
+ print(" ,;::::::; ;' / OOOOOOO \n");
+ print(" ;:::::::::`. ,,,;. / / DOOOOOO \n");
+ print(" .';:::::::::::::::::;, / / DOOOO \n");
+ print(" ,::::::;::::::;;;;::::;, / / DOOO \n");
+ print(" ;`::::::`'::::::;;;::::: ,#/ / DOOO \n");
+ print(" :`:::::::`;::::::;;::: ;::# / DOOO \n");
+ print(" ::`:::::::`;:::::::: ;::::# / DOO \n");
+ print(" `:`:::::::`;:::::: ;::::::#/ DOO \n");
+ print(" :::`:::::::`;; ;:::::::::## OO \n");
+ print(" ::::`:::::::`;::::::::;:::# OO \n");
+ print(" `:::::`::::::::::::;'`:;::# O \n");
+ print(" `:::::`::::::::;' / / `:# \n");
+ print(" ::::::`:::::;' / / `# \n");
+ print(" \n");
+ print(" \n");
+ die('Wrong command.');
+}
+
+$config = $API_COMMANDS[$cmd];
+
+
+$secret = isset($_GET['secret']) ? $_GET['secret'] : '';
+
+if ($config['auth'] === 'webhook_secret' && $secret !== $CONFIG['webhook_secret']) die('Unauthorized.');
+if ($config['auth'] === 'ajax_secret' && $secret !== $CONFIG['ajax_secret']) die('Unauthorized.');
+if ($config['auth'] === 'upload_secret' && $secret !== $CONFIG['upload_secret']) die('Unauthorized.');
+if ($config['auth'] === 'admin' && !isLoggedInByCookie()) die('Unauthorized.');
+
+
+global $API_OPTIONS;
+
+$API_OPTIONS = [];
+foreach ($_GET as $k => $v) $API_OPTIONS[strtolower($k)] = $v;
+foreach ($OPTIONS['_urlparams'] as $k => $v) $API_OPTIONS[strtolower($k)] = $v;
+
+
+try
+{
+ /** @noinspection PhpIncludeInspection */
+ include $config['src'];
+}
+catch (exception $e)
+{
+ print("API Command failed with exception");
+ print($e);
+}
diff --git a/www/pages/api_setselfadress.php b/www/pages/api_setselfadress.php
deleted file mode 100644
index aa96d14..0000000
--- a/www/pages/api_setselfadress.php
+++ /dev/null
@@ -1,9 +0,0 @@
-".$data['version']."
".$data['url']);
\ No newline at end of file
diff --git a/www/pages/api_webhook.php b/www/pages/api_webhook.php
deleted file mode 100644
index db44fe5..0000000
--- a/www/pages/api_webhook.php
+++ /dev/null
@@ -1,28 +0,0 @@
-getMessage();
-}
-
-die('Wrong command.');