From 0519a59f8a8dbe66aae22e100b8e14b37f84c99b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 27 Apr 2019 00:13:26 +0200 Subject: [PATCH] Use global namespace --- Admin/Routes/Web/Api.php | 11 ----------- Models/UploadFile.php | 4 ++-- Views/MediaView.php | 4 ++-- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index 23f67de..57ae8c3 100644 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -22,17 +22,6 @@ return [ ], ], ], - '^.*/media/create.*$' => [ - [ - 'dest' => '\Modules\Media\Controller\ApiController:apiMediaCreate', - 'verb' => RouteVerb::SET, - 'permission' => [ - 'module' => ApiController::MODULE_NAME, - 'type' => PermissionType::CREATE, - 'state' => PermissionState::MEDIA, - ], - ], - ], // todo: the order of find is bad but needed for now. '^.*/media/find.*$' => [ [ diff --git a/Models/UploadFile.php b/Models/UploadFile.php index d7ec169..4e98b84 100644 --- a/Models/UploadFile.php +++ b/Models/UploadFile.php @@ -135,7 +135,7 @@ class UploadFile } // TODO: do I need pecl fileinfo? - if (!empty($this->allowedTypes) && ($ext = array_search($f['type'], $this->allowedTypes, true)) === false) { + if (!empty($this->allowedTypes) && ($ext = \array_search($f['type'], $this->allowedTypes, true)) === false) { $result[$key]['status'] = UploadStatus::WRONG_EXTENSION; return $result; @@ -282,7 +282,7 @@ class UploadFile private function findOutputDir(array $files) : string { do { - $rndPath = \str_pad(\dechex(rand(0, 65535)), 4, '0', STR_PAD_LEFT); + $rndPath = \str_pad(\dechex(\rand(0, 65535)), 4, '0', STR_PAD_LEFT); } while (\file_exists($this->outputDir . '/' . $rndPath)); return $this->outputDir . '/' . $rndPath; diff --git a/Views/MediaView.php b/Views/MediaView.php index dc80d69..0b5e890 100644 --- a/Views/MediaView.php +++ b/Views/MediaView.php @@ -34,7 +34,7 @@ class MediaView extends View { protected function filePathFunction(Media $media, string $sub) : string { - if (is_file($media->getPath() . $sub) + if (\is_file($media->getPath() . $sub) && StringUtils::startsWith( \str_replace('\\', '/', \realpath($media->getPath() . $sub)), $media->getPath() @@ -74,7 +74,7 @@ class MediaView extends View $output = \file_get_contents($path); $output = \str_replace(["\r\n", "\r"], "\n", $output); - return explode("\n", $output); + return \explode("\n", $output); } protected function isImageFunction(Media $media, string $path) : bool