X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/d476bcd5e359b590b36e7372833e0e6ebd419587..117541049ca0a09a13a40fc0a5e686e334334fae:/lib/functions.php
diff --git a/lib/functions.php b/lib/functions.php
index cf89593..fd0fe2c 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -143,8 +143,11 @@ function jirafeau_human_size($octets)
// Convert UTC timestamp to a datetime field
function jirafeau_get_datetimefield($timestamp)
{
- $content = ''
- . strftime('%Y-%m-%d %H:%M', $timestamp) . ' (GMT)';
+
+ $ts = date_create("@" . $timestamp);
+ $content = ''
+ . date_format($ts, 'Y-m-d H:i') . ' (GMT)';
+
return $content;
}
@@ -451,13 +454,15 @@ function jirafeau_upload($file, $one_time_download, $key, $time, $ip, $crypt, $l
/* Crypt file if option is enabled. */
$crypted = false;
$crypt_key = '';
- if ($crypt == true && !(extension_loaded('mcrypt') == true)) {
- error_log("PHP extension mcrypt not loaded, won't encrypt in Jirafeau");
+ if ($crypt == true && !(extension_loaded('sodium') == true)) {
+ error_log("PHP extension sodium not loaded, won't encrypt in Jirafeau");
}
- if ($crypt == true && extension_loaded('mcrypt') == true) {
- $crypt_key = jirafeau_encrypt_file($file['tmp_name'], $file['tmp_name']);
+ if ($crypt == true && extension_loaded('sodium') == true) {
+ $crypt_key = jirafeau_encrypt_file($file['tmp_name'], $file['tmp_name'].'crypt');
if (strlen($crypt_key) > 0) {
- $crypted = true;
+ if (rename($file['tmp_name'].'crypt', $file['tmp_name']) === true) {
+ $crypted = true;
+ }
}
}
@@ -512,7 +517,7 @@ function jirafeau_upload($file, $one_time_download, $key, $time, $ip, $crypt, $l
$handle,
$name . NL. $mime_type . NL. $size . NL. $password . NL. $time .
NL . $hash. NL . ($one_time_download ? 'O' : 'R') . NL . time() .
- NL . $ip . NL. $delete_link_code . NL . ($crypted ? 'C' : 'O')
+ NL . $ip . NL. $delete_link_code . NL . ($crypted ? 'C2' : 'O')
);
fclose($handle);
$hash_link = substr(base_16_to_64(md5_file($link_tmp_name)), 0, $link_name_length);
@@ -661,7 +666,8 @@ function jirafeau_get_link($hash)
$out['upload_date'] = trim($c[7]);
$out['ip'] = trim($c[8]);
$out['link_code'] = trim($c[9]);
- $out['crypted'] = trim($c[10]) == 'C';
+ $out['crypted'] = trim($c[10]) == 'C2';
+ $out['crypted_legacy'] = trim($c[10]) == 'C';
return $out;
}
@@ -873,7 +879,7 @@ function jirafeau_fileperms($path)
function jirafeau_admin_bug_report($cfg)
{
$out = "