From d6cd52ceded35d0df5cb99a25248b6a44b101413 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Wed, 22 Jul 2020 01:56:12 +0000 Subject: [PATCH] [LIB][Util] Make Common::config return the unserialized value instead of the entity --- src/Util/Common.php | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Util/Common.php b/src/Util/Common.php index f1dd205c10..67b8b51457 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -40,7 +40,7 @@ abstract class Common */ public static function config(string $section, string $setting) { - return DB::find('config', ['section' => $section, 'setting' => $setting]); + return unserialize(DB::find('config', ['section' => $section, 'setting' => $setting])->getValue()); } /** @@ -61,29 +61,32 @@ abstract class Common */ public static function isSystemPath(string $str): bool { - $paths = []; + // TODO Implement + return false; - // All directory and file names in site root should be blacklisted - $d = dir(PUBLICDIR); - while (false !== ($entry = $d->read())) { - $paths[$entry] = true; - } - $d->close(); + // $paths = []; - // All top level names in the router should be blocked - $router = Router::get(); - foreach ($router->m->getPaths() as $path) { - if (preg_match('/^([^\/\?]+)[\/\?]/', $path, $matches) && isset($matches[1])) { - $paths[$matches[1]] = true; - } - } + // // All directory and file names in site root should be blacklisted + // $d = dir(PUBLICDIR); + // while (false !== ($entry = $d->read())) { + // $paths[$entry] = true; + // } + // $d->close(); - // FIXME: this assumes the 'path' is in the first-level directory, though common it's not certain - foreach (['avatar', 'attachments'] as $cat) { - $paths[basename(common_config($cat, 'path'))] = true; - } + // // All top level names in the router should be blocked + // $router = Router::get(); + // foreach ($router->m->getPaths() as $path) { + // if (preg_match('/^([^\/\?]+)[\/\?]/', $path, $matches) && isset($matches[1])) { + // $paths[$matches[1]] = true; + // } + // } - return in_array($str, array_keys($paths)); + // // FIXME: this assumes the 'path' is in the first-level directory, though common it's not certain + // foreach (['avatar', 'attachments'] as $cat) { + // $paths[basename(common_config($cat, 'path'))] = true; + // } + + // return in_array($str, array_keys($paths)); } /**