mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-13 23:01:02 +00:00
Fallback fix server
Fallback fix server
This commit is contained in:
@@ -340,89 +340,82 @@ if (!function_exists('admin_config_template_path')) {
|
|||||||
$text = str_replace($placeholder, (string) $value, $text);
|
$text = str_replace($placeholder, (string) $value, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* PLASA DE SIGURANTA: orice placeholder ramas se rezolva din constanta
|
return $text;
|
||||||
* pe care o defineste chiar linia lui.
|
}
|
||||||
*
|
}
|
||||||
* De ce e nevoie: fiecare pagina din panou regenereaza INTREG config.php
|
|
||||||
* din acelasi sablon, dar rezolva doar setarile ei. O setare noua,
|
if (!function_exists('tz_config_finalize')) {
|
||||||
* tratata de un singur modul, ramanea literala cand salvai din alta
|
|
||||||
* pagina:
|
/**
|
||||||
* define("NEW_FUNCTIONS_ALLIANCE_BONUSES", %ALLIANCEBONUSES%);
|
* Ultima verificare inainte de a scrie config.php.
|
||||||
* adica eroare de parsare si 500 pe tot serverul, pana la reparare
|
*
|
||||||
* manuala a fisierului. Ni s-a intamplat de trei ori: %GP%,
|
* TREBUIE apelata DUPA toate apelurile de tz_config_set() si INAINTE de
|
||||||
* %ALLIANCEBONUSES% si %NATARS_WW_START_DELAY%.
|
* fwrite(). Rezolva orice placeholder ramas, din constanta pe care o
|
||||||
*
|
* defineste chiar linia lui.
|
||||||
* Listele de mai sus raman - sunt explicite si mai lizibile. Blocul asta
|
*
|
||||||
* prinde ce scapa, ca urmatoarea setare adaugata sa nu mai poata sparge
|
* DE CE AICI si nu in admin_config_template_contents():
|
||||||
* serverul. Ruleaza ULTIMUL, deci nu suprascrie nimic rezolvat inainte.
|
* acea functie ruleaza la INCEPUT, inainte ca modulul sa-si scrie valorile.
|
||||||
*/
|
* Daca plasa ar rula acolo, ar consuma placeholderele din valorile CURENTE,
|
||||||
if (preg_match_all('/^\s*define\(\s*["\']([A-Z0-9_]+)["\']\s*,\s*(.*?%[A-Z0-9_]+%.*?)\s*\)\s*;/m',
|
* iar tz_config_set() n-ar mai avea ce inlocui - adica orice modificare
|
||||||
|
* facuta de admin ar fi ignorata in tacere. Exact asta s-a intamplat.
|
||||||
|
*
|
||||||
|
* De ce e nevoie de ea: fiecare pagina din panou regenereaza INTREG
|
||||||
|
* config.php din acelasi sablon, dar rezolva doar setarile ei. O setare
|
||||||
|
* tratata de un singur modul ramanea literala cand salvai din alta pagina:
|
||||||
|
* define("NEW_FUNCTIONS_ALLIANCE_BONUSES", %ALLIANCEBONUSES%);
|
||||||
|
* adica eroare de parsare si 500 pe tot serverul.
|
||||||
|
*/
|
||||||
|
function tz_config_finalize($text)
|
||||||
|
{
|
||||||
|
if (!preg_match_all('/^\s*define\(\s*["\']([A-Z0-9_]+)["\']\s*,\s*(.*?%[A-Z0-9_]+%.*?)\s*\)\s*;/m',
|
||||||
$text, $leftovers, PREG_SET_ORDER)) {
|
$text, $leftovers, PREG_SET_ORDER)) {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($leftovers as $row) {
|
$defaults = array(
|
||||||
$constant = $row[1];
|
'NATARS_WW_START_DELAY' => 10,
|
||||||
|
'USRNM_MIN_LENGTH' => 3,
|
||||||
|
'USRNM_MAX_LENGTH' => 15,
|
||||||
|
'PW_MIN_LENGTH' => 4,
|
||||||
|
'USRNM_SPECIAL' => true,
|
||||||
|
'PLUS_STATS_INTERVAL_HOURS' => 6,
|
||||||
|
'PLUS_STATS_KEEP_DAYS' => 0,
|
||||||
|
);
|
||||||
|
|
||||||
if (!preg_match('/%[A-Z0-9_]+%/', $row[2], $ph)) {
|
foreach ($leftovers as $row) {
|
||||||
continue;
|
$constant = $row[1];
|
||||||
}
|
|
||||||
|
|
||||||
if (!defined($constant)) {
|
if (!preg_match('/%[A-Z0-9_]+%/', $row[2], $ph)) {
|
||||||
/**
|
continue;
|
||||||
* Constanta nu exista inca: config.php a fost generat
|
|
||||||
* inaintea acestei setari.
|
|
||||||
*
|
|
||||||
* ATENTIE: aici NU se poate pune "false" la nimereala.
|
|
||||||
* Fisierul ar ramane PHP valid, dar setarea ar deveni
|
|
||||||
* inutilizabila fara niciun semn - Natarii n-ar mai
|
|
||||||
* construi, lungimea minima a numelui ar deveni 0 si asa
|
|
||||||
* mai departe. Folosim valoarea implicita reala a fiecarei
|
|
||||||
* setari, aceeasi ca la instalare.
|
|
||||||
*/
|
|
||||||
$defaults = array(
|
|
||||||
'NATARS_WW_START_DELAY' => 10,
|
|
||||||
'USRNM_MIN_LENGTH' => 3,
|
|
||||||
'USRNM_MAX_LENGTH' => 15,
|
|
||||||
'PW_MIN_LENGTH' => 4,
|
|
||||||
'USRNM_SPECIAL' => true,
|
|
||||||
'PLUS_STATS_INTERVAL_HOURS' => 6,
|
|
||||||
'PLUS_STATS_KEEP_DAYS' => 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($defaults[$constant])) {
|
|
||||||
$d = $defaults[$constant];
|
|
||||||
$value = is_bool($d) ? ($d ? 'true' : 'false') : (string) $d;
|
|
||||||
} else {
|
|
||||||
// Setare necunoscuta: alegem dupa context, ca fisierul
|
|
||||||
// sa ramana valid. Ghilimele in sablon => sir gol,
|
|
||||||
// altfel 0 (acceptabil si ca numar, si ca boolean).
|
|
||||||
$quoted = (strpos($row[2], '"' . $ph[0] . '"') !== false)
|
|
||||||
|| (strpos($row[2], "'" . $ph[0] . "'") !== false);
|
|
||||||
$value = $quoted ? '' : '0';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$current = constant($constant);
|
|
||||||
|
|
||||||
if (is_bool($current)) {
|
|
||||||
$value = $current ? 'true' : 'false';
|
|
||||||
} elseif (is_int($current) || is_float($current)) {
|
|
||||||
$value = (string) $current;
|
|
||||||
} else {
|
|
||||||
// Sir: pastram ghilimelele din sablon daca exista deja,
|
|
||||||
// altfel le adaugam noi.
|
|
||||||
$quoted = (strpos($row[2], '"' . $ph[0] . '"') !== false)
|
|
||||||
|| (strpos($row[2], "'" . $ph[0] . "'") !== false);
|
|
||||||
|
|
||||||
$safe = addcslashes((string) $current, "\"\\\$");
|
|
||||||
$value = $quoted ? $safe : '"' . $safe . '"';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = str_replace($ph[0], $value, $text);
|
|
||||||
|
|
||||||
error_log('[TravianZ] config: placeholder ' . $ph[0]
|
|
||||||
. ' nerezolvat de niciun modul, completat din ' . $constant);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$quoted = (strpos($row[2], '"' . $ph[0] . '"') !== false)
|
||||||
|
|| (strpos($row[2], "'" . $ph[0] . "'") !== false);
|
||||||
|
|
||||||
|
if (defined($constant)) {
|
||||||
|
$current = constant($constant);
|
||||||
|
|
||||||
|
if (is_bool($current)) {
|
||||||
|
$value = $current ? 'true' : 'false';
|
||||||
|
} elseif (is_int($current) || is_float($current)) {
|
||||||
|
$value = (string) $current;
|
||||||
|
} else {
|
||||||
|
$safe = addcslashes((string) $current, "\"\\\$");
|
||||||
|
$value = $quoted ? $safe : '"' . $safe . '"';
|
||||||
|
}
|
||||||
|
} elseif (isset($defaults[$constant])) {
|
||||||
|
$d = $defaults[$constant];
|
||||||
|
$value = is_bool($d) ? ($d ? 'true' : 'false') : (string) $d;
|
||||||
|
} else {
|
||||||
|
// setare necunoscuta: alegem dupa context, ca fisierul sa ramana valid
|
||||||
|
$value = $quoted ? '' : '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = str_replace($ph[0], $value, $text);
|
||||||
|
|
||||||
|
error_log('[TravianZ] config: placeholder ' . $ph[0]
|
||||||
|
. ' nerezolvat de niciun modul, completat din ' . $constant);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
|
|||||||
@@ -195,6 +195,11 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
|||||||
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
||||||
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
||||||
|
|
||||||
|
// Ultima verificare: rezolva orice placeholder pe care acest modul
|
||||||
|
// nu il trateaza. TREBUIE apelata dupa toate tz_config_set() si
|
||||||
|
// inainte de scriere - altfel setarile modulului ar fi ignorate.
|
||||||
|
$text = tz_config_finalize($text);
|
||||||
|
|
||||||
fwrite($fh, $text);
|
fwrite($fh, $text);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,11 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
|||||||
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
||||||
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
||||||
|
|
||||||
|
// Ultima verificare: rezolva orice placeholder pe care acest modul
|
||||||
|
// nu il trateaza. TREBUIE apelata dupa toate tz_config_set() si
|
||||||
|
// inainte de scriere - altfel setarile modulului ar fi ignorate.
|
||||||
|
$text = tz_config_finalize($text);
|
||||||
|
|
||||||
fwrite($fh, $text);
|
fwrite($fh, $text);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,11 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
|||||||
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
||||||
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
||||||
|
|
||||||
|
// Ultima verificare: rezolva orice placeholder pe care acest modul
|
||||||
|
// nu il trateaza. TREBUIE apelata dupa toate tz_config_set() si
|
||||||
|
// inainte de scriere - altfel setarile modulului ar fi ignorate.
|
||||||
|
$text = tz_config_finalize($text);
|
||||||
|
|
||||||
fwrite($fh, $text);
|
fwrite($fh, $text);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
|
|||||||
@@ -178,6 +178,11 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
|||||||
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
||||||
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
||||||
|
|
||||||
|
// Ultima verificare: rezolva orice placeholder pe care acest modul
|
||||||
|
// nu il trateaza. TREBUIE apelata dupa toate tz_config_set() si
|
||||||
|
// inainte de scriere - altfel setarile modulului ar fi ignorate.
|
||||||
|
$text = tz_config_finalize($text);
|
||||||
|
|
||||||
fwrite($fh, $text);
|
fwrite($fh, $text);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,11 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
|||||||
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
||||||
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
||||||
|
|
||||||
|
// Ultima verificare: rezolva orice placeholder pe care acest modul
|
||||||
|
// nu il trateaza. TREBUIE apelata dupa toate tz_config_set() si
|
||||||
|
// inainte de scriere - altfel setarile modulului ar fi ignorate.
|
||||||
|
$text = tz_config_finalize($text);
|
||||||
|
|
||||||
fwrite($fh, $text);
|
fwrite($fh, $text);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,11 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
|||||||
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', $_POST['plus-e-gold'] ?? '');
|
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', $_POST['plus-e-gold'] ?? '');
|
||||||
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', $_POST['plus-e-price'] ?? '');
|
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', $_POST['plus-e-price'] ?? '');
|
||||||
|
|
||||||
|
// Ultima verificare: rezolva orice placeholder pe care acest modul
|
||||||
|
// nu il trateaza. TREBUIE apelata dupa toate tz_config_set() si
|
||||||
|
// inainte de scriere - altfel setarile modulului ar fi ignorate.
|
||||||
|
$text = tz_config_finalize($text);
|
||||||
|
|
||||||
fwrite($fh, $text);
|
fwrite($fh, $text);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
|
|||||||
@@ -287,6 +287,11 @@ $text = admin_config_template_contents(array(
|
|||||||
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_PRICE%', (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'));
|
||||||
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
tz_config_set($text, '%PLUS_PACKAGE_E_GOLD%', (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'));
|
||||||
|
|
||||||
|
// Ultima verificare: rezolva orice placeholder pe care acest modul
|
||||||
|
// nu il trateaza. TREBUIE apelata dupa toate tz_config_set() si
|
||||||
|
// inainte de scriere - altfel setarile modulului ar fi ignorate.
|
||||||
|
$text = tz_config_finalize($text);
|
||||||
|
|
||||||
fwrite($fh, $text);
|
fwrite($fh, $text);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ $dbPrefix = $_SESSION['install_random_prefix'];
|
|||||||
<div><label>Natars Spawn (days)</label><input class="input" name="natars_spawn_time" id="natars_spawn_time" value="260"></div>
|
<div><label>Natars Spawn (days)</label><input class="input" name="natars_spawn_time" id="natars_spawn_time" value="260"></div>
|
||||||
<div><label>WW Spawn (days)</label><input class="input" name="natars_ww_spawn_time" id="natars_ww_spawn_time" value="260"></div>
|
<div><label>WW Spawn (days)</label><input class="input" name="natars_ww_spawn_time" id="natars_ww_spawn_time" value="260"></div>
|
||||||
<div><label>WW BP Spawn (days)</label><input class="input" name="natars_ww_building_plan_spawn_time" id="natars_ww_building_plan_spawn_time" value="260"></div>
|
<div><label>WW BP Spawn (days)</label><input class="input" name="natars_ww_building_plan_spawn_time" id="natars_ww_building_plan_spawn_time" value="260"></div>
|
||||||
<div><label>WW BP Spawn (days)</label><input class="input" name="natars_ww_start_delay" id="natars_ww_start_delay" value="10"></div>
|
<div><label>Natars start build WW (days)</label><input class="input" name="natars_ww_start_delay" id="natars_ww_start_delay" value="10"></div>
|
||||||
<div><label>Nature regen</label><select class="input" name="nature_regtime"><option value="28800">8 hours</option><option value="36000">10 hours</option><option value="43200" selected>12 hours</option><option value="57600">16 hours</option><option value="72000">20 hours</option><option value="86400">24 hours</option></select></div>
|
<div><label>Nature regen</label><select class="input" name="nature_regtime"><option value="28800">8 hours</option><option value="36000">10 hours</option><option value="43200" selected>12 hours</option><option value="57600">16 hours</option><option value="72000">20 hours</option><option value="86400">24 hours</option></select></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user