]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/BasePath.php
Merge pull request #7000 from MrPetovan/task/6999-no-probe-magic-link
[friendica.git] / src / Util / BasePath.php
index a2849831eb55e8708b2d97fa77cd46b8d2a0cfc8..f29c2e864ec414b7d1219344e4e14d6fd0b622f9 100644 (file)
@@ -17,17 +17,23 @@ class BasePath
         *
         * @throws \Exception if directory isn't usable
         */
-       public static function create($basePath, $server = [])
+       public static function create($basePath, array $server = [])
        {
-               if (!$basePath && !empty($server['DOCUMENT_ROOT'])) {
+               if ((!$basePath || !is_dir($basePath)) && !empty($server['DOCUMENT_ROOT'])) {
                        $basePath = $server['DOCUMENT_ROOT'];
                }
 
-               if (!$basePath && !empty($server['PWD'])) {
+               if ((!$basePath || !is_dir($basePath)) && !empty($server['PWD'])) {
                        $basePath = $server['PWD'];
                }
 
-               return self::getRealPath($basePath);
+               $basePath = self::getRealPath($basePath);
+
+               if (!is_dir($basePath)) {
+                       throw new \Exception(sprintf('\'%s\' is not a valid basepath', $basePath));
+               }
+
+               return $basePath;
        }
 
        /**