Suggest a filename when saving a page
parent
041eb96343
commit
e73af72e67
|
@ -20,14 +20,18 @@ $USER='USER THAT SUDO WILL RUN paperfind.sh AS';
|
||||||
##### NO CHANGE PAST THIS LINE #####
|
##### NO CHANGE PAST THIS LINE #####
|
||||||
|
|
||||||
if (array_key_exists('doDownload', $_REQUEST)) {
|
if (array_key_exists('doDownload', $_REQUEST)) {
|
||||||
$date = escapeshellarg(@$_REQUEST['date']);
|
$date = @$_REQUEST['date'];
|
||||||
$page = escapeshellarg(@$_REQUEST['page']);
|
$page = @$_REQUEST['page'];
|
||||||
|
$datearg = escapeshellarg($date);
|
||||||
|
$pagearg = escapeshellarg($page);
|
||||||
|
|
||||||
# -M and -R are used instead of -D to avoid storing the data in RAM
|
# -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) {
|
if ($json) {
|
||||||
$meta = json_decode($json, true);
|
$meta = json_decode($json, true);
|
||||||
|
$ext = explode('/', $meta['mime'])[1];
|
||||||
header("Content-Type: {$meta['mime']}");
|
header("Content-Type: {$meta['mime']}");
|
||||||
|
header("Content-Disposition: inline; filename=\"{$date}_{$page}.{$ext}\"");
|
||||||
passthru("sudo -u {$USER} {$PATH} -R {$date} -p {$page}");
|
passthru("sudo -u {$USER} {$PATH} -R {$date} -p {$page}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue