fixed some API methods
This commit is contained in:
parent
3f4cc7875d
commit
6e895484d7
@ -5,12 +5,12 @@ global $API_OPTIONS;
|
|||||||
require_once (__DIR__ . '/../internals/base.php');
|
require_once (__DIR__ . '/../internals/base.php');
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
require_once (__DIR__ . '/../internals/database.php');
|
||||||
|
|
||||||
if (!isset($API_OPTIONS['name'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['name'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['clientid'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['clientid'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['version'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['version'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['providerstr'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['providerstr'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['providerid'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['providerid'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['notecount'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['notecount'])) httpDie(400, "Wrong parameters.");
|
||||||
|
|
||||||
$nam = $API_OPTIONS['name'];
|
$nam = $API_OPTIONS['name'];
|
||||||
$cid = $API_OPTIONS['clientid'];
|
$cid = $API_OPTIONS['clientid'];
|
||||||
|
@ -6,7 +6,7 @@ require_once (__DIR__ . '/../internals/base.php');
|
|||||||
require_once (__DIR__ . '/../internals/programs.php');
|
require_once (__DIR__ . '/../internals/programs.php');
|
||||||
require_once (__DIR__ . '/../internals/updateslog.php');
|
require_once (__DIR__ . '/../internals/updateslog.php');
|
||||||
|
|
||||||
if (!isset($API_OPTIONS['name'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['name'])) httpDie(400, "Wrong parameters.");
|
||||||
|
|
||||||
$name = $API_OPTIONS['name'];
|
$name = $API_OPTIONS['name'];
|
||||||
|
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $API_OPTIONS;
|
global $API_OPTIONS;
|
||||||
|
global $OPTIONS;
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
require_once (__DIR__ . '/../internals/base.php');
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
require_once (__DIR__ . '/../internals/database.php');
|
||||||
|
|
||||||
if (!isset($API_OPTIONS['folder'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['folder'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['filename'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['filename'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['secret'])) die("Wrong parameters.");
|
|
||||||
if (!isset($API_OPTIONS['uri'])) die("Wrong parameters.");
|
|
||||||
|
|
||||||
$folder = $API_OPTIONS['folder'];
|
$folder = $API_OPTIONS['folder'];
|
||||||
$filename = $API_OPTIONS['filename'];
|
$filename = $API_OPTIONS['filename'];
|
||||||
$secret = $API_OPTIONS['secret'];
|
$uri = $OPTIONS['uri'];
|
||||||
$uri = $API_OPTIONS['uri'];
|
|
||||||
|
|
||||||
$reltarget = "Backup/$folder/$filename";
|
$reltarget = "Backup/$folder/$filename";
|
||||||
|
|
||||||
|
@ -1,23 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $API_OPTIONS;
|
global $API_OPTIONS;
|
||||||
|
global $OPTIONS;
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
require_once (__DIR__ . '/../internals/base.php');
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
require_once (__DIR__ . '/../internals/database.php');
|
||||||
|
|
||||||
if (!isset($API_OPTIONS['target'])) die("Wrong parameters.");
|
if (!isset($API_OPTIONS['target'])) httpDie(400, "Wrong parameters.");
|
||||||
if (!isset($API_OPTIONS['secret'])) die("Wrong parameters.");
|
|
||||||
if (!isset($API_OPTIONS['uri'])) die("Wrong parameters.");
|
|
||||||
|
|
||||||
$hook = $API_OPTIONS['target'];
|
$hook = $API_OPTIONS['target'];
|
||||||
$secret = $API_OPTIONS['secret'];
|
$uri = $OPTIONS['uri'];
|
||||||
$uri = $API_OPTIONS['uri'];
|
|
||||||
|
|
||||||
$cmd = "";
|
$cmd = "";
|
||||||
|
|
||||||
if ($hook == 'website_mikescher') $cmd = 'git pull';
|
if ($hook == 'website_mikescher') $cmd = 'git pull';
|
||||||
else if ($hook == 'griddominance') $cmd = 'update-gdapi';
|
else if ($hook == 'griddominance') $cmd = 'update-gdapi';
|
||||||
else die("Unknown webhook: $hook");
|
else httpDie(400, "Unknown webhook: $hook");
|
||||||
|
|
||||||
$std = shell_exec($cmd);
|
$std = shell_exec($cmd);
|
||||||
|
|
||||||
|
@ -27,6 +27,3 @@ echo 'Finished.' . '<br/>' . "\n";
|
|||||||
echo '<script>setTimeout(function () { window.location.href = "/admin"; }, 3000);</script>';
|
echo '<script>setTimeout(function () { window.location.href = "/admin"; }, 3000);</script>';
|
||||||
echo '</body>';
|
echo '</body>';
|
||||||
echo '</html>';
|
echo '</html>';
|
||||||
|
|
||||||
|
|
||||||
die('Wrong command.');
|
|
@ -51,6 +51,14 @@ function httpError($errorcode, $message)
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function httpDie($errorcode, $message)
|
||||||
|
{
|
||||||
|
ob_clean();
|
||||||
|
http_response_code($errorcode);
|
||||||
|
die($message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function destructiveUrlEncode($str) {
|
function destructiveUrlEncode($str) {
|
||||||
$str = str_replace(' ', '_', $str);
|
$str = str_replace(' ', '_', $str);
|
||||||
$str = str_replace('+', '_', $str);
|
$str = str_replace('+', '_', $str);
|
||||||
|
@ -56,7 +56,7 @@ if (!array_key_exists($cmd, $API_COMMANDS))
|
|||||||
print(" ::::::`:::::;' / / `# \n");
|
print(" ::::::`:::::;' / / `# \n");
|
||||||
print(" \n");
|
print(" \n");
|
||||||
print(" \n");
|
print(" \n");
|
||||||
die('Wrong command.');
|
httpDie(400, 'Wrong command.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = $API_COMMANDS[$cmd];
|
$config = $API_COMMANDS[$cmd];
|
||||||
@ -64,10 +64,10 @@ $config = $API_COMMANDS[$cmd];
|
|||||||
|
|
||||||
$secret = isset($_GET['secret']) ? $_GET['secret'] : '';
|
$secret = isset($_GET['secret']) ? $_GET['secret'] : '';
|
||||||
|
|
||||||
if ($config['auth'] === 'webhook_secret' && $secret !== $CONFIG['webhook_secret']) die('Unauthorized.');
|
if ($config['auth'] === 'webhook_secret' && $secret !== $CONFIG['webhook_secret']) httpDie(401, 'Unauthorized.');
|
||||||
if ($config['auth'] === 'ajax_secret' && $secret !== $CONFIG['ajax_secret']) die('Unauthorized.');
|
if ($config['auth'] === 'ajax_secret' && $secret !== $CONFIG['ajax_secret']) httpDie(401, 'Unauthorized.');
|
||||||
if ($config['auth'] === 'upload_secret' && $secret !== $CONFIG['upload_secret']) die('Unauthorized.');
|
if ($config['auth'] === 'upload_secret' && $secret !== $CONFIG['upload_secret']) httpDie(401, 'Unauthorized.');
|
||||||
if ($config['auth'] === 'admin' && !isLoggedInByCookie()) die('Unauthorized.');
|
if ($config['auth'] === 'admin' && !isLoggedInByCookie()) httpDie(401, 'Unauthorized.');
|
||||||
|
|
||||||
|
|
||||||
global $API_OPTIONS;
|
global $API_OPTIONS;
|
||||||
|
Loading…
Reference in New Issue
Block a user