1
0
www.mikescher.com/www/commands/server_backupupload.php

37 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2018-03-03 16:12:44 +01:00
<?php
2020-01-16 13:21:14 +01:00
require_once (__DIR__ . '/../internals/website.php');
2018-03-03 16:12:44 +01:00
2020-01-16 13:21:14 +01:00
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
2018-03-03 16:12:44 +01:00
2020-01-16 13:21:14 +01:00
if (!isset($API_OPTIONS['folder'])) { $FRAME_OPTIONS->forceResult(400, "Wrong parameters."); return; }
if (!isset($API_OPTIONS['filename'])) { $FRAME_OPTIONS->forceResult(400, "Wrong parameters."); return; }
2018-03-03 16:12:44 +01:00
$folder = $API_OPTIONS['folder'];
$filename = $API_OPTIONS['filename'];
2020-01-16 13:21:14 +01:00
$uri = $ROUTE->full_url;
2018-03-03 16:12:44 +01:00
$reltarget = "Backup/$folder/$filename";
2018-03-03 16:12:44 +01:00
$putdata = fopen("php://input", "r");
2018-12-22 21:20:12 +01:00
$fp = tmpfile();
$tmppath = stream_get_meta_data($fp)['uri'];
2018-03-03 16:12:44 +01:00
while ($data = fread($putdata, 1024)) fwrite($fp, $data);
fclose($putdata);
2019-03-04 14:31:09 +01:00
$std = shell_exec("ncc_upload " . '"' . $tmppath . '" "' . $reltarget . '" 2>&1');
fclose($fp);
2018-03-03 16:12:44 +01:00
2018-12-22 21:20:12 +01:00
$content = "REQUEST: " . $uri . "\r\n\r\n" .
2018-03-03 16:12:44 +01:00
"IP: " . get_client_ip() . "\r\n\r\n" .
2018-12-22 21:20:12 +01:00
"TARGET: " . $reltarget . "\r\n\r\n" .
"OUTPUT: " . $std . "\r\n\r\n";
2018-03-03 16:12:44 +01:00
2019-03-04 14:31:09 +01:00
sendMail("Fileupload to '$folder' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-info@mikescher.com');
echo "OK.\n\n";
echo $content;