1
0

api_backupupload

This commit is contained in:
Mike Schwörer 2018-03-03 16:12:44 +01:00
parent cd24a6e5ad
commit 35c1ea30c7
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 38 additions and 1 deletions

View File

@ -41,6 +41,7 @@ $URL_RULES =
[ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api_setselfadress.php', 'options' => [ '_opt' => 'http', ], ], [ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api_setselfadress.php', 'options' => [ '_opt' => 'http', ], ],
[ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ], [ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ],
[ 'url' => ['api', 'webhook', '?{target}'], 'target' => 'pages/api_webhook.php', 'options' => [ '_opt' => 'http', 'target' => '%URL%', 'secret' => '%GET%', ],], [ 'url' => ['api', 'webhook', '?{target}'], 'target' => 'pages/api_webhook.php', 'options' => [ '_opt' => 'http', 'target' => '%URL%', 'secret' => '%GET%', ],],
[ 'url' => ['api', 'backupupload'], 'target' => 'pages/api_backupupload.php', 'options' => [ '_opt' => 'http', 'folder' => '%GET%', 'filename' => '%GET%', 'secret' => '%GET%', ],],
[ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ], [ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ],
[ 'url' => ['admin', 'updateslog', '${name}'], 'target' => 'pages/admin_ul-list.php', 'options' => [ '_opt' => 'password', 'name' => '%URL%'],], [ 'url' => ['admin', 'updateslog', '${name}'], 'target' => 'pages/admin_ul-list.php', 'options' => [ '_opt' => 'password', 'name' => '%URL%'],],
@ -208,3 +209,6 @@ try {
//TODO support for different color schemes //TODO support for different color schemes
// should be possible to change with just a few constant in config.scss // should be possible to change with just a few constant in config.scss
// a (little) bit more hue in default scheme // a (little) bit more hue in default scheme
//TODO Add easing cookbook
//TODO add befunrep query
//TODO evtl webapp section (?)

View File

@ -0,0 +1,33 @@
<?php
global $OPTIONS;
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/database.php');
$folder = $OPTIONS['folder'];
$filename = $OPTIONS['filename'];
$secret = $OPTIONS['secret'];
$uri = $OPTIONS['uri'];
$reltarget = "/Mikescher/files/Backup/$folder";
$target = "/media/filecloud/data/Mikescher/files/Backup/$folder/$filename";
if ($secret !== $CONFIG['upload_secret']) die('Unauthorized.');
$putdata = fopen("php://input", "r");
$fp = fopen($target, "x");
while ($data = fread($putdata, 1024)) fwrite($fp, $data);
fclose($fp);
fclose($putdata);
$std = shell_exec("sudo scan-cloud " . '"' . $reltarget . '"'); // scan-cloud is allowed for all in /etc/sudoers
$content = "REQUEST: " . $uri . "\r\n\r\n" .
"IP: " . get_client_ip() . "\r\n\r\n" .
"TARGET: " . $target . "\r\n\r\n" .
"OUTPUT: " . $std . "\r\n\r\n";
sendMail("Fileupload to '$folder' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-error@mikescher.com');