From: Erik Lundin Date: Tue, 25 Feb 2020 21:40:57 +0000 (+0100) Subject: Make one time download optional X-Git-Tag: 4.2.0~65 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/208418c2e083ff46b0de2e5db64844db68112cc1 Make one time download optional --- 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';
:
' . t('ONE_TIME_DL') . ':