Suggest a filename when saving a page

master
Y 2016-01-28 20:53:25 +01:00
parent 041eb96343
commit e73af72e67
1 changed files with 7 additions and 3 deletions

View File

@ -20,14 +20,18 @@ $USER='USER THAT SUDO WILL RUN paperfind.sh AS';
##### NO CHANGE PAST THIS LINE #####
if (array_key_exists('doDownload', $_REQUEST)) {
$date = escapeshellarg(@$_REQUEST['date']);
$page = escapeshellarg(@$_REQUEST['page']);
$date = @$_REQUEST['date'];
$page = @$_REQUEST['page'];
$datearg = escapeshellarg($date);
$pagearg = escapeshellarg($page);
# -M and -R are used instead of -D to avoid storing the data in RAM
$json = exec("sudo -u {$USER} {$PATH} -M {$date} -p {$page}");
$json = exec("sudo -u {$USER} {$PATH} -M {$datearg} -p {$pagearg}");
if ($json) {
$meta = json_decode($json, true);
$ext = explode('/', $meta['mime'])[1];
header("Content-Type: {$meta['mime']}");
header("Content-Disposition: inline; filename=\"{$date}_{$page}.{$ext}\"");
passthru("sudo -u {$USER} {$PATH} -R {$date} -p {$page}");
}
} else {