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");
|
|
|
|
}
|
|
|
|
|
2023-10-31 21:57:17 +03:00
|
|
|
|
|
|
|
|
|
|
|
// Checking paths on existence
|
|
|
|
|
|
|
|
function CreateDirIfNotExist ($path) {
|
|
|
|
if (!is_dir($path))
|
|
|
|
mkdir($path, 0755, true);
|
|
|
|
}
|
|
|
|
|
2023-11-03 02:38:51 +03:00
|
|
|
CreateDirIfNotExist("../" . $Config["media"]["pics_path"]); // TODO: treat path as absolute
|
2023-10-31 21:57:17 +03:00
|
|
|
CreateDirIfNotExist("../" . $Config["media"]["prevs_path"]);
|
|
|
|
|
2023-08-12 01:39:17 +03:00
|
|
|
?>
|