From 5bae1cfd54b44d6b808f5eb17db7fa8b81dd78d6 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Sat, 28 Oct 2017 00:49:00 +0200 Subject: [PATCH] fix: admin DB prefixes to try and find the unfindable database --- GameEngine/Admin/database.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php index edfd87a3..3daace9c 100755 --- a/GameEngine/Admin/database.php +++ b/GameEngine/Admin/database.php @@ -24,15 +24,25 @@ if (!function_exists('mysqli_result')) { } } -if(isset($gameinstall) && $gameinstall == 1){ -include_once("../../GameEngine/config.php"); -include_once("../../GameEngine/Data/buidata.php"); -}else{ -include_once("../GameEngine/Data/unitdata.php"); -include_once("../GameEngine/Technology.php"); -include_once("../GameEngine/Data/buidata.php"); +// go max 5 levels up - we don't have folders that go deeper than that +$autoprefix = ''; +for ($i = 0; $i < 5; $i++) { + $autoprefix = str_repeat('../', $i); + if (file_exists($autoprefix.'autoloader.php')) { + // we have our path, let's leave + break; + } } -include_once("../GameEngine/Database.php"); + +if(isset($gameinstall) && $gameinstall == 1){ + include_once($autoprefix."GameEngine/config.php"); + include_once($autoprefix."GameEngine/Data/buidata.php"); +}else{ + include_once($autoprefix."GameEngine/Data/unitdata.php"); + include_once($autoprefix."GameEngine/Technology.php"); + include_once($autoprefix."GameEngine/Data/buidata.php"); +} +include_once($autoprefix."GameEngine/Database.php"); class adm_DB { var $connection;