]> git.p6c8.net - jirafeau_project.git/commitdiff
modularization date_int
authorBlackeye <>
Sun, 11 Aug 2024 12:52:16 +0000 (14:52 +0200)
committerBlackeye <>
Sun, 11 Aug 2024 18:44:39 +0000 (20:44 +0200)
lib/functions.php
script.php

index 2378d76a34a56710aafc07d04fee24ad6bdf63c7..d40feb22c4bc26803851b6fa408726dc04626c99 100644 (file)
@@ -1843,3 +1843,36 @@ function jirafeau_get_expiration_time_options() {
         echo '</select>';
  }
 
         echo '</select>';
  }
 
+ function jirafeau_datestr_to_int ($time_str) {
+    $time = time();
+    switch ($time_str) {
+        case 'minute':
+            $time += JIRAFEAU_MINUTE;
+            break;
+        case 'hour':
+            $time += JIRAFEAU_HOUR;
+            break;
+        case 'day':
+            $time += JIRAFEAU_DAY;
+            break;
+        case 'week':
+            $time += JIRAFEAU_WEEK;
+            break;
+        case 'fortnight':
+            $time += JIRAFEAU_FORTNIGHT;
+            break;
+        case 'month':
+            $time += JIRAFEAU_MONTH;
+            break;
+        case 'quarter':
+            $time += JIRAFEAU_QUARTER;
+            break;
+        case 'year':
+            $time += JIRAFEAU_YEAR;
+            break;
+       default:
+            $time = JIRAFEAU_INFINITY;
+            break;
+    }
+    return $time;
+}
index f32ab2048396a152cec5ec7028e360668662593f..95888b5f7a0e80d266844bc049ae9edfcd642dc1 100644 (file)
@@ -92,40 +92,11 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
         exit;
     }
 
         exit;
     }
 
-    $time = time();
     if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) {
         echo 'Error 4: The parameter time is invalid.';
         exit;
     } else {
     if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) {
         echo 'Error 4: The parameter time is invalid.';
         exit;
     } else {
-        switch ($_POST['time']) {
-            case 'minute':
-                $time += JIRAFEAU_MINUTE;
-                break;
-            case 'hour':
-                $time += JIRAFEAU_HOUR;
-                break;
-            case 'day':
-                $time += JIRAFEAU_DAY;
-                break;
-            case 'week':
-                $time += JIRAFEAU_WEEK;
-                break;
-            case 'fortnight':
-                $time += JIRAFEAU_FORTNIGHT;
-                break;
-            case 'month':
-                $time += JIRAFEAU_MONTH;
-                break;
-            case 'quarter':
-                $time += JIRAFEAU_QUARTER;
-                break;
-            case 'year':
-                $time += JIRAFEAU_YEAR;
-                break;
-            default:
-                $time = JIRAFEAU_INFINITY;
-                break;
-        }
+        $time = jirafeau_datestr_to_int($_POST['time']);
     }
 
     // Check file size
     }
 
     // Check file size
@@ -468,40 +439,11 @@ elseif (isset($_GET['init_async'])) {
         exit;
     }
 
         exit;
     }
 
-    $time = time();
     if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) {
         echo 'Error 22';
         exit;
     } else {
     if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) {
         echo 'Error 22';
         exit;
     } else {
-        switch ($_POST['time']) {
-            case 'minute':
-                $time += JIRAFEAU_MINUTE;
-                break;
-            case 'hour':
-                $time += JIRAFEAU_HOUR;
-                break;
-            case 'day':
-                $time += JIRAFEAU_DAY;
-                break;
-            case 'week':
-                $time += JIRAFEAU_WEEK;
-                break;
-            case 'fortnight':
-                $time += JIRAFEAU_FORTNIGHT;
-                break;
-            case 'month':
-                $time += JIRAFEAU_MONTH;
-                break;
-            case 'quarter':
-                $time += JIRAFEAU_QUARTER;
-                break;
-            case 'year':
-                $time += JIRAFEAU_YEAR;
-                break;
-            default:
-                $time = JIRAFEAU_INFINITY;
-                break;
-        }
+        $time = jirafeau_datestr_to_int($_POST['time']);
     }
 
     if ($cfg['store_uploader_ip']) {
     }
 
     if ($cfg['store_uploader_ip']) {

patrick-canterino.de