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
+17 -8
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");
$T4=(T4_COMING==false)? "false":"true";
$LOG_BUILD=(LOG_BUILD==false)? "false":"true";
$LOG_TECH=(LOG_TECH==false)? "false":"true";
@@ -33,7 +42,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%'", $_POST['error'], $text);
$text = preg_replace("'%ERROR%'", $_POST['error'], $text);
@@ -54,7 +63,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
$text = preg_replace("'%TRAPPERCAP%'", $_POST['trappercap'], $text);
$text = preg_replace("'%VILLAGE_EXPAND%'", $_POST['village_expand'], $text);
$text = preg_replace("'%DEMOLISH%'", $_POST['demolish'], $text);
$text = preg_replace("'%STORAGE_MULTIPLIER%'", $_POST['storage_multiplier'], $text);
$text = preg_replace("'%STORAGE_MULTIPLIER%'", $_POST['storage_multiplier'], $text);
$text = preg_replace("'%QUEST%'", $_POST['quest'], $text);
$text = preg_replace("'%QTYPE%'", $_POST['qtype'], $text);
$text = preg_replace("'%BEGINNER%'", $_POST['beginner'], $text);
@@ -76,7 +85,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
$text = preg_replace("'%LOGADMIN%'", $LOG_ADMIN, $text);
$text = preg_replace("'%LOGWAR%'", $LOG_WAR, $text);
$text = preg_replace("'%LOGMARKET%'", $LOG_MARKET, $text);
$text = preg_replace("'%LOGILLEGAL%'", $LOG_ILLEGAL, $text);
$text = preg_replace("'%LOGILLEGAL%'", $LOG_ILLEGAL, $text);
$text = preg_replace("'%BOX1%'", $NEWSBOX1, $text);
$text = preg_replace("'%BOX2%'", $NEWSBOX2, $text);
$text = preg_replace("'%BOX3%'", $NEWSBOX3, $text);
@@ -86,10 +95,10 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
$text = preg_replace("'%SPASS%'", SQL_PASS, $text);
$text = preg_replace("'%SDB%'", SQL_DB, $text);
$text = preg_replace("'%PREFIX%'", TB_PREFIX, $text);
$text = preg_replace("'%CONNECTT%'", DB_TYPE, $text);
$text = preg_replace("'%CONNECTT%'", DB_TYPE, $text);
$text = preg_replace("'%LIMIT_MAILBOX%'", $LIMIT_MAILBOX, $text);
$text = preg_replace("'%MAX_MAILS%'", MAX_MAIL, $text);
$text = preg_replace("'%ARANK%'", $INCLUDE_ADMIN, $text);
$text = preg_replace("'%ARANK%'", $INCLUDE_ADMIN, $text);
$text = preg_replace("'%AEMAIL%'", ADMIN_EMAIL, $text);
$text = preg_replace("'%ASUPPMSGS%'", $SUPPORT_MSGS_IN_ADMIN, $text);
$text = preg_replace("'%ARAIDS%'", $ADMINS_RAIDABLE, $text);
@@ -99,7 +108,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);
@@ -115,7 +124,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);