diff --git a/config/config.php b/config/config.php index f5c7898..997a82d 100644 --- a/config/config.php +++ b/config/config.php @@ -1,7 +1,19 @@ $value) { + if (is_string($value)) { + if ((substr($value, 0, 1) === '"' && substr($value, -1) === '"') || + (substr($value, 0, 1) === "'" && substr($value, -1) === "'")) { + $envVars[$key] = substr($value, 1, -1); + } + } + } +} // Global configuration $GLOBALS['config'] = [ diff --git a/create_ticket_api.php b/create_ticket_api.php index 4684974..2e7bc87 100644 --- a/create_ticket_api.php +++ b/create_ticket_api.php @@ -15,7 +15,7 @@ if (!file_exists($envFile)) { exit; } -$envVars = parse_ini_file($envFile); +$envVars = parse_ini_file($envFile, false, INI_SCANNER_TYPED); if (!$envVars) { echo json_encode([ 'success' => false, @@ -24,6 +24,16 @@ if (!$envVars) { exit; } +// Strip quotes from values if present (parse_ini_file may include them) +foreach ($envVars as $key => $value) { + if (is_string($value)) { + if ((substr($value, 0, 1) === '"' && substr($value, -1) === '"') || + (substr($value, 0, 1) === "'" && substr($value, -1) === "'")) { + $envVars[$key] = substr($value, 1, -1); + } + } +} + // Database connection with detailed error handling $conn = new mysqli( $envVars['DB_HOST'],