From 208418c2e083ff46b0de2e5db64844db68112cc1 Mon Sep 17 00:00:00 2001 From: Erik Lundin Date: Tue, 25 Feb 2020 22:40:57 +0100 Subject: [PATCH] Make one time download optional --- index.php | 10 ++++++---- lib/config.original.php | 5 +++++ lib/functions.js.php | 6 ++++-- script.php | 12 ++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 832749b..faeb8db 100644 --- a/index.php +++ b/index.php @@ -178,10 +178,12 @@ else {
- - - - + '; + echo ''; + } + ?> diff --git a/lib/config.original.php b/lib/config.original.php index 7f8e6ce..736790a 100644 --- a/lib/config.original.php +++ b/lib/config.original.php @@ -133,6 +133,11 @@ $cfg['availabilities'] = array( */ $cfg['availability_default'] = 'month'; +/* Give the uploading user the option to have the file + * deleted after the first download. + */ +$cfg['one_time_download'] = true; + /* Set maximal upload size expressed in MB. * »0« means unlimited upload size. */ diff --git a/lib/functions.js.php b/lib/functions.js.php index 1f83ae7..b2580b5 100644 --- a/lib/functions.js.php +++ b/lib/functions.js.php @@ -558,6 +558,8 @@ function async_upload_end (code) function upload (max_size) { + var one_time_checkbox = document.getElementById('one_time_download'); + var one_time = one_time_checkbox !== null ? one_time_checkbox.checked : false; if (check_html5_file_api () && document.getElementById('file_select').files[0].size >= max_size) { @@ -566,7 +568,7 @@ function upload (max_size) document.getElementById('file_select').files[0], document.getElementById('select_time').value, document.getElementById('input_key').value, - document.getElementById('one_time_download').checked, + one_time, document.getElementById('upload_password').value ); } @@ -576,7 +578,7 @@ function upload (max_size) document.getElementById('file_select').files[0], document.getElementById('select_time').value, document.getElementById('input_key').value, - document.getElementById('one_time_download').checked, + one_time, document.getElementById('upload_password').value ); } diff --git a/script.php b/script.php index 5fe60e2..105023f 100644 --- a/script.php +++ b/script.php @@ -126,6 +126,12 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES) exit; } + // Check if one time download is enabled + if (!$cfg['one_time_download'] && isset($_POST['one_time_download'])) { + echo 'Error 26: One time download is disabled.'; + exit; + } + $res = jirafeau_upload($_FILES['file'], isset($_POST['one_time_download']), $key, $time, get_ip_address($cfg), @@ -409,6 +415,12 @@ elseif (isset($_GET['init_async'])) { $key = $_POST['key']; } + // Check if one time download is enabled + if (!$cfg['one_time_download'] && isset($_POST['one_time_download'])) { + echo 'Error 26: One time download is disabled.'; + exit; + } + $time = time(); if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) { echo 'Error 22'; -- 2.34.1
:
' . t('ONE_TIME_DL') . ':