diff --git a/library/language/source/html/sidebar2.html b/library/language/source/html/sidebar2.html
index 08a4bdf20..168ec84a7 100644
--- a/library/language/source/html/sidebar2.html
+++ b/library/language/source/html/sidebar2.html
@@ -7,5 +7,5 @@
style/templates/default/page_footer.tpl
- To disable this sidebar, set the variable $bb_cfg['page']['show_sidebar2'] in file config.php to false.
+ To disable this sidebar, set the variable page.show_sidebar2 in file config.php to false.
diff --git a/src/Legacy/Admin/Common.php b/src/Legacy/Admin/Common.php
index eeb5bbeda..db0d93215 100644
--- a/src/Legacy/Admin/Common.php
+++ b/src/Legacy/Admin/Common.php
@@ -217,7 +217,7 @@ class Common
*/
public static function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $prune_all = false)
{
- global $bb_cfg, $lang, $log_action;
+ global $lang, $log_action;
$topic_csv = [];
$prune = ($mode_or_topic_id === 'prune');
@@ -348,7 +348,7 @@ class Common
@unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename);
}
// TorrServer integration
- if ($bb_cfg['torr_server']['enabled']) {
+ if (config()->get('torr_server.enabled')) {
$torrServer = new \TorrentPier\TorrServerAPI();
$torrServer->removeM3U($row['attach_id']);
}
@@ -699,7 +699,7 @@ class Common
*/
public static function user_delete($user_id, $delete_posts = false)
{
- global $bb_cfg, $log_action;
+ global $log_action;
if (!$user_csv = get_id_csv($user_id)) {
return false;
@@ -779,7 +779,7 @@ class Common
// Delete user feed
foreach (explode(',', $user_csv) as $user_id) {
- $file_path = $bb_cfg['atom']['path'] . '/u/' . floor($user_id / 5000) . '/' . ($user_id % 100) . '/' . $user_id . '.atom';
+ $file_path = config()->get('atom.path') . '/u/' . floor($user_id / 5000) . '/' . ($user_id % 100) . '/' . $user_id . '.atom';
@unlink($file_path);
}
}
diff --git a/src/Legacy/BBCode.php b/src/Legacy/BBCode.php
index 330fc6a02..2825e57d1 100644
--- a/src/Legacy/BBCode.php
+++ b/src/Legacy/BBCode.php
@@ -157,15 +157,13 @@ class BBCode
*/
public function bbcode2html(string $text): string
{
- global $bb_cfg;
-
$text = self::clean_up($text);
$text = $this->parse($text);
$text = $this->make_clickable($text);
$text = $this->smilies_pass($text);
$text = $this->new_line2html($text);
- if ($bb_cfg['tidy_post']) {
+ if (config()->get('tidy_post')) {
$text = $this->tidy($text);
}
@@ -395,9 +393,7 @@ class BBCode
*/
private function nofollow_url(string $href, string $name): string
{
- global $bb_cfg;
-
- if (\in_array(parse_url($href, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) {
+ if (\in_array(parse_url($href, PHP_URL_HOST), config()->get('nofollow.allowed_url')) || config()->get('nofollow.disabled')) {
$link = "$name";
} else {
$link = "$name";
diff --git a/src/Legacy/Common/Select.php b/src/Legacy/Common/Select.php
index 424c99869..69b7c5959 100644
--- a/src/Legacy/Common/Select.php
+++ b/src/Legacy/Common/Select.php
@@ -25,11 +25,9 @@ class Select
*/
public static function language(string $default_lang, string $select_name = 'language'): mixed
{
- global $bb_cfg;
-
$lang_select = '';
- return ($x > 1) ? $lang_select : reset($bb_cfg['lang']);
+ $languages = config()->get('lang');
+ return ($x > 1) ? $lang_select : reset($languages);
}
/**
@@ -77,11 +76,9 @@ class Select
*/
public static function template(string $default_style, string $select_name = 'tpl_name'): mixed
{
- global $bb_cfg;
-
$templates_select = '';
- return ($x > 1) ? $templates_select : reset($bb_cfg['templates']);
+ $templates = config()->get('templates');
+ return ($x > 1) ? $templates_select : reset($templates);
}
}
diff --git a/src/Legacy/Common/Upload.php b/src/Legacy/Common/Upload.php
index 685614803..d16542c07 100644
--- a/src/Legacy/Common/Upload.php
+++ b/src/Legacy/Common/Upload.php
@@ -103,7 +103,7 @@ class Upload
*/
public function init(array $cfg = [], array $post_params = [], bool $uploaded_only = true): bool
{
- global $bb_cfg, $lang;
+ global $lang;
$this->cfg = array_merge($this->cfg, $cfg);
$this->file = $post_params;
@@ -150,7 +150,7 @@ class Upload
$file_name_ary = explode('.', $this->file['name']);
$this->file_ext = strtolower(end($file_name_ary));
- $this->ext_ids = array_flip($bb_cfg['file_id_ext']);
+ $this->ext_ids = array_flip(config()->get('file_id_ext'));
// Actions for images [E.g. Change avatar]
if ($this->cfg['max_width'] || $this->cfg['max_height']) {
diff --git a/src/Legacy/Common/User.php b/src/Legacy/Common/User.php
index f6a424b55..f5738083e 100644
--- a/src/Legacy/Common/User.php
+++ b/src/Legacy/Common/User.php
@@ -243,8 +243,6 @@ class User
*/
public function session_create(array $userdata, bool $auto_created = false): array
{
- global $bb_cfg;
-
$this->data = $userdata;
$session_id = $this->sessiondata['sid'];
@@ -281,8 +279,8 @@ class User
if (!$session_time = $this->data['user_session_time']) {
$last_visit = TIMENOW;
define('FIRST_LOGON', true);
- } elseif ($session_time < (TIMENOW - $bb_cfg['last_visit_update_intrv'])) {
- $last_visit = max($session_time, (TIMENOW - 86400 * $bb_cfg['max_last_visit_days']));
+ } elseif ($session_time < (TIMENOW - config()->get('last_visit_update_intrv'))) {
+ $last_visit = max($session_time, (TIMENOW - 86400 * config()->get('max_last_visit_days')));
}
if ($last_visit != $this->data['user_lastvisit']) {
@@ -463,7 +461,6 @@ class User
*/
public function set_session_cookies($user_id)
{
- global $bb_cfg;
$debug_cookies = [
COOKIE_DBG,
diff --git a/src/Legacy/LogAction.php b/src/Legacy/LogAction.php
index b1d7b2dfb..25689c853 100644
--- a/src/Legacy/LogAction.php
+++ b/src/Legacy/LogAction.php
@@ -44,7 +44,7 @@ class LogAction
*/
public function init()
{
- global $lang, $bb_cfg;
+ global $lang;
foreach ($lang['LOG_ACTION']['LOG_TYPE'] as $log_type => $log_desc) {
$this->log_type_select[strip_tags($log_desc)] = $this->log_type[$log_type];
diff --git a/src/Legacy/Post.php b/src/Legacy/Post.php
index 0a08cb3d2..feb0a71f1 100644
--- a/src/Legacy/Post.php
+++ b/src/Legacy/Post.php
@@ -31,7 +31,7 @@ class Post
*/
public static function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &$message)
{
- global $bb_cfg, $user, $userdata, $lang;
+ global $user, $userdata, $lang;
// Check username
if (!empty($username)) {
@@ -60,15 +60,15 @@ class Post
}
// Check smilies limit
- if ($bb_cfg['max_smilies']) {
- $count_smilies = substr_count(bbcode2html($message), '
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')) {
bb_die($lang['FLOOD_ERROR']);
}
}
@@ -200,9 +200,9 @@ class Post
update_post_html(['post_id' => $post_id, 'post_text' => $post_message]);
// Updating news cache on index page
- if ($bb_cfg['show_latest_news']) {
- $news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));
- if (isset($news_forums[$forum_id]) && $bb_cfg['show_latest_news'] && $mode == 'newtopic') {
+ if (config()->get('show_latest_news')) {
+ $news_forums = array_flip(explode(',', config()->get('latest_news_forum_id')));
+ if (isset($news_forums[$forum_id]) && config()->get('show_latest_news') && $mode == 'newtopic') {
$datastore->enqueue([
'latest_news'
]);
@@ -210,9 +210,9 @@ class Post
}
}
- if ($bb_cfg['show_network_news']) {
- $net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id']));
- if (isset($net_forums[$forum_id]) && $bb_cfg['show_network_news'] && $mode == 'newtopic') {
+ if (config()->get('show_network_news')) {
+ $net_forums = array_flip(explode(',', config()->get('network_news_forum_id')));
+ if (isset($net_forums[$forum_id]) && config()->get('show_network_news') && $mode == 'newtopic') {
$datastore->enqueue([
'network_news'
]);
@@ -341,9 +341,9 @@ class Post
*/
public static function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$notify_user)
{
- global $bb_cfg, $lang, $userdata, $wordCensor;
+ global $lang, $userdata, $wordCensor;
- if (!$bb_cfg['topic_notify_enabled']) {
+ if (!config()->get('topic_notify_enabled')) {
return;
}
@@ -378,7 +378,7 @@ class Post
$emailer->set_template('topic_notify', $row['user_lang']);
$emailer->assign_vars([
'TOPIC_TITLE' => html_entity_decode($topic_title),
- 'SITENAME' => $bb_cfg['sitename'],
+ 'SITENAME' => config()->get('sitename'),
'USERNAME' => $row['username'],
'U_TOPIC' => $u_topic,
'U_STOP_WATCHING_TOPIC' => $unwatch_topic,
@@ -500,7 +500,7 @@ class Post
*/
public static function topic_review($topic_id)
{
- global $bb_cfg, $template;
+ global $template;
// Fetch posts data
$review_posts = DB()->fetch_rowset("
@@ -513,7 +513,7 @@ class Post
LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = p.post_id)
WHERE p.topic_id = " . (int)$topic_id . "
ORDER BY p.post_time DESC
- LIMIT " . $bb_cfg['posts_per_page'] . "
+ LIMIT " . config()->get('posts_per_page') . "
");
// Topic posts block
@@ -523,7 +523,7 @@ class Post
'POSTER' => profile_url($post),
'POSTER_NAME_JS' => addslashes($post['username']),
'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, $post['forum_id']),
'MESSAGE' => get_parsed_post($post),
]);
diff --git a/src/Legacy/Template.php b/src/Legacy/Template.php
index a9f8ab406..ffed992c6 100644
--- a/src/Legacy/Template.php
+++ b/src/Legacy/Template.php
@@ -228,6 +228,7 @@ class Template
{
$this->cur_tpl = $filename;
+ // bb_cfg deprecated, but kept for compatibility with non-adapted themes
global $lang, $source_lang, $bb_cfg, $user;
$L =& $lang;
diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php
index e0a905433..7bdf42943 100644
--- a/src/Legacy/Torrent.php
+++ b/src/Legacy/Torrent.php
@@ -277,7 +277,7 @@ class Torrent
*/
public static function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED, $reg_time = TIMENOW)
{
- global $bb_cfg, $lang, $reg_mode;
+ global $lang, $reg_mode;
$attach_id = (int)$attach_id;
$reg_mode = $mode;
@@ -505,7 +505,7 @@ class Torrent
$attach_id = $attachment['attach_id'];
if (!$passkey_key = config()->get('passkey_key')) {
- bb_die('Could not add passkey (wrong config $bb_cfg[\'passkey_key\'])');
+ bb_die('Could not add passkey (wrong config passkey_key)');
}
// Get $post_id & $poster_id
diff --git a/styles/templates/default/tpl_config.php b/styles/templates/default/tpl_config.php
index 29b3c2b93..aa69b6d53 100644
--- a/styles/templates/default/tpl_config.php
+++ b/styles/templates/default/tpl_config.php
@@ -7,14 +7,14 @@
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/
-global $bb_cfg, $page_cfg, $template, $images, $lang;
+global $page_cfg, $template, $images, $lang;
$width = $height = [];
$template_name = basename(__DIR__);
$_img = BB_ROOT . 'styles/images/';
$_main = BB_ROOT . 'styles/' . basename(TEMPLATES_DIR) . '/' . $template_name . '/images/';
-$_lang = $_main . 'lang/' . basename($bb_cfg['default_lang']) . '/';
+$_lang = $_main . 'lang/' . basename(config()->get('default_lang')) . '/';
// post_buttons
$images['icon_code'] = $_lang . 'icon_code.gif';
@@ -117,13 +117,13 @@ $images['progress_bar_full'] = $_main . 'progress_bar_full.gif';
$template->assign_vars([
'IMG' => $_main,
- 'TEXT_BUTTONS' => $bb_cfg['text_buttons'],
- 'POST_BTN_SPACER' => $bb_cfg['text_buttons'] ? ' ' : '',
+ 'TEXT_BUTTONS' => config()->get('text_buttons'),
+ 'POST_BTN_SPACER' => config()->get('text_buttons') ? ' ' : '',
'TOPIC_ATTACH_ICON' => '
',
'OPEN_MENU_IMG_ALT' => '',
- 'TOPIC_LEFT_COL_SPACER_WITDH' => $bb_cfg['topic_left_column_witdh'] - 8, // 8px padding
- 'POST_IMG_WIDTH_DECR_JS' => $bb_cfg['topic_left_column_witdh'] + $bb_cfg['post_img_width_decr'],
- 'ATTACH_IMG_WIDTH_DECR_JS' => $bb_cfg['topic_left_column_witdh'] + $bb_cfg['attach_img_width_decr'],
+ 'TOPIC_LEFT_COL_SPACER_WITDH' => config()->get('topic_left_column_witdh') - 8, // 8px padding
+ 'POST_IMG_WIDTH_DECR_JS' => config()->get('topic_left_column_witdh') + config()->get('post_img_width_decr'),
+ 'ATTACH_IMG_WIDTH_DECR_JS' => config()->get('topic_left_column_witdh') + config()->get('attach_img_width_decr'),
'FEED_IMG' => '
',
]);
@@ -131,25 +131,25 @@ $template->assign_vars([
if (!empty($page_cfg['load_tpl_vars']) and $vars = array_flip($page_cfg['load_tpl_vars'])) {
if (isset($vars['post_buttons'])) {
$template->assign_vars([
- 'CODE_IMG' => $bb_cfg['text_buttons'] ? $lang['CODE_TOPIC_TXTB'] : '
',
- 'QUOTE_IMG' => $bb_cfg['text_buttons'] ? $lang['REPLY_WITH_QUOTE_TXTB'] : '
',
- 'EDIT_POST_IMG' => $bb_cfg['text_buttons'] ? $lang['EDIT_DELETE_POST_TXTB'] : '
',
- 'DELETE_POST_IMG' => $bb_cfg['text_buttons'] ? $lang['DELETE_POST_TXTB'] : '
',
- 'IP_POST_IMG' => $bb_cfg['text_buttons'] ? $lang['VIEW_IP_TXTB'] : '
',
- 'MOD_POST_IMG' => $bb_cfg['text_buttons'] ? $lang['MODERATE_POST_TXTB'] : '
',
- 'MC_IMG' => $bb_cfg['text_buttons'] ? '[' . $lang['COMMENT'] . ']' : '
',
- 'POLL_IMG' => $bb_cfg['text_buttons'] ? $lang['TOPIC_POLL'] : '
',
+ 'CODE_IMG' => config()->get('text_buttons') ? $lang['CODE_TOPIC_TXTB'] : '
',
+ 'QUOTE_IMG' => config()->get('text_buttons') ? $lang['REPLY_WITH_QUOTE_TXTB'] : '
',
+ 'EDIT_POST_IMG' => config()->get('text_buttons') ? $lang['EDIT_DELETE_POST_TXTB'] : '
',
+ 'DELETE_POST_IMG' => config()->get('text_buttons') ? $lang['DELETE_POST_TXTB'] : '
',
+ 'IP_POST_IMG' => config()->get('text_buttons') ? $lang['VIEW_IP_TXTB'] : '
',
+ 'MOD_POST_IMG' => config()->get('text_buttons') ? $lang['MODERATE_POST_TXTB'] : '
',
+ 'MC_IMG' => config()->get('text_buttons') ? '[' . $lang['COMMENT'] . ']' : '
',
+ 'POLL_IMG' => config()->get('text_buttons') ? $lang['TOPIC_POLL'] : '
',
'QUOTE_URL' => BB_ROOT . POSTING_URL . '?mode=quote&' . POST_POST_URL . '=',
'EDIT_POST_URL' => BB_ROOT . POSTING_URL . '?mode=editpost&' . POST_POST_URL . '=',
'DELETE_POST_URL' => BB_ROOT . POSTING_URL . '?mode=delete&' . POST_POST_URL . '=',
'IP_POST_URL' => BB_ROOT . 'modcp.php?mode=ip&' . POST_POST_URL . '=',
- 'PROFILE_IMG' => $bb_cfg['text_buttons'] ? $lang['READ_PROFILE_TXTB'] : '
',
- 'PM_IMG' => $bb_cfg['text_buttons'] ? $lang['SEND_PM_TXTB'] : '
',
- 'EMAIL_IMG' => $bb_cfg['text_buttons'] ? $lang['SEND_EMAIL_TXTB'] : '
',
- 'WWW_IMG' => $bb_cfg['text_buttons'] ? $lang['VISIT_WEBSITE_TXTB'] : '
',
- 'ICQ_IMG' => $bb_cfg['text_buttons'] ? $lang['ICQ_TXTB'] : '
',
+ 'PROFILE_IMG' => config()->get('text_buttons') ? $lang['READ_PROFILE_TXTB'] : '
',
+ 'PM_IMG' => config()->get('text_buttons') ? $lang['SEND_PM_TXTB'] : '
',
+ 'EMAIL_IMG' => config()->get('text_buttons') ? $lang['SEND_EMAIL_TXTB'] : '
',
+ 'WWW_IMG' => config()->get('text_buttons') ? $lang['VISIT_WEBSITE_TXTB'] : '
',
+ 'ICQ_IMG' => config()->get('text_buttons') ? $lang['ICQ_TXTB'] : '
',
'EMAIL_URL' => BB_ROOT . 'profile.php?mode=email&' . POST_USERS_URL . '=',
'FORUM_URL' => BB_ROOT . FORUM_URL,