feat: implement centralized Config class to replace global $bb_cfg array (#1953)
Some checks failed
Continuous Integration / Nightly builds 📦 (push) Has been cancelled
Continuous Integration / 🎉 Deploy (push) Has been cancelled
PHPMD / Run PHPMD scanning (push) Has been cancelled

* feat: implement centralized Config class to replace global $bb_cfg array

- Add singleton Config class with dot notation support for nested configuration
- Implement thread-safe configuration access with magic methods (__get, __set, __isset)
- Add global config() helper function for convenient access
- Support for getSection(), merge(), has(), all() methods with type safety

BREAKING CHANGE: While $bb_cfg global array still works for backward compatibility,
new code should use config()->get() method with dot notation

Updated files:
- src/Config.php: New Config singleton class implementation
- common.php: Initialize Config singleton and add global helper
- src/Emailer.php: Replace $bb_cfg with config()->get()
- src/Ajax.php: Replace $bb_cfg with config()->get()
- src/Censor.php: Replace $bb_cfg with config()->get()
- src/Validate.php: Replace $bb_cfg with config()->get()
- src/Dev.php: Replace $bb_cfg with config()->get()
- src/Sitemap.php: Replace $bb_cfg with config()->get()
- src/TorrServerAPI.php: Replace $bb_cfg with config()->get()
- src/Sessions.php: Replace $bb_cfg with config()->get()
- src/Legacy/TorrentFileList.php: Replace $bb_cfg with config()->get()
- src/Legacy/Poll.php: Replace $bb_cfg with config()->get()
- src/Legacy/Torrent.php: Replace $bb_cfg with config()->get()
- src/Legacy/Common/User.php: Replace $bb_cfg with config()->get()
- src/Legacy/Template.php: Replace $bb_cfg with config()->get()
- src/Legacy/Atom.php: Replace $bb_cfg with config()->get()
- src/Legacy/Admin/Common.php: Replace $bb_cfg with config()->get()
- viewforum.php: Replace $bb_cfg with config()->get()
- posting.php: Replace $bb_cfg with config()->get()
- dl.php: Replace $bb_cfg with config()->get()
- feed.php: Replace $bb_cfg with config()->get()
- filelist.php: Replace $bb_cfg with config()->get()
- group_edit.php: Replace $bb_cfg with config()->get()
- group.php: Replace $bb_cfg with config()->get()
- index.php: Replace $bb_cfg with config()->get()
- login.php: Replace $bb_cfg with config()->get()
- memberlist.php: Replace $bb_cfg with config()->get()
- modcp.php: Replace $bb_cfg with config()->get()
- playback_m3u.php: Replace $bb_cfg with config()->get()
- poll.php: Replace $bb_cfg with config()->get()

* refactor: replace $bb_cfg with config() in various admin files

- Updated multiple admin files to utilize the new Config class for configuration access.
- Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency.
- Ensured backward compatibility while transitioning to the new configuration system.

Files modified:
- common.php
- index.php
- admin_attach_cp.php
- admin_log.php
- admin_mass_email.php
- admin_sitemap.php
- admin_smilies.php
- admin_terms.php
- admin_user_search.php
- admin_words.php
- admin/index.php
- admin/stats/tracker.php

* refactor: update init_bb.php to use config() for configuration management

- Replaced the merging of $bb_cfg with a call to config()->merge() for improved clarity and maintainability.
- Updated the retrieval of all configuration settings to use config()->all().

This change continues the transition towards a centralized configuration system.

* refactor: replace $bb_cfg with config() in various files

- Updated multiple files to utilize the new Config class for configuration access.
- Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency.
- Ensured backward compatibility while transitioning to the new configuration system.

Files modified:
- privmsg.php
- search.php
- terms.php
- tracker.php
- viewtopic.php
- bt/announce.php
- bt/scrape.php
- bt/includes/init_tr.php
- library/ajax/*.php
- src/Config.php

* refactor: replace $bb_cfg with config() in attachment and display files

- Updated multiple files to utilize the new Config class for configuration access.
- Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency.
- Ensured backward compatibility while transitioning to the new configuration system.

Files modified:
- attachment_mod.php
- displaying_torrent.php
- functions_delete.php
- bbcode.php
- functions.php
- init_bb.php
- online_userlist.php
- page_footer.php
- page_header.php
- torrent_show_dl_list.php
- cron jobs (various files)
- datastore build files (various files)

* refactor: replace $bb_cfg with config() in user control panel files

- Updated multiple user control panel files to utilize the new Config class for configuration access.
- Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency.
- Ensured backward compatibility while transitioning to the new configuration system.

Files modified:
- bonus.php
- email.php
- register.php
- sendpasswd.php
- topic_watch.php
- viewprofile.php

* refactor: replace $bb_cfg with config() in various legacy files

- Updated multiple legacy files to utilize the new Config class for configuration access.
- Replaced instances of $bb_cfg with config()->get() for improved maintainability and consistency.
- Ensured backward compatibility while transitioning to the new configuration system.

Files modified:
- sidebar2.html
- BBCode.php
- LogAction.php
- Post.php
- Template.php
- Torrent.php
- Common/User.php
- Common/Select.php
- Common/Upload.php
- Admin/Common.php
- tpl_config.php

* refactor: remove legacy DOCUMENTATION.md and add UPGRADE_GUIDE.md

- Deleted the outdated DOCUMENTATION.md file, which contained legacy configuration information.
- Introduced a new UPGRADE_GUIDE.md to assist users in migrating to the new configuration system.
- The upgrade guide includes migration strategies, breaking changes, and best practices for using the new Config class.

Files modified:
- DOCUMENTATION.md (deleted)
- UPGRADE_GUIDE.md (new)

* refactor: update legacy files to maintain compatibility with bb_cfg deprecation

- Added comments in init_bb.php, Template.php, and Cron.php to indicate that bb_cfg is deprecated but retained for compatibility with non-adapted code.
- Ensured clarity in documentation for future reference while transitioning to the new configuration system.

Files modified:
- init_bb.php
- Template.php
- Cron.php
This commit is contained in:
Yury Pikhtarev 2025-06-18 01:19:49 +04:00 committed by GitHub
commit bf9100fbfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
106 changed files with 885 additions and 803 deletions

165
UPGRADE_GUIDE.md Normal file
View file

@ -0,0 +1,165 @@
# 🚀 TorrentPier Upgrade Guide
This guide helps you upgrade your TorrentPier installation to the latest version, covering breaking changes, new features, and migration strategies.
## 📖 Table of Contents
- [Configuration System Migration](#configuration-system-migration)
- [Breaking Changes](#breaking-changes)
- [Best Practices](#best-practices)
## ⚙️ Configuration System Migration
The new TorrentPier features a modern, centralized configuration system with full backward compatibility.
### Quick Migration Overview
```php
// ❌ Old way (still works, but not recommended)
global $bb_cfg;
$announceUrl = $bb_cfg['bt_announce_url'];
$dbHost = $bb_cfg['database']['host'];
// ✅ New way (recommended)
$announceUrl = config()->get('bt_announce_url');
$dbHost = config()->get('database.host');
```
### Key Configuration Changes
#### Basic Usage
```php
// Get configuration values using dot notation
$siteName = config()->get('sitename');
$dbHost = config()->get('database.host');
$cacheTimeout = config()->get('cache.timeout');
// Get with default value if key doesn't exist
$maxUsers = config()->get('max_users_online', 100);
$debugMode = config()->get('debug.enabled', false);
```
#### Setting Values
```php
// Set configuration values
config()->set('sitename', 'My Awesome Tracker');
config()->set('database.port', 3306);
config()->set('cache.enabled', true);
```
#### Working with Sections
```php
// Get entire configuration section
$dbConfig = config()->getSection('database');
$trackerConfig = config()->getSection('tracker');
// Check if configuration exists
if (config()->has('bt_announce_url')) {
$announceUrl = config()->get('bt_announce_url');
}
```
### Common Configuration Mappings
| Old Syntax | New Syntax |
|------------|------------|
| `$bb_cfg['sitename']` | `config()->get('sitename')` |
| `$bb_cfg['database']['host']` | `config()->get('database.host')` |
| `$bb_cfg['tracker']['enabled']` | `config()->get('tracker.enabled')` |
| `$bb_cfg['cache']['timeout']` | `config()->get('cache.timeout')` |
| `$bb_cfg['torr_server']['url']` | `config()->get('torr_server.url')` |
### Magic Methods Support
```php
// Magic getter
$siteName = config()->sitename;
$dbHost = config()->{'database.host'};
// Magic setter
config()->sitename = 'New Site Name';
config()->{'database.port'} = 3306;
// Magic isset
if (isset(config()->bt_announce_url)) {
// Configuration exists
}
```
## ⚠️ Breaking Changes
### Deprecated Functions
- `get_config()` → Use `config()->get()`
- `set_config()` → Use `config()->set()`
- Direct `$bb_cfg` access → Use `config()` methods
### File Structure Changes
- New `/src/` directory for modern PHP classes
- Reorganized template structure
### Template Changes
- Updated template syntax in some areas
- New template variables available
- Deprecated template functions
## 📋 Best Practices
### Configuration Management
```php
// ✅ Always provide defaults
$timeout = config()->get('api.timeout', 30);
// ✅ Use type hints
function getMaxUploadSize(): int {
return (int) config()->get('upload.max_size', 10485760);
}
// ✅ Cache frequently used values
class TrackerService {
private string $announceUrl;
public function __construct() {
$this->announceUrl = config()->get('bt_announce_url');
}
}
```
### Error Handling
```php
// ✅ Graceful error handling
try {
$dbConfig = config()->getSection('database');
// Database operations
} catch (Exception $e) {
error_log("Database configuration error: " . $e->getMessage());
// Fallback behavior
}
```
### Performance Optimization
```php
// ✅ Minimize configuration calls in loops
$cacheEnabled = config()->get('cache.enabled', false);
for ($i = 0; $i < 1000; $i++) {
if ($cacheEnabled) {
// Use cached value
}
}
```
### Security Considerations
```php
// ✅ Validate configuration values
$maxFileSize = min(
config()->get('upload.max_size', 1048576),
1048576 * 100 // Hard limit: 100MB
);
// ✅ Sanitize user-configurable values
$siteName = htmlspecialchars(config()->get('sitename', 'TorrentPier'));
```
---
**Important**: Always test the upgrade process in a staging environment before applying it to production. Keep backups of your database and files until you're confident the upgrade was successful.
For additional support, visit our [Official Forum](https://torrentpier.com) or check our [GitHub Repository](https://github.com/torrentpier/torrentpier) for the latest updates and community discussions.

View file

@ -69,44 +69,44 @@ $order_by = '';
if ($view === 'username') { if ($view === 'username') {
switch ($mode) { switch ($mode) {
case 'username': case 'username':
$order_by = 'ORDER BY u.username ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY u.username ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
case 'attachments': case 'attachments':
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
case 'filesize': case 'filesize':
$order_by = 'ORDER BY total_size ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY total_size ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
default: default:
$mode = 'attachments'; $mode = 'attachments';
$sort_order = 'DESC'; $sort_order = 'DESC';
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
} }
} elseif ($view === 'attachments') { } elseif ($view === 'attachments') {
switch ($mode) { switch ($mode) {
case 'real_filename': case 'real_filename':
$order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
case 'comment': case 'comment':
$order_by = 'ORDER BY a.comment ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY a.comment ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
case 'extension': case 'extension':
$order_by = 'ORDER BY a.extension ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY a.extension ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
case 'filesize': case 'filesize':
$order_by = 'ORDER BY a.filesize ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY a.filesize ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
case 'downloads': case 'downloads':
$order_by = 'ORDER BY a.download_count ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY a.download_count ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
case 'post_time': case 'post_time':
$order_by = 'ORDER BY a.filetime ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY a.filetime ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
default: default:
$mode = 'a.real_filename'; $mode = 'a.real_filename';
$sort_order = 'ASC'; $sort_order = 'ASC';
$order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; $order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page');
break; break;
} }
} }
@ -470,8 +470,8 @@ if ($view === 'attachments') {
} }
// Generate Pagination // Generate Pagination
if ($do_pagination && $total_rows > $bb_cfg['topics_per_page']) { if ($do_pagination && $total_rows > config()->get('topics_per_page')) {
generate_pagination('admin_attach_cp.php?view=' . $view . '&amp;mode=' . $mode . '&amp;order=' . $sort_order . '&amp;uid=' . $uid, $total_rows, $bb_cfg['topics_per_page'], $start); generate_pagination('admin_attach_cp.php?view=' . $view . '&amp;mode=' . $mode . '&amp;order=' . $sort_order . '&amp;uid=' . $uid, $total_rows, config()->get('topics_per_page'), $start);
} }
print_page('admin_attach_cp.tpl', 'admin'); print_page('admin_attach_cp.tpl', 'admin');

View file

@ -151,7 +151,7 @@ if ($var =& $_REQUEST[$daysback_key] && $var != $def_days) {
$url = url_arg($url, $daysback_key, $daysback_val); $url = url_arg($url, $daysback_key, $daysback_val);
} }
if ($var =& $_REQUEST[$datetime_key] && $var != $def_datetime) { if ($var =& $_REQUEST[$datetime_key] && $var != $def_datetime) {
$tz = TIMENOW + (3600 * $bb_cfg['board_timezone']); $tz = TIMENOW + (3600 * config()->get('board_timezone'));
if (($tmp_timestamp = strtotime($var, $tz)) > 0) { if (($tmp_timestamp = strtotime($var, $tz)) > 0) {
$datetime_val = $tmp_timestamp; $datetime_val = $tmp_timestamp;
$url = url_arg($url, $datetime_key, date($dt_format, $datetime_val)); $url = url_arg($url, $datetime_key, date($dt_format, $datetime_val));

View file

@ -14,7 +14,7 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php'; require __DIR__ . '/pagestart.php';
if (!$bb_cfg['emailer']['enabled']) { if (!config()->get('emailer.enabled')) {
bb_die($lang['EMAILER_DISABLED']); bb_die($lang['EMAILER_DISABLED']);
} }
@ -23,7 +23,7 @@ set_time_limit(1200);
$subject = trim(request_var('subject', '')); $subject = trim(request_var('subject', ''));
$message = (string)request_var('message', ''); $message = (string)request_var('message', '');
$group_id = (int)request_var(POST_GROUPS_URL, 0); $group_id = (int)request_var(POST_GROUPS_URL, 0);
$reply_to = (string)request_var('reply_to', $bb_cfg['board_email']); $reply_to = (string)request_var('reply_to', config()->get('board_email'));
$message_type = (string)request_var('message_type', ''); $message_type = (string)request_var('message_type', '');
$errors = $user_id_sql = []; $errors = $user_id_sql = [];

View file

@ -39,7 +39,7 @@ if (!$result = DB()->sql_query($sql)) {
} }
} }
$s_mess = $lang['SITEMAP_CREATED'] . ': <b>' . bb_date($new['sitemap_time'], $bb_cfg['post_date_format']) . '</b> ' . $lang['SITEMAP_AVAILABLE'] . ': <a href="' . make_url('sitemap/sitemap.xml') . '" target="_blank">' . make_url('sitemap/sitemap.xml') . '</a>'; $s_mess = $lang['SITEMAP_CREATED'] . ': <b>' . bb_date($new['sitemap_time'], config()->get('post_date_format')) . '</b> ' . $lang['SITEMAP_AVAILABLE'] . ': <a href="' . make_url('sitemap/sitemap.xml') . '" target="_blank">' . make_url('sitemap/sitemap.xml') . '</a>';
$message = is_file(SITEMAP_DIR . '/sitemap.xml') ? $s_mess : $lang['SITEMAP_NOT_CREATED']; $message = is_file(SITEMAP_DIR . '/sitemap.xml') ? $s_mess : $lang['SITEMAP_NOT_CREATED'];
$template->assign_vars([ $template->assign_vars([

View file

@ -26,7 +26,7 @@ if ($mode == 'delete' && isset($_POST['cancel'])) {
$mode = ''; $mode = '';
} }
$pathToSmilesDir = BB_ROOT . $bb_cfg['smilies_path']; $pathToSmilesDir = BB_ROOT . config()->get('smilies_path');
$delimeter = '=+:'; $delimeter = '=+:';
$s_hidden_fields = ''; $s_hidden_fields = '';
$smiley_paks = $smiley_images = []; $smiley_paks = $smiley_images = [];

View file

@ -17,15 +17,15 @@ require INC_DIR . '/bbcode.php';
$preview = isset($_POST['preview']); $preview = isset($_POST['preview']);
if (isset($_POST['post']) && ($bb_cfg['terms'] !== $_POST['message'])) { if (isset($_POST['post']) && (config()->get('terms') !== $_POST['message'])) {
bb_update_config(['terms' => $_POST['message']]); bb_update_config(['terms' => $_POST['message']]);
bb_die($lang['TERMS_UPDATED_SUCCESSFULLY'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_TERMS_CONFIG'], '<a href="admin_terms.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>')); bb_die($lang['TERMS_UPDATED_SUCCESSFULLY'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_TERMS_CONFIG'], '<a href="admin_terms.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} }
$template->assign_vars([ $template->assign_vars([
'S_ACTION' => 'admin_terms.php', 'S_ACTION' => 'admin_terms.php',
'EXT_LINK_NW' => $bb_cfg['ext_link_new_win'], 'EXT_LINK_NW' => config()->get('ext_link_new_win'),
'MESSAGE' => $preview ? $_POST['message'] : $bb_cfg['terms'], 'MESSAGE' => $preview ? $_POST['message'] : config()->get('terms'),
'PREVIEW_HTML' => $preview ? bbcode2html($_POST['message']) : '', 'PREVIEW_HTML' => $preview ? bbcode2html($_POST['message']) : '',
]); ]);

View file

@ -841,10 +841,10 @@ if (!isset($_REQUEST['dosearch'])) {
if ($page == 1) { if ($page == 1) {
$offset = 0; $offset = 0;
} else { } else {
$offset = (($page - 1) * $bb_cfg['topics_per_page']); $offset = (($page - 1) * config()->get('topics_per_page'));
} }
$limit = "LIMIT $offset, " . $bb_cfg['topics_per_page']; $limit = "LIMIT $offset, " . config()->get('topics_per_page');
$select_sql .= " $limit"; $select_sql .= " $limit";
@ -859,7 +859,7 @@ if (!isset($_REQUEST['dosearch'])) {
bb_die($lang['SEARCH_NO_RESULTS']); bb_die($lang['SEARCH_NO_RESULTS']);
} }
} }
$num_pages = ceil($total_pages['total'] / $bb_cfg['topics_per_page']); $num_pages = ceil($total_pages['total'] / config()->get('topics_per_page'));
$pagination = ''; $pagination = '';

View file

@ -14,8 +14,8 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php'; require __DIR__ . '/pagestart.php';
if (!$bb_cfg['use_word_censor']) { if (!config()->get('use_word_censor')) {
bb_die('Word censor disabled <br /><br /> ($bb_cfg[\'use_word_censor\'] in config.php)'); bb_die('Word censor disabled <br /><br /> (use_word_censor in config.php)');
} }
$mode = request_var('mode', ''); $mode = request_var('mode', '');

View file

@ -78,7 +78,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
} elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') { } elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') {
$template->assign_vars([ $template->assign_vars([
'TPL_ADMIN_MAIN' => true, 'TPL_ADMIN_MAIN' => true,
'ADMIN_LOCK' => (bool)$bb_cfg['board_disable'], 'ADMIN_LOCK' => (bool)config()->get('board_disable'),
'ADMIN_LOCK_CRON' => is_file(BB_DISABLED), 'ADMIN_LOCK_CRON' => is_file(BB_DISABLED),
]); ]);
@ -98,8 +98,8 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$total_posts = $stats['postcount']; $total_posts = $stats['postcount'];
$total_topics = $stats['topiccount']; $total_topics = $stats['topiccount'];
$total_users = $stats['usercount']; $total_users = $stats['usercount'];
$start_date = bb_date($bb_cfg['board_startdate']); $start_date = bb_date(config()->get('board_startdate'));
$boarddays = (TIMENOW - $bb_cfg['board_startdate']) / 86400; $boarddays = (TIMENOW - config()->get('board_startdate')) / 86400;
$posts_per_day = sprintf('%.2f', $total_posts / $boarddays); $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
$topics_per_day = sprintf('%.2f', $total_topics / $boarddays); $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
@ -107,10 +107,10 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$avatar_dir_size = 0; $avatar_dir_size = 0;
if ($avatar_dir = opendir($bb_cfg['avatars']['upload_path'])) { if ($avatar_dir = opendir(config()->get('avatars.upload_path'))) {
while ($file = readdir($avatar_dir)) { while ($file = readdir($avatar_dir)) {
if ($file != '.' && $file != '..') { if ($file != '.' && $file != '..') {
$avatar_dir_size += @filesize($bb_cfg['avatars']['upload_path'] . $file); $avatar_dir_size += @filesize(config()->get('avatars.upload_path') . $file);
} }
} }
closedir($avatar_dir); closedir($avatar_dir);
@ -187,7 +187,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'd-M-Y H:i', false), 'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'd-M-Y H:i', false),
'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'd-M-Y H:i', false), 'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'd-M-Y H:i', false),
'IP_ADDRESS' => $reg_ip, 'IP_ADDRESS' => $reg_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $reg_ip, 'U_WHOIS_IP' => config()->get('whois_info') . $reg_ip,
]); ]);
} }
} }
@ -206,7 +206,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'd-M-Y H:i', false), 'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'd-M-Y H:i', false),
'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'd-M-Y H:i', false), 'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'd-M-Y H:i', false),
'IP_ADDRESS' => $guest_ip, 'IP_ADDRESS' => $guest_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $guest_ip, 'U_WHOIS_IP' => config()->get('whois_info') . $guest_ip,
]); ]);
} }
} }

View file

@ -21,7 +21,7 @@ if (!IS_ADMIN) {
$peers_in_last_minutes = [30, 15, 5, 1]; $peers_in_last_minutes = [30, 15, 5, 1];
$peers_in_last_sec_limit = 300; $peers_in_last_sec_limit = 300;
$announce_interval = (int)$bb_cfg['announce_interval']; $announce_interval = (int)config()->get('announce_interval');
$stat = []; $stat = [];
define('TMP_TRACKER_TABLE', 'tmp_tracker'); define('TMP_TRACKER_TABLE', 'tmp_tracker');

View file

@ -11,8 +11,6 @@ define('IN_TRACKER', true);
define('BB_ROOT', './../'); define('BB_ROOT', './../');
require dirname(__DIR__) . '/common.php'; require dirname(__DIR__) . '/common.php';
global $bb_cfg;
// Check User-Agent for existence // Check User-Agent for existence
$userAgent = (string)$_SERVER['HTTP_USER_AGENT']; $userAgent = (string)$_SERVER['HTTP_USER_AGENT'];
if (empty($userAgent)) { if (empty($userAgent)) {
@ -20,8 +18,8 @@ if (empty($userAgent)) {
die; die;
} }
$announce_interval = $bb_cfg['announce_interval']; $announce_interval = config()->get('announce_interval');
$passkey_key = $bb_cfg['passkey_key']; $passkey_key = config()->get('passkey_key');
// Recover info_hash // Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) { if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
@ -67,10 +65,10 @@ if (strlen($peer_id) !== 20) {
} }
// Check for client ban // Check for client ban
if ($bb_cfg['client_ban']['enabled']) { if (config()->get('client_ban.enabled')) {
$targetClient = []; $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)) { if (str_starts_with($peer_id, $clientId)) {
$targetClient = [ $targetClient = [
'peer_id' => $clientId, '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'])) { if (empty($targetClient['peer_id'])) {
msg_die('Your BitTorrent client has been banned!'); msg_die('Your BitTorrent client has been banned!');
} }
@ -131,7 +129,7 @@ if (
|| !is_numeric($port) || !is_numeric($port)
|| ($port < 1024 && !$stopped) || ($port < 1024 && !$stopped)
|| $port > 0xFFFF || $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); 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 = $_SERVER['REMOTE_ADDR'];
// 'ip' query handling // 'ip' query handling
if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip']) { if (!config()->get('ignore_reported_ip') && isset($_GET['ip']) && $ip !== $_GET['ip']) {
if (!$bb_cfg['verify_reported_ip'] && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { if (!config()->get('verify_reported_ip') && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$x_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; $x_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if ($x_ip === $_GET['ip']) { if ($x_ip === $_GET['ip']) {
$filteredIp = filter_var($x_ip, FILTER_VALIDATE_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; $ip = $filteredIp;
} }
} }
@ -272,7 +270,7 @@ if ($lp_info) {
define('IS_MOD', !IS_GUEST && (int)$row['user_level'] === MOD); define('IS_MOD', !IS_GUEST && (int)$row['user_level'] === MOD);
define('IS_GROUP_MEMBER', !IS_GUEST && (int)$row['user_level'] === GROUP_MEMBER); define('IS_GROUP_MEMBER', !IS_GUEST && (int)$row['user_level'] === GROUP_MEMBER);
define('IS_USER', !IS_GUEST && (int)$row['user_level'] === USER); 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); define('IS_AM', IS_ADMIN || IS_MOD);
$topic_id = $row['topic_id']; $topic_id = $row['topic_id'];
$releaser = (int)($user_id == $row['poster_id']); $releaser = (int)($user_id == $row['poster_id']);
@ -280,13 +278,13 @@ if ($lp_info) {
$tor_status = $row['tor_status']; $tor_status = $row['tor_status'];
// Check 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'); msg_die('Torrent frozen and cannot be downloaded');
} }
// Check hybrid status // Check hybrid status
if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) { 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), 2 => substr($row['info_hash_v2'], 0, 20),
default => $row['info_hash'] // 1 default => $row['info_hash'] // 1
}; };
@ -296,7 +294,7 @@ if ($lp_info) {
} }
// Ratio limits // 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); $user_ratio = get_bt_ratio($row);
if ($user_ratio === null) { if ($user_ratio === null) {
$user_ratio = 1; $user_ratio = 1;
@ -304,10 +302,10 @@ if ($lp_info) {
$rating_msg = ''; $rating_msg = '';
if (!$seeder) { if (!$seeder) {
foreach ($bb_cfg['rating'] as $ratio => $limit) { foreach (config()->get('rating') as $ratio => $limit) {
if ($user_ratio < $ratio) { if ($user_ratio < $ratio) {
$bb_cfg['tracker']['limit_active_tor'] = 1; config()->set('tracker.limit_active_tor', 1);
$bb_cfg['tracker']['limit_leech_count'] = $limit; config()->set('tracker.limit_leech_count', $limit);
$rating_msg = " (ratio < $ratio)"; $rating_msg = " (ratio < $ratio)";
break; break;
} }
@ -315,29 +313,29 @@ if ($lp_info) {
} }
// Limit active torrents // 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 $sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
FROM " . BB_BT_TRACKER . " FROM " . BB_BT_TRACKER . "
WHERE user_id = $user_id WHERE user_id = $user_id
AND seeder = $seeder AND seeder = $seeder
AND topic_id != $topic_id"; AND topic_id != $topic_id";
if (!$seeder && $bb_cfg['tracker']['leech_expire_factor'] && $user_ratio < 0.5) { if (!$seeder && config()->get('tracker.leech_expire_factor') && $user_ratio < 0.5) {
$sql .= " AND update_time > " . (TIMENOW - 60 * $bb_cfg['tracker']['leech_expire_factor']); $sql .= " AND update_time > " . (TIMENOW - 60 * config()->get('tracker.leech_expire_factor'));
} }
$sql .= " GROUP BY user_id"; $sql .= " GROUP BY user_id";
if ($row = DB()->fetch_row($sql)) { if ($row = DB()->fetch_row($sql)) {
if ($seeder && $bb_cfg['tracker']['limit_seed_count'] && $row['active_torrents'] >= $bb_cfg['tracker']['limit_seed_count']) { if ($seeder && config()->get('tracker.limit_seed_count') && $row['active_torrents'] >= config()->get('tracker.limit_seed_count')) {
msg_die('Only ' . $bb_cfg['tracker']['limit_seed_count'] . ' torrent(s) allowed for seeding'); msg_die('Only ' . config()->get('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']) { } elseif (!$seeder && config()->get('tracker.limit_leech_count') && $row['active_torrents'] >= config()->get('tracker.limit_leech_count')) {
msg_die('Only ' . $bb_cfg['tracker']['limit_leech_count'] . ' torrent(s) allowed for leeching' . $rating_msg); msg_die('Only ' . config()->get('tracker.limit_leech_count') . ' torrent(s) allowed for leeching' . $rating_msg);
} }
} }
} }
// Limit concurrent IPs // 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 $sql = "SELECT COUNT(DISTINCT ip) AS ips
FROM " . BB_BT_TRACKER . " FROM " . BB_BT_TRACKER . "
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
@ -345,16 +343,16 @@ if ($lp_info) {
AND seeder = $seeder AND seeder = $seeder
AND $ip_version != '$ip_sql'"; AND $ip_version != '$ip_sql'";
if (!$seeder && $bb_cfg['tracker']['leech_expire_factor']) { if (!$seeder && config()->get('tracker.leech_expire_factor')) {
$sql .= " AND update_time > " . (TIMENOW - 60 * $bb_cfg['tracker']['leech_expire_factor']); $sql .= " AND update_time > " . (TIMENOW - 60 * config()->get('tracker.leech_expire_factor'));
} }
$sql .= " GROUP BY topic_id"; $sql .= " GROUP BY topic_id";
if ($row = DB()->fetch_row($sql)) { if ($row = DB()->fetch_row($sql)) {
if ($seeder && $bb_cfg['tracker']['limit_seed_ips'] && $row['ips'] >= $bb_cfg['tracker']['limit_seed_ips']) { if ($seeder && config()->get('tracker.limit_seed_ips') && $row['ips'] >= config()->get('tracker.limit_seed_ips')) {
msg_die('You can seed only from ' . $bb_cfg['tracker']['limit_seed_ips'] . " IP's"); msg_die('You can seed only from ' . config()->get('tracker.limit_seed_ips') . " IP's");
} elseif (!$seeder && $bb_cfg['tracker']['limit_leech_ips'] && $row['ips'] >= $bb_cfg['tracker']['limit_leech_ips']) { } elseif (!$seeder && config()->get('tracker.limit_leech_ips') && $row['ips'] >= config()->get('tracker.limit_leech_ips')) {
msg_die('You can leech only from ' . $bb_cfg['tracker']['limit_leech_ips'] . " IP's"); 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; $down_add = ($lp_info && $downloaded > $lp_info['downloaded']) ? $downloaded - $lp_info['downloaded'] : 0;
// Gold/Silver releases // 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) { if ($tor_type == TOR_TYPE_GOLD) {
$down_add = 0; $down_add = 0;
} // Silver releases } // Silver releases
@ -388,7 +386,7 @@ if ($bb_cfg['tracker']['gold_silver_enabled'] && $down_add) {
} }
// Freeleech // Freeleech
if ($bb_cfg['tracker']['freeleech'] && $down_add) { if (config()->get('tracker.freeleech') && $down_add) {
$down_add = 0; $down_add = 0;
} }
@ -466,8 +464,8 @@ $output = CACHE('tr_cache')->get(PEERS_LIST_PREFIX . $topic_id);
if (!$output) { if (!$output) {
// Retrieve peers // Retrieve peers
$numwant = (int)$bb_cfg['tracker']['numwant']; $numwant = (int)config()->get('tracker.numwant');
$compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact)); $compact_mode = (config()->get('tracker.compact_mode') || !empty($compact));
$rowset = DB()->fetch_rowset(" $rowset = DB()->fetch_rowset("
SELECT ip, ipv6, port SELECT ip, ipv6, port
@ -512,7 +510,7 @@ if (!$output) {
$seeders = $leechers = $client_completed = 0; $seeders = $leechers = $client_completed = 0;
if ($bb_cfg['tracker']['scrape']) { if (config()->get('tracker.scrape')) {
$row = DB()->fetch_row(" $row = DB()->fetch_row("
SELECT seeders, leechers, completed SELECT seeders, leechers, completed
FROM " . BB_BT_TRACKER_SNAP . " FROM " . BB_BT_TRACKER_SNAP . "

View file

@ -11,11 +11,9 @@ if (!defined('IN_TRACKER')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg;
// Exit if tracker is disabled // Exit if tracker is disabled
if ($bb_cfg['tracker']['bt_off']) { if (config()->get('tracker.bt_off')) {
msg_die($bb_cfg['tracker']['bt_off_reason']); msg_die(config()->get('tracker.bt_off_reason'));
} }
// //

View file

@ -11,9 +11,7 @@ define('IN_TRACKER', true);
define('BB_ROOT', './../'); define('BB_ROOT', './../');
require dirname(__DIR__) . '/common.php'; require dirname(__DIR__) . '/common.php';
global $bb_cfg; if (!config()->get('tracker.scrape')) {
if (!$bb_cfg['tracker']['scrape']) {
msg_die('Please disable SCRAPE!'); msg_die('Please disable SCRAPE!');
} }
@ -60,8 +58,8 @@ foreach ($info_hash_array[1] as $hash) {
$info_hash_count = count($info_hashes); $info_hash_count = count($info_hashes);
if (!empty($info_hash_count)) { if (!empty($info_hash_count)) {
if ($info_hash_count > $bb_cfg['max_scrapes']) { if ($info_hash_count > config()->get('max_scrapes')) {
$info_hashes = array_slice($info_hashes, 0, $bb_cfg['max_scrapes']); $info_hashes = array_slice($info_hashes, 0, config()->get('max_scrapes'));
} }
$info_hashes_sql = implode('\', \'', $info_hashes); $info_hashes_sql = implode('\', \'', $info_hashes);

View file

@ -377,9 +377,9 @@ if (!defined('IN_TRACKER')) {
} else { } else {
define('DUMMY_PEER', pack('Nn', \TorrentPier\Helpers\IPHelper::ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : random_int(1000, 65000))); define('DUMMY_PEER', pack('Nn', \TorrentPier\Helpers\IPHelper::ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : random_int(1000, 65000)));
define('PEER_HASH_EXPIRE', round($bb_cfg['announce_interval'] * (0.85 * $bb_cfg['tracker']['expire_factor']))); define('PEER_HASH_EXPIRE', round(config()->get('announce_interval') * (0.85 * config()->get('tracker.expire_factor'))));
define('PEERS_LIST_EXPIRE', round($bb_cfg['announce_interval'] * 0.7)); define('PEERS_LIST_EXPIRE', round(config()->get('announce_interval') * 0.7));
define('SCRAPE_LIST_EXPIRE', round($bb_cfg['scrape_interval'] * 0.7)); define('SCRAPE_LIST_EXPIRE', round(config()->get('scrape_interval') * 0.7));
define('PEER_HASH_PREFIX', 'peer_'); define('PEER_HASH_PREFIX', 'peer_');
define('PEERS_LIST_PREFIX', 'peers_list_'); define('PEERS_LIST_PREFIX', 'peers_list_');

6
dl.php
View file

@ -25,7 +25,7 @@ $m3u = isset($_GET['m3u']) && $_GET['m3u'];
// Send file to browser // Send file to browser
function send_file_to_browser($attachment, $upload_dir) function send_file_to_browser($attachment, $upload_dir)
{ {
global $bb_cfg, $lang; global $lang;
$filename = $upload_dir . '/' . $attachment['physical_filename']; $filename = $upload_dir . '/' . $attachment['physical_filename'];
$gotit = false; $gotit = false;
@ -170,7 +170,7 @@ if (!IS_AM && ($attachment['mimetype'] === TORRENT_MIMETYPE)) {
$row = DB()->sql_fetchrow($result); $row = DB()->sql_fetchrow($result);
if (isset($bb_cfg['tor_frozen'][$row['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$row['tor_status']]) && $userdata['user_id'] === $row['poster_id'])) { if (isset(config()->get('tor_frozen')[$row['tor_status']]) && !(isset(config()->get('tor_frozen_author_download')[$row['tor_status']]) && $userdata['user_id'] === $row['poster_id'])) {
bb_die($lang['TOR_STATUS_FORBIDDEN'] . $lang['TOR_STATUS_NAME'][$row['tor_status']]); bb_die($lang['TOR_STATUS_FORBIDDEN'] . $lang['TOR_STATUS_NAME'][$row['tor_status']]);
} }
@ -219,7 +219,7 @@ switch ($download_mode) {
header('Location: ' . $url); header('Location: ' . $url);
exit; exit;
case INLINE_LINK: case INLINE_LINK:
if (IS_GUEST && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) { if (IS_GUEST && !config()->get('captcha.disabled') && !bb_captcha('check')) {
global $template; global $template;
$redirect_url = $_POST['redirect_url'] ?? $_SERVER['HTTP_REFERER'] ?? '/'; $redirect_url = $_POST['redirect_url'] ?? $_SERVER['HTTP_REFERER'] ?? '/';

View file

@ -34,11 +34,11 @@ if ($mode === 'get_feed_url' && ($type === 'f' || $type === 'u') && $id >= 0) {
bb_simple_die($lang['ATOM_ERROR'] . ' #1'); bb_simple_die($lang['ATOM_ERROR'] . ' #1');
} }
} }
if (is_file($bb_cfg['atom']['path'] . '/f/' . $id . '.atom') && filemtime($bb_cfg['atom']['path'] . '/f/' . $id . '.atom') > $timecheck) { if (is_file(config()->get('atom.path') . '/f/' . $id . '.atom') && filemtime(config()->get('atom.path') . '/f/' . $id . '.atom') > $timecheck) {
redirect($bb_cfg['atom']['url'] . '/f/' . $id . '.atom'); redirect(config()->get('atom.url') . '/f/' . $id . '.atom');
} else { } else {
if (\TorrentPier\Legacy\Atom::update_forum_feed($id, $forum_data)) { if (\TorrentPier\Legacy\Atom::update_forum_feed($id, $forum_data)) {
redirect($bb_cfg['atom']['url'] . '/f/' . $id . '.atom'); redirect(config()->get('atom.url') . '/f/' . $id . '.atom');
} else { } else {
bb_simple_die($lang['ATOM_NO_FORUM']); bb_simple_die($lang['ATOM_NO_FORUM']);
} }
@ -52,11 +52,11 @@ if ($mode === 'get_feed_url' && ($type === 'f' || $type === 'u') && $id >= 0) {
if (!$username = get_username($id)) { if (!$username = get_username($id)) {
bb_simple_die($lang['ATOM_ERROR'] . ' #3'); bb_simple_die($lang['ATOM_ERROR'] . ' #3');
} }
if (is_file($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') && filemtime($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') > $timecheck) { if (is_file(config()->get('atom.path') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') && filemtime(config()->get('atom.path') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') > $timecheck) {
redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom'); redirect(config()->get('atom.url') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom');
} else { } else {
if (\TorrentPier\Legacy\Atom::update_user_feed($id, $username)) { if (\TorrentPier\Legacy\Atom::update_user_feed($id, $username)) {
redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom'); redirect(config()->get('atom.url') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom');
} else { } else {
bb_simple_die($lang['ATOM_NO_USER']); bb_simple_die($lang['ATOM_NO_USER']);
} }

View file

@ -14,7 +14,7 @@ require __DIR__ . '/common.php';
// Start session management // Start session management
$user->session_start(); $user->session_start();
if ($bb_cfg['bt_disable_dht'] && IS_GUEST) { if (config()->get('bt_disable_dht') && IS_GUEST) {
bb_die($lang['BT_PRIVATE_TRACKER'], 403); bb_die($lang['BT_PRIVATE_TRACKER'], 403);
} }
@ -55,7 +55,7 @@ if (!is_file($file_path)) {
} }
$file_contents = file_get_contents($file_path); $file_contents = file_get_contents($file_path);
if ($bb_cfg['flist_max_files']) { if (config()->get('flist_max_files')) {
$filetree_pos = $meta_v2 ? strpos($file_contents, '9:file tree') : false; $filetree_pos = $meta_v2 ? strpos($file_contents, '9:file tree') : false;
$files_pos = $meta_v1 ? strpos($file_contents, '5:files', $filetree_pos) : false; $files_pos = $meta_v1 ? strpos($file_contents, '5:files', $filetree_pos) : false;
@ -65,8 +65,8 @@ if ($bb_cfg['flist_max_files']) {
$file_count = substr_count($file_contents, '6:length', $files_pos); $file_count = substr_count($file_contents, '6:length', $files_pos);
} }
if ($file_count > $bb_cfg['flist_max_files']) { if ($file_count > config()->get('flist_max_files')) {
bb_die(sprintf($lang['BT_FLIST_LIMIT'], $bb_cfg['flist_max_files'], $file_count), 410); bb_die(sprintf($lang['BT_FLIST_LIMIT'], config()->get('flist_max_files'), $file_count), 410);
} }
} }

View file

@ -24,7 +24,7 @@ set_die_append_msg();
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null; $group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null;
$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; $start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0;
$per_page = $bb_cfg['group_members_per_page']; $per_page = config()->get('group_members_per_page');
$view_mode = isset($_REQUEST['view']) ? (string)$_REQUEST['view'] : null; $view_mode = isset($_REQUEST['view']) ? (string)$_REQUEST['view'] : null;
$rel_limit = 50; $rel_limit = 50;
@ -168,7 +168,7 @@ if (!$group_id) {
\TorrentPier\Legacy\Group::add_user_into_group($group_id, $userdata['user_id'], 1, TIMENOW); \TorrentPier\Legacy\Group::add_user_into_group($group_id, $userdata['user_id'], 1, TIMENOW);
if ($bb_cfg['group_send_email']) { if (config()->get('group_send_email')) {
// Sending email // Sending email
$emailer = new TorrentPier\Emailer(); $emailer = new TorrentPier\Emailer();
@ -224,7 +224,7 @@ if (!$group_id) {
\TorrentPier\Legacy\Group::add_user_into_group($group_id, $row['user_id']); \TorrentPier\Legacy\Group::add_user_into_group($group_id, $row['user_id']);
if ($bb_cfg['group_send_email']) { if (config()->get('group_send_email')) {
// Sending email // Sending email
$emailer = new TorrentPier\Emailer(); $emailer = new TorrentPier\Emailer();
@ -273,7 +273,7 @@ if (!$group_id) {
} }
} }
// Email users when they are approved // Email users when they are approved
if (!empty($_POST['approve']) && $bb_cfg['group_send_email']) { if (!empty($_POST['approve']) && config()->get('group_send_email')) {
$sql_select = "SELECT username, user_email, user_lang $sql_select = "SELECT username, user_email, user_lang
FROM " . BB_USERS . " FROM " . BB_USERS . "
WHERE user_id IN($sql_in)"; WHERE user_id IN($sql_in)";

View file

@ -35,10 +35,10 @@ if ($group_id) {
if ($is_moderator) { if ($is_moderator) {
// Avatar // Avatar
if ($submit) { if ($submit) {
if (!empty($_FILES['avatar']['name']) && $bb_cfg['group_avatars']['up_allowed']) { if (!empty($_FILES['avatar']['name']) && config()->get('group_avatars.up_allowed')) {
$upload = new TorrentPier\Legacy\Common\Upload(); $upload = new TorrentPier\Legacy\Common\Upload();
if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) and $upload->store('avatar', ['user_id' => GROUP_AVATAR_MASK . $group_id, 'avatar_ext_id' => $group_info['avatar_ext_id']])) { if ($upload->init(config()->get('group_avatars'), $_FILES['avatar']) and $upload->store('avatar', ['user_id' => GROUP_AVATAR_MASK . $group_id, 'avatar_ext_id' => $group_info['avatar_ext_id']])) {
$avatar_ext_id = (int)$upload->file_ext_id; $avatar_ext_id = (int)$upload->file_ext_id;
DB()->query("UPDATE " . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id LIMIT 1"); DB()->query("UPDATE " . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id LIMIT 1");
} else { } else {
@ -76,7 +76,7 @@ if ($is_moderator) {
'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id", 'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id",
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], humn_size($bb_cfg['group_avatars']['max_size'])), 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], config()->get('group_avatars.max_width'), config()->get('group_avatars.max_height'), humn_size(config()->get('group_avatars.max_size'))),
'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']), 'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
]); ]);

View file

@ -31,12 +31,12 @@ $datastore->enqueue([
'cat_forums' 'cat_forums'
]); ]);
if ($bb_cfg['show_latest_news']) { if (config()->get('show_latest_news')) {
$datastore->enqueue([ $datastore->enqueue([
'latest_news' 'latest_news'
]); ]);
} }
if ($bb_cfg['show_network_news']) { if (config()->get('show_network_news')) {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -46,7 +46,7 @@ if ($bb_cfg['show_network_news']) {
$user->session_start(); $user->session_start();
// Set meta description // Set meta description
$page_cfg['meta_description'] = $bb_cfg['site_desc']; $page_cfg['meta_description'] = config()->get('site_desc');
// Init main vars // Init main vars
$viewcat = isset($_GET[POST_CAT_URL]) ? (int)$_GET[POST_CAT_URL] : 0; $viewcat = isset($_GET[POST_CAT_URL]) ? (int)$_GET[POST_CAT_URL] : 0;
@ -57,7 +57,7 @@ $req_page = 'index_page';
$req_page .= $viewcat ? "_c{$viewcat}" : ''; $req_page .= $viewcat ? "_c{$viewcat}" : '';
define('REQUESTED_PAGE', $req_page); define('REQUESTED_PAGE', $req_page);
caching_output(IS_GUEST, 'send', REQUESTED_PAGE . '_guest_' . $bb_cfg['default_lang']); caching_output(IS_GUEST, 'send', REQUESTED_PAGE . '_guest_' . config()->get('default_lang'));
$hide_cat_opt = isset($user->opt_js['h_cat']) ? (string)$user->opt_js['h_cat'] : 0; $hide_cat_opt = isset($user->opt_js['h_cat']) ? (string)$user->opt_js['h_cat'] : 0;
$hide_cat_user = array_flip(explode('-', $hide_cat_opt)); $hide_cat_user = array_flip(explode('-', $hide_cat_opt));
@ -259,7 +259,7 @@ foreach ($cat_forums as $cid => $c) {
'LAST_TOPIC_ID' => $f['last_topic_id'], 'LAST_TOPIC_ID' => $f['last_topic_id'],
'LAST_TOPIC_TIP' => $f['last_topic_title'], 'LAST_TOPIC_TIP' => $f['last_topic_title'],
'LAST_TOPIC_TITLE' => str_short($f['last_topic_title'], $last_topic_max_len), 'LAST_TOPIC_TITLE' => str_short($f['last_topic_title'], $last_topic_max_len),
'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']), 'LAST_POST_TIME' => bb_date($f['last_post_time'], config()->get('last_post_date_format')),
'LAST_POST_USER' => profile_url(['username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank']]), 'LAST_POST_USER' => profile_url(['username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank']]),
]); ]);
} }
@ -275,7 +275,7 @@ $template->assign_vars([
'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']), 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']),
'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']), 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']),
'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']), 'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']),
'TOTAL_GENDER' => $bb_cfg['gender'] ? sprintf( 'TOTAL_GENDER' => config()->get('gender') ? sprintf(
$lang['USERS_TOTAL_GENDER'], $lang['USERS_TOTAL_GENDER'],
$stats['male'], $stats['male'],
$stats['female'], $stats['female'],
@ -284,22 +284,22 @@ $template->assign_vars([
'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])), 'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])),
// Tracker stats // Tracker stats
'TORRENTS_STAT' => $bb_cfg['tor_stats'] ? sprintf( 'TORRENTS_STAT' => config()->get('tor_stats') ? sprintf(
$lang['TORRENTS_STAT'], $lang['TORRENTS_STAT'],
$stats['torrentcount'], $stats['torrentcount'],
humn_size($stats['size']) humn_size($stats['size'])
) : '', ) : '',
'PEERS_STAT' => $bb_cfg['tor_stats'] ? sprintf( 'PEERS_STAT' => config()->get('tor_stats') ? sprintf(
$lang['PEERS_STAT'], $lang['PEERS_STAT'],
$stats['peers'], $stats['peers'],
$stats['seeders'], $stats['seeders'],
$stats['leechers'] $stats['leechers']
) : '', ) : '',
'SPEED_STAT' => $bb_cfg['tor_stats'] ? sprintf( 'SPEED_STAT' => config()->get('tor_stats') ? sprintf(
$lang['SPEED_STAT'], $lang['SPEED_STAT'],
humn_size($stats['speed']) . '/s' humn_size($stats['speed']) . '/s'
) : '', ) : '',
'SHOW_MOD_INDEX' => $bb_cfg['show_mod_index'], 'SHOW_MOD_INDEX' => config()->get('show_mod_index'),
'FORUM_IMG' => $images['forum'], 'FORUM_IMG' => $images['forum'],
'FORUM_NEW_IMG' => $images['forum_new'], 'FORUM_NEW_IMG' => $images['forum_new'],
'FORUM_LOCKED_IMG' => $images['forum_locked'], 'FORUM_LOCKED_IMG' => $images['forum_locked'],
@ -312,19 +312,19 @@ $template->assign_vars([
'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&amp;o=1", 'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&amp;o=1",
'U_SEARCH_LATEST' => 'search.php?search_id=latest', 'U_SEARCH_LATEST' => 'search.php?search_id=latest',
'U_SEARCH_UNANSWERED' => 'search.php?search_id=unanswered', 'U_SEARCH_UNANSWERED' => 'search.php?search_id=unanswered',
'U_ATOM_FEED' => is_file($bb_cfg['atom']['path'] . '/f/0.atom') ? make_url($bb_cfg['atom']['url'] . '/f/0.atom') : false, 'U_ATOM_FEED' => is_file(config()->get('atom.path') . '/f/0.atom') ? make_url(config()->get('atom.url') . '/f/0.atom') : false,
'SHOW_LAST_TOPIC' => $show_last_topic, 'SHOW_LAST_TOPIC' => $show_last_topic,
'BOARD_START' => $bb_cfg['show_board_start_index'] ? ($lang['BOARD_STARTED'] . ':&nbsp;' . '<b>' . bb_date($bb_cfg['board_startdate']) . '</b>') : false, 'BOARD_START' => config()->get('show_board_start_index') ? ($lang['BOARD_STARTED'] . ':&nbsp;' . '<b>' . bb_date(config()->get('board_startdate')) . '</b>') : false,
]); ]);
// Set tpl vars for bt_userdata // Set tpl vars for bt_userdata
if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) { if (config()->get('bt_show_dl_stat_on_index') && !IS_GUEST) {
show_bt_userdata($userdata['user_id']); show_bt_userdata($userdata['user_id']);
} }
// Latest news // Latest news
if ($bb_cfg['show_latest_news']) { if (config()->get('show_latest_news')) {
if (!$latest_news = $datastore->get('latest_news')) { if (!$latest_news = $datastore->get('latest_news')) {
$datastore->update('latest_news'); $datastore->update('latest_news');
$latest_news = $datastore->get('latest_news'); $latest_news = $datastore->get('latest_news');
@ -339,7 +339,7 @@ if ($bb_cfg['show_latest_news']) {
$template->assign_block_vars('news', [ $template->assign_block_vars('news', [
'NEWS_TOPIC_ID' => $news['topic_id'], 'NEWS_TOPIC_ID' => $news['topic_id'],
'NEWS_TITLE' => str_short($wordCensor->censorString($news['topic_title']), $bb_cfg['max_news_title']), 'NEWS_TITLE' => str_short($wordCensor->censorString($news['topic_title']), config()->get('max_news_title')),
'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false), 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']), 'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']),
]); ]);
@ -347,7 +347,7 @@ if ($bb_cfg['show_latest_news']) {
} }
// Network news // Network news
if ($bb_cfg['show_network_news']) { if (config()->get('show_network_news')) {
if (!$network_news = $datastore->get('network_news')) { if (!$network_news = $datastore->get('network_news')) {
$datastore->update('network_news'); $datastore->update('network_news');
$network_news = $datastore->get('network_news'); $network_news = $datastore->get('network_news');
@ -362,14 +362,14 @@ if ($bb_cfg['show_network_news']) {
$template->assign_block_vars('net', [ $template->assign_block_vars('net', [
'NEWS_TOPIC_ID' => $net['topic_id'], 'NEWS_TOPIC_ID' => $net['topic_id'],
'NEWS_TITLE' => str_short($wordCensor->censorString($net['topic_title']), $bb_cfg['max_net_title']), 'NEWS_TITLE' => str_short($wordCensor->censorString($net['topic_title']), config()->get('max_net_title')),
'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false), 'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']), 'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']),
]); ]);
} }
} }
if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { if (config()->get('birthday_check_day') && config()->get('birthday_enabled')) {
$week_list = $today_list = []; $week_list = $today_list = [];
$week_all = $today_all = false; $week_all = $today_all = false;
@ -383,9 +383,9 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
$week_list[] = profile_url($week) . ' <span class="small">(' . birthday_age(date('Y-m-d', strtotime('-1 year', strtotime($week['user_birthday'])))) . ')</span>'; $week_list[] = profile_url($week) . ' <span class="small">(' . birthday_age(date('Y-m-d', strtotime('-1 year', strtotime($week['user_birthday'])))) . ')</span>';
} }
$week_all = $week_all ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : ''; $week_all = $week_all ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : '';
$week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], implode(', ', $week_list)) . $week_all; $week_list = sprintf($lang['BIRTHDAY_WEEK'], config()->get('birthday_check_day'), implode(', ', $week_list)) . $week_all;
} else { } else {
$week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']); $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], config()->get('birthday_check_day'));
} }
if (!empty($stats['birthday_today_list'])) { if (!empty($stats['birthday_today_list'])) {

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg, $lang, $user; global $lang, $user;
if (!$mode = (string)$this->request['mode']) { if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)'); $this->ajax_die('invalid mode (empty)');

View file

@ -11,9 +11,9 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); 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']); $this->ajax_die($lang['MODULE_OFF']);
} }
@ -32,7 +32,7 @@ if ($t_data['seeders'] >= 3) {
} elseif ($t_data['call_seed_time'] >= (TIMENOW - 86400)) { } elseif ($t_data['call_seed_time'] >= (TIMENOW - 86400)) {
$time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days'); $time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
$this->ajax_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left)); $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']); $this->ajax_die($lang['NOT_AVAILABLE']);
} }

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $userdata, $bb_cfg, $lang, $log_action; global $userdata, $lang, $log_action;
if (!$attach_id = (int)$this->request['attach_id']) { if (!$attach_id = (int)$this->request['attach_id']) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']); $this->ajax_die($lang['EMPTY_ATTACH_ID']);
@ -22,7 +22,7 @@ if (!$mode = (string)$this->request['mode']) {
} }
$comment = false; $comment = false;
if ($bb_cfg['tor_comment']) { if (config()->get('tor_comment')) {
$comment = (string)$this->request['comment']; $comment = (string)$this->request['comment'];
} }
@ -88,7 +88,7 @@ switch ($mode) {
\TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $new_status); \TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $new_status);
// Log action // Log action
$log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], $bb_cfg['tor_icons'][$new_status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b>', $bb_cfg['tor_icons'][$tor['tor_status']] . ' <b> ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '</b>'); $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], config()->get('tor_icons')[$new_status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b>', config()->get('tor_icons')[$tor['tor_status']] . ' <b> ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '</b>');
if ($comment && $comment != $lang['COMMENT']) { if ($comment && $comment != $lang['COMMENT']) {
$log_msg .= "<br/>{$lang['COMMENT']}: <b>$comment</b>."; $log_msg .= "<br/>{$lang['COMMENT']}: <b>$comment</b>.";
} }
@ -99,12 +99,12 @@ switch ($mode) {
'log_msg' => $log_msg . '<br/>-------------', 'log_msg' => $log_msg . '<br/>-------------',
]); ]);
$this->response['status'] = $bb_cfg['tor_icons'][$new_status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b> &middot; ' . profile_url($userdata) . ' &middot; <i>' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '</i>'; $this->response['status'] = config()->get('tor_icons')[$new_status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b> &middot; ' . profile_url($userdata) . ' &middot; <i>' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '</i>';
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) { if ($tor['poster_id'] > 0) {
$subject = sprintf($lang['TOR_MOD_TITLE'], $tor['topic_title']); $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']) { if ($comment && $comment != $lang['COMMENT']) {
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment; $message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
@ -117,7 +117,7 @@ switch ($mode) {
break; break;
case 'status_reply': case 'status_reply':
if (!$bb_cfg['tor_comment']) { if (!config()->get('tor_comment')) {
$this->ajax_die($lang['MODULE_OFF']); $this->ajax_die($lang['MODULE_OFF']);
} }

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $userdata, $bb_cfg, $lang, $log_action; global $userdata, $lang, $log_action;
if (!isset($this->request['attach_id'])) { if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']); $this->ajax_die($lang['EMPTY_ATTACH_ID']);

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); 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)) { 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']); $this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']);

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg, $lang; global $lang;
if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) { if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) {
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']); $this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
@ -55,7 +55,7 @@ switch ($field) {
break; break;
case 'user_gender': case 'user_gender':
if (!$bb_cfg['gender']) { if (!config()->get('gender')) {
$this->ajax_die($lang['MODULE_OFF']); $this->ajax_die($lang['MODULE_OFF']);
} }
if (!isset($lang['GENDER_SELECT'][$value])) { if (!isset($lang['GENDER_SELECT'][$value])) {
@ -65,7 +65,7 @@ switch ($field) {
break; break;
case 'user_birthday': case 'user_birthday':
if (!$bb_cfg['birthday_enabled']) { if (!config()->get('birthday_enabled')) {
$this->ajax_die($lang['MODULE_OFF']); $this->ajax_die($lang['MODULE_OFF']);
} }
$birthday_date = date_parse($value); $birthday_date = date_parse($value);
@ -73,10 +73,10 @@ switch ($field) {
if (!empty($birthday_date['year'])) { if (!empty($birthday_date['year'])) {
if (strtotime($value) >= TIMENOW) { if (strtotime($value) >= TIMENOW) {
$this->ajax_die($lang['WRONG_BIRTHDAY_FORMAT']); $this->ajax_die($lang['WRONG_BIRTHDAY_FORMAT']);
} elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > $bb_cfg['birthday_max_age']) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > config()->get('birthday_max_age')) {
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], $bb_cfg['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'] < $bb_cfg['birthday_min_age']) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < config()->get('birthday_min_age')) {
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], $bb_cfg['birthday_min_age'])); $this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], config()->get('birthday_min_age')));
} }
} }

View file

@ -11,13 +11,13 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); 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']); $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']); $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
} }

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg, $lang, $userdata, $datastore; global $lang, $userdata, $datastore;
if (!$mode = (string)$this->request['mode']) { if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)'); $this->ajax_die('invalid mode (empty)');
@ -31,9 +31,9 @@ switch ($mode) {
foreach ($stats['birthday_week_list'] as $week) { foreach ($stats['birthday_week_list'] as $week) {
$users[] = profile_url($week) . ' <span class="small">(' . birthday_age(date('Y-m-d', strtotime('-1 year', strtotime($week['user_birthday'])))) . ')</span>'; $users[] = profile_url($week) . ' <span class="small">(' . birthday_age(date('Y-m-d', strtotime('-1 year', strtotime($week['user_birthday'])))) . ')</span>';
} }
$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 { } else {
$html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']); $html = sprintf($lang['NOBIRTHDAY_WEEK'], config()->get('birthday_check_day'));
} }
break; break;
@ -84,7 +84,7 @@ switch ($mode) {
break; break;
case 'null_ratio': 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']); $this->ajax_die($lang['MODULE_OFF']);
} }
if (empty($this->request['confirmed'])) { if (empty($this->request['confirmed'])) {
@ -106,8 +106,8 @@ switch ($mode) {
if ($ratio_nulled && !IS_ADMIN) { if ($ratio_nulled && !IS_ADMIN) {
$this->ajax_die($lang['BT_NULL_RATIO_AGAIN']); $this->ajax_die($lang['BT_NULL_RATIO_AGAIN']);
} }
if (($user_ratio >= $bb_cfg['ratio_to_null']) && !IS_ADMIN) { if (($user_ratio >= config()->get('ratio_to_null')) && !IS_ADMIN) {
$this->ajax_die(sprintf($lang['BT_NULL_RATIO_NOT_NEEDED'], $bb_cfg['ratio_to_null'])); $this->ajax_die(sprintf($lang['BT_NULL_RATIO_NOT_NEEDED'], config()->get('ratio_to_null')));
} }
$ratio_nulled_sql = !IS_ADMIN ? ', ratio_nulled = 1' : ''; $ratio_nulled_sql = !IS_ADMIN ? ', ratio_nulled = 1' : '';
@ -172,7 +172,7 @@ switch ($mode) {
<th>' . $lang['UPLOADED'] . '</th> <th>' . $lang['UPLOADED'] . '</th>
<th>' . $lang['RELEASED'] . '</th> <th>' . $lang['RELEASED'] . '</th>
<th>' . $lang['BONUS'] . '</th>'; <th>' . $lang['BONUS'] . '</th>';
$html .= $bb_cfg['seed_bonus_enabled'] ? '<th>' . $lang['SEED_BONUS'] . '</th>' : ''; $html .= config()->get('seed_bonus_enabled') ? '<th>' . $lang['SEED_BONUS'] . '</th>' : '';
$html .= '</tr> $html .= '</tr>
<tr class="row1"> <tr class="row1">
<td>' . $lang['TOTAL_TRAF'] . '</td> <td>' . $lang['TOTAL_TRAF'] . '</td>
@ -180,17 +180,17 @@ switch ($mode) {
<td id="u_up_total"><span class="editable bold seedmed">' . humn_size($btu['u_up_total']) . '</span></td> <td id="u_up_total"><span class="editable bold seedmed">' . humn_size($btu['u_up_total']) . '</span></td>
<td id="u_up_release"><span class="editable bold seedmed">' . humn_size($btu['u_up_release']) . '</span></td> <td id="u_up_release"><span class="editable bold seedmed">' . humn_size($btu['u_up_release']) . '</span></td>
<td id="u_up_bonus"><span class="editable bold seedmed">' . humn_size($btu['u_up_bonus']) . '</span></td>'; <td id="u_up_bonus"><span class="editable bold seedmed">' . humn_size($btu['u_up_bonus']) . '</span></td>';
$html .= $bb_cfg['seed_bonus_enabled'] ? '<td id="user_points"><span class="editable bold points">' . $profiledata['user_points'] . '</b></td>' : ''; $html .= config()->get('seed_bonus_enabled') ? '<td id="user_points"><span class="editable bold points">' . $profiledata['user_points'] . '</b></td>' : '';
$html .= '</tr> $html .= '</tr>
<tr class="row5"> <tr class="row5">
<td colspan="1">' . $lang['MAX_SPEED'] . '</td> <td colspan="1">' . $lang['MAX_SPEED'] . '</td>
<td colspan="2">' . $lang['DL_DL_SPEED'] . ': ' . $speed_down . '</span></td> <td colspan="2">' . $lang['DL_DL_SPEED'] . ': ' . $speed_down . '</span></td>
<td colspan="2">' . $lang['DL_UL_SPEED'] . ': ' . $speed_up . '</span></td>'; <td colspan="2">' . $lang['DL_UL_SPEED'] . ': ' . $speed_up . '</span></td>';
$html .= $bb_cfg['seed_bonus_enabled'] ? '<td colspan="1"></td>' : ''; $html .= config()->get('seed_bonus_enabled') ? '<td colspan="1"></td>' : '';
$html .= '</tr>'; $html .= '</tr>';
$this->response['user_ratio'] = ' $this->response['user_ratio'] = '
<th><a href="' . $bb_cfg['ratio_url_help'] . '" class="bold">' . $lang['USER_RATIO'] . '</a>:</th> <th><a href="' . config()->get('ratio_url_help') . '" class="bold">' . $lang['USER_RATIO'] . '</a>:</th>
<td>' . $user_ratio . '</td> <td>' . $user_ratio . '</td>
'; ';
break; break;

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $userdata, $lang, $bb_cfg; global $userdata, $lang;
if (!$mode = (string)$this->request['mode']) { if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)'); $this->ajax_die('invalid mode (empty)');
@ -19,7 +19,7 @@ if (!$mode = (string)$this->request['mode']) {
switch ($mode) { switch ($mode) {
case 'clear_cache': 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(); CACHE($cache_name)->rm();
} }
@ -48,20 +48,20 @@ switch ($mode) {
$this->response['template_cache_html'] = '<span class="seed bold">' . $lang['ALL_TEMPLATE_CLEARED'] . '</span>'; $this->response['template_cache_html'] = '<span class="seed bold">' . $lang['ALL_TEMPLATE_CLEARED'] . '</span>';
break; break;
case 'indexer': 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")) { if (!is_file(config()->get('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); 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) { 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(config()->get('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);
$this->response['indexer_html'] = '<span class="seed bold">' . $lang['INDEXER'] . '</span>'; $this->response['indexer_html'] = '<span class="seed bold">' . $lang['INDEXER'] . '</span>';
break; break;

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $userdata, $lang, $bb_cfg; global $userdata, $lang;
if (!$mode = (string)$this->request['mode']) { if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)'); $this->ajax_die('invalid mode (empty)');

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $userdata, $bb_cfg, $lang, $datastore, $log_action; global $userdata, $lang, $datastore, $log_action;
if (!$mode = (string)$this->request['mode']) { if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)'); $this->ajax_die('invalid mode (empty)');
@ -44,7 +44,7 @@ switch ($mode) {
\TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $status); \TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $status);
// Log action // Log action
$log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], $bb_cfg['tor_icons'][$status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$status] . '</b>', $bb_cfg['tor_icons'][$tor['tor_status']] . ' <b> ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '</b>'); $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], config()->get('tor_icons')[$status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$status] . '</b>', config()->get('tor_icons')[$tor['tor_status']] . ' <b> ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . '</b>');
$log_action->mod('mod_topic_change_tor_status', [ $log_action->mod('mod_topic_change_tor_status', [
'forum_id' => $tor['forum_id'], 'forum_id' => $tor['forum_id'],
'topic_id' => $tor['topic_id'], 'topic_id' => $tor['topic_id'],
@ -52,7 +52,7 @@ switch ($mode) {
'log_msg' => $log_msg . '<br/>-------------', 'log_msg' => $log_msg . '<br/>-------------',
]); ]);
} }
$this->response['status'] = $bb_cfg['tor_icons'][$status]; $this->response['status'] = config()->get('tor_icons')[$status];
$this->response['topics'] = explode(',', $topics); $this->response['topics'] = explode(',', $topics);
break; 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"); 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 // Update the news cache on the index page
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id'])); $news_forums = array_flip(explode(',', config()->get('latest_news_forum_id')));
if (isset($news_forums[$t_data['forum_id']]) && $bb_cfg['show_latest_news']) { if (isset($news_forums[$t_data['forum_id']]) && config()->get('show_latest_news')) {
$datastore->enqueue([ $datastore->enqueue([
'latest_news' 'latest_news'
]); ]);
$datastore->update('latest_news'); $datastore->update('latest_news');
} }
$net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id'])); $net_forums = array_flip(explode(',', config()->get('network_news_forum_id')));
if (isset($net_forums[$t_data['forum_id']]) && $bb_cfg['show_network_news']) { if (isset($net_forums[$t_data['forum_id']]) && config()->get('show_network_news')) {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -151,8 +151,8 @@ switch ($mode) {
} else { } else {
$user_reg_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($profiledata['user_reg_ip']); $user_reg_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($profiledata['user_reg_ip']);
$user_last_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($profiledata['user_last_ip']); $user_last_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($profiledata['user_last_ip']);
$reg_ip = '<a href="' . $bb_cfg['whois_info'] . $user_reg_ip . '" class="gen" target="_blank">' . $user_reg_ip . '</a>'; $reg_ip = '<a href="' . config()->get('whois_info') . $user_reg_ip . '" class="gen" target="_blank">' . $user_reg_ip . '</a>';
$last_ip = '<a href="' . $bb_cfg['whois_info'] . $user_last_ip . '" class="gen" target="_blank">' . $user_last_ip . '</a>'; $last_ip = '<a href="' . config()->get('whois_info') . $user_last_ip . '" class="gen" target="_blank">' . $user_last_ip . '</a>';
} }
$this->response['ip_list_html'] = ' $this->response['ip_list_html'] = '

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $lang, $bb_cfg, $userdata, $wordCensor; global $lang, $userdata, $wordCensor;
if (!isset($this->request['type'])) { if (!isset($this->request['type'])) {
$this->ajax_die('empty 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"; $message = "[quote=\"" . $quote_username . "\"][qpost=" . $post['post_id'] . "]" . $post['post_text'] . "[/quote]\r";
// hide user passkey // 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 // hide sid
$message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]#', 'sid', $message); $message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]#', 'sid', $message);
@ -120,10 +120,10 @@ switch ($this->request['type']) {
if (mb_strlen($text) > 2) { if (mb_strlen($text) > 2) {
if ($text != $post['post_text']) { if ($text != $post['post_text']) {
if ($bb_cfg['max_smilies']) { if (config()->get('max_smilies')) {
$count_smilies = substr_count(bbcode2html($text), '<img class="smile" src="' . $bb_cfg['smilies_path']); $count_smilies = substr_count(bbcode2html($text), '<img class="smile" src="' . config()->get('smilies_path'));
if ($count_smilies > $bb_cfg['max_smilies']) { if ($count_smilies > config()->get('max_smilies')) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies'])); $this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies')));
} }
} }
DB()->query("UPDATE " . BB_POSTS_TEXT . " SET post_text = '" . DB()->escape($text) . "' WHERE post_id = $post_id LIMIT 1"); DB()->query("UPDATE " . BB_POSTS_TEXT . " SET post_text = '" . DB()->escape($text) . "' WHERE post_id = $post_id LIMIT 1");
@ -225,7 +225,7 @@ switch ($this->request['type']) {
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql"; $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 ($row = DB()->fetch_row($sql) and $row['last_post_time']) {
if ($userdata['user_level'] == USER) { 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']); $this->ajax_die($lang['FLOOD_ERROR']);
} }
} }
@ -251,10 +251,10 @@ switch ($this->request['type']) {
} }
} }
if ($bb_cfg['max_smilies']) { if (config()->get('max_smilies')) {
$count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . $bb_cfg['smilies_path']); $count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . config()->get('smilies_path'));
if ($count_smilies > $bb_cfg['max_smilies']) { if ($count_smilies > config()->get('max_smilies')) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies'])); $this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies')));
} }
} }
@ -272,7 +272,7 @@ switch ($this->request['type']) {
'post_text' => $message 'post_text' => $message
]); ]);
if ($bb_cfg['topic_notify_enabled']) { if (config()->get('topic_notify_enabled')) {
$notify = !empty($this->request['notify']); $notify = !empty($this->request['notify']);
\TorrentPier\Legacy\Post::user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify); \TorrentPier\Legacy\Post::user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify);
} }

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg, $lang; global $lang;
if (!$mode = (string)$this->request['mode']) { if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)'); $this->ajax_die('invalid mode (empty)');
@ -24,7 +24,7 @@ switch ($mode) {
case 'create': case 'create':
$map->createSitemap(); $map->createSitemap();
if (is_file(SITEMAP_DIR . '/sitemap.xml')) { if (is_file(SITEMAP_DIR . '/sitemap.xml')) {
$html .= $lang['SITEMAP_CREATED'] . ': <b>' . bb_date(TIMENOW, $bb_cfg['post_date_format']) . '</b> ' . $lang['SITEMAP_AVAILABLE'] . ': <a href="' . make_url('sitemap/sitemap.xml') . '" target="_blank">' . make_url('sitemap/sitemap.xml') . '</a>'; $html .= $lang['SITEMAP_CREATED'] . ': <b>' . bb_date(TIMENOW, config()->get('post_date_format')) . '</b> ' . $lang['SITEMAP_AVAILABLE'] . ': <a href="' . make_url('sitemap/sitemap.xml') . '" target="_blank">' . make_url('sitemap/sitemap.xml') . '</a>';
} else { } else {
$html .= $lang['SITEMAP_NOT_CREATED']; $html .= $lang['SITEMAP_NOT_CREATED'];
} }

View file

@ -11,9 +11,9 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); 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']); $this->ajax_die($lang['MODULE_OFF']);
} }
@ -49,12 +49,12 @@ switch ($mode) {
// Limit voters per topic // Limit voters per topic
$thanks_count = DB()->fetch_row('SELECT COUNT(*) as thx FROM ' . BB_THX . " WHERE topic_id = $topic_id")['thx']; $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"); DB()->query('DELETE FROM ' . BB_THX . " WHERE topic_id = $topic_id ORDER BY time ASC LIMIT 1");
} }
break; break;
case 'get': 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']); $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
} }

View file

@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg, $lang, $userdata; global $lang, $userdata;
if (!$mode = (string)$this->request['mode']) { if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)'); $this->ajax_die('invalid mode (empty)');

View file

@ -11,11 +11,11 @@ if (!defined('IN_AJAX')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $user, $lang, $bb_cfg; global $user, $lang;
$post_id = isset($this->request['post_id']) ? (int)$this->request['post_id'] : null; $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; $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)) { 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'); $post_id = DB()->fetch_row("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id", 'topic_first_post_id');

View file

@ -25,11 +25,11 @@ if (defined('ATTACH_INSTALL')) {
*/ */
function attach_mod_get_lang($language_file) 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)) { 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'; $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() function get_config()
{ {
global $bb_cfg;
$attach_config = []; $attach_config = [];
$sql = 'SELECT * FROM ' . BB_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 // 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; return $attach_config;
} }

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); 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; $tor_status_by_for_all = true;
$change_peers_bgr_over = 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) // 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'] ?? ''; $get_sp_mode = $_GET['spmode'] ?? '';
$s_mode = 'count'; $s_mode = 'count';
@ -51,7 +51,7 @@ if ($cfg_sp_mode == SHOW_PEERS_NAMES) {
$s_mode = 'full'; $s_mode = 'full';
} }
if ($bb_cfg['bt_allow_spmode_change']) { if (config()->get('bt_allow_spmode_change')) {
if ($get_sp_mode == 'names') { if ($get_sp_mode == 'names') {
$s_mode = 'names'; $s_mode = 'names';
} elseif ($get_sp_mode == 'full') { } 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_file_time = bb_date($attachments['_' . $post_id][$i]['filetime']);
$tor_reged = (bool)$tracker_status; $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); $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'])); $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; $tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url;
} }
if ($bb_cfg['tracker']['use_old_torrent_name_format']) { if (config()->get('tracker.use_old_torrent_name_format')) {
$display_name = '[' . $bb_cfg['server_name'] . '].t' . $bt_topic_id . '.' . TORRENT_EXT; $display_name = '[' . config()->get('server_name') . '].t' . $bt_topic_id . '.' . TORRENT_EXT;
} else { } 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) { 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); $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 // ratio limits
$min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor']; $min_ratio_dl = config()->get('bt_min_ratio_allow_dl_tor');
$min_ratio_warn = $bb_cfg['bt_min_ratio_warning']; $min_ratio_warn = config()->get('bt_min_ratio_warning');
$dl_allowed = true; $dl_allowed = true;
$user_ratio = 0; $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)) { 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([ $template->assign_vars([
'SHOW_RATIO_WARN' => true, '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), 'TOR_TYPE' => is_gold($tor_type),
// torrent status mod // 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_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)) ? ('<span title="' . bb_date($tor_info['checked_time']) . '"> &middot; ' . profile_url($tor_info) . ' &middot; <i>' . delta_time($tor_info['checked_time']) . $lang['TOR_BACK'] . '</i></span>') : '', 'TOR_STATUS_BY' => ($tor_info['checked_user_id'] && ($is_auth['auth_mod'] || $tor_status_by_for_all)) ? ('<span title="' . bb_date($tor_info['checked_time']) . '"> &middot; ' . profile_url($tor_info) . ' &middot; <i>' . delta_time($tor_info['checked_time']) . $lang['TOR_BACK'] . '</i></span>') : '',
'TOR_STATUS_SELECT' => build_select('sel_status', array_flip($lang['TOR_STATUS_NAME']), TOR_APPROVED), '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 //end torrent status mod
'S_UPLOAD_IMAGE' => $upload_image, 'S_UPLOAD_IMAGE' => $upload_image,
@ -227,7 +227,7 @@ if ($tor_reged && $tor_info) {
]); ]);
// TorrServer integration // 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', [ $template->assign_block_vars('postrow.attach.tor_reged.tor_server', [
'TORR_SERVER_M3U_LINK' => PLAYBACK_M3U_URL . $bt_topic_id, 'TORR_SERVER_M3U_LINK' => PLAYBACK_M3U_URL . $bt_topic_id,
'TORR_SERVER_M3U_ICON' => $images['icon_tor_m3u_icon'], '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([ $template->assign_vars([
'SHOW_DL_LIST' => true, 'SHOW_DL_LIST' => true,
'SHOW_DL_LIST_TOR_INFO' => true, 'SHOW_DL_LIST_TOR_INFO' => true,
@ -470,7 +470,7 @@ if ($tor_reged && $tor_info) {
} }
$peerCountry = $lang['HIDDEN_USER']; $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 (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 ($infoByIP = infoByIP((!empty($peer['ipv6']) ? $peer['ipv6'] : $peer['ip']), $peer['port'])) {
if (!empty($infoByIP['countryCode'])) { if (!empty($infoByIP['countryCode'])) {
@ -500,7 +500,7 @@ if ($tor_reged && $tor_info) {
if ($ip) { if ($ip) {
$template->assign_block_vars("$x_full.$x_row.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 '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([ $template->assign_vars([
'PEERS_FULL_LINK' => true, 'PEERS_FULL_LINK' => true,
'SPMODE_FULL_HREF' => TOPIC_URL . "$bt_topic_id&amp;spmode=full#seeders" 'SPMODE_FULL_HREF' => TOPIC_URL . "$bt_topic_id&amp;spmode=full#seeders"
@ -571,14 +571,14 @@ if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full') {
} }
$template->assign_vars([ $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_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($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) || IS_AM)), '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_COUNT' => ($s_mode == 'count'),
'S_MODE_NAMES' => ($s_mode == 'names'), 'S_MODE_NAMES' => ($s_mode == 'names'),
'S_MODE_FULL' => ($s_mode == 'full'), 'S_MODE_FULL' => ($s_mode == 'full'),
'PEER_EXIST' => ($seeders || $leechers || defined('SEEDER_EXIST') || defined('LEECHER_EXIST')), 'PEER_EXIST' => ($seeders || $leechers || defined('SEEDER_EXIST') || defined('LEECHER_EXIST')),
'SEED_EXIST' => ($seeders || defined('SEEDER_EXIST')), 'SEED_EXIST' => ($seeders || defined('SEEDER_EXIST')),
'LEECH_EXIST' => ($leechers || defined('LEECHER_EXIST')), 'LEECH_EXIST' => ($leechers || defined('LEECHER_EXIST')),
'TOR_HELP_LINKS' => $bb_cfg['tor_help_links'], 'TOR_HELP_LINKS' => config()->get('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)), '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)),
]); ]);

View file

@ -16,7 +16,7 @@
*/ */
function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $user_id = 0) 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 // Generate Array, if it's not an array
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) { 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 // TorrServer integration
if ($bb_cfg['torr_server']['enabled']) { if (config()->get('torr_server.enabled')) {
$torrServer = new \TorrentPier\TorrServerAPI(); $torrServer = new \TorrentPier\TorrServerAPI();
$torrServer->removeM3U($attachments[$j]['attach_id']); $torrServer->removeM3U($attachments[$j]['attach_id']);
} }

View file

@ -123,7 +123,7 @@ function prepare_message($message)
// Either in a window or inline // Either in a window or inline
function generate_smilies($mode) function generate_smilies($mode)
{ {
global $bb_cfg, $template, $lang, $user, $datastore; global $template, $lang, $user, $datastore;
$inline_columns = 4; $inline_columns = 4;
$inline_rows = 7; $inline_rows = 7;
@ -160,7 +160,7 @@ function generate_smilies($mode)
$template->assign_block_vars('smilies_row.smilies_col', [ $template->assign_block_vars('smilies_row.smilies_col', [
'SMILEY_CODE' => $data['code'], 'SMILEY_CODE' => $data['code'],
'SMILEY_IMG' => $bb_cfg['smilies_path'] . '/' . $smile_url, 'SMILEY_IMG' => config()->get('smilies_path') . '/' . $smile_url,
'SMILEY_DESC' => $data['emoticon'], 'SMILEY_DESC' => $data['emoticon'],
]); ]);
@ -341,11 +341,9 @@ function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $s
function extract_search_words($text) function extract_search_words($text)
{ {
global $bb_cfg; $max_words_count = config()->get('max_search_words_per_post');
$min_word_len = max(2, config()->get('search_min_word_len') - 1);
$max_words_count = $bb_cfg['max_search_words_per_post']; $max_word_len = config()->get('search_max_word_len');
$min_word_len = max(2, $bb_cfg['search_min_word_len'] - 1);
$max_word_len = $bb_cfg['search_max_word_len'];
$text = ' ' . str_compact(strip_tags(mb_strtolower($text))) . ' '; $text = ' ' . str_compact(strip_tags(mb_strtolower($text))) . ' ';
$text = str_replace(['&#91;', '&#93;'], ['[', ']'], $text); $text = str_replace(['&#91;', '&#93;'], ['[', ']'], $text);
@ -382,12 +380,10 @@ function extract_search_words($text)
function add_search_words($post_id, $post_message, $topic_title = '', $only_return_words = false) function add_search_words($post_id, $post_message, $topic_title = '', $only_return_words = false)
{ {
global $bb_cfg;
$text = $topic_title . ' ' . $post_message; $text = $topic_title . ' ' . $post_message;
$words = ($text) ? extract_search_words($text) : []; $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); return implode("\n", $words);
} }
@ -425,22 +421,19 @@ function get_words_rate($text)
function hide_passkey($str) function hide_passkey($str)
{ {
global $bb_cfg; return preg_replace("#\?{config()->get('passkey_key')}=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?{config()->get('passkey_key')}=passkey", $str);
return preg_replace("#\?{$bb_cfg['passkey_key']}=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?{$bb_cfg['passkey_key']}=passkey", $str);
} }
function get_parsed_post($postrow, $mode = 'full', $return_chars = 600) function get_parsed_post($postrow, $mode = 'full', $return_chars = 600)
{ {
global $bb_cfg; if (config()->get('use_posts_cache') && !empty($postrow['post_html'])) {
if ($bb_cfg['use_posts_cache'] && !empty($postrow['post_html'])) {
return $postrow['post_html']; return $postrow['post_html'];
} }
$message = bbcode2html($postrow['post_text']); $message = bbcode2html($postrow['post_text']);
// Posts cache // Posts cache
if ($bb_cfg['use_posts_cache']) { if (config()->get('use_posts_cache')) {
DB()->shutdown['post_html'][] = [ DB()->shutdown['post_html'][] = [
'post_id' => (int)$postrow['post_id'], 'post_id' => (int)$postrow['post_id'],
'post_html' => (string)$message 'post_html' => (string)$message

View file

@ -144,7 +144,7 @@ if ($check_attachments) {
$orphan_db_attach[] = $row['attach_id']; $orphan_db_attach[] = $row['attach_id'];
} }
// Delete all orphan attachments // 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) { foreach ($orphan_db_attach as $attach_id) {
// TorrServer integration // TorrServer integration
$torrServer = new \TorrentPier\TorrServerAPI(); $torrServer = new \TorrentPier\TorrServerAPI();

View file

@ -17,7 +17,7 @@ if (!defined('BB_ROOT')) {
\TorrentPier\Legacy\Admin\Common::sync_all_forums(); \TorrentPier\Legacy\Admin\Common::sync_all_forums();
// Cleaning bb_poll_users // 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; $per_cycle = 20000;
$row = DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM " . BB_POLL_USERS); $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']; $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)); DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400));
// Cleaning post cache // 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)"); DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)");
} }
// Autofill announcer url // 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']); bb_update_config(['bt_announce_url' => FULL_URL . 'bt/announce.php']);
} }

View file

@ -13,10 +13,10 @@ if (!defined('BB_ROOT')) {
// Delete staled dl-status records // Delete staled dl-status records
$keeping_dlstat = [ $keeping_dlstat = [
DL_STATUS_WILL => (int)$bb_cfg['dl_will_days_keep'], DL_STATUS_WILL => (int)config()->get('dl_will_days_keep'),
DL_STATUS_DOWN => (int)$bb_cfg['dl_down_days_keep'], DL_STATUS_DOWN => (int)config()->get('dl_down_days_keep'),
DL_STATUS_COMPLETE => (int)$bb_cfg['dl_complete_days_keep'], DL_STATUS_COMPLETE => (int)config()->get('dl_complete_days_keep'),
DL_STATUS_CANCEL => (int)$bb_cfg['dl_cancel_days_keep'] DL_STATUS_CANCEL => (int)config()->get('dl_cancel_days_keep')
]; ];
$delete_dlstat_sql = []; $delete_dlstat_sql = [];
@ -51,7 +51,7 @@ DB()->query("
"); ");
// Tor-Stats cleanup // 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)"); DB()->query("DELETE QUICK FROM " . BB_BT_TORSTAT . " WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)");
} }

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); 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) { if ($log_days_keep !== 0) {
DB()->query("DELETE FROM " . BB_LOG . " WHERE log_time < " . (TIMENOW - 86400 * $log_days_keep)); DB()->query("DELETE FROM " . BB_LOG . " WHERE log_time < " . (TIMENOW - 86400 * $log_days_keep));

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); 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) { if ($pm_days_keep !== 0) {
$per_cycle = 20000; $per_cycle = 20000;

View file

@ -23,7 +23,7 @@ if (!IN_DEMO_MODE || !is_file($dump_path) || !is_readable($dump_path)) {
// Clean cache & datastore // Clean cache & datastore
$datastore->clean(); $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(); CACHE($cache_name)->rm();
} }

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); 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"; $sql = "SELECT forum_id, prune_days FROM " . BB_FORUMS . " WHERE prune_days != 0";
foreach (DB()->fetch_rowset($sql) as $row) { foreach (DB()->fetch_rowset($sql) as $row) {

View file

@ -17,7 +17,7 @@ while (true) {
set_time_limit(600); set_time_limit(600);
$prune_users = $not_activated_users = $not_active_users = []; $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 . " $sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
WHERE user_level = 0 WHERE user_level = 0
AND user_lastvisit = 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 . " $sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
WHERE user_level = 0 WHERE user_level = 0
AND user_posts = 0 AND user_posts = 0

View file

@ -11,8 +11,8 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
if ($bb_cfg['topic_moved_days_keep']) { if (config()->get('topic_moved_days_keep')) {
$prune_time = TIMENOW - 86400 * $bb_cfg['topic_moved_days_keep']; $prune_time = TIMENOW - 86400 * config()->get('topic_moved_days_keep');
DB()->query(" DB()->query("
DELETE FROM " . BB_TOPICS . " DELETE FROM " . BB_TOPICS . "

View file

@ -11,10 +11,10 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
$user_session_expire_time = TIMENOW - (int)$bb_cfg['user_session_duration']; $user_session_expire_time = TIMENOW - (int)config()->get('user_session_duration');
$admin_session_expire_time = TIMENOW - (int)$bb_cfg['admin_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; $admin_session_gc_time = $admin_session_expire_time;
// ############################ Tables LOCKED ################################ // ############################ Tables LOCKED ################################

View file

@ -27,7 +27,7 @@ DB()->query("CREATE TABLE " . NEW_BB_BT_LAST_USERSTAT . " LIKE " . BB_BT_LAST_US
DB()->expect_slow_query(600); DB()->expect_slow_query(600);
// Update dlstat (part 1) // Update dlstat (part 1)
if ($bb_cfg['tracker']['update_dlstat']) { if (config()->get('tracker.update_dlstat')) {
// ############################ Tables LOCKED ################################ // ############################ Tables LOCKED ################################
DB()->lock([ DB()->lock([
BB_BT_TRACKER, BB_BT_TRACKER,
@ -64,16 +64,16 @@ DB()->query("
"); ");
// Clean peers table // Clean peers table
if ($bb_cfg['tracker']['autoclean']) { if (config()->get('tracker.autoclean')) {
$announce_interval = max((int)$bb_cfg['announce_interval'], 60); $announce_interval = max((int)config()->get('announce_interval'), 60);
$expire_factor = max((float)$bb_cfg['tracker']['expire_factor'], 1); $expire_factor = max((float)config()->get('tracker.expire_factor'), 1);
$peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor); $peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor);
DB()->query("DELETE FROM " . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time"); DB()->query("DELETE FROM " . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time");
} }
// Update dlstat (part 2) // Update dlstat (part 2)
if ($bb_cfg['tracker']['update_dlstat']) { if (config()->get('tracker.update_dlstat')) {
// Set "only 1 seeder" bonus // Set "only 1 seeder" bonus
DB()->query(" DB()->query("
UPDATE UPDATE

View file

@ -11,12 +11,12 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); 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; return;
} }
$last_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_last_seen_days_keep']; $last_seen_time = TIMENOW - 86400 * config()->get('seeder_last_seen_days_keep');
$never_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_never_seen_days_keep']; $never_seen_time = TIMENOW - 86400 * config()->get('seeder_never_seen_days_keep');
$limit_sql = 3000; $limit_sql = 3000;
$topics_sql = $attach_sql = []; $topics_sql = $attach_sql = [];

View file

@ -11,8 +11,6 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg;
DB()->expect_slow_query(600); 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); 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(" DB()->query("
INSERT INTO " . NEW_BB_BT_DLSTATUS_SNAP . " INSERT INTO " . NEW_BB_BT_DLSTATUS_SNAP . "
(topic_id, dl_status, users_count) (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 // TORHELP
// //
if ($bb_cfg['torhelp_enabled']) { if (config()->get('torhelp_enabled')) {
$tor_min_seeders = 0; // "<=" $tor_min_seeders = 0; // "<="
$tor_min_leechers = 2; // ">=" $tor_min_leechers = 2; // ">="
$tor_min_completed = 10; // ">=" $tor_min_completed = 10; // ">="
@ -147,7 +145,7 @@ if ($bb_cfg['torhelp_enabled']) {
WHERE WHERE
trsn.seeders <= $tor_min_seeders trsn.seeders <= $tor_min_seeders
AND trsn.leechers >= $tor_min_leechers 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.complete_count >= $tor_min_completed
AND tor.seeder_last_seen <= (UNIX_TIMESTAMP() - $tor_seed_last_seen_days*86400) AND tor.seeder_last_seen <= (UNIX_TIMESTAMP() - $tor_seed_last_seen_days*86400)
AND dl.user_id IN($online_users_csv) AND dl.user_id IN($online_users_csv)

View file

@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
DB()->expect_slow_query(600); 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(" DB()->query("
CREATE TEMPORARY TABLE tmp_bonus ( CREATE TEMPORARY TABLE tmp_bonus (
user_id INT UNSIGNED NOT NULL DEFAULT '0', 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 ) 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 DB()->query("INSERT INTO tmp_bonus
SELECT bt.user_id, count(bt.seeder) AS release_count 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 GROUP BY bt.user_id
"); ");
$seed_bonus = unserialize($bb_cfg['seed_bonus_points']); $seed_bonus = unserialize(config()->get('seed_bonus_points'));
$seed_release = unserialize($bb_cfg['seed_bonus_release']); $seed_release = unserialize(config()->get('seed_bonus_release'));
foreach ($seed_bonus as $i => $points) { foreach ($seed_bonus as $i => $points) {
if (!$points || !$seed_release[$i]) { 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); $user_points = ((float)$points / 4);
$release = (int)$seed_release[$i]; $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(" DB()->query("
UPDATE " . BB_USERS . " u, " . BB_BT_USERS . " bu, tmp_bonus b UPDATE " . BB_USERS . " u, " . BB_BT_USERS . " bu, tmp_bonus b

View file

@ -11,13 +11,11 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg;
$timecheck = TIMENOW - 600; $timecheck = TIMENOW - 600;
$forums_data = DB()->fetch_rowset("SELECT forum_id, allow_reg_tracker, forum_name FROM " . BB_FORUMS); $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 (is_file(config()->get('atom.path') . '/f/0.atom')) {
if (filemtime($bb_cfg['atom']['path'] . '/f/0.atom') <= $timecheck) { if (filemtime(config()->get('atom.path') . '/f/0.atom') <= $timecheck) {
\TorrentPier\Legacy\Atom::update_forum_feed(0, $forums_data); \TorrentPier\Legacy\Atom::update_forum_feed(0, $forums_data);
} }
} else { } else {
@ -25,8 +23,8 @@ if (is_file($bb_cfg['atom']['path'] . '/f/0.atom')) {
} }
foreach ($forums_data as $forum_data) { foreach ($forums_data as $forum_data) {
if (is_file($bb_cfg['atom']['path'] . '/f/' . $forum_data['forum_id'] . '.atom')) { if (is_file(config()->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom')) {
if (filemtime($bb_cfg['atom']['path'] . '/f/' . $forum_data['forum_id'] . '.atom') <= $timecheck) { 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); \TorrentPier\Legacy\Atom::update_forum_feed($forum_data['forum_id'], $forum_data);
} }
} else { } else {

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bf, $bb_cfg; global $bf;
// //
// cat_forums // cat_forums
@ -106,7 +106,7 @@ $this->store('cat_forums', $data);
// //
// jumpbox // jumpbox
// //
if ($bb_cfg['show_jumpbox']) { if (config()->get('show_jumpbox')) {
$data = [ $data = [
'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'), '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;"'), '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 // latest_news
// //
if ($bb_cfg['show_latest_news'] and $news_forum_ids = $bb_cfg['latest_news_forum_id']) { if (config()->get('show_latest_news') and $news_forum_ids = config()->get('latest_news_forum_id')) {
$news_count = max($bb_cfg['latest_news_count'], 1); $news_count = max(config()->get('latest_news_count'), 1);
$data = DB()->fetch_rowset(" $data = DB()->fetch_rowset("
SELECT topic_id, topic_time, topic_title, forum_id 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 // Network_news
// //
if ($bb_cfg['show_network_news'] and $net_forum_ids = $bb_cfg['network_news_forum_id']) { if (config()->get('show_network_news') and $net_forum_ids = config()->get('network_news_forum_id')) {
$net_count = max($bb_cfg['network_news_count'], 1); $net_count = max(config()->get('network_news_count'), 1);
$data = DB()->fetch_rowset(" $data = DB()->fetch_rowset("
SELECT topic_id, topic_time, topic_title, forum_id SELECT topic_id, topic_time, topic_title, forum_id

View file

@ -11,19 +11,17 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg; if (!config()->get('tp_updater_settings.enabled')) {
if (!$bb_cfg['tp_updater_settings']['enabled']) {
return; return;
} }
$data = []; $data = [];
$updaterDownloader = new \TorrentPier\Updater(); $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']); $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! // Has update!
if (\z4kn4fein\SemVer\Version::greaterThan($getVersion, $currentVersion)) { if (\z4kn4fein\SemVer\Version::greaterThan($getVersion, $currentVersion)) {

View file

@ -11,8 +11,6 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg;
$smilies = []; $smilies = [];
$rowset = DB()->fetch_rowset("SELECT * FROM " . BB_SMILIES); $rowset = DB()->fetch_rowset("SELECT * FROM " . BB_SMILIES);
@ -20,7 +18,7 @@ sort($rowset);
foreach ($rowset as $smile) { foreach ($rowset as $smile) {
$smilies['orig'][] = '#(?<=^|\W)' . preg_quote($smile['code'], '#') . '(?=$|\W)#'; $smilies['orig'][] = '#(?<=^|\W)' . preg_quote($smile['code'], '#') . '(?=$|\W)#';
$smilies['repl'][] = ' <img class="smile" src="' . $bb_cfg['smilies_path'] . '/' . $smile['smile_url'] . '" alt="' . $smile['code'] . '" title="' . $smile['emoticon'] . '" align="absmiddle" border="0" />'; $smilies['repl'][] = ' <img class="smile" src="' . config()->get('smilies_path') . '/' . $smile['smile_url'] . '" alt="' . $smile['code'] . '" title="' . $smile['emoticon'] . '" align="absmiddle" border="0" />';
$smilies['smile'][] = $smile; $smilies['smile'][] = $smile;
} }

View file

@ -11,8 +11,6 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg;
$data = []; $data = [];
// usercount // usercount
@ -29,7 +27,7 @@ $data['postcount'] = commify($row['postcount']);
$data['topiccount'] = commify($row['topiccount']); $data['topiccount'] = commify($row['topiccount']);
// Tracker stats // Tracker stats
if ($bb_cfg['tor_stats']) { if (config()->get('tor_stats')) {
// torrents stat // torrents stat
$row = DB()->fetch_row("SELECT COUNT(topic_id) AS torrentcount, SUM(size) AS size FROM " . BB_BT_TORRENTS); $row = DB()->fetch_row("SELECT COUNT(topic_id) AS torrentcount, SUM(size) AS size FROM " . BB_BT_TORRENTS);
$data['torrentcount'] = commify($row['torrentcount']); $data['torrentcount'] = commify($row['torrentcount']);
@ -44,7 +42,7 @@ if ($bb_cfg['tor_stats']) {
} }
// gender stat // 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 . ")"); $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 . ")"); $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 . ")"); $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 // 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 $sql = DB()->fetch_rowset("SELECT user_id, username, user_rank , user_birthday
FROM " . BB_USERS . " FROM " . BB_USERS . "
WHERE user_id NOT IN(" . EXCLUDED_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_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 = []; $birthday_today_list = $birthday_week_list = [];

View file

@ -13,22 +13,19 @@ if (!defined('BB_ROOT')) {
function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div) function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div)
{ {
global $bb_cfg; $ext = config()->get('file_id_ext')[$ext_id] ?? '';
$ext = $bb_cfg['file_id_ext'][$ext_id] ?? '';
return ($base_path ? "$base_path/" : '') . floor($id / $first_div) . '/' . ($id % $sec_div) . '/' . $id . ($ext ? ".$ext" : ''); 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) function get_avatar_path($id, $ext_id, $base_path = null, $first_div = 10000, $sec_div = 100)
{ {
global $bb_cfg; $base_path ??= config()->get('avatars.upload_path');
$base_path ??= $bb_cfg['avatars']['upload_path'];
return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); 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) function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 10000, $sec_div = 100)
{ {
global $bb_cfg; $base_path ??= config()->get('attach.upload_path');
$base_path ??= $bb_cfg['attach']['upload_path'];
return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); 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 = '&nbsp;')
function bt_show_ip($ip, $port = '') function bt_show_ip($ip, $port = '')
{ {
global $bb_cfg;
if (IS_AM) { if (IS_AM) {
$ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($ip); $ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($ip);
@ -617,18 +612,16 @@ function bt_show_ip($ip, $port = '')
return $ip; 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) function bt_show_port($port)
{ {
global $bb_cfg;
if (IS_AM) { if (IS_AM) {
return $port; 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) 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 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']; $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); $joined = bb_date($row['user_regdate'], 'Y-m-d H:i', false);
$user_time = !empty($row['user_time']) ? sprintf('%s <span class="signature">(%s)</span>', bb_date($row['user_time']), delta_time($row['user_time'])) : $lang['NOSELECT']; $user_time = !empty($row['user_time']) ? sprintf('%s <span class="signature">(%s)</span>', bb_date($row['user_time']), delta_time($row['user_time'])) : $lang['NOSELECT'];
$posts = '<a href="search.php?search_author=1&amp;uid=' . $row['user_id'] . '" target="_blank">' . $row['user_posts'] ?: 0 . '</a>'; $posts = '<a href="search.php?search_author=1&amp;uid=' . $row['user_id'] . '" target="_blank">' . $row['user_posts'] ?: 0 . '</a>';
$pm = $bb_cfg['text_buttons'] ? '<a class="txtb" href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $lang['SEND_PM_TXTB'] . '</a>' : '<a href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PRIVATE_MESSAGE'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" border="0" /></a>'; $pm = config()->get('text_buttons') ? '<a class="txtb" href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $lang['SEND_PM_TXTB'] . '</a>' : '<a href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PRIVATE_MESSAGE'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" border="0" /></a>';
$avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), 50, 50); $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'])) { 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&amp;" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email']; $email_uri = (config()->get('board_email_form')) ? ("profile.php?mode=email&amp;" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email'];
$email = '<a class="editable" href="' . $email_uri . '">' . $row['user_email'] . '</a>'; $email = '<a class="editable" href="' . $email_uri . '">' . $row['user_email'] . '</a>';
} else { } else {
$email = $lang['HIDDEN_USER']; $email = $lang['HIDDEN_USER'];
} }
if ($row['user_website']) { if ($row['user_website']) {
$www = $bb_cfg['text_buttons'] ? '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww">' . $lang['VISIT_WEBSITE_TXTB'] . '</a>' : '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE'] . '" title="' . $lang['VISIT_WEBSITE'] . '" border="0" /></a>'; $www = config()->get('text_buttons') ? '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww">' . $lang['VISIT_WEBSITE_TXTB'] . '</a>' : '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE'] . '" title="' . $lang['VISIT_WEBSITE'] . '" border="0" /></a>';
} else { } else {
$www = $lang['NOSELECT']; $www = $lang['NOSELECT'];
} }
@ -996,9 +989,9 @@ function get_userdata(int|string $u, bool $is_name = false, bool $allow_guest =
function make_jumpbox(): void function make_jumpbox(): void
{ {
global $datastore, $template, $bb_cfg; global $datastore, $template;
if (!$bb_cfg['show_jumpbox']) { if (!config()->get('show_jumpbox')) {
return; return;
} }
@ -1076,14 +1069,14 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
function setup_style() function setup_style()
{ {
global $bb_cfg, $template, $userdata; global $template, $userdata;
// AdminCP works only with default template // AdminCP works only with default template
$tpl_dir_name = defined('IN_ADMIN') ? 'default' : basename($bb_cfg['tpl_name']); $tpl_dir_name = defined('IN_ADMIN') ? 'default' : basename(config()->get('tpl_name'));
$stylesheet = defined('IN_ADMIN') ? 'main.css' : basename($bb_cfg['stylesheet']); $stylesheet = defined('IN_ADMIN') ? 'main.css' : basename(config()->get('stylesheet'));
if (!IS_GUEST && !empty($userdata['tpl_name'])) { 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) { if ($userdata['tpl_name'] == $folder) {
$tpl_dir_name = basename($userdata['tpl_name']); $tpl_dir_name = basename($userdata['tpl_name']);
} }
@ -1096,7 +1089,7 @@ function setup_style()
$template->assign_vars([ $template->assign_vars([
'SPACER' => make_url('styles/images/spacer.gif'), 'SPACER' => make_url('styles/images/spacer.gif'),
'STYLESHEET' => make_url($css_dir . $stylesheet), '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), 'TPL_DIR' => make_url($css_dir),
'SITE_URL' => make_url('/') 'SITE_URL' => make_url('/')
]); ]);
@ -1109,19 +1102,19 @@ function setup_style()
// Create date / time with format and friendly date // Create date / time with format and friendly date
function bb_date($gmepoch, $format = false, $friendly_date = true) function bb_date($gmepoch, $format = false, $friendly_date = true)
{ {
global $bb_cfg, $lang, $userdata; global $lang, $userdata;
$gmepoch = (int)$gmepoch; $gmepoch = (int)$gmepoch;
if (!$format) { if (!$format) {
$format = $bb_cfg['default_dateformat']; $format = config()->get('default_dateformat');
} }
if (empty($lang)) { 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) { if (!defined('IS_GUEST') || IS_GUEST) {
$tz = $bb_cfg['board_timezone']; $tz = config()->get('board_timezone');
} else { } else {
$tz = $userdata['user_timezone']; $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 function get_user_torrent_client(string $peer_id): string
{ {
global $bb_cfg;
static $iconExtension = '.png'; static $iconExtension = '.png';
$bestMatch = null; $bestMatch = null;
$bestMatchLength = 0; $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) { if (str_starts_with($peer_id, $key) !== false && strlen($key) > $bestMatchLength) {
$bestMatch = $clientName; $bestMatch = $clientName;
$bestMatchLength = strlen($key); $bestMatchLength = strlen($key);
@ -1223,12 +1215,11 @@ function render_flag(string $code, bool $showName = true): string
function birthday_age($date) function birthday_age($date)
{ {
global $bb_cfg;
if (!$date) { if (!$date) {
return ''; return '';
} }
$tz = TIMENOW + (3600 * $bb_cfg['board_timezone']); $tz = TIMENOW + (3600 * config()->get('board_timezone'));
return delta_time(strtotime($date, $tz)); return delta_time(strtotime($date, $tz));
} }
@ -1339,7 +1330,7 @@ function bb_preg_quote($str, $delimiter)
function bb_die($msg_text, $status_code = null) 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)) { if (isset($status_code)) {
http_response_code($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
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 // 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 the header hasn't been output then do it
if (!defined('PAGE_HEADER_SENT')) { if (!defined('PAGE_HEADER_SENT')) {
if (empty($template)) { 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)) { if (empty($theme)) {
$theme = setup_style(); $theme = setup_style();
@ -1397,8 +1388,6 @@ function bb_die($msg_text, $status_code = null)
function bb_simple_die($txt, $status_code = null) function bb_simple_die($txt, $status_code = null)
{ {
global $bb_cfg;
header('Content-Type: text/plain; charset=' . DEFAULT_CHARSET); header('Content-Type: text/plain; charset=' . DEFAULT_CHARSET);
if (isset($status_code)) { if (isset($status_code)) {
@ -1426,8 +1415,6 @@ function meta_refresh($url, $time = 5)
function redirect($url) function redirect($url)
{ {
global $bb_cfg;
if (headers_sent($filename, $linenum)) { if (headers_sent($filename, $linenum)) {
trigger_error("Headers already sent in $filename($linenum)", E_USER_ERROR); trigger_error("Headers already sent in $filename($linenum)", E_USER_ERROR);
} }
@ -1437,11 +1424,11 @@ function redirect($url)
} }
$url = trim($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_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(config()->get('server_name')));
$server_port = ($bb_cfg['server_port'] <> 80) ? ':' . trim($bb_cfg['server_port']) : ''; $server_port = (config()->get('server_port') <> 80) ? ':' . trim(config()->get('server_port')) : '';
$script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($bb_cfg['script_path'])); $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(config()->get('script_path')));
if ($script_name) { if ($script_name) {
$script_name = "/$script_name"; $script_name = "/$script_name";
@ -1549,9 +1536,9 @@ function cat_exists($cat_id): bool
function get_topic_icon($topic, $is_unread = null) 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']); $is_unread ??= is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']);
if ($topic['topic_status'] == TOPIC_MOVED) { 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) function clean_text_match($text, $ltrim_star = true, $die_if_empty = false)
{ {
global $bb_cfg, $lang; global $lang;
$text = str_compact($text); $text = str_compact($text);
$ltrim_chars = ($ltrim_star) ? ' *-!' : ' '; $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)) . ' '; $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('#(?<=\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 = 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 $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 = []) 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 = []; $where_ids = [];
if ($forum_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); $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(); $sphinx = init_sphinx();
$where = $title_match ? 'topics' : 'posts'; $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) { if ($forum_ids) {
$sphinx->setFilter('forum_id', $forum_ids, false); $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()) { if ($warning = $sphinx->getLastWarning()) {
log_sphinx_error('wrn', $warning, $title_match_sql); 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) . ")" : ''; $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) { if ($title_match) {
$where_id = 'topic_id'; $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 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; return false;
} }
// Only for registered users // Only for registered users
if (!$bb_cfg['magnet_links_for_guests'] && IS_GUEST) { if (!config()->get('magnet_links_for_guests') && IS_GUEST) {
return false; return false;
} }
@ -1864,7 +1851,7 @@ function create_magnet(string $infohash, string $infohash_v2, string $auth_key,
$magnet .= '&xl=' . $length; $magnet .= '&xl=' . $length;
} }
return '<a title="' . ($v2_support ? $lang['MAGNET_v2'] : $lang['MAGNET']) . '" href="' . $magnet . '&tr=' . urlencode($bb_cfg['bt_announce_url'] . "?{$bb_cfg['passkey_key']}=$auth_key") . '&dn=' . urlencode($name) . '"><img src="' . ($v2_support ? $images['icon_magnet_v2'] : $images['icon_magnet']) . '" width="12" height="12" border="0" /></a>'; return '<a title="' . ($v2_support ? $lang['MAGNET_v2'] : $lang['MAGNET']) . '" href="' . $magnet . '&tr=' . urlencode(config()->get('bt_announce_url') . "?" . config()->get('passkey_key') . "=$auth_key") . '&dn=' . urlencode($name) . '"><img src="' . ($v2_support ? $images['icon_magnet_v2'] : $images['icon_magnet']) . '" width="12" height="12" border="0" /></a>';
} }
function set_die_append_msg($forum_id = null, $topic_id = null, $group_id = null) 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 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')) { if (!$ranks = $datastore->get('ranks')) {
$datastore->update('ranks'); $datastore->update('ranks');
@ -1940,7 +1927,7 @@ function profile_url(array $data, bool $target_blank = false, bool $no_link = fa
$style = 'colorUser'; $style = 'colorUser';
if (isset($ranks[$user_rank])) { if (isset($ranks[$user_rank])) {
$title = $ranks[$user_rank]['rank_title']; $title = $ranks[$user_rank]['rank_title'];
if ($bb_cfg['color_nick']) { if (config()->get('color_nick')) {
$style = $ranks[$user_rank]['rank_style']; $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 = '') function get_avatar($user_id, $ext_id, $allow_avatar = true, $height = '', $width = '')
{ {
global $bb_cfg;
$height = $height ? 'height="' . $height . '"' : ''; $height = $height ? 'height="' . $height . '"' : '';
$width = $width ? 'width="' . $width . '"' : ''; $width = $width ? 'width="' . $width . '"' : '';
$user_avatar = '<img src="' . make_url($bb_cfg['avatars']['display_path'] . $bb_cfg['avatars']['no_avatar']) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />'; $user_avatar = '<img src="' . make_url(config()->get('avatars.display_path') . config()->get('avatars.no_avatar')) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
if ($user_id == BOT_UID && $bb_cfg['avatars']['bot_avatar']) { if ($user_id == BOT_UID && config()->get('avatars.bot_avatar')) {
$user_avatar = '<img src="' . make_url($bb_cfg['avatars']['display_path'] . $bb_cfg['avatars']['bot_avatar']) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />'; $user_avatar = '<img src="' . make_url(config()->get('avatars.display_path') . config()->get('avatars.bot_avatar')) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
} elseif ($allow_avatar && $ext_id) { } elseif ($allow_avatar && $ext_id) {
if (is_file(get_avatar_path($user_id, $ext_id))) { if (is_file(get_avatar_path($user_id, $ext_id))) {
$user_avatar = '<img src="' . make_url(get_avatar_path($user_id, $ext_id, $bb_cfg['avatars']['display_path'])) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />'; $user_avatar = '<img src="' . make_url(get_avatar_path($user_id, $ext_id, config()->get('avatars.display_path'))) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
} }
} }
@ -1994,9 +1979,9 @@ function get_avatar($user_id, $ext_id, $allow_avatar = true, $height = '', $widt
*/ */
function genderImage(int $gender): ?string function genderImage(int $gender): ?string
{ {
global $bb_cfg, $lang, $images; global $lang, $images;
if (!$bb_cfg['gender']) { if (!config()->get('gender')) {
return false; return false;
} }
@ -2009,12 +1994,12 @@ function genderImage(int $gender): ?string
function is_gold($type): string function is_gold($type): string
{ {
global $lang, $bb_cfg, $images; global $lang, $images;
$type = (int)$type; $type = (int)$type;
$is_gold = ''; $is_gold = '';
if (!$bb_cfg['tracker']['gold_silver_enabled']) { if (!config()->get('tracker.gold_silver_enabled')) {
return $is_gold; return $is_gold;
} }
@ -2083,10 +2068,10 @@ function hash_search($hash)
*/ */
function bb_captcha(string $mode): bool|string function bb_captcha(string $mode): bool|string
{ {
global $bb_cfg, $lang; global $lang;
$settings = $bb_cfg['captcha']; $settings = config()->get('captcha');
$settings['language'] = $bb_cfg['default_lang']; $settings['language'] = config()->get('default_lang');
// Checking captcha settings // Checking captcha settings
if (!$settings['disabled'] && $settings['service'] !== 'text') { if (!$settings['disabled'] && $settings['service'] !== 'text') {
@ -2138,13 +2123,13 @@ function clean_tor_dirname($dirname)
*/ */
function user_birthday_icon($user_birthday, $user_id): string function user_birthday_icon($user_birthday, $user_id): string
{ {
global $bb_cfg, $images, $lang; global $images, $lang;
$current_date = bb_date(TIMENOW, 'md', false); $current_date = bb_date(TIMENOW, 'md', false);
$user_birthday = ($user_id != GUEST_UID && !empty($user_birthday) && $user_birthday != '1900-01-01') $user_birthday = ($user_id != GUEST_UID && !empty($user_birthday) && $user_birthday != '1900-01-01')
? bb_date(strtotime($user_birthday), 'md', false) : false; ? bb_date(strtotime($user_birthday), 'md', false) : false;
return ($bb_cfg['birthday_enabled'] && $current_date == $user_birthday) ? '<img src="' . $images['icon_birthday'] . '" alt="' . $lang['HAPPY_BIRTHDAY'] . '" title="' . $lang['HAPPY_BIRTHDAY'] . '" border="0" />' : ''; return (config()->get('birthday_enabled') && $current_date == $user_birthday) ? '<img src="' . $images['icon_birthday'] . '" alt="' . $lang['HAPPY_BIRTHDAY'] . '" title="' . $lang['HAPPY_BIRTHDAY'] . '" border="0" />' : '';
} }
/** /**
@ -2190,9 +2175,7 @@ function readUpdaterFile(): array|bool
*/ */
function infoByIP(string $ipAddress, int $port = 0): array function infoByIP(string $ipAddress, int $port = 0): array
{ {
global $bb_cfg; if (!config()->get('ip2country_settings.enabled')) {
if (!$bb_cfg['ip2country_settings']['enabled']) {
return []; return [];
} }
@ -2203,14 +2186,14 @@ function infoByIP(string $ipAddress, int $port = 0): array
$data = []; $data = [];
$contextOptions = []; $contextOptions = [];
if (!empty($bb_cfg['ip2country_settings']['api_token'])) { if (!empty(config()->get('ip2country_settings.api_token'))) {
$contextOptions['http'] = [ $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); $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) { if ($response !== false) {
$json = json_decode($response, true); $json = json_decode($response, true);

View file

@ -39,9 +39,7 @@ function send_page($contents)
*/ */
function compress_output($contents) function compress_output($contents)
{ {
global $bb_cfg; if (config()->get('gzip_compress') && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
if ($bb_cfg['gzip_compress'] && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
if (UA_GZIP_SUPPORTED && strlen($contents) > 2000) { if (UA_GZIP_SUPPORTED && strlen($contents) > 2000) {
header('Content-Encoding: gzip'); header('Content-Encoding: gzip');
$contents = gzencode($contents, 1); $contents = gzencode($contents, 1);
@ -59,7 +57,7 @@ if (!defined('IN_AJAX')) {
} }
// Cookie params // Cookie params
$c = $bb_cfg['cookie_prefix']; $c = config()->get('cookie_prefix');
define('COOKIE_DATA', $c . 'data'); define('COOKIE_DATA', $c . 'data');
define('COOKIE_FORUM', $c . 'f'); define('COOKIE_FORUM', $c . 'f');
define('COOKIE_MARK', $c . 'mark_read'); 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 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( $cookie = new \Josantonius\Cookie\Cookie(
domain: $bb_cfg['cookie_domain'], domain: config()->get('cookie_domain'),
expires: $lifetime, expires: $lifetime,
httpOnly: $httponly, httpOnly: $httponly,
path: $bb_cfg['script_path'], path: config()->get('script_path'),
raw: $isRaw, raw: $isRaw,
sameSite: $bb_cfg['cookie_same_site'], sameSite: config()->get('cookie_same_site'),
secure: $bb_cfg['cookie_secure'] secure: config()->get('cookie_secure')
); );
if (!empty($val)) { if (!empty($val)) {
@ -275,14 +271,14 @@ define('PAGE_HEADER', INC_DIR . '/page_header.php');
define('PAGE_FOOTER', INC_DIR . '/page_footer.php'); define('PAGE_FOOTER', INC_DIR . '/page_footer.php');
define('CAT_URL', 'index.php?' . POST_CAT_URL . '='); 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('FORUM_URL', 'viewforum.php?' . POST_FORUM_URL . '=');
define('GROUP_URL', 'group.php?' . POST_GROUPS_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('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('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&amp;' . POST_USERS_URL . '='); define('PROFILE_URL', 'profile.php?mode=viewprofile&amp;' . POST_USERS_URL . '=');
define('BONUS_URL', 'profile.php?mode=bonus'); define('BONUS_URL', 'profile.php?mode=bonus');
define('TOPIC_URL', 'viewtopic.php?' . POST_TOPIC_URL . '='); define('TOPIC_URL', 'viewtopic.php?' . POST_TOPIC_URL . '=');
@ -378,7 +374,10 @@ function make_url(string $path = ''): string
*/ */
require_once INC_DIR . '/functions.php'; require_once INC_DIR . '/functions.php';
$bb_cfg = array_merge(bb_get_config(BB_CONFIG), $bb_cfg); // Merge database configuration with base configuration using singleton
// bb_cfg deprecated, but kept for compatibility with non-adapted code
config()->merge(bb_get_config(BB_CONFIG));
$bb_cfg = config()->all();
$log_action = new TorrentPier\Legacy\LogAction(); $log_action = new TorrentPier\Legacy\LogAction();
$wordCensor = new TorrentPier\Censor(); $wordCensor = new TorrentPier\Censor();
@ -396,7 +395,7 @@ if (
!is_file(CRON_RUNNING) && !is_file(CRON_RUNNING) &&
(TorrentPier\Helpers\CronHelper::isEnabled() || defined('START_CRON')) (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 */ /** Update cron_last_check */
bb_update_config(['cron_last_check' => TIMENOW + 10]); bb_update_config(['cron_last_check' => TIMENOW + 10]);
@ -436,8 +435,8 @@ if (
/** /**
* Exit if board is disabled via trigger * 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 ((config()->get('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')) {
// admin lock // admin lock
send_no_cache_headers(); send_no_cache_headers();
bb_die('BOARD_DISABLE', 503); bb_die('BOARD_DISABLE', 503);

View file

@ -116,7 +116,7 @@ if (!$online['userlist']) {
$total_online = $logged_online + $guests_online; $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([ bb_update_config([
'record_online_users' => $total_online, 'record_online_users' => $total_online,
'record_online_date' => TIMENOW 'record_online_date' => TIMENOW

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
global $bb_cfg, $userdata, $template, $DBS, $lang; global $userdata, $template, $DBS, $lang;
if (!empty($template)) { if (!empty($template)) {
$birthday_tp = ((string)bb_date(TIMENOW, 'd.m', false) === '04.04') ? '&nbsp;|&nbsp;&#127881;&#127856;&#128154;' : ''; $birthday_tp = ((string)bb_date(TIMENOW, 'd.m', false) === '04.04') ? '&nbsp;|&nbsp;&#127881;&#127856;&#128154;' : '';
@ -29,7 +29,7 @@ if (!empty($template)) {
$show_dbg_info = (DBG_USER && !(isset($_GET['pane']) && $_GET['pane'] == 'left')); $show_dbg_info = (DBG_USER && !(isset($_GET['pane']) && $_GET['pane'] == 'left'));
if (!$bb_cfg['gzip_compress']) { if (!config()->get('gzip_compress')) {
flush(); flush();
} }
@ -37,7 +37,7 @@ if ($show_dbg_info) {
$gen_time = utime() - TIMESTART; $gen_time = utime() - TIMESTART;
$gen_time_txt = sprintf('%.3f', $gen_time); $gen_time_txt = sprintf('%.3f', $gen_time);
$gzip_text = UA_GZIP_SUPPORTED ? "{$lang['GZIP_COMPRESSION']}: " : "<s>{$lang['GZIP_COMPRESSION']}:</s> "; $gzip_text = UA_GZIP_SUPPORTED ? "{$lang['GZIP_COMPRESSION']}: " : "<s>{$lang['GZIP_COMPRESSION']}:</s> ";
$gzip_text .= $bb_cfg['gzip_compress'] ? $lang['ON'] : $lang['OFF']; $gzip_text .= config()->get('gzip_compress') ? $lang['ON'] : $lang['OFF'];
$stat = '[&nbsp; ' . $lang['EXECUTION_TIME'] . " $gen_time_txt " . $lang['SEC']; $stat = '[&nbsp; ' . $lang['EXECUTION_TIME'] . " $gen_time_txt " . $lang['SEC'];
@ -51,7 +51,7 @@ if ($show_dbg_info) {
$stat .= " &nbsp;|&nbsp; $gzip_text"; $stat .= " &nbsp;|&nbsp; $gzip_text";
$stat .= ' &nbsp;|&nbsp; ' . $lang['MEMORY']; $stat .= ' &nbsp;|&nbsp; ' . $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_peak'), 2) . ' / ';
$stat .= humn_size(sys('mem'), 2); $stat .= humn_size(sys('mem'), 2);
@ -83,7 +83,7 @@ echo '
if (defined('REQUESTED_PAGE') && !defined('DISABLE_CACHING_OUTPUT')) { if (defined('REQUESTED_PAGE') && !defined('DISABLE_CACHING_OUTPUT')) {
if (IS_GUEST === true) { 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'));
} }
} }

View file

@ -16,7 +16,7 @@ if (defined('PAGE_HEADER_SENT')) {
} }
// Parse and show the overall page header // 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']); $logged_in = (int)!empty($userdata['session_logged_in']);
@ -52,7 +52,7 @@ if (defined('SHOW_ONLINE') && SHOW_ONLINE) {
'TOTAL_USERS_ONLINE' => ${$online_list}['stat'], 'TOTAL_USERS_ONLINE' => ${$online_list}['stat'],
'LOGGED_IN_USER_LIST' => ${$online_list}['userlist'], 'LOGGED_IN_USER_LIST' => ${$online_list}['userlist'],
'USERS_ONLINE_COUNTS' => ${$online_list}['cnt'], '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), 'USER_OPTIONS_JS' => IS_GUEST ? '{}' : json_encode($user->opt_js, JSON_THROW_ON_ERROR),
'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']), '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'])) : '', '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', '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_GUEST' => IS_GUEST,
'IS_USER' => IS_USER, 'IS_USER' => IS_USER,
@ -138,9 +138,9 @@ $template->assign_vars([
'FORUM_PATH' => FORUM_PATH, 'FORUM_PATH' => FORUM_PATH,
'FULL_URL' => FULL_URL, 'FULL_URL' => FULL_URL,
'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, $bb_cfg['last_visit_date_format'], false)), '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)$bb_cfg['board_timezone'])])), 'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', (float)config()->get('board_timezone'))])),
'BOARD_TIMEZONE' => $bb_cfg['board_timezone'], 'BOARD_TIMEZONE' => config()->get('board_timezone'),
'PM_INFO' => $pm_info, 'PM_INFO' => $pm_info,
'PRIVMSG_IMG' => $icon_pm, 'PRIVMSG_IMG' => $icon_pm,
@ -151,7 +151,7 @@ $template->assign_vars([
'THIS_USER' => profile_url($userdata), 'THIS_USER' => profile_url($userdata),
'THIS_AVATAR' => get_avatar($userdata['user_id'], $userdata['avatar_ext_id'], !bf($userdata['user_opt'], 'user_opt', 'dis_avatar')), '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'), 'SHOW_LOGIN_LINK' => !defined('IN_LOGIN'),
'AUTOLOGIN_DISABLED' => !$bb_cfg['allow_autologin'], 'AUTOLOGIN_DISABLED' => !config()->get('allow_autologin'),
'S_LOGIN_ACTION' => LOGIN_URL, 'S_LOGIN_ACTION' => LOGIN_URL,
'U_CUR_DOWNLOADS' => PROFILE_URL . $userdata['user_id'], 'U_CUR_DOWNLOADS' => PROFILE_URL . $userdata['user_id'],
@ -167,11 +167,11 @@ $template->assign_vars([
'U_REGISTER' => 'profile.php?mode=register', 'U_REGISTER' => 'profile.php?mode=register',
'U_SEARCH' => 'search.php', 'U_SEARCH' => 'search.php',
'U_SEND_PASSWORD' => "profile.php?mode=sendpassword", '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', 'U_TRACKER' => 'tracker.php',
'SHOW_SIDEBAR1' => !empty($bb_cfg['page']['show_sidebar1'][BB_SCRIPT]) || $bb_cfg['show_sidebar1_on_every_page'], 'SHOW_SIDEBAR1' => !empty(config()->get('page.show_sidebar1')[BB_SCRIPT]) || config()->get('show_sidebar1_on_every_page'),
'SHOW_SIDEBAR2' => !empty($bb_cfg['page']['show_sidebar2'][BB_SCRIPT]) || $bb_cfg['show_sidebar2_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_AGREEMENT' => LANG_DIR . 'html/user_agreement.html',
'HTML_COPYRIGHT' => LANG_DIR . 'html/copyright_holders.html', 'HTML_COPYRIGHT' => LANG_DIR . 'html/copyright_holders.html',
@ -185,11 +185,11 @@ $template->assign_vars([
'DOWNLOAD_URL' => BB_ROOT . DL_URL, 'DOWNLOAD_URL' => BB_ROOT . DL_URL,
'FORUM_URL' => BB_ROOT . FORUM_URL, 'FORUM_URL' => BB_ROOT . FORUM_URL,
'GROUP_URL' => BB_ROOT . GROUP_URL, 'GROUP_URL' => BB_ROOT . GROUP_URL,
'LOGIN_URL' => $bb_cfg['login_url'], 'LOGIN_URL' => config()->get('login_url'),
'NEWEST_URL' => '&amp;view=newest#newest', 'NEWEST_URL' => '&amp;view=newest#newest',
'PM_URL' => $bb_cfg['pm_url'], 'PM_URL' => config()->get('pm_url'),
'POST_URL' => BB_ROOT . POST_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, 'PROFILE_URL' => BB_ROOT . PROFILE_URL,
'BONUS_URL' => BB_ROOT . BONUS_URL, 'BONUS_URL' => BB_ROOT . BONUS_URL,
'TOPIC_URL' => BB_ROOT . TOPIC_URL, 'TOPIC_URL' => BB_ROOT . TOPIC_URL,
@ -208,7 +208,7 @@ $template->assign_vars([
'U_WATCHED_TOPICS' => 'profile.php?mode=watch' '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; $ignore_time = !empty($_COOKIE['torhelp']) ? (int)$_COOKIE['torhelp'] : 0;
if (TIMENOW > $ignore_time) { if (TIMENOW > $ignore_time) {
@ -249,6 +249,6 @@ $template->pparse('page_header');
define('PAGE_HEADER_SENT', true); define('PAGE_HEADER_SENT', true);
if (!$bb_cfg['gzip_compress']) { if (!config()->get('gzip_compress')) {
flush(); flush();
} }

View file

@ -21,12 +21,12 @@ $dl_users_div_style_overflow = "padding: 6px; height: $dl_users_overflow_div_hei
$template->assign_vars(['DL_BUTTONS' => false]); $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']); $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 && !($bb_cfg['bt_dl_list_only_1st_page'] && $start)); $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 && ($bb_cfg['bt_show_dl_list'] || ($bb_cfg['allow_dl_list_names_mode'] && @$_GET['dl'] === 'names'))); $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 && $bb_cfg['bt_show_dl_list_buttons']); $show_dl_buttons = (!IS_GUEST && $dl_topic && config()->get('bt_show_dl_list_buttons'));
// link to clear DL-List // link to clear DL-List
$template->assign_vars(['S_DL_DELETE' => false]); $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', []); $template->assign_block_vars('dl_list_none', []);
} }
} }
@ -107,10 +107,10 @@ if ($show_dl_list) {
if ($show_dl_buttons) { if ($show_dl_buttons) {
$template->assign_vars([ $template->assign_vars([
'DL_BUTTONS' => true, 'DL_BUTTONS' => true,
'DL_BUT_WILL' => $bb_cfg['bt_show_dl_but_will'], 'DL_BUT_WILL' => config()->get('bt_show_dl_but_will'),
'DL_BUT_DOWN' => $bb_cfg['bt_show_dl_but_down'], 'DL_BUT_DOWN' => config()->get('bt_show_dl_but_down'),
'DL_BUT_COMPL' => $bb_cfg['bt_show_dl_but_compl'], 'DL_BUT_COMPL' => config()->get('bt_show_dl_but_compl'),
'DL_BUT_CANCEL' => $bb_cfg['bt_show_dl_but_cancel'] 'DL_BUT_CANCEL' => config()->get('bt_show_dl_but_cancel')
]); ]);
$dl_hidden_fields = ' $dl_hidden_fields = '

View file

@ -14,9 +14,9 @@ if (!defined('BB_ROOT')) {
$user_id = $userdata['user_id']; $user_id = $userdata['user_id'];
$user_points = $userdata['user_points']; $user_points = $userdata['user_points'];
if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['bonus_upload'] && $bb_cfg['bonus_upload_price']) { if (config()->get('seed_bonus_enabled') && config()->get('bonus_upload') && config()->get('bonus_upload_price')) {
$upload_row = unserialize($bb_cfg['bonus_upload']); $upload_row = unserialize(config()->get('bonus_upload'));
$price_row = unserialize($bb_cfg['bonus_upload_price']); $price_row = unserialize(config()->get('bonus_upload_price'));
} else { } else {
bb_die($lang['EXCHANGE_NOT']); bb_die($lang['EXCHANGE_NOT']);
} }

View file

@ -12,7 +12,7 @@ if (!defined('BB_ROOT')) {
} }
// Is send through board enabled? No, return to index // Is send through board enabled? No, return to index
if (!$bb_cfg['board_email_form']) { if (!config()->get('board_email_form')) {
redirect('index.php'); redirect('index.php');
} }

View file

@ -16,7 +16,7 @@ array_deep($_POST, 'trim');
set_die_append_msg(); set_die_append_msg();
if (IS_ADMIN) { if (IS_ADMIN) {
$bb_cfg['reg_email_activation'] = false; config()->set('reg_email_activation', false);
$new_user = (int)request_var('admin', ''); $new_user = (int)request_var('admin', '');
if ($new_user) { if ($new_user) {
@ -50,17 +50,17 @@ switch ($mode) {
if (!IS_ADMIN) { if (!IS_ADMIN) {
// IP limit // IP limit
if ($bb_cfg['unique_ip']) { if (config()->get('unique_ip')) {
if ($users = DB()->fetch_row("SELECT user_id, username FROM " . BB_USERS . " WHERE user_reg_ip = '" . USER_IP . "' LIMIT 1")) { if ($users = DB()->fetch_row("SELECT user_id, username FROM " . BB_USERS . " WHERE user_reg_ip = '" . USER_IP . "' LIMIT 1")) {
bb_die(sprintf($lang['ALREADY_REG_IP'], '<a href="' . PROFILE_URL . $users['user_id'] . '"><b>' . $users['username'] . '</b></a>', $bb_cfg['tech_admin_email'])); bb_die(sprintf($lang['ALREADY_REG_IP'], '<a href="' . PROFILE_URL . $users['user_id'] . '"><b>' . $users['username'] . '</b></a>', config()->get('tech_admin_email')));
} }
} }
// Disabling registration // Disabling registration
if ($bb_cfg['new_user_reg_disabled'] || ($bb_cfg['reg_email_activation'] && !$bb_cfg['emailer']['enabled'])) { if (config()->get('new_user_reg_disabled') || (config()->get('reg_email_activation') && !config()->get('emailer.enabled'))) {
bb_die($lang['NEW_USER_REG_DISABLED']); bb_die($lang['NEW_USER_REG_DISABLED']);
} // Time limit } // Time limit
elseif ($bb_cfg['new_user_reg_restricted']) { elseif (config()->get('new_user_reg_restricted')) {
if (in_array(date('G'), $bb_cfg['new_user_reg_interval'], true)) { if (in_array(date('G'), config()->get('new_user_reg_interval'), true)) {
bb_die($lang['REGISTERED_IN_TIME']); bb_die($lang['REGISTERED_IN_TIME']);
} }
} }
@ -83,8 +83,8 @@ switch ($mode) {
'user_password' => '', 'user_password' => '',
'user_email' => '', 'user_email' => '',
'invite_code' => '', 'invite_code' => '',
'user_timezone' => $bb_cfg['board_timezone'], 'user_timezone' => config()->get('board_timezone'),
'user_lang' => $bb_cfg['default_lang'], 'user_lang' => config()->get('default_lang'),
'user_opt' => 0, 'user_opt' => 0,
'avatar_ext_id' => 0 'avatar_ext_id' => 0
]; ];
@ -101,13 +101,13 @@ switch ($mode) {
// field => can_edit // field => can_edit
$profile_fields = [ $profile_fields = [
'user_active' => IS_ADMIN, 'user_active' => IS_ADMIN,
'username' => (IS_ADMIN || $bb_cfg['allow_namechange']) && !IN_DEMO_MODE, 'username' => (IS_ADMIN || config()->get('allow_namechange')) && !IN_DEMO_MODE,
'user_password' => !IN_DEMO_MODE, 'user_password' => !IN_DEMO_MODE,
'user_email' => !IN_DEMO_MODE, // should be after user_password 'user_email' => !IN_DEMO_MODE, // should be after user_password
'user_lang' => $bb_cfg['allow_change']['language'], 'user_lang' => config()->get('allow_change.language'),
'user_gender' => $bb_cfg['gender'], 'user_gender' => config()->get('gender'),
'user_birthday' => $bb_cfg['birthday_enabled'], 'user_birthday' => config()->get('birthday_enabled'),
'user_timezone' => $bb_cfg['allow_change']['timezone'], 'user_timezone' => config()->get('allow_change.timezone'),
'user_opt' => true, 'user_opt' => true,
'avatar_ext_id' => true, 'avatar_ext_id' => true,
'user_icq' => true, 'user_icq' => true,
@ -152,7 +152,7 @@ switch ($mode) {
} }
// Captcha // Captcha
$need_captcha = ($mode == 'register' && !IS_ADMIN && !$bb_cfg['captcha']['disabled']); $need_captcha = ($mode == 'register' && !IS_ADMIN && !config()->get('captcha.disabled'));
if ($submit) { if ($submit) {
if ($need_captcha && !bb_captcha('check')) { if ($need_captcha && !bb_captcha('check')) {
@ -203,12 +203,13 @@ foreach ($profile_fields as $field => $can_edit) {
* Invite code (reg) * Invite code (reg)
*/ */
case 'invite_code': case 'invite_code':
if ($bb_cfg['invites_system']['enabled']) { if (config()->get('invites_system.enabled')) {
$invite_code = $_POST['invite_code'] ?? ''; $invite_code = $_POST['invite_code'] ?? '';
if ($submit) { if ($submit) {
if (isset($bb_cfg['invites_system']['codes'][$invite_code])) { $inviteCodes = config()->get('invites_system.codes');
if ($bb_cfg['invites_system']['codes'][$invite_code] !== 'permanent') { if (isset($inviteCodes[$invite_code])) {
if (TIMENOW > strtotime($bb_cfg['invites_system']['codes'][$invite_code])) { if ($inviteCodes[$invite_code] !== 'permanent') {
if (TIMENOW > strtotime($inviteCodes[$invite_code])) {
$errors[] = $lang['INVITE_EXPIRED']; $errors[] = $lang['INVITE_EXPIRED'];
} }
} }
@ -264,7 +265,7 @@ foreach ($profile_fields as $field => $can_edit) {
} }
$db_data['user_email'] = $email; $db_data['user_email'] = $email;
} elseif ($email != $pr_data['user_email']) { } elseif ($email != $pr_data['user_email']) {
if ($bb_cfg['email_change_disabled'] && !$adm_edit && !IS_ADMIN) { if (config()->get('email_change_disabled') && !$adm_edit && !IS_ADMIN) {
$errors[] = $lang['EMAIL_CHANGING_DISABLED']; $errors[] = $lang['EMAIL_CHANGING_DISABLED'];
} }
if (!$cur_pass_valid) { if (!$cur_pass_valid) {
@ -273,7 +274,7 @@ foreach ($profile_fields as $field => $can_edit) {
if (!$errors and $err = \TorrentPier\Validate::email($email)) { if (!$errors and $err = \TorrentPier\Validate::email($email)) {
$errors[] = $err; $errors[] = $err;
} }
if ($bb_cfg['reg_email_activation']) { if (config()->get('reg_email_activation')) {
$pr_data['user_active'] = 0; $pr_data['user_active'] = 0;
$db_data['user_active'] = 0; $db_data['user_active'] = 0;
} }
@ -336,10 +337,10 @@ foreach ($profile_fields as $field => $can_edit) {
if (!empty($birthday_date['year'])) { if (!empty($birthday_date['year'])) {
if (strtotime($user_birthday) >= TIMENOW) { if (strtotime($user_birthday) >= TIMENOW) {
$errors[] = $lang['WRONG_BIRTHDAY_FORMAT']; $errors[] = $lang['WRONG_BIRTHDAY_FORMAT'];
} elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > $bb_cfg['birthday_max_age']) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > config()->get('birthday_max_age')) {
$errors[] = sprintf($lang['BIRTHDAY_TO_HIGH'], $bb_cfg['birthday_max_age']); $errors[] = sprintf($lang['BIRTHDAY_TO_HIGH'], config()->get('birthday_max_age'));
} elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < $bb_cfg['birthday_min_age']) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < config()->get('birthday_min_age')) {
$errors[] = sprintf($lang['BIRTHDAY_TO_LOW'], $bb_cfg['birthday_min_age']); $errors[] = sprintf($lang['BIRTHDAY_TO_LOW'], config()->get('birthday_min_age'));
} }
} }
@ -357,16 +358,16 @@ foreach ($profile_fields as $field => $can_edit) {
$update_user_opt = [ $update_user_opt = [
# 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change # 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change
'user_viewemail' => $reg_mode ? false : (IS_ADMIN || $bb_cfg['show_email_visibility_settings']), 'user_viewemail' => $reg_mode ? false : (IS_ADMIN || config()->get('show_email_visibility_settings')),
'user_viewonline' => $reg_mode ? false : true, 'user_viewonline' => $reg_mode ? false : true,
'user_notify' => $reg_mode ? true : true, 'user_notify' => $reg_mode ? true : true,
'user_notify_pm' => $reg_mode ? true : $bb_cfg['pm_notify_enabled'], 'user_notify_pm' => $reg_mode ? true : config()->get('pm_notify_enabled'),
'user_porn_forums' => $reg_mode ? false : true, 'user_porn_forums' => $reg_mode ? false : true,
'user_dls' => $reg_mode ? false : true, 'user_dls' => $reg_mode ? false : true,
'user_callseed' => $reg_mode ? true : true, 'user_callseed' => $reg_mode ? true : true,
'user_retracker' => $reg_mode ? true : true, 'user_retracker' => $reg_mode ? true : true,
'user_hide_torrent_client' => $reg_mode ? true : true, 'user_hide_torrent_client' => $reg_mode ? true : true,
'user_hide_peer_country' => $reg_mode ? true : $bb_cfg['ip2country_settings']['enabled'], 'user_hide_peer_country' => $reg_mode ? true : config()->get('ip2country_settings.enabled'),
'user_hide_peer_username' => $reg_mode ? false : true, 'user_hide_peer_username' => $reg_mode ? false : true,
]; ];
@ -390,7 +391,7 @@ foreach ($profile_fields as $field => $can_edit) {
if ($submit && !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')) { if ($submit && !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')) {
// Integration with MonsterID // Integration with MonsterID
if (empty($_FILES['avatar']['name']) && !isset($_POST['delete_avatar']) && isset($_POST['use_monster_avatar'])) { if (empty($_FILES['avatar']['name']) && !isset($_POST['delete_avatar']) && isset($_POST['use_monster_avatar'])) {
$monsterAvatar = new Arokettu\MonsterID\Monster($pr_data['user_email'], $bb_cfg['avatars']['max_height']); $monsterAvatar = new Arokettu\MonsterID\Monster($pr_data['user_email'], config()->get('avatars.max_height'));
$tempAvatar = tmpfile(); $tempAvatar = tmpfile();
$tempAvatarPath = stream_get_meta_data($tempAvatar)['uri']; $tempAvatarPath = stream_get_meta_data($tempAvatar)['uri'];
$monsterAvatar->writeToStream($tempAvatar); $monsterAvatar->writeToStream($tempAvatar);
@ -412,10 +413,10 @@ foreach ($profile_fields as $field => $can_edit) {
delete_avatar($pr_data['user_id'], $pr_data['avatar_ext_id']); delete_avatar($pr_data['user_id'], $pr_data['avatar_ext_id']);
$pr_data['avatar_ext_id'] = 0; $pr_data['avatar_ext_id'] = 0;
$db_data['avatar_ext_id'] = 0; $db_data['avatar_ext_id'] = 0;
} elseif (!empty($_FILES['avatar']['name']) && $bb_cfg['avatars']['up_allowed']) { } elseif (!empty($_FILES['avatar']['name']) && config()->get('avatars.up_allowed')) {
$upload = new TorrentPier\Legacy\Common\Upload(); $upload = new TorrentPier\Legacy\Common\Upload();
if ($upload->init($bb_cfg['avatars'], $_FILES['avatar'], !isset($_POST['use_monster_avatar'])) and $upload->store('avatar', $pr_data)) { if ($upload->init(config()->getSection('avatars'), $_FILES['avatar'], !isset($_POST['use_monster_avatar'])) and $upload->store('avatar', $pr_data)) {
$pr_data['avatar_ext_id'] = $upload->file_ext_id; $pr_data['avatar_ext_id'] = $upload->file_ext_id;
$db_data['avatar_ext_id'] = (int)$upload->file_ext_id; $db_data['avatar_ext_id'] = (int)$upload->file_ext_id;
} else { } else {
@ -423,7 +424,7 @@ foreach ($profile_fields as $field => $can_edit) {
} }
} }
} }
$tp_data['AVATARS_MAX_SIZE'] = humn_size($bb_cfg['avatars']['max_size']); $tp_data['AVATARS_MAX_SIZE'] = humn_size(config()->get('avatars.max_size'));
break; break;
/** /**
@ -484,7 +485,7 @@ foreach ($profile_fields as $field => $can_edit) {
if ($submit && $sig != $pr_data['user_sig']) { if ($submit && $sig != $pr_data['user_sig']) {
$sig = prepare_message($sig); $sig = prepare_message($sig);
if (mb_strlen($sig, DEFAULT_CHARSET) > $bb_cfg['max_sig_chars']) { if (mb_strlen($sig, DEFAULT_CHARSET) > config()->get('max_sig_chars')) {
$errors[] = $lang['SIGNATURE_TOO_LONG']; $errors[] = $lang['SIGNATURE_TOO_LONG'];
} elseif (preg_match('#<(a|b|i|u|table|tr|td|img) #i', $sig) || preg_match('#(href|src|target|title)=#i', $sig)) { } elseif (preg_match('#<(a|b|i|u|table|tr|td|img) #i', $sig) || preg_match('#(href|src|target|title)=#i', $sig)) {
$errors[] = $lang['SIGNATURE_ERROR_HTML']; $errors[] = $lang['SIGNATURE_ERROR_HTML'];
@ -559,9 +560,10 @@ foreach ($profile_fields as $field => $can_edit) {
$templates = isset($_POST['tpl_name']) ? (string)$_POST['tpl_name'] : $pr_data['tpl_name']; $templates = isset($_POST['tpl_name']) ? (string)$_POST['tpl_name'] : $pr_data['tpl_name'];
$templates = htmlCHR($templates); $templates = htmlCHR($templates);
if ($submit && $templates != $pr_data['tpl_name']) { if ($submit && $templates != $pr_data['tpl_name']) {
$pr_data['tpl_name'] = $bb_cfg['tpl_name']; $pr_data['tpl_name'] = config()->get('tpl_name');
$db_data['tpl_name'] = (string)$bb_cfg['tpl_name']; $db_data['tpl_name'] = (string)config()->get('tpl_name');
foreach ($bb_cfg['templates'] as $folder => $name) { $availableTemplates = config()->get('templates');
foreach ($availableTemplates as $folder => $name) {
if ($templates == $folder) { if ($templates == $folder) {
$pr_data['tpl_name'] = $templates; $pr_data['tpl_name'] = $templates;
$db_data['tpl_name'] = (string)$templates; $db_data['tpl_name'] = (string)$templates;
@ -585,7 +587,7 @@ if ($submit && !$errors) {
* Создание нового профиля * Создание нового профиля
*/ */
if ($mode == 'register') { if ($mode == 'register') {
if ($bb_cfg['reg_email_activation']) { if (config()->get('reg_email_activation')) {
$user_actkey = make_rand_str(ACTKEY_LENGTH); $user_actkey = make_rand_str(ACTKEY_LENGTH);
$db_data['user_active'] = 0; $db_data['user_active'] = 0;
$db_data['user_actkey'] = $user_actkey; $db_data['user_actkey'] = $user_actkey;
@ -600,7 +602,7 @@ if ($submit && !$errors) {
} }
if (!isset($db_data['tpl_name'])) { if (!isset($db_data['tpl_name'])) {
$db_data['tpl_name'] = (string)$bb_cfg['tpl_name']; $db_data['tpl_name'] = (string)config()->get('tpl_name');
} }
$sql_args = DB()->build_array('INSERT', $db_data); $sql_args = DB()->build_array('INSERT', $db_data);
@ -622,13 +624,13 @@ if ($submit && !$errors) {
set_pr_die_append_msg($new_user_id); set_pr_die_append_msg($new_user_id);
$message = $lang['ACCOUNT_ADDED']; $message = $lang['ACCOUNT_ADDED'];
} else { } else {
if ($bb_cfg['reg_email_activation']) { if (config()->get('reg_email_activation')) {
$message = $lang['ACCOUNT_INACTIVE']; $message = $lang['ACCOUNT_INACTIVE'];
$email_subject = sprintf($lang['EMAILER_SUBJECT']['USER_WELCOME_INACTIVE'], $bb_cfg['sitename']); $email_subject = sprintf($lang['EMAILER_SUBJECT']['USER_WELCOME_INACTIVE'], config()->get('sitename'));
$email_template = 'user_welcome_inactive'; $email_template = 'user_welcome_inactive';
} else { } else {
$message = $lang['ACCOUNT_ADDED']; $message = $lang['ACCOUNT_ADDED'];
$email_subject = sprintf($lang['EMAILER_SUBJECT']['USER_WELCOME'], $bb_cfg['sitename']); $email_subject = sprintf($lang['EMAILER_SUBJECT']['USER_WELCOME'], config()->get('sitename'));
$email_template = 'user_welcome'; $email_template = 'user_welcome';
} }
@ -640,7 +642,7 @@ if ($submit && !$errors) {
$emailer->set_template($email_template, $user_lang); $emailer->set_template($email_template, $user_lang);
$emailer->assign_vars([ $emailer->assign_vars([
'WELCOME_MSG' => sprintf($lang['WELCOME_SUBJECT'], $bb_cfg['sitename']), 'WELCOME_MSG' => sprintf($lang['WELCOME_SUBJECT'], config()->get('sitename')),
'USERNAME' => html_entity_decode($username), 'USERNAME' => html_entity_decode($username),
'PASSWORD' => $new_pass, 'PASSWORD' => $new_pass,
'U_ACTIVATE' => make_url('profile.php?mode=activate&' . POST_USERS_URL . '=' . $new_user_id . '&act_key=' . $db_data['user_actkey']) 'U_ACTIVATE' => make_url('profile.php?mode=activate&' . POST_USERS_URL . '=' . $new_user_id . '&act_key=' . $db_data['user_actkey'])
@ -728,12 +730,12 @@ $template->assign_vars([
'LANGUAGE_SELECT' => \TorrentPier\Legacy\Common\Select::language($pr_data['user_lang'], 'user_lang'), 'LANGUAGE_SELECT' => \TorrentPier\Legacy\Common\Select::language($pr_data['user_lang'], 'user_lang'),
'TIMEZONE_SELECT' => \TorrentPier\Legacy\Common\Select::timezone($pr_data['user_timezone'], 'user_timezone'), 'TIMEZONE_SELECT' => \TorrentPier\Legacy\Common\Select::timezone($pr_data['user_timezone'], 'user_timezone'),
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['avatars']['max_width'], $bb_cfg['avatars']['max_height'], humn_size($bb_cfg['avatars']['max_size'])), 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], config()->get('avatars.max_width'), config()->get('avatars.max_height'), humn_size(config()->get('avatars.max_size'))),
'AVATAR_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'), 'AVATAR_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'),
'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], $bb_cfg['terms_and_conditions_url']), 'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], config()->get('terms_and_conditions_url')),
'AVATAR_IMG' => get_avatar($pr_data['user_id'], $pr_data['avatar_ext_id'], !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')), 'AVATAR_IMG' => get_avatar($pr_data['user_id'], $pr_data['avatar_ext_id'], !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')),
'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], $bb_cfg['max_sig_chars']), 'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], config()->get('max_sig_chars')),
'SIG_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_sig'), 'SIG_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_sig'),
'PR_USER_ID' => $pr_data['user_id'], 'PR_USER_ID' => $pr_data['user_id'],

View file

@ -13,11 +13,11 @@ if (!defined('BB_ROOT')) {
set_die_append_msg(); set_die_append_msg();
if (!$bb_cfg['emailer']['enabled']) { if (!config()->get('emailer.enabled')) {
bb_die($lang['EMAILER_DISABLED']); bb_die($lang['EMAILER_DISABLED']);
} }
$need_captcha = ($_GET['mode'] == 'sendpassword' && !IS_ADMIN && !$bb_cfg['captcha']['disabled']); $need_captcha = ($_GET['mode'] == 'sendpassword' && !IS_ADMIN && !config()->get('captcha.disabled'));
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
if ($need_captcha && !bb_captcha('check')) { if ($need_captcha && !bb_captcha('check')) {

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
if (!$bb_cfg['topic_notify_enabled']) { if (!config()->get('topic_notify_enabled')) {
bb_die($lang['DISABLED']); bb_die($lang['DISABLED']);
} }
@ -35,7 +35,7 @@ if (isset($_GET[POST_USERS_URL])) {
} }
} }
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0; $start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
$per_page = $bb_cfg['topics_per_page']; $per_page = config()->get('topics_per_page');
if (isset($_POST['topic_id_list'])) { if (isset($_POST['topic_id_list'])) {
$topic_ids = implode(",", $_POST['topic_id_list']); $topic_ids = implode(",", $_POST['topic_id_list']);
@ -96,7 +96,7 @@ if ($watch_count > 0) {
'IS_UNREAD' => $is_unread, 'IS_UNREAD' => $is_unread,
'POLL' => (bool)$watch[$i]['topic_vote'], 'POLL' => (bool)$watch[$i]['topic_vote'],
'TOPIC_ICON' => get_topic_icon($watch[$i], $is_unread), 'TOPIC_ICON' => get_topic_icon($watch[$i], $is_unread),
'PAGINATION' => ($watch[$i]['topic_status'] == TOPIC_MOVED) ? '' : build_topic_pagination(TOPIC_URL . $watch[$i]['topic_id'], $watch[$i]['topic_replies'], $bb_cfg['posts_per_page']) 'PAGINATION' => ($watch[$i]['topic_status'] == TOPIC_MOVED) ? '' : build_topic_pagination(TOPIC_URL . $watch[$i]['topic_id'], $watch[$i]['topic_replies'], config()->get('posts_per_page'))
]); ]);
} }

View file

@ -50,7 +50,7 @@ if (IS_ADMIN) {
} }
if (bf($profiledata['user_opt'], 'user_opt', 'user_viewemail') || $profiledata['user_id'] == $userdata['user_id'] || IS_ADMIN) { if (bf($profiledata['user_opt'], 'user_opt', 'user_viewemail') || $profiledata['user_id'] == $userdata['user_id'] || IS_ADMIN) {
$email_uri = ($bb_cfg['board_email_form']) ? 'profile.php?mode=email&amp;' . POST_USERS_URL . '=' . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email']; $email_uri = (config()->get('board_email_form')) ? 'profile.php?mode=email&amp;' . POST_USERS_URL . '=' . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email'];
$email = '<a class="editable" href="' . $email_uri . '">' . $profiledata['user_email'] . '</a>'; $email = '<a class="editable" href="' . $email_uri . '">' . $profiledata['user_email'] . '</a>';
} else { } else {
$email = ''; $email = '';
@ -62,7 +62,7 @@ if (bf($profiledata['user_opt'], 'user_opt', 'user_viewemail') || $profiledata['
$profile_user_id = ($profiledata['user_id'] == $userdata['user_id']); $profile_user_id = ($profiledata['user_id'] == $userdata['user_id']);
$signature = ($bb_cfg['allow_sig'] && $profiledata['user_sig']) ? $profiledata['user_sig'] : ''; $signature = (config()->get('allow_sig') && $profiledata['user_sig']) ? $profiledata['user_sig'] : '';
if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) { if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
if ($profile_user_id) { if ($profile_user_id) {
@ -75,7 +75,7 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
} }
// Null ratio // Null ratio
if ($bb_cfg['ratio_null_enabled'] && $btu = get_bt_userdata($profiledata['user_id'])) { if (config()->get('ratio_null_enabled') && $btu = get_bt_userdata($profiledata['user_id'])) {
$template->assign_vars(['NULLED_RATIO' => $btu['ratio_nulled']]); $template->assign_vars(['NULLED_RATIO' => $btu['ratio_nulled']]);
} }
@ -110,10 +110,10 @@ $template->assign_vars([
'SKYPE' => $profiledata['user_skype'], 'SKYPE' => $profiledata['user_skype'],
'TWITTER' => $profiledata['user_twitter'], 'TWITTER' => $profiledata['user_twitter'],
'USER_POINTS' => $profiledata['user_points'], 'USER_POINTS' => $profiledata['user_points'],
'GENDER' => $bb_cfg['gender'] ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', 'GENDER' => config()->get('gender') ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '',
'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? $profiledata['user_birthday'] : '', 'BIRTHDAY' => (config()->get('birthday_enabled') && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? $profiledata['user_birthday'] : '',
'BIRTHDAY_ICON' => user_birthday_icon($profiledata['user_birthday'], $profiledata['user_id']), 'BIRTHDAY_ICON' => user_birthday_icon($profiledata['user_birthday'], $profiledata['user_id']),
'AGE' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? birthday_age($profiledata['user_birthday']) : '', 'AGE' => (config()->get('birthday_enabled') && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? birthday_age($profiledata['user_birthday']) : '',
'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
'L_MY_PROFILE' => sprintf($lang['VIEWING_MY_PROFILE'], 'profile.php?mode=editprofile'), 'L_MY_PROFILE' => sprintf($lang['VIEWING_MY_PROFILE'], 'profile.php?mode=editprofile'),

View file

@ -7,5 +7,5 @@
<li>style/templates/default/page_footer.tpl</li> <li>style/templates/default/page_footer.tpl</li>
</ul> </ul>
<br /> <br />
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.
</div> </div>

View file

@ -63,7 +63,7 @@ $login_password = $_POST['login_password'] ?? '';
$need_captcha = false; $need_captcha = false;
if (!$mod_admin_login) { if (!$mod_admin_login) {
$need_captcha = CACHE('bb_login_err')->get('l_err_' . USER_IP); $need_captcha = CACHE('bb_login_err')->get('l_err_' . USER_IP);
if ($need_captcha < $bb_cfg['invalid_logins']) { if ($need_captcha < config()->get('invalid_logins')) {
$need_captcha = false; $need_captcha = false;
} }
} }
@ -80,13 +80,13 @@ if (isset($_POST['login'])) {
} }
// Captcha // Captcha
if ($need_captcha && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) { if ($need_captcha && !config()->get('captcha.disabled') && !bb_captcha('check')) {
$login_errors[] = $lang['CAPTCHA_WRONG']; $login_errors[] = $lang['CAPTCHA_WRONG'];
} }
if (!$login_errors) { if (!$login_errors) {
if ($user->login($_POST, $mod_admin_login)) { if ($user->login($_POST, $mod_admin_login)) {
$redirect_url = (defined('FIRST_LOGON')) ? $bb_cfg['first_logon_redirect_url'] : $redirect_url; $redirect_url = (defined('FIRST_LOGON')) ? config()->get('first_logon_redirect_url') : $redirect_url;
// Reset when entering the correct login/password combination // Reset when entering the correct login/password combination
CACHE('bb_login_err')->rm('l_err_' . USER_IP); CACHE('bb_login_err')->rm('l_err_' . USER_IP);
@ -101,7 +101,7 @@ if (isset($_POST['login'])) {
if (!$mod_admin_login) { if (!$mod_admin_login) {
$login_err = CACHE('bb_login_err')->get('l_err_' . USER_IP); $login_err = CACHE('bb_login_err')->get('l_err_' . USER_IP);
if ($login_err > $bb_cfg['invalid_logins']) { if ($login_err > config()->get('invalid_logins')) {
$need_captcha = true; $need_captcha = true;
} }
CACHE('bb_login_err')->set('l_err_' . USER_IP, ($login_err + 1), 3600); CACHE('bb_login_err')->set('l_err_' . USER_IP, ($login_err + 1), 3600);
@ -118,7 +118,7 @@ if (IS_GUEST || $mod_admin_login) {
'ERROR_MESSAGE' => implode('<br />', $login_errors), 'ERROR_MESSAGE' => implode('<br />', $login_errors),
'ADMIN_LOGIN' => $mod_admin_login, 'ADMIN_LOGIN' => $mod_admin_login,
'REDIRECT_URL' => htmlCHR($redirect_url), 'REDIRECT_URL' => htmlCHR($redirect_url),
'CAPTCHA_HTML' => ($need_captcha && !$bb_cfg['captcha']['disabled']) ? bb_captcha('get') : '', 'CAPTCHA_HTML' => ($need_captcha && !config()->get('captcha.disabled')) ? bb_captcha('get') : '',
'PAGE_TITLE' => $lang['LOGIN'], 'PAGE_TITLE' => $lang['LOGIN'],
'S_LOGIN_ACTION' => LOGIN_URL 'S_LOGIN_ACTION' => LOGIN_URL
]); ]);

View file

@ -54,26 +54,26 @@ $select_sort_role .= '</select>';
switch ($mode) { switch ($mode) {
case 'username': case 'username':
$order_by = "username $sort_order LIMIT $start, " . $bb_cfg['topics_per_page']; $order_by = "username $sort_order LIMIT $start, " . config()->get('topics_per_page');
break; break;
case 'location': case 'location':
$order_by = "user_from $sort_order LIMIT $start, " . $bb_cfg['topics_per_page']; $order_by = "user_from $sort_order LIMIT $start, " . config()->get('topics_per_page');
break; break;
case 'posts': case 'posts':
$order_by = "user_posts $sort_order LIMIT $start, " . $bb_cfg['topics_per_page']; $order_by = "user_posts $sort_order LIMIT $start, " . config()->get('topics_per_page');
break; break;
case 'email': case 'email':
$order_by = "user_email $sort_order LIMIT $start, " . $bb_cfg['topics_per_page']; $order_by = "user_email $sort_order LIMIT $start, " . config()->get('topics_per_page');
break; break;
case 'website': case 'website':
$order_by = "user_website $sort_order LIMIT $start, " . $bb_cfg['topics_per_page']; $order_by = "user_website $sort_order LIMIT $start, " . config()->get('topics_per_page');
break; break;
case 'topten': case 'topten':
$order_by = "user_posts $sort_order LIMIT 10"; $order_by = "user_posts $sort_order LIMIT 10";
break; break;
case 'joined': case 'joined':
default: default:
$order_by = "user_regdate $sort_order LIMIT $start, " . $bb_cfg['topics_per_page']; $order_by = "user_regdate $sort_order LIMIT $start, " . config()->get('topics_per_page');
break; break;
} }
@ -134,7 +134,7 @@ if ($mode != 'topten') {
} }
if ($total = DB()->sql_fetchrow($result)) { if ($total = DB()->sql_fetchrow($result)) {
$total_members = $total['total']; $total_members = $total['total'];
generate_pagination($paginationurl, $total_members, $bb_cfg['topics_per_page'], $start); generate_pagination($paginationurl, $total_members, config()->get('topics_per_page'), $start);
} }
DB()->sql_freeresult($result); DB()->sql_freeresult($result);
} }

View file

@ -223,16 +223,16 @@ switch ($mode) {
$result = \TorrentPier\Legacy\Admin\Common::topic_delete($req_topics, $forum_id); $result = \TorrentPier\Legacy\Admin\Common::topic_delete($req_topics, $forum_id);
//Обновление кеша новостей на главной //Обновление кеша новостей на главной
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id'])); $news_forums = array_flip(explode(',', config()->get('latest_news_forum_id')));
if (isset($news_forums[$forum_id]) && $bb_cfg['show_latest_news'] && $result) { if (isset($news_forums[$forum_id]) && config()->get('show_latest_news') && $result) {
$datastore->enqueue([ $datastore->enqueue([
'latest_news' 'latest_news'
]); ]);
$datastore->update('latest_news'); $datastore->update('latest_news');
} }
$net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id'])); $net_forums = array_flip(explode(',', config()->get('network_news_forum_id')));
if (isset($net_forums[$forum_id]) && $bb_cfg['show_network_news'] && $result) { if (isset($net_forums[$forum_id]) && config()->get('show_network_news') && $result) {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -258,16 +258,16 @@ switch ($mode) {
$result = \TorrentPier\Legacy\Admin\Common::topic_move($req_topics, $new_forum_id, $forum_id, isset($_POST['move_leave_shadow']), isset($_POST['insert_bot_msg']), $_POST['reason_move_bot']); $result = \TorrentPier\Legacy\Admin\Common::topic_move($req_topics, $new_forum_id, $forum_id, isset($_POST['move_leave_shadow']), isset($_POST['insert_bot_msg']), $_POST['reason_move_bot']);
//Обновление кеша новостей на главной //Обновление кеша новостей на главной
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id'])); $news_forums = array_flip(explode(',', config()->get('latest_news_forum_id')));
if ((isset($news_forums[$forum_id]) || isset($news_forums[$new_forum_id])) && $bb_cfg['show_latest_news'] && $result) { if ((isset($news_forums[$forum_id]) || isset($news_forums[$new_forum_id])) && config()->get('show_latest_news') && $result) {
$datastore->enqueue([ $datastore->enqueue([
'latest_news' 'latest_news'
]); ]);
$datastore->update('latest_news'); $datastore->update('latest_news');
} }
$net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id'])); $net_forums = array_flip(explode(',', config()->get('network_news_forum_id')));
if ((isset($net_forums[$forum_id]) || isset($net_forums[$new_forum_id])) && $bb_cfg['show_network_news'] && $result) { if ((isset($net_forums[$forum_id]) || isset($net_forums[$new_forum_id])) && config()->get('show_network_news') && $result) {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -557,7 +557,7 @@ switch ($mode) {
$poster = $postrow[$i]['username']; $poster = $postrow[$i]['username'];
$poster_rank = $postrow[$i]['user_rank']; $poster_rank = $postrow[$i]['user_rank'];
$post_date = bb_date($postrow[$i]['post_time'], $bb_cfg['post_date_format']); $post_date = bb_date($postrow[$i]['post_time'], config()->get('post_date_format'));
$message = $postrow[$i]['post_text']; $message = $postrow[$i]['post_text'];

View file

@ -11,7 +11,7 @@ define('BB_SCRIPT', 'playback_m3u');
require __DIR__ . '/common.php'; require __DIR__ . '/common.php';
if (!$bb_cfg['torr_server']['enabled']) { if (!config()->get('torr_server.enabled')) {
redirect('index.php'); redirect('index.php');
} }
@ -22,7 +22,7 @@ $validFormats = [
]; ];
// Start session management // Start session management
$user->session_start(['req_login' => $bb_cfg['torr_server']['disable_for_guest']]); $user->session_start(['req_login' => config()->get('torr_server.disable_for_guest')]);
// Disable robots indexing // Disable robots indexing
$page_cfg['allow_robots'] = false; $page_cfg['allow_robots'] = false;

View file

@ -47,8 +47,8 @@ if ($mode != 'poll_vote') {
// Checking the ability to make changes // Checking the ability to make changes
if ($mode == 'poll_delete') { if ($mode == 'poll_delete') {
if ($t_data['topic_time'] < TIMENOW - $bb_cfg['poll_max_days'] * 86400) { if ($t_data['topic_time'] < TIMENOW - config()->get('poll_max_days') * 86400) {
bb_die(sprintf($lang['NEW_POLL_DAYS'], $bb_cfg['poll_max_days'])); bb_die(sprintf($lang['NEW_POLL_DAYS'], config()->get('poll_max_days')));
} }
if (!IS_ADMIN && ($t_data['topic_vote'] != POLL_FINISHED)) { if (!IS_ADMIN && ($t_data['topic_vote'] != POLL_FINISHED)) {
bb_die($lang['CANNOT_DELETE_POLL']); bb_die($lang['CANNOT_DELETE_POLL']);

View file

@ -221,7 +221,7 @@ if (!$is_auth[$is_auth_type]) {
} }
if ($mode == 'new_rel') { if ($mode == 'new_rel') {
if ($tor_status = implode(',', $bb_cfg['tor_cannot_new'])) { if ($tor_status = implode(',', config()->get('tor_cannot_new'))) {
$sql = DB()->fetch_rowset("SELECT t.topic_title, t.topic_id, tor.tor_status $sql = DB()->fetch_rowset("SELECT t.topic_title, t.topic_id, tor.tor_status
FROM " . BB_BT_TORRENTS . " tor, " . BB_TOPICS . " t FROM " . BB_BT_TORRENTS . " tor, " . BB_TOPICS . " t
WHERE poster_id = {$userdata['user_id']} WHERE poster_id = {$userdata['user_id']}
@ -232,7 +232,7 @@ if ($mode == 'new_rel') {
$topics = ''; $topics = '';
foreach ($sql as $row) { foreach ($sql as $row) {
$topics .= $bb_cfg['tor_icons'][$row['tor_status']] . '<a href="' . TOPIC_URL . $row['topic_id'] . '">' . $row['topic_title'] . '</a><div class="spacer_12"></div>'; $topics .= config()->get('tor_icons')[$row['tor_status']] . '<a href="' . TOPIC_URL . $row['topic_id'] . '">' . $row['topic_title'] . '</a><div class="spacer_12"></div>';
} }
if ($topics && !(IS_SUPER_ADMIN && !empty($_REQUEST['edit_tpl']))) { if ($topics && !(IS_SUPER_ADMIN && !empty($_REQUEST['edit_tpl']))) {
bb_die($topics . $lang['UNEXECUTED_RELEASE']); bb_die($topics . $lang['UNEXECUTED_RELEASE']);
@ -243,9 +243,9 @@ if ($mode == 'new_rel') {
} }
// Disallowed release editing with a certain status // Disallowed release editing with a certain status
if (!empty($bb_cfg['tor_cannot_edit']) && $post_info['allow_reg_tracker'] && $post_data['first_post'] && !IS_AM) { if (!empty(config()->get('tor_cannot_edit')) && $post_info['allow_reg_tracker'] && $post_data['first_post'] && !IS_AM) {
if ($tor_status = DB()->fetch_row("SELECT tor_status FROM " . BB_BT_TORRENTS . " WHERE topic_id = $topic_id AND forum_id = $forum_id AND tor_status IN(" . implode(',', $bb_cfg['tor_cannot_edit']) . ") LIMIT 1")) { if ($tor_status = DB()->fetch_row("SELECT tor_status FROM " . BB_BT_TORRENTS . " WHERE topic_id = $topic_id AND forum_id = $forum_id AND tor_status IN(" . implode(',', config()->get('tor_cannot_edit')) . ") LIMIT 1")) {
bb_die($lang['NOT_EDIT_TOR_STATUS'] . ':&nbsp;<span title="' . $lang['TOR_STATUS_NAME'][$tor_status['tor_status']] . '">' . $bb_cfg['tor_icons'][$tor_status['tor_status']] . '&nbsp;' . $lang['TOR_STATUS_NAME'][$tor_status['tor_status']] . '</span>.'); bb_die($lang['NOT_EDIT_TOR_STATUS'] . ':&nbsp;<span title="' . $lang['TOR_STATUS_NAME'][$tor_status['tor_status']] . '">' . config()->get('tor_icons')[$tor_status['tor_status']] . '&nbsp;' . $lang['TOR_STATUS_NAME'][$tor_status['tor_status']] . '</span>.');
} }
} }
@ -281,7 +281,7 @@ if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote'
AND pt.post_id = p.post_id AND pt.post_id = p.post_id
AND p.post_time > $topic_last_read AND p.post_time > $topic_last_read
ORDER BY p.post_time ORDER BY p.post_time
LIMIT " . $bb_cfg['posts_per_page']; LIMIT " . config()->get('posts_per_page');
if ($rowset = DB()->fetch_rowset($sql)) { if ($rowset = DB()->fetch_rowset($sql)) {
$topic_has_new_posts = true; $topic_has_new_posts = true;
@ -291,7 +291,7 @@ if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote'
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'POSTER' => profile_url($row), 'POSTER' => profile_url($row),
'POSTER_NAME_JS' => addslashes($row['username']), 'POSTER_NAME_JS' => addslashes($row['username']),
'POST_DATE' => '<a class="small" href="' . POST_URL . $row['post_id'] . '#' . $row['post_id'] . '" title="' . $lang['POST_LINK'] . '">' . bb_date($row['post_time'], $bb_cfg['post_date_format']) . '</a>', 'POST_DATE' => '<a class="small" href="' . POST_URL . $row['post_id'] . '#' . $row['post_id'] . '" title="' . $lang['POST_LINK'] . '">' . bb_date($row['post_time'], config()->get('post_date_format')) . '</a>',
'MESSAGE' => get_parsed_post($row) 'MESSAGE' => get_parsed_post($row)
]); ]);
} }
@ -374,9 +374,9 @@ if (($delete || $mode == 'delete') && !$confirm) {
set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id); set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id);
} }
if (defined('TORRENT_ATTACH_ID') && $bb_cfg['bt_newtopic_auto_reg'] && !$error_msg) { if (defined('TORRENT_ATTACH_ID') && config()->get('bt_newtopic_auto_reg') && !$error_msg) {
if (!DB()->fetch_row("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE attach_id = " . TORRENT_ATTACH_ID)) { if (!DB()->fetch_row("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE attach_id = " . TORRENT_ATTACH_ID)) {
if ($bb_cfg['premod']) { if (config()->get('premod')) {
// Getting a list of forum ids starting with "parent" // Getting a list of forum ids starting with "parent"
$forum_parent = $forum_id; $forum_parent = $forum_id;
if ($post_info['forum_parent']) { if ($post_info['forum_parent']) {
@ -468,7 +468,7 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) {
$message = '[quote="' . $quote_username . '"][qpost=' . $post_info['post_id'] . ']' . $message . '[/quote]'; $message = '[quote="' . $quote_username . '"][qpost=' . $post_info['post_id'] . ']' . $message . '[/quote]';
// hide user passkey // 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 // hide sid
$message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]#', 'sid', $message); $message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]#', 'sid', $message);
@ -618,7 +618,7 @@ $template->assign_vars([
'U_VIEW_FORUM' => FORUM_URL . $forum_id, 'U_VIEW_FORUM' => FORUM_URL . $forum_id,
'USERNAME' => @$username, 'USERNAME' => @$username,
'CAPTCHA_HTML' => (IS_GUEST && !$bb_cfg['captcha']['disabled']) ? bb_captcha('get') : '', 'CAPTCHA_HTML' => (IS_GUEST && !config()->get('captcha.disabled')) ? bb_captcha('get') : '',
'SUBJECT' => $subject, 'SUBJECT' => $subject,
'MESSAGE' => $message, 'MESSAGE' => $message,

View file

@ -24,7 +24,7 @@ $page_cfg['load_tpl_vars'] = [
// //
// Is PM disabled? // Is PM disabled?
// //
if ($bb_cfg['privmsg_disable']) { if (config()->get('privmsg_disable')) {
bb_die('PM_DISABLED'); bb_die('PM_DISABLED');
} }
@ -59,13 +59,13 @@ $user->session_start(['req_login' => true]);
$template->assign_vars([ $template->assign_vars([
'IN_PM' => true, '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 // 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'; $mode = 'reply';
} }
@ -206,7 +206,7 @@ if ($mode == 'read') {
} }
if ($sent_info = DB()->sql_fetchrow($result)) { 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 . " $sql = "SELECT privmsgs_id FROM " . BB_PRIVMSGS . "
WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . " WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . "
AND privmsgs_date = " . $sent_info['oldest_post_time'] . " AND privmsgs_date = " . $sent_info['oldest_post_time'] . "
@ -604,7 +604,7 @@ if ($mode == 'read') {
} }
if ($saved_info = DB()->sql_fetchrow($result)) { 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 . " $sql = "SELECT privmsgs_id FROM " . BB_PRIVMSGS . "
WHERE ( ( privmsgs_to_userid = " . $userdata['user_id'] . " WHERE ( ( privmsgs_to_userid = " . $userdata['user_id'] . "
AND privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . " ) AND privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . " )
@ -749,7 +749,7 @@ if ($mode == 'read') {
$last_post_time = $db_row['last_post_time']; $last_post_time = $db_row['last_post_time'];
$current_time = TIMENOW; $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']); bb_die($lang['FLOOD_ERROR']);
} }
} }
@ -802,11 +802,11 @@ if ($mode == 'read') {
} }
// Check smilies limit // Check smilies limit
if ($bb_cfg['max_smilies_pm']) { if (config()->get('max_smilies_pm')) {
$count_smilies = substr_count(bbcode2html($privmsg_message), '<img class="smile" src="' . $bb_cfg['smilies_path']); $count_smilies = substr_count(bbcode2html($privmsg_message), '<img class="smile" src="' . config()->get('smilies_path'));
if ($count_smilies > $bb_cfg['max_smilies_pm']) { if ($count_smilies > config()->get('max_smilies_pm')) {
$error = true; $error = true;
$error_msg .= ((!empty($error_msg)) ? '<br />' : '') . sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies_pm']); $error_msg .= ((!empty($error_msg)) ? '<br />' : '') . sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies_pm'));
} }
} }
} }
@ -834,7 +834,7 @@ if ($mode == 'read') {
} }
if ($inbox_info = DB()->sql_fetchrow($result)) { if ($inbox_info = DB()->sql_fetchrow($result)) {
if ($bb_cfg['max_inbox_privmsgs'] && $inbox_info['inbox_items'] >= $bb_cfg['max_inbox_privmsgs']) { if (config()->get('max_inbox_privmsgs') && $inbox_info['inbox_items'] >= config()->get('max_inbox_privmsgs')) {
$sql = "SELECT privmsgs_id FROM " . BB_PRIVMSGS . " $sql = "SELECT privmsgs_id FROM " . BB_PRIVMSGS . "
WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_READ_MAIL . "
@ -902,7 +902,7 @@ if ($mode == 'read') {
\TorrentPier\Sessions::cache_rm_user_sessions($to_userdata['user_id']); \TorrentPier\Sessions::cache_rm_user_sessions($to_userdata['user_id']);
if (bf($to_userdata['user_opt'], 'user_opt', 'user_notify_pm') && $to_userdata['user_active'] && $bb_cfg['pm_notify_enabled']) { if (bf($to_userdata['user_opt'], 'user_opt', 'user_notify_pm') && $to_userdata['user_active'] && config()->get('pm_notify_enabled')) {
// Sending email // Sending email
$emailer = new TorrentPier\Emailer(); $emailer = new TorrentPier\Emailer();
@ -1252,7 +1252,7 @@ if ($mode == 'read') {
$msg_days = 0; $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_all_tot = $sql_tot;
$sql_tot .= $limit_msg_time_total; $sql_tot .= $limit_msg_time_total;
@ -1308,11 +1308,11 @@ if ($mode == 'read') {
// Output data for inbox status // Output data for inbox status
// //
$box_limit_img_length = $box_limit_percent = $l_box_size_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) { if ($max_pm) {
$box_limit_percent = min(round(($pm_all_total / $max_pm) * 100), 100); $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); $box_limit_remain = max(($max_pm - $pm_all_total), 0);
$template->assign_var('PM_BOX_SIZE_INFO'); $template->assign_var('PM_BOX_SIZE_INFO');
@ -1410,7 +1410,7 @@ if ($mode == 'read') {
]); ]);
} while ($row = DB()->sql_fetchrow($result)); } 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 { } else {
$template->assign_block_vars('switch_no_messages', []); $template->assign_block_vars('switch_no_messages', []);
} }

View file

@ -20,7 +20,7 @@ $page_cfg['load_tpl_vars'] = [
]; ];
// Start session management // 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(); set_die_append_msg();
@ -289,7 +289,7 @@ if (empty($_GET) && empty($_POST)) {
'MY_TOPICS_ID' => 'my_topics', 'MY_TOPICS_ID' => 'my_topics',
'MY_TOPICS_CHBOX' => build_checkbox($my_topics_key, $lang['SEARCH_MY_TOPICS'], $my_topics_val, true, null, '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), '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_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'), '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']))); $new_topics = (!IS_GUEST && ($new_topics_val || isset($_GET['newposts'])));
$my_topics = ($poster_id_val && $my_topics_val); $my_topics = ($poster_id_val && $my_topics_val);
$my_posts = ($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) // "Display as" mode (posts or topics)
$post_mode = (!$dl_search && ($display_as_val == $as_posts || isset($_GET['search_author']))); $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) { if ($post_mode) {
$order = $order_opt[$order_val]['sql']; $order = $order_opt[$order_val]['sql'];
$sort = $sort_opt[$sort_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; $display_as_val = $as_posts;
// Run initial search for post_ids // Run initial search for post_ids
@ -593,7 +593,7 @@ if ($post_mode) {
'POSTER_ID' => $post['poster_id'], 'POSTER_ID' => $post['poster_id'],
'POSTER' => profile_url($post), 'POSTER' => profile_url($post),
'POST_ID' => $post['post_id'], '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), 'IS_UNREAD' => is_unread($post['post_time'], $topic_id, $forum_id),
'MESSAGE' => $message, 'MESSAGE' => $message,
'POSTED_AFTER' => '', 'POSTED_AFTER' => '',
@ -612,7 +612,7 @@ if ($post_mode) {
else { else {
$order = $order_opt[$order_val]['sql']; $order = $order_opt[$order_val]['sql'];
$sort = $sort_opt[$sort_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; $display_as_val = $as_topics;
// Run initial search for topic_ids // Run initial search for topic_ids
@ -733,7 +733,7 @@ else {
// Build SQL for displaying topics // Build SQL for displaying topics
$SQL = DB()->get_empty_sql_array(); $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'][] = " $SQL['SELECT'][] = "
t.*, t.topic_poster AS first_user_id, u1.user_rank AS first_user_rank, 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']), 'TOPIC_TITLE' => $wordCensor->censorString($topic['topic_title']),
'IS_UNREAD' => $is_unread, 'IS_UNREAD' => $is_unread,
'TOPIC_ICON' => get_topic_icon($topic, $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'], 'REPLIES' => $moved ? '' : $topic['topic_replies'],
'ATTACH' => $topic['topic_attachment'], 'ATTACH' => $topic['topic_attachment'],
'STATUS' => $topic['topic_status'], 'STATUS' => $topic['topic_status'],
@ -888,15 +888,13 @@ function fetch_search_ids($sql, $search_type = SEARCH_TYPE_POST)
function prevent_huge_searches($SQL) function prevent_huge_searches($SQL)
{ {
global $bb_cfg; if (config()->get('limit_max_search_results')) {
if ($bb_cfg['limit_max_search_results']) {
$SQL['select_options'][] = 'SQL_CALC_FOUND_ROWS'; $SQL['select_options'][] = 'SQL_CALC_FOUND_ROWS';
$SQL['ORDER BY'] = []; $SQL['ORDER BY'] = [];
$SQL['LIMIT'] = array('0'); $SQL['LIMIT'] = array('0');
if (DB()->query($SQL) and $row = DB()->fetch_row("SELECT FOUND_ROWS() AS rows_count")) { 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_log(str_compact(DB()->build_sql($SQL)) ." [{$row['rows_count']} rows]". LOG_LF, 'sql_huge_search');
bb_die('Too_many_search_results'); bb_die('Too_many_search_results');
} }

View file

@ -34,9 +34,9 @@ class Censor
*/ */
public function __construct() public function __construct()
{ {
global $bb_cfg, $datastore; global $datastore;
if (!$bb_cfg['use_word_censor']) { if (!config()->get('use_word_censor')) {
return; return;
} }

View file

@ -67,13 +67,11 @@ class Dev
*/ */
private function getBugsnag(): void private function getBugsnag(): void
{ {
global $bb_cfg; if (!config()->get('bugsnag.enabled')) {
if (!$bb_cfg['bugsnag']['enabled']) {
return; return;
} }
$bugsnag = Client::make($bb_cfg['bugsnag']['api_key']); $bugsnag = Client::make(config()->get('bugsnag.api_key'));
$this->whoops->pushHandler(function ($e) use ($bugsnag) { $this->whoops->pushHandler(function ($e) use ($bugsnag) {
$bugsnag->notifyException($e); $bugsnag->notifyException($e);
}); });
@ -86,9 +84,7 @@ class Dev
*/ */
private function getTelegramSender(): void private function getTelegramSender(): void
{ {
global $bb_cfg; if (!config()->get('telegram_sender.enabled')) {
if (!$bb_cfg['telegram_sender']['enabled']) {
return; return;
} }
@ -96,7 +92,7 @@ class Dev
$telegramSender->loggerOnly(true); $telegramSender->loggerOnly(true);
$telegramSender->setLogger((new Logger( $telegramSender->setLogger((new Logger(
APP_NAME, APP_NAME,
[(new TelegramHandler($bb_cfg['telegram_sender']['token'], (int)$bb_cfg['telegram_sender']['chat_id'], timeout: (int)$bb_cfg['telegram_sender']['timeout'])) [(new TelegramHandler(config()->get('telegram_sender.token'), (int)config()->get('telegram_sender.chat_id'), timeout: (int)config()->get('telegram_sender.timeout')))
->setFormatter(new TelegramFormatter())] ->setFormatter(new TelegramFormatter())]
))); )));
$this->whoops->pushHandler($telegramSender); $this->whoops->pushHandler($telegramSender);
@ -109,13 +105,11 @@ class Dev
*/ */
private function getWhoopsOnPage(): void private function getWhoopsOnPage(): void
{ {
global $bb_cfg;
/** /**
* Show errors on page * Show errors on page
*/ */
$prettyPageHandler = new PrettyPageHandler(); $prettyPageHandler = new PrettyPageHandler();
foreach ($bb_cfg['whoops']['blacklist'] as $key => $secrets) { foreach (config()->get('whoops.blacklist', []) as $key => $secrets) {
foreach ($secrets as $secret) { foreach ($secrets as $secret) {
$prettyPageHandler->blacklist($key, $secret); $prettyPageHandler->blacklist($key, $secret);
} }
@ -163,10 +157,8 @@ class Dev
*/ */
private function getWhoopsPlaceholder(): void private function getWhoopsPlaceholder(): void
{ {
global $bb_cfg; $this->whoops->pushHandler(function ($e) {
echo config()->get('whoops.error_message');
$this->whoops->pushHandler(function ($e) use ($bb_cfg) {
echo $bb_cfg['whoops']['error_message'];
echo "<hr/>Error: {$e->getMessage()}."; echo "<hr/>Error: {$e->getMessage()}.";
}); });
} }

View file

@ -217,7 +217,7 @@ class Common
*/ */
public static function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $prune_all = false) 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 = []; $topic_csv = [];
$prune = ($mode_or_topic_id === 'prune'); $prune = ($mode_or_topic_id === 'prune');
@ -348,7 +348,7 @@ class Common
@unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename); @unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename);
} }
// TorrServer integration // TorrServer integration
if ($bb_cfg['torr_server']['enabled']) { if (config()->get('torr_server.enabled')) {
$torrServer = new \TorrentPier\TorrServerAPI(); $torrServer = new \TorrentPier\TorrServerAPI();
$torrServer->removeM3U($row['attach_id']); $torrServer->removeM3U($row['attach_id']);
} }
@ -699,7 +699,7 @@ class Common
*/ */
public static function user_delete($user_id, $delete_posts = false) 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)) { if (!$user_csv = get_id_csv($user_id)) {
return false; return false;
@ -779,7 +779,7 @@ class Common
// Delete user feed // Delete user feed
foreach (explode(',', $user_csv) as $user_id) { 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); @unlink($file_path);
} }
} }

View file

@ -23,6 +23,7 @@ class Cron
public static function run_jobs(string $jobs): void public static function run_jobs(string $jobs): void
{ {
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
// bb_cfg deprecated, but kept for compatibility with non-adapted cron jobs
global $bb_cfg, $datastore; global $bb_cfg, $datastore;
\define('IN_CRON', true); \define('IN_CRON', true);

View file

@ -25,9 +25,9 @@ class Atom
*/ */
public static function update_forum_feed($forum_id, $forum_data) public static function update_forum_feed($forum_id, $forum_data)
{ {
global $bb_cfg, $lang, $datastore; global $lang, $datastore;
$sql = null; $sql = null;
$file_path = $bb_cfg['atom']['path'] . '/f/' . $forum_id . '.atom'; $file_path = config()->get('atom.path') . '/f/' . $forum_id . '.atom';
$select_tor_sql = $join_tor_sql = ''; $select_tor_sql = $join_tor_sql = '';
if (!$forums = $datastore->get('cat_forums')) { if (!$forums = $datastore->get('cat_forums')) {
@ -37,7 +37,7 @@ class Atom
$not_forums_id = $forums['not_auth_forums']['guest_view']; $not_forums_id = $forums['not_auth_forums']['guest_view'];
if ($forum_id == 0) { if ($forum_id == 0) {
$forum_data['forum_name'] = $lang['ATOM_GLOBAL_FEED'] ?? $bb_cfg['server_name']; $forum_data['forum_name'] = $lang['ATOM_GLOBAL_FEED'] ?? config()->get('server_name');
} }
if ($forum_id > 0 && $forum_data['allow_reg_tracker']) { if ($forum_id > 0 && $forum_data['allow_reg_tracker']) {
$select_tor_sql = ', tor.size AS tor_size, tor.tor_status, tor.attach_id'; $select_tor_sql = ', tor.size AS tor_size, tor.tor_status, tor.attach_id';
@ -93,7 +93,7 @@ class Atom
} }
} }
if (isset($topic['tor_status'])) { if (isset($topic['tor_status'])) {
if (isset($bb_cfg['tor_frozen'][$topic['tor_status']])) { if (isset(config()->get('tor_frozen')[$topic['tor_status']])) {
continue; continue;
} }
} }
@ -120,8 +120,8 @@ class Atom
*/ */
public static function update_user_feed($user_id, $username) public static function update_user_feed($user_id, $username)
{ {
global $bb_cfg; global $lang, $datastore;
$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';
$sql = " $sql = "
SELECT SELECT
t.topic_id, t.topic_title, t.topic_status, t.topic_id, t.topic_title, t.topic_status,
@ -149,7 +149,7 @@ class Atom
} }
} }
if (isset($topic['tor_status'])) { if (isset($topic['tor_status'])) {
if (isset($bb_cfg['tor_frozen'][$topic['tor_status']])) { if (isset(config()->get('tor_frozen')[$topic['tor_status']])) {
continue; continue;
} }
} }
@ -179,7 +179,7 @@ class Atom
*/ */
private static function create_atom($file_path, $mode, $id, $title, $topics) private static function create_atom($file_path, $mode, $id, $title, $topics)
{ {
global $bb_cfg, $lang, $wordCensor; global $lang, $wordCensor;
$date = null; $date = null;
$time = null; $time = null;
$dir = \dirname($file_path); $dir = \dirname($file_path);
@ -233,13 +233,13 @@ class Atom
$atom .= " </author>\n"; $atom .= " </author>\n";
$atom .= " <updated>" . $date . "T$time+00:00</updated>\n"; $atom .= " <updated>" . $date . "T$time+00:00</updated>\n";
$atom .= " <id>tag:rto.feed," . $date . ":/t/$topic_id</id>\n"; $atom .= " <id>tag:rto.feed," . $date . ":/t/$topic_id</id>\n";
if ($bb_cfg['atom']['direct_down'] && isset($topic['attach_id'])) { if (config()->get('atom.direct_down') && isset($topic['attach_id'])) {
$atom .= " <link href=\"" . DL_URL . $topic['attach_id'] . "\" />\n"; $atom .= " <link href=\"" . DL_URL . $topic['attach_id'] . "\" />\n";
} else { } else {
$atom .= " <link href=\"" . TOPIC_URL . $topic_id . "\" />\n"; $atom .= " <link href=\"" . TOPIC_URL . $topic_id . "\" />\n";
} }
if ($bb_cfg['atom']['direct_view']) { if (config()->get('atom.direct_view')) {
$atom .= " <description>" . $topic['post_html'] . "\n\nNews URL: " . FULL_URL . TOPIC_URL . $topic_id . "</description>\n"; $atom .= " <description>" . $topic['post_html'] . "\n\nNews URL: " . FULL_URL . TOPIC_URL . $topic_id . "</description>\n";
} }

View file

@ -157,15 +157,13 @@ class BBCode
*/ */
public function bbcode2html(string $text): string public function bbcode2html(string $text): string
{ {
global $bb_cfg;
$text = self::clean_up($text); $text = self::clean_up($text);
$text = $this->parse($text); $text = $this->parse($text);
$text = $this->make_clickable($text); $text = $this->make_clickable($text);
$text = $this->smilies_pass($text); $text = $this->smilies_pass($text);
$text = $this->new_line2html($text); $text = $this->new_line2html($text);
if ($bb_cfg['tidy_post']) { if (config()->get('tidy_post')) {
$text = $this->tidy($text); $text = $this->tidy($text);
} }
@ -395,9 +393,7 @@ class BBCode
*/ */
private function nofollow_url(string $href, string $name): string private function nofollow_url(string $href, string $name): string
{ {
global $bb_cfg; if (\in_array(parse_url($href, PHP_URL_HOST), config()->get('nofollow.allowed_url')) || config()->get('nofollow.disabled')) {
if (\in_array(parse_url($href, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) {
$link = "<a href=\"$href\" class=\"postLink\">$name</a>"; $link = "<a href=\"$href\" class=\"postLink\">$name</a>";
} else { } else {
$link = "<a href=\"$href\" class=\"postLink\" rel=\"nofollow\">$name</a>"; $link = "<a href=\"$href\" class=\"postLink\" rel=\"nofollow\">$name</a>";

View file

@ -25,11 +25,9 @@ class Select
*/ */
public static function language(string $default_lang, string $select_name = 'language'): mixed public static function language(string $default_lang, string $select_name = 'language'): mixed
{ {
global $bb_cfg;
$lang_select = '<select name="' . $select_name . '">'; $lang_select = '<select name="' . $select_name . '">';
$x = 0; $x = 0;
foreach ($bb_cfg['lang'] as $key => $data) { foreach (config()->get('lang') as $key => $data) {
$selected = ''; $selected = '';
if ($key == $default_lang) { if ($key == $default_lang) {
$selected = ' selected'; $selected = ' selected';
@ -38,7 +36,8 @@ class Select
$x++; $x++;
} }
$lang_select .= '</select>'; $lang_select .= '</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 public static function template(string $default_style, string $select_name = 'tpl_name'): mixed
{ {
global $bb_cfg;
$templates_select = '<select name="' . $select_name . '">'; $templates_select = '<select name="' . $select_name . '">';
$x = 0; $x = 0;
foreach ($bb_cfg['templates'] as $folder => $name) { foreach (config()->get('templates') as $folder => $name) {
$selected = ''; $selected = '';
if ($folder == $default_style) { if ($folder == $default_style) {
$selected = ' selected'; $selected = ' selected';
@ -90,6 +87,7 @@ class Select
$x++; $x++;
} }
$templates_select .= '</select>'; $templates_select .= '</select>';
return ($x > 1) ? $templates_select : reset($bb_cfg['templates']); $templates = config()->get('templates');
return ($x > 1) ? $templates_select : reset($templates);
} }
} }

View file

@ -103,7 +103,7 @@ class Upload
*/ */
public function init(array $cfg = [], array $post_params = [], bool $uploaded_only = true): bool 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->cfg = array_merge($this->cfg, $cfg);
$this->file = $post_params; $this->file = $post_params;
@ -150,7 +150,7 @@ class Upload
$file_name_ary = explode('.', $this->file['name']); $file_name_ary = explode('.', $this->file['name']);
$this->file_ext = strtolower(end($file_name_ary)); $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] // Actions for images [E.g. Change avatar]
if ($this->cfg['max_width'] || $this->cfg['max_height']) { if ($this->cfg['max_width'] || $this->cfg['max_height']) {

View file

@ -111,7 +111,7 @@ class User
*/ */
public function session_start(array $cfg = []) public function session_start(array $cfg = [])
{ {
global $bb_cfg, $lang; global $lang;
$update_sessions_table = false; $update_sessions_table = false;
$this->cfg = array_merge($this->cfg, $cfg); $this->cfg = array_merge($this->cfg, $cfg);
@ -130,7 +130,7 @@ class User
if ($session_id) { if ($session_id) {
$SQL['WHERE'][] = "s.session_id = '$session_id'"; $SQL['WHERE'][] = "s.session_id = '$session_id'";
if ($bb_cfg['torhelp_enabled']) { if (config()->get('torhelp_enabled')) {
$SQL['SELECT'][] = "th.topic_id_csv AS torhelp"; $SQL['SELECT'][] = "th.topic_id_csv AS torhelp";
$SQL['LEFT JOIN'][] = BB_BT_TORHELP . " th ON(u.user_id = th.user_id)"; $SQL['LEFT JOIN'][] = BB_BT_TORHELP . " th ON(u.user_id = th.user_id)";
} }
@ -146,7 +146,7 @@ class User
if (!$this->data = Sessions::cache_get_userdata($userdata_cache_id)) { if (!$this->data = Sessions::cache_get_userdata($userdata_cache_id)) {
$this->data = DB()->fetch_row($SQL); $this->data = DB()->fetch_row($SQL);
if ($this->data && (TIMENOW - $this->data['session_time']) > $bb_cfg['session_update_intrv']) { if ($this->data && (TIMENOW - $this->data['session_time']) > config()->get('session_update_intrv')) {
$this->data['session_time'] = TIMENOW; $this->data['session_time'] = TIMENOW;
$update_sessions_table = true; $update_sessions_table = true;
} }
@ -187,7 +187,7 @@ class User
// using the cookie user_id if available to pull basic user prefs. // using the cookie user_id if available to pull basic user prefs.
if (!$this->data) { if (!$this->data) {
$login = false; $login = false;
$user_id = ($bb_cfg['allow_autologin'] && $this->sessiondata['uk'] && $this->sessiondata['uid']) ? $this->sessiondata['uid'] : GUEST_UID; $user_id = (config()->get('allow_autologin') && $this->sessiondata['uk'] && $this->sessiondata['uid']) ? $this->sessiondata['uid'] : GUEST_UID;
if ($userdata = get_userdata((int)$user_id, false, true)) { if ($userdata = get_userdata((int)$user_id, false, true)) {
if ($userdata['user_id'] != GUEST_UID && $userdata['user_active']) { if ($userdata['user_id'] != GUEST_UID && $userdata['user_active']) {
@ -208,7 +208,7 @@ class User
define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD); define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD);
define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER); define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER);
define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER); define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER);
define('IS_SUPER_ADMIN', IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']])); define('IS_SUPER_ADMIN', IS_ADMIN && isset(config()->get('super_admins')[$this->data['user_id']]));
define('IS_AM', IS_ADMIN || IS_MOD); define('IS_AM', IS_ADMIN || IS_MOD);
$this->set_shortcuts(); $this->set_shortcuts();
@ -243,8 +243,6 @@ class User
*/ */
public function session_create(array $userdata, bool $auto_created = false): array public function session_create(array $userdata, bool $auto_created = false): array
{ {
global $bb_cfg;
$this->data = $userdata; $this->data = $userdata;
$session_id = $this->sessiondata['sid']; $session_id = $this->sessiondata['sid'];
@ -281,8 +279,8 @@ class User
if (!$session_time = $this->data['user_session_time']) { if (!$session_time = $this->data['user_session_time']) {
$last_visit = TIMENOW; $last_visit = TIMENOW;
define('FIRST_LOGON', true); define('FIRST_LOGON', true);
} elseif ($session_time < (TIMENOW - $bb_cfg['last_visit_update_intrv'])) { } elseif ($session_time < (TIMENOW - config()->get('last_visit_update_intrv'))) {
$last_visit = max($session_time, (TIMENOW - 86400 * $bb_cfg['max_last_visit_days'])); $last_visit = max($session_time, (TIMENOW - 86400 * config()->get('max_last_visit_days')));
} }
if ($last_visit != $this->data['user_lastvisit']) { if ($last_visit != $this->data['user_lastvisit']) {
@ -301,7 +299,7 @@ class User
$this->data['user_lastvisit'] = $last_visit; $this->data['user_lastvisit'] = $last_visit;
} }
if (!empty($_POST['autologin']) && $bb_cfg['allow_autologin']) { if (!empty($_POST['autologin']) && config()->get('allow_autologin')) {
if (!$auto_created) { if (!$auto_created) {
$this->verify_autologin_id($this->data, true, true); $this->verify_autologin_id($this->data, true, true);
} }
@ -463,7 +461,6 @@ class User
*/ */
public function set_session_cookies($user_id) public function set_session_cookies($user_id)
{ {
global $bb_cfg;
$debug_cookies = [ $debug_cookies = [
COOKIE_DBG, COOKIE_DBG,
@ -486,10 +483,10 @@ class User
} }
} }
} else { } else {
if (!isset($bb_cfg['dbg_users'][$this->data['user_id']]) && DBG_USER) { if (!isset(config()->get('dbg_users')[$this->data['user_id']]) && DBG_USER) {
bb_setcookie(COOKIE_DBG, null); bb_setcookie(COOKIE_DBG, null);
} elseif (isset($bb_cfg['dbg_users'][$this->data['user_id']]) && !DBG_USER) { } elseif (isset(config()->get('dbg_users')[$this->data['user_id']]) && !DBG_USER) {
bb_setcookie(COOKIE_DBG, hash('xxh128', $bb_cfg['dbg_users'][$this->data['user_id']]), COOKIE_SESSION); bb_setcookie(COOKIE_DBG, hash('xxh128', config()->get('dbg_users')[$this->data['user_id']]), COOKIE_SESSION);
} }
// Unset sql debug cookies if SQL_DEBUG is disabled or DBG_USER cookie not present // Unset sql debug cookies if SQL_DEBUG is disabled or DBG_USER cookie not present
@ -522,8 +519,6 @@ class User
*/ */
public function verify_autologin_id($userdata, bool $expire_check = false, bool $create_new = true): bool|string public function verify_autologin_id($userdata, bool $expire_check = false, bool $create_new = true): bool|string
{ {
global $bb_cfg;
$autologin_id = $userdata['autologin_id']; $autologin_id = $userdata['autologin_id'];
if ($expire_check) { if ($expire_check) {
@ -531,8 +526,8 @@ class User
return $this->create_autologin_id($userdata); return $this->create_autologin_id($userdata);
} }
if ($autologin_id && $userdata['user_session_time'] && $bb_cfg['max_autologin_time']) { if ($autologin_id && $userdata['user_session_time'] && config()->get('max_autologin_time')) {
if (TIMENOW - $userdata['user_session_time'] > $bb_cfg['max_autologin_time'] * 86400) { if (TIMENOW - $userdata['user_session_time'] > config()->get('max_autologin_time') * 86400) {
return $this->create_autologin_id($userdata, $create_new); return $this->create_autologin_id($userdata, $create_new);
} }
} }
@ -584,39 +579,39 @@ class User
*/ */
public function init_userprefs() public function init_userprefs()
{ {
global $bb_cfg, $theme, $source_lang, $DeltaTime; global $theme, $source_lang, $DeltaTime;
if (defined('LANG_DIR')) { if (defined('LANG_DIR')) {
return; return;
} // prevent multiple calling } // prevent multiple calling
// Apply browser language // Apply browser language
if ($bb_cfg['auto_language_detection'] && IS_GUEST && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { if (config()->get('auto_language_detection') && IS_GUEST && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$http_accept_language = locale_get_primary_language(locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE'])); $http_accept_language = locale_get_primary_language(locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']));
if (isset($bb_cfg['lang'][$http_accept_language])) { if (isset(config()->get('lang')[$http_accept_language])) {
$bb_cfg['default_lang'] = $http_accept_language; config()->set('default_lang', $http_accept_language);
} }
} }
define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/'); define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . config()->get('default_lang') . '/');
define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/'); define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/');
if ($this->data['user_id'] != GUEST_UID) { if ($this->data['user_id'] != GUEST_UID) {
if (IN_DEMO_MODE && isset($_COOKIE['user_lang'])) { if (IN_DEMO_MODE && isset($_COOKIE['user_lang'])) {
$this->data['user_lang'] = $_COOKIE['user_lang']; $this->data['user_lang'] = $_COOKIE['user_lang'];
} }
if ($this->data['user_lang'] && $this->data['user_lang'] != $bb_cfg['default_lang']) { if ($this->data['user_lang'] && $this->data['user_lang'] != config()->get('default_lang')) {
$bb_cfg['default_lang'] = basename($this->data['user_lang']); config()->set('default_lang', basename($this->data['user_lang']));
define('LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/'); define('LANG_DIR', LANG_ROOT_DIR . '/' . config()->get('default_lang') . '/');
} }
if (isset($this->data['user_timezone'])) { if (isset($this->data['user_timezone'])) {
$bb_cfg['board_timezone'] = $this->data['user_timezone']; config()->set('board_timezone', $this->data['user_timezone']);
} }
} }
$this->data['user_lang'] = $bb_cfg['default_lang']; $this->data['user_lang'] = config()->get('default_lang');
$this->data['user_timezone'] = $bb_cfg['board_timezone']; $this->data['user_timezone'] = config()->get('board_timezone');
if (!defined('LANG_DIR')) { if (!defined('LANG_DIR')) {
define('LANG_DIR', DEFAULT_LANG_DIR); define('LANG_DIR', DEFAULT_LANG_DIR);
@ -631,7 +626,7 @@ class User
/** Place user language to the global */ /** Place user language to the global */
global $lang; global $lang;
require(LANG_DIR . 'main.php'); require(LANG_DIR . 'main.php');
setlocale(LC_ALL, $bb_cfg['lang'][$this->data['user_lang']]['locale'] ?? 'en_US.UTF-8'); setlocale(LC_ALL, config()->get('lang')[$this->data['user_lang']]['locale'] ?? 'en_US.UTF-8');
$lang += $source_lang; $lang += $source_lang;
$theme = setup_style(); $theme = setup_style();
@ -804,10 +799,8 @@ class User
*/ */
public function checkPassword(string $enteredPassword, array $userdata): bool public function checkPassword(string $enteredPassword, array $userdata): bool
{ {
global $bb_cfg;
if (password_verify($enteredPassword, $userdata['user_password'])) { if (password_verify($enteredPassword, $userdata['user_password'])) {
if (password_needs_rehash($userdata['user_password'], $bb_cfg['password_hash_options']['algo'], $bb_cfg['password_hash_options']['options'])) { if (password_needs_rehash($userdata['user_password'], config()->get('password_hash_options.algo'), config()->get('password_hash_options.options'))) {
// Update password_hash // Update password_hash
DB()->query("UPDATE " . BB_USERS . " SET user_password = '" . $this->password_hash($enteredPassword) . "' WHERE user_id = '" . $userdata['user_id'] . "' AND user_password = '" . $userdata['user_password'] . "' LIMIT 1"); DB()->query("UPDATE " . BB_USERS . " SET user_password = '" . $this->password_hash($enteredPassword) . "' WHERE user_id = '" . $userdata['user_id'] . "' AND user_password = '" . $userdata['user_password'] . "' LIMIT 1");
} }
@ -833,8 +826,6 @@ class User
*/ */
public function password_hash(string $enteredPassword): string public function password_hash(string $enteredPassword): string
{ {
global $bb_cfg; return password_hash($enteredPassword, config()->get('password_hash_options.algo'), config()->get('password_hash_options.options'));
return password_hash($enteredPassword, $bb_cfg['password_hash_options']['algo'], $bb_cfg['password_hash_options']['options']);
} }
} }

View file

@ -44,7 +44,7 @@ class LogAction
*/ */
public function init() public function init()
{ {
global $lang, $bb_cfg; global $lang;
foreach ($lang['LOG_ACTION']['LOG_TYPE'] as $log_type => $log_desc) { foreach ($lang['LOG_ACTION']['LOG_TYPE'] as $log_type => $log_desc) {
$this->log_type_select[strip_tags($log_desc)] = $this->log_type[$log_type]; $this->log_type_select[strip_tags($log_desc)] = $this->log_type[$log_type];

View file

@ -21,8 +21,7 @@ class Poll
public function __construct() public function __construct()
{ {
global $bb_cfg; $this->max_votes = config()->get('max_poll_options');
$this->max_votes = $bb_cfg['max_poll_options'];
} }
/** /**
@ -162,7 +161,6 @@ class Poll
*/ */
public static function pollIsActive(array $t_data): bool public static function pollIsActive(array $t_data): bool
{ {
global $bb_cfg; return ($t_data['topic_vote'] == 1 && $t_data['topic_time'] > TIMENOW - config()->get('poll_max_days') * 86400);
return ($t_data['topic_vote'] == 1 && $t_data['topic_time'] > TIMENOW - $bb_cfg['poll_max_days'] * 86400);
} }
} }

View file

@ -31,7 +31,7 @@ class Post
*/ */
public static function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &$message) 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 // Check username
if (!empty($username)) { if (!empty($username)) {
@ -60,15 +60,15 @@ class Post
} }
// Check smilies limit // Check smilies limit
if ($bb_cfg['max_smilies']) { if (config()->get('max_smilies')) {
$count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . $bb_cfg['smilies_path']); $count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . config()->get('smilies_path'));
if ($count_smilies > $bb_cfg['max_smilies']) { if ($count_smilies > config()->get('max_smilies')) {
$to_many_smilies = sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']); $to_many_smilies = sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies'));
$error_msg .= (!empty($error_msg)) ? '<br />' . $to_many_smilies : $to_many_smilies; $error_msg .= (!empty($error_msg)) ? '<br />' . $to_many_smilies : $to_many_smilies;
} }
} }
if (IS_GUEST && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) { if (IS_GUEST && !config()->get('captcha.disabled') && !bb_captcha('check')) {
$error_msg .= (!empty($error_msg)) ? '<br />' . $lang['CAPTCHA_WRONG'] : $lang['CAPTCHA_WRONG']; $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['CAPTCHA_WRONG'] : $lang['CAPTCHA_WRONG'];
} }
} }
@ -96,7 +96,7 @@ class Post
*/ */
public static function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig, $robots_indexing) public static function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig, $robots_indexing)
{ {
global $userdata, $post_info, $is_auth, $bb_cfg, $lang, $datastore; global $userdata, $post_info, $is_auth, $lang, $datastore;
$current_time = TIMENOW; $current_time = TIMENOW;
@ -108,7 +108,7 @@ class Post
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql"; $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 ($row = DB()->fetch_row($sql) and $row['last_post_time']) {
if ($userdata['user_level'] == USER) { 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']); bb_die($lang['FLOOD_ERROR']);
} }
} }
@ -200,9 +200,9 @@ class Post
update_post_html(['post_id' => $post_id, 'post_text' => $post_message]); update_post_html(['post_id' => $post_id, 'post_text' => $post_message]);
// Updating news cache on index page // Updating news cache on index page
if ($bb_cfg['show_latest_news']) { if (config()->get('show_latest_news')) {
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id'])); $news_forums = array_flip(explode(',', config()->get('latest_news_forum_id')));
if (isset($news_forums[$forum_id]) && $bb_cfg['show_latest_news'] && $mode == 'newtopic') { if (isset($news_forums[$forum_id]) && config()->get('show_latest_news') && $mode == 'newtopic') {
$datastore->enqueue([ $datastore->enqueue([
'latest_news' 'latest_news'
]); ]);
@ -210,9 +210,9 @@ class Post
} }
} }
if ($bb_cfg['show_network_news']) { if (config()->get('show_network_news')) {
$net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id'])); $net_forums = array_flip(explode(',', config()->get('network_news_forum_id')));
if (isset($net_forums[$forum_id]) && $bb_cfg['show_network_news'] && $mode == 'newtopic') { if (isset($net_forums[$forum_id]) && config()->get('show_network_news') && $mode == 'newtopic') {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -341,9 +341,9 @@ class Post
*/ */
public static function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$notify_user) 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; return;
} }
@ -378,7 +378,7 @@ class Post
$emailer->set_template('topic_notify', $row['user_lang']); $emailer->set_template('topic_notify', $row['user_lang']);
$emailer->assign_vars([ $emailer->assign_vars([
'TOPIC_TITLE' => html_entity_decode($topic_title), 'TOPIC_TITLE' => html_entity_decode($topic_title),
'SITENAME' => $bb_cfg['sitename'], 'SITENAME' => config()->get('sitename'),
'USERNAME' => $row['username'], 'USERNAME' => $row['username'],
'U_TOPIC' => $u_topic, 'U_TOPIC' => $u_topic,
'U_STOP_WATCHING_TOPIC' => $unwatch_topic, 'U_STOP_WATCHING_TOPIC' => $unwatch_topic,
@ -500,7 +500,7 @@ class Post
*/ */
public static function topic_review($topic_id) public static function topic_review($topic_id)
{ {
global $bb_cfg, $template; global $template;
// Fetch posts data // Fetch posts data
$review_posts = DB()->fetch_rowset(" $review_posts = DB()->fetch_rowset("
@ -513,7 +513,7 @@ class Post
LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = p.post_id) LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = p.post_id)
WHERE p.topic_id = " . (int)$topic_id . " WHERE p.topic_id = " . (int)$topic_id . "
ORDER BY p.post_time DESC ORDER BY p.post_time DESC
LIMIT " . $bb_cfg['posts_per_page'] . " LIMIT " . config()->get('posts_per_page') . "
"); ");
// Topic posts block // Topic posts block
@ -523,7 +523,7 @@ class Post
'POSTER' => profile_url($post), 'POSTER' => profile_url($post),
'POSTER_NAME_JS' => addslashes($post['username']), 'POSTER_NAME_JS' => addslashes($post['username']),
'POST_ID' => $post['post_id'], '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']), 'IS_UNREAD' => is_unread($post['post_time'], $topic_id, $post['forum_id']),
'MESSAGE' => get_parsed_post($post), 'MESSAGE' => get_parsed_post($post),
]); ]);

View file

@ -17,7 +17,7 @@ class Template
{ {
/** /**
* Variable that holds all the data we'll be substituting into the compiled templates. * Variable that holds all the data we'll be substituting into the compiled templates.
* This will end up being a multi-dimensional array like this: * This will end up being a multidimensional array like this:
* $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value * $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value
* if it's a root-level variable, it'll be like this: * if it's a root-level variable, it'll be like this:
* $this->vars[varname] == value or $this->_tpldata['.'][0][varname] == value * $this->vars[varname] == value or $this->_tpldata['.'][0][varname] == value
@ -99,7 +99,7 @@ class Template
*/ */
public function __construct($root = '.') public function __construct($root = '.')
{ {
global $bb_cfg, $lang; global $lang;
// setting pointer "vars" // setting pointer "vars"
$this->vars = &$this->_tpldata['.'][0]; $this->vars = &$this->_tpldata['.'][0];
@ -108,7 +108,7 @@ class Template
$this->root = $root; $this->root = $root;
$this->tpl = basename($root); $this->tpl = basename($root);
$this->lang =& $lang; $this->lang =& $lang;
$this->use_cache = $bb_cfg['xs_use_cache']; $this->use_cache = config()->get('xs_use_cache');
// Check template exists // Check template exists
if (!is_dir($this->root)) { if (!is_dir($this->root)) {
@ -228,6 +228,8 @@ class Template
{ {
$this->cur_tpl = $filename; $this->cur_tpl = $filename;
/** @noinspection PhpUnusedLocalVariableInspection */
// bb_cfg deprecated, but kept for compatibility with non-adapted themes
global $lang, $source_lang, $bb_cfg, $user; global $lang, $source_lang, $bb_cfg, $user;
$L =& $lang; $L =& $lang;
@ -987,11 +989,9 @@ class Template
public function xs_startup() public function xs_startup()
{ {
global $bb_cfg;
// adding language variable (eg: "english" or "german") // adding language variable (eg: "english" or "german")
// can be used to make truly multi-lingual templates // can be used to make truly multi-lingual templates
$this->vars['LANG'] ??= $bb_cfg['default_lang']; $this->vars['LANG'] ??= config()->get('default_lang');
// adding current template // adding current template
$tpl = $this->root . '/'; $tpl = $this->root . '/';
if (str_starts_with($tpl, './')) { if (str_starts_with($tpl, './')) {

View file

@ -97,7 +97,7 @@ class Torrent
*/ */
public static function tracker_unregister($attach_id, $mode = '') public static function tracker_unregister($attach_id, $mode = '')
{ {
global $lang, $bb_cfg, $log_action; global $lang, $log_action;
$attach_id = (int)$attach_id; $attach_id = (int)$attach_id;
$post_id = $topic_id = $topic_title = $forum_id = null; $post_id = $topic_id = $topic_title = $forum_id = null;
@ -132,7 +132,7 @@ class Torrent
} }
// Unset DL-Type for topic // Unset DL-Type for topic
if ($bb_cfg['bt_unset_dltype_on_tor_unreg'] && $topic_id) { if (config()->get('bt_unset_dltype_on_tor_unreg') && $topic_id) {
$sql = "UPDATE " . BB_TOPICS . " SET topic_dl_type = " . TOPIC_DL_TYPE_NORMAL . " WHERE topic_id = $topic_id"; $sql = "UPDATE " . BB_TOPICS . " SET topic_dl_type = " . TOPIC_DL_TYPE_NORMAL . " WHERE topic_id = $topic_id";
if (!$result = DB()->sql_query($sql)) { if (!$result = DB()->sql_query($sql)) {
@ -148,7 +148,7 @@ class Torrent
} }
// TorrServer integration // TorrServer integration
if ($bb_cfg['torr_server']['enabled']) { if (config()->get('torr_server.enabled')) {
$torrServer = new TorrServerAPI(); $torrServer = new TorrServerAPI();
$torrServer->removeM3U($attach_id); $torrServer->removeM3U($attach_id);
} }
@ -277,7 +277,7 @@ class Torrent
*/ */
public static function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED, $reg_time = TIMENOW) 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; $attach_id = (int)$attach_id;
$reg_mode = $mode; $reg_mode = $mode;
@ -327,19 +327,19 @@ class Torrent
self::torrent_error_exit(htmlCHR("{$lang['TORFILE_INVALID']}: {$e->getMessage()}")); self::torrent_error_exit(htmlCHR("{$lang['TORFILE_INVALID']}: {$e->getMessage()}"));
} }
if ($bb_cfg['bt_disable_dht']) { if (config()->get('bt_disable_dht')) {
$tor['info']['private'] = (int)1; $tor['info']['private'] = (int)1;
$fp = fopen($filename, 'wb+'); $fp = fopen($filename, 'wb+');
fwrite($fp, Bencode::encode($tor)); fwrite($fp, Bencode::encode($tor));
fclose($fp); fclose($fp);
} }
if ($bb_cfg['bt_check_announce_url']) { if (config()->get('bt_check_announce_url')) {
$announce_urls = []; $announce_urls = [];
include INC_DIR . '/torrent_announce_urls.php'; include INC_DIR . '/torrent_announce_urls.php';
$ann = $tor['announce'] ?? ''; $ann = $tor['announce'] ?? '';
$announce_urls['main_url'] = $bb_cfg['bt_announce_url']; $announce_urls['main_url'] = config()->get('bt_announce_url');
if (!$ann || !in_array($ann, $announce_urls)) { if (!$ann || !in_array($ann, $announce_urls)) {
$msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']); $msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']);
@ -365,11 +365,11 @@ class Torrent
$bt_v1 = true; $bt_v1 = true;
} }
if ($bb_cfg['tracker']['disabled_v1_torrents'] && isset($bt_v1) && !isset($bt_v2)) { if (config()->get('tracker.disabled_v1_torrents') && isset($bt_v1) && !isset($bt_v2)) {
self::torrent_error_exit($lang['BT_V1_ONLY_DISALLOWED']); self::torrent_error_exit($lang['BT_V1_ONLY_DISALLOWED']);
} }
if ($bb_cfg['tracker']['disabled_v2_torrents'] && !isset($bt_v1) && isset($bt_v2)) { if (config()->get('tracker.disabled_v2_torrents') && !isset($bt_v1) && isset($bt_v2)) {
self::torrent_error_exit($lang['BT_V2_ONLY_DISALLOWED']); self::torrent_error_exit($lang['BT_V2_ONLY_DISALLOWED']);
} }
@ -388,7 +388,7 @@ class Torrent
} }
// TorrServer integration // TorrServer integration
if ($bb_cfg['torr_server']['enabled']) { if (config()->get('torr_server.enabled')) {
$torrServer = new TorrServerAPI(); $torrServer = new TorrServerAPI();
if ($torrServer->uploadTorrent($filename, $torrent['mimetype'])) { if ($torrServer->uploadTorrent($filename, $torrent['mimetype'])) {
$torrServer->saveM3U($attach_id, bin2hex($info_hash ?? $info_hash_v2)); $torrServer->saveM3U($attach_id, bin2hex($info_hash ?? $info_hash_v2));
@ -467,7 +467,7 @@ class Torrent
} }
// set DL-Type for topic // set DL-Type for topic
if ($bb_cfg['bt_set_dltype_on_tor_reg']) { if (config()->get('bt_set_dltype_on_tor_reg')) {
$sql = 'UPDATE ' . BB_TOPICS . ' SET topic_dl_type = ' . TOPIC_DL_TYPE_DL . " WHERE topic_id = $topic_id"; $sql = 'UPDATE ' . BB_TOPICS . ' SET topic_dl_type = ' . TOPIC_DL_TYPE_DL . " WHERE topic_id = $topic_id";
if (!$result = DB()->sql_query($sql)) { if (!$result = DB()->sql_query($sql)) {
@ -475,7 +475,7 @@ class Torrent
} }
} }
if ($bb_cfg['tracker']['tor_topic_up']) { if (config()->get('tracker.tor_topic_up')) {
DB()->query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = GREATEST(topic_last_post_time, " . (TIMENOW - 3 * 86400) . ") WHERE topic_id = $topic_id"); DB()->query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = GREATEST(topic_last_post_time, " . (TIMENOW - 3 * 86400) . ") WHERE topic_id = $topic_id");
} }
@ -494,9 +494,9 @@ class Torrent
*/ */
public static function send_torrent_with_passkey($filename) public static function send_torrent_with_passkey($filename)
{ {
global $attachment, $auth_pages, $userdata, $bb_cfg, $lang; global $attachment, $auth_pages, $userdata, $lang;
if (!$bb_cfg['bt_add_auth_key'] || $attachment['extension'] !== TORRENT_EXT || !$size = @filesize($filename)) { if (!config()->get('bt_add_auth_key') || $attachment['extension'] !== TORRENT_EXT || !$size = @filesize($filename)) {
return; return;
} }
@ -504,8 +504,8 @@ class Torrent
$user_id = $userdata['user_id']; $user_id = $userdata['user_id'];
$attach_id = $attachment['attach_id']; $attach_id = $attachment['attach_id'];
if (!$passkey_key = $bb_cfg['passkey_key']) { 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 // Get $post_id & $poster_id
@ -543,7 +543,7 @@ class Torrent
} }
// Ratio limits // Ratio limits
$min_ratio = $bb_cfg['bt_min_ratio_allow_dl_tor']; $min_ratio = config()->get('bt_min_ratio_allow_dl_tor');
if ($min_ratio && $user_id != $poster_id && ($user_ratio = get_bt_ratio($bt_userdata)) !== null) { if ($min_ratio && $user_id != $poster_id && ($user_ratio = get_bt_ratio($bt_userdata)) !== null) {
if ($user_ratio < $min_ratio && $post_id) { if ($user_ratio < $min_ratio && $post_id) {
@ -570,15 +570,15 @@ class Torrent
} }
// Get tracker announcer // Get tracker announcer
$announce_url = $bb_cfg['bt_announce_url'] . "?$passkey_key=$passkey_val"; $announce_url = config()->get('bt_announce_url') . "?$passkey_key=$passkey_val";
// Replace original announce url with tracker default // Replace original announce url with tracker default
if ($bb_cfg['bt_replace_ann_url'] || !isset($tor['announce'])) { if (config()->get('bt_replace_ann_url') || !isset($tor['announce'])) {
$tor['announce'] = $announce_url; $tor['announce'] = $announce_url;
} }
// Creating / cleaning announce-list // Creating / cleaning announce-list
if (!isset($tor['announce-list']) || !is_array($tor['announce-list']) || $bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) { if (!isset($tor['announce-list']) || !is_array($tor['announce-list']) || config()->get('bt_del_addit_ann_urls') || config()->get('bt_disable_dht')) {
$tor['announce-list'] = []; $tor['announce-list'] = [];
} }
@ -597,15 +597,15 @@ class Torrent
} }
// Add retracker // Add retracker
if (!empty($bb_cfg['tracker']['retracker_host']) && $bb_cfg['tracker']['retracker']) { if (!empty(config()->get('tracker.retracker_host')) && config()->get('tracker.retracker')) {
if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) { if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) {
$tor['announce-list'] = array_merge($tor['announce-list'], [[$bb_cfg['tracker']['retracker_host']]]); $tor['announce-list'] = array_merge($tor['announce-list'], [[config()->get('tracker.retracker_host')]]);
} }
} }
// Adding tracker announcer to announce-list // Adding tracker announcer to announce-list
if (!empty($tor['announce-list'])) { if (!empty($tor['announce-list'])) {
if ($bb_cfg['bt_replace_ann_url']) { if (config()->get('bt_replace_ann_url')) {
// Adding tracker announcer as main announcer (At start) // Adding tracker announcer as main announcer (At start)
array_unshift($tor['announce-list'], [$announce_url]); array_unshift($tor['announce-list'], [$announce_url]);
} else { } else {
@ -629,7 +629,7 @@ class Torrent
} }
// Add publisher & topic url // Add publisher & topic url
$publisher_name = $bb_cfg['server_name']; $publisher_name = config()->get('server_name');
$publisher_url = make_url(TOPIC_URL . $topic_id); $publisher_url = make_url(TOPIC_URL . $topic_id);
$tor['publisher'] = (string)$publisher_name; $tor['publisher'] = (string)$publisher_name;
@ -644,10 +644,10 @@ class Torrent
// Send torrent // Send torrent
$output = Bencode::encode($tor); $output = Bencode::encode($tor);
if ($bb_cfg['tracker']['use_old_torrent_name_format']) { if (config()->get('tracker.use_old_torrent_name_format')) {
$dl_fname = '[' . $bb_cfg['server_name'] . '].t' . $topic_id . '.' . TORRENT_EXT; $dl_fname = '[' . config()->get('server_name') . '].t' . $topic_id . '.' . TORRENT_EXT;
} else { } else {
$dl_fname = html_ent_decode($topic_title) . ' [' . $bb_cfg['server_name'] . '-' . $topic_id . ']' . '.' . TORRENT_EXT; $dl_fname = html_ent_decode($topic_title) . ' [' . config()->get('server_name') . '-' . $topic_id . ']' . '.' . TORRENT_EXT;
} }
if (!empty($_COOKIE['explain'])) { if (!empty($_COOKIE['explain'])) {

View file

@ -41,12 +41,12 @@ class TorrentFileList
*/ */
public function get_filelist() public function get_filelist()
{ {
global $bb_cfg, $html; global $html;
$info = &$this->tor_decoded['info']; $info = &$this->tor_decoded['info'];
if (isset($info['meta version'], $info['file tree'])) { //v2 if (isset($info['meta version'], $info['file tree'])) { //v2
if (($info['meta version']) === 2 && is_array($info['file tree'])) { if (($info['meta version']) === 2 && is_array($info['file tree'])) {
return $this->fileTreeList($info['file tree'], $info['name'] ?? '', $bb_cfg['flist_timeout']); return $this->fileTreeList($info['file tree'], $info['name'] ?? '', config()->get('flist_timeout'));
} }
} }
@ -71,8 +71,6 @@ class TorrentFileList
*/ */
private function build_filelist_array() private function build_filelist_array()
{ {
global $bb_cfg;
$info = &$this->tor_decoded['info']; $info = &$this->tor_decoded['info'];
if (isset($info['name.utf-8'])) { if (isset($info['name.utf-8'])) {
@ -95,7 +93,7 @@ class TorrentFileList
continue; continue;
} }
$structure = array_deep($f['path'], 'clean_tor_dirname', timeout: $bb_cfg['flist_timeout']); $structure = array_deep($f['path'], 'clean_tor_dirname', timeout: config()->get('flist_timeout'));
if (isset($structure['timeout'])) { if (isset($structure['timeout'])) {
bb_die("Timeout, too many nested files/directories for file listing, aborting after \n{$structure['recs']} recursive calls.\nNesting level: " . count($info['files'], COUNT_RECURSIVE)); bb_die("Timeout, too many nested files/directories for file listing, aborting after \n{$structure['recs']} recursive calls.\nNesting level: " . count($info['files'], COUNT_RECURSIVE));
} }

View file

@ -51,14 +51,12 @@ class Sessions
*/ */
public static function cache_set_userdata(?array $userdata, bool $force = false): bool public static function cache_set_userdata(?array $userdata, bool $force = false): bool
{ {
global $bb_cfg;
if (!$userdata || (self::ignore_cached_userdata() && !$force)) { if (!$userdata || (self::ignore_cached_userdata() && !$force)) {
return false; return false;
} }
$id = ($userdata['user_id'] == GUEST_UID) ? $userdata['session_ip'] : $userdata['session_id']; $id = ($userdata['user_id'] == GUEST_UID) ? $userdata['session_ip'] : $userdata['session_id'];
return CACHE('session_cache')->set($id, $userdata, $bb_cfg['session_update_intrv']); return CACHE('session_cache')->set($id, $userdata, config()->get('session_update_intrv'));
} }
/** /**

View file

@ -99,13 +99,11 @@ class Sitemap
*/ */
private function getStaticUrls(): array private function getStaticUrls(): array
{ {
global $bb_cfg;
$staticUrls = []; $staticUrls = [];
if (isset($bb_cfg['static_sitemap'])) { if (config()->has('static_sitemap')) {
/** @var array $urls разбиваем строку по переносам */ /** @var array $urls разбиваем строку по переносам */
$urls = explode("\n", $bb_cfg['static_sitemap']); $urls = explode("\n", config()->get('static_sitemap'));
foreach ($urls as $url) { foreach ($urls as $url) {
/** @var string $url проверяем что адрес валиден и с указанными протоколом */ /** @var string $url проверяем что адрес валиден и с указанными протоколом */
if (filter_var(trim($url), FILTER_VALIDATE_URL)) { if (filter_var(trim($url), FILTER_VALIDATE_URL)) {

View file

@ -52,9 +52,7 @@ class TorrServerAPI
*/ */
public function __construct() public function __construct()
{ {
global $bb_cfg; $this->url = config()->get('torr_server.url') . '/';
$this->url = $bb_cfg['torr_server']['url'] . '/';
} }
/** /**
@ -66,15 +64,13 @@ class TorrServerAPI
*/ */
public function uploadTorrent(string $path, string $mimetype): bool public function uploadTorrent(string $path, string $mimetype): bool
{ {
global $bb_cfg;
// Check mimetype // Check mimetype
if ($mimetype !== TORRENT_MIMETYPE) { if ($mimetype !== TORRENT_MIMETYPE) {
return false; return false;
} }
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout($bb_cfg['torr_server']['timeout']); $curl->setTimeout(config()->get('torr_server.timeout'));
$curl->setHeaders([ $curl->setHeaders([
'Accept' => 'application/json', 'Accept' => 'application/json',
@ -101,8 +97,6 @@ class TorrServerAPI
*/ */
public function saveM3U(string|int $attach_id, string $hash): string public function saveM3U(string|int $attach_id, string $hash): string
{ {
global $bb_cfg;
$m3uFile = get_attachments_dir() . '/' . self::M3U['prefix'] . $attach_id . self::M3U['extension']; $m3uFile = get_attachments_dir() . '/' . self::M3U['prefix'] . $attach_id . self::M3U['extension'];
// Make stream call to store torrent in memory // Make stream call to store torrent in memory
@ -115,7 +109,7 @@ class TorrServerAPI
} }
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout($bb_cfg['torr_server']['timeout']); $curl->setTimeout(config()->get('torr_server.timeout'));
$curl->setHeader('Accept', 'audio/x-mpegurl'); $curl->setHeader('Accept', 'audio/x-mpegurl');
$curl->get($this->url . $this->endpoints['playlist'], ['hash' => $hash]); $curl->get($this->url . $this->endpoints['playlist'], ['hash' => $hash]);
@ -197,8 +191,6 @@ class TorrServerAPI
*/ */
public function getFfpInfo(string $hash, int $index, int|string $attach_id): mixed public function getFfpInfo(string $hash, int $index, int|string $attach_id): mixed
{ {
global $bb_cfg;
if (!$response = CACHE('tr_cache')->get("ffprobe_m3u_$attach_id")) { if (!$response = CACHE('tr_cache')->get("ffprobe_m3u_$attach_id")) {
$response = new stdClass(); $response = new stdClass();
} }
@ -214,7 +206,7 @@ class TorrServerAPI
} }
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout($bb_cfg['torr_server']['timeout']); $curl->setTimeout(config()->get('torr_server.timeout'));
$curl->setHeader('Accept', 'application/json'); $curl->setHeader('Accept', 'application/json');
$curl->get($this->url . $this->endpoints['ffprobe'] . '/' . $hash . '/' . $index); $curl->get($this->url . $this->endpoints['ffprobe'] . '/' . $hash . '/' . $index);
@ -238,10 +230,8 @@ class TorrServerAPI
*/ */
private function getStream(string $hash): bool private function getStream(string $hash): bool
{ {
global $bb_cfg;
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout($bb_cfg['torr_server']['timeout']); $curl->setTimeout(config()->get('torr_server.timeout'));
$curl->setHeader('Accept', 'application/octet-stream'); $curl->setHeader('Accept', 'application/octet-stream');
$curl->get($this->url . $this->endpoints['stream'], ['link' => $hash]); $curl->get($this->url . $this->endpoints['stream'], ['link' => $hash]);

View file

@ -99,7 +99,7 @@ class Validate
*/ */
public static function email(string $email, bool $check_taken = true) public static function email(string $email, bool $check_taken = true)
{ {
global $lang, $userdata, $bb_cfg; global $lang, $userdata;
// Check for empty // Check for empty
if (empty($email)) { if (empty($email)) {
@ -117,7 +117,7 @@ class Validate
} }
// Extended email validation // Extended email validation
if ($bb_cfg['extended_email_validation']) { if (config()->get('extended_email_validation')) {
$validator = new EmailValidator(); $validator = new EmailValidator();
$multipleValidations = new MultipleValidationWithAnd([ $multipleValidations = new MultipleValidationWithAnd([
@ -157,7 +157,7 @@ class Validate
*/ */
public static function password(string $password, string $password_confirm) public static function password(string $password, string $password_confirm)
{ {
global $lang, $bb_cfg; global $lang;
// Check for empty // Check for empty
if (empty($password) || empty($password_confirm)) { if (empty($password) || empty($password_confirm)) {
@ -178,26 +178,26 @@ class Validate
} }
// Symbols check // Symbols check
if ($bb_cfg['password_symbols']) { if (config()->get('password_symbols')) {
// Numbers // Numbers
if ($bb_cfg['password_symbols']['nums']) { if (config()->get('password_symbols.nums')) {
if (!StringHelper::isContainsNums($password)) { if (!StringHelper::isContainsNums($password)) {
return $lang['CHOOSE_PASS_ERR_NUM']; return $lang['CHOOSE_PASS_ERR_NUM'];
} }
} }
// Letters // Letters
if ($bb_cfg['password_symbols']['letters']['lowercase']) { if (config()->get('password_symbols.letters.lowercase')) {
if (!StringHelper::isContainsLetters($password)) { if (!StringHelper::isContainsLetters($password)) {
return $lang['CHOOSE_PASS_ERR_LETTER']; return $lang['CHOOSE_PASS_ERR_LETTER'];
} }
} }
if ($bb_cfg['password_symbols']['letters']['uppercase']) { if (config()->get('password_symbols.letters.uppercase')) {
if (!StringHelper::isContainsLetters($password, true)) { if (!StringHelper::isContainsLetters($password, true)) {
return $lang['CHOOSE_PASS_ERR_LETTER_UPPERCASE']; return $lang['CHOOSE_PASS_ERR_LETTER_UPPERCASE'];
} }
} }
// Spec symbols // Spec symbols
if ($bb_cfg['password_symbols']['spec_symbols']) { if (config()->get('password_symbols.spec_symbols')) {
if (!StringHelper::isContainsSpecSymbols($password)) { if (!StringHelper::isContainsSpecSymbols($password)) {
return $lang['CHOOSE_PASS_ERR_SPEC_SYMBOL']; return $lang['CHOOSE_PASS_ERR_SPEC_SYMBOL'];
} }

Some files were not shown because too many files have changed in this diff Show more