Refactor chdir() call

This commit is contained in:
Art4 2024-12-26 09:05:50 +00:00
parent 38ad97f24f
commit 0cd2b8e2c0

View file

@ -33,16 +33,7 @@ $longopts = ['foreground'];
$options = getopt($shortopts, $longopts); $options = getopt($shortopts, $longopts);
// Ensure that daemon.php is executed from the base path of the installation // Ensure that daemon.php is executed from the base path of the installation
if (!file_exists('index.php') && (sizeof($_SERVER['argv']) != 0)) { chdir(dirname(__DIR__));
$directory = dirname($_SERVER['argv'][0]);
if (substr($directory, 0, 1) != '/') {
$directory = $_SERVER['PWD'] . '/' . $directory;
}
$directory = realpath($directory . '/..');
chdir($directory);
}
require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/autoload.php';