[LIB][Util] Make Common::config return the unserialized value instead of the entity

This commit is contained in:
Hugo Sales 2020-07-22 01:56:12 +00:00 committed by Hugo Sales
parent 284fbe2c5b
commit d6cd52cede
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
1 changed files with 23 additions and 20 deletions

View File

@ -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));
}
/**