Refactor [su_ajax|admin_cmd|api_webhook] methods into single /api/ interface
This commit is contained in:
38
www/commands/server_backupupload.php
Normal file
38
www/commands/server_backupupload.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
global $API_OPTIONS;
|
||||
|
||||
require_once (__DIR__ . '/../internals/base.php');
|
||||
require_once (__DIR__ . '/../internals/database.php');
|
||||
|
||||
if (!isset($API_OPTIONS['folder'])) die("Wrong parameters.");
|
||||
if (!isset($API_OPTIONS['filename'])) die("Wrong parameters.");
|
||||
if (!isset($API_OPTIONS['secret'])) die("Wrong parameters.");
|
||||
if (!isset($API_OPTIONS['uri'])) die("Wrong parameters.");
|
||||
|
||||
$folder = $API_OPTIONS['folder'];
|
||||
$filename = $API_OPTIONS['filename'];
|
||||
$secret = $API_OPTIONS['secret'];
|
||||
$uri = $API_OPTIONS['uri'];
|
||||
|
||||
$reltarget = "Backup/$folder/$filename";
|
||||
|
||||
$putdata = fopen("php://input", "r");
|
||||
$fp = tmpfile();
|
||||
$tmppath = stream_get_meta_data($fp)['uri'];
|
||||
while ($data = fread($putdata, 1024)) fwrite($fp, $data);
|
||||
fclose($putdata);
|
||||
|
||||
$std = shell_exec("ncc_upload " . '"' . $tmppath . '" "' . $reltarget . '" 2>&1');
|
||||
|
||||
fclose($fp);
|
||||
|
||||
$content = "REQUEST: " . $uri . "\r\n\r\n" .
|
||||
"IP: " . get_client_ip() . "\r\n\r\n" .
|
||||
"TARGET: " . $reltarget . "\r\n\r\n" .
|
||||
"OUTPUT: " . $std . "\r\n\r\n";
|
||||
|
||||
sendMail("Fileupload to '$folder' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-info@mikescher.com');
|
||||
|
||||
echo "OK.\n\n";
|
||||
echo $content;
|
||||
Reference in New Issue
Block a user