From ad69668105c542fa3eb06fce95dbb69740a0fa82 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Wed, 23 Aug 2023 12:06:35 +0200 Subject: [PATCH] Bugfix --- app/Http/Controllers/AdminController.php | 29 +++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 6471a9d..424b026 100755 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -365,15 +365,13 @@ public function SendTestMail(Request $request) //Delete avatar public function delAvatar() { + $path = findFile('avatar'); + $path = base_path('/assets/linkstack/images/'.$path); + // Delete existing image - $directory = base_path('/assets/linkstack/images/'); - $files = scandir($directory); - $pathinfo = "error.error"; - foreach($files as $file) { - if (strpos($file, "avatar".'.') !== false) { - $pathinfo = "avatar". "." . pathinfo($file, PATHINFO_EXTENSION); - }} - if(file_exists(base_path('/assets/linkstack/images/').$pathinfo)){File::delete(base_path('/assets/linkstack/images/').$pathinfo);} + if (File::exists($path)) { + File::delete($path); + } return back(); } @@ -382,14 +380,13 @@ public function SendTestMail(Request $request) public function delFavicon() { // Delete existing image - $directory = base_path('/assets/linkstack/images/'); - $files = scandir($directory); - $pathinfo = "error.error"; - foreach($files as $file) { - if (strpos($file, "favicon".'.') !== false) { - $pathinfo = "favicon". "." . pathinfo($file, PATHINFO_EXTENSION); - }} - if(file_exists(base_path('/assets/linkstack/images/').$pathinfo)){File::delete(base_path('/assets/linkstack/images/').$pathinfo);} + $path = findFile('favicon'); + $path = base_path('/assets/linkstack/images/'.$path); + + // Delete existing image + if (File::exists($path)) { + File::delete($path); + } return back(); }