Files
TravianZ/GameEngine/Admin/Mods/config_template.php
T
novgorodschi catalin 1e19f117ca Last fix for Hero T4 & V11
/*
|--------------------------------------------------------------------------
| FIX List
|--------------------------------------------------------------------------
|
| 1. Hero Attribute Points
|    - When adding attribute points to the hero, the page currently refreshes
|      after every click on the "+" button.
|    - Implement a faster allocation method (AJAX or similar) so multiple
|      points can be assigned without a full page refresh.
|    - The implementation must remain secure and not be exploitable
|      (validate requests server-side, prevent double submissions,
|      verify available points, etc.).
|
| 2. Hero Equipment Restrictions (Original Travian Behavior)
|    - Prevent equipping or unequipping hero items while the hero is:
|        • On an adventure.
|        • Attacking (alone or with troops).
|        • Away as reinforcements.
|
| 3. Oasis Navigation
|    - When opening an oasis (37_land.tpl), the 37_t4nav.tpl navigation
|      disappears.
|    - Include the navigation menu on the oasis page as well.
|
| 4. Auction House Redesign
|    - Redesign 37_auction.tpl to match the Merchant.png mockup.
|    - Keep the existing auction functionality exactly as it is.
|    - Only improve the UI/UX.
|    - You may crop and reuse graphics from Merchant.png.
|    - Add Gold ⇄ Silver exchange functionality.
|
| 5. Hero Item Bonuses (Highest Priority)
|    - Verify that hero equipment bonuses are applied correctly.
|    - Example:
|        • Helmet of the Ruler should reduce Barracks training time by 20%.
|        • Currently, training time remains unchanged whether the helmet
|          is equipped or not.
|    - Also verify:
|        • Stable training speed bonuses.
|        • Boots bonuses.
|        • Any other related hero equipment effects.
|
| 6. Adventures Page Redesign
|    - Redesign 37_adventures.tpl to match the Adventure.png mockup.
|    - Keep the "Expires in" column intact.
|
*/
2026-07-23 15:16:51 +03:00

122 lines
5.4 KiB
PHP

<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename config_template.php ##
## Project TravianZ ##
## License TravianZ Project ##
#################################################################################
// Shared helper for the admin "Server Settings" Mods, which regenerate
// GameEngine/config.php from the constant_format.tpl template.
//
// Issue #322: each Mod used to read the install-time copy
// GameEngine/Admin/Mods/constant_format.tpl. That copy is written once by the
// installer and is gitignored, so a code update NEVER refreshes it. When a new
// line is added to config.php (e.g. the per-user LANG block, issue #166),
// servers installed before that change keep the stale copy and the admin panel
// silently rewrites config.php without the new line.
//
// Fix: prefer the version-controlled template (install/data/constant_format.tpl)
// so shipping a new template via git is enough. Fall back to the install-time
// copy only when the install folder was deleted (a common hardening step once
// setup is done).
if (!function_exists('admin_config_template_path')) {
// Absolute path of the template to use, or false when none is available.
function admin_config_template_path() {
$canonical = __DIR__ . '/../../../install/data/constant_format.tpl';
if (is_file($canonical)) {
return $canonical;
}
$local = __DIR__ . '/constant_format.tpl';
return is_file($local) ? $local : false;
}
function admin_config_template_available() {
return admin_config_template_path() !== false;
}
// Raw template contents, or false when unavailable.
//
// Placeholders are left untouched for the caller to fill in, with ONE
// exception: %CRONKEY%. Every edit*.php mod regenerates config.php from this
// template and replaces only the placeholders it knows about, so a value that
// no mod handles would be written to config.php literally — breaking the key
// used to call cron.php over HTTP. CRON_KEY is not something the admin edits
// in any of those forms, so it is resolved here, once, for all callers:
// - existing server -> keep the current CRON_KEY (survives config saves)
// - key not defined -> provision a fresh random one (servers installed
// before CRON_KEY existed in the template)
// $overrides permite unui mod de editare sa IMPUNA o valoare pentru un
// placeholder pe care altfel l-am pastra din constanta curenta (ex.
// editServerSet care schimba HERO_BASE_REGEN). Celelalte module apeleaza
// fara argumente si valorile curente raman neatinse.
function admin_config_template_contents(array $overrides = array()) {
$path = admin_config_template_path();
if ($path === false) {
return false;
}
$text = file_get_contents($path);
if ($text === false) {
return false;
}
if (strpos($text, '%CRONKEY%') !== false) {
$cronKey = (defined('CRON_KEY') && CRON_KEY !== '' && CRON_KEY !== '%CRONKEY%')
? CRON_KEY
: bin2hex(random_bytes(24));
$text = str_replace('%CRONKEY%', $cronKey, $text);
}
// Acelasi tratament pentru durata ciclului si intervalul de tick: sunt
// editate din ACP (editCronSet), deci orice alt mod care regenereaza
// config.php trebuie sa PASTREZE valorile curente, nu sa le reseteze la
// cele din template.
if (strpos($text, '%CRONLOOP%') !== false) {
$cronLoop = defined('CRON_LOOP_SECONDS') ? (int) CRON_LOOP_SECONDS : 300;
$text = str_replace('%CRONLOOP%', (string) $cronLoop, $text);
}
if (strpos($text, '%CRONTICK%') !== false) {
$cronTick = defined('CRON_TICK_SECONDS') ? (int) CRON_TICK_SECONDS : 60;
$text = str_replace('%CRONTICK%', (string) $cronTick, $text);
}
// Retentiile de curatenie: la fel, editate din ACP, deci orice alt mod
// care regenereaza config.php trebuie sa le pastreze.
$cleanupDefaults = array(
'%CLEANUPREPORTS%' => array('CLEANUP_REPORTS_DAYS', 14),
'%CLEANUPCHAT%' => array('CLEANUP_CHAT_DAYS', 7),
'%CLEANUPMESSAGES%' => array('CLEANUP_MESSAGES_DAYS', 0),
);
// regenerarea de baza a eroului: acelasi tratament, sa nu fie resetata
$cleanupDefaults['%HEROBASEREGEN%'] = array('HERO_BASE_REGEN', 10);
foreach ($overrides as $ovPlaceholder => $ovValue) {
if (strpos($text, $ovPlaceholder) !== false) {
$text = str_replace($ovPlaceholder, (string) $ovValue, $text);
}
}
foreach ($cleanupDefaults as $placeholder => $info) {
if (strpos($text, $placeholder) === false) {
continue;
}
list($constant, $default) = $info;
$value = defined($constant) ? (int) constant($constant) : $default;
$text = str_replace($placeholder, (string) $value, $text);
}
return $text;
}
}