X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/a046e3b04175367c1afadd306513414fa61ba3fd..23a68ba6e720d9d9449ccea4dd366cb002b4aa0f:/lib/functions.php diff --git a/lib/functions.php b/lib/functions.php index 83d7a2d..2843e29 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -93,7 +93,7 @@ function jirafeau_gen_random($l) return 42; } - $code=""; + $code = ''; for ($i = 0; $i < $l; $i++) { $code .= dechex(rand(0, 15)); } @@ -106,7 +106,7 @@ function jirafeau_gen_download_pass($length, $allowed_chars) if ($length <= 0) { return false; } - $pass=""; + $pass = ''; for ($i = 0; $i < $length; $i++) { $pass .= $allowed_chars[rand(0, strlen($allowed_chars) - 1)]; } @@ -143,10 +143,10 @@ function jirafeau_human_size($octets) // Convert UTC timestamp to a datetime field function jirafeau_get_datetimefield($timestamp) { - $ts = date_create("@" . $timestamp); + $ts = date_create('@' . $timestamp); $content = '' . date_format($ts, 'Y-m-d H:i') . ' (GMT)'; - + return $content; } @@ -397,7 +397,7 @@ function jirafeau_hash_file($method, $file_path) function jirafeau_md5_outside($file_path) { $out = false; - $handle = fopen($file_path, "r"); + $handle = fopen($file_path, 'r'); if ($handle === false) { return false; } @@ -450,12 +450,13 @@ function jirafeau_upload($file, $one_time_download, $key, $time, $ip, $crypt, $l } /** - * - * @param bool $crypt_module_enabled - * @param string $file_path + * + * @param bool $crypt_module_enabled + * @param string $file_path * @return array [bool, string] */ -function jirafeau_handle_add_file_encryption($crypt_module_enabled, $file_path) { +function jirafeau_handle_add_file_encryption($crypt_module_enabled, $file_path) +{ /* Crypt file if option is enabled. */ $crypted = false; $crypt_key = ''; @@ -501,7 +502,6 @@ function jirafeau_add_file($file, $one_time_download, $key, $time, $ip, $crypt, $crypt_key = ''; list($crypted, $crypt_key) = jirafeau_handle_add_file_encryption($crypt, $file['tmp_name']); - /* file information */ $hash = jirafeau_hash_file($file_hash_method, $file['tmp_name']); $name = str_replace(NL, '', trim($file['name'])); @@ -513,12 +513,9 @@ function jirafeau_add_file($file, $one_time_download, $key, $time, $ip, $crypt, $p = s2p("$hash"); if (file_exists(VAR_FILES . $p . $hash)) { $rc = unlink($file['tmp_name']); - } elseif ((file_exists(VAR_FILES . $p) || @mkdir(VAR_FILES . $p, 0755, true)) - && - //move_uploaded_file($file['tmp_name'], VAR_FILES . $p . $hash)) - $move_operation($file['tmp_name'], VAR_FILES . $p . $hash)) - { - + } elseif ( + (file_exists(VAR_FILES . $p) || @mkdir(VAR_FILES . $p, 0755, true)) && + $move_operation($file['tmp_name'], VAR_FILES . $p . $hash)) { $rc = true; } if (!$rc) { @@ -526,7 +523,7 @@ function jirafeau_add_file($file, $one_time_download, $key, $time, $ip, $crypt, 'error' => array('has_error' => true, 'why' => t('INTERNAL_ERROR_DEL')), - 'link' =>'', + 'link' => '', 'delete_link' => '')); } @@ -580,7 +577,7 @@ function jirafeau_add_file($file, $one_time_download, $key, $time, $ip, $crypt, 'error' => array('has_error' => true, 'why' => t('Internal error during file creation. ')), - 'link' =>'', + 'link' => '', 'delete_link' => ''); } return array( 'error' => $noerr, @@ -589,8 +586,8 @@ function jirafeau_add_file($file, $one_time_download, $key, $time, $ip, $crypt, 'crypt_key' => $crypt_key); } - -function jirafeau_admin_list_table ($name, $file_hash, $link_hash, $visitor_function = null) { +function jirafeau_admin_list_table($name, $file_hash, $link_hash, $visitor_function = null) +{ echo '
'; } - - - - /** * Tells if a mime-type is viewable in a browser * @param $mime the mime type @@ -744,12 +737,12 @@ function jirafeau_get_link($hash) } /** - * List files ii folder in admin interface. + * List files in admin interface. */ function jirafeau_admin_list($name, $file_hash, $link_hash) { - $function = function($name, $file_hash, $link_hash) { - /* Get all links files. */ + $function = function ($name, $file_hash, $link_hash) { + /* Get all links files. */ $stack = array(VAR_LINKS); while (($d = array_shift($stack)) && $d != null) { $dir = scandir($d); @@ -780,25 +773,38 @@ function jirafeau_admin_list($name, $file_hash, $link_hash) } /* Print link information. */ echo '