From d1c03f9a1910ad47ffaaf2f331e6adc26f173b42 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Mon, 3 Oct 2022 17:25:03 +0300 Subject: [PATCH] Making env check more strict --- env.inc.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/env.inc.php b/env.inc.php index 5b04592..4d67d6b 100644 --- a/env.inc.php +++ b/env.inc.php @@ -63,12 +63,6 @@ function include_env() global $GAME_ROOT; $env_filename = get_env_file(); - $root_env = get_root_env_name(); - - if($env_filename && !file_exists($env_filename)) - throw new Exception("Error setting environment. No such env file $env_filename"); - else if($env_filename === null && file_exists("$GAME_ROOT/$root_env")) - $env_filename = "$GAME_ROOT/$root_env"; if($env_filename) include($env_filename); @@ -83,13 +77,18 @@ function get_env_file() $env = getenv("GAME_ENV"); if($env) + { $env_filename = "$GAME_ROOT/env/$env.props.php"; - else - $env_filename = "$GAME_ROOT/" . get_root_env_name(); - - if(file_exists($env_filename)) + if(!file_exists($env_filename)) + throw new Exception("No such env file $env_filename"); return $env_filename; - - return null; + } + else + { + $env_filename = "$GAME_ROOT/" . get_root_env_name(); + if(!file_exists($env_filename)) + return null; + return $env_filename; + } }