mirror of
https://github.com/torrentpier/torrentpier
synced 2025-07-05 12:36:12 -07:00
* feat: implement centralized Config class to replace global $bb_cfg array - Add singleton Config class with dot notation support for nested configuration - Implement thread-safe configuration access with magic methods (__get, __set, __isset) - Add global config() helper function for convenient access - Support for getSection(), merge(), has(), all() methods with type safety BREAKING CHANGE: While $bb_cfg global array still works for backward compatibility, new code should use config()->get() method with dot notation Updated files: - src/Config.php: New Config singleton class implementation - common.php: Initialize Config singleton and add global helper - src/Emailer.php: Replace $bb_cfg with config()->get() - src/Ajax.php: Replace $bb_cfg with config()->get() - src/Censor.php: Replace $bb_cfg with config()->get() - src/Validate.php: Replace $bb_cfg with config()->get() - src/Dev.php: Replace $bb_cfg with config()->get() - src/Sitemap.php: Replace $bb_cfg with config()->get() - src/TorrServerAPI.php: Replace $bb_cfg with config()->get() - src/Sessions.php: Replace $bb_cfg with config()->get() - src/Legacy/TorrentFileList.php: Replace $bb_cfg with config()->get() - src/Legacy/Poll.php: Replace $bb_cfg with config()->get() - src/Legacy/Torrent.php: Replace $bb_cfg with config()->get() - src/Legacy/Common/User.php: Replace $bb_cfg with config()->get() - src/Legacy/Template.php: Replace $bb_cfg with config()->get() - src/Legacy/Atom.php: Replace $bb_cfg with config()->get() - src/Legacy/Admin/Common.php: Replace $bb_cfg with config()->get() - viewforum.php: Replace $bb_cfg with config()->get() - posting.php: Replace $bb_cfg with config()->get() - dl.php: Replace $bb_cfg with config()->get() - feed.php: Replace $bb_cfg with config()->get() - filelist.php: Replace $bb_cfg with config()->get() - group_edit.php: Replace $bb_cfg with config()->get() - group.php: Replace $bb_cfg with config()->get() - index.php: Replace $bb_cfg with config()->get() - login.php: Replace $bb_cfg with config()->get() - memberlist.php: Replace $bb_cfg with config()->get() - modcp.php: Replace $bb_cfg with config()->get() - playback_m3u.php: Replace $bb_cfg with config()->get() - poll.php: Replace $bb_cfg with config()->get() * refactor: replace $bb_cfg with config() in various admin files - Updated multiple admin files to utilize the new Config class for configuration access. - Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency. - Ensured backward compatibility while transitioning to the new configuration system. Files modified: - common.php - index.php - admin_attach_cp.php - admin_log.php - admin_mass_email.php - admin_sitemap.php - admin_smilies.php - admin_terms.php - admin_user_search.php - admin_words.php - admin/index.php - admin/stats/tracker.php * refactor: update init_bb.php to use config() for configuration management - Replaced the merging of $bb_cfg with a call to config()->merge() for improved clarity and maintainability. - Updated the retrieval of all configuration settings to use config()->all(). This change continues the transition towards a centralized configuration system. * refactor: replace $bb_cfg with config() in various files - Updated multiple files to utilize the new Config class for configuration access. - Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency. - Ensured backward compatibility while transitioning to the new configuration system. Files modified: - privmsg.php - search.php - terms.php - tracker.php - viewtopic.php - bt/announce.php - bt/scrape.php - bt/includes/init_tr.php - library/ajax/*.php - src/Config.php * refactor: replace $bb_cfg with config() in attachment and display files - Updated multiple files to utilize the new Config class for configuration access. - Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency. - Ensured backward compatibility while transitioning to the new configuration system. Files modified: - attachment_mod.php - displaying_torrent.php - functions_delete.php - bbcode.php - functions.php - init_bb.php - online_userlist.php - page_footer.php - page_header.php - torrent_show_dl_list.php - cron jobs (various files) - datastore build files (various files) * refactor: replace $bb_cfg with config() in user control panel files - Updated multiple user control panel files to utilize the new Config class for configuration access. - Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency. - Ensured backward compatibility while transitioning to the new configuration system. Files modified: - bonus.php - email.php - register.php - sendpasswd.php - topic_watch.php - viewprofile.php * refactor: replace $bb_cfg with config() in various legacy files - Updated multiple legacy files to utilize the new Config class for configuration access. - Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency. - Ensured backward compatibility while transitioning to the new configuration system. Files modified: - sidebar2.html - BBCode.php - LogAction.php - Post.php - Template.php - Torrent.php - Common/User.php - Common/Select.php - Common/Upload.php - Admin/Common.php - tpl_config.php * refactor: remove legacy DOCUMENTATION.md and add UPGRADE_GUIDE.md - Deleted the outdated DOCUMENTATION.md file, which contained legacy configuration information. - Introduced a new UPGRADE_GUIDE.md to assist users in migrating to the new configuration system. - The upgrade guide includes migration strategies, breaking changes, and best practices for using the new Config class. Files modified: - DOCUMENTATION.md (deleted) - UPGRADE_GUIDE.md (new) * refactor: update legacy files to maintain compatibility with bb_cfg deprecation - Added comments in init_bb.php, Template.php, and Cron.php to indicate that bb_cfg is deprecated but retained for compatibility with non-adapted code. - Ensured clarity in documentation for future reference while transitioning to the new configuration system. Files modified: - init_bb.php - Template.php - Cron.php
152 lines
5.6 KiB
PHP
152 lines
5.6 KiB
PHP
<?php
|
||
/**
|
||
* TorrentPier – Bull-powered BitTorrent tracker engine
|
||
*
|
||
* @copyright Copyright (c) 2005-2025 TorrentPier (https://torrentpier.com)
|
||
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
|
||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||
*/
|
||
|
||
define('BB_SCRIPT', 'memberlist');
|
||
|
||
require __DIR__ . '/common.php';
|
||
|
||
$user->session_start(['req_login' => true]);
|
||
|
||
$start = abs((int)request_var('start', 0));
|
||
$mode = (string)request_var('mode', 'joined');
|
||
$sort_order = (request_var('order', 'ASC') == 'ASC') ? 'ASC' : 'DESC';
|
||
$username = trim(request_var('username', ''));
|
||
$role = (string)request_var('role', 'all');
|
||
|
||
// Memberlist sorting
|
||
$mode_types_text = [$lang['SORT_JOINED'], $lang['SORT_USERNAME'], $lang['SORT_LOCATION'], $lang['SORT_POSTS'], $lang['SORT_EMAIL'], $lang['SORT_WEBSITE'], $lang['SORT_TOP_TEN']];
|
||
$mode_types = ['joined', 'username', 'location', 'posts', 'email', 'website', 'topten'];
|
||
|
||
$select_sort_mode = '<select name="mode">';
|
||
for ($i = 0, $iMax = count($mode_types_text); $i < $iMax; $i++) {
|
||
$selected = ($mode == $mode_types[$i]) ? ' selected' : '';
|
||
$select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
|
||
}
|
||
$select_sort_mode .= '</select>';
|
||
|
||
$select_sort_order = '<select name="order">';
|
||
if ($sort_order == 'ASC') {
|
||
$select_sort_order .= '<option value="ASC" selected>' . $lang['ASC'] . '</option><option value="DESC">' . $lang['DESC'] . '</option>';
|
||
} else {
|
||
$select_sort_order .= '<option value="ASC">' . $lang['ASC'] . '</option><option value="DESC" selected>' . $lang['DESC'] . '</option>';
|
||
}
|
||
$select_sort_order .= '</select>';
|
||
|
||
// Role selector
|
||
$role_select = [
|
||
'all' => $lang['ALL'],
|
||
'user' => $lang['AUTH_USER'],
|
||
'admin' => $lang['AUTH_ADMIN'],
|
||
'moderator' => $lang['MODERATOR']
|
||
];
|
||
$select_sort_role = '<select name="role">';
|
||
foreach ($role_select as $key => $value) {
|
||
$selected = ($role == $key) ? ' selected' : '';
|
||
$select_sort_role .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
|
||
}
|
||
$select_sort_role .= '</select>';
|
||
|
||
switch ($mode) {
|
||
case 'username':
|
||
$order_by = "username $sort_order LIMIT $start, " . config()->get('topics_per_page');
|
||
break;
|
||
case 'location':
|
||
$order_by = "user_from $sort_order LIMIT $start, " . config()->get('topics_per_page');
|
||
break;
|
||
case 'posts':
|
||
$order_by = "user_posts $sort_order LIMIT $start, " . config()->get('topics_per_page');
|
||
break;
|
||
case 'email':
|
||
$order_by = "user_email $sort_order LIMIT $start, " . config()->get('topics_per_page');
|
||
break;
|
||
case 'website':
|
||
$order_by = "user_website $sort_order LIMIT $start, " . config()->get('topics_per_page');
|
||
break;
|
||
case 'topten':
|
||
$order_by = "user_posts $sort_order LIMIT 10";
|
||
break;
|
||
case 'joined':
|
||
default:
|
||
$order_by = "user_regdate $sort_order LIMIT $start, " . config()->get('topics_per_page');
|
||
break;
|
||
}
|
||
|
||
$where_sql = '';
|
||
|
||
// Search by role
|
||
switch ($role) {
|
||
case 'user':
|
||
$where_sql .= ' AND user_level = ' . USER;
|
||
break;
|
||
case 'admin':
|
||
$where_sql .= ' AND user_level = ' . ADMIN;
|
||
break;
|
||
case 'moderator':
|
||
$where_sql .= ' AND user_level = ' . MOD;
|
||
break;
|
||
}
|
||
|
||
// Search by username
|
||
if (!empty($username)) {
|
||
$where_sql .= ' AND username LIKE "' . DB()->escape(str_replace('*', '%', clean_username($username))) . '"';
|
||
}
|
||
|
||
// Generate user information
|
||
$sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email, avatar_ext_id FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ") $where_sql ORDER BY $order_by";
|
||
if ($result = DB()->fetch_rowset($sql)) {
|
||
foreach ($result as $i => $row) {
|
||
$user_id = $row['user_id'];
|
||
$user_info = generate_user_info($row);
|
||
|
||
$row_class = !($i % 2) ? 'row1' : 'row2';
|
||
$template->assign_block_vars('memberrow', [
|
||
'ROW_NUMBER' => $i + ($start + 1),
|
||
'ROW_CLASS' => $row_class,
|
||
'USER' => profile_url($row),
|
||
'AVATAR' => $user_info['avatar'],
|
||
'FROM' => $user_info['from'],
|
||
'JOINED' => $user_info['joined'],
|
||
'POSTS' => $user_info['posts'],
|
||
'PM' => $user_info['pm'],
|
||
'EMAIL' => $user_info['email'],
|
||
'WWW' => $user_info['www'],
|
||
'U_VIEWPROFILE' => PROFILE_URL . $user_id
|
||
]);
|
||
}
|
||
} else {
|
||
$template->assign_block_vars('no_username', ['NO_USER_ID_SPECIFIED' => $lang['NO_USER_ID_SPECIFIED']]);
|
||
}
|
||
|
||
// Pagination
|
||
$paginationurl = "memberlist.php?mode=$mode&order=$sort_order&role=$role";
|
||
$paginationurl .= !empty($username) ? "&username=$username" : '';
|
||
|
||
if ($mode != 'topten') {
|
||
$sql = "SELECT COUNT(*) AS total FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ") $where_sql";
|
||
if (!$result = DB()->sql_query($sql)) {
|
||
bb_die('Error getting total users');
|
||
}
|
||
if ($total = DB()->sql_fetchrow($result)) {
|
||
$total_members = $total['total'];
|
||
generate_pagination($paginationurl, $total_members, config()->get('topics_per_page'), $start);
|
||
}
|
||
DB()->sql_freeresult($result);
|
||
}
|
||
|
||
// Generate output
|
||
$template->assign_vars([
|
||
'PAGE_TITLE' => $lang['MEMBERLIST'],
|
||
'S_MODE_SELECT' => $select_sort_mode,
|
||
'S_ORDER_SELECT' => $select_sort_order,
|
||
'S_ROLE_SELECT' => $select_sort_role,
|
||
'S_MODE_ACTION' => "memberlist.php?mode=$mode&order=$sort_order&role=$role",
|
||
'S_USERNAME' => $username,
|
||
]);
|
||
|
||
print_page('memberlist.tpl');
|