From 83b465ddd21af1f05585cebcd265ff16f670eba9 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 7 Dec 2024 20:29:21 +0700 Subject: [PATCH] Merged some fixes from `new-attachments` branch (#1700) * Merged some fixes from `new-attachments` branch * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/ajax/change_user_rank.php | 2 +- library/ajax/edit_group_profile.php | 2 +- library/ajax/edit_user_profile.php | 2 +- library/ajax/index_data.php | 6 +++--- library/ajax/topic_tpl.php | 4 ++-- library/includes/functions.php | 2 +- modcp.php | 2 +- posting.php | 2 ++ 9 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 286d65b72..d7b0c0bfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Show torrent unregister action in log actions [\#1696](https://github.com/torrentpier/torrentpier/pull/1696) ([belomaxorka](https://github.com/belomaxorka)) - Show torrent status changes in actions log [\#1688](https://github.com/torrentpier/torrentpier/pull/1688) ([belomaxorka](https://github.com/belomaxorka)) - Show torrent type (gold / silver) changes in actions log [\#1689](https://github.com/torrentpier/torrentpier/pull/1689) ([belomaxorka](https://github.com/belomaxorka)) +- Merged some fixes from `new-attachments` branch [\#1700](https://github.com/torrentpier/torrentpier/pull/1700) ([belomaxorka](https://github.com/belomaxorka)) - Changed database encoding to `utf8mb4_unicode_ci` [\#1684](https://github.com/torrentpier/torrentpier/pull/1684) ([belomaxorka](https://github.com/belomaxorka)) - Demo mode: Save user language in cookies [\#1584](https://github.com/torrentpier/torrentpier/pull/1584) ([belomaxorka](https://github.com/belomaxorka)) - Make `get_torrent_info()` as public method for re-use [\#1697](https://github.com/torrentpier/torrentpier/pull/1697) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/library/ajax/change_user_rank.php b/library/ajax/change_user_rank.php index 417000098..977eb41d5 100644 --- a/library/ajax/change_user_rank.php +++ b/library/ajax/change_user_rank.php @@ -28,7 +28,7 @@ if ($rank_id != 0 && !isset($ranks[$rank_id])) { $this->ajax_die("invalid rank_id: $rank_id"); } -DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id"); +DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id LIMIT 1"); \TorrentPier\Sessions::cache_rm_user_sessions($user_id); diff --git a/library/ajax/edit_group_profile.php b/library/ajax/edit_group_profile.php index c9c98df52..94b7fcfb7 100644 --- a/library/ajax/edit_group_profile.php +++ b/library/ajax/edit_group_profile.php @@ -51,4 +51,4 @@ switch ($mode) { } $value_sql = DB()->escape($value, true); -DB()->query("UPDATE " . BB_GROUPS . " SET $mode = $value_sql WHERE group_id = $group_id"); +DB()->query("UPDATE " . BB_GROUPS . " SET $mode = $value_sql WHERE group_id = $group_id LIMIT 1"); diff --git a/library/ajax/edit_user_profile.php b/library/ajax/edit_user_profile.php index 17cf223be..95bb5c659 100644 --- a/library/ajax/edit_user_profile.php +++ b/library/ajax/edit_user_profile.php @@ -152,7 +152,7 @@ switch ($field) { } $value_sql = DB()->escape($value, true); -DB()->query("UPDATE $table SET $field = $value_sql WHERE user_id = $user_id"); +DB()->query("UPDATE $table SET $field = $value_sql WHERE user_id = $user_id LIMIT 1"); \TorrentPier\Sessions::cache_rm_user_sessions($user_id); diff --git a/library/ajax/index_data.php b/library/ajax/index_data.php index 9508e58c1..91864c5e6 100644 --- a/library/ajax/index_data.php +++ b/library/ajax/index_data.php @@ -170,7 +170,7 @@ switch ($mode) { ' . $lang['UPLOADED'] . ' ' . $lang['RELEASED'] . ' ' . $lang['BONUS'] . ''; - $html .= ($bb_cfg['seed_bonus_enabled']) ? '' . $lang['SEED_BONUS'] . '' : ''; + $html .= $bb_cfg['seed_bonus_enabled'] ? '' . $lang['SEED_BONUS'] . '' : ''; $html .= ' ' . $lang['TOTAL_TRAF'] . ' @@ -178,13 +178,13 @@ switch ($mode) { ' . humn_size($btu['u_up_total']) . ' ' . humn_size($btu['u_up_release']) . ' ' . humn_size($btu['u_up_bonus']) . ''; - $html .= ($bb_cfg['seed_bonus_enabled']) ? '' . $profiledata['user_points'] . '' : ''; + $html .= $bb_cfg['seed_bonus_enabled'] ? '' . $profiledata['user_points'] . '' : ''; $html .= ' ' . $lang['MAX_SPEED'] . ' ' . $lang['DL_DL_SPEED'] . ': ' . $speed_down . ' ' . $lang['DL_UL_SPEED'] . ': ' . $speed_up . ''; - $html .= ($bb_cfg['seed_bonus_enabled']) ? '' : ''; + $html .= $bb_cfg['seed_bonus_enabled'] ? '' : ''; $html .= ''; $this->response['user_ratio'] = ' diff --git a/library/ajax/topic_tpl.php b/library/ajax/topic_tpl.php index a2f75d22f..70f47e161 100644 --- a/library/ajax/topic_tpl.php +++ b/library/ajax/topic_tpl.php @@ -116,7 +116,7 @@ switch ($mode) { $new_tpl_id = $tpl_id; $this->response['msg'] = "Включен шаблон $tpl_name"; } - DB()->query("UPDATE " . BB_FORUMS . " SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id"); + DB()->query("UPDATE " . BB_FORUMS . " SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id LIMIT 1"); break; // сохранение изменений @@ -127,7 +127,7 @@ switch ($mode) { $msg .= 'Шаблон был отредактирован: ' . html_ent_decode($last_edit_by_username) . ', ' . bb_date($tpl_data['tpl_last_edit_tm'], 'd-M-y H:i'); $this->ajax_die($msg); } - $sql = "UPDATE " . BB_TOPIC_TPL . " SET " . DB()->build_array('UPDATE', $sql_args) . " WHERE tpl_id = $tpl_id"; + $sql = "UPDATE " . BB_TOPIC_TPL . " SET " . DB()->build_array('UPDATE', $sql_args) . " WHERE tpl_id = $tpl_id LIMIT 1"; if (!DB()->query($sql)) { $sql_error = DB()->sql_error(); } diff --git a/library/includes/functions.php b/library/includes/functions.php index 383334b32..e5abd036e 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -254,7 +254,7 @@ function setbit(&$int, $bit_num, $on) All results are returned as associative arrays, even when a single auth type is specified. - If available you can send an array (either one or two dimensional) containing the + If available you can send an array (either one or two-dimensional) containing the forum auth levels, this will prevent the auth function having to do its own lookup */ diff --git a/modcp.php b/modcp.php index 73685d931..812b6ec42 100644 --- a/modcp.php +++ b/modcp.php @@ -355,7 +355,7 @@ switch ($mode) { case 'set_download': case 'unset_download': $set_download = ($mode == 'set_download'); - $new_dl_type = ($set_download) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL; + $new_dl_type = $set_download ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL; DB()->query(" UPDATE " . BB_TOPICS . " SET diff --git a/posting.php b/posting.php index adb1258c8..30ff09024 100644 --- a/posting.php +++ b/posting.php @@ -625,7 +625,9 @@ $template->assign_vars([ 'POSTER_RGROUPS' => !empty($poster_rgroups) ? $poster_rgroups : '', 'ATTACH_RG_SIG' => $switch_rg_sig ?: false, + // todo: remove (cuz unused) 'U_VIEWTOPIC' => ($mode == 'reply') ? TOPIC_URL . "$topic_id&postorder=desc" : '', + // todo: end 'S_NOTIFY_CHECKED' => $notify_user ? 'checked' : '', 'S_ROBOTS_CHECKED' => $robots_indexing ? 'checked' : '',