diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f83c59f4..eecc32916 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@
- Fixed issue with poll_users cleaning at every cron job startup [\#1390](https://github.com/torrentpier/torrentpier/pull/1390) ([belomaxorka](https://github.com/belomaxorka))
- Improved word censor 🤐 [\#1393](https://github.com/torrentpier/torrentpier/pull/1393) ([belomaxorka](https://github.com/belomaxorka))
- Used hashing for filenames generation [\#1385](https://github.com/torrentpier/torrentpier/pull/1385) ([belomaxorka](https://github.com/belomaxorka))
-- Minor improvements [\#1382](https://github.com/torrentpier/torrentpier/pull/1382), [\#1383](https://github.com/torrentpier/torrentpier/pull/1383), [\#1391](https://github.com/torrentpier/torrentpier/pull/1391), [\#1394](https://github.com/torrentpier/torrentpier/pull/1394) ([belomaxorka](https://github.com/belomaxorka))
+- Minor improvements [\#1382](https://github.com/torrentpier/torrentpier/pull/1382), [\#1383](https://github.com/torrentpier/torrentpier/pull/1383), [\#1391](https://github.com/torrentpier/torrentpier/pull/1391) ([belomaxorka](https://github.com/belomaxorka))
- Some bugfixes [\#1380](https://github.com/torrentpier/torrentpier/pull/1380) ([belomaxorka](https://github.com/belomaxorka))
- New Crowdin updates [\#1384](https://github.com/torrentpier/torrentpier/pull/1384), [\#1389](https://github.com/torrentpier/torrentpier/pull/1389), [\#1392](https://github.com/torrentpier/torrentpier/pull/1392) ([Exileum](https://github.com/Exileum))
diff --git a/library/includes/functions.php b/library/includes/functions.php
index ff43a727c..927bbd0f0 100644
--- a/library/includes/functions.php
+++ b/library/includes/functions.php
@@ -2172,44 +2172,24 @@ function send_pm($user_id, $subject, $message, $poster_id = BOT_UID)
DB()->query("UPDATE " . BB_USERS . " SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . TIMENOW . ", user_newest_pm_id = $pm_id WHERE user_id = $user_id");
}
-/**
- * Generates link to profile
- *
- * @param array $data
- * @param bool $target_blank
- * @return string
- */
-function profile_url(array $data, bool $target_blank = false): string
+function profile_url($data, $target_blank = false)
{
global $bb_cfg, $lang, $datastore;
- $user_id = (int)$data['user_id'];
- $username = $data['username'];
- $user_rank = $data['user_rank'];
-
if (!$ranks = $datastore->get('ranks')) {
$datastore->update('ranks');
$ranks = $datastore->get('ranks');
}
- $title = $style = '';
+ $user_rank = !empty($data['user_rank']) ? $data['user_rank'] : 0;
+
if (isset($ranks[$user_rank])) {
$title = $ranks[$user_rank]['rank_title'];
$style = $ranks[$user_rank]['rank_style'];
}
-
- if (empty($username)) {
- $username = $lang['GUEST'];
- }
-
if (empty($title)) {
- $title = match ($user_id) {
- GUEST_UID => $lang['GUEST'],
- BOT_UID => $username,
- default => $lang['USER'],
- };
+ $title = $lang['USER'];
}
-
if (empty($style)) {
$style = 'colorUser';
}
@@ -2218,12 +2198,16 @@ function profile_url(array $data, bool $target_blank = false): string
$style = '';
}
+ $username = !empty($data['username']) ? $data['username'] : $lang['GUEST'];
+ $user_id = (!empty($data['user_id']) && $username != $lang['GUEST']) ? $data['user_id'] : GUEST_UID;
+
$profile = '' . $username . '';
- if (!in_array($user_id, explode(',', EXCLUDED_USERS))) {
+
+ if (!in_array($user_id, explode(',', EXCLUDED_USERS)) && $username) {
$target_blank = $target_blank ? ' target="_blank" ' : '';
$profile = '' . $profile . '';
- if (getBanInfo($user_id)) {
+ if (getBanInfo((int)$user_id)) {
return '' . $profile . '';
}
}
diff --git a/viewtopic.php b/viewtopic.php
index e55a145ef..b02d87bd1 100644
--- a/viewtopic.php
+++ b/viewtopic.php
@@ -578,7 +578,7 @@ for ($i = 0; $i < $total_posts; $i++) {
$rg_signature = $postrow[$i]['group_signature'] ? bbcode2html(htmlCHR($postrow[$i]['group_signature'])) : '';
$poster_avatar = '';
- if ((!$user->opt_js['h_av'] || $poster_bot) && !$poster_guest) {
+ if (!$user->opt_js['h_av'] && !$poster_guest) {
$poster_avatar = get_avatar($poster_id, $postrow[$i]['avatar_ext_id'], !bf($postrow[$i]['user_opt'], 'user_opt', 'dis_avatar'));
}
@@ -649,7 +649,7 @@ for ($i = 0; $i < $total_posts; $i++) {
// Editing information
if ($postrow[$i]['post_edit_count']) {
$l_edit_time_total = ($postrow[$i]['post_edit_count'] == 1) ? $lang['EDITED_TIME_TOTAL'] : $lang['EDITED_TIMES_TOTAL'];
- $l_edited_by = '
' . sprintf($l_edit_time_total, profile_url(['username' => $poster, 'user_id' => $poster_id, 'user_rank' => $user_rank]), bb_date($postrow[$i]['post_edit_time']), $postrow[$i]['post_edit_count']);
+ $l_edited_by = '
' . sprintf($l_edit_time_total, $poster, bb_date($postrow[$i]['post_edit_time']), $postrow[$i]['post_edit_count']);
} else {
$l_edited_by = '';
}
@@ -676,7 +676,7 @@ for ($i = 0; $i < $total_posts; $i++) {
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'POST_ID' => $post_id,
'IS_NEWEST' => ($post_id == $newest),
- 'POSTER_NAME' => profile_url(['username' => $poster, 'user_id' => $poster_id, 'user_rank' => $user_rank]),
+ 'POSTER_NAME' => profile_url(['username' => $poster, 'user_rank' => $user_rank]),
'POSTER_NAME_JS' => addslashes($poster),
'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image,