]> git.p6c8.net - jirafeau_mojo42.git/commitdiff
Make one time download optional
authorErik Lundin <erik@lun.nu>
Tue, 25 Feb 2020 21:40:57 +0000 (22:40 +0100)
committerJerome Jutteau <jerome@jutteau.fr>
Tue, 7 Apr 2020 20:17:15 +0000 (22:17 +0200)
index.php
lib/config.original.php
lib/functions.js.php
script.php

index 832749bb3303be153066bb2b1797fcc6c7122a63..faeb8db07670973e916173b931bdad50a1236acb 100644 (file)
--- a/index.php
+++ b/index.php
@@ -178,10 +178,12 @@ else {
 
     <div id="options">
         <table id="option_table">
-        <tr>
-        <td><?php echo t('ONE_TIME_DL'); ?>:</td>
-        <td><input type="checkbox" id="one_time_download" /></td>
-        </tr>
+        <?php
+        if ($cfg['one_time_download']) {
+            echo '<tr><td>' . t('ONE_TIME_DL') . ':</td>';
+            echo '<td><input type="checkbox" id="one_time_download" /></td></tr>';
+        }
+        ?>
         <tr>
         <td><label for="input_key"><?php echo t('PSW') . ':'; ?></label></td>
         <td><input type="password" name="key" id="input_key" /></td>
index 7f8e6ceeab99f518ff3b1279c03833b19ed1991e..736790a4010d4c484ff6e3f4a9b3e24920c7780d 100644 (file)
@@ -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.
  */
index 1f83ae75d08343d3f36b3c9385b16e01db7d7d89..b2580b512b9d3029a508868a290b4b733f768e9b 100644 (file)
@@ -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
             );
     }
index 5fe60e2c4829a02000c36ec2006d7418c40c25bd..105023fcc8b7abb726f72e00efa86775d5b985be 100644 (file)
@@ -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';

patrick-canterino.de