47 lines
955 B
PHP
47 lines
955 B
PHP
<?php
|
|
// Parsing configuration file
|
|
|
|
|
|
|
|
$Config = array();
|
|
$Config_FileName = "config.json";
|
|
$Config_PossiblePaths = array( // TODO: remake with flag $IS_FRONTEND
|
|
"./" . $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);
|
|
}
|
|
|
|
// Creating dirs at correct path
|
|
if ($IS_FRONTEND) {
|
|
CreateDirIfNotExist($Config["media"]["pics_path"]);
|
|
CreateDirIfNotExist($Config["media"]["prevs_path"]);
|
|
} else {
|
|
CreateDirIfNotExist("../" . $Config["media"]["pics_path"]);
|
|
CreateDirIfNotExist("../" . $Config["media"]["prevs_path"]);
|
|
}
|
|
|
|
?>
|