feat: MySQL port into installation options

Closes #279
This commit is contained in:
Martin Ambrus
2017-11-07 12:30:32 +01:00
parent a6d14c6b6d
commit 312507fe9f
14 changed files with 168 additions and 109 deletions
+6 -2
View File
@@ -54,7 +54,7 @@ define("SPEED", "%SPEED%");
define("WORLD_MAX", "%MAX%");
// ***** Graphic Pack
// True = enabled, false = disabled
// true = enabled, false = disabled
//!!!!!!!!!!!! DO NOT ENABLE !!!!!!!!!!!!
define("GP_ENABLE",false);
// Graphic pack location (default: gpack/travian_default/)
@@ -213,11 +213,15 @@ define("NEWSBOX3",%BOX3%);
//////////////////////////////////
// ***** SQL Hostname
// example. sql106.000space.com / localhost
// example: sql106.000space.com / localhost
// If you host server on own PC than this value is: localhost
// If you use online hosting, value must be written in host cpanel
define("SQL_SERVER", "%SSERVER%");
// ***** SQL Port
// default: 3306
define("SQL_PORT", %SPORT%);
// ***** Database Username
define("SQL_USER", "%SUSER%");
+104 -88
View File
@@ -32,104 +32,120 @@ class Process {
}
private function constForm() {
$myFile = "../GameEngine/config.php";
$fh = @fopen($myFile, 'w') or die("<br/><br/><br/>Can't create or update file: GameEngine\config.php");
$configFile = "../GameEngine/config.php";
$configTemplateFile = "../GameEngine/Admin/Mods/constant_format.tpl";
$gameConfig = @fopen($configFile, 'w') or die("<br/><br/><br/>Can't create or update file: GameEngine\config.php");
// copy the contents of the config template file into a new location, used when editing
// game configuration from the in-game Admin (since the install folder would be deleted at that point)
$templateFile = @fopen($configTemplateFile, 'w') or die("<br/><br/><br/>Can't create or update file: GameEngine\Admin\Mods\constant_format.tpl");
fclose($templateFile);
$text = file_get_contents("data/constant_format.tpl");
$text = preg_replace("'%SERVERNAME%'", $_POST['servername'], $text);
$text = preg_replace("'%SSTARTDATE%'", $_POST['start_date'], $text);
$text = preg_replace("'%SSTARTTIME%'", $_POST['start_time'], $text);
// make template copy
file_put_contents($configTemplateFile, $text);
// continue with text replacements
$findReplace = [];
$findReplace["%SERVERNAME%"] = $_POST['servername'];
$findReplace["%SSTARTDATE%"] = $_POST['start_date'];
$findReplace["%SSTARTTIME%"] = $_POST['start_time'];
$tz = explode(",",$_POST['tzone']);
$text = preg_replace("'%STIMEZONE%'", $tz[1], $text);
$text = preg_replace("'%LANG%'", $_POST['lang'], $text);
$text = preg_replace("'%SPEED%'", $_POST['speed'], $text);
$text = preg_replace("'%INCSPEED%'", $_POST['incspeed'], $text);
$text = preg_replace("'%EVASIONSPEED%'", $_POST['evasionspeed'], $text);
$text = preg_replace("'%TRADERCAP%'", $_POST['tradercap'], $text);
$text = preg_replace("'%CRANNYCAP%'", $_POST['crannycap'], $text);
$text = preg_replace("'%TRAPPERCAP%'", $_POST['trappercap'], $text);
$text = preg_replace("'%STORAGE_MULTIPLIER%'", $_POST['storage_multiplier'], $text);
//$text = preg_replace("'%UTRACK%'", $_POST['trackusers'], $text);
//$text = preg_replace("'%UTOUT%'", $_POST['timeout'], $text);
//$text = preg_replace("'%AUTOD%'", $_POST['autodel'], $text);
//$text = preg_replace("'%AUTODT%'", $_POST['autodeltime'], $text);
$text = preg_replace("'%MAX%'", $_POST['wmax'], $text);
//$text = preg_replace("'%GP%'", $_POST['gpack'], $text);
$text = preg_replace("'%SSERVER%'", $_POST['sserver'], $text);
$text = preg_replace("'%SUSER%'", $_POST['suser'], $text);
$text = preg_replace("'%SPASS%'", $_POST['spass'], $text);
$text = preg_replace("'%SDB%'", $_POST['sdb'], $text);
$text = preg_replace("'%PREFIX%'", $_POST['prefix'], $text);
$text = preg_replace("'%CONNECTT%'", $_POST['connectt'], $text);
$text = preg_replace("'%AEMAIL%'", $_POST['aemail'], $text);
$text = preg_replace("'%ANAME%'", $_POST['aname'], $text);
$text = preg_replace("'%ASUPPMSGS%'", ($_POST['admin_support_msgs'] == 'True' ? 'true' : 'false'), $text);
$text = preg_replace("'%ARAIDS%'", ($_POST['admin_raidable'] == 'True' ? 'true' : 'false'), $text);
//$text = preg_replace("'%SUBDOM%'", $_POST['subdom'], $text);
$text = preg_replace("'%LOGBUILD%'", $_POST['log_build'], $text);
$text = preg_replace("'%LOGTECH%'", $_POST['log_tech'], $text);
$text = preg_replace("'%LOGLOGIN%'", $_POST['log_login'], $text);
$text = preg_replace("'%LOGGOLDFIN%'", $_POST['log_gold_fin'], $text);
$text = preg_replace("'%LOGADMIN%'", $_POST['log_admin'], $text);
$text = preg_replace("'%LOGWAR%'", $_POST['log_war'], $text);
$text = preg_replace("'%LOGMARKET%'", $_POST['log_market'], $text);
$text = preg_replace("'%LOGILLEGAL%'", $_POST['log_illegal'], $text);
//$text = preg_replace("'%MINUSERLENGTH%'", $_POST['userlength'], $text);
//$text = preg_replace("'%MINPASSLENGTH%'", $_POST['passlength'], $text);
//$text = preg_replace("'%SPECIALCHARS%'", $_POST['specialchars'], $text);
$text = preg_replace("'%ACTIVATE%'", $_POST['activate'], $text);
$text = preg_replace("'%ARANK%'", $_POST['admin_rank'], $text);
$text = preg_replace("'%QUEST%'", $_POST['quest'], $text);
$text = preg_replace("'%QTYPE%'", $_POST['qtype'], $text);
$text = preg_replace("'%BEGINNER%'", $_POST['beginner'], $text);
$text = preg_replace("'%STARTTIME%'", time(), $text);
$text = preg_replace("'%DOMAIN%'", $_POST['domain'], $text);
$text = preg_replace("'%HOMEPAGE%'", $_POST['homepage'], $text);
$text = preg_replace("'%SERVER%'", $_POST['server'], $text);
$text = preg_replace("'%LIMIT_MAILBOX%'", $_POST['limit_mailbox'], $text);
$text = preg_replace("'%MAX_MAILS%'", $_POST['max_mails'], $text);
$text = preg_replace("'%DEMOLISH%'", $_POST['demolish'], $text);
$text = preg_replace("'%BOX1%'", $_POST['box1'], $text);
$text = preg_replace("'%BOX2%'", $_POST['box2'], $text);
$text = preg_replace("'%BOX3%'", $_POST['box3'], $text);
$text = preg_replace("'%VILLAGE_EXPAND%'", $_POST['village_expand'], $text);
$text = preg_replace("'%ERRORREPORT%'", $_POST['error'], $text);
$text = preg_replace("'%ERROR%'", $_POST['error'], $text);
//$text = preg_replace("'%GP_LOCATE%'", $_POST['gp_locate'], $text);
$text = preg_replace("'%PLUS_TIME%'", $_POST['plus_time'], $text);
$text = preg_replace("'%PLUS_PRODUCTION%'", $_POST['plus_production'], $text);
$text = preg_replace("'%PAYPAL_EMAIL%'", $_POST['paypal-email'], $text);
$text = preg_replace("'%PAYPAL_CURRENCY%'", $_POST['paypal-currency'], $text);
$text = preg_replace("'%PLUS_PACKAGE_A_GOLD%'", $_POST['plus-a-gold'], $text);
$text = preg_replace("'%PLUS_PACKAGE_A_PRICE%'", $_POST['plus-a-price'], $text);
$text = preg_replace("'%PLUS_PACKAGE_B_GOLD%'", $_POST['plus-b-gold'], $text);
$text = preg_replace("'%PLUS_PACKAGE_B_PRICE%'", $_POST['plus-b-price'], $text);
$text = preg_replace("'%PLUS_PACKAGE_C_GOLD%'", $_POST['plus-c-gold'], $text);
$text = preg_replace("'%PLUS_PACKAGE_C_PRICE%'", $_POST['plus-c-price'], $text);
$text = preg_replace("'%PLUS_PACKAGE_D_GOLD%'", $_POST['plus-d-gold'], $text);
$text = preg_replace("'%PLUS_PACKAGE_D_PRICE%'", $_POST['plus-d-price'], $text);
$text = preg_replace("'%PLUS_PACKAGE_E_GOLD%'", $_POST['plus-e-gold'], $text);
$text = preg_replace("'%PLUS_PACKAGE_E_PRICE%'", $_POST['plus-e-price'], $text);
$text = preg_replace("'%MEDALINTERVAL%'", $_POST['medalinterval'], $text);
$text = preg_replace("'%GREAT_WKS%'", $_POST['great_wks'], $text);
$text = preg_replace("'%TS_THRESHOLD%'", $_POST['ts_threshold'], $text);
$text = preg_replace("'%WW%'", $_POST['ww'], $text);
$text = preg_replace("'%SHOW_NATARS%'", $_POST['show_natars'], $text);
$text = preg_replace("'%NATARS_UNITS%'", $_POST['natars_units'], $text);
$text = preg_replace("'%NATURE_REGTIME%'", $_POST['nature_regtime'], $text);
$text = preg_replace("'%T4_COMING%'", $_POST['t4_coming'], $text);
$text = preg_replace("'%REG_OPEN%'", $_POST['reg_open'], $text);
$text = preg_replace("'%PEACE%'", $_POST['peace'], $text);
$findReplace["%STIMEZONE%"] = $tz[1];
$findReplace["%LANG%"] = $_POST['lang'];
$findReplace["%SPEED%"] = $_POST['speed'];
$findReplace["%INCSPEED%"] = $_POST['incspeed'];
$findReplace["%EVASIONSPEED%"] = $_POST['evasionspeed'];
$findReplace["%TRADERCAP%"] = $_POST['tradercap'];
$findReplace["%CRANNYCAP%"] = $_POST['crannycap'];
$findReplace["%TRAPPERCAP%"] = $_POST['trappercap'];
$findReplace["%STORAGE_MULTIPLIER%"] = $_POST['storage_multiplier'];
//$findReplace["%UTRACK%"] = $_POST['trackusers'];
//$findReplace["%UTOUT%"] = $_POST['timeout'];
//$findReplace["%AUTOD%"] = $_POST['autodel'];
//$findReplace["%AUTODT%"] = $_POST['autodeltime'];
$findReplace["%MAX%"] = $_POST['wmax'];
//$findReplace["%GP%"] = $_POST['gpack'];
$findReplace["%SSERVER%"] = $_POST['sserver'];
$findReplace["%SPORT%"] = $_POST['sport'];
$findReplace["%SUSER%"] = $_POST['suser'];
$findReplace["%SPASS%"] = $_POST['spass'];
$findReplace["%SDB%"] = $_POST['sdb'];
$findReplace["%PREFIX%"] = $_POST['prefix'];
$findReplace["%CONNECTT%"] = $_POST['connectt'];
$findReplace["%AEMAIL%"] = $_POST['aemail'];
$findReplace["%ANAME%"] = $_POST['aname'];
$findReplace["%ASUPPMSGS%"] = ($_POST['admin_support_msgs'] == 'true' ? 'true' : 'false');
$findReplace["%ARAIDS%"] = ($_POST['admin_raidable'] == 'true' ? 'true' : 'false');
//$findReplace["%SUBDOM%"] = $_POST['subdom'];
$findReplace["%LOGBUILD%"] = $_POST['log_build'];
$findReplace["%LOGTECH%"] = $_POST['log_tech'];
$findReplace["%LOGLOGIN%"] = $_POST['log_login'];
$findReplace["%LOGGOLDFIN%"] = $_POST['log_gold_fin'];
$findReplace["%LOGADMIN%"] = $_POST['log_admin'];
$findReplace["%LOGWAR%"] = $_POST['log_war'];
$findReplace["%LOGMARKET%"] = $_POST['log_market'];
$findReplace["%LOGILLEGAL%"] = $_POST['log_illegal'];
//$findReplace["%MINUSERLENGTH%"] = $_POST['userlength'];
//$findReplace["%MINPASSLENGTH%"] = $_POST['passlength'];
//$findReplace["%SPECIALCHARS%"] = $_POST['specialchars'];
$findReplace["%ACTIVATE%"] = $_POST['activate'];
$findReplace["%ARANK%"] = $_POST['admin_rank'];
$findReplace["%QUEST%"] = $_POST['quest'];
$findReplace["%QTYPE%"] = $_POST['qtype'];
$findReplace["%BEGINNER%"] = $_POST['beginner'];
$findReplace["%STARTTIME%"] = time();
$findReplace["%DOMAIN%"] = $_POST['domain'];
$findReplace["%HOMEPAGE%"] = $_POST['homepage'];
$findReplace["%SERVER%"] = $_POST['server'];
$findReplace["%LIMIT_MAILBOX%"] = $_POST['limit_mailbox'];
$findReplace["%MAX_MAILS%"] = $_POST['max_mails'];
$findReplace["%DEMOLISH%"] = $_POST['demolish'];
$findReplace["%BOX1%"] = $_POST['box1'];
$findReplace["%BOX2%"] = $_POST['box2'];
$findReplace["%BOX3%"] = $_POST['box3'];
$findReplace["%VILLAGE_EXPAND%"] = $_POST['village_expand'];
$findReplace["%ERRORREPORT%"] = $_POST['error'];
$findReplace["%ERROR%"] = $_POST['error'];
//$findReplace["%GP_LOCATE%"] = $_POST['gp_locate'];
$findReplace["%PLUS_TIME%"] = $_POST['plus_time'];
$findReplace["%PLUS_PRODUCTION%"] = $_POST['plus_production'];
$findReplace["%PAYPAL_EMAIL%"] = $_POST['paypal-email'];
$findReplace["%PAYPAL_CURRENCY%"] = $_POST['paypal-currency'];
$findReplace["%PLUS_PACKAGE_A_GOLD%"] = $_POST['plus-a-gold'];
$findReplace["%PLUS_PACKAGE_A_PRICE%"] = $_POST['plus-a-price'];
$findReplace["%PLUS_PACKAGE_B_GOLD%"] = $_POST['plus-b-gold'];
$findReplace["%PLUS_PACKAGE_B_PRICE%"] = $_POST['plus-b-price'];
$findReplace["%PLUS_PACKAGE_C_GOLD%"] = $_POST['plus-c-gold'];
$findReplace["%PLUS_PACKAGE_C_PRICE%"] = $_POST['plus-c-price'];
$findReplace["%PLUS_PACKAGE_D_GOLD%"] = $_POST['plus-d-gold'];
$findReplace["%PLUS_PACKAGE_D_PRICE%"] = $_POST['plus-d-price'];
$findReplace["%PLUS_PACKAGE_E_GOLD%"] = $_POST['plus-e-gold'];
$findReplace["%PLUS_PACKAGE_E_PRICE%"] = $_POST['plus-e-price'];
$findReplace["%MEDALINTERVAL%"] = $_POST['medalinterval'];
$findReplace["%GREAT_WKS%"] = $_POST['great_wks'];
$findReplace["%TS_THRESHOLD%"] = $_POST['ts_threshold'];
$findReplace["%WW%"] = $_POST['ww'];
$findReplace["%SHOW_NATARS%"] = $_POST['show_natars'];
$findReplace["%NATARS_UNITS%"] = $_POST['natars_units'];
$findReplace["%NATURE_REGTIME%"] = $_POST['nature_regtime'];
$findReplace["%T4_COMING%"] = $_POST['t4_coming'];
$findReplace["%REG_OPEN%"] = $_POST['reg_open'];
$findReplace["%PEACE%"] = $_POST['peace'];
fwrite($fh, $text);
fwrite($gameConfig, str_replace(array_keys($findReplace), array_values($findReplace), $text));
if(file_exists("../GameEngine/config.php")) {
if (file_exists($configFile) && file_exists($configTemplateFile)) {
header("Location: index.php?s=2");
} else {
header("Location: index.php?s=1&c=1");
}
fclose($fh);
fclose($gameConfig);
}
/**
+18 -14
View File
@@ -118,8 +118,8 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">Register Open:</span></td>
<td>
<select name="reg_open">
<option value="True" selected="selected">True</option>
<option value="False">False</option>
<option value="true" selected="selected">true</option>
<option value="false">false</option>
</select>
</td>
</tr>
@@ -202,8 +202,8 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">Great Workshop:</span></td>
<td>
<select name="great_wks">
<option value="True">True</option>
<option value="False" selected="selected">False</option>
<option value="true">true</option>
<option value="false" selected="selected">false</option>
</select>
</td>
</tr>
@@ -211,8 +211,8 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">ww:</span></td>
<td>
<select name="ww">
<option value="True">True</option>
<option value="False" selected="selected">False</option>
<option value="true">true</option>
<option value="false" selected="selected">false</option>
</select>
</td>
</tr>
@@ -220,8 +220,8 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">Show Natars in Statistics:</span></td>
<td>
<select name="show_natars">
<option value="True">True</option>
<option value="False" selected="selected">False</option>
<option value="true">true</option>
<option value="false" selected="selected">false</option>
</select>
</td>
</tr>
@@ -255,8 +255,8 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">Show admin in stats:</span></td>
<td>
<select name="admin_rank">
<option value="True">True</option>
<option value="False" selected="selected">False</option>
<option value="true">true</option>
<option value="false" selected="selected">false</option>
</select>
</td>
</tr>
@@ -264,8 +264,8 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">Include Support Messages in Admin Mailbox:</span></td>
<td>
<select name="admin_support_msgs">
<option value="True" selected="selected">True</option>
<option value="False">False</option>
<option value="true" selected="selected">true</option>
<option value="false">false</option>
</select>
</td>
</tr>
@@ -273,8 +273,8 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">Allow Administrative Accounts to be Raided and Attacked:</span></td>
<td>
<select name="admin_raidable">
<option value="True" selected="selected">True</option>
<option value="False">False</option>
<option value="true" selected="selected">true</option>
<option value="false">false</option>
</select>
</td>
</tr>
@@ -287,6 +287,10 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
<td><span class="f9 c6">Hostname:</span></td>
<td><input name="sserver" type="text" id="sserver" value="localhost"></td>
</tr>
<tr>
<td><span class="f9 c6">Port:</span></td>
<td><input name="sport" type="text" id="sport" value="3306"></td>
</tr>
<tr>
<td><span class="f9 c6">Username:</span></td>
<td><input name="suser" type="text" id="suser" value=""></td>
+3 -3
View File
@@ -49,9 +49,9 @@ touch('../var/installed');
</br>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="LWVKB9LSJNL3C">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="hosted_button_id" value="QHUTVY5MLECFQ">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
</center>
</div>