From 85ae4780432f117b512c09ef78c6e004bc4b6095 Mon Sep 17 00:00:00 2001 From: Dmitriy Novash Date: Thu, 9 Jun 2022 19:14:26 +0300 Subject: [PATCH 1/5] add webp to images --- src/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.php b/src/main.php index a7e4a8e..118ca9a 100644 --- a/src/main.php +++ b/src/main.php @@ -1168,7 +1168,7 @@ f00bar; $type = strtolower($type); switch ($type) { case "aac": case "aiff": case "mid": case "mp3": case "wav": return 'icon icon-file-audio'; break; - case "ai": case "bmp": case "eps": case "tiff": case "gif": case "jpg": case "jpeg": case "png": case "psd": case "svg": return 'icon icon-file-image'; break; + case "ai": case "bmp": case "eps": case "tiff": case "gif": case "jpg": case "jpeg": case "png": case "psd": case "svg": case "webp": return 'icon icon-file-image'; break; case "avi": case "flv": case "mp4": case "mpg": case "mkv": case "mpeg": case "webm": case "wmv": case "mov": return 'icon icon-file-video'; break; case "c": case "cpp": case "css": case "dat": case "h": case "html": case "java": case "js": case "php": case "py": case "sql": case "xml": case "yml": case "json": return 'icon icon-file-code'; break; case "doc": case "docx": case "odf": case "odt": case "rtf": return 'icon icon-file-word'; break; From 61e911fa4f88ab37136ca5f03836adc4396a9f0d Mon Sep 17 00:00:00 2001 From: Dmitriy Novash Date: Thu, 9 Jun 2022 19:16:50 +0300 Subject: [PATCH 2/5] fix whitespaces --- src/main.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main.php b/src/main.php index 118ca9a..2017cba 100644 --- a/src/main.php +++ b/src/main.php @@ -220,22 +220,22 @@ f00bar; $this->chDirIfNecessary($_REQUEST['dir']); switch ($_REQUEST["api"]) { - case "createDir": return $this->createDir($_REQUEST); - case "saveFile": return $this->saveFile($_REQUEST); - case "getContent": return $this->getContent($_REQUEST); - case "delete": return $this->deleteFiles($_REQUEST); - case "rename": return $this->renameFile($_REQUEST); - case "download": return $this->downloadFile($_REQUEST); - case "extract": return $this->extractFile($_REQUEST); - case "upload": return $this->uploadFile($_REQUEST); - case "copyMove": return $this->copyMove($_REQUEST); - case "changePermissions": return $this->changePermissions($_REQUEST); - case "zipnload": return $this->zipnload($_REQUEST); - case "remoteUpload": return $this->remoteUpload($_REQUEST); - case "searchItems": return $this->searchItems($_REQUEST); - case "getFolderTree": return $this->getFolderTree($_REQUEST); - case "createArchive": return $this->createArchive($_REQUEST); - case "proxy": return $this->downloadFile($_REQUEST, false); + case "createDir": return $this->createDir($_REQUEST); + case "saveFile": return $this->saveFile($_REQUEST); + case "getContent": return $this->getContent($_REQUEST); + case "delete": return $this->deleteFiles($_REQUEST); + case "rename": return $this->renameFile($_REQUEST); + case "download": return $this->downloadFile($_REQUEST); + case "extract": return $this->extractFile($_REQUEST); + case "upload": return $this->uploadFile($_REQUEST); + case "copyMove": return $this->copyMove($_REQUEST); + case "changePermissions": return $this->changePermissions($_REQUEST); + case "zipnload": return $this->zipnload($_REQUEST); + case "remoteUpload": return $this->remoteUpload($_REQUEST); + case "searchItems": return $this->searchItems($_REQUEST); + case "getFolderTree": return $this->getFolderTree($_REQUEST); + case "createArchive": return $this->createArchive($_REQUEST); + case "proxy": return $this->downloadFile($_REQUEST, false); default: throw new IFMException($this->l("invalid_action")); } @@ -353,7 +353,7 @@ f00bar; $item["type"] = "dir"; if ($name == "..") $item["icon"] = "icon icon-up-open"; - else + else $item["icon"] = "icon icon-folder-empty"; } else { $item["type"] = "file"; @@ -573,7 +573,7 @@ f00bar; if (isset($d['filename']) && $this->isFilenameValid($d['filename'])) { if (isset($d['content'])) { // work around magic quotes - if((function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) + if((function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) || (ini_get('magic_quotes_sybase') && (strtolower(ini_get('magic_quotes_sybase'))!="off")) ) { $content = stripslashes($d['content']); } else { @@ -663,7 +663,7 @@ f00bar; if (!is_file($d['filename'])) http_response_code(404); - else + else $this->fileDownload(["file" => $d['filename'], "forceDL" => $forceDL]); } @@ -861,7 +861,7 @@ f00bar; return ["status" => "OK", "message" => $this->l('file_upload_success')]; curl_close($ch); fclose($fp); - } else + } else throw new IFMException($this->l('file_open_error')); } } else @@ -893,7 +893,7 @@ f00bar; foreach ($d['filenames'] as $file) if (!$this->isFilenameValid($file)) throw new IFMException($this->l('invalid_filename')); - else + else array_push($filenames, realpath($file)); switch ($d['format']) { From ac67994b7217fa82102f52ae22fce910eadff464 Mon Sep 17 00:00:00 2001 From: Dmitriy Novash Date: Thu, 9 Jun 2022 19:18:34 +0300 Subject: [PATCH 3/5] getScriptRoot return wrong path when use symlinks --- src/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.php b/src/main.php index 2017cba..53e2cfd 100644 --- a/src/main.php +++ b/src/main.php @@ -1160,7 +1160,7 @@ f00bar; } private function chDirIfNecessary($d) { - if (substr(getcwd(), strlen($this->getScriptRoot())) != $this->getValidDir($d) && !empty($d)) + if (substr(getcwd(), strlen($this->getRootDir())) != $this->getValidDir($d) && !empty($d)) chdir($d); } From 49c42b635e1dab42895710a87e7b714a11b2551f Mon Sep 17 00:00:00 2001 From: Dmitriy Novash Date: Thu, 9 Jun 2022 19:20:04 +0300 Subject: [PATCH 4/5] more right way to get filename --- src/main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.php b/src/main.php index 53e2cfd..38b706c 100644 --- a/src/main.php +++ b/src/main.php @@ -1141,8 +1141,8 @@ f00bar; $tmp_d = $dir; $tmp_missing_parts = []; while (realpath($tmp_d) === false) { - $tmp_i = pathinfo($tmp_d); - array_push($tmp_missing_parts, $tmp_i['filename']); + $tmp_i = pathinfo($tmp_d, PATHINFO_FILENAME); + array_push($tmp_missing_parts, $tmp_i); $tmp_d = dirname($tmp_d); if ($tmp_d == dirname($tmp_d)) break; From b8bce0617bb57b70dd2466696b03b6664cbd122c Mon Sep 17 00:00:00 2001 From: Dmitriy Novash Date: Thu, 9 Jun 2022 19:26:41 +0300 Subject: [PATCH 5/5] if dir not exist return "invalid path" --- src/main.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.php b/src/main.php index 38b706c..1f75378 100644 --- a/src/main.php +++ b/src/main.php @@ -1153,6 +1153,8 @@ f00bar; return false; elseif ($rpDir == $rpConfig) return true; + elseif (!file_exists($rpDir)) + return false; elseif (0 === strpos($rpDir, $rpConfig)) return true; else