diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 61937d7..1184536 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -245,7 +245,7 @@ if (isset($_GET['logout'])) { // Validate connection IP if ($ip_ruleset != 'OFF') { - function getClientIP() { + function getClientIP() { if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { return $_SERVER["HTTP_X_FORWARDED_FOR"]; }else if (array_key_exists('REMOTE_ADDR', $_SERVER)) { @@ -255,7 +255,7 @@ if ($ip_ruleset != 'OFF') { } return ''; } - + $clientIp = getClientIP(); $proceed = false; @@ -904,28 +904,28 @@ if (!empty($_FILES) && !FM_READONLY) { if ( is_writable($targetPath) ) { $fullPath = $path . '/' . basename($_REQUEST['fullpath']); $folder = substr($fullPath, 0, strrpos($fullPath, "/")); - + if(file_exists ($fullPath) && !$override_file_name && !$chunks) { $ext_1 = $ext ? '.'.$ext : ''; $fullPath = $path . '/' . basename($_REQUEST['fullpath'], $ext_1) .'_'. date('ymdHis'). $ext_1; } - + if (!is_dir($folder)) { $old = umask(0); mkdir($folder, 0777, true); umask($old); } - - - + + + if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) { if ($chunkTotal){ $out = @fopen("{$fullPath}.part", $chunkIndex == 0 ? "wb" : "ab"); if ($out) { $in = @fopen($tmp_name, "rb"); - if ($in) { - while ($buff = fread($in, 4096)) { fwrite($out, $buff); } - } else { + if ($in) { + while ($buff = fread($in, 4096)) { fwrite($out, $buff); } + } else { $response = array ( 'status' => 'error', 'info' => "failed to open output stream" @@ -934,25 +934,25 @@ if (!empty($_FILES) && !FM_READONLY) { @fclose($in); @fclose($out); @unlink($tmp_name); - + $response = array ( 'status' => 'success', 'info' => "file upload successful", 'fullPath' => $fullPath ); - } else { + } else { $response = array ( 'status' => 'error', 'info' => "failed to open output stream" ); } - - - if ($chunkIndex == $chunkTotal - 1) { - rename("{$fullPath}.part", $fullPath); + + + if ($chunkIndex == $chunkTotal - 1) { + rename("{$fullPath}.part", $fullPath); } - + } else if (move_uploaded_file($tmp_name, $fullPath)) { // Be sure that the file has been uploaded if ( file_exists($fullPath) ) { @@ -1300,11 +1300,11 @@ if (isset($_GET['upload']) && !FM_READONLY) { }); }).on("success", function (res) { let _response = JSON.parse(res.xhr.response); - + if(_response.status == "error") { toast(_response.info); } - + }).on("error", function(file, response) { toast(response); }); @@ -1503,7 +1503,7 @@ if (isset($_GET['settings']) && !FM_READONLY) { - +