]> git.p6c8.net - jirafeau_project.git/commitdiff
modularized index php
authorBlackeye <>
Sun, 11 Aug 2024 12:10:38 +0000 (14:10 +0200)
committerBlackeye <>
Sun, 11 Aug 2024 18:44:39 +0000 (20:44 +0200)
index.php
lib/functions.php

index 662f1579d5dabbab766800528b3f15a8c8c994a2..fd8586da143790b67efba663db37c34784c29153 100644 (file)
--- a/index.php
+++ b/index.php
@@ -101,70 +101,8 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
 }
 
 ?>
-<div id="upload_finished">
-    <p><?php echo t('FILE_UP') ?></p>
 
-    <div id="upload_finished_download_page">
-    <p>
-        <a id="upload_link" href=""><?php echo t('DL_PAGE') ?></a>
-        <a id="upload_link_email" href=""><img id="upload_image_email"/></a>
-    </p><p>
-        <code id=upload_link_text></code>
-        <button id="upload_link_button">&#128203;</button>
-    </p>
-    </div>
-
-    <?php if ($cfg['download_password_requirement'] === "generated"){
-    ?>
-    <div id="show_password">
-    <p><?php echo t('PSW') ?></p>
-
-    <div id="download_password">
-    <p>
-        <?php echo '<input id="output_key" value="' . $download_pass . '"/>'?>
-        <button id="password_copy_button">&#128203;</button>
-    </p>
-    </div>
-    </div>
-    <?php
-    }?>
-
-    <?php if ($cfg['preview'] == true) {
-        ?>
-    <div id="upload_finished_preview">
-    <p>
-        <a id="preview_link" href=""><?php echo t('VIEW_LINK') ?></a>
-    </p><p>
-        <code id=preview_link_text></code>
-        <button id="preview_link_button">&#128203;</button>
-    </p>
-    </div>
-    <?php
-    } ?>
-
-    <div id="upload_direct_download">
-    <p>
-        <a id="direct_link" href=""><?php echo t('DIRECT_DL') ?></a>
-    </p><p>
-        <code id=direct_link_text></code>
-        <button id="direct_link_button">&#128203;</button>
-    </p>
-    </div>
-
-    <div id="upload_delete">
-    <p>
-        <a id="delete_link" href=""><?php echo t('DELETE_LINK') ?></a>
-    </p><p>
-        <code id=delete_link_text></code>
-        <button id="delete_link_button">&#128203;</button>
-    </p>
-    </div>
-
-    <div id="upload_validity">
-    <p><?php echo t('VALID_UNTIL'); ?>:</p>
-    <p id="date"></p>
-    </div>
-</div>
+<?php jirafeau_create_upload_finished_box($cfg['preview']); ?>
 
 <div id="uploading">
     <p>
@@ -227,55 +165,9 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
         }?>
         <tr>
         <td><label for="select_time"><?php echo t('TIME_LIM') . ':'; ?></label></td>
-        <td><select name="time" id="select_time">
-        <?php
-$expirationTimeOptions = array(
-  array(
-    'value' => 'minute',
-    'label' => '1_MIN'
-  ),
-  array(
-    'value' => 'hour',
-    'label' => '1_H'
-  ),
-  array(
-    'value' => 'day',
-    'label' => '1_D'
-  ),
-  array(
-    'value' => 'week',
-    'label' => '1_W'
-  ),
-  array(
-      'value' => 'fortnight',
-      'label' => '2_W'
-  ),
-  array(
-    'value' => 'month',
-    'label' => '1_M'
-  ),
-  array(
-    'value' => 'quarter',
-    'label' => '1_Q'
-  ),
-  array(
-    'value' => 'year',
-    'label' => '1_Y'
-  ),
-  array(
-    'value' => 'none',
-    'label' => 'NONE'
-  )
-);
-foreach ($expirationTimeOptions as $expirationTimeOption) {
-    $selected = ($expirationTimeOption['value'] === $cfg['availability_default'])? 'selected="selected"' : '';
-    if (true === $cfg['availabilities'][$expirationTimeOption['value']]) {
-        echo '<option value="' . $expirationTimeOption['value'] . '" ' .
-              $selected . '>' . t($expirationTimeOption['label']) . '</option>';
-    }
-}
-?>
-        </select></td>
+        <td>
+            <?php jirafeau_create_selection_array($cfg); ?> 
+        </td>
         </tr>
 
         <?php
