From 63a99e0f92214bc5fd60b867f80bb451af29da79 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 30 Jan 2026 22:24:09 +0100 Subject: [PATCH 1/7] Fix post_edit being an author, didn't worked --- system/pages/forum/edit_post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php index 4b7976aa..bbc00699 100644 --- a/system/pages/forum/edit_post.php +++ b/system/pages/forum/edit_post.php @@ -24,7 +24,7 @@ if(Forum::canPost($account_logged)) { $first_post = $db->query("SELECT `" . FORUM_TABLE_PREFIX . "forum`.`author_guid`, `" . FORUM_TABLE_PREFIX . "forum`.`author_aid`, `" . FORUM_TABLE_PREFIX . "forum`.`first_post`, `" . FORUM_TABLE_PREFIX . "forum`.`post_topic`, `" . FORUM_TABLE_PREFIX . "forum`.`post_text`, `" . FORUM_TABLE_PREFIX . "forum`.`post_smile`, `" . FORUM_TABLE_PREFIX . "forum`.`id`, `" . FORUM_TABLE_PREFIX . "forum`.`section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `" . FORUM_TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch(); echo 'Boards >> '.$sections[$thread['section']]['name'].' >> '.htmlspecialchars($first_post['post_topic']).' >> Edit post'; - if(Forum::hasAccess($thread['section'] && ($account_logged->getId() == $thread['author_aid'] || Forum::isModerator()))) + if(Forum::hasAccess($thread['section']) && ($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())) { $char_id = $post_topic = $text = $smile = $html = null; $players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll(); From a76741c9dae97584cbc6736bbc6404d1e59f856d Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 30 Jan 2026 22:29:44 +0100 Subject: [PATCH 2/7] Remove html tags from email function (patched from 1.x) Better score in tests --- system/functions.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/system/functions.php b/system/functions.php index acacd30e..0278882b 100644 --- a/system/functions.php +++ b/system/functions.php @@ -823,11 +823,11 @@ function getWorldName($id) * * @param string $to Recipient email address. * @param string $subject Subject of the message. - * @param string $body Message body in html format. + * @param string $body Message body in HTML format. * @param string $altBody Alternative message body, plain text. * @return bool PHPMailer status returned (success/failure). */ -function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true) +function _mail(string $to, string $subject, string $body, string $altBody = ''): bool { /** @var PHPMailer $mailer */ global $mailer, $config; @@ -841,15 +841,6 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true) $mailer->clearAllRecipients(); } - $signature_html = ''; - if(isset($config['mail_signature']['html'])) - $signature_html = $config['mail_signature']['html']; - - if($add_html_tags && isset($body[0])) - $tmp_body = '' . $body . '

' . $signature_html . ''; - else - $tmp_body = $body . '

' . $signature_html; - if($config['smtp_enabled']) { $mailer->isSMTP(); @@ -864,6 +855,12 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true) $mailer->isMail(); } + if(isset($config['mail_signature']['html'])) { + $signature_html = $config['mail_signature']['html']; + } + + $tmp_body = $body . '

