diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8631082 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.php text eol=lf +*.json text eol=lf diff --git a/.github/workflows/PublishDocker.yml b/.github/workflows/PublishDocker.yml index 73dee66..517bae8 100644 --- a/.github/workflows/PublishDocker.yml +++ b/.github/workflows/PublishDocker.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Docker meta id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: images: | ${{ secrets.DOCKERHUB_USERNAME }}/tinyfilemanager @@ -21,6 +21,8 @@ jobs: type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -35,4 +37,5 @@ jobs: uses: docker/build-push-action@v2 with: push: true - tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 8dba40a..37bd371 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -4,7 +4,7 @@ $CONFIG = '{"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols": /** * H3K | Tiny File Manager V2.5.3 - * @author Prasath Mani | CCP Programmers + * @author CCP Programmers * @email ccpprogrammers@gmail.com * @github https://github.com/prasathmani/tinyfilemanager * @link https://tinyfilemanager.github.io @@ -77,6 +77,12 @@ $iconv_input_encoding = 'UTF-8'; // Doc - https://www.php.net/manual/en/function.date.php $datetime_format = 'm/d/Y g:i A'; +// Path display mode when viewing file information +// 'full' => show full path +// 'relative' => show path relative to root_path +// 'host' => show path on the host +$path_display_mode = 'full'; + // Allowed file extensions for create and rename files // e.g. 'txt,html,css,js' $allowed_file_extensions = ''; @@ -220,7 +226,7 @@ if (defined('FM_EMBED')) { mb_regex_encoding('UTF-8'); } - session_cache_limiter(''); + session_cache_limiter('nocache'); // Prevent logout issue after page was cached session_name(FM_SESSION_ID ); function session_error_handling_function($code, $msg, $file, $line) { // Permission denied for default session, try to create a new one @@ -235,7 +241,7 @@ if (defined('FM_EMBED')) { restore_error_handler(); } -//Genrating CSRF Token +//Generating CSRF Token if (empty($_SESSION['token'])) { $_SESSION['token'] = bin2hex(random_bytes(32)); } @@ -320,11 +326,11 @@ if ($use_auth) { if (isset($auth_users[$_POST['fm_usr']]) && isset($_POST['fm_pwd']) && password_verify($_POST['fm_pwd'], $auth_users[$_POST['fm_usr']]) && verifyToken($_POST['token'])) { $_SESSION[FM_SESSION_ID]['logged'] = $_POST['fm_usr']; fm_set_msg(lng('You are logged in')); - fm_redirect(FM_ROOT_URL); + fm_redirect(FM_SELF_URL); } else { unset($_SESSION[FM_SESSION_ID]['logged']); fm_set_msg(lng('Login failed. Invalid username or password'), 'error'); - fm_redirect(FM_ROOT_URL); + fm_redirect(FM_SELF_URL); } } else { fm_set_msg(lng('password_hash not supported, Upgrade PHP version'), 'error');; @@ -912,7 +918,6 @@ if (!empty($_FILES) && !FM_READONLY) { echo json_encode($response); exit(); } - $override_file_name = false; $chunkIndex = $_POST['dzchunkindex']; $chunkTotal = $_POST['dztotalchunkcount']; $fullPathInput = fm_clean_path($_REQUEST['fullpath']); @@ -950,11 +955,6 @@ if (!empty($_FILES) && !FM_READONLY) { $fullPath = $path . '/' . basename($fullPathInput); $folder = substr($fullPath, 0, strrpos($fullPath, "/")); - if(file_exists ($fullPath) && !$override_file_name && !$chunks) { - $ext_1 = $ext ? '.'.$ext : ''; - $fullPath = $path . '/' . basename($fullPathInput, $ext_1) .'_'. date('ymdHis'). $ext_1; - } - if (!is_dir($folder)) { $old = umask(0); mkdir($folder, 0777, true); @@ -967,7 +967,12 @@ if (!empty($_FILES) && !FM_READONLY) { if ($out) { $in = @fopen($tmp_name, "rb"); if ($in) { - while ($buff = fread($in, 4096)) { fwrite($out, $buff); } + if (PHP_VERSION_ID < 80009) { + // workaround https://bugs.php.net/bug.php?id=81145 + while (!feof($in)) { fwrite($out, fread($in, 4096)); } + } else { + stream_copy_to_stream($in, $out); + } $response = array ( 'status' => 'success', 'info' => "file upload successful" @@ -995,7 +1000,13 @@ if (!empty($_FILES) && !FM_READONLY) { } if ($chunkIndex == $chunkTotal - 1) { - rename("{$fullPath}.part", $fullPath); + if (file_exists ($fullPath)) { + $ext_1 = $ext ? '.'.$ext : ''; + $fullPathTarget = $path . '/' . basename($fullPathInput, $ext_1) .'_'. date('ymdHis'). $ext_1; + } else { + $fullPathTarget = $fullPath; + } + rename("{$fullPath}.part", $fullPathTarget); } } else if (move_uploaded_file($tmp_name, $fullPath)) { @@ -1677,7 +1688,8 @@ if (isset($_GET['view'])) {
""
- Full path:
+
+ :
File size:
MIME-type:
- Full path:
+
+ :