Some fix and add protected players

Some fix and add protected players
This commit is contained in:
novgorodschi catalin
2026-08-10 12:37:56 +03:00
parent d325fce01f
commit 1ecbba0e26
12 changed files with 193 additions and 93 deletions
+1
View File
@@ -117,6 +117,7 @@ $editIcon = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke=
<tr><td><?php echo CONF_SERV_USRNM_MAX; ?></td><td><b><?php echo defined('USRNM_MAX_LENGTH') ? (int) USRNM_MAX_LENGTH : 15; ?></b></td></tr>
<tr><td><?php echo CONF_SERV_PW_MIN; ?></td><td><b><?php echo defined('PW_MIN_LENGTH') ? (int) PW_MIN_LENGTH : 4; ?></b></td></tr>
<tr><td><?php echo CONF_SERV_USRNM_SPECIAL; ?> <em class="tooltip">?<span class="classic"><?php echo CONF_SERV_USRNM_SPECIAL_TOOLTIP; ?></span></em></td><td><?php echo (!defined('USRNM_SPECIAL') || USRNM_SPECIAL) ? "<span class='badge green'>Enabled</span>" : "<span class='badge red'>Disabled</span>"; ?></td></tr>
<tr><td><?php echo ADM_PROTECTED_PLAYERS; ?> <em class="tooltip">?<span class="classic"><?php echo ADM_PROTECTED_PLAYERS_TIP; ?></span></em></td><td><?php echo (defined('PROTECTED_PLAYERS') && trim(PROTECTED_PLAYERS) !== '') ? htmlspecialchars(PROTECTED_PLAYERS, ENT_QUOTES, 'UTF-8') : "<span class='badge red'>None</span>"; ?></td></tr>
</table>
</div>
+4
View File
@@ -458,6 +458,10 @@ function refresh(tz) {
<input type="number" name="hero_res_all" min="0" max="10000" style="width:80px"
value="<?php echo defined('HERO_RES_PER_POINT_ALL') ? (int) HERO_RES_PER_POINT_ALL : 3; ?>"><?php echo ADM_OF_EACH; ?><input type="number" name="hero_res_one" min="0" max="10000" style="width:80px"
value="<?php echo defined('HERO_RES_PER_POINT_ONE') ? (int) HERO_RES_PER_POINT_ONE : 10; ?>"><?php echo ADM_OF_ONE_TYPE; ?></td>
</tr>
<tr>
<td class="b"><?php echo ADM_PROTECTED_PLAYERS; ?><em class="tooltip">?<span class="classic"><?php echo ADM_PROTECTED_PLAYERS_TIP; ?></span></em></td>
<td><input class="fm" name="protected_players" value="<?php echo defined('PROTECTED_PLAYERS') ? htmlspecialchars(PROTECTED_PLAYERS, ENT_QUOTES, 'UTF-8') : ''; ?>" style="width: 70%;" placeholder="Shadow,Multihunter"></td>
</tr>
</tbody>
</table>
@@ -352,6 +352,7 @@ if (!function_exists('tz_config_finalize')) {
}
$defaults = array(
'PROTECTED_PLAYERS' => '',
'NATARS_WW_START_DELAY' => 10,
'USRNM_MIN_LENGTH' => 3,
'USRNM_MAX_LENGTH' => 15,
+4
View File
@@ -140,6 +140,10 @@ $text = admin_config_template_contents(array(
tz_config_set($text, '%PWMIN%', $pMin);
tz_config_set($text, '%SERVERNAME%', $_POST['servername'] ?? '');
// Jucatori protejati impotriva atacurilor. Scoatem ghilimelele, ca sirul
// intra intre ghilimele in config.php.
tz_config_set($text, '%PROTECTEDPLAYERS%',
trim(str_replace('"', '', $_POST['protected_players'] ?? '')));
// Fusul orar se scrie intr-un fisier PHP (define("TIMEZONE","...")), deci
// valoarea NU are voie sa ajunga acolo nefiltrata: pana acum $_POST['tzone']
// era inserat ca atare, ceea ce permitea scrierea de cod in config.php.
+6
View File
@@ -4360,3 +4360,9 @@ tz_def('TZ_WW_NO_CAPITAL', 'The World Wonder village cannot become your capital.
// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ALLYBONUS_MSG_OVERMAX', 'This is the final level: you can donate at most %s more resources.');
//////////////////////////////////////////////////////////////////////////////////////////////////////
// JUCATORI PROTEJATI IMPOTRIVA ATACURILOR
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ADM_PROTECTED_PLAYERS', 'Protected players');
tz_def('ADM_PROTECTED_PLAYERS_TIP', 'Comma-separated player names that cannot be attacked or raided by anyone. Reinforcements are still allowed. Leave empty to disable.');
+6
View File
@@ -4303,3 +4303,9 @@ tz_def('TZ_WW_NO_CAPITAL', 'Le village de la Merveille du Monde ne peut pas deve
// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ALLYBONUS_MSG_OVERMAX', 'Ceci est le dernier niveau : vous pouvez donner au maximum %s ressources supplementaires.');
//////////////////////////////////////////////////////////////////////////////////////////////////////
// JUCATORI PROTEJATI IMPOTRIVA ATACURILOR
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ADM_PROTECTED_PLAYERS', 'Joueurs proteges');
tz_def('ADM_PROTECTED_PLAYERS_TIP', 'Noms de joueurs separes par des virgules qui ne peuvent etre ni attaques ni pilles. Les renforts restent autorises. Laisser vide pour desactiver.');
+6
View File
@@ -4100,3 +4100,9 @@ tz_def('TZ_WW_NO_CAPITAL', 'Satul Minunii Lumii nu poate deveni capitala.');
// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ALLYBONUS_MSG_OVERMAX', 'Acesta e ultimul nivel: poti dona cel mult %s resurse.');
//////////////////////////////////////////////////////////////////////////////////////////////////////
// JUCATORI PROTEJATI IMPOTRIVA ATACURILOR
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('ADM_PROTECTED_PLAYERS', 'Jucatori protejati');
tz_def('ADM_PROTECTED_PLAYERS_TIP', 'Nume de jucatori separate prin virgula, care nu pot fi atacati sau jefuiti de nimeni. Intaririle raman permise. Lasa gol ca sa dezactivezi.');
+50
View File
@@ -230,6 +230,52 @@ class Units {
* @param array $villageInfo Out: the resolved village/oasis row
* @return string An error message, or "" if the target can be attacked
*/
/**
* Jucatori protejati impotriva atacurilor.
*
* Lista vine din PROTECTED_PLAYERS (config.php), separata prin virgula:
* define("PROTECTED_PLAYERS", "Shadow,Multihunter");
*
* Verificarea sta AICI fiindca e punctul unic prin care trec toate
* trimiterile de trupe ale jucatorilor - din a2b.php, din harta sau de
* oriunde altundeva. Nu e nevoie sa modificam fiecare pagina.
*
* Se blocheaza doar ATACUL si RAIDUL (c = 3 si 4). Intaririle (c = 2) trec,
* ca jucatorul protejat sa poata primi ajutor.
*
* @param int $ownerId proprietarul satului tinta
* @param mixed $missionType tipul misiunii din formular
* @return bool
*/
private function isProtectedTarget($ownerId, $missionType) {
global $database;
if (!defined('PROTECTED_PLAYERS') || trim(PROTECTED_PLAYERS) === '') {
return false;
}
// intaririle raman permise
if ((int) $missionType !== 3 && (int) $missionType !== 4) {
return false;
}
$targetName = (string) $database->getUserField((int) $ownerId, 'username', 0);
if ($targetName === '') {
return false;
}
foreach (explode(',', PROTECTED_PLAYERS) as $protectedName) {
$protectedName = trim($protectedName);
if ($protectedName !== '' && strcasecmp($protectedName, $targetName) === 0) {
return true;
}
}
return false;
}
private function validateTargetPlayer($id, $isOasis, &$villageInfo) {
global $database, $village;
@@ -250,6 +296,10 @@ class Units {
//check if the user' is on the vacation mode:
if($database->getvacmodexy($id)) return "User is on vacation mode";
// jucator protejat prin PROTECTED_PLAYERS
if($this->isProtectedTarget($villageOwner, isset($_POST['c']) ? $_POST['c'] : 0)) {
return "This player is protected from attacks.";
}
//check if attacking same village that units are in
if($id == $village->wid) return "You cant attack same village you are sending from.";
+106 -93
View File
@@ -3,7 +3,7 @@
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename config.php ##
## Version 10.0 Full Refactor & Security ##
## Version 11.0 Full Refactor & Security ##
## Developed by: Dzoki and Dixie Edited by Advocaite ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2013-2026. All rights reserved. ##
@@ -144,31 +144,6 @@ define("SPEED", "%SPEED%");
// Defines world size. NOTICE: DO NOT EDIT!!
define("WORLD_MAX", "%MAX%");
// ***** Alliance Bonuses (T4 Port)
// Members donate resources, allowing the alliance to unlock four bonuses, each
// with five levels. The costs, durations, and limits below are based on
// Travian T4; upgrade times and donation limits are scaled by the server speed.
define("NEW_FUNCTIONS_ALLIANCE_BONUSES", %ALLIANCEBONUSES%);
// Total resources required for each level (cumulative for that level).
define("ALLIANCE_BONUS_COSTS", "1200000,5600000,17100000,51200000,153600000");
// Upgrade duration in HOURS for each level (divided by the server speed).
define("ALLIANCE_BONUS_HOURS", "24,48,72,96,120");
// Daily donation limit per player, based on the highest bonus level unlocked
// by the alliance (index 0 = no bonuses unlocked).
define("ALLIANCE_BONUS_DAILY", "300000,300000,400000,550000,750000,1000000");
// Percentage granted by each level. Two sets: "small" bonuses (2% per level:
// Recruitment, Philosophy) and "large" bonuses (4% per level: Metallurgy,
// Commerce), exactly as in T4.
define("ALLIANCE_BONUS_PCT_SMALL", 2);
define("ALLIANCE_BONUS_PCT_LARGE", 4);
// Gold cost to triple a donation.
define("ALLIANCE_BONUS_TRIPLE_GOLD", 3);
// ***** Graphical statistics (Travian Plus)
// The game periodically records each player's rank, population, villages, and
// army from the moment this feature is enabled. These snapshots are then used
@@ -200,39 +175,11 @@ define("USRNM_MIN_LENGTH", %USRNMMIN%);
define("USRNM_MAX_LENGTH", %USRNMMAX%);
define("PW_MIN_LENGTH", %PWMIN%);
// ***** Tribe-specific World Wonder style
// When set to true, each tribe sees its own World Wonder, both on the village
// map and on the building page. Tribes without dedicated images on disk will
// continue to use the original image, regardless of this setting.
define("NEW_FUNCTION_WW_IMAGE", %WWIMAGE%);
// ***** Graphic Pack
//
// SERVER_GP is the pack every player sees by default (chosen at install or in
// Admin -> Server Configuration). GP_ENABLE decides whether players may pick a
// different pack for themselves in Profile -> Graphic Pack.
//
// GP_LOCATE is the pack ACTUALLY used for the current request. It follows the
// same pattern as LANG above: the player's own choice wins when it is enabled
// and points at a real pack on disk, otherwise the server pack is used. A pack
// counts as real when the folder exists and contains travian.css, so a stale
// value in the database can never leave the game without stylesheets.
define("GP_ENABLE",%GP%);
define("SERVER_GP", "%GP_LOCATE%");
$__user_gp = '';
if (GP_ENABLE && isset($_SESSION['gpack']) && is_string($_SESSION['gpack'])) {
$__candidate = trim((string) $_SESSION['gpack']);
// only local packs: "gpack/<name>/" with no traversal and no remote URL
if (preg_match('#^gpack/[A-Za-z0-9_\-]+/$#', $__candidate)
&& is_file(__DIR__ . "/../" . $__candidate . "travian.css")) {
$__user_gp = $__candidate;
}
}
define("GP_LOCATE", $__user_gp !== '' ? $__user_gp : SERVER_GP);
// ***** Activation Mail
// true = activation mail will be sent, users will have to finish registration
// by clicking on link recieved in mail.
// false = users can register with any mail. Not needed to be real one.
define("AUTH_EMAIL",%ACTIVATE%);
// ***** Troop Speed
// Values: 1 (normal), 3 (3x speed) etc...
@@ -317,16 +264,102 @@ define("OASIS_CLAY_PRODUCTION",OASIS_CLAY_MULTIPLIER*SPEED);
define("OASIS_IRON_PRODUCTION",OASIS_IRON_MULTIPLIER*SPEED);
define("OASIS_CROP_PRODUCTION",OASIS_CROP_MULTIPLIER*SPEED);
// ***** Medal Interval check
define("MEDALINTERVAL",%MEDALINTERVAL%);
// ***** Great Workshop
define("GREAT_WKS",%GREAT_WKS%);
// ***** Tourn threshold
define("TS_THRESHOLD",%TS_THRESHOLD%);
// ***** Register open/close
define("REG_OPEN",%REG_OPEN%);
// ***** Peace system
// 0 = None
// 1 = Normal
// 2 = Christmas
// 3 = New Year
// 4 = Easter
define("PEACE",%PEACE%);
// ***** Players protected from attacks
// Comma-separated list of names. Players listed here cannot be attacked or
// raided by anyone; reinforcements are still allowed. Leave empty to disable.
// Example: define("PROTECTED_PLAYERS", "Shadow,Multihunter");
define("PROTECTED_PLAYERS", "%PROTECTEDPLAYERS%");
//////////////////////////////////
// ***** Alliance Bonuses *****//
//////////////////////////////////
// Members donate resources, allowing the alliance to unlock four bonuses, each
// with five levels. The costs, durations, and limits below are based on
// Travian T4; upgrade times and donation limits are scaled by the server speed.
define("NEW_FUNCTIONS_ALLIANCE_BONUSES", %ALLIANCEBONUSES%);
// Total resources required for each level (cumulative for that level).
define("ALLIANCE_BONUS_COSTS", "1200000,5600000,17100000,51200000,153600000");
// Upgrade duration in HOURS for each level (divided by the server speed).
define("ALLIANCE_BONUS_HOURS", "24,48,72,96,120");
// Daily donation limit per player, based on the highest bonus level unlocked
// by the alliance (index 0 = no bonuses unlocked).
define("ALLIANCE_BONUS_DAILY", "300000,300000,400000,550000,750000,1000000");
// Percentage granted by each level. Two sets: "small" bonuses (2% per level:
// Recruitment, Philosophy) and "large" bonuses (4% per level: Metallurgy,
// Commerce), exactly as in T4.
define("ALLIANCE_BONUS_PCT_SMALL", 2);
define("ALLIANCE_BONUS_PCT_LARGE", 4);
// Gold cost to triple a donation.
define("ALLIANCE_BONUS_TRIPLE_GOLD", 3);
//////////////////////////////////
// ***** Graphic Pack *****//
//////////////////////////////////
//
// SERVER_GP is the pack every player sees by default (chosen at install or in
// Admin -> Server Configuration). GP_ENABLE decides whether players may pick a
// different pack for themselves in Profile -> Graphic Pack.
//
// GP_LOCATE is the pack ACTUALLY used for the current request. It follows the
// same pattern as LANG above: the player's own choice wins when it is enabled
// and points at a real pack on disk, otherwise the server pack is used. A pack
// counts as real when the folder exists and contains travian.css, so a stale
// value in the database can never leave the game without stylesheets.
define("GP_ENABLE",%GP%);
define("SERVER_GP", "%GP_LOCATE%");
$__user_gp = '';
if (GP_ENABLE && isset($_SESSION['gpack']) && is_string($_SESSION['gpack'])) {
$__candidate = trim((string) $_SESSION['gpack']);
// only local packs: "gpack/<name>/" with no traversal and no remote URL
if (preg_match('#^gpack/[A-Za-z0-9_\-]+/$#', $__candidate)
&& is_file(__DIR__ . "/../" . $__candidate . "travian.css")) {
$__user_gp = $__candidate;
}
}
define("GP_LOCATE", $__user_gp !== '' ? $__user_gp : SERVER_GP);
// ***** Tribe-specific World Wonder style
// When set to true, each tribe sees its own World Wonder, both on the village
// map and on the building page. Tribes without dedicated images on disk will
// continue to use the original image, regardless of this setting.
define("NEW_FUNCTION_WW_IMAGE", %WWIMAGE%);
// ***** Enable T4 is Coming screen
define("T4_COMING",%T4_COMING%);
// ***** Activation Mail
// true = activation mail will be sent, users will have to finish registration
// by clicking on link recieved in mail.
// false = users can register with any mail. Not needed to be real one.
define("AUTH_EMAIL",%ACTIVATE%);
//////////////////////////////////
// ***** PLUS *****//
//////////////////////////////////
// ***** PLUS
//Plus PayPal e-mail address
define("PAYPAL_EMAIL","%PAYPAL_EMAIL%");
//Plus PayPal currency
@@ -355,27 +388,11 @@ define("PLUS_PACKAGE_E_GOLD","%PLUS_PACKAGE_E_GOLD%");
define("PLUS_TIME",%PLUS_TIME%);
//+25% production lenght
define("PLUS_PRODUCTION",%PLUS_PRODUCTION%);
// ***** Medal Interval check
define("MEDALINTERVAL",%MEDALINTERVAL%);
// ***** Great Workshop
define("GREAT_WKS",%GREAT_WKS%);
// ***** Tourn threshold
define("TS_THRESHOLD",%TS_THRESHOLD%);
// ***** Register open/close
define("REG_OPEN",%REG_OPEN%);
// ***** Peace system
// 0 = None
// 1 = Normal
// 2 = Christmas
// 3 = New Year
// 4 = Easter
define("PEACE",%PEACE%);
//////////////////////////////////
// **** LOG SETTINGS **** //
//////////////////////////////////
//
// LOG BUILDING/UPGRADING
define("LOG_BUILD",%LOGBUILD%);
// LOG RESEARCHES
@@ -393,8 +410,6 @@ define("LOG_MARKET",%LOGMARKET%);
// LOG ILLEGAL ACTIONS
define("LOG_ILLEGAL",%LOGILLEGAL%);
//////////////////////////////////
// **** NEWSBOX SETTINGS **** //
//////////////////////////////////
@@ -404,8 +419,6 @@ define("NEWSBOX1",%BOX1%);
define("NEWSBOX2",%BOX2%);
define("NEWSBOX3",%BOX3%);
//////////////////////////////////
// **** SQL SETTINGS **** //
//////////////////////////////////
@@ -438,8 +451,6 @@ define("TB_PREFIX", "%PREFIX%");
// default: 1
define("DB_TYPE", %CONNECTT%);
////////////////////////////////////
// **** EXTRA SETTINGS **** //
////////////////////////////////////
@@ -461,8 +472,6 @@ define("MAX_MAIL","%MAX_MAILS%");
// ***** Include administrator in statistics/rank
define("INCLUDE_ADMIN", %ARANK%);
////////////////////////////////////
// **** ADMIN SETTINGS **** //
////////////////////////////////////
@@ -479,10 +488,10 @@ define("ADMIN_RECEIVE_SUPPORT_MESSAGES", %ASUPPMSGS%);
// ***** Allow Admin accounts to be raided and attacked
define("ADMIN_ALLOW_INCOMING_RAIDS", %ARAIDS%);
/////////////////////////////////////////////////
// **** NEW MECHANICS AND FUNCTIONS **** //
/////////////////////////////////////////////////
define("NEW_FUNCTIONS_OASIS", %NEW_FUNCTIONS_OASIS%);
define("NEW_FUNCTIONS_ALLIANCE_INVITATION", %NEW_FUNCTIONS_ALLIANCE_INVITATION%);
define("NEW_FUNCTIONS_EMBASSY_MECHANICS", %NEW_FUNCTIONS_EMBASSY_MECHANICS%);
@@ -512,6 +521,7 @@ define("NEW_FUNCTION_REGISTRATION_GOLD_VALUE", %NEW_FUNCTION_REGISTRATION_GOLD_V
//////////////////////////////////////////
// **** DO NOT EDIT SETTINGS **** //
//////////////////////////////////////////
define("AUTO_DEL_INACTIVE",false); // auto-delete inactive players; default = false
define("UN_ACT_TIME", 3628800); // 6 weeks to consider a player inactive
define("ALLOW_BURST",false);
@@ -522,7 +532,10 @@ define("ALLOW_ALL_TRIBE",false);
define("CFM_ADMIN_ACT",true);
define("SERVER_WEB_ROOT",false);
// === IP ban ===
////////////////////////////
// **** IP BAN **** //
////////////////////////////
// Master switch for IP-ban enforcement.
define("BAN_IP_ENABLED",true);
// Comma-separated list of trusted proxy IPs/CIDRs allowed to set the forwarded
@@ -558,7 +571,7 @@ $requse = 0;
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename config.php ##
## Version 10.0 Full Refactor & Security ##
## Version 11.0 Full Refactor & Security ##
## Developed by: Dzoki and Dixie Edited by Advocaite ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2013-2026. All rights reserved. ##
+4
View File
@@ -109,6 +109,10 @@ class Process {
// Minunea Lumii cu stil pe trib
$findReplace["%WWIMAGE%"] = (isset($_POST['ww_image']) && $_POST['ww_image'] === 'false') ? 'false' : 'true';
// Jucatori protejati impotriva atacurilor
$findReplace["%PROTECTEDPLAYERS%"] = isset($_POST['protected_players'])
? trim(str_replace('"', '', $_POST['protected_players'])) : '';
$findReplace["%GP%"] = (isset($_POST['gpack']) && $_POST['gpack'] === 'true') ? 'true' : 'false';
$findReplace["%SSERVER%"] = $_POST['sserver'];
$findReplace["%SPORT%"] = $_POST['sport'];
+4
View File
@@ -55,6 +55,10 @@ if(isset($_GET['err']) && $_GET['err'] == 2) {
<option value="1" selected>Romans</option>
<option value="2">Teutons</option>
<option value="3">Gauls</option>
<option value="6">Huns</option>
<option value="7">Egyptians</option>
<option value="8">Spartans</option>
<option value="9">Vikings</option>
</select>
</div>
<div><label>Show in stats</label>
+1
View File
@@ -334,6 +334,7 @@ foreach($mechs as $k => $l){
<option value="true" selected>Yes</option>
<option value="false">No &ndash; same image for everyone</option>
</select></div>
<div><label>Protected players (no attacks)</label><input class="input" type="text" name="protected_players" value="" placeholder="e.g. Shadow,Multihunter"></div>
<div><label>Allow player graphic packs</label><select class="input" name="gpack">
<option value="false" selected>No &ndash; everyone sees the server pack</option>
<option value="true">Yes &ndash; players may pick their own in Profile</option>