Use trim on the file contents and use file_exists

This commit is contained in:
FusionPBX 2023-08-14 21:35:31 -06:00 committed by GitHub
parent 0fb78ee94e
commit 9f004f696e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -33,9 +33,9 @@
}
elseif (file_exists(__DIR__ . '/config.php')) {
//set a custom config_file variable after the config.php has been validated
$file_content = file_get_contents(__DIR__ . '/config.php');
$file_content = trim(file_get_contents(__DIR__ . '/config.php'));
$pattern = '/^<\?php\s+\$config_file\s+=\s+[\'"](.+?)[\'"];\s+\?>$/';
if (preg_match($pattern, $file_content, $matches)) {
if (preg_match($pattern, $file_content, $matches) && file_exists($matches[1])) {
$config_file = $matches[1];
}
}