From 613d800e29fbcf9d811376224b56bff219575fd6 Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Mon, 3 Aug 2026 07:51:50 +0300 Subject: [PATCH] Clear some dead code! Clear some dead code! --- Admin/Templates/editServerSet.tpl | 21 +++++++++++++++ Admin/Templates/server_info.tpl | 5 +++- GameEngine/Admin/Mods/editExtraSet.php | 3 +-- GameEngine/Admin/Mods/editNewFunctions.php | 3 +-- GameEngine/Admin/Mods/editPlusSet.php | 3 +-- GameEngine/Admin/Mods/editServerSet.php | 19 ++++++++++++-- .../AutomationAccountMaintenance.php | 10 +------ GameEngine/Database/DatabaseUserQueries.php | 26 +++++++------------ GameEngine/Lang/en.php | 10 +++++++ GameEngine/Lang/fr.php | 10 +++++++ GameEngine/Lang/ro.php | 10 +++++++ GameEngine/Session.php | 6 ++++- install/data/constant_format.tpl | 18 +++++++------ install/process.php | 23 ++++++++++------ install/templates/config.tpl | 7 +++++ var/db/struct.sql | 16 ------------ 16 files changed, 123 insertions(+), 67 deletions(-) diff --git a/Admin/Templates/editServerSet.tpl b/Admin/Templates/editServerSet.tpl index e9996d2b..98c2680e 100644 --- a/Admin/Templates/editServerSet.tpl +++ b/Admin/Templates/editServerSet.tpl @@ -198,6 +198,27 @@ function refresh(tz) { ? + + ? + + + + + + + + + + + + ? + + + + ? diff --git a/Admin/Templates/server_info.tpl b/Admin/Templates/server_info.tpl index 621f4975..4f1b79cf 100644 --- a/Admin/Templates/server_info.tpl +++ b/Admin/Templates/server_info.tpl @@ -32,7 +32,10 @@ function q1($sql){ global $database; $r=$database->query($sql); return $r ? $r-> // ---- DATE ---- $users = (int)(q1("SELECT COUNT(*) c FROM ".TB_PREFIX."users WHERE tribe IN (1,2,3,6,7,8,9)")['c'] ?? 0); -$active = (int)(q1("SELECT COUNT(*) c FROM ".TB_PREFIX."active")['c'] ?? 0); +// Jucatori online: se numara din users.timestamp, ca in home.tpl si in pagina +// Online Players - aceeasi fereastra de 5 minute, aceeasi sursa. +// Tabela separata "active" a fost eliminata: dubla exact aceasta informatie. +$active = (int)(q1("SELECT COUNT(*) c FROM ".TB_PREFIX."users WHERE timestamp > ".(time()-300)." AND id > 5")['c'] ?? 0); $online = (int)(q1("SELECT COUNT(*) c FROM ".TB_PREFIX."users WHERE timestamp > ".(time()-300)." AND tribe>0")['c'] ?? 0); $banned = (int)(q1("SELECT COUNT(*) c FROM ".TB_PREFIX."users WHERE access=0")['c'] ?? 0); $villages = (int)(q1("SELECT COUNT(*) c FROM ".TB_PREFIX."vdata")['c'] ?? 0); diff --git a/GameEngine/Admin/Mods/editExtraSet.php b/GameEngine/Admin/Mods/editExtraSet.php index 0cea5602..290e079d 100755 --- a/GameEngine/Admin/Mods/editExtraSet.php +++ b/GameEngine/Admin/Mods/editExtraSet.php @@ -143,8 +143,7 @@ $fh = fopen($myFile, 'w') or die("


Can't open file: GameEngine\con tz_config_set($text, '%ANAME%', ADMIN_NAME); tz_config_set($text, '%ASUPPMSGS%', $SUPPORT_MSGS_IN_ADMIN); tz_config_set($text, '%ARAIDS%', $ADMINS_RAIDABLE); - tz_config_set($text, '%UTRACK%', "TRACK_USR"); // not in use, text only in a comment - tz_config_set($text, '%UTOUT%', "USER_TIMEOUT"); // not in use, text only in a comment + tz_config_set($text, '%DOMAIN%', DOMAIN); tz_config_set($text, '%HOMEPAGE%', HOMEPAGE); tz_config_set($text, '%SERVER%', SERVER); diff --git a/GameEngine/Admin/Mods/editNewFunctions.php b/GameEngine/Admin/Mods/editNewFunctions.php index 2030b201..ee2b236b 100644 --- a/GameEngine/Admin/Mods/editNewFunctions.php +++ b/GameEngine/Admin/Mods/editNewFunctions.php @@ -127,8 +127,7 @@ $fh = fopen($myFile, 'w') or die("


Can't open file: GameEngine\con tz_config_set($text, '%ANAME%', ADMIN_NAME); tz_config_set($text, '%ASUPPMSGS%', $SUPPORT_MSGS_IN_ADMIN); tz_config_set($text, '%ARAIDS%', $ADMINS_RAIDABLE); - tz_config_set($text, '%UTRACK%', "TRACK_USR"); // not in use, text only in a comment - tz_config_set($text, '%UTOUT%', "USER_TIMEOUT"); // not in use, text only in a comment + tz_config_set($text, '%DOMAIN%', DOMAIN); tz_config_set($text, '%HOMEPAGE%', HOMEPAGE); tz_config_set($text, '%SERVER%', SERVER); diff --git a/GameEngine/Admin/Mods/editPlusSet.php b/GameEngine/Admin/Mods/editPlusSet.php index aea93e9c..07a57a19 100644 --- a/GameEngine/Admin/Mods/editPlusSet.php +++ b/GameEngine/Admin/Mods/editPlusSet.php @@ -128,8 +128,7 @@ $fh = fopen($myFile, 'w') or die("


Can't open file: GameEngine\con tz_config_set($text, '%ANAME%', ADMIN_NAME); tz_config_set($text, '%ASUPPMSGS%', $SUPPORT_MSGS_IN_ADMIN); tz_config_set($text, '%ARAIDS%', $ADMINS_RAIDABLE); - tz_config_set($text, '%UTRACK%', "TRACK_USR"); // not in use, text only in a comment - tz_config_set($text, '%UTOUT%', "USER_TIMEOUT"); // not in use, text only in a comment + tz_config_set($text, '%DOMAIN%', DOMAIN); tz_config_set($text, '%HOMEPAGE%', HOMEPAGE); tz_config_set($text, '%SERVER%', SERVER); diff --git a/GameEngine/Admin/Mods/editServerSet.php b/GameEngine/Admin/Mods/editServerSet.php index fa03b6e3..471dade3 100755 --- a/GameEngine/Admin/Mods/editServerSet.php +++ b/GameEngine/Admin/Mods/editServerSet.php @@ -124,6 +124,22 @@ $text = admin_config_template_contents(array( )); tz_config_set($text, '%ERRORREPORT%', $_POST['error'] ?? ''); tz_config_set($text, '%ERROR%', $_POST['error'] ?? '', 'code'); + // Regulile de inregistrare + tz_config_set($text, '%USRNMSPECIAL%', + (isset($_POST['usrnm_special']) && $_POST['usrnm_special'] === 'false') ? 'false' : 'true'); + + $uMin = isset($_POST['usrnm_min']) ? (int) $_POST['usrnm_min'] : 3; + if ($uMin < 1 || $uMin > 50) { $uMin = 3; } + tz_config_set($text, '%USRNMMIN%', $uMin); + + $uMax = isset($_POST['usrnm_max']) ? (int) $_POST['usrnm_max'] : 15; + if ($uMax < $uMin || $uMax > 100) { $uMax = max(15, $uMin); } + tz_config_set($text, '%USRNMMAX%', $uMax); + + $pMin = isset($_POST['pw_min']) ? (int) $_POST['pw_min'] : 4; + if ($pMin < 1 || $pMin > 100) { $pMin = 4; } + tz_config_set($text, '%PWMIN%', $pMin); + tz_config_set($text, '%SERVERNAME%', $_POST['servername'] ?? ''); // Fusul orar se scrie intr-un fisier PHP (define("TIMEZONE","...")), deci // valoarea NU are voie sa ajunga acolo nefiltrata: pana acum $_POST['tzone'] @@ -224,8 +240,7 @@ $text = admin_config_template_contents(array( tz_config_set($text, '%ASUPPMSGS%', $SUPPORT_MSGS_IN_ADMIN); tz_config_set($text, '%ARAIDS%', $ADMINS_RAIDABLE); tz_config_set($text, '%ANAME%', ADMIN_NAME); - tz_config_set($text, '%UTRACK%', ""); - tz_config_set($text, '%UTOUT%', ""); + tz_config_set($text, '%DOMAIN%', DOMAIN); tz_config_set($text, '%HOMEPAGE%', HOMEPAGE); tz_config_set($text, '%SERVER%', SERVER); diff --git a/GameEngine/Automation/AutomationAccountMaintenance.php b/GameEngine/Automation/AutomationAccountMaintenance.php index eb4db6dc..324483b3 100644 --- a/GameEngine/Automation/AutomationAccountMaintenance.php +++ b/GameEngine/Automation/AutomationAccountMaintenance.php @@ -92,15 +92,7 @@ trait AutomationAccountMaintenance { } } - private function ClearInactive() { - global $database; - - if(TRACK_USR) { - $timeout = time()-USER_TIMEOUT * 60; - $q = "DELETE FROM ".TB_PREFIX."active WHERE timestamp < $timeout"; - $database->query($q); - } - } + private function checkInvitedPlayes() { global $database; diff --git a/GameEngine/Database/DatabaseUserQueries.php b/GameEngine/Database/DatabaseUserQueries.php index 072afbc9..4cc6bad6 100644 --- a/GameEngine/Database/DatabaseUserQueries.php +++ b/GameEngine/Database/DatabaseUserQueries.php @@ -462,17 +462,6 @@ trait DatabaseUserQueries { return mysqli_query($this->dblink,$q); } - function addActiveUser($username, $time) { - list($username, $time) = $this->escape_input($username, $time); - - $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; - if(mysqli_query($this->dblink,$q)) { - return true; - } else { - return false; - } - } - function updateActiveUser($username, $time) { static $updated = false; @@ -482,15 +471,20 @@ trait DatabaseUserQueries { list($username, $time) = $this->escape_input($username, $time); - $res1 = $this->addActiveUser($username, $time); + // Marcam ultima activitate DOAR in users.timestamp. + // + // Exista si o tabela separata "active" care tinea aceeasi informatie, + // dar era citita de o singura pagina din panou, iar users.timestamp e + // oricum sursa pentru lista de jucatori online, harta de caldura si + // stergerea conturilor inactive. Tabela a fost eliminata. $q = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'"; - $res2 = mysqli_query($this->dblink,$q); - if($res1 && $res2) { + + if (mysqli_query($this->dblink, $q)) { $updated = true; return true; - } else { - return false; } + + return false; } function submitProfile($uid, $gender, $location, $birthday, $desc1, $desc2) { diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index 7366f2d0..93e01cac 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -4318,3 +4318,13 @@ tz_def('TZ_WS_VS_NATARS', 'Against Natars'); // MESAJ DE SISTEM - previzualizare ////////////////////////////////////////////////////////////////////////////////////////////////////// tz_def('ADM_PREVIEW', 'Preview'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// REGULI DE INREGISTRARE (Server Configuration) +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('CONF_SERV_USRNM_MIN', 'Minimum username length'); +tz_def('CONF_SERV_USRNM_MAX', 'Maximum username length'); +tz_def('CONF_SERV_PW_MIN', 'Minimum password length'); +tz_def('CONF_SERV_USRNM_SPECIAL', 'Allow . - _ in usernames'); +tz_def('CONF_SERV_USRNM_SPECIAL_TOOLTIP', 'With True, usernames may contain a dot, hyphen or underscore, and single spaces between words. With False, only letters and digits are accepted.'); +tz_def('CONF_SERV_REGRULES_TOOLTIP', 'Rules checked when a player registers. Changing them does not affect existing accounts.'); diff --git a/GameEngine/Lang/fr.php b/GameEngine/Lang/fr.php index 6637368a..f24243ba 100644 --- a/GameEngine/Lang/fr.php +++ b/GameEngine/Lang/fr.php @@ -4261,3 +4261,13 @@ tz_def('TZ_WS_VS_NATARS', 'Contre les Natars'); // MESAJ DE SISTEM - previzualizare ////////////////////////////////////////////////////////////////////////////////////////////////////// tz_def('ADM_PREVIEW', 'Aperçu'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// REGULI DE INREGISTRARE (Server Configuration) +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('CONF_SERV_USRNM_MIN', 'Longueur minimale du nom'); +tz_def('CONF_SERV_USRNM_MAX', 'Longueur maximale du nom'); +tz_def('CONF_SERV_PW_MIN', 'Longueur minimale du mot de passe'); +tz_def('CONF_SERV_USRNM_SPECIAL', 'Autoriser . - _ dans les noms'); +tz_def('CONF_SERV_USRNM_SPECIAL_TOOLTIP', 'Avec True, les noms peuvent contenir un point, un tiret ou un underscore, et des espaces simples entre les mots. Avec False, seules les lettres et les chiffres sont acceptes.'); +tz_def('CONF_SERV_REGRULES_TOOLTIP', 'Regles verifiees lors de l\'inscription. Les modifier n\'affecte pas les comptes existants.'); diff --git a/GameEngine/Lang/ro.php b/GameEngine/Lang/ro.php index acf86e16..dfbee255 100644 --- a/GameEngine/Lang/ro.php +++ b/GameEngine/Lang/ro.php @@ -4058,3 +4058,13 @@ tz_def('TZ_WS_VS_NATARS', 'Contra Natarilor'); // MESAJ DE SISTEM - previzualizare ////////////////////////////////////////////////////////////////////////////////////////////////////// tz_def('ADM_PREVIEW', 'Previzualizare'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// REGULI DE INREGISTRARE (Server Configuration) +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('CONF_SERV_USRNM_MIN', 'Lungimea minima a numelui'); +tz_def('CONF_SERV_USRNM_MAX', 'Lungimea maxima a numelui'); +tz_def('CONF_SERV_PW_MIN', 'Lungimea minima a parolei'); +tz_def('CONF_SERV_USRNM_SPECIAL', 'Permite . - _ in nume'); +tz_def('CONF_SERV_USRNM_SPECIAL_TOOLTIP', 'Cu True, numele pot contine punct, liniuta sau underscore, si spatii simple intre cuvinte. Cu False, se accepta doar litere si cifre.'); +tz_def('CONF_SERV_REGRULES_TOOLTIP', 'Reguli verificate la inregistrare. Schimbarea lor nu afecteaza conturile existente.'); diff --git a/GameEngine/Session.php b/GameEngine/Session.php index 4836c7b3..a439624f 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -106,7 +106,11 @@ function __construct() { $this->logged_in = $this->checkLogin(); - if ($this->logged_in && TRACK_USR) { + // users.timestamp nu mai e optional: din el se scot lista de jucatori + // online, harta de caldura si stergerea conturilor inactive. Inainte era + // in spatele lui TRACK_USR - cu flagul stins, stergerea automata ar fi + // considerat TOTI jucatorii inactivi. + if ($this->logged_in) { $database->updateActiveUser($this->username, $this->time); } diff --git a/install/data/constant_format.tpl b/install/data/constant_format.tpl index 6c9e599e..010df37d 100644 --- a/install/data/constant_format.tpl +++ b/install/data/constant_format.tpl @@ -188,6 +188,16 @@ define("PLUS_STATS_INTERVAL_HOURS", %PLUSSTATSHOURS%); // lifetime of an entire server, this only amounts to a few tens of thousands of records. define("PLUS_STATS_KEEP_DAYS", %PLUSSTATSKEEP%); +// ***** Registration rules +// Regulile verificate la inregistrare (vezi Account.php). +// +// USRNM_SPECIAL: cu true se accepta punct, liniuta si underscore in nume, si +// spatii simple intre cuvinte; cu false doar litere si cifre. +define("USRNM_SPECIAL", %USRNMSPECIAL%); +define("USRNM_MIN_LENGTH", %USRNMMIN%); +define("USRNM_MAX_LENGTH", %USRNMMAX%); +define("PW_MIN_LENGTH", %PWMIN%); + // ***** Graphic Pack // // SERVER_GP is the pack every player sees by default (chosen at install or in @@ -495,10 +505,6 @@ define("NEW_FUNCTION_REGISTRATION_GOLD_VALUE", %NEW_FUNCTION_REGISTRATION_GOLD_V ////////////////////////////////////////// define("AUTO_DEL_INACTIVE",false); // auto-delete inactive players; default = false define("UN_ACT_TIME", 3628800); // 6 weeks to consider a player inactive -//define("TRACK_USR","%UTRACK%"); -//define("USER_TIMEOUT","%UTOUT%"); -define("TRACK_USR",true); // track users' being active or not -define("USER_TIMEOUT",3600); // 1 hour of no activity counts as inactivity define("ALLOW_BURST",false); define("BASIC_MAX",1); define("INNER_MAX",1); @@ -506,10 +512,6 @@ define("PLUS_MAX",1); define("ALLOW_ALL_TRIBE",false); define("CFM_ADMIN_ACT",true); define("SERVER_WEB_ROOT",false); -define("USRNM_SPECIAL",true); -define("USRNM_MIN_LENGTH",3); -define("USRNM_MAX_LENGTH",15); -define("PW_MIN_LENGTH",4); // === IP ban (issue #185) === // Master switch for IP-ban enforcement. diff --git a/install/process.php b/install/process.php index 9b73cd01..5656a022 100644 --- a/install/process.php +++ b/install/process.php @@ -74,10 +74,6 @@ class Process { $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']; // Comutatorul de pachete grafice proprii. Linia era comentata, deci %GP% // ramanea neinlocuit in config.php si constanta nu se definea deloc. @@ -95,6 +91,21 @@ class Process { if ($psKeep < 0 || $psKeep > 3650) { $psKeep = 0; } $findReplace["%PLUSSTATSKEEP%"] = $psKeep; + // Regulile de inregistrare + $findReplace["%USRNMSPECIAL%"] = (isset($_POST['usrnm_special']) && $_POST['usrnm_special'] === 'false') ? 'false' : 'true'; + + $uMin = isset($_POST['usrnm_min']) ? (int) $_POST['usrnm_min'] : 3; + if ($uMin < 1 || $uMin > 50) { $uMin = 3; } + $findReplace["%USRNMMIN%"] = $uMin; + + $uMax = isset($_POST['usrnm_max']) ? (int) $_POST['usrnm_max'] : 15; + if ($uMax < $uMin || $uMax > 100) { $uMax = max(15, $uMin); } + $findReplace["%USRNMMAX%"] = $uMax; + + $pMin = isset($_POST['pw_min']) ? (int) $_POST['pw_min'] : 4; + if ($pMin < 1 || $pMin > 100) { $pMin = 4; } + $findReplace["%PWMIN%"] = $pMin; + $findReplace["%GP%"] = (isset($_POST['gpack']) && $_POST['gpack'] === 'true') ? 'true' : 'false'; $findReplace["%SSERVER%"] = $_POST['sserver']; $findReplace["%SPORT%"] = $_POST['sport']; @@ -105,7 +116,6 @@ class Process { $findReplace["%CONNECTT%"] = $_POST['connectt']; $findReplace["%ASUPPMSGS%"] = 'true'; $findReplace["%ARAIDS%"] = 'false'; - //$findReplace["%SUBDOM%"] = $_POST['subdom']; $findReplace["%LOGBUILD%"] = $_POST['log_build']; $findReplace["%LOGTECH%"] = $_POST['log_tech']; $findReplace["%LOGLOGIN%"] = $_POST['log_login']; @@ -114,9 +124,6 @@ class Process { $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%"] = 'false'; $findReplace["%QUEST%"] = $_POST['quest']; diff --git a/install/templates/config.tpl b/install/templates/config.tpl index f547e47c..e1a2363f 100644 --- a/install/templates/config.tpl +++ b/install/templates/config.tpl @@ -323,6 +323,13 @@ foreach($mechs as $k => $l){ +
+
+
+