fix: old version cannot save config data anymore

This commit is contained in:
Martin Ambrus
2017-11-22 12:20:05 +01:00
parent 268131e024
commit 30fc76e85b
6 changed files with 93 additions and 39 deletions
+13 -4
View File
@@ -14,9 +14,18 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
if (file_exists('constant_format.tpl')) {
die(
'You seem to be running a new version of TravianZ which was installed using an old installer.<br />' .
'Please download <strong>constant_format.tpl</strong> file and copy it into the <strong>GameEngine/Admin/Mods</strong> ' .
'directory - otherwise saving configuration won\'t work.<br /><br />' .
'The constant_format.tpl file can be downloaded at ' .
'<strong>https://raw.githubusercontent.com/Shadowss/TravianZ/master/install/data/constant_format.tpl</strong>');
}
$myFile = "../../config.php";
$fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\config.php");
$ERRORREPORT=ERROR_REPORT;
$T4=(T4_COMING==false)? "false":"true";
$GP_ENABLE=(GP_ENABLE==false)? "false":"true";
@@ -38,7 +47,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
$INCLUDE_ADMIN=(INCLUDE_ADMIN==false)? "false":"true";
$SUPPORT_MSGS_IN_ADMIN = (ADMIN_RECEIVE_SUPPORT_MESSAGES == false ? 'false' : 'true');
$ADMINS_RAIDABLE = (ADMIN_ALLOW_INCOMING_RAIDS == false ? 'false' : 'true');
$text = file_get_contents("constant_format.tpl");
$text = preg_replace("'%ERRORREPORT%'", ERROR_REPORT, $text);
$text = preg_replace("'%ERROR%'", ERROR_REPORT, $text);
@@ -104,7 +113,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
$text = preg_replace("'%DOMAIN%'", DOMAIN, $text);
$text = preg_replace("'%HOMEPAGE%'", HOMEPAGE, $text);
$text = preg_replace("'%SERVER%'", SERVER, $text);
// PLUS settings need to be kept intact
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
$text = preg_replace("'%PLUS_PRODUCTION%'", PLUS_PRODUCTION, $text);
@@ -120,7 +129,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
$text = preg_replace("'%PLUS_PACKAGE_D_GOLD%'", (defined('PLUS_PACKAGE_D_GOLD') ? PLUS_PACKAGE_D_GOLD : '1000'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_PRICE%'", (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_GOLD%'", (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'), $text);
fwrite($fh, $text);
fclose($fh);