e949/api/_config.php

37 lines
811 B
PHP
Raw Normal View History

2023-08-19 21:15:47 +03:00
<?php // Parsing configuration file
2023-08-12 01:39:17 +03:00
$Config = array();
$Config_FileName = "config.json";
2023-12-20 06:08:13 +03:00
$Config_PossiblePaths = array( // TODO: remake with flag $IS_FRONTEND
2023-08-12 01:39:17 +03:00
"./" . $Config_FileName,
"../" . $Config_FileName,
"../../" . $Config_FileName,
"../../../" . $Config_FileName,
"./api/" . $Config_FileName,
);
foreach ($Config_PossiblePaths as $path) {
if (file_exists($path)) {
$content = file_get_contents($path);
$Config = json_decode($content, true);
break;
}
}
if (!$Config) {
die("invalid configuration file");
}
// Checking paths on existence
function CreateDirIfNotExist ($path) {
if (!is_dir($path))
mkdir($path, 0755, true);
}
CreateDirIfNotExist("../" . $Config["media"]["pics_path"]); // TODO: treat path as absolute
CreateDirIfNotExist("../" . $Config["media"]["prevs_path"]);
2023-08-12 01:39:17 +03:00
?>