diff --git a/Admin/Templates/playerinfo.tpl b/Admin/Templates/playerinfo.tpl index 598c76c9..90b3d093 100644 --- a/Admin/Templates/playerinfo.tpl +++ b/Admin/Templates/playerinfo.tpl @@ -1,4 +1,4 @@ -dbname = $dbname; // connect to the DB - if (!$this->connect()) die(mysqli_error($this->dblink)); + if (!$this->connect()) { + // $this->dblink is FALSE here, so we cannot call mysqli_error() on it. + // Use mysqli_connect_error() and show a friendly, actionable message. + $error = mysqli_connect_error(); + die("Database connection failed: " . htmlspecialchars( + $error !== null && $error !== '' + ? $error + : 'could not connect to the database server. Please check the host, port and credentials. (When running with Docker, the database host is usually "db", not "localhost".)' + )); + } // we will operate in UTF8 mysqli_query($this->dblink,"SET NAMES 'UTF8'"); diff --git a/GameEngine/Logging.php b/GameEngine/Logging.php index ccb5df34..4c7e9876 100755 --- a/GameEngine/Logging.php +++ b/GameEngine/Logging.php @@ -110,7 +110,7 @@ class Logging { $log = "Finish construction and research with gold"; list($log) = $database->escape_input($log); - $q = "Insert into " . TB_PREFIX . "gold_fin_log values (0,$wid,'$log')"; + $q = "INSERT INTO " . TB_PREFIX . "gold_fin_log (wid, action, time, details) VALUES ($wid, 'Finish all constructions', " . time() . ", '$log')"; $database->query($q); } } diff --git a/docker/php/zz-travianz.ini b/docker/php/zz-travianz.ini new file mode 100644 index 00000000..d6ddb920 --- /dev/null +++ b/docker/php/zz-travianz.ini @@ -0,0 +1,11 @@ +; TravianZ production PHP settings +; ----------------------------------------------------------------------------- +; Do NOT show PHP errors, warnings or stack traces to end users. Leaking server +; paths and internal structure is both a security risk and makes the game look +; unstable. Errors are still logged server-side (visible via `docker logs`). +display_errors = Off +display_startup_errors = Off +log_errors = On +error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_WARNING +; Send the error log to the container's stderr so it shows up in `docker logs web`. +error_log = /dev/stderr diff --git a/var/db/struct.sql b/var/db/struct.sql index f525f1cb..e8ce958e 100644 --- a/var/db/struct.sql +++ b/var/db/struct.sql @@ -905,6 +905,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%gold_fin_log` ( gold int(11) NOT NULL DEFAULT 0, time int(11) NOT NULL DEFAULT 0, log varchar(255) DEFAULT NULL, + details varchar(255) DEFAULT NULL, PRIMARY KEY (id), KEY uid (uid), KEY time (time) @@ -1776,13 +1777,12 @@ CREATE TABLE IF NOT EXISTS %PREFIX%croppers ( fieldtype TINYINT UNSIGNED NOT NULL, -- 1 = 9c, 6 = 15c best_oasis_bonus TINYINT UNSIGNED NOT NULL, -- 0,25,50,75,100,125,150 updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - CHECK (best_oasis_bonus IN (0,25,50,75,100,125,150)) + CHECK (best_oasis_bonus IN (0,25,50,75,100,125,150)), + KEY idx_ft_bonus_xy (fieldtype, best_oasis_bonus, x, y), + KEY idx_xy (x, y), + KEY idx_bonus (best_oasis_bonus) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -CREATE INDEX idx_ft_bonus_xy ON %PREFIX%croppers (fieldtype, best_oasis_bonus, x, y); -CREATE INDEX idx_xy ON %PREFIX%croppers (x, y); -CREATE INDEX idx_bonus ON %PREFIX%croppers (best_oasis_bonus); - -- -- Dumping data for table `%prefix%croppers` --