' . $signature_html; + $mailer->isHTML(isset($body[0]) > 0); $mailer->From = $config['mail_address']; $mailer->Sender = $config['mail_address']; From c376fd93c6fbf3f9c4bd79bae8875720464c28fa Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 30 Jan 2026 22:32:21 +0100 Subject: [PATCH 3/7] Return 404 when signature player not found (patching from 1.x) In most cases it was a request for a non existing file --- tools/signature/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/signature/index.php b/tools/signature/index.php index e3e33303..b272824d 100644 --- a/tools/signature/index.php +++ b/tools/signature/index.php @@ -33,14 +33,14 @@ if(!isset($_REQUEST['name'])) die('Please enter name as get or post parameter.'); - $name = stripslashes(ucwords(strtolower(trim($_REQUEST['name'])))); $player = new OTS_Player(); - $player->find($name); + $player->find($_REQUEST['name']); if(!$player->isLoaded()) { - header('Content-type: image/png'); - readfile(SIGNATURES_IMAGES.'nocharacter.png'); + //header('Content-type: image/png'); + //readfile(SIGNATURES_IMAGES.'nocharacter.png'); + http_response_code(404); exit; } From 0a930e9acb7f3adc708307cb2d4e1f57d9aa08ad Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 30 Jan 2026 22:32:44 +0100 Subject: [PATCH 4/7] Account Manage: Change last login to correct login time Instead of just "now" --- system/templates/account.management.html.twig | 2 +- templates/tibiacom/account.management.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/templates/account.management.html.twig b/system/templates/account.management.html.twig index 65919558..9d89a442 100644 --- a/system/templates/account.management.html.twig +++ b/system/templates/account.management.html.twig @@ -109,7 +109,7 @@ Last Login: - {{ "now"|date("j F Y, G:i:s") }} + {{ account_logged.getCustomField('web_lastlogin')|date("j F Y, G:i:s") }} {% autoescape false %} diff --git a/templates/tibiacom/account.management.html.twig b/templates/tibiacom/account.management.html.twig index 1a851bf0..deb53dc5 100644 --- a/templates/tibiacom/account.management.html.twig +++ b/templates/tibiacom/account.management.html.twig @@ -161,7 +161,7 @@ Last Login: - {{ "now"|date("j F Y, G:i:s") }} + {{ account_logged.getCustomField('web_lastlogin')|date("j F Y, G:i:s") }} {% autoescape false %} From 44c917aefa20ad8dcba7a47ccab50635e33f2e53 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 30 Jan 2026 22:34:33 +0100 Subject: [PATCH 5/7] Account character list: Add [ DELETED ] for deleted characters --- system/templates/account.management.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/templates/account.management.html.twig b/system/templates/account.management.html.twig index 9d89a442..8f399b23 100644 --- a/system/templates/account.management.html.twig +++ b/system/templates/account.management.html.twig @@ -173,7 +173,7 @@ {% set i = i + 1 %} - {{ player.getName() }} + {{ player.getName() }}{% if player.isDeleted() %} [ DELETED ] {% endif %} {{ player.getLevel() }} {{ player.getVocationName() }} From ed8b36f4528668f29ea1a2adc7234ec249fa031b Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 30 Jan 2026 22:38:19 +0100 Subject: [PATCH 6/7] Server Status: Write to status-error.log if there is connection error Patching from 1.x --- system/libs/pot/OTS_ServerInfo.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/libs/pot/OTS_ServerInfo.php b/system/libs/pot/OTS_ServerInfo.php index 591443e9..1f01d028 100644 --- a/system/libs/pot/OTS_ServerInfo.php +++ b/system/libs/pot/OTS_ServerInfo.php @@ -92,6 +92,8 @@ class OTS_ServerInfo return new OTS_Buffer($data); } + log_append('status-error.log', "Cannot connect to {$this->server}:{$this->port} - Error code: $error, message: $message"); + return false; } From 2e50f8f81cfd1bfe763c6ed8e329c89b69604865 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 30 Jan 2026 22:40:58 +0100 Subject: [PATCH 7/7] Fix $status['uptimeReadable'], was totally wrong --- system/functions.php | 37 +++++++++++++++++++++++++++++++++++++ system/status.php | 8 +------- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/system/functions.php b/system/functions.php index 0278882b..0d26f89c 100644 --- a/system/functions.php +++ b/system/functions.php @@ -1335,6 +1335,43 @@ function getDatabasePages($withHidden = false): array return $ret; } +function getStatusUptimeReadable(int $uptime): string +{ + $fullMinute = 60; + $fullHour = (60 * $fullMinute); + $fullDay = (24 * $fullHour); + $fullMonth = (30 * $fullDay); + $fullYear = (365 * $fullDay); + + // years + $years = floor($uptime / $fullYear); + $y = ($years > 1 ? "$years years, " : ($years == 1 ? 'year, ' : '')); + + $uptime -= $years * $fullYear; + + // months + $months = floor($uptime / $fullMonth); + $m = ($months > 1 ? "$months months, " : ($months == 1 ? 'month, ' : '')); + + $uptime -= $months * $fullMonth; + + // days + $days = floor($uptime / $fullDay); + $d = ($days > 1 ? "$days days, " : ($days == 1 ? 'day, ' : '')); + + $uptime -= $days * $fullDay; + + // hours + $hours = floor($uptime / $fullHour); + + $uptime -= $hours * $fullHour; + + // minutes + $min = floor($uptime / $fullMinute); + + return "{$y}{$m}{$d}{$hours}h {$min}m"; +} + // validator functions require_once LIBS . 'validator.php'; require_once SYSTEM . 'compat/base.php'; diff --git a/system/status.php b/system/status.php index e3fcaf5a..08304cf8 100644 --- a/system/status.php +++ b/system/status.php @@ -143,13 +143,7 @@ function updateStatus() { } $uptime = $status['uptime'] = $serverStatus->getUptime(); - $m = date('m', $uptime); - $m = $m > 1 ? "$m months, " : ($m == 1 ? 'month, ' : ''); - $d = date('d', $uptime); - $d = $d > 1 ? "$d days, " : ($d == 1 ? 'day, ' : ''); - $h = date('H', $uptime); - $min = date('i', $uptime); - $status['uptimeReadable'] = "{$m}{$d}{$h}h {$min}m"; + $status['uptimeReadable'] = getStatusUptimeReadable($uptime); $status['monsters'] = $serverStatus->getMonstersCount(); $status['motd'] = $serverStatus->getMOTD();