function Load_Configs() { chdir(dirname(__FILE__) . "/.."); // chdir(".."); // echo "CWD: ".getcwd()."<BR>"; $config_database_file_path = "config/config_database.php"; $config_settings_file_path = "config/config_settings.php"; $copy_stx = array_key_exists('copy_stx', $_POST) ? $_POST['copy_stx'] : NULL; $read_config_database_ok = read_ini_file($config_database_file_path, $GLOBALS['config_db']); if ($read_config_database_ok === 1) { //$config_success .= "DATABASE CONFIG READ OK<BR>"; // Create abbreviated variables for cleaner & easier code // 'config_db's variable names are generated by the config files, which are intended to be easy for the end user to understand $GLOBALS['db']['s_host'] = $GLOBALS['config_db']['db_source']['host']; $GLOBALS['db']['s_base'] = $GLOBALS['config_db']['db_source']['base']; $GLOBALS['db']['s_user'] = $GLOBALS['config_db']['db_source']['user']; $GLOBALS['db']['s_pass'] = $GLOBALS['config_db']['db_source']['pass']; $GLOBALS['db']['s_prefix'] = $GLOBALS['config_db']['db_source']['prefix']; $GLOBALS['db']['table_players'] = "`" . DB_Type_PlayersTable($GLOBALS['config_db']['db_config']['db_module_type']) . "`"; $GLOBALS['db']['x_host'] = $GLOBALS['config_db']['db_xray']['host']; $GLOBALS['db']['x_base'] = $GLOBALS['config_db']['db_xray']['base']; $GLOBALS['db']['x_user'] = $GLOBALS['config_db']['db_xray']['user']; $GLOBALS['db']['x_pass'] = $GLOBALS['config_db']['db_xray']['pass']; $GLOBALS['db']['x_prefix'] = $GLOBALS['config_db']['db_xray']['prefix']; $GLOBALS['db']['same'] = FixInput_Bool($GLOBALS['config_db']['db_config']['db_use_same']); $GLOBALS['db']['type'] = $GLOBALS['config_db']['db_config']['db_module_type']; $GLOBALS['db']['players'] = $GLOBALS['db']['s_prefix'] . DB_Type_PlayersTable($GLOBALS['db']['type']); } else { $show_process = true; echo "ERROR: Could not load database config file.<BR>({$config_database_file_path})<BR>"; } $read_config_settings_ok = read_ini_file($config_settings_file_path, $GLOBALS['config_settings']); $GLOBALS['config'] = $GLOBALS['config_settings']; if ($read_config_settings_ok === 1) { $GLOBALS['config']['settings']['first_setup'] = FixOutput_Bool($GLOBALS['config_settings']['settings']['first_setup'], true, false, true); } else { $show_process = true; echo "ERROR: Could not load settings config file.<BR>({$config_settings_file_path})<BR>"; } $db1_ok = Check_DB_Exists(true, $GLOBALS['db']['type'], $GLOBALS['db']['s_host'], $GLOBALS['db']['s_base'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass'], $GLOBALS['db']['s_prefix']); if (!$db1_ok) { echo "ERROR: There was an error validating the Source Database: [" . $GLOBALS['db']['s_base'] . "]<BR>"; } if ($copy_stx) { $db2_ok = Check_DB_Exists(false, "", $GLOBALS['db']['x_host'], $GLOBALS['db']['x_base'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass'], $GLOBALS['db']['x_prefix']); if (!$db2_ok) { echo "ERROR: There was an error validating the X-Ray Database: [" . $GLOBALS['db']['x_base'] . "]<BR>"; } } else { $db2_ok = $db1_ok; $GLOBALS['db']['x_host'] = $GLOBALS['db']['s_host']; $GLOBALS['db']['x_base'] = $GLOBALS['db']['s_base']; $GLOBALS['db']['x_user'] = $GLOBALS['db']['s_user']; $GLOBALS['db']['x_pass'] = $GLOBALS['db']['s_pass']; $GLOBALS['db']['x_prefix'] = $GLOBALS['db']['s_prefix']; } return $read_config_database_ok && $read_config_settings_ok && $db1_ok && $db2_ok; }
$_SESSION['first_setup'] = FixOutput_Bool($GLOBALS['config_settings']['settings']['first_setup'], true, false, true); //echo "FIRST SETUP: " . FixOutput_Bool($_SESSION['first_setup'], "YES", "NO", "UNDEFINED") . "<BR>"; // Only users who have been authenticated by IP can use the setup script if ($_SESSION['auth_type'] != "ip") { $_SESSION['auth_is_valid'] = false; $config_error['message'] .= "ERROR: Your IP is not on the Failsafe IPs list.<BR>You cannot use the Setup script until you add your IP to that list.<BR><BR>(You must manually edit: <em>config_settings.php</em>)<BR><BR>Your current IP is: [" . $_SERVER['REMOTE_ADDR'] . "]<BR>"; $config_error['canceltext'] = "Try Again"; $config_error['URL'] = "setup.php"; } if ($_POST['form'] != "") { $setup_submit_ok = false; if (isset($_POST['config_db_submit']) && $_POST['config_db_submit'] != "") { $setup_stage_tab = 0; $db1_ok = Check_DB_Exists(true, $_POST['db_type'], $_POST['db_source_host'], $_POST['db_source_base'], $_POST['db_source_user'], $_POST['db_source_pass'], $_POST['db_source_prefix']); if (!$_POST['copy_stx']) { $db2_ok = Check_DB_Exists(false, "", $_POST['db_xray_host'], $_POST['db_xray_base'], $_POST['db_xray_user'], $_POST['db_xray_pass'], $_POST['db_xray_prefix']); } else { $db2_ok = $db1_ok; $_POST['db_xray_host'] = $_POST['db_source_host']; $_POST['db_xray_base'] = $_POST['db_source_base']; $_POST['db_xray_user'] = $_POST['db_source_user']; $_POST['db_xray_pass'] = $_POST['db_source_pass']; $_POST['db_xray_prefix'] = $_POST['db_source_prefix']; } if ($db1_ok && $db2_ok) { $GLOBALS['config_db']['db_config']['db_module_type'] = $_POST['db_type']; $GLOBALS['config_db']['db_config']['db_use_same'] = FixOutput_Bool($_POST['copy_stx'], "yes", "no"); $GLOBALS['config_db']['db_source']['host'] = $_POST['db_source_host']; $GLOBALS['config_db']['db_source']['base'] = $_POST['db_source_base']; $GLOBALS['config_db']['db_source']['user'] = $_POST['db_source_user']; $GLOBALS['config_db']['db_source']['pass'] = $_POST['db_source_pass'];
function SQL_DB_OK($choose) { //echo "GLOBALS['db_config']['db_$choose']['host']: " . $GLOBALS['config_db']['db_' . $choose]['host'] . "<BR>"; return Check_DB_Exists($choose == "source", $GLOBALS['db']['type'], $GLOBALS['config_db']['db_' . $choose]['host'], $GLOBALS['config_db']['db_' . $choose]['base'], $GLOBALS['config_db']['db_' . $choose]['user'], $GLOBALS['config_db']['db_' . $choose]['pass'], $GLOBALS['config_db']['db_' . $choose]['prefix']); }