2024-01-13 03:24:42 +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);
|
|
|
|
}
|
|
|
|
|
2024-01-13 03:24:42 +03:00
|
|
|
// Creating dirs at correct path
|
2024-01-20 20:05:45 +03:00
|
|
|
if (isset($IS_FRONTEND) && $IS_FRONTEND) {
|
2024-01-13 03:24:42 +03:00
|
|
|
CreateDirIfNotExist($Config["media"]["pics_path"]);
|
|
|
|
CreateDirIfNotExist($Config["media"]["prevs_path"]);
|
|
|
|
} else {
|
|
|
|
CreateDirIfNotExist("../" . $Config["media"]["pics_path"]);
|
|
|
|
CreateDirIfNotExist("../" . $Config["media"]["prevs_path"]);
|
|
|
|
}
|
2023-10-31 21:57:17 +03:00
|
|
|
|
2024-01-13 03:24:42 +03:00
|
|
|
?>
|