From a004f5352b5d4eee46e5cc9bc37cb9a9988d30a4 Mon Sep 17 00:00:00 2001 From: Catalin Novgorodschi <1140613+Shadowss@users.noreply.github.com> Date: Tue, 12 May 2026 13:39:10 +0300 Subject: [PATCH] For incremental refactor + some credits --- GameEngine/Account.php | 19 ++++++------- GameEngine/Alliance.php | 4 +-- GameEngine/Battle.php | 4 +-- GameEngine/Building.php | 4 +-- GameEngine/Form.php | 61 +++++++++++++++++++++++++++-------------- 5 files changed, 56 insertions(+), 36 deletions(-) diff --git a/GameEngine/Account.php b/GameEngine/Account.php index a3dde57f..95ca4934 100755 --- a/GameEngine/Account.php +++ b/GameEngine/Account.php @@ -4,16 +4,15 @@ use App\Entity\User; ################################################################################# ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## --------------------------------------------------------------------------- ## -## Project: TravianZ ## -## Version: 22.06.2015 ## -## Filename Account.php ## -## Developed by: Mr.php , Advocaite , brainiacX , yi12345 , Shadow , ronix ## -## Fixed by: Shadow - STARVATION , HERO FIXED COMPL. ## -## Fixed by: InCube - double troops ## -## License: TravianZ Project ## -## Copyright: TravianZ (c) 2010-2015. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## -## Source code: https://github.com/Shadowss/TravianZ ## +## Project: TravianZ ## +## Version: 18.05.2026 ## +## Filename: Account.php ## +## Developed by: Dzoki ## +## Refactored by: Shadow ## +## License: TravianZ Project ## +## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## +## URLs: https://travianz.org ## +## https://github.com/Shadowss/TravianZ ## ## ## ################################################################################# diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php index a1562de3..a8d312dc 100755 --- a/GameEngine/Alliance.php +++ b/GameEngine/Alliance.php @@ -10,8 +10,8 @@ ## Refactor by: Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## -## Source code: https://github.com/Shadowss/TravianZ ## +## URLs: https://travianz.org ## +## https://github.com/Shadowss/TravianZ ## ## ## ################################################################################# diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php index 9236773b..1d2034c5 100644 --- a/GameEngine/Battle.php +++ b/GameEngine/Battle.php @@ -14,8 +14,8 @@ ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## ## ## -## URLs: http://travian.shadowss.ro ## -## https://github.com/Shadowss/TravianZ ## +## URLs: https://travianz.org ## +## https://github.com/Shadowss/TravianZ ## ## ## ################################################################################# diff --git a/GameEngine/Building.php b/GameEngine/Building.php index c5c49cf8..71d9aa64 100755 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -12,8 +12,8 @@ ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## ## ## -## URLs: http://travian.shadowss.ro ## -## https://github.com/Shadowss/TravianZ ## +## URLs: https://travianz.org ## +## https://github.com/Shadowss/TravianZ ## ## ## ################################################################################# diff --git a/GameEngine/Form.php b/GameEngine/Form.php index 2196c091..bfab69a5 100755 --- a/GameEngine/Form.php +++ b/GameEngine/Form.php @@ -5,7 +5,14 @@ ## --------------------------------------------------------------------------- ## ## Filename Form.php ## ## License: TravianZ Project ## -## Copyright: TravianZ (c) 2010-2025. All rights reserved. ## +## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## +## Refactored by: Shadow ## +## ## +## Refactor: Incremental cleanup (compatibility preserved) ## +## Notes: PHP 7+ / legacy safe ## +## ## +## URLs: http://travian.shadowss.ro ## +## https://github.com/Shadowss/TravianZ ## ## ## ################################################################################# @@ -13,63 +20,77 @@ class Form { private $errorarray = array(); public $valuearray = array(); - private $errorcount; + private $errorcount = 0; public function __construct() { - if(isset($_SESSION['errorarray']) && isset($_SESSION['valuearray'])) { + + if (isset($_SESSION['errorarray']) && isset($_SESSION['valuearray'])) { + $this->errorarray = $_SESSION['errorarray']; $this->valuearray = $_SESSION['valuearray']; $this->errorcount = count($this->errorarray); - unset($_SESSION['errorarray']); - unset($_SESSION['valuearray']); + unset($_SESSION['errorarray'], $_SESSION['valuearray']); + } else { + $this->errorcount = 0; } - else $this->errorcount = 0; } - public function addError($field,$error) { + public function addError($field, $error) { + $this->errorarray[$field] = $error; $this->errorcount = count($this->errorarray); } public function getError($field) { - if(array_key_exists($field,$this->errorarray)) { + + if (array_key_exists($field, $this->errorarray)) { return $this->errorarray[$field]; } - else return ""; + + return ""; } public function getValue($field) { - if(array_key_exists($field,$this->valuearray)) { + + if (array_key_exists($field, $this->valuearray)) { return $this->valuearray[$field]; } - else return ""; + + return ""; } - + public function setValue($field, $value) { - $this->valuearray[$field] = $value; + + $this->valuearray[$field] = $value; } - public function getDiff($field,$cookie) { - if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] != $cookie) { + public function getDiff($field, $cookie) { + + if (array_key_exists($field, $this->valuearray) && $this->valuearray[$field] != $cookie) { return $this->valuearray[$field]; } - else return $cookie; + + return $cookie; } - public function getRadio($field,$value) { - if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] == $value) { + public function getRadio($field, $value) { + + if (array_key_exists($field, $this->valuearray) && $this->valuearray[$field] == $value) { return "checked"; } - else return ""; + + return ""; } public function returnErrors() { + return $this->errorcount; } public function getErrors() { + return $this->errorarray; } -}; +} ?> \ No newline at end of file