diff --git a/bt/announce.php b/bt/announce.php
index 91d9d1e23..ea1cca19a 100644
--- a/bt/announce.php
+++ b/bt/announce.php
@@ -11,8 +11,6 @@ define('IN_TRACKER', true);
define('BB_ROOT', './../');
require dirname(__DIR__) . '/common.php';
-global $bb_cfg;
-
// Check User-Agent for existence
$userAgent = (string)$_SERVER['HTTP_USER_AGENT'];
if (empty($userAgent)) {
@@ -20,8 +18,8 @@ if (empty($userAgent)) {
die;
}
-$announce_interval = $bb_cfg['announce_interval'];
-$passkey_key = $bb_cfg['passkey_key'];
+$announce_interval = config()->get('announce_interval');
+$passkey_key = config()->get('passkey_key');
// Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
@@ -67,10 +65,10 @@ if (strlen($peer_id) !== 20) {
}
// Check for client ban
-if ($bb_cfg['client_ban']['enabled']) {
+if (config()->get('client_ban.enabled')) {
$targetClient = [];
- foreach ($bb_cfg['client_ban']['clients'] as $clientId => $banReason) {
+ foreach (config()->get('client_ban.clients') as $clientId => $banReason) {
if (str_starts_with($peer_id, $clientId)) {
$targetClient = [
'peer_id' => $clientId,
@@ -80,7 +78,7 @@ if ($bb_cfg['client_ban']['enabled']) {
}
}
- if ($bb_cfg['client_ban']['only_allow_mode']) {
+ if (config()->get('client_ban.only_allow_mode')) {
if (empty($targetClient['peer_id'])) {
msg_die('Your BitTorrent client has been banned!');
}
@@ -131,7 +129,7 @@ if (
|| !is_numeric($port)
|| ($port < 1024 && !$stopped)
|| $port > 0xFFFF
- || (!empty($bb_cfg['disallowed_ports']) && in_array($port, $bb_cfg['disallowed_ports']))
+ || (!empty(config()->get('disallowed_ports')) && in_array($port, config()->get('disallowed_ports')))
) {
msg_die('Invalid port: ' . $port);
}
@@ -170,13 +168,13 @@ if (preg_match('/(Mozilla|Browser|Chrome|Safari|AppleWebKit|Opera|Links|Lynx|Bot
$ip = $_SERVER['REMOTE_ADDR'];
// 'ip' query handling
-if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip']) {
- if (!$bb_cfg['verify_reported_ip'] && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+if (!config()->get('ignore_reported_ip') && isset($_GET['ip']) && $ip !== $_GET['ip']) {
+ if (!config()->get('verify_reported_ip') && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$x_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if ($x_ip === $_GET['ip']) {
$filteredIp = filter_var($x_ip, FILTER_VALIDATE_IP);
- if ($filteredIp !== false && ($bb_cfg['allow_internal_ip'] || !filter_var($filteredIp, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) {
+ if ($filteredIp !== false && (config()->get('allow_internal_ip') || !filter_var($filteredIp, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) {
$ip = $filteredIp;
}
}
@@ -272,7 +270,7 @@ if ($lp_info) {
define('IS_MOD', !IS_GUEST && (int)$row['user_level'] === MOD);
define('IS_GROUP_MEMBER', !IS_GUEST && (int)$row['user_level'] === GROUP_MEMBER);
define('IS_USER', !IS_GUEST && (int)$row['user_level'] === USER);
- define('IS_SUPER_ADMIN', IS_ADMIN && isset($bb_cfg['super_admins'][$user_id]));
+ define('IS_SUPER_ADMIN', IS_ADMIN && isset(config()->get('super_admins')[$user_id]));
define('IS_AM', IS_ADMIN || IS_MOD);
$topic_id = $row['topic_id'];
$releaser = (int)($user_id == $row['poster_id']);
@@ -280,13 +278,13 @@ if ($lp_info) {
$tor_status = $row['tor_status'];
// Check tor status
- if (!IS_AM && isset($bb_cfg['tor_frozen'][$tor_status]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_status]) && $releaser)) {
+ if (!IS_AM && isset(config()->get('tor_frozen')[$tor_status]) && !(isset(config()->get('tor_frozen_author_download')[$tor_status]) && $releaser)) {
msg_die('Torrent frozen and cannot be downloaded');
}
// Check hybrid status
if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) {
- $stat_protocol = match ((int)$bb_cfg['tracker']['hybrid_stat_protocol']) {
+ $stat_protocol = match ((int)config()->get('tracker.hybrid_stat_protocol')) {
2 => substr($row['info_hash_v2'], 0, 20),
default => $row['info_hash'] // 1
};
@@ -296,7 +294,7 @@ if ($lp_info) {
}
// Ratio limits
- if ((RATIO_ENABLED || $bb_cfg['tracker']['limit_concurrent_ips']) && !$stopped) {
+ if ((RATIO_ENABLED || config()->get('tracker.limit_concurrent_ips')) && !$stopped) {
$user_ratio = get_bt_ratio($row);
if ($user_ratio === null) {
$user_ratio = 1;
@@ -304,10 +302,10 @@ if ($lp_info) {
$rating_msg = '';
if (!$seeder) {
- foreach ($bb_cfg['rating'] as $ratio => $limit) {
+ foreach (config()->get('rating') as $ratio => $limit) {
if ($user_ratio < $ratio) {
- $bb_cfg['tracker']['limit_active_tor'] = 1;
- $bb_cfg['tracker']['limit_leech_count'] = $limit;
+ config()->set('tracker.limit_active_tor', 1);
+ config()->set('tracker.limit_leech_count', $limit);
$rating_msg = " (ratio < $ratio)";
break;
}
@@ -315,29 +313,29 @@ if ($lp_info) {
}
// Limit active torrents
- if (!isset($bb_cfg['unlimited_users'][$user_id]) && $bb_cfg['tracker']['limit_active_tor'] && (($bb_cfg['tracker']['limit_seed_count'] && $seeder) || ($bb_cfg['tracker']['limit_leech_count'] && !$seeder))) {
+ if (!isset(config()->get('unlimited_users')[$user_id]) && config()->get('tracker.limit_active_tor') && ((config()->get('tracker.limit_seed_count') && $seeder) || (config()->get('tracker.limit_leech_count') && !$seeder))) {
$sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
FROM " . BB_BT_TRACKER . "
WHERE user_id = $user_id
AND seeder = $seeder
AND topic_id != $topic_id";
- if (!$seeder && $bb_cfg['tracker']['leech_expire_factor'] && $user_ratio < 0.5) {
- $sql .= " AND update_time > " . (TIMENOW - 60 * $bb_cfg['tracker']['leech_expire_factor']);
+ if (!$seeder && config()->get('tracker.leech_expire_factor') && $user_ratio < 0.5) {
+ $sql .= " AND update_time > " . (TIMENOW - 60 * config()->get('tracker.leech_expire_factor'));
}
$sql .= " GROUP BY user_id";
if ($row = DB()->fetch_row($sql)) {
- if ($seeder && $bb_cfg['tracker']['limit_seed_count'] && $row['active_torrents'] >= $bb_cfg['tracker']['limit_seed_count']) {
- msg_die('Only ' . $bb_cfg['tracker']['limit_seed_count'] . ' torrent(s) allowed for seeding');
- } elseif (!$seeder && $bb_cfg['tracker']['limit_leech_count'] && $row['active_torrents'] >= $bb_cfg['tracker']['limit_leech_count']) {
- msg_die('Only ' . $bb_cfg['tracker']['limit_leech_count'] . ' torrent(s) allowed for leeching' . $rating_msg);
+ if ($seeder && config()->get('tracker.limit_seed_count') && $row['active_torrents'] >= config()->get('tracker.limit_seed_count')) {
+ msg_die('Only ' . config()->get('tracker.limit_seed_count') . ' torrent(s) allowed for seeding');
+ } elseif (!$seeder && config()->get('tracker.limit_leech_count') && $row['active_torrents'] >= config()->get('tracker.limit_leech_count')) {
+ msg_die('Only ' . config()->get('tracker.limit_leech_count') . ' torrent(s) allowed for leeching' . $rating_msg);
}
}
}
// Limit concurrent IPs
- if ($bb_cfg['tracker']['limit_concurrent_ips'] && (($bb_cfg['tracker']['limit_seed_ips'] && $seeder) || ($bb_cfg['tracker']['limit_leech_ips'] && !$seeder))) {
+ if (config()->get('tracker.limit_concurrent_ips') && ((config()->get('tracker.limit_seed_ips') && $seeder) || (config()->get('tracker.limit_leech_ips') && !$seeder))) {
$sql = "SELECT COUNT(DISTINCT ip) AS ips
FROM " . BB_BT_TRACKER . "
WHERE topic_id = $topic_id
@@ -345,16 +343,16 @@ if ($lp_info) {
AND seeder = $seeder
AND $ip_version != '$ip_sql'";
- if (!$seeder && $bb_cfg['tracker']['leech_expire_factor']) {
- $sql .= " AND update_time > " . (TIMENOW - 60 * $bb_cfg['tracker']['leech_expire_factor']);
+ if (!$seeder && config()->get('tracker.leech_expire_factor')) {
+ $sql .= " AND update_time > " . (TIMENOW - 60 * config()->get('tracker.leech_expire_factor'));
}
$sql .= " GROUP BY topic_id";
if ($row = DB()->fetch_row($sql)) {
- if ($seeder && $bb_cfg['tracker']['limit_seed_ips'] && $row['ips'] >= $bb_cfg['tracker']['limit_seed_ips']) {
- msg_die('You can seed only from ' . $bb_cfg['tracker']['limit_seed_ips'] . " IP's");
- } elseif (!$seeder && $bb_cfg['tracker']['limit_leech_ips'] && $row['ips'] >= $bb_cfg['tracker']['limit_leech_ips']) {
- msg_die('You can leech only from ' . $bb_cfg['tracker']['limit_leech_ips'] . " IP's");
+ if ($seeder && config()->get('tracker.limit_seed_ips') && $row['ips'] >= config()->get('tracker.limit_seed_ips')) {
+ msg_die('You can seed only from ' . config()->get('tracker.limit_seed_ips') . " IP's");
+ } elseif (!$seeder && config()->get('tracker.limit_leech_ips') && $row['ips'] >= config()->get('tracker.limit_leech_ips')) {
+ msg_die('You can leech only from ' . config()->get('tracker.limit_leech_ips') . " IP's");
}
}
}
@@ -378,7 +376,7 @@ $up_add = ($lp_info && $uploaded > $lp_info['uploaded']) ? $uploaded - $lp_info[
$down_add = ($lp_info && $downloaded > $lp_info['downloaded']) ? $downloaded - $lp_info['downloaded'] : 0;
// Gold/Silver releases
-if ($bb_cfg['tracker']['gold_silver_enabled'] && $down_add) {
+if (config()->get('tracker.gold_silver_enabled') && $down_add) {
if ($tor_type == TOR_TYPE_GOLD) {
$down_add = 0;
} // Silver releases
@@ -388,7 +386,7 @@ if ($bb_cfg['tracker']['gold_silver_enabled'] && $down_add) {
}
// Freeleech
-if ($bb_cfg['tracker']['freeleech'] && $down_add) {
+if (config()->get('tracker.freeleech') && $down_add) {
$down_add = 0;
}
@@ -466,8 +464,8 @@ $output = CACHE('tr_cache')->get(PEERS_LIST_PREFIX . $topic_id);
if (!$output) {
// Retrieve peers
- $numwant = (int)$bb_cfg['tracker']['numwant'];
- $compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact));
+ $numwant = (int)config()->get('tracker.numwant');
+ $compact_mode = (config()->get('tracker.compact_mode') || !empty($compact));
$rowset = DB()->fetch_rowset("
SELECT ip, ipv6, port
@@ -512,7 +510,7 @@ if (!$output) {
$seeders = $leechers = $client_completed = 0;
- if ($bb_cfg['tracker']['scrape']) {
+ if (config()->get('tracker.scrape')) {
$row = DB()->fetch_row("
SELECT seeders, leechers, completed
FROM " . BB_BT_TRACKER_SNAP . "
diff --git a/bt/includes/init_tr.php b/bt/includes/init_tr.php
index 43e6bf43b..283c71ede 100644
--- a/bt/includes/init_tr.php
+++ b/bt/includes/init_tr.php
@@ -11,11 +11,9 @@ if (!defined('IN_TRACKER')) {
die(basename(__FILE__));
}
-global $bb_cfg;
-
// Exit if tracker is disabled
-if ($bb_cfg['tracker']['bt_off']) {
- msg_die($bb_cfg['tracker']['bt_off_reason']);
+if (config()->get('tracker.bt_off')) {
+ msg_die(config()->get('tracker.bt_off_reason'));
}
//
diff --git a/bt/scrape.php b/bt/scrape.php
index 534cd57fd..dd94ab8ff 100644
--- a/bt/scrape.php
+++ b/bt/scrape.php
@@ -11,9 +11,7 @@ define('IN_TRACKER', true);
define('BB_ROOT', './../');
require dirname(__DIR__) . '/common.php';
-global $bb_cfg;
-
-if (!$bb_cfg['tracker']['scrape']) {
+if (!config()->get('tracker.scrape')) {
msg_die('Please disable SCRAPE!');
}
@@ -60,8 +58,8 @@ foreach ($info_hash_array[1] as $hash) {
$info_hash_count = count($info_hashes);
if (!empty($info_hash_count)) {
- if ($info_hash_count > $bb_cfg['max_scrapes']) {
- $info_hashes = array_slice($info_hashes, 0, $bb_cfg['max_scrapes']);
+ if ($info_hash_count > config()->get('max_scrapes')) {
+ $info_hashes = array_slice($info_hashes, 0, config()->get('max_scrapes'));
}
$info_hashes_sql = implode('\', \'', $info_hashes);
diff --git a/library/ajax/avatar.php b/library/ajax/avatar.php
index 1b35c8bd1..08ae4a057 100644
--- a/library/ajax/avatar.php
+++ b/library/ajax/avatar.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $lang, $user;
+global $lang, $user;
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
diff --git a/library/ajax/callseed.php b/library/ajax/callseed.php
index a2e523612..9ef54a72d 100644
--- a/library/ajax/callseed.php
+++ b/library/ajax/callseed.php
@@ -11,9 +11,9 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $userdata, $lang;
+global $userdata, $lang;
-if (!$bb_cfg['callseed']) {
+if (!config()->get('callseed')) {
$this->ajax_die($lang['MODULE_OFF']);
}
@@ -32,7 +32,7 @@ if ($t_data['seeders'] >= 3) {
} elseif ($t_data['call_seed_time'] >= (TIMENOW - 86400)) {
$time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
$this->ajax_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left));
-} elseif (isset($bb_cfg['tor_no_tor_act'][$t_data['tor_status']])) {
+} elseif (isset(config()->get('tor_no_tor_act')[$t_data['tor_status']])) {
$this->ajax_die($lang['NOT_AVAILABLE']);
}
diff --git a/library/ajax/change_tor_status.php b/library/ajax/change_tor_status.php
index 0ece009cb..ae534774c 100644
--- a/library/ajax/change_tor_status.php
+++ b/library/ajax/change_tor_status.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $userdata, $bb_cfg, $lang, $log_action;
+global $userdata, $lang, $log_action;
if (!$attach_id = (int)$this->request['attach_id']) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
@@ -22,7 +22,7 @@ if (!$mode = (string)$this->request['mode']) {
}
$comment = false;
-if ($bb_cfg['tor_comment']) {
+if (config()->get('tor_comment')) {
$comment = (string)$this->request['comment'];
}
@@ -88,7 +88,7 @@ switch ($mode) {
\TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $new_status);
// Log action
- $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], $bb_cfg['tor_icons'][$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status] . '', $bb_cfg['tor_icons'][$tor['tor_status']] . ' ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '');
+ $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], config()->get('tor_icons')[$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status] . '', config()->get('tor_icons')[$tor['tor_status']] . ' ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '');
if ($comment && $comment != $lang['COMMENT']) {
$log_msg .= "
{$lang['COMMENT']}: $comment.";
}
@@ -99,12 +99,12 @@ switch ($mode) {
'log_msg' => $log_msg . '
-------------',
]);
- $this->response['status'] = $bb_cfg['tor_icons'][$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status] . ' · ' . profile_url($userdata) . ' · ' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '';
+ $this->response['status'] = config()->get('tor_icons')[$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status] . ' · ' . profile_url($userdata) . ' · ' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '';
- if ($bb_cfg['tor_comment'] && (($comment && $comment != $lang['COMMENT']) || in_array($new_status, $bb_cfg['tor_reply']))) {
+ if (config()->get('tor_comment') && (($comment && $comment != $lang['COMMENT']) || in_array($new_status, config()->get('tor_reply')))) {
if ($tor['poster_id'] > 0) {
$subject = sprintf($lang['TOR_MOD_TITLE'], $tor['topic_title']);
- $message = sprintf($lang['TOR_MOD_MSG'], get_username($tor['poster_id']), make_url(TOPIC_URL . $tor['topic_id']), $bb_cfg['tor_icons'][$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status]);
+ $message = sprintf($lang['TOR_MOD_MSG'], get_username($tor['poster_id']), make_url(TOPIC_URL . $tor['topic_id']), config()->get('tor_icons')[$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status]);
if ($comment && $comment != $lang['COMMENT']) {
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
@@ -117,7 +117,7 @@ switch ($mode) {
break;
case 'status_reply':
- if (!$bb_cfg['tor_comment']) {
+ if (!config()->get('tor_comment')) {
$this->ajax_die($lang['MODULE_OFF']);
}
diff --git a/library/ajax/change_torrent.php b/library/ajax/change_torrent.php
index ca26b7c24..dbcef89c8 100644
--- a/library/ajax/change_torrent.php
+++ b/library/ajax/change_torrent.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $userdata, $bb_cfg, $lang, $log_action;
+global $userdata, $lang, $log_action;
if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
diff --git a/library/ajax/edit_group_profile.php b/library/ajax/edit_group_profile.php
index 1a40f941f..f66911ed1 100644
--- a/library/ajax/edit_group_profile.php
+++ b/library/ajax/edit_group_profile.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $userdata, $lang;
+global $userdata, $lang;
if (!$group_id = (int)$this->request['group_id'] or !$group_info = \TorrentPier\Legacy\Group::get_group_data($group_id)) {
$this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']);
diff --git a/library/ajax/edit_user_profile.php b/library/ajax/edit_user_profile.php
index 9b7f24b5a..8cfc342f7 100644
--- a/library/ajax/edit_user_profile.php
+++ b/library/ajax/edit_user_profile.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $lang;
+global $lang;
if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) {
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
@@ -55,7 +55,7 @@ switch ($field) {
break;
case 'user_gender':
- if (!$bb_cfg['gender']) {
+ if (!config()->get('gender')) {
$this->ajax_die($lang['MODULE_OFF']);
}
if (!isset($lang['GENDER_SELECT'][$value])) {
@@ -65,7 +65,7 @@ switch ($field) {
break;
case 'user_birthday':
- if (!$bb_cfg['birthday_enabled']) {
+ if (!config()->get('birthday_enabled')) {
$this->ajax_die($lang['MODULE_OFF']);
}
$birthday_date = date_parse($value);
@@ -73,10 +73,10 @@ switch ($field) {
if (!empty($birthday_date['year'])) {
if (strtotime($value) >= TIMENOW) {
$this->ajax_die($lang['WRONG_BIRTHDAY_FORMAT']);
- } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > $bb_cfg['birthday_max_age']) {
- $this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], $bb_cfg['birthday_max_age']));
- } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < $bb_cfg['birthday_min_age']) {
- $this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], $bb_cfg['birthday_min_age']));
+ } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > config()->get('birthday_max_age')) {
+ $this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], config()->get('birthday_max_age')));
+ } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < config()->get('birthday_min_age')) {
+ $this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], config()->get('birthday_min_age')));
}
}
diff --git a/library/ajax/ffprobe_info.php b/library/ajax/ffprobe_info.php
index d6bf8067d..c2b8e7e5c 100644
--- a/library/ajax/ffprobe_info.php
+++ b/library/ajax/ffprobe_info.php
@@ -11,13 +11,13 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $lang;
+global $lang;
-if (!$bb_cfg['torr_server']['enabled']) {
+if (!config()->get('torr_server.enabled')) {
$this->ajax_die($lang['MODULE_OFF']);
}
-if ($bb_cfg['torr_server']['disable_for_guest'] && IS_GUEST) {
+if (config()->get('torr_server.disable_for_guest') && IS_GUEST) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
diff --git a/library/ajax/index_data.php b/library/ajax/index_data.php
index 42ec056c5..95fdaacda 100644
--- a/library/ajax/index_data.php
+++ b/library/ajax/index_data.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $lang, $userdata, $datastore;
+global $lang, $userdata, $datastore;
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
@@ -31,9 +31,9 @@ switch ($mode) {
foreach ($stats['birthday_week_list'] as $week) {
$users[] = profile_url($week) . ' (' . birthday_age(date('Y-m-d', strtotime('-1 year', strtotime($week['user_birthday'])))) . ')';
}
- $html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], implode(', ', $users));
+ $html = sprintf($lang['BIRTHDAY_WEEK'], config()->get('birthday_check_day'), implode(', ', $users));
} else {
- $html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
+ $html = sprintf($lang['NOBIRTHDAY_WEEK'], config()->get('birthday_check_day'));
}
break;
@@ -84,7 +84,7 @@ switch ($mode) {
break;
case 'null_ratio':
- if (!$bb_cfg['ratio_null_enabled'] || !RATIO_ENABLED) {
+ if (!config()->get('ratio_null_enabled') || !RATIO_ENABLED) {
$this->ajax_die($lang['MODULE_OFF']);
}
if (empty($this->request['confirmed'])) {
@@ -106,8 +106,8 @@ switch ($mode) {
if ($ratio_nulled && !IS_ADMIN) {
$this->ajax_die($lang['BT_NULL_RATIO_AGAIN']);
}
- if (($user_ratio >= $bb_cfg['ratio_to_null']) && !IS_ADMIN) {
- $this->ajax_die(sprintf($lang['BT_NULL_RATIO_NOT_NEEDED'], $bb_cfg['ratio_to_null']));
+ if (($user_ratio >= config()->get('ratio_to_null')) && !IS_ADMIN) {
+ $this->ajax_die(sprintf($lang['BT_NULL_RATIO_NOT_NEEDED'], config()->get('ratio_to_null')));
}
$ratio_nulled_sql = !IS_ADMIN ? ', ratio_nulled = 1' : '';
@@ -172,7 +172,7 @@ switch ($mode) {
' . $lang['UPLOADED'] . ' |
' . $lang['RELEASED'] . ' |
' . $lang['BONUS'] . ' | ';
- $html .= $bb_cfg['seed_bonus_enabled'] ? '' . $lang['SEED_BONUS'] . ' | ' : '';
+ $html .= config()->get('seed_bonus_enabled') ? '' . $lang['SEED_BONUS'] . ' | ' : '';
$html .= '
' . $lang['TOTAL_TRAF'] . ' |
@@ -180,17 +180,17 @@ 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 .= config()->get('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 .= config()->get('seed_bonus_enabled') ? ' | ' : '';
$html .= '
';
$this->response['user_ratio'] = '
- ' . $lang['USER_RATIO'] . ': |
+ ' . $lang['USER_RATIO'] . ': |
' . $user_ratio . ' |
';
break;
diff --git a/library/ajax/manage_admin.php b/library/ajax/manage_admin.php
index cb0249239..29ecbb3bc 100644
--- a/library/ajax/manage_admin.php
+++ b/library/ajax/manage_admin.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $userdata, $lang, $bb_cfg;
+global $userdata, $lang;
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
@@ -19,7 +19,7 @@ if (!$mode = (string)$this->request['mode']) {
switch ($mode) {
case 'clear_cache':
- foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) {
+ foreach (config()->get('cache.engines') as $cache_name => $cache_val) {
CACHE($cache_name)->rm();
}
@@ -48,20 +48,20 @@ switch ($mode) {
$this->response['template_cache_html'] = '' . $lang['ALL_TEMPLATE_CLEARED'] . '';
break;
case 'indexer':
- exec("indexer --config {$bb_cfg['sphinx_config_path']} --all --rotate", $result);
+ exec("indexer --config " . config()->get('sphinx_config_path') . " --all --rotate", $result);
- if (!is_file($bb_cfg['sphinx_config_path'] . ".log")) {
- file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "##############################" . date("H:i:s", TIMENOW) . "##############################\r\n\r\n\r\n\r\n", FILE_APPEND);
+ if (!is_file(config()->get('sphinx_config_path') . ".log")) {
+ file_put_contents(config()->get('sphinx_config_path') . ".log", "##############################" . date("H:i:s", TIMENOW) . "##############################\r\n\r\n\r\n\r\n", FILE_APPEND);
}
- file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "##############################" . date("H:i:s", TIMENOW) . "##############################\r\n", FILE_APPEND);
+ file_put_contents(config()->get('sphinx_config_path') . ".log", "##############################" . date("H:i:s", TIMENOW) . "##############################\r\n", FILE_APPEND);
foreach ($result as $row) {
- file_put_contents($bb_cfg['sphinx_config_path'] . ".log", $row . "\r\n", FILE_APPEND);
+ file_put_contents(config()->get('sphinx_config_path') . ".log", $row . "\r\n", FILE_APPEND);
}
- file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "\r\n", FILE_APPEND);
- file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "\r\n", FILE_APPEND);
+ file_put_contents(config()->get('sphinx_config_path') . ".log", "\r\n", FILE_APPEND);
+ file_put_contents(config()->get('sphinx_config_path') . ".log", "\r\n", FILE_APPEND);
$this->response['indexer_html'] = '' . $lang['INDEXER'] . '';
break;
diff --git a/library/ajax/manage_user.php b/library/ajax/manage_user.php
index 8a1e4b25e..3925b739f 100644
--- a/library/ajax/manage_user.php
+++ b/library/ajax/manage_user.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $userdata, $lang, $bb_cfg;
+global $userdata, $lang;
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
diff --git a/library/ajax/mod_action.php b/library/ajax/mod_action.php
index 0817f7e4e..a82c122a0 100644
--- a/library/ajax/mod_action.php
+++ b/library/ajax/mod_action.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $userdata, $bb_cfg, $lang, $datastore, $log_action;
+global $userdata, $lang, $datastore, $log_action;
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
@@ -44,7 +44,7 @@ switch ($mode) {
\TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $status);
// Log action
- $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], $bb_cfg['tor_icons'][$status] . ' ' . $lang['TOR_STATUS_NAME'][$status] . '', $bb_cfg['tor_icons'][$tor['tor_status']] . ' ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '');
+ $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], config()->get('tor_icons')[$status] . ' ' . $lang['TOR_STATUS_NAME'][$status] . '', config()->get('tor_icons')[$tor['tor_status']] . ' ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '');
$log_action->mod('mod_topic_change_tor_status', [
'forum_id' => $tor['forum_id'],
'topic_id' => $tor['topic_id'],
@@ -52,7 +52,7 @@ switch ($mode) {
'log_msg' => $log_msg . '
-------------',
]);
}
- $this->response['status'] = $bb_cfg['tor_icons'][$status];
+ $this->response['status'] = config()->get('tor_icons')[$status];
$this->response['topics'] = explode(',', $topics);
break;
@@ -78,16 +78,16 @@ switch ($mode) {
DB()->query("UPDATE " . BB_TOPICS . " SET topic_title = '$topic_title_sql' WHERE topic_id = $topic_id LIMIT 1");
// Update the news cache on the index page
- $news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));
- if (isset($news_forums[$t_data['forum_id']]) && $bb_cfg['show_latest_news']) {
+ $news_forums = array_flip(explode(',', config()->get('latest_news_forum_id')));
+ if (isset($news_forums[$t_data['forum_id']]) && config()->get('show_latest_news')) {
$datastore->enqueue([
'latest_news'
]);
$datastore->update('latest_news');
}
- $net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id']));
- if (isset($net_forums[$t_data['forum_id']]) && $bb_cfg['show_network_news']) {
+ $net_forums = array_flip(explode(',', config()->get('network_news_forum_id')));
+ if (isset($net_forums[$t_data['forum_id']]) && config()->get('show_network_news')) {
$datastore->enqueue([
'network_news'
]);
@@ -151,8 +151,8 @@ switch ($mode) {
} else {
$user_reg_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($profiledata['user_reg_ip']);
$user_last_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($profiledata['user_last_ip']);
- $reg_ip = '' . $user_reg_ip . '';
- $last_ip = '' . $user_last_ip . '';
+ $reg_ip = '' . $user_reg_ip . '';
+ $last_ip = '' . $user_last_ip . '';
}
$this->response['ip_list_html'] = '
diff --git a/library/ajax/posts.php b/library/ajax/posts.php
index e34b8b2c1..2c5405df3 100644
--- a/library/ajax/posts.php
+++ b/library/ajax/posts.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $lang, $bb_cfg, $userdata, $wordCensor;
+global $lang, $userdata, $wordCensor;
if (!isset($this->request['type'])) {
$this->ajax_die('empty type');
@@ -76,7 +76,7 @@ switch ($this->request['type']) {
$message = "[quote=\"" . $quote_username . "\"][qpost=" . $post['post_id'] . "]" . $post['post_text'] . "[/quote]\r";
// hide user passkey
- $message = preg_replace('#(?<=[\?&;]' . $bb_cfg['passkey_key'] . '=)[a-zA-Z0-9]#', 'passkey', $message);
+ $message = preg_replace('#(?<=[\?&;]' . config()->get('passkey_key') . '=)[a-zA-Z0-9]#', 'passkey', $message);
// hide sid
$message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]#', 'sid', $message);
@@ -120,10 +120,10 @@ switch ($this->request['type']) {
if (mb_strlen($text) > 2) {
if ($text != $post['post_text']) {
- if ($bb_cfg['max_smilies']) {
- $count_smilies = substr_count(bbcode2html($text), '
request['type']) {
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql";
if ($row = DB()->fetch_row($sql) and $row['last_post_time']) {
if ($userdata['user_level'] == USER) {
- if ((TIMENOW - $row['last_post_time']) < $bb_cfg['flood_interval']) {
+ if ((TIMENOW - $row['last_post_time']) < config()->get('flood_interval')) {
$this->ajax_die($lang['FLOOD_ERROR']);
}
}
@@ -251,10 +251,10 @@ switch ($this->request['type']) {
}
}
- if ($bb_cfg['max_smilies']) {
- $count_smilies = substr_count(bbcode2html($message), '
' . make_url('sitemap/sitemap.xml') . '';
+ $html .= $lang['SITEMAP_CREATED'] . ': ' . bb_date(TIMENOW, config()->get('post_date_format')) . ' ' . $lang['SITEMAP_AVAILABLE'] . ': ' . make_url('sitemap/sitemap.xml') . '';
} else {
$html .= $lang['SITEMAP_NOT_CREATED'];
}
diff --git a/library/ajax/thanks.php b/library/ajax/thanks.php
index cbe29ac01..c4eb38689 100644
--- a/library/ajax/thanks.php
+++ b/library/ajax/thanks.php
@@ -11,9 +11,9 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $lang, $userdata;
+global $lang, $userdata;
-if (!$bb_cfg['tor_thank']) {
+if (!config()->get('tor_thank')) {
$this->ajax_die($lang['MODULE_OFF']);
}
@@ -49,12 +49,12 @@ switch ($mode) {
// Limit voters per topic
$thanks_count = DB()->fetch_row('SELECT COUNT(*) as thx FROM ' . BB_THX . " WHERE topic_id = $topic_id")['thx'];
- if ($thanks_count > (int)$bb_cfg['tor_thank_limit_per_topic']) {
+ if ($thanks_count > (int)config()->get('tor_thank_limit_per_topic')) {
DB()->query('DELETE FROM ' . BB_THX . " WHERE topic_id = $topic_id ORDER BY time ASC LIMIT 1");
}
break;
case 'get':
- if (IS_GUEST && !$bb_cfg['tor_thanks_list_guests']) {
+ if (IS_GUEST && !config()->get('tor_thanks_list_guests')) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
diff --git a/library/ajax/user_register.php b/library/ajax/user_register.php
index 9491e3b57..ef03c683d 100644
--- a/library/ajax/user_register.php
+++ b/library/ajax/user_register.php
@@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $bb_cfg, $lang, $userdata;
+global $lang, $userdata;
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
diff --git a/library/ajax/view_post.php b/library/ajax/view_post.php
index 916ce6cb6..e5d3e8462 100644
--- a/library/ajax/view_post.php
+++ b/library/ajax/view_post.php
@@ -11,11 +11,11 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
-global $user, $lang, $bb_cfg;
+global $user, $lang;
$post_id = isset($this->request['post_id']) ? (int)$this->request['post_id'] : null;
$topic_id = isset($this->request['topic_id']) ? (int)$this->request['topic_id'] : null;
-$return_text = $bb_cfg['show_post_bbcode_button']['enabled'] && isset($this->request['return_text']) && (bool)$this->request['return_text'];
+$return_text = config()->get('show_post_bbcode_button.enabled') && isset($this->request['return_text']) && (bool)$this->request['return_text'];
if (is_null($post_id)) {
$post_id = DB()->fetch_row("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id", 'topic_first_post_id');
diff --git a/privmsg.php b/privmsg.php
index 5bd56d1b6..42b47d1c1 100644
--- a/privmsg.php
+++ b/privmsg.php
@@ -24,7 +24,7 @@ $page_cfg['load_tpl_vars'] = [
//
// Is PM disabled?
//
-if ($bb_cfg['privmsg_disable']) {
+if (config()->get('privmsg_disable')) {
bb_die('PM_DISABLED');
}
@@ -59,13 +59,13 @@ $user->session_start(['req_login' => true]);
$template->assign_vars([
'IN_PM' => true,
- 'QUICK_REPLY' => $bb_cfg['show_quick_reply'] && $folder == 'inbox' && $mode == 'read',
+ 'QUICK_REPLY' => config()->get('show_quick_reply') && $folder == 'inbox' && $mode == 'read',
]);
//
// Set mode for quick reply
//
-if (empty($mode) && $bb_cfg['show_quick_reply'] && $folder == 'inbox' && $preview) {
+if (empty($mode) && config()->get('show_quick_reply') && $folder == 'inbox' && $preview) {
$mode = 'reply';
}
@@ -206,7 +206,7 @@ if ($mode == 'read') {
}
if ($sent_info = DB()->sql_fetchrow($result)) {
- if ($bb_cfg['max_sentbox_privmsgs'] && $sent_info['sent_items'] >= $bb_cfg['max_sentbox_privmsgs']) {
+ if (config()->get('max_sentbox_privmsgs') && $sent_info['sent_items'] >= config()->get('max_sentbox_privmsgs')) {
$sql = "SELECT privmsgs_id FROM " . BB_PRIVMSGS . "
WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . "
AND privmsgs_date = " . $sent_info['oldest_post_time'] . "
@@ -604,7 +604,7 @@ if ($mode == 'read') {
}
if ($saved_info = DB()->sql_fetchrow($result)) {
- if ($bb_cfg['max_savebox_privmsgs'] && $saved_info['savebox_items'] >= $bb_cfg['max_savebox_privmsgs']) {
+ if (config()->get('max_savebox_privmsgs') && $saved_info['savebox_items'] >= config()->get('max_savebox_privmsgs')) {
$sql = "SELECT privmsgs_id FROM " . BB_PRIVMSGS . "
WHERE ( ( privmsgs_to_userid = " . $userdata['user_id'] . "
AND privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . " )
@@ -749,7 +749,7 @@ if ($mode == 'read') {
$last_post_time = $db_row['last_post_time'];
$current_time = TIMENOW;
- if (($current_time - $last_post_time) < $bb_cfg['flood_interval']) {
+ if (($current_time - $last_post_time) < config()->get('flood_interval')) {
bb_die($lang['FLOOD_ERROR']);
}
}
@@ -802,11 +802,11 @@ if ($mode == 'read') {
}
// Check smilies limit
- if ($bb_cfg['max_smilies_pm']) {
- $count_smilies = substr_count(bbcode2html($privmsg_message), '
get('pm_notify_enabled')) {
// Sending email
$emailer = new TorrentPier\Emailer();
@@ -1252,7 +1252,7 @@ if ($mode == 'read') {
$msg_days = 0;
}
- $sql .= $limit_msg_time . " ORDER BY pm.privmsgs_date DESC LIMIT $start, " . $bb_cfg['topics_per_page'];
+ $sql .= $limit_msg_time . " ORDER BY pm.privmsgs_date DESC LIMIT $start, " . config()->get('topics_per_page');
$sql_all_tot = $sql_tot;
$sql_tot .= $limit_msg_time_total;
@@ -1308,11 +1308,11 @@ if ($mode == 'read') {
// Output data for inbox status
//
$box_limit_img_length = $box_limit_percent = $l_box_size_status = '';
- $max_pm = ($folder != 'outbox') ? $bb_cfg["max_{$folder}_privmsgs"] : null;
+ $max_pm = ($folder != 'outbox') ? config()->get("max_{$folder}_privmsgs") : null;
if ($max_pm) {
$box_limit_percent = min(round(($pm_all_total / $max_pm) * 100), 100);
- $box_limit_img_length = min(round(($pm_all_total / $max_pm) * $bb_cfg['privmsg_graphic_length']), $bb_cfg['privmsg_graphic_length']);
+ $box_limit_img_length = min(round(($pm_all_total / $max_pm) * config()->get('privmsg_graphic_length')), config()->get('privmsg_graphic_length'));
$box_limit_remain = max(($max_pm - $pm_all_total), 0);
$template->assign_var('PM_BOX_SIZE_INFO');
@@ -1410,7 +1410,7 @@ if ($mode == 'read') {
]);
} while ($row = DB()->sql_fetchrow($result));
- generate_pagination(PM_URL . "?folder=$folder", $pm_total, $bb_cfg['topics_per_page'], $start);
+ generate_pagination(PM_URL . "?folder=$folder", $pm_total, config()->get('topics_per_page'), $start);
} else {
$template->assign_block_vars('switch_no_messages', []);
}
diff --git a/search.php b/search.php
index 5e85b5940..b0d9bb977 100644
--- a/search.php
+++ b/search.php
@@ -20,7 +20,7 @@ $page_cfg['load_tpl_vars'] = [
];
// Start session management
-$user->session_start(array('req_login' => $bb_cfg['disable_search_for_guest']));
+$user->session_start(array('req_login' => config()->get('disable_search_for_guest')));
set_die_append_msg();
@@ -289,7 +289,7 @@ if (empty($_GET) && empty($_POST)) {
'MY_TOPICS_ID' => 'my_topics',
'MY_TOPICS_CHBOX' => build_checkbox($my_topics_key, $lang['SEARCH_MY_TOPICS'], $my_topics_val, true, null, 'my_topics'),
- 'TITLE_ONLY_CHBOX' => build_checkbox($title_only_key, $lang['SEARCH_TITLES_ONLY'], true, $bb_cfg['disable_ft_search_in_posts']),
+ 'TITLE_ONLY_CHBOX' => build_checkbox($title_only_key, $lang['SEARCH_TITLES_ONLY'], true, config()->get('disable_ft_search_in_posts')),
'ALL_WORDS_CHBOX' => build_checkbox($all_words_key, $lang['SEARCH_ALL_WORDS'], true),
'DL_CANCEL_CHBOX' => build_checkbox($dl_cancel_key, $lang['SEARCH_DL_CANCEL'], $dl_cancel_val, IS_GUEST, 'dlCancel'),
'DL_COMPL_CHBOX' => build_checkbox($dl_compl_key, $lang['SEARCH_DL_COMPLETE'], $dl_compl_val, IS_GUEST, 'dlComplete'),
@@ -421,7 +421,7 @@ $prev_days = ($time_val != $search_all);
$new_topics = (!IS_GUEST && ($new_topics_val || isset($_GET['newposts'])));
$my_topics = ($poster_id_val && $my_topics_val);
$my_posts = ($poster_id_val && !$my_topics_val);
-$title_match = ($text_match_sql && ($title_only_val || $bb_cfg['disable_ft_search_in_posts']));
+$title_match = ($text_match_sql && ($title_only_val || config()->get('disable_ft_search_in_posts')));
// "Display as" mode (posts or topics)
$post_mode = (!$dl_search && ($display_as_val == $as_posts || isset($_GET['search_author'])));
@@ -433,7 +433,7 @@ $SQL = DB()->get_empty_sql_array();
if ($post_mode) {
$order = $order_opt[$order_val]['sql'];
$sort = $sort_opt[$sort_val]['sql'];
- $per_page = $bb_cfg['posts_per_page'];
+ $per_page = config()->get('posts_per_page');
$display_as_val = $as_posts;
// Run initial search for post_ids
@@ -593,7 +593,7 @@ if ($post_mode) {
'POSTER_ID' => $post['poster_id'],
'POSTER' => profile_url($post),
'POST_ID' => $post['post_id'],
- 'POST_DATE' => bb_date($post['post_time'], $bb_cfg['post_date_format']),
+ 'POST_DATE' => bb_date($post['post_time'], config()->get('post_date_format')),
'IS_UNREAD' => is_unread($post['post_time'], $topic_id, $forum_id),
'MESSAGE' => $message,
'POSTED_AFTER' => '',
@@ -612,7 +612,7 @@ if ($post_mode) {
else {
$order = $order_opt[$order_val]['sql'];
$sort = $sort_opt[$sort_val]['sql'];
- $per_page = $bb_cfg['topics_per_page'];
+ $per_page = config()->get('topics_per_page');
$display_as_val = $as_topics;
// Run initial search for topic_ids
@@ -733,7 +733,7 @@ else {
// Build SQL for displaying topics
$SQL = DB()->get_empty_sql_array();
- $join_dl = ($bb_cfg['show_dl_status_in_search'] && !IS_GUEST);
+ $join_dl = (config()->get('show_dl_status_in_search') && !IS_GUEST);
$SQL['SELECT'][] = "
t.*, t.topic_poster AS first_user_id, u1.user_rank AS first_user_rank,
@@ -790,7 +790,7 @@ else {
'TOPIC_TITLE' => $wordCensor->censorString($topic['topic_title']),
'IS_UNREAD' => $is_unread,
'TOPIC_ICON' => get_topic_icon($topic, $is_unread),
- 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], $bb_cfg['posts_per_page']),
+ 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], config()->get('posts_per_page')),
'REPLIES' => $moved ? '' : $topic['topic_replies'],
'ATTACH' => $topic['topic_attachment'],
'STATUS' => $topic['topic_status'],
@@ -888,15 +888,13 @@ function fetch_search_ids($sql, $search_type = SEARCH_TYPE_POST)
function prevent_huge_searches($SQL)
{
- global $bb_cfg;
-
- if ($bb_cfg['limit_max_search_results']) {
+ if (config()->get('limit_max_search_results')) {
$SQL['select_options'][] = 'SQL_CALC_FOUND_ROWS';
$SQL['ORDER BY'] = [];
$SQL['LIMIT'] = array('0');
if (DB()->query($SQL) and $row = DB()->fetch_row("SELECT FOUND_ROWS() AS rows_count")) {
- if ($row['rows_count'] > $bb_cfg['limit_max_search_results']) {
+ if ($row['rows_count'] > config()->get('limit_max_search_results')) {
# bb_log(str_compact(DB()->build_sql($SQL)) ." [{$row['rows_count']} rows]". LOG_LF, 'sql_huge_search');
bb_die('Too_many_search_results');
}
diff --git a/src/Config.php b/src/Config.php
index 2490e94c3..9d39668b8 100644
--- a/src/Config.php
+++ b/src/Config.php
@@ -11,7 +11,7 @@ namespace TorrentPier;
/**
* Configuration management class
- *
+ *
* Encapsulates the global $bb_cfg array and provides methods to access configuration values
*/
class Config
@@ -179,4 +179,4 @@ class Config
{
throw new \Exception("Cannot unserialize a singleton.");
}
-}
\ No newline at end of file
+}
diff --git a/terms.php b/terms.php
index d173f82f8..e3598073f 100644
--- a/terms.php
+++ b/terms.php
@@ -15,13 +15,13 @@ require INC_DIR . '/bbcode.php';
// Start session management
$user->session_start();
-if (!$bb_cfg['terms'] && !IS_ADMIN) {
+if (!config()->get('terms') && !IS_ADMIN) {
redirect('index.php');
}
$template->assign_vars([
'TERMS_EDIT' => bbcode2html(sprintf($lang['TERMS_EMPTY_TEXT'], make_url('admin/admin_terms.php'))),
- 'TERMS_HTML' => bbcode2html($bb_cfg['terms']),
+ 'TERMS_HTML' => bbcode2html(config()->get('terms')),
]);
print_page('terms.tpl');
diff --git a/tracker.php b/tracker.php
index 2e94615b9..ddb56a51f 100644
--- a/tracker.php
+++ b/tracker.php
@@ -19,7 +19,7 @@ $page_cfg['load_tpl_vars'] = [
];
// Session start
-$user->session_start(array('req_login' => $bb_cfg['bt_tor_browse_only_reg']));
+$user->session_start(array('req_login' => config()->get('bt_tor_browse_only_reg')));
set_die_append_msg();
@@ -30,7 +30,7 @@ $max_forums_selected = 50;
$title_match_max_len = 60;
$poster_name_max_len = 25;
$tor_colspan = 12; // torrents table colspan with all columns
-$per_page = $bb_cfg['topics_per_page'];
+$per_page = config()->get('topics_per_page');
$tracker_url = basename(__FILE__);
$time_format = 'H:i';
@@ -299,8 +299,8 @@ if (isset($_GET[$user_releases_key])) {
}
// Random release
-if ($bb_cfg['tracker']['random_release_button'] && isset($_GET['random_release'])) {
- if ($random_release = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE tor_status NOT IN(" . implode(', ', array_keys($bb_cfg['tor_frozen'])) . ") ORDER BY RAND() LIMIT 1")) {
+if (config()->get('tracker.random_release_button') && isset($_GET['random_release'])) {
+ if ($random_release = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE tor_status NOT IN(" . implode(', ', array_keys(config()->get('tor_frozen'))) . ") ORDER BY RAND() LIMIT 1")) {
redirect(TOPIC_URL . $random_release['topic_id']);
} else {
bb_die($lang['NO_MATCH']);
@@ -749,8 +749,8 @@ if ($allowed_forums) {
'MAGNET' => $tor_magnet,
'TOR_TYPE' => is_gold($tor['tor_type']),
- 'TOR_FROZEN' => !IS_AM ? isset($bb_cfg['tor_frozen'][$tor['tor_status']]) : '',
- 'TOR_STATUS_ICON' => $bb_cfg['tor_icons'][$tor['tor_status']],
+ 'TOR_FROZEN' => !IS_AM ? isset(config()->get('tor_frozen')[$tor['tor_status']]) : '',
+ 'TOR_STATUS_ICON' => config()->get('tor_icons')[$tor['tor_status']],
'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor['tor_status']],
'TOR_SIZE_RAW' => $size,
@@ -819,9 +819,9 @@ $search_all_opt = '