mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Code refactoring (#1441)
* Code refactoring * Update viewtopic.php * Update viewforum.php * Update posting.php * Update viewtopic.php * Revert "Code refactoring" This reverts commite4ac08e377
. * Revert "Update viewforum.php" This reverts commit1ee6321385
. * Update viewforum.php * Update viewtopic.php * Update viewtopic.php * Update viewtopic.php * Update viewtopic.php * Update dl_list.php * Update posting.php * Update posting.php * Update posting.php * Update viewprofile.php * Update email.php * Update viewtopic.php * Update functions.php * Update posting.php * Update viewtopic.php * Update CHANGELOG.md
This commit is contained in:
parent
8ba00d5966
commit
2472608c6d
8 changed files with 19 additions and 29 deletions
|
@ -8,6 +8,7 @@
|
|||
- Release 2.4.3 🐎 ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Improved app debug [\#1438](https://github.com/torrentpier/torrentpier/pull/1438) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Demo mode: Allow registering torrents by default [\#1440](https://github.com/torrentpier/torrentpier/pull/1440) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Code refactoring [\#1441](https://github.com/torrentpier/torrentpier/pull/1441) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Minor improvements [\#1435](https://github.com/torrentpier/torrentpier/pull/1435) ([belomaxorka](https://github.com/belomaxorka))
|
||||
|
||||
## [v2.4.2](https://github.com/torrentpier/torrentpier/tree/v2.4.2) (2024-03-30)
|
||||
|
|
|
@ -52,7 +52,7 @@ $user->session_start();
|
|||
set_die_append_msg();
|
||||
|
||||
// Check if user logged in
|
||||
if (!$userdata['session_logged_in']) {
|
||||
if (IS_GUEST) {
|
||||
redirect(LOGIN_URL . "?redirect=$redirect_type&$redirect");
|
||||
}
|
||||
|
||||
|
|
|
@ -1115,7 +1115,7 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
|
|||
require_once($bb_cfg['default_lang_dir'] . 'main.php');
|
||||
}
|
||||
|
||||
if (empty($userdata['session_logged_in'])) {
|
||||
if (!defined('IS_GUEST') || IS_GUEST) {
|
||||
$tz = $bb_cfg['board_timezone'];
|
||||
} else {
|
||||
$tz = $userdata['user_timezone'];
|
||||
|
|
|
@ -24,7 +24,7 @@ if (!empty($_GET[POST_USERS_URL]) || !empty($_POST[POST_USERS_URL])) {
|
|||
bb_die($lang['NO_USER_SPECIFIED']);
|
||||
}
|
||||
|
||||
if (!$userdata['session_logged_in']) {
|
||||
if (IS_GUEST) {
|
||||
redirect(LOGIN_URL . "?redirect=profile.php&mode=email&" . POST_USERS_URL . "=$user_id");
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ $datastore->enqueue([
|
|||
'cat_forums'
|
||||
]);
|
||||
|
||||
if (!$userdata['session_logged_in']) {
|
||||
if (IS_GUEST) {
|
||||
redirect(LOGIN_URL . "?redirect={$_SERVER['REQUEST_URI']}");
|
||||
} else {
|
||||
if (empty($_GET[POST_USERS_URL])) {
|
||||
|
|
12
posting.php
12
posting.php
|
@ -120,10 +120,10 @@ switch ($mode) {
|
|||
}
|
||||
|
||||
$select_sql = 'SELECT f.*, t.*, p.*';
|
||||
$select_sql .= (!$submit) ? ', pt.*, u.username, u.user_id' : '';
|
||||
$select_sql .= !$submit ? ', pt.*, u.username, u.user_id' : '';
|
||||
|
||||
$from_sql = "FROM " . BB_POSTS . " p, " . BB_TOPICS . " t, " . BB_FORUMS . " f";
|
||||
$from_sql .= (!$submit) ? ", " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u" : '';
|
||||
$from_sql .= !$submit ? ", " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u" : '';
|
||||
|
||||
$where_sql = "
|
||||
WHERE p.post_id = $post_id
|
||||
|
@ -446,10 +446,10 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) {
|
|||
} else {
|
||||
// User default entry point
|
||||
if ($mode == 'newtopic') {
|
||||
$username = ($userdata['session_logged_in']) ? $userdata['username'] : '';
|
||||
$username = !IS_GUEST ? $userdata['username'] : '';
|
||||
$subject = $message = '';
|
||||
} elseif ($mode == 'reply') {
|
||||
$username = ($userdata['session_logged_in']) ? $userdata['username'] : '';
|
||||
$username = !IS_GUEST ? $userdata['username'] : '';
|
||||
$subject = $message = '';
|
||||
} elseif ($mode == 'quote' || $mode == 'editpost') {
|
||||
$subject = ($post_data['first_post']) ? $post_info['topic_title'] : '';
|
||||
|
@ -539,7 +539,7 @@ if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_ty
|
|||
|
||||
$dl_ds = $dl_ch = $dl_hid = '';
|
||||
$dl_type_name = 'topic_dl_type';
|
||||
$dl_type_val = ($topic_dl_type) ? 1 : 0;
|
||||
$dl_type_val = $topic_dl_type ? 1 : 0;
|
||||
|
||||
if (!$post_info['allow_reg_tracker'] && !$is_auth['auth_mod']) {
|
||||
$dl_ds = ' disabled ';
|
||||
|
@ -612,7 +612,7 @@ $template->assign_vars([
|
|||
'SUBJECT' => $subject,
|
||||
'MESSAGE' => $message,
|
||||
|
||||
'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '',
|
||||
'POSTER_RGROUPS' => !empty($poster_rgroups) ? $poster_rgroups : '',
|
||||
'ATTACH_RG_SIG' => ($switch_rg_sig) ?: false,
|
||||
|
||||
'U_VIEWTOPIC' => ($mode == 'reply') ? TOPIC_URL . "$topic_id&postorder=desc" : '',
|
||||
|
|
|
@ -289,7 +289,7 @@ if ($forum_data['allow_reg_tracker']) {
|
|||
bt.auth_key, tor.info_hash, tor.info_hash_v2, tor.size AS tor_size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.attach_id, tor.tor_status, tor.tor_type,
|
||||
sn.seeders, sn.leechers, ad.download_count
|
||||
';
|
||||
$select_tor_sql .= ($join_dl) ? ', dl.user_status AS dl_status' : '';
|
||||
$select_tor_sql .= $join_dl ? ', dl.user_status AS dl_status' : '';
|
||||
|
||||
$join_tor_sql = "
|
||||
LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)
|
||||
|
@ -297,7 +297,7 @@ if ($forum_data['allow_reg_tracker']) {
|
|||
LEFT JOIN " . BB_BT_TRACKER_SNAP . " sn ON(tor.topic_id = sn.topic_id)
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " ad ON(tor.attach_id = ad.attach_id)
|
||||
";
|
||||
$join_tor_sql .= ($join_dl) ? " LEFT JOIN " . BB_BT_DLSTATUS . " dl ON(dl.user_id = {$userdata['user_id']} AND dl.topic_id = t.topic_id)" : '';
|
||||
$join_tor_sql .= $join_dl ? " LEFT JOIN " . BB_BT_DLSTATUS . " dl ON(dl.user_id = {$userdata['user_id']} AND dl.topic_id = t.topic_id)" : '';
|
||||
}
|
||||
|
||||
// Title match
|
||||
|
@ -404,7 +404,7 @@ $template->assign_vars([
|
|||
'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS),
|
||||
|
||||
'TITLE_MATCH' => htmlCHR($title_match),
|
||||
'SELECT_TPP' => ($select_tpp) ? build_select('tpp', $select_tpp, $topics_per_page, null, null, 'onchange="$(\'#tpp\').submit();"') : '',
|
||||
'SELECT_TPP' => $select_tpp ? build_select('tpp', $select_tpp, $topics_per_page, null, null, 'onchange="$(\'#tpp\').submit();"') : '',
|
||||
'T_POST_NEW_TOPIC' => ($forum_data['forum_status'] == FORUM_LOCKED) ? $lang['FORUM_LOCKED'] : $post_new_topic,
|
||||
'S_AUTH_LIST' => $u_auth,
|
||||
'U_VIEW_FORUM' => FORUM_URL . $forum_id,
|
||||
|
|
|
@ -228,31 +228,22 @@ if ($post_id && !empty($t_data['prev_posts'])) {
|
|||
$can_watch_topic = $is_watching_topic = false;
|
||||
|
||||
if ($bb_cfg['topic_notify_enabled']) {
|
||||
if ($userdata['session_logged_in']) {
|
||||
if (!IS_GUEST) {
|
||||
$can_watch_topic = true;
|
||||
|
||||
if (!empty($t_data['notify_status']) && $t_data['notify_status']) {
|
||||
if ($t_data['notify_status'] == TOPIC_WATCH_NOTIFIED) {
|
||||
$is_watching_topic = true;
|
||||
if (isset($_GET['unwatch'])) {
|
||||
if ($_GET['unwatch'] == 'topic') {
|
||||
$is_watching_topic = 0;
|
||||
|
||||
DB()->query("DELETE FROM " . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}");
|
||||
}
|
||||
|
||||
set_die_append_msg($forum_id, $topic_id);
|
||||
bb_die($lang['NO_LONGER_WATCHING']);
|
||||
} else {
|
||||
$is_watching_topic = true;
|
||||
|
||||
if (!$t_data['notify_status']) {
|
||||
DB()->query("UPDATE " . BB_TOPICS_WATCH . " SET notify_status = " . TOPIC_WATCH_NOTIFIED . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} elseif ($t_data['notify_status'] == TOPIC_WATCH_UNNOTIFIED) {
|
||||
if (isset($_GET['watch'])) {
|
||||
if ($_GET['watch'] == 'topic') {
|
||||
$is_watching_topic = true;
|
||||
|
||||
DB()->query("
|
||||
INSERT INTO " . BB_TOPICS_WATCH . " (user_id, topic_id, notify_status)
|
||||
VALUES (" . $userdata['user_id'] . ", $topic_id, " . TOPIC_WATCH_NOTIFIED . ")
|
||||
|
@ -261,8 +252,6 @@ if ($bb_cfg['topic_notify_enabled']) {
|
|||
|
||||
set_die_append_msg($forum_id, $topic_id);
|
||||
bb_die($lang['YOU_ARE_WATCHING']);
|
||||
} else {
|
||||
$is_watching_topic = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -408,7 +397,7 @@ if ($is_auth['auth_mod']) {
|
|||
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&mode=set_download&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_dl'] . '" alt="' . $lang['SET_DL_STATUS'] . '" title="' . $lang['SET_DL_STATUS'] . '" border="0" /></a>';
|
||||
}
|
||||
}
|
||||
} elseif (($t_data['topic_poster'] == $userdata['user_id']) && $userdata['session_logged_in'] && $t_data['self_moderated']) {
|
||||
} elseif (!IS_GUEST && ($t_data['topic_poster'] == $userdata['user_id']) && $t_data['self_moderated']) {
|
||||
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&mode=move&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['MOVE_TOPIC'] . '" title="' . $lang['MOVE_TOPIC'] . '" border="0" /></a> ';
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue