diff --git a/library/attach_mod/attachment_mod.php b/library/attach_mod/attachment_mod.php index b59d273ca..16fa06a8b 100644 --- a/library/attach_mod/attachment_mod.php +++ b/library/attach_mod/attachment_mod.php @@ -25,11 +25,11 @@ if (defined('ATTACH_INSTALL')) { */ function attach_mod_get_lang($language_file) { - global $attach_config, $bb_cfg; + global $attach_config; - $file = LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/' . $language_file . '.php'; + $file = LANG_ROOT_DIR . '/' . config()->get('default_lang') . '/' . $language_file . '.php'; if (file_exists($file)) { - return $bb_cfg['default_lang']; + return config()->get('default_lang'); } $file = LANG_ROOT_DIR . '/' . $attach_config['board_lang'] . '/' . $language_file . '.php'; @@ -45,8 +45,6 @@ function attach_mod_get_lang($language_file) */ function get_config() { - global $bb_cfg; - $attach_config = []; $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; @@ -60,7 +58,7 @@ function get_config() } // We assign the original default board language here, because it gets overwritten later with the users default language - $attach_config['board_lang'] = trim($bb_cfg['default_lang']); + $attach_config['board_lang'] = trim(config()->get('default_lang')); return $attach_config; } diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 06a670266..edded7f47 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bb_cfg, $t_data, $poster_id, $is_auth, $dl_link_css, $dl_status_css, $lang, $images; +global $t_data, $poster_id, $is_auth, $dl_link_css, $dl_status_css, $lang, $images; $tor_status_by_for_all = true; $change_peers_bgr_over = true; @@ -40,7 +40,7 @@ $template->assign_vars([ ]); // Define show peers mode (count only || user names with complete % || full details) -$cfg_sp_mode = $bb_cfg['bt_show_peers_mode']; +$cfg_sp_mode = config()->get('bt_show_peers_mode'); $get_sp_mode = $_GET['spmode'] ?? ''; $s_mode = 'count'; @@ -51,7 +51,7 @@ if ($cfg_sp_mode == SHOW_PEERS_NAMES) { $s_mode = 'full'; } -if ($bb_cfg['bt_allow_spmode_change']) { +if (config()->get('bt_allow_spmode_change')) { if ($get_sp_mode == 'names') { $s_mode = 'names'; } elseif ($get_sp_mode == 'full') { @@ -68,7 +68,7 @@ $tor_file_size = humn_size($attachments['_' . $post_id][$i]['filesize']); $tor_file_time = bb_date($attachments['_' . $post_id][$i]['filetime']); $tor_reged = (bool)$tracker_status; -$show_peers = (bool)$bb_cfg['bt_show_peers']; +$show_peers = (bool)config()->get('bt_show_peers'); $locked = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED); $tor_auth = ($bt_user_id != GUEST_UID && (($bt_user_id == $poster_id && !$locked) || $is_auth['auth_mod'])); @@ -88,10 +88,10 @@ if ($tor_auth_reg || $tor_auth_del) { $tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url; } -if ($bb_cfg['tracker']['use_old_torrent_name_format']) { - $display_name = '[' . $bb_cfg['server_name'] . '].t' . $bt_topic_id . '.' . TORRENT_EXT; +if (config()->get('tracker.use_old_torrent_name_format')) { + $display_name = '[' . config()->get('server_name') . '].t' . $bt_topic_id . '.' . TORRENT_EXT; } else { - $display_name = $t_data['topic_title'] . ' [' . $bb_cfg['server_name'] . '-' . $bt_topic_id . ']' . '.' . TORRENT_EXT; + $display_name = $t_data['topic_title'] . ' [' . config()->get('server_name') . '-' . $bt_topic_id . ']' . '.' . TORRENT_EXT; } if (!$tor_reged) { @@ -152,8 +152,8 @@ if ($tor_reged && $tor_info) { $tor_magnet = create_magnet($tor_info['info_hash'], $tor_info['info_hash_v2'], $user_passkey, html_ent_decode($t_data['topic_title']), $tor_size); // ratio limits - $min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor']; - $min_ratio_warn = $bb_cfg['bt_min_ratio_warning']; + $min_ratio_dl = config()->get('bt_min_ratio_allow_dl_tor'); + $min_ratio_warn = config()->get('bt_min_ratio_warning'); $dl_allowed = true; $user_ratio = 0; @@ -182,7 +182,7 @@ if ($tor_reged && $tor_info) { if ((isset($user_ratio, $min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) { $template->assign_vars([ 'SHOW_RATIO_WARN' => true, - 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']), + 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, config()->get('ratio_url_help')), ]); } } @@ -202,12 +202,12 @@ if ($tor_reged && $tor_info) { 'TOR_TYPE' => is_gold($tor_type), // torrent status mod - 'TOR_FROZEN' => !IS_AM ? (isset($bb_cfg['tor_frozen'][$tor_info['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_info['tor_status']]) && $userdata['user_id'] == $tor_info['poster_id'])) ? true : '' : '', + 'TOR_FROZEN' => !IS_AM ? (isset(config()->get('tor_frozen')[$tor_info['tor_status']]) && !(isset(config()->get('tor_frozen_author_download')[$tor_info['tor_status']]) && $userdata['user_id'] == $tor_info['poster_id'])) ? true : '' : '', 'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor_info['tor_status']], - 'TOR_STATUS_ICON' => $bb_cfg['tor_icons'][$tor_info['tor_status']], + 'TOR_STATUS_ICON' => config()->get('tor_icons')[$tor_info['tor_status']], 'TOR_STATUS_BY' => ($tor_info['checked_user_id'] && ($is_auth['auth_mod'] || $tor_status_by_for_all)) ? (' · ' . profile_url($tor_info) . ' · ' . delta_time($tor_info['checked_time']) . $lang['TOR_BACK'] . '') : '', 'TOR_STATUS_SELECT' => build_select('sel_status', array_flip($lang['TOR_STATUS_NAME']), TOR_APPROVED), - 'TOR_STATUS_REPLY' => $bb_cfg['tor_comment'] && !IS_GUEST && in_array($tor_info['tor_status'], $bb_cfg['tor_reply']) && $userdata['user_id'] == $tor_info['poster_id'] && $t_data['topic_status'] != TOPIC_LOCKED, + 'TOR_STATUS_REPLY' => config()->get('tor_comment') && !IS_GUEST && in_array($tor_info['tor_status'], config()->get('tor_reply')) && $userdata['user_id'] == $tor_info['poster_id'] && $t_data['topic_status'] != TOPIC_LOCKED, //end torrent status mod 'S_UPLOAD_IMAGE' => $upload_image, @@ -227,7 +227,7 @@ if ($tor_reged && $tor_info) { ]); // TorrServer integration - if ($bb_cfg['torr_server']['enabled'] && (!IS_GUEST || !$bb_cfg['torr_server']['disable_for_guest']) && (new \TorrentPier\TorrServerAPI())->getM3UPath($attach_id)) { + if (config()->get('torr_server.enabled') && (!IS_GUEST || !config()->get('torr_server.disable_for_guest')) && (new \TorrentPier\TorrServerAPI())->getM3UPath($attach_id)) { $template->assign_block_vars('postrow.attach.tor_reged.tor_server', [ 'TORR_SERVER_M3U_LINK' => PLAYBACK_M3U_URL . $bt_topic_id, 'TORR_SERVER_M3U_ICON' => $images['icon_tor_m3u_icon'], @@ -239,7 +239,7 @@ if ($tor_reged && $tor_info) { } } - if ($bb_cfg['show_tor_info_in_dl_list']) { + if (config()->get('show_tor_info_in_dl_list')) { $template->assign_vars([ 'SHOW_DL_LIST' => true, 'SHOW_DL_LIST_TOR_INFO' => true, @@ -470,7 +470,7 @@ if ($tor_reged && $tor_info) { } $peerCountry = $lang['HIDDEN_USER']; - if ($bb_cfg['ip2country_settings']['enabled']) { + if (config()->get('ip2country_settings.enabled')) { if (IS_AM || $peer['user_id'] == $userdata['user_id'] || !bf($peer['user_opt'], 'user_opt', 'user_hide_peer_country')) { if ($infoByIP = infoByIP((!empty($peer['ipv6']) ? $peer['ipv6'] : $peer['ip']), $peer['port'])) { if (!empty($infoByIP['countryCode'])) { @@ -500,7 +500,7 @@ if ($tor_reged && $tor_info) { if ($ip) { $template->assign_block_vars("$x_full.$x_row.ip", [ - 'U_WHOIS_IP' => $bb_cfg['whois_info'] . $ip, + 'U_WHOIS_IP' => config()->get('whois_info') . $ip, 'IP' => $ip ]); } @@ -563,7 +563,7 @@ if ($tor_reged && $tor_info) { } } -if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full') { +if (config()->get('bt_allow_spmode_change') && $s_mode != 'full') { $template->assign_vars([ 'PEERS_FULL_LINK' => true, 'SPMODE_FULL_HREF' => TOPIC_URL . "$bt_topic_id&spmode=full#seeders" @@ -571,14 +571,14 @@ if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full') { } $template->assign_vars([ - 'SHOW_DL_LIST_LINK' => (($bb_cfg['bt_show_dl_list'] || $bb_cfg['allow_dl_list_names_mode']) && $t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL), - 'SHOW_TOR_ACT' => ($tor_reged && $show_peers && (!isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) || IS_AM)), + 'SHOW_DL_LIST_LINK' => ((config()->get('bt_show_dl_list') || config()->get('allow_dl_list_names_mode')) && $t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL), + 'SHOW_TOR_ACT' => ($tor_reged && $show_peers && (!isset(config()->get('tor_no_tor_act')[$tor_info['tor_status']]) || IS_AM)), 'S_MODE_COUNT' => ($s_mode == 'count'), 'S_MODE_NAMES' => ($s_mode == 'names'), 'S_MODE_FULL' => ($s_mode == 'full'), 'PEER_EXIST' => ($seeders || $leechers || defined('SEEDER_EXIST') || defined('LEECHER_EXIST')), 'SEED_EXIST' => ($seeders || defined('SEEDER_EXIST')), 'LEECH_EXIST' => ($leechers || defined('LEECHER_EXIST')), - 'TOR_HELP_LINKS' => $bb_cfg['tor_help_links'], - 'CALL_SEED' => (!IS_GUEST && $bb_cfg['callseed'] && $tor_reged && !isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) && $seed_count < 3 && $tor_info['call_seed_time'] < (TIMENOW - 86400)), + 'TOR_HELP_LINKS' => config()->get('tor_help_links'), + 'CALL_SEED' => (!IS_GUEST && config()->get('callseed') && $tor_reged && !isset(config()->get('tor_no_tor_act')[$tor_info['tor_status']]) && $seed_count < 3 && $tor_info['call_seed_time'] < (TIMENOW - 86400)), ]); diff --git a/library/attach_mod/includes/functions_delete.php b/library/attach_mod/includes/functions_delete.php index 4a2b7ae0c..79679db2a 100644 --- a/library/attach_mod/includes/functions_delete.php +++ b/library/attach_mod/includes/functions_delete.php @@ -16,7 +16,7 @@ */ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $user_id = 0) { - global $lang, $bb_cfg; + global $lang; // Generate Array, if it's not an array if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) { @@ -215,7 +215,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } // TorrServer integration - if ($bb_cfg['torr_server']['enabled']) { + if (config()->get('torr_server.enabled')) { $torrServer = new \TorrentPier\TorrServerAPI(); $torrServer->removeM3U($attachments[$j]['attach_id']); } diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php index d2465c275..7e5a40916 100644 --- a/library/includes/bbcode.php +++ b/library/includes/bbcode.php @@ -123,7 +123,7 @@ function prepare_message($message) // Either in a window or inline function generate_smilies($mode) { - global $bb_cfg, $template, $lang, $user, $datastore; + global $template, $lang, $user, $datastore; $inline_columns = 4; $inline_rows = 7; @@ -160,7 +160,7 @@ function generate_smilies($mode) $template->assign_block_vars('smilies_row.smilies_col', [ 'SMILEY_CODE' => $data['code'], - 'SMILEY_IMG' => $bb_cfg['smilies_path'] . '/' . $smile_url, + 'SMILEY_IMG' => config()->get('smilies_path') . '/' . $smile_url, 'SMILEY_DESC' => $data['emoticon'], ]); @@ -341,11 +341,9 @@ function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $s function extract_search_words($text) { - global $bb_cfg; - - $max_words_count = $bb_cfg['max_search_words_per_post']; - $min_word_len = max(2, $bb_cfg['search_min_word_len'] - 1); - $max_word_len = $bb_cfg['search_max_word_len']; + $max_words_count = config()->get('max_search_words_per_post'); + $min_word_len = max(2, config()->get('search_min_word_len') - 1); + $max_word_len = config()->get('search_max_word_len'); $text = ' ' . str_compact(strip_tags(mb_strtolower($text))) . ' '; $text = str_replace(['[', ']'], ['[', ']'], $text); @@ -382,12 +380,10 @@ function extract_search_words($text) function add_search_words($post_id, $post_message, $topic_title = '', $only_return_words = false) { - global $bb_cfg; - $text = $topic_title . ' ' . $post_message; $words = ($text) ? extract_search_words($text) : []; - if ($only_return_words || $bb_cfg['search_engine_type'] == 'sphinx') { + if ($only_return_words || config()->get('search_engine_type') == 'sphinx') { return implode("\n", $words); } @@ -425,22 +421,19 @@ function get_words_rate($text) function hide_passkey($str) { - global $bb_cfg; - return preg_replace("#\?{$bb_cfg['passkey_key']}=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?{$bb_cfg['passkey_key']}=passkey", $str); + return preg_replace("#\?{config()->get('passkey_key')}=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?{config()->get('passkey_key')}=passkey", $str); } function get_parsed_post($postrow, $mode = 'full', $return_chars = 600) { - global $bb_cfg; - - if ($bb_cfg['use_posts_cache'] && !empty($postrow['post_html'])) { + if (config()->get('use_posts_cache') && !empty($postrow['post_html'])) { return $postrow['post_html']; } $message = bbcode2html($postrow['post_text']); // Posts cache - if ($bb_cfg['use_posts_cache']) { + if (config()->get('use_posts_cache')) { DB()->shutdown['post_html'][] = [ 'post_id' => (int)$postrow['post_id'], 'post_html' => (string)$message diff --git a/library/includes/cron/jobs/attach_maintenance.php b/library/includes/cron/jobs/attach_maintenance.php index 99e9a7168..84987405e 100644 --- a/library/includes/cron/jobs/attach_maintenance.php +++ b/library/includes/cron/jobs/attach_maintenance.php @@ -144,7 +144,7 @@ if ($check_attachments) { $orphan_db_attach[] = $row['attach_id']; } // Delete all orphan attachments - if ($bb_cfg['torr_server']['enabled'] && $fix_errors) { + if (config()->get('torr_server.enabled') && $fix_errors) { foreach ($orphan_db_attach as $attach_id) { // TorrServer integration $torrServer = new \TorrentPier\TorrServerAPI(); diff --git a/library/includes/cron/jobs/board_maintenance.php b/library/includes/cron/jobs/board_maintenance.php index de789f9f8..e25cf5f75 100644 --- a/library/includes/cron/jobs/board_maintenance.php +++ b/library/includes/cron/jobs/board_maintenance.php @@ -17,7 +17,7 @@ if (!defined('BB_ROOT')) { \TorrentPier\Legacy\Admin\Common::sync_all_forums(); // Cleaning bb_poll_users -if ($poll_max_days = (int)$bb_cfg['poll_max_days']) { +if ($poll_max_days = (int)config()->get('poll_max_days')) { $per_cycle = 20000; $row = DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM " . BB_POLL_USERS); $start_id = (int)$row['start_id']; @@ -45,12 +45,12 @@ if ($poll_max_days = (int)$bb_cfg['poll_max_days']) { DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400)); // Cleaning post cache -if ($posts_days = (int)$bb_cfg['posts_cache_days_keep']) { +if ($posts_days = (int)config()->get('posts_cache_days_keep')) { DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)"); } // Autofill announcer url -if (empty($bb_cfg['bt_announce_url']) || ($bb_cfg['bt_announce_url'] === 'https://localhost/bt/announce.php')) { +if (empty(config()->get('bt_announce_url')) || (config()->get('bt_announce_url') === 'https://localhost/bt/announce.php')) { bb_update_config(['bt_announce_url' => FULL_URL . 'bt/announce.php']); } diff --git a/library/includes/cron/jobs/clean_dlstat.php b/library/includes/cron/jobs/clean_dlstat.php index 2c2c433b2..490254561 100644 --- a/library/includes/cron/jobs/clean_dlstat.php +++ b/library/includes/cron/jobs/clean_dlstat.php @@ -13,10 +13,10 @@ if (!defined('BB_ROOT')) { // Delete staled dl-status records $keeping_dlstat = [ - DL_STATUS_WILL => (int)$bb_cfg['dl_will_days_keep'], - DL_STATUS_DOWN => (int)$bb_cfg['dl_down_days_keep'], - DL_STATUS_COMPLETE => (int)$bb_cfg['dl_complete_days_keep'], - DL_STATUS_CANCEL => (int)$bb_cfg['dl_cancel_days_keep'] + DL_STATUS_WILL => (int)config()->get('dl_will_days_keep'), + DL_STATUS_DOWN => (int)config()->get('dl_down_days_keep'), + DL_STATUS_COMPLETE => (int)config()->get('dl_complete_days_keep'), + DL_STATUS_CANCEL => (int)config()->get('dl_cancel_days_keep') ]; $delete_dlstat_sql = []; @@ -51,7 +51,7 @@ DB()->query(" "); // Tor-Stats cleanup -if ($torstat_days_keep = (int)$bb_cfg['torstat_days_keep']) { +if ($torstat_days_keep = (int)config()->get('torstat_days_keep')) { DB()->query("DELETE QUICK FROM " . BB_BT_TORSTAT . " WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)"); } diff --git a/library/includes/cron/jobs/clean_log.php b/library/includes/cron/jobs/clean_log.php index c21ee2b5f..b136c298b 100644 --- a/library/includes/cron/jobs/clean_log.php +++ b/library/includes/cron/jobs/clean_log.php @@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -$log_days_keep = (int)$bb_cfg['log_days_keep']; +$log_days_keep = (int)config()->get('log_days_keep'); if ($log_days_keep !== 0) { DB()->query("DELETE FROM " . BB_LOG . " WHERE log_time < " . (TIMENOW - 86400 * $log_days_keep)); diff --git a/library/includes/cron/jobs/clean_pm.php b/library/includes/cron/jobs/clean_pm.php index 1d4203995..abbe6d343 100644 --- a/library/includes/cron/jobs/clean_pm.php +++ b/library/includes/cron/jobs/clean_pm.php @@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -$pm_days_keep = (int)$bb_cfg['pm_days_keep']; +$pm_days_keep = (int)config()->get('pm_days_keep'); if ($pm_days_keep !== 0) { $per_cycle = 20000; diff --git a/library/includes/cron/jobs/demo_mode.php b/library/includes/cron/jobs/demo_mode.php index cbdb252ea..ec02cc498 100644 --- a/library/includes/cron/jobs/demo_mode.php +++ b/library/includes/cron/jobs/demo_mode.php @@ -23,7 +23,7 @@ if (!IN_DEMO_MODE || !is_file($dump_path) || !is_readable($dump_path)) { // Clean cache & datastore $datastore->clean(); -foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) { +foreach (config()->get('cache.engines') as $cache_name => $cache_val) { CACHE($cache_name)->rm(); } diff --git a/library/includes/cron/jobs/prune_forums.php b/library/includes/cron/jobs/prune_forums.php index 722aef2c5..473bb4156 100644 --- a/library/includes/cron/jobs/prune_forums.php +++ b/library/includes/cron/jobs/prune_forums.php @@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -if ($bb_cfg['prune_enable']) { +if (config()->get('prune_enable')) { $sql = "SELECT forum_id, prune_days FROM " . BB_FORUMS . " WHERE prune_days != 0"; foreach (DB()->fetch_rowset($sql) as $row) { diff --git a/library/includes/cron/jobs/prune_inactive_users.php b/library/includes/cron/jobs/prune_inactive_users.php index 92b271a91..527ba0609 100644 --- a/library/includes/cron/jobs/prune_inactive_users.php +++ b/library/includes/cron/jobs/prune_inactive_users.php @@ -17,7 +17,7 @@ while (true) { set_time_limit(600); $prune_users = $not_activated_users = $not_active_users = []; - if ($not_activated_days = (int)$bb_cfg['user_not_activated_days_keep']) { + if ($not_activated_days = (int)config()->get('user_not_activated_days_keep')) { $sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . " WHERE user_level = 0 AND user_lastvisit = 0 @@ -31,7 +31,7 @@ while (true) { } } - if ($not_active_days = (int)$bb_cfg['user_not_active_days_keep']) { + if ($not_active_days = (int)config()->get('user_not_active_days_keep')) { $sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . " WHERE user_level = 0 AND user_posts = 0 diff --git a/library/includes/cron/jobs/prune_topic_moved.php b/library/includes/cron/jobs/prune_topic_moved.php index 9c1f6cb76..d43fa07ce 100644 --- a/library/includes/cron/jobs/prune_topic_moved.php +++ b/library/includes/cron/jobs/prune_topic_moved.php @@ -11,8 +11,8 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -if ($bb_cfg['topic_moved_days_keep']) { - $prune_time = TIMENOW - 86400 * $bb_cfg['topic_moved_days_keep']; +if (config()->get('topic_moved_days_keep')) { + $prune_time = TIMENOW - 86400 * config()->get('topic_moved_days_keep'); DB()->query(" DELETE FROM " . BB_TOPICS . " diff --git a/library/includes/cron/jobs/sessions_cleanup.php b/library/includes/cron/jobs/sessions_cleanup.php index 07fc2a76d..1f6adbc5e 100644 --- a/library/includes/cron/jobs/sessions_cleanup.php +++ b/library/includes/cron/jobs/sessions_cleanup.php @@ -11,10 +11,10 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -$user_session_expire_time = TIMENOW - (int)$bb_cfg['user_session_duration']; -$admin_session_expire_time = TIMENOW - (int)$bb_cfg['admin_session_duration']; +$user_session_expire_time = TIMENOW - (int)config()->get('user_session_duration'); +$admin_session_expire_time = TIMENOW - (int)config()->get('admin_session_duration'); -$user_session_gc_time = $user_session_expire_time - (int)$bb_cfg['user_session_gc_ttl']; +$user_session_gc_time = $user_session_expire_time - (int)config()->get('user_session_gc_ttl'); $admin_session_gc_time = $admin_session_expire_time; // ############################ Tables LOCKED ################################ diff --git a/library/includes/cron/jobs/tr_cleanup_and_dlstat.php b/library/includes/cron/jobs/tr_cleanup_and_dlstat.php index a0a64251f..ecd557c71 100644 --- a/library/includes/cron/jobs/tr_cleanup_and_dlstat.php +++ b/library/includes/cron/jobs/tr_cleanup_and_dlstat.php @@ -27,7 +27,7 @@ DB()->query("CREATE TABLE " . NEW_BB_BT_LAST_USERSTAT . " LIKE " . BB_BT_LAST_US DB()->expect_slow_query(600); // Update dlstat (part 1) -if ($bb_cfg['tracker']['update_dlstat']) { +if (config()->get('tracker.update_dlstat')) { // ############################ Tables LOCKED ################################ DB()->lock([ BB_BT_TRACKER, @@ -64,16 +64,16 @@ DB()->query(" "); // Clean peers table -if ($bb_cfg['tracker']['autoclean']) { - $announce_interval = max((int)$bb_cfg['announce_interval'], 60); - $expire_factor = max((float)$bb_cfg['tracker']['expire_factor'], 1); +if (config()->get('tracker.autoclean')) { + $announce_interval = max((int)config()->get('announce_interval'), 60); + $expire_factor = max((float)config()->get('tracker.expire_factor'), 1); $peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor); DB()->query("DELETE FROM " . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time"); } // Update dlstat (part 2) -if ($bb_cfg['tracker']['update_dlstat']) { +if (config()->get('tracker.update_dlstat')) { // Set "only 1 seeder" bonus DB()->query(" UPDATE diff --git a/library/includes/cron/jobs/tr_maintenance.php b/library/includes/cron/jobs/tr_maintenance.php index 04dd77857..0e7e20dab 100644 --- a/library/includes/cron/jobs/tr_maintenance.php +++ b/library/includes/cron/jobs/tr_maintenance.php @@ -11,12 +11,12 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -if (empty($bb_cfg['seeder_last_seen_days_keep']) || empty($bb_cfg['seeder_never_seen_days_keep'])) { +if (empty(config()->get('seeder_last_seen_days_keep')) || empty(config()->get('seeder_never_seen_days_keep'))) { return; } -$last_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_last_seen_days_keep']; -$never_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_never_seen_days_keep']; +$last_seen_time = TIMENOW - 86400 * config()->get('seeder_last_seen_days_keep'); +$never_seen_time = TIMENOW - 86400 * config()->get('seeder_never_seen_days_keep'); $limit_sql = 3000; $topics_sql = $attach_sql = []; diff --git a/library/includes/cron/jobs/tr_make_snapshot.php b/library/includes/cron/jobs/tr_make_snapshot.php index 3ec24cd92..9dda76187 100644 --- a/library/includes/cron/jobs/tr_make_snapshot.php +++ b/library/includes/cron/jobs/tr_make_snapshot.php @@ -11,8 +11,6 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bb_cfg; - DB()->expect_slow_query(600); // @@ -81,7 +79,7 @@ DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_DLSTATUS_SNAP . ", " . OLD_BB_BT DB()->query("CREATE TABLE " . NEW_BB_BT_DLSTATUS_SNAP . " LIKE " . BB_BT_DLSTATUS_SNAP); -if ($bb_cfg['bt_show_dl_list'] && $bb_cfg['bt_dl_list_only_count']) { +if (config()->get('bt_show_dl_list') && config()->get('bt_dl_list_only_count')) { DB()->query(" INSERT INTO " . NEW_BB_BT_DLSTATUS_SNAP . " (topic_id, dl_status, users_count) @@ -104,7 +102,7 @@ DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_DLSTATUS_SNAP . ", " . OLD_BB_BT // // TORHELP // -if ($bb_cfg['torhelp_enabled']) { +if (config()->get('torhelp_enabled')) { $tor_min_seeders = 0; // "<=" $tor_min_leechers = 2; // ">=" $tor_min_completed = 10; // ">=" @@ -147,7 +145,7 @@ if ($bb_cfg['torhelp_enabled']) { WHERE trsn.seeders <= $tor_min_seeders AND trsn.leechers >= $tor_min_leechers - AND tor.forum_id != " . (int)$bb_cfg['trash_forum_id'] . " + AND tor.forum_id != " . (int)config()->get('trash_forum_id') . " AND tor.complete_count >= $tor_min_completed AND tor.seeder_last_seen <= (UNIX_TIMESTAMP() - $tor_seed_last_seen_days*86400) AND dl.user_id IN($online_users_csv) diff --git a/library/includes/cron/jobs/tr_seed_bonus.php b/library/includes/cron/jobs/tr_seed_bonus.php index 83e817ea9..b3bdaf936 100644 --- a/library/includes/cron/jobs/tr_seed_bonus.php +++ b/library/includes/cron/jobs/tr_seed_bonus.php @@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) { DB()->expect_slow_query(600); -if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['seed_bonus_release']) { +if (config()->get('seed_bonus_enabled') && config()->get('seed_bonus_points') && config()->get('seed_bonus_release')) { DB()->query(" CREATE TEMPORARY TABLE tmp_bonus ( user_id INT UNSIGNED NOT NULL DEFAULT '0', @@ -21,7 +21,7 @@ if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['se ) ENGINE = MEMORY "); - $tor_size = ($bb_cfg['seed_bonus_tor_size'] * 1073741824); + $tor_size = (config()->get('seed_bonus_tor_size') * 1073741824); DB()->query("INSERT INTO tmp_bonus SELECT bt.user_id, count(bt.seeder) AS release_count @@ -32,8 +32,8 @@ if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['se GROUP BY bt.user_id "); - $seed_bonus = unserialize($bb_cfg['seed_bonus_points']); - $seed_release = unserialize($bb_cfg['seed_bonus_release']); + $seed_bonus = unserialize(config()->get('seed_bonus_points')); + $seed_release = unserialize(config()->get('seed_bonus_release')); foreach ($seed_bonus as $i => $points) { if (!$points || !$seed_release[$i]) { @@ -42,7 +42,7 @@ if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['se $user_points = ((float)$points / 4); $release = (int)$seed_release[$i]; - $user_regdate = (TIMENOW - $bb_cfg['seed_bonus_user_regdate'] * 86400); + $user_regdate = (TIMENOW - config()->get('seed_bonus_user_regdate') * 86400); DB()->query(" UPDATE " . BB_USERS . " u, " . BB_BT_USERS . " bu, tmp_bonus b diff --git a/library/includes/cron/jobs/update_forums_atom.php b/library/includes/cron/jobs/update_forums_atom.php index e6151add0..6cbfd1973 100644 --- a/library/includes/cron/jobs/update_forums_atom.php +++ b/library/includes/cron/jobs/update_forums_atom.php @@ -11,13 +11,11 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bb_cfg; - $timecheck = TIMENOW - 600; $forums_data = DB()->fetch_rowset("SELECT forum_id, allow_reg_tracker, forum_name FROM " . BB_FORUMS); -if (is_file($bb_cfg['atom']['path'] . '/f/0.atom')) { - if (filemtime($bb_cfg['atom']['path'] . '/f/0.atom') <= $timecheck) { +if (is_file(config()->get('atom.path') . '/f/0.atom')) { + if (filemtime(config()->get('atom.path') . '/f/0.atom') <= $timecheck) { \TorrentPier\Legacy\Atom::update_forum_feed(0, $forums_data); } } else { @@ -25,8 +23,8 @@ if (is_file($bb_cfg['atom']['path'] . '/f/0.atom')) { } foreach ($forums_data as $forum_data) { - if (is_file($bb_cfg['atom']['path'] . '/f/' . $forum_data['forum_id'] . '.atom')) { - if (filemtime($bb_cfg['atom']['path'] . '/f/' . $forum_data['forum_id'] . '.atom') <= $timecheck) { + if (is_file(config()->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom')) { + if (filemtime(config()->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom') <= $timecheck) { \TorrentPier\Legacy\Atom::update_forum_feed($forum_data['forum_id'], $forum_data); } } else { diff --git a/library/includes/datastore/build_cat_forums.php b/library/includes/datastore/build_cat_forums.php index 8df40d67f..fcf71e9e3 100644 --- a/library/includes/datastore/build_cat_forums.php +++ b/library/includes/datastore/build_cat_forums.php @@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bf, $bb_cfg; +global $bf; // // cat_forums @@ -106,7 +106,7 @@ $this->store('cat_forums', $data); // // jumpbox // -if ($bb_cfg['show_jumpbox']) { +if (config()->get('show_jumpbox')) { $data = [ 'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'), 'user' => get_forum_select('user', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'), @@ -125,8 +125,8 @@ $this->store('viewtopic_forum_select', $data); // // latest_news // -if ($bb_cfg['show_latest_news'] and $news_forum_ids = $bb_cfg['latest_news_forum_id']) { - $news_count = max($bb_cfg['latest_news_count'], 1); +if (config()->get('show_latest_news') and $news_forum_ids = config()->get('latest_news_forum_id')) { + $news_count = max(config()->get('latest_news_count'), 1); $data = DB()->fetch_rowset(" SELECT topic_id, topic_time, topic_title, forum_id @@ -143,8 +143,8 @@ if ($bb_cfg['show_latest_news'] and $news_forum_ids = $bb_cfg['latest_news_forum // // Network_news // -if ($bb_cfg['show_network_news'] and $net_forum_ids = $bb_cfg['network_news_forum_id']) { - $net_count = max($bb_cfg['network_news_count'], 1); +if (config()->get('show_network_news') and $net_forum_ids = config()->get('network_news_forum_id')) { + $net_count = max(config()->get('network_news_count'), 1); $data = DB()->fetch_rowset(" SELECT topic_id, topic_time, topic_title, forum_id diff --git a/library/includes/datastore/build_check_updates.php b/library/includes/datastore/build_check_updates.php index a990d4364..416a9d4f7 100644 --- a/library/includes/datastore/build_check_updates.php +++ b/library/includes/datastore/build_check_updates.php @@ -11,19 +11,17 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bb_cfg; - -if (!$bb_cfg['tp_updater_settings']['enabled']) { +if (!config()->get('tp_updater_settings.enabled')) { return; } $data = []; $updaterDownloader = new \TorrentPier\Updater(); -$updaterDownloader = $updaterDownloader->getLastVersion($bb_cfg['tp_updater_settings']['allow_pre_releases']); +$updaterDownloader = $updaterDownloader->getLastVersion(config()->get('tp_updater_settings.allow_pre_releases')); $getVersion = \TorrentPier\Helpers\VersionHelper::removerPrefix($updaterDownloader['tag_name']); -$currentVersion = \TorrentPier\Helpers\VersionHelper::removerPrefix($bb_cfg['tp_version']); +$currentVersion = \TorrentPier\Helpers\VersionHelper::removerPrefix(config()->get('tp_version')); // Has update! if (\z4kn4fein\SemVer\Version::greaterThan($getVersion, $currentVersion)) { diff --git a/library/includes/datastore/build_smilies.php b/library/includes/datastore/build_smilies.php index 40b9c85f7..204a92e62 100644 --- a/library/includes/datastore/build_smilies.php +++ b/library/includes/datastore/build_smilies.php @@ -11,8 +11,6 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bb_cfg; - $smilies = []; $rowset = DB()->fetch_rowset("SELECT * FROM " . BB_SMILIES); @@ -20,7 +18,7 @@ sort($rowset); foreach ($rowset as $smile) { $smilies['orig'][] = '#(?<=^|\W)' . preg_quote($smile['code'], '#') . '(?=$|\W)#'; - $smilies['repl'][] = ' ' . $smile['code'] . ''; + $smilies['repl'][] = ' ' . $smile['code'] . ''; $smilies['smile'][] = $smile; } diff --git a/library/includes/datastore/build_stats.php b/library/includes/datastore/build_stats.php index e25d8e085..86fd14a35 100644 --- a/library/includes/datastore/build_stats.php +++ b/library/includes/datastore/build_stats.php @@ -11,8 +11,6 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bb_cfg; - $data = []; // usercount @@ -29,7 +27,7 @@ $data['postcount'] = commify($row['postcount']); $data['topiccount'] = commify($row['topiccount']); // Tracker stats -if ($bb_cfg['tor_stats']) { +if (config()->get('tor_stats')) { // torrents stat $row = DB()->fetch_row("SELECT COUNT(topic_id) AS torrentcount, SUM(size) AS size FROM " . BB_BT_TORRENTS); $data['torrentcount'] = commify($row['torrentcount']); @@ -44,7 +42,7 @@ if ($bb_cfg['tor_stats']) { } // gender stat -if ($bb_cfg['gender']) { +if (config()->get('gender')) { $male = DB()->fetch_row("SELECT COUNT(user_id) AS male FROM " . BB_USERS . " WHERE user_gender = " . MALE . " AND user_id NOT IN(" . EXCLUDED_USERS . ")"); $female = DB()->fetch_row("SELECT COUNT(user_id) AS female FROM " . BB_USERS . " WHERE user_gender = " . FEMALE . " AND user_id NOT IN(" . EXCLUDED_USERS . ")"); $unselect = DB()->fetch_row("SELECT COUNT(user_id) AS unselect FROM " . BB_USERS . " WHERE user_gender = 0 AND user_id NOT IN(" . EXCLUDED_USERS . ")"); @@ -55,7 +53,7 @@ if ($bb_cfg['gender']) { } // birthday stat -if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { +if (config()->get('birthday_check_day') && config()->get('birthday_enabled')) { $sql = DB()->fetch_rowset("SELECT user_id, username, user_rank , user_birthday FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ") @@ -66,7 +64,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { "); $date_today = bb_date(TIMENOW, 'md', false); - $date_forward = bb_date(TIMENOW + ($bb_cfg['birthday_check_day'] * 86400), 'md', false); + $date_forward = bb_date(TIMENOW + (config()->get('birthday_check_day') * 86400), 'md', false); $birthday_today_list = $birthday_week_list = []; diff --git a/library/includes/functions.php b/library/includes/functions.php index 67256eb1f..c569b55b3 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -13,22 +13,19 @@ if (!defined('BB_ROOT')) { function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div) { - global $bb_cfg; - $ext = $bb_cfg['file_id_ext'][$ext_id] ?? ''; + $ext = config()->get('file_id_ext')[$ext_id] ?? ''; return ($base_path ? "$base_path/" : '') . floor($id / $first_div) . '/' . ($id % $sec_div) . '/' . $id . ($ext ? ".$ext" : ''); } function get_avatar_path($id, $ext_id, $base_path = null, $first_div = 10000, $sec_div = 100) { - global $bb_cfg; - $base_path ??= $bb_cfg['avatars']['upload_path']; + $base_path ??= config()->get('avatars.upload_path'); return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); } function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 10000, $sec_div = 100) { - global $bb_cfg; - $base_path ??= $bb_cfg['attach']['upload_path']; + $base_path ??= config()->get('attach.upload_path'); return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); } @@ -600,8 +597,6 @@ function humn_size($size, $rounder = null, $min = null, $space = ' ') function bt_show_ip($ip, $port = '') { - global $bb_cfg; - if (IS_AM) { $ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($ip); @@ -617,18 +612,16 @@ function bt_show_ip($ip, $port = '') return $ip; } - return $bb_cfg['bt_show_ip_only_moder'] ? false : \TorrentPier\Helpers\IPHelper::anonymizeIP($ip); + return config()->get('bt_show_ip_only_moder') ? false : \TorrentPier\Helpers\IPHelper::anonymizeIP($ip); } function bt_show_port($port) { - global $bb_cfg; - if (IS_AM) { return $port; } - return $bb_cfg['bt_show_port_only_moder'] ? false : $port; + return config()->get('bt_show_port_only_moder') ? false : $port; } function checkbox_get_val(&$key, &$val, $default = 1, $on = 1, $off = 0) @@ -802,24 +795,24 @@ function str_short($text, $max_length, $space = ' ') function generate_user_info($row, bool $have_auth = IS_ADMIN): array { - global $userdata, $lang, $images, $bb_cfg; + global $userdata, $lang, $images; $from = !empty($row['user_from']) ? render_flag($row['user_from'], false) : $lang['NOSELECT']; $joined = bb_date($row['user_regdate'], 'Y-m-d H:i', false); $user_time = !empty($row['user_time']) ? sprintf('%s (%s)', bb_date($row['user_time']), delta_time($row['user_time'])) : $lang['NOSELECT']; $posts = '' . $row['user_posts'] ?: 0 . ''; - $pm = $bb_cfg['text_buttons'] ? '' . $lang['SEND_PM_TXTB'] . '' : '' . $lang['SEND_PRIVATE_MESSAGE'] . ''; + $pm = config()->get('text_buttons') ? '' . $lang['SEND_PM_TXTB'] . '' : '' . $lang['SEND_PRIVATE_MESSAGE'] . ''; $avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), 50, 50); if (bf($row['user_opt'], 'user_opt', 'user_viewemail') || $have_auth || ($row['user_id'] == $userdata['user_id'])) { - $email_uri = ($bb_cfg['board_email_form']) ? ("profile.php?mode=email&" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email']; + $email_uri = (config()->get('board_email_form')) ? ("profile.php?mode=email&" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email']; $email = '' . $row['user_email'] . ''; } else { $email = $lang['HIDDEN_USER']; } if ($row['user_website']) { - $www = $bb_cfg['text_buttons'] ? '' . $lang['VISIT_WEBSITE_TXTB'] . '' : '' . $lang['VISIT_WEBSITE'] . ''; + $www = config()->get('text_buttons') ? '' . $lang['VISIT_WEBSITE_TXTB'] . '' : '' . $lang['VISIT_WEBSITE'] . ''; } else { $www = $lang['NOSELECT']; } @@ -996,9 +989,9 @@ function get_userdata(int|string $u, bool $is_name = false, bool $allow_guest = function make_jumpbox(): void { - global $datastore, $template, $bb_cfg; + global $datastore, $template; - if (!$bb_cfg['show_jumpbox']) { + if (!config()->get('show_jumpbox')) { return; } @@ -1076,14 +1069,14 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n function setup_style() { - global $bb_cfg, $template, $userdata; + global $template, $userdata; // AdminCP works only with default template - $tpl_dir_name = defined('IN_ADMIN') ? 'default' : basename($bb_cfg['tpl_name']); - $stylesheet = defined('IN_ADMIN') ? 'main.css' : basename($bb_cfg['stylesheet']); + $tpl_dir_name = defined('IN_ADMIN') ? 'default' : basename(config()->get('tpl_name')); + $stylesheet = defined('IN_ADMIN') ? 'main.css' : basename(config()->get('stylesheet')); if (!IS_GUEST && !empty($userdata['tpl_name'])) { - foreach ($bb_cfg['templates'] as $folder => $name) { + foreach (config()->get('templates') as $folder => $name) { if ($userdata['tpl_name'] == $folder) { $tpl_dir_name = basename($userdata['tpl_name']); } @@ -1096,7 +1089,7 @@ function setup_style() $template->assign_vars([ 'SPACER' => make_url('styles/images/spacer.gif'), 'STYLESHEET' => make_url($css_dir . $stylesheet), - 'EXT_LINK_NEW_WIN' => $bb_cfg['ext_link_new_win'], + 'EXT_LINK_NEW_WIN' => config()->get('ext_link_new_win'), 'TPL_DIR' => make_url($css_dir), 'SITE_URL' => make_url('/') ]); @@ -1109,19 +1102,19 @@ function setup_style() // Create date / time with format and friendly date function bb_date($gmepoch, $format = false, $friendly_date = true) { - global $bb_cfg, $lang, $userdata; + global $lang, $userdata; $gmepoch = (int)$gmepoch; if (!$format) { - $format = $bb_cfg['default_dateformat']; + $format = config()->get('default_dateformat'); } if (empty($lang)) { - require_once($bb_cfg['default_lang_dir'] . 'main.php'); + require_once(config()->get('default_lang_dir') . 'main.php'); } if (!defined('IS_GUEST') || IS_GUEST) { - $tz = $bb_cfg['board_timezone']; + $tz = config()->get('board_timezone'); } else { $tz = $userdata['user_timezone']; } @@ -1156,7 +1149,7 @@ function bb_date($gmepoch, $format = false, $friendly_date = true) } } - return ($bb_cfg['translate_dates']) ? strtr(strtoupper($date), $lang['DATETIME']) : $date; + return (config()->get('translate_dates')) ? strtr(strtoupper($date), $lang['DATETIME']) : $date; } /** @@ -1167,12 +1160,11 @@ function bb_date($gmepoch, $format = false, $friendly_date = true) */ function get_user_torrent_client(string $peer_id): string { - global $bb_cfg; static $iconExtension = '.png'; $bestMatch = null; $bestMatchLength = 0; - foreach ($bb_cfg['tor_clients'] as $key => $clientName) { + foreach (config()->get('tor_clients') as $key => $clientName) { if (str_starts_with($peer_id, $key) !== false && strlen($key) > $bestMatchLength) { $bestMatch = $clientName; $bestMatchLength = strlen($key); @@ -1223,12 +1215,11 @@ function render_flag(string $code, bool $showName = true): string function birthday_age($date) { - global $bb_cfg; if (!$date) { return ''; } - $tz = TIMENOW + (3600 * $bb_cfg['board_timezone']); + $tz = TIMENOW + (3600 * config()->get('board_timezone')); return delta_time(strtotime($date, $tz)); } @@ -1339,7 +1330,7 @@ function bb_preg_quote($str, $delimiter) function bb_die($msg_text, $status_code = null) { - global $ajax, $bb_cfg, $lang, $template, $theme, $userdata, $user; + global $ajax, $lang, $template, $theme, $userdata, $user; if (isset($status_code)) { http_response_code($status_code); @@ -1358,7 +1349,7 @@ function bb_die($msg_text, $status_code = null) // If empty lang if (empty($lang)) { - require($bb_cfg['default_lang_dir'] . 'main.php'); + require(config()->get('default_lang_dir') . 'main.php'); } // If empty session @@ -1369,7 +1360,7 @@ function bb_die($msg_text, $status_code = null) // If the header hasn't been output then do it if (!defined('PAGE_HEADER_SENT')) { if (empty($template)) { - $template = new TorrentPier\Legacy\Template(BB_ROOT . "templates/{$bb_cfg['tpl_name']}"); + $template = new TorrentPier\Legacy\Template(BB_ROOT . "templates/" . config()->get('tpl_name')); } if (empty($theme)) { $theme = setup_style(); @@ -1397,8 +1388,6 @@ function bb_die($msg_text, $status_code = null) function bb_simple_die($txt, $status_code = null) { - global $bb_cfg; - header('Content-Type: text/plain; charset=' . DEFAULT_CHARSET); if (isset($status_code)) { @@ -1426,8 +1415,6 @@ function meta_refresh($url, $time = 5) function redirect($url) { - global $bb_cfg; - if (headers_sent($filename, $linenum)) { trigger_error("Headers already sent in $filename($linenum)", E_USER_ERROR); } @@ -1437,11 +1424,11 @@ function redirect($url) } $url = trim($url); - $server_protocol = ($bb_cfg['cookie_secure']) ? 'https://' : 'http://'; + $server_protocol = (config()->get('cookie_secure')) ? 'https://' : 'http://'; - $server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($bb_cfg['server_name'])); - $server_port = ($bb_cfg['server_port'] <> 80) ? ':' . trim($bb_cfg['server_port']) : ''; - $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($bb_cfg['script_path'])); + $server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(config()->get('server_name'))); + $server_port = (config()->get('server_port') <> 80) ? ':' . trim(config()->get('server_port')) : ''; + $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(config()->get('script_path'))); if ($script_name) { $script_name = "/$script_name"; @@ -1549,9 +1536,9 @@ function cat_exists($cat_id): bool function get_topic_icon($topic, $is_unread = null) { - global $bb_cfg, $images; + global $images; - $t_hot = ($topic['topic_replies'] >= $bb_cfg['hot_threshold']); + $t_hot = ($topic['topic_replies'] >= config()->get('hot_threshold')); $is_unread ??= is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']); if ($topic['topic_status'] == TOPIC_MOVED) { @@ -1684,7 +1671,7 @@ function clean_title($str, $replace_underscore = false) function clean_text_match($text, $ltrim_star = true, $die_if_empty = false) { - global $bb_cfg, $lang; + global $lang; $text = str_compact($text); $ltrim_chars = ($ltrim_star) ? ' *-!' : ' '; @@ -1692,7 +1679,7 @@ function clean_text_match($text, $ltrim_star = true, $die_if_empty = false) $text = ' ' . str_compact(ltrim($text, $ltrim_chars)) . ' '; - if ($bb_cfg['search_engine_type'] == 'sphinx') { + if (config()->get('search_engine_type') == 'sphinx') { $text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3" $text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // valid characters (except '"' which are separate) $text = str_replace(['-', '*'], [' -', '* '], $text); // only at the beginning/end of a word @@ -1742,7 +1729,7 @@ function log_sphinx_error($err_type, $err_msg, $query = '') function get_title_match_topics($title_match_sql, array $forum_ids = []) { - global $bb_cfg, $sphinx, $userdata, $title_match, $lang; + global $sphinx, $userdata, $title_match, $lang; $where_ids = []; if ($forum_ids) { @@ -1750,12 +1737,12 @@ function get_title_match_topics($title_match_sql, array $forum_ids = []) } $title_match_sql = encode_text_match($title_match_sql); - if ($bb_cfg['search_engine_type'] == 'sphinx') { + if (config()->get('search_engine_type') == 'sphinx') { $sphinx = init_sphinx(); $where = $title_match ? 'topics' : 'posts'; - $sphinx->setServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']); + $sphinx->setServer(config()->get('sphinx_topic_titles_host'), config()->get('sphinx_topic_titles_port')); if ($forum_ids) { $sphinx->setFilter('forum_id', $forum_ids, false); } @@ -1775,9 +1762,9 @@ function get_title_match_topics($title_match_sql, array $forum_ids = []) if ($warning = $sphinx->getLastWarning()) { log_sphinx_error('wrn', $warning, $title_match_sql); } - } elseif ($bb_cfg['search_engine_type'] == 'mysql') { + } elseif (config()->get('search_engine_type') == 'mysql') { $where_forum = ($forum_ids) ? "AND forum_id IN(" . implode(',', $forum_ids) . ")" : ''; - $search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : ''; + $search_bool_mode = (config()->get('allow_search_in_bool_mode')) ? ' IN BOOLEAN MODE' : ''; if ($title_match) { $where_id = 'topic_id'; @@ -1832,14 +1819,14 @@ function decode_text_match($txt) */ function create_magnet(string $infohash, string $infohash_v2, string $auth_key, string $name, int|string $length = 0): string { - global $bb_cfg, $images, $lang; + global $images, $lang; - if (!$bb_cfg['magnet_links_enabled']) { + if (!config()->get('magnet_links_enabled')) { return false; } // Only for registered users - if (!$bb_cfg['magnet_links_for_guests'] && IS_GUEST) { + if (!config()->get('magnet_links_for_guests') && IS_GUEST) { return false; } @@ -1864,7 +1851,7 @@ function create_magnet(string $infohash, string $infohash_v2, string $auth_key, $magnet .= '&xl=' . $length; } - return ''; + return 'get('passkey_key') . "=$auth_key") . '&dn=' . urlencode($name) . '">'; } function set_die_append_msg($forum_id = null, $topic_id = null, $group_id = null) @@ -1925,7 +1912,7 @@ function send_pm($user_id, $subject, $message, $poster_id = BOT_UID) */ function profile_url(array $data, bool $target_blank = false, bool $no_link = false): string { - global $bb_cfg, $lang, $datastore; + global $lang, $datastore; if (!$ranks = $datastore->get('ranks')) { $datastore->update('ranks'); @@ -1940,7 +1927,7 @@ function profile_url(array $data, bool $target_blank = false, bool $no_link = fa $style = 'colorUser'; if (isset($ranks[$user_rank])) { $title = $ranks[$user_rank]['rank_title']; - if ($bb_cfg['color_nick']) { + if (config()->get('color_nick')) { $style = $ranks[$user_rank]['rank_style']; } } @@ -1968,18 +1955,16 @@ function profile_url(array $data, bool $target_blank = false, bool $no_link = fa function get_avatar($user_id, $ext_id, $allow_avatar = true, $height = '', $width = '') { - global $bb_cfg; - $height = $height ? 'height="' . $height . '"' : ''; $width = $width ? 'width="' . $width . '"' : ''; - $user_avatar = '' . $user_id . ''; + $user_avatar = '' . $user_id . ''; - if ($user_id == BOT_UID && $bb_cfg['avatars']['bot_avatar']) { - $user_avatar = '' . $user_id . ''; + if ($user_id == BOT_UID && config()->get('avatars.bot_avatar')) { + $user_avatar = '' . $user_id . ''; } elseif ($allow_avatar && $ext_id) { if (is_file(get_avatar_path($user_id, $ext_id))) { - $user_avatar = '' . $user_id . ''; + $user_avatar = '' . $user_id . ''; } } @@ -1994,9 +1979,9 @@ function get_avatar($user_id, $ext_id, $allow_avatar = true, $height = '', $widt */ function genderImage(int $gender): ?string { - global $bb_cfg, $lang, $images; + global $lang, $images; - if (!$bb_cfg['gender']) { + if (!config()->get('gender')) { return false; } @@ -2009,12 +1994,12 @@ function genderImage(int $gender): ?string function is_gold($type): string { - global $lang, $bb_cfg, $images; + global $lang, $images; $type = (int)$type; $is_gold = ''; - if (!$bb_cfg['tracker']['gold_silver_enabled']) { + if (!config()->get('tracker.gold_silver_enabled')) { return $is_gold; } @@ -2083,10 +2068,10 @@ function hash_search($hash) */ function bb_captcha(string $mode): bool|string { - global $bb_cfg, $lang; + global $lang; - $settings = $bb_cfg['captcha']; - $settings['language'] = $bb_cfg['default_lang']; + $settings = config()->get('captcha'); + $settings['language'] = config()->get('default_lang'); // Checking captcha settings if (!$settings['disabled'] && $settings['service'] !== 'text') { @@ -2138,13 +2123,13 @@ function clean_tor_dirname($dirname) */ function user_birthday_icon($user_birthday, $user_id): string { - global $bb_cfg, $images, $lang; + global $images, $lang; $current_date = bb_date(TIMENOW, 'md', false); $user_birthday = ($user_id != GUEST_UID && !empty($user_birthday) && $user_birthday != '1900-01-01') ? bb_date(strtotime($user_birthday), 'md', false) : false; - return ($bb_cfg['birthday_enabled'] && $current_date == $user_birthday) ? '' . $lang['HAPPY_BIRTHDAY'] . '' : ''; + return (config()->get('birthday_enabled') && $current_date == $user_birthday) ? '' . $lang['HAPPY_BIRTHDAY'] . '' : ''; } /** @@ -2190,9 +2175,7 @@ function readUpdaterFile(): array|bool */ function infoByIP(string $ipAddress, int $port = 0): array { - global $bb_cfg; - - if (!$bb_cfg['ip2country_settings']['enabled']) { + if (!config()->get('ip2country_settings.enabled')) { return []; } @@ -2203,14 +2186,14 @@ function infoByIP(string $ipAddress, int $port = 0): array $data = []; $contextOptions = []; - if (!empty($bb_cfg['ip2country_settings']['api_token'])) { + if (!empty(config()->get('ip2country_settings.api_token'))) { $contextOptions['http'] = [ - 'header' => "Authorization: Bearer " . $bb_cfg['ip2country_settings']['api_token'] . "\r\n" + 'header' => "Authorization: Bearer " . config()->get('ip2country_settings.api_token') . "\r\n" ]; } $context = stream_context_create($contextOptions); - $response = file_get_contents($bb_cfg['ip2country_settings']['endpoint'] . $ipAddress, context: $context); + $response = file_get_contents(config()->get('ip2country_settings.endpoint') . $ipAddress, context: $context); if ($response !== false) { $json = json_decode($response, true); diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index f8f0cd0c2..11fab663f 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -39,9 +39,7 @@ function send_page($contents) */ function compress_output($contents) { - global $bb_cfg; - - if ($bb_cfg['gzip_compress'] && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) { + if (config()->get('gzip_compress') && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) { if (UA_GZIP_SUPPORTED && strlen($contents) > 2000) { header('Content-Encoding: gzip'); $contents = gzencode($contents, 1); @@ -59,7 +57,7 @@ if (!defined('IN_AJAX')) { } // Cookie params -$c = $bb_cfg['cookie_prefix']; +$c = config()->get('cookie_prefix'); define('COOKIE_DATA', $c . 'data'); define('COOKIE_FORUM', $c . 'f'); define('COOKIE_MARK', $c . 'mark_read'); @@ -85,16 +83,14 @@ define('COOKIE_MAX_TRACKS', 90); */ function bb_setcookie(string $name, mixed $val, int $lifetime = COOKIE_PERSIST, bool $httponly = false, bool $isRaw = false): void { - global $bb_cfg; - $cookie = new \Josantonius\Cookie\Cookie( - domain: $bb_cfg['cookie_domain'], + domain: config()->get('cookie_domain'), expires: $lifetime, httpOnly: $httponly, - path: $bb_cfg['script_path'], + path: config()->get('script_path'), raw: $isRaw, - sameSite: $bb_cfg['cookie_same_site'], - secure: $bb_cfg['cookie_secure'] + sameSite: config()->get('cookie_same_site'), + secure: config()->get('cookie_secure') ); if (!empty($val)) { @@ -275,14 +271,14 @@ define('PAGE_HEADER', INC_DIR . '/page_header.php'); define('PAGE_FOOTER', INC_DIR . '/page_footer.php'); define('CAT_URL', 'index.php?' . POST_CAT_URL . '='); -define('DL_URL', $bb_cfg['dl_url']); +define('DL_URL', config()->get('dl_url')); define('FORUM_URL', 'viewforum.php?' . POST_FORUM_URL . '='); define('GROUP_URL', 'group.php?' . POST_GROUPS_URL . '='); -define('LOGIN_URL', $bb_cfg['login_url']); +define('LOGIN_URL', config()->get('login_url')); define('MODCP_URL', 'modcp.php?' . POST_FORUM_URL . '='); -define('PM_URL', $bb_cfg['pm_url']); +define('PM_URL', config()->get('pm_url')); define('POST_URL', 'viewtopic.php?' . POST_POST_URL . '='); -define('POSTING_URL', $bb_cfg['posting_url']); +define('POSTING_URL', config()->get('posting_url')); define('PROFILE_URL', 'profile.php?mode=viewprofile&' . POST_USERS_URL . '='); define('BONUS_URL', 'profile.php?mode=bonus'); define('TOPIC_URL', 'viewtopic.php?' . POST_TOPIC_URL . '='); @@ -398,7 +394,7 @@ if ( !is_file(CRON_RUNNING) && (TorrentPier\Helpers\CronHelper::isEnabled() || defined('START_CRON')) ) { - if (TIMENOW - $bb_cfg['cron_last_check'] > $bb_cfg['cron_check_interval']) { + if (TIMENOW - config()->get('cron_last_check') > config()->get('cron_check_interval')) { /** Update cron_last_check */ bb_update_config(['cron_last_check' => TIMENOW + 10]); @@ -438,8 +434,8 @@ if ( /** * Exit if board is disabled via trigger */ -if (($bb_cfg['board_disable'] || is_file(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN')) { - if ($bb_cfg['board_disable']) { +if ((config()->get('board_disable') || is_file(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN')) { + if (config()->get('board_disable')) { // admin lock send_no_cache_headers(); bb_die('BOARD_DISABLE', 503); diff --git a/library/includes/online_userlist.php b/library/includes/online_userlist.php index 7434f79ea..ca3651e72 100644 --- a/library/includes/online_userlist.php +++ b/library/includes/online_userlist.php @@ -116,7 +116,7 @@ if (!$online['userlist']) { $total_online = $logged_online + $guests_online; -if ($total_online > $bb_cfg['record_online_users']) { +if ($total_online > config()->get('record_online_users')) { bb_update_config([ 'record_online_users' => $total_online, 'record_online_date' => TIMENOW diff --git a/library/includes/page_footer.php b/library/includes/page_footer.php index 2eadbe6f2..80b15b559 100644 --- a/library/includes/page_footer.php +++ b/library/includes/page_footer.php @@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -global $bb_cfg, $userdata, $template, $DBS, $lang; +global $userdata, $template, $DBS, $lang; if (!empty($template)) { $birthday_tp = ((string)bb_date(TIMENOW, 'd.m', false) === '04.04') ? ' | 🎉🍰💚' : ''; @@ -29,7 +29,7 @@ if (!empty($template)) { $show_dbg_info = (DBG_USER && !(isset($_GET['pane']) && $_GET['pane'] == 'left')); -if (!$bb_cfg['gzip_compress']) { +if (!config()->get('gzip_compress')) { flush(); } @@ -37,7 +37,7 @@ if ($show_dbg_info) { $gen_time = utime() - TIMESTART; $gen_time_txt = sprintf('%.3f', $gen_time); $gzip_text = UA_GZIP_SUPPORTED ? "{$lang['GZIP_COMPRESSION']}: " : "{$lang['GZIP_COMPRESSION']}: "; - $gzip_text .= $bb_cfg['gzip_compress'] ? $lang['ON'] : $lang['OFF']; + $gzip_text .= config()->get('gzip_compress') ? $lang['ON'] : $lang['OFF']; $stat = '[  ' . $lang['EXECUTION_TIME'] . " $gen_time_txt " . $lang['SEC']; @@ -51,7 +51,7 @@ if ($show_dbg_info) { $stat .= "  |  $gzip_text"; $stat .= '  |  ' . $lang['MEMORY']; - $stat .= humn_size($bb_cfg['mem_on_start'], 2) . ' / '; + $stat .= humn_size(config()->get('mem_on_start'), 2) . ' / '; $stat .= humn_size(sys('mem_peak'), 2) . ' / '; $stat .= humn_size(sys('mem'), 2); @@ -83,7 +83,7 @@ echo ' if (defined('REQUESTED_PAGE') && !defined('DISABLE_CACHING_OUTPUT')) { if (IS_GUEST === true) { - caching_output(true, 'store', REQUESTED_PAGE . '_guest_' . $bb_cfg['default_lang']); + caching_output(true, 'store', REQUESTED_PAGE . '_guest_' . config()->get('default_lang')); } } diff --git a/library/includes/page_header.php b/library/includes/page_header.php index 195bcec10..e3bdc3e12 100644 --- a/library/includes/page_header.php +++ b/library/includes/page_header.php @@ -16,7 +16,7 @@ if (defined('PAGE_HEADER_SENT')) { } // Parse and show the overall page header -global $page_cfg, $userdata, $user, $ads, $bb_cfg, $template, $lang, $images; +global $page_cfg, $userdata, $user, $ads, $template, $lang, $images; $logged_in = (int)!empty($userdata['session_logged_in']); @@ -52,7 +52,7 @@ if (defined('SHOW_ONLINE') && SHOW_ONLINE) { 'TOTAL_USERS_ONLINE' => ${$online_list}['stat'], 'LOGGED_IN_USER_LIST' => ${$online_list}['userlist'], 'USERS_ONLINE_COUNTS' => ${$online_list}['cnt'], - 'RECORD_USERS' => sprintf($lang['RECORD_ONLINE_USERS'], $bb_cfg['record_online_users'], bb_date($bb_cfg['record_online_date'])), + 'RECORD_USERS' => sprintf($lang['RECORD_ONLINE_USERS'], config()->get('record_online_users'), bb_date(config()->get('record_online_date'))), ]); } @@ -122,12 +122,12 @@ $template->assign_vars([ 'USER_OPTIONS_JS' => IS_GUEST ? '{}' : json_encode($user->opt_js, JSON_THROW_ON_ERROR), 'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']), - 'ALLOW_ROBOTS' => !$bb_cfg['board_disable'] && (!isset($page_cfg['allow_robots']) || $page_cfg['allow_robots'] === true), + 'ALLOW_ROBOTS' => !config()->get('board_disable') && (!isset($page_cfg['allow_robots']) || $page_cfg['allow_robots'] === true), 'META_DESCRIPTION' => !empty($page_cfg['meta_description']) ? trim(htmlCHR($page_cfg['meta_description'])) : '', - 'SITENAME' => $bb_cfg['sitename'], + 'SITENAME' => config()->get('sitename'), 'U_INDEX' => BB_ROOT . 'index.php', - 'T_INDEX' => sprintf($lang['FORUM_INDEX'], $bb_cfg['sitename']), + 'T_INDEX' => sprintf($lang['FORUM_INDEX'], config()->get('sitename')), 'IS_GUEST' => IS_GUEST, 'IS_USER' => IS_USER, @@ -138,9 +138,9 @@ $template->assign_vars([ 'FORUM_PATH' => FORUM_PATH, 'FULL_URL' => FULL_URL, - 'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, $bb_cfg['last_visit_date_format'], false)), - 'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', (float)$bb_cfg['board_timezone'])])), - 'BOARD_TIMEZONE' => $bb_cfg['board_timezone'], + 'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, config()->get('last_visit_date_format'), false)), + 'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', (float)config()->get('board_timezone'))])), + 'BOARD_TIMEZONE' => config()->get('board_timezone'), 'PM_INFO' => $pm_info, 'PRIVMSG_IMG' => $icon_pm, @@ -151,7 +151,7 @@ $template->assign_vars([ 'THIS_USER' => profile_url($userdata), 'THIS_AVATAR' => get_avatar($userdata['user_id'], $userdata['avatar_ext_id'], !bf($userdata['user_opt'], 'user_opt', 'dis_avatar')), 'SHOW_LOGIN_LINK' => !defined('IN_LOGIN'), - 'AUTOLOGIN_DISABLED' => !$bb_cfg['allow_autologin'], + 'AUTOLOGIN_DISABLED' => !config()->get('allow_autologin'), 'S_LOGIN_ACTION' => LOGIN_URL, 'U_CUR_DOWNLOADS' => PROFILE_URL . $userdata['user_id'], @@ -167,11 +167,11 @@ $template->assign_vars([ 'U_REGISTER' => 'profile.php?mode=register', 'U_SEARCH' => 'search.php', 'U_SEND_PASSWORD' => "profile.php?mode=sendpassword", - 'U_TERMS' => $bb_cfg['terms_and_conditions_url'], + 'U_TERMS' => config()->get('terms_and_conditions_url'), 'U_TRACKER' => 'tracker.php', - 'SHOW_SIDEBAR1' => !empty($bb_cfg['page']['show_sidebar1'][BB_SCRIPT]) || $bb_cfg['show_sidebar1_on_every_page'], - 'SHOW_SIDEBAR2' => !empty($bb_cfg['page']['show_sidebar2'][BB_SCRIPT]) || $bb_cfg['show_sidebar2_on_every_page'], + 'SHOW_SIDEBAR1' => !empty(config()->get('page.show_sidebar1')[BB_SCRIPT]) || config()->get('show_sidebar1_on_every_page'), + 'SHOW_SIDEBAR2' => !empty(config()->get('page.show_sidebar2')[BB_SCRIPT]) || config()->get('show_sidebar2_on_every_page'), 'HTML_AGREEMENT' => LANG_DIR . 'html/user_agreement.html', 'HTML_COPYRIGHT' => LANG_DIR . 'html/copyright_holders.html', @@ -185,11 +185,11 @@ $template->assign_vars([ 'DOWNLOAD_URL' => BB_ROOT . DL_URL, 'FORUM_URL' => BB_ROOT . FORUM_URL, 'GROUP_URL' => BB_ROOT . GROUP_URL, - 'LOGIN_URL' => $bb_cfg['login_url'], + 'LOGIN_URL' => config()->get('login_url'), 'NEWEST_URL' => '&view=newest#newest', - 'PM_URL' => $bb_cfg['pm_url'], + 'PM_URL' => config()->get('pm_url'), 'POST_URL' => BB_ROOT . POST_URL, - 'POSTING_URL' => $bb_cfg['posting_url'], + 'POSTING_URL' => config()->get('posting_url'), 'PROFILE_URL' => BB_ROOT . PROFILE_URL, 'BONUS_URL' => BB_ROOT . BONUS_URL, 'TOPIC_URL' => BB_ROOT . TOPIC_URL, @@ -208,7 +208,7 @@ $template->assign_vars([ 'U_WATCHED_TOPICS' => 'profile.php?mode=watch' ]); -if (!empty($bb_cfg['page']['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp'])) { +if (!empty(config()->get('page.show_torhelp')[BB_SCRIPT]) && !empty($userdata['torhelp'])) { $ignore_time = !empty($_COOKIE['torhelp']) ? (int)$_COOKIE['torhelp'] : 0; if (TIMENOW > $ignore_time) { @@ -249,6 +249,6 @@ $template->pparse('page_header'); define('PAGE_HEADER_SENT', true); -if (!$bb_cfg['gzip_compress']) { +if (!config()->get('gzip_compress')) { flush(); } diff --git a/library/includes/torrent_show_dl_list.php b/library/includes/torrent_show_dl_list.php index b5384f4ad..02e1f6f7b 100644 --- a/library/includes/torrent_show_dl_list.php +++ b/library/includes/torrent_show_dl_list.php @@ -21,12 +21,12 @@ $dl_users_div_style_overflow = "padding: 6px; height: $dl_users_overflow_div_hei $template->assign_vars(['DL_BUTTONS' => false]); -$count_mode = ($bb_cfg['bt_dl_list_only_count'] && !(@$_GET['dl'] === 'names')); +$count_mode = (config()->get('bt_dl_list_only_count') && !(@$_GET['dl'] === 'names')); -$have_dl_buttons_enabled = ($bb_cfg['bt_show_dl_but_will'] || $bb_cfg['bt_show_dl_but_down'] || $bb_cfg['bt_show_dl_but_compl'] || $bb_cfg['bt_show_dl_but_cancel']); -$dl_topic = ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL && !($bb_cfg['bt_dl_list_only_1st_page'] && $start)); -$show_dl_list = ($dl_topic && ($bb_cfg['bt_show_dl_list'] || ($bb_cfg['allow_dl_list_names_mode'] && @$_GET['dl'] === 'names'))); -$show_dl_buttons = (!IS_GUEST && $dl_topic && $bb_cfg['bt_show_dl_list_buttons']); +$have_dl_buttons_enabled = (config()->get('bt_show_dl_but_will') || config()->get('bt_show_dl_but_down') || config()->get('bt_show_dl_but_compl') || config()->get('bt_show_dl_but_cancel')); +$dl_topic = ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL && !(config()->get('bt_dl_list_only_1st_page') && $start)); +$show_dl_list = ($dl_topic && (config()->get('bt_show_dl_list') || (config()->get('allow_dl_list_names_mode') && @$_GET['dl'] === 'names'))); +$show_dl_buttons = (!IS_GUEST && $dl_topic && config()->get('bt_show_dl_list_buttons')); // link to clear DL-List $template->assign_vars(['S_DL_DELETE' => false]); @@ -99,7 +99,7 @@ if ($show_dl_list) { ]); } } - } elseif ($bb_cfg['bt_show_dl_list_buttons'] && $have_dl_buttons_enabled) { + } elseif (config()->get('bt_show_dl_list_buttons') && $have_dl_buttons_enabled) { $template->assign_block_vars('dl_list_none', []); } } @@ -107,10 +107,10 @@ if ($show_dl_list) { if ($show_dl_buttons) { $template->assign_vars([ 'DL_BUTTONS' => true, - 'DL_BUT_WILL' => $bb_cfg['bt_show_dl_but_will'], - 'DL_BUT_DOWN' => $bb_cfg['bt_show_dl_but_down'], - 'DL_BUT_COMPL' => $bb_cfg['bt_show_dl_but_compl'], - 'DL_BUT_CANCEL' => $bb_cfg['bt_show_dl_but_cancel'] + 'DL_BUT_WILL' => config()->get('bt_show_dl_but_will'), + 'DL_BUT_DOWN' => config()->get('bt_show_dl_but_down'), + 'DL_BUT_COMPL' => config()->get('bt_show_dl_but_compl'), + 'DL_BUT_CANCEL' => config()->get('bt_show_dl_but_cancel') ]); $dl_hidden_fields = '