]> git.p6c8.net - jirafeau_project.git/blobdiff - lib/functions.php
modularization date_int
[jirafeau_project.git] / lib / functions.php
index 3883173cbd29ac1dcfcaaed612f0ea2eecb00261..d40feb22c4bc26803851b6fa408726dc04626c99 100644 (file)
@@ -879,7 +879,7 @@ function jirafeau_fileperms($path)
 function jirafeau_admin_bug_report($cfg)
 {
     $out = "<fieldset><legend>" . t('REPORTING_AN_ISSUE') . "</legend>";
-    $out .= "If you have a problem related to Jirafeau, please <a href='https://gitlab.com/mojo42/Jirafeau/-/issues'>open an issue</a>, explain your problem in english and copy-paste the following content:<br/><br/><code>";
+    $out .= "If you have a problem related to Jirafeau, please <a href='" . JIRAFEAU_WEBSITE . "/-/issues'>open an issue</a>, explain your problem in english and copy-paste the following content:<br/><br/><code>";
 
     $out .= "# Jirafeau<br/>";
     $out .= "- version: " . JIRAFEAU_VERSION . "<br/>";
@@ -1315,6 +1315,8 @@ function jirafeau_decrypt_file_legacy($fp_src, $fp_dst, $k)
     $crypt_key = $k;
     $hash_key = md5($crypt_key);
     $iv = jirafeau_crypt_create_iv($hash_key, mcrypt_enc_get_iv_size($m));
+    /* Init module. */
+    mcrypt_generic_init($m, $hash_key, $iv);
     /* Decrypt file. */
     $r = fopen($fp_src, 'r');
     $w = fopen($fp_dst, 'c');
@@ -1718,3 +1720,159 @@ 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>';
+ }
+
+ 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;
+}

patrick-canterino.de