index b3a84ac64620961b9acb07e32a59c0034f84bafc..2378d76a34a56710aafc07d04fee24ad6bdf63c7 100644 (file)
@@ -1720,3 +1720,126 @@ function jirafeau_write_download_stats($hash, $ip)
     fwrite($handle, $count . NL . time() . NL . $ip);
     fclose($handle);
 }
+
+function jirafeau_create_upload_finished_box($preview = true) {
+    ?>
+
+    <div id="upload_finished">
+    <p><?php echo t('FILE_UP') ?></p>
+
+    <div id="upload_finished_download_page">
+    <p>
+        <a id="upload_link" href=""><?php echo t('DL_PAGE') ?></a>
+        <a id="upload_link_email" href=""><img id="upload_image_email"/></a>
+    </p><p>
+        <code id=upload_link_text></code>
+        <button id="upload_link_button">&#128203;</button>
+    </p>
+    </div>
+
+    <?php if ($preview == true) {
+    ?>
+    <div id="upload_finished_preview">
+    <p>
+        <a id="preview_link" href=""><?php echo t('VIEW_LINK') ?></a>
+    </p><p>
+        <code id=preview_link_text></code>
+        <button id="preview_link_button">&#128203;</button>
+    </p>
+    </div>
+    <?php
+} ?>
+
+    <div id="upload_direct_download">
+    <p>
+        <a id="direct_link" href=""><?php echo t('DIRECT_DL') ?></a>
+    </p><p>
+        <code id=direct_link_text></code>
+        <button id="direct_link_button">&#128203;</button>
+    </p>
+    </div>
+
+    <div id="upload_delete">
+    <p>
+        <a id="delete_link" href=""><?php echo t('DELETE_LINK') ?></a>
+    </p><p>
+        <code id=delete_link_text></code>
+        <button id="delete_link_button">&#128203;</button>
+    </p>
+    </div>
+
+    <div id="upload_validity">
+    <p><?php echo t('VALID_UNTIL'); ?>:</p>
+    <p id="date"></p>
+    </div>
+</div>
+<?php 
+}
+
+function jirafeau_get_expiration_time_options() {
+    return 
+    array(
+        array(
+          'value' => 'minute',
+          'label' => '1_MIN'
+        ),
+        array(
+          'value' => 'hour',
+          'label' => '1_H'
+        ),
+        array(
+          'value' => 'day',
+          'label' => '1_D'
+        ),
+        array(
+          'value' => 'week',
+          'label' => '1_W'
+        ),
+        array(
+            'value' => 'fortnight',
+            'label' => '2_W'
+        ),
+        array(
+          'value' => 'month',
+          'label' => '1_M'
+        ),
+        array(
+          'value' => 'quarter',
+          'label' => '1_Q'
+        ),
+        array(
+          'value' => 'year',
+          'label' => '1_Y'
+        ),
+        array(
+          'value' => 'none',
+          'label' => 'NONE'
+        )
+      );
+}
+
+
+
+ /**
+  * 
+  * creates the time selection field
+  * @param mixed $cfg 
+  * @return void 
+  */
+  function jirafeau_create_selection_array($cfg) {
+    echo 
+    '<select name="time" id="select_time">';
+        
+        
+        $expirationTimeOptions = jirafeau_get_expiration_time_options();
+
+        foreach ($expirationTimeOptions as $expirationTimeOption) {
+            $selected = ($expirationTimeOption['value'] === $cfg['availability_default'])? 'selected="selected"' : '';
+            if (true === $cfg['availabilities'][$expirationTimeOption['value']]) {
+                echo '<option value="' . $expirationTimeOption['value'] . '" ' .
+              $selected . '>' . t($expirationTimeOption['label']) . '</option>';
+            }
+        }
+        echo '</select>';
+ }
+

patrick-canterino.de