refactor: rename config() to tp_config() to avoid Laravel conflicts

Systematically replace all config() function calls with tp_config() across 88 files to prevent naming conflicts with Laravel's illuminate/config package while maintaining backward compatibility.
This commit is contained in:
Yury Pikhtarev 2025-06-23 00:13:58 +04:00
commit 3848c6f2c0
No known key found for this signature in database
88 changed files with 614 additions and 614 deletions

View file

@ -595,8 +595,8 @@ $announceUrl = $bb_cfg['bt_announce_url'];
$dbHost = $bb_cfg['database']['host']; $dbHost = $bb_cfg['database']['host'];
// ✅ New way (recommended) // ✅ New way (recommended)
$announceUrl = config()->get('bt_announce_url'); $announceUrl = tp_config()->get('bt_announce_url');
$dbHost = config()->get('database.host'); $dbHost = tp_config()->get('database.host');
``` ```
### Key Configuration Changes ### Key Configuration Changes
@ -604,57 +604,57 @@ $dbHost = config()->get('database.host');
#### Basic Usage #### Basic Usage
```php ```php
// Get configuration values using dot notation // Get configuration values using dot notation
$siteName = config()->get('sitename'); $siteName = tp_config()->get('sitename');
$dbHost = config()->get('database.host'); $dbHost = tp_config()->get('database.host');
$cacheTimeout = config()->get('cache.timeout'); $cacheTimeout = tp_config()->get('cache.timeout');
// Get with default value if key doesn't exist // Get with default value if key doesn't exist
$maxUsers = config()->get('max_users_online', 100); $maxUsers = tp_config()->get('max_users_online', 100);
$debugMode = config()->get('debug.enabled', false); $debugMode = tp_config()->get('debug.enabled', false);
``` ```
#### Setting Values #### Setting Values
```php ```php
// Set configuration values // Set configuration values
config()->set('sitename', 'My Awesome Tracker'); tp_config()->set('sitename', 'My Awesome Tracker');
config()->set('database.port', 3306); tp_config()->set('database.port', 3306);
config()->set('cache.enabled', true); tp_config()->set('cache.enabled', true);
``` ```
#### Working with Sections #### Working with Sections
```php ```php
// Get entire configuration section // Get entire configuration section
$dbConfig = config()->getSection('database'); $dbConfig = tp_config()->getSection('database');
$trackerConfig = config()->getSection('tracker'); $trackerConfig = tp_config()->getSection('tracker');
// Check if configuration exists // Check if configuration exists
if (config()->has('bt_announce_url')) { if (tp_config()->has('bt_announce_url')) {
$announceUrl = config()->get('bt_announce_url'); $announceUrl = tp_config()->get('bt_announce_url');
} }
``` ```
### Common Configuration Mappings ### Common Configuration Mappings
| Old Syntax | New Syntax | | Old Syntax | New Syntax |
|------------|------------| |------------|---------------------------------------|
| `$bb_cfg['sitename']` | `config()->get('sitename')` | | `$bb_cfg['sitename']` | `tp_config()->get('sitename')` |
| `$bb_cfg['database']['host']` | `config()->get('database.host')` | | `$bb_cfg['database']['host']` | `tp_config()->get('database.host')` |
| `$bb_cfg['tracker']['enabled']` | `config()->get('tracker.enabled')` | | `$bb_cfg['tracker']['enabled']` | `tp_config()->get('tracker.enabled')` |
| `$bb_cfg['cache']['timeout']` | `config()->get('cache.timeout')` | | `$bb_cfg['cache']['timeout']` | `tp_config()->get('cache.timeout')` |
| `$bb_cfg['torr_server']['url']` | `config()->get('torr_server.url')` | | `$bb_cfg['torr_server']['url']` | `tp_config()->get('torr_server.url')` |
### Magic Methods Support ### Magic Methods Support
```php ```php
// Magic getter // Magic getter
$siteName = config()->sitename; $siteName = tp_config()->sitename;
$dbHost = config()->{'database.host'}; $dbHost = tp_config()->{'database.host'};
// Magic setter // Magic setter
config()->sitename = 'New Site Name'; tp_config()->sitename = 'New Site Name';
config()->{'database.port'} = 3306; tp_config()->{'database.port'} = 3306;
// Magic isset // Magic isset
if (isset(config()->bt_announce_url)) { if (isset(tp_config()->bt_announce_url)) {
// Configuration exists // Configuration exists
} }
``` ```
@ -804,7 +804,7 @@ _e('WELCOME_MESSAGE'); // Same as: echo __('WELCOME_MESSAGE')
_e('USER_ONLINE', 'Online'); // With default value _e('USER_ONLINE', 'Online'); // With default value
// ✅ Common usage patterns // ✅ Common usage patterns
$title = __('PAGE_TITLE', config()->get('sitename')); $title = __('PAGE_TITLE', tp_config()->get('sitename'));
$error = __('ERROR.INVALID_INPUT', 'Invalid input'); $error = __('ERROR.INVALID_INPUT', 'Invalid input');
``` ```
@ -1113,8 +1113,8 @@ $environment = [
- **New Implementation**: Uses Nette Database v3.2 with improved API requiring code updates - **New Implementation**: Uses Nette Database v3.2 with improved API requiring code updates
### Deprecated Functions ### Deprecated Functions
- `get_config()` → Use `config()->get()` - `get_config()` → Use `tp_config()->get()`
- `set_config()` → Use `config()->set()` - `set_config()` → Use `tp_config()->set()`
- Direct `$bb_cfg` access → Use `config()` methods - Direct `$bb_cfg` access → Use `config()` methods
### Deprecated Patterns ### Deprecated Patterns
@ -1139,11 +1139,11 @@ $environment = [
### Configuration Management ### Configuration Management
```php ```php
// ✅ Always provide defaults // ✅ Always provide defaults
$timeout = config()->get('api.timeout', 30); $timeout = tp_config()->get('api.timeout', 30);
// ✅ Use type hints // ✅ Use type hints
function getMaxUploadSize(): int { function getMaxUploadSize(): int {
return (int) config()->get('upload.max_size', 10485760); return (int) tp_config()->get('upload.max_size', 10485760);
} }
// ✅ Cache frequently used values // ✅ Cache frequently used values
@ -1151,7 +1151,7 @@ class TrackerService {
private string $announceUrl; private string $announceUrl;
public function __construct() { public function __construct() {
$this->announceUrl = config()->get('bt_announce_url'); $this->announceUrl = tp_config()->get('bt_announce_url');
} }
} }
``` ```
@ -1221,7 +1221,7 @@ function setupCustomCensoring(): void {
```php ```php
// ✅ Graceful error handling // ✅ Graceful error handling
try { try {
$dbConfig = config()->getSection('database'); $dbConfig = tp_config()->getSection('database');
// Database operations // Database operations
} catch (Exception $e) { } catch (Exception $e) {
error_log("Database configuration error: " . $e->getMessage()); error_log("Database configuration error: " . $e->getMessage());
@ -1232,7 +1232,7 @@ try {
### Performance Optimization ### Performance Optimization
```php ```php
// ✅ Minimize configuration calls in loops // ✅ Minimize configuration calls in loops
$cacheEnabled = config()->get('cache.enabled', false); $cacheEnabled = tp_config()->get('cache.enabled', false);
for ($i = 0; $i < 1000; $i++) { for ($i = 0; $i < 1000; $i++) {
if ($cacheEnabled) { if ($cacheEnabled) {
// Use cached value // Use cached value
@ -1244,12 +1244,12 @@ for ($i = 0; $i < 1000; $i++) {
```php ```php
// ✅ Validate configuration values // ✅ Validate configuration values
$maxFileSize = min( $maxFileSize = min(
config()->get('upload.max_size', 1048576), tp_config()->get('upload.max_size', 1048576),
1048576 * 100 // Hard limit: 100MB 1048576 * 100 // Hard limit: 100MB
); );
// ✅ Sanitize user-configurable values // ✅ Sanitize user-configurable values
$siteName = htmlspecialchars(config()->get('sitename', 'TorrentPier')); $siteName = htmlspecialchars(tp_config()->get('sitename', 'TorrentPier'));
``` ```
### Testing and Quality Assurance ### Testing and Quality Assurance

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 . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY u.username ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
case 'attachments': case 'attachments':
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
case 'filesize': case 'filesize':
$order_by = 'ORDER BY total_size ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY total_size ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_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 . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_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 . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
case 'comment': case 'comment':
$order_by = 'ORDER BY a.comment ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY a.comment ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
case 'extension': case 'extension':
$order_by = 'ORDER BY a.extension ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY a.extension ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
case 'filesize': case 'filesize':
$order_by = 'ORDER BY a.filesize ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY a.filesize ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
case 'downloads': case 'downloads':
$order_by = 'ORDER BY a.download_count ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY a.download_count ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
case 'post_time': case 'post_time':
$order_by = 'ORDER BY a.filetime ' . $sort_order . ' LIMIT ' . $start . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY a.filetime ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_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 . ', ' . config()->get('topics_per_page'); $order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . tp_config()->get('topics_per_page');
break; break;
} }
} }
@ -470,8 +470,8 @@ if ($view === 'attachments') {
} }
// Generate Pagination // Generate Pagination
if ($do_pagination && $total_rows > config()->get('topics_per_page')) { if ($do_pagination && $total_rows > tp_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, config()->get('topics_per_page'), $start); generate_pagination('admin_attach_cp.php?view=' . $view . '&amp;mode=' . $mode . '&amp;order=' . $sort_order . '&amp;uid=' . $uid, $total_rows, tp_config()->get('topics_per_page'), $start);
} }
print_page('admin_attach_cp.tpl', 'admin'); print_page('admin_attach_cp.tpl', 'admin');

View file

@ -39,7 +39,7 @@ if (!$result = DB()->sql_query($sql)) {
} }
} }
$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>'; $s_mess = $lang['SITEMAP_CREATED'] . ': <b>' . bb_date($new['sitemap_time'], tp_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 . config()->get('smilies_path'); $pathToSmilesDir = BB_ROOT . tp_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']) && (config()->get('terms') !== $_POST['message'])) { if (isset($_POST['post']) && (tp_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' => config()->get('ext_link_new_win'), 'EXT_LINK_NW' => tp_config()->get('ext_link_new_win'),
'MESSAGE' => $preview ? $_POST['message'] : config()->get('terms'), 'MESSAGE' => $preview ? $_POST['message'] : tp_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) * config()->get('topics_per_page')); $offset = (($page - 1) * tp_config()->get('topics_per_page'));
} }
$limit = "LIMIT $offset, " . config()->get('topics_per_page'); $limit = "LIMIT $offset, " . tp_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'] / config()->get('topics_per_page')); $num_pages = ceil($total_pages['total'] / tp_config()->get('topics_per_page'));
$pagination = ''; $pagination = '';

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)config()->get('board_disable'), 'ADMIN_LOCK' => (bool)tp_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(config()->get('board_startdate')); $start_date = bb_date(tp_config()->get('board_startdate'));
$boarddays = (TIMENOW - config()->get('board_startdate')) / 86400; $boarddays = (TIMENOW - tp_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(config()->get('avatars.upload_path'))) { if ($avatar_dir = opendir(tp_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(config()->get('avatars.upload_path') . $file); $avatar_dir_size += @filesize(tp_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' => config()->get('whois_info') . $reg_ip, 'U_WHOIS_IP' => tp_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' => config()->get('whois_info') . $guest_ip, 'U_WHOIS_IP' => tp_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)config()->get('announce_interval'); $announce_interval = (int)tp_config()->get('announce_interval');
$stat = []; $stat = [];
define('TMP_TRACKER_TABLE', 'tmp_tracker'); define('TMP_TRACKER_TABLE', 'tmp_tracker');

View file

@ -313,7 +313,7 @@ if ($lp_info) {
} }
// Limit active torrents // Limit active torrents
if (!isset(tp_config()->get('unlimited_users')[$user_id]) && tp_config()->get('tracker.limit_active_tor') && ((config()->get('tracker.limit_seed_count') && $seeder) || (config()->get('tracker.limit_leech_count') && !$seeder))) { if (!isset(tp_config()->get('unlimited_users')[$user_id]) && tp_config()->get('tracker.limit_active_tor') && ((tp_config()->get('tracker.limit_seed_count') && $seeder) || (tp_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
@ -321,7 +321,7 @@ if ($lp_info) {
AND topic_id != $topic_id"; AND topic_id != $topic_id";
if (!$seeder && tp_config()->get('tracker.leech_expire_factor') && $user_ratio < 0.5) { if (!$seeder && tp_config()->get('tracker.leech_expire_factor') && $user_ratio < 0.5) {
$sql .= " AND update_time > " . (TIMENOW - 60 * config()->get('tracker.leech_expire_factor')); $sql .= " AND update_time > " . (TIMENOW - 60 * tp_config()->get('tracker.leech_expire_factor'));
} }
$sql .= " GROUP BY user_id"; $sql .= " GROUP BY user_id";
@ -335,7 +335,7 @@ if ($lp_info) {
} }
// Limit concurrent IPs // Limit concurrent IPs
if (config()->get('tracker.limit_concurrent_ips') && ((config()->get('tracker.limit_seed_ips') && $seeder) || (config()->get('tracker.limit_leech_ips') && !$seeder))) { if (tp_config()->get('tracker.limit_concurrent_ips') && ((tp_config()->get('tracker.limit_seed_ips') && $seeder) || (tp_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
@ -343,16 +343,16 @@ if ($lp_info) {
AND seeder = $seeder AND seeder = $seeder
AND $ip_version != '$ip_sql'"; AND $ip_version != '$ip_sql'";
if (!$seeder && config()->get('tracker.leech_expire_factor')) { if (!$seeder && tp_config()->get('tracker.leech_expire_factor')) {
$sql .= " AND update_time > " . (TIMENOW - 60 * config()->get('tracker.leech_expire_factor')); $sql .= " AND update_time > " . (TIMENOW - 60 * tp_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 && config()->get('tracker.limit_seed_ips') && $row['ips'] >= config()->get('tracker.limit_seed_ips')) { if ($seeder && tp_config()->get('tracker.limit_seed_ips') && $row['ips'] >= tp_config()->get('tracker.limit_seed_ips')) {
msg_die('You can seed only from ' . config()->get('tracker.limit_seed_ips') . " IP's"); msg_die('You can seed only from ' . tp_config()->get('tracker.limit_seed_ips') . " IP's");
} elseif (!$seeder && config()->get('tracker.limit_leech_ips') && $row['ips'] >= config()->get('tracker.limit_leech_ips')) { } elseif (!$seeder && tp_config()->get('tracker.limit_leech_ips') && $row['ips'] >= tp_config()->get('tracker.limit_leech_ips')) {
msg_die('You can leech only from ' . config()->get('tracker.limit_leech_ips') . " IP's"); msg_die('You can leech only from ' . tp_config()->get('tracker.limit_leech_ips') . " IP's");
} }
} }
} }
@ -376,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 (config()->get('tracker.gold_silver_enabled') && $down_add) { if (tp_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
@ -386,7 +386,7 @@ if (config()->get('tracker.gold_silver_enabled') && $down_add) {
} }
// Freeleech // Freeleech
if (config()->get('tracker.freeleech') && $down_add) { if (tp_config()->get('tracker.freeleech') && $down_add) {
$down_add = 0; $down_add = 0;
} }
@ -464,8 +464,8 @@ $output = CACHE('tr_cache')->get(PEERS_LIST_PREFIX . $topic_id);
if (!$output) { if (!$output) {
// Retrieve peers // Retrieve peers
$numwant = (int)config()->get('tracker.numwant'); $numwant = (int)tp_config()->get('tracker.numwant');
$compact_mode = (config()->get('tracker.compact_mode') || !empty($compact)); $compact_mode = (tp_config()->get('tracker.compact_mode') || !empty($compact));
$rowset = DB()->fetch_rowset(" $rowset = DB()->fetch_rowset("
SELECT ip, ipv6, port SELECT ip, ipv6, port
@ -510,7 +510,7 @@ if (!$output) {
$seeders = $leechers = $client_completed = 0; $seeders = $leechers = $client_completed = 0;
if (config()->get('tracker.scrape')) { if (tp_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

@ -80,7 +80,7 @@ $config = \TorrentPier\Config::init($bb_cfg);
* *
* @return \TorrentPier\Config * @return \TorrentPier\Config
*/ */
function config(): \TorrentPier\Config function tp_config(): \TorrentPier\Config
{ {
return \TorrentPier\Config::getInstance(); return \TorrentPier\Config::getInstance();
} }
@ -153,14 +153,14 @@ if (APP_ENV === 'development') {
/** /**
* Server variables initialize * Server variables initialize
*/ */
$server_protocol = config()->get('cookie_secure') ? 'https://' : 'http://'; $server_protocol = tp_config()->get('cookie_secure') ? 'https://' : 'http://';
$server_port = in_array((int)config()->get('server_port'), [80, 443], true) ? '' : ':' . config()->get('server_port'); $server_port = in_array((int)tp_config()->get('server_port'), [80, 443], true) ? '' : ':' . tp_config()->get('server_port');
define('FORUM_PATH', config()->get('script_path')); define('FORUM_PATH', tp_config()->get('script_path'));
define('FULL_URL', $server_protocol . config()->get('server_name') . $server_port . config()->get('script_path')); define('FULL_URL', $server_protocol . tp_config()->get('server_name') . $server_port . tp_config()->get('script_path'));
unset($server_protocol, $server_port); unset($server_protocol, $server_port);
// Initialize the new DB factory with database configuration // Initialize the new DB factory with database configuration
TorrentPier\Database\DatabaseFactory::init(config()->get('db'), config()->get('db_alias', [])); TorrentPier\Database\DatabaseFactory::init(tp_config()->get('db'), tp_config()->get('db_alias', []));
/** /**
* Get the Database instance * Get the Database instance
@ -174,7 +174,7 @@ function DB(string $db_alias = 'db'): \TorrentPier\Database\Database
} }
// Initialize Unified Cache System // Initialize Unified Cache System
TorrentPier\Cache\UnifiedCacheSystem::getInstance(config()->all()); TorrentPier\Cache\UnifiedCacheSystem::getInstance(tp_config()->all());
/** /**
* Get cache manager instance (replaces legacy cache system) * Get cache manager instance (replaces legacy cache system)
@ -194,7 +194,7 @@ function CACHE(string $cache_name): \TorrentPier\Cache\CacheManager
*/ */
function datastore(): \TorrentPier\Cache\DatastoreManager function datastore(): \TorrentPier\Cache\DatastoreManager
{ {
return TorrentPier\Cache\UnifiedCacheSystem::getInstance()->getDatastore(config()->get('datastore_type', 'file')); return TorrentPier\Cache\UnifiedCacheSystem::getInstance()->getDatastore(tp_config()->get('datastore_type', 'file'));
} }
/** /**
@ -418,9 +418,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(config()->get('announce_interval') * (0.85 * config()->get('tracker.expire_factor')))); define('PEER_HASH_EXPIRE', round(tp_config()->get('announce_interval') * (0.85 * tp_config()->get('tracker.expire_factor'))));
define('PEERS_LIST_EXPIRE', round(config()->get('announce_interval') * 0.7)); define('PEERS_LIST_EXPIRE', round(tp_config()->get('announce_interval') * 0.7));
define('SCRAPE_LIST_EXPIRE', round(config()->get('scrape_interval') * 0.7)); define('SCRAPE_LIST_EXPIRE', round(tp_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_');

View file

@ -174,7 +174,7 @@ if (!IS_AM && ($attachment['mimetype'] === TORRENT_MIMETYPE)) {
$row = DB()->sql_fetchrow($result); $row = DB()->sql_fetchrow($result);
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'])) { if (isset(tp_config()->get('tor_frozen')[$row['tor_status']]) && !(isset(tp_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']]);
} }
@ -223,7 +223,7 @@ switch ($download_mode) {
header('Location: ' . $url); header('Location: ' . $url);
exit; exit;
case INLINE_LINK: case INLINE_LINK:
if (IS_GUEST && !config()->get('captcha.disabled') && !bb_captcha('check')) { if (IS_GUEST && !tp_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

@ -37,11 +37,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(config()->get('atom.path') . '/f/' . $id . '.atom') && filemtime(config()->get('atom.path') . '/f/' . $id . '.atom') > $timecheck) { if (is_file(tp_config()->get('atom.path') . '/f/' . $id . '.atom') && filemtime(tp_config()->get('atom.path') . '/f/' . $id . '.atom') > $timecheck) {
redirect(config()->get('atom.url') . '/f/' . $id . '.atom'); redirect(tp_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(config()->get('atom.url') . '/f/' . $id . '.atom'); redirect(tp_config()->get('atom.url') . '/f/' . $id . '.atom');
} else { } else {
bb_simple_die($lang['ATOM_NO_FORUM']); bb_simple_die($lang['ATOM_NO_FORUM']);
} }
@ -55,11 +55,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(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) { if (is_file(tp_config()->get('atom.path') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') && filemtime(tp_config()->get('atom.path') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') > $timecheck) {
redirect(config()->get('atom.url') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom'); redirect(tp_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(config()->get('atom.url') . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom'); redirect(tp_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

@ -17,7 +17,7 @@ if (!defined('IN_TORRENTPIER')) {
// Start session management // Start session management
$user->session_start(); $user->session_start();
if (config()->get('bt_disable_dht') && IS_GUEST) { if (tp_config()->get('bt_disable_dht') && IS_GUEST) {
bb_die($lang['BT_PRIVATE_TRACKER'], 403); bb_die($lang['BT_PRIVATE_TRACKER'], 403);
} }
@ -58,7 +58,7 @@ if (!is_file($file_path)) {
} }
$file_contents = file_get_contents($file_path); $file_contents = file_get_contents($file_path);
if (config()->get('flist_max_files')) { if (tp_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;
@ -68,8 +68,8 @@ if (config()->get('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 > config()->get('flist_max_files')) { if ($file_count > tp_config()->get('flist_max_files')) {
bb_die(sprintf($lang['BT_FLIST_LIMIT'], config()->get('flist_max_files'), $file_count), 410); bb_die(sprintf($lang['BT_FLIST_LIMIT'], tp_config()->get('flist_max_files'), $file_count), 410);
} }
} }

View file

@ -28,7 +28,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 = config()->get('group_members_per_page'); $per_page = tp_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;
@ -172,7 +172,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 (config()->get('group_send_email')) { if (tp_config()->get('group_send_email')) {
// Sending email // Sending email
$emailer = new TorrentPier\Emailer(); $emailer = new TorrentPier\Emailer();
@ -228,7 +228,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 (config()->get('group_send_email')) { if (tp_config()->get('group_send_email')) {
// Sending email // Sending email
$emailer = new TorrentPier\Emailer(); $emailer = new TorrentPier\Emailer();
@ -277,7 +277,7 @@ if (!$group_id) {
} }
} }
// Email users when they are approved // Email users when they are approved
if (!empty($_POST['approve']) && config()->get('group_send_email')) { if (!empty($_POST['approve']) && tp_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

@ -38,10 +38,10 @@ if ($group_id) {
if ($is_moderator) { if ($is_moderator) {
// Avatar // Avatar
if ($submit) { if ($submit) {
if (!empty($_FILES['avatar']['name']) && config()->get('group_avatars.up_allowed')) { if (!empty($_FILES['avatar']['name']) && tp_config()->get('group_avatars.up_allowed')) {
$upload = new TorrentPier\Legacy\Common\Upload(); $upload = new TorrentPier\Legacy\Common\Upload();
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']])) { if ($upload->init(tp_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 {
@ -79,7 +79,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'], config()->get('group_avatars.max_width'), config()->get('group_avatars.max_height'), humn_size(config()->get('group_avatars.max_size'))), 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], tp_config()->get('group_avatars.max_width'), tp_config()->get('group_avatars.max_height'), humn_size(tp_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

@ -34,12 +34,12 @@ $datastore->enqueue([
'cat_forums' 'cat_forums'
]); ]);
if (config()->get('show_latest_news')) { if (tp_config()->get('show_latest_news')) {
$datastore->enqueue([ $datastore->enqueue([
'latest_news' 'latest_news'
]); ]);
} }
if (config()->get('show_network_news')) { if (tp_config()->get('show_network_news')) {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -49,7 +49,7 @@ if (config()->get('show_network_news')) {
$user->session_start(); $user->session_start();
// Set meta description // Set meta description
$page_cfg['meta_description'] = config()->get('site_desc'); $page_cfg['meta_description'] = tp_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;
@ -60,7 +60,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_' . config()->get('default_lang')); caching_output(IS_GUEST, 'send', REQUESTED_PAGE . '_guest_' . tp_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));
@ -265,7 +265,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'], config()->get('last_post_date_format')), 'LAST_POST_TIME' => bb_date($f['last_post_time'], tp_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']]),
]); ]);
} }
@ -281,7 +281,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' => config()->get('gender') ? sprintf( 'TOTAL_GENDER' => tp_config()->get('gender') ? sprintf(
$lang['USERS_TOTAL_GENDER'], $lang['USERS_TOTAL_GENDER'],
$stats['male'], $stats['male'],
$stats['female'], $stats['female'],
@ -290,22 +290,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' => config()->get('tor_stats') ? sprintf( 'TORRENTS_STAT' => tp_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' => config()->get('tor_stats') ? sprintf( 'PEERS_STAT' => tp_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' => config()->get('tor_stats') ? sprintf( 'SPEED_STAT' => tp_config()->get('tor_stats') ? sprintf(
$lang['SPEED_STAT'], $lang['SPEED_STAT'],
humn_size($stats['speed']) . '/s' humn_size($stats['speed']) . '/s'
) : '', ) : '',
'SHOW_MOD_INDEX' => config()->get('show_mod_index'), 'SHOW_MOD_INDEX' => tp_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'],
@ -318,19 +318,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(config()->get('atom.path') . '/f/0.atom') ? make_url(config()->get('atom.url') . '/f/0.atom') : false, 'U_ATOM_FEED' => is_file(tp_config()->get('atom.path') . '/f/0.atom') ? make_url(tp_config()->get('atom.url') . '/f/0.atom') : false,
'SHOW_LAST_TOPIC' => $show_last_topic, 'SHOW_LAST_TOPIC' => $show_last_topic,
'BOARD_START' => config()->get('show_board_start_index') ? ($lang['BOARD_STARTED'] . ':&nbsp;' . '<b>' . bb_date(config()->get('board_startdate')) . '</b>') : false, 'BOARD_START' => tp_config()->get('show_board_start_index') ? ($lang['BOARD_STARTED'] . ':&nbsp;' . '<b>' . bb_date(tp_config()->get('board_startdate')) . '</b>') : false,
]); ]);
// Set tpl vars for bt_userdata // Set tpl vars for bt_userdata
if (config()->get('bt_show_dl_stat_on_index') && !IS_GUEST) { if (tp_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 (config()->get('show_latest_news')) { if (tp_config()->get('show_latest_news')) {
$latest_news = $datastore->get('latest_news'); $latest_news = $datastore->get('latest_news');
if ($latest_news === false) { if ($latest_news === false) {
$datastore->update('latest_news'); $datastore->update('latest_news');
@ -346,7 +346,7 @@ if (config()->get('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(censor()->censorString($news['topic_title']), config()->get('max_news_title')), 'NEWS_TITLE' => str_short(censor()->censorString($news['topic_title']), tp_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']),
]); ]);
@ -354,7 +354,7 @@ if (config()->get('show_latest_news')) {
} }
// Network news // Network news
if (config()->get('show_network_news')) { if (tp_config()->get('show_network_news')) {
$network_news = $datastore->get('network_news'); $network_news = $datastore->get('network_news');
if ($network_news === false) { if ($network_news === false) {
$datastore->update('network_news'); $datastore->update('network_news');
@ -370,14 +370,14 @@ if (config()->get('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(censor()->censorString($net['topic_title']), config()->get('max_net_title')), 'NEWS_TITLE' => str_short(censor()->censorString($net['topic_title']), tp_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 (config()->get('birthday_check_day') && config()->get('birthday_enabled')) { if (tp_config()->get('birthday_check_day') && tp_config()->get('birthday_enabled')) {
$week_list = $today_list = []; $week_list = $today_list = [];
$week_all = $today_all = false; $week_all = $today_all = false;
@ -391,9 +391,9 @@ if (config()->get('birthday_check_day') && config()->get('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'], config()->get('birthday_check_day'), implode(', ', $week_list)) . $week_all; $week_list = sprintf($lang['BIRTHDAY_WEEK'], tp_config()->get('birthday_check_day'), implode(', ', $week_list)) . $week_all;
} else { } else {
$week_list = sprintf($lang['NOBIRTHDAY_WEEK'], config()->get('birthday_check_day')); $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], tp_config()->get('birthday_check_day'));
} }
if (!empty($stats['birthday_today_list'])) { if (!empty($stats['birthday_today_list'])) {

View file

@ -66,7 +66,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 < config()->get('invalid_logins')) { if ($need_captcha < tp_config()->get('invalid_logins')) {
$need_captcha = false; $need_captcha = false;
} }
} }
@ -83,13 +83,13 @@ if (isset($_POST['login'])) {
} }
// Captcha // Captcha
if ($need_captcha && !config()->get('captcha.disabled') && !bb_captcha('check')) { if ($need_captcha && !tp_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')) ? config()->get('first_logon_redirect_url') : $redirect_url; $redirect_url = (defined('FIRST_LOGON')) ? tp_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);
@ -104,7 +104,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 > config()->get('invalid_logins')) { if ($login_err > tp_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);
@ -121,7 +121,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 && !config()->get('captcha.disabled')) ? bb_captcha('get') : '', 'CAPTCHA_HTML' => ($need_captcha && !tp_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

@ -57,26 +57,26 @@ $select_sort_role .= '</select>';
switch ($mode) { switch ($mode) {
case 'username': case 'username':
$order_by = "username $sort_order LIMIT $start, " . config()->get('topics_per_page'); $order_by = "username $sort_order LIMIT $start, " . tp_config()->get('topics_per_page');
break; break;
case 'location': case 'location':
$order_by = "user_from $sort_order LIMIT $start, " . config()->get('topics_per_page'); $order_by = "user_from $sort_order LIMIT $start, " . tp_config()->get('topics_per_page');
break; break;
case 'posts': case 'posts':
$order_by = "user_posts $sort_order LIMIT $start, " . config()->get('topics_per_page'); $order_by = "user_posts $sort_order LIMIT $start, " . tp_config()->get('topics_per_page');
break; break;
case 'email': case 'email':
$order_by = "user_email $sort_order LIMIT $start, " . config()->get('topics_per_page'); $order_by = "user_email $sort_order LIMIT $start, " . tp_config()->get('topics_per_page');
break; break;
case 'website': case 'website':
$order_by = "user_website $sort_order LIMIT $start, " . config()->get('topics_per_page'); $order_by = "user_website $sort_order LIMIT $start, " . tp_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, " . config()->get('topics_per_page'); $order_by = "user_regdate $sort_order LIMIT $start, " . tp_config()->get('topics_per_page');
break; break;
} }
@ -137,7 +137,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, config()->get('topics_per_page'), $start); generate_pagination($paginationurl, $total_members, tp_config()->get('topics_per_page'), $start);
} }
DB()->sql_freeresult($result); DB()->sql_freeresult($result);
} }

View file

@ -227,16 +227,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(',', config()->get('latest_news_forum_id'))); $news_forums = array_flip(explode(',', tp_config()->get('latest_news_forum_id')));
if (isset($news_forums[$forum_id]) && config()->get('show_latest_news') && $result) { if (isset($news_forums[$forum_id]) && tp_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(',', config()->get('network_news_forum_id'))); $net_forums = array_flip(explode(',', tp_config()->get('network_news_forum_id')));
if (isset($net_forums[$forum_id]) && config()->get('show_network_news') && $result) { if (isset($net_forums[$forum_id]) && tp_config()->get('show_network_news') && $result) {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -262,16 +262,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(',', config()->get('latest_news_forum_id'))); $news_forums = array_flip(explode(',', tp_config()->get('latest_news_forum_id')));
if ((isset($news_forums[$forum_id]) || isset($news_forums[$new_forum_id])) && config()->get('show_latest_news') && $result) { if ((isset($news_forums[$forum_id]) || isset($news_forums[$new_forum_id])) && tp_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(',', config()->get('network_news_forum_id'))); $net_forums = array_flip(explode(',', tp_config()->get('network_news_forum_id')));
if ((isset($net_forums[$forum_id]) || isset($net_forums[$new_forum_id])) && config()->get('show_network_news') && $result) { if ((isset($net_forums[$forum_id]) || isset($net_forums[$new_forum_id])) && tp_config()->get('show_network_news') && $result) {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);
@ -561,7 +561,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'], config()->get('post_date_format')); $post_date = bb_date($postrow[$i]['post_time'], tp_config()->get('post_date_format'));
$message = $postrow[$i]['post_text']; $message = $postrow[$i]['post_text'];

View file

@ -14,7 +14,7 @@ if (!defined('IN_TORRENTPIER')) {
require __DIR__ . '/../common.php'; require __DIR__ . '/../common.php';
} }
if (!config()->get('torr_server.enabled')) { if (!tp_config()->get('torr_server.enabled')) {
redirect('index.php'); redirect('index.php');
} }
@ -25,7 +25,7 @@ $validFormats = [
]; ];
// Start session management // Start session management
$user->session_start(['req_login' => config()->get('torr_server.disable_for_guest')]); $user->session_start(['req_login' => tp_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

@ -50,8 +50,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 - config()->get('poll_max_days') * 86400) { if ($t_data['topic_time'] < TIMENOW - tp_config()->get('poll_max_days') * 86400) {
bb_die(sprintf(__('NEW_POLL_DAYS'), config()->get('poll_max_days'))); bb_die(sprintf(__('NEW_POLL_DAYS'), tp_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(__('CANNOT_DELETE_POLL')); bb_die(__('CANNOT_DELETE_POLL'));

View file

@ -225,7 +225,7 @@ if (!$is_auth[$is_auth_type]) {
} }
if ($mode == 'new_rel') { if ($mode == 'new_rel') {
if ($tor_status = implode(',', config()->get('tor_cannot_new'))) { if ($tor_status = implode(',', tp_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']}
@ -236,7 +236,7 @@ if ($mode == 'new_rel') {
$topics = ''; $topics = '';
foreach ($sql as $row) { foreach ($sql as $row) {
$topics .= config()->get('tor_icons')[$row['tor_status']] . '<a href="' . TOPIC_URL . $row['topic_id'] . '">' . $row['topic_title'] . '</a><div class="spacer_12"></div>'; $topics .= tp_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']);
@ -247,9 +247,9 @@ if ($mode == 'new_rel') {
} }
// Disallowed release editing with a certain status // Disallowed release editing with a certain status
if (!empty(config()->get('tor_cannot_edit')) && $post_info['allow_reg_tracker'] && $post_data['first_post'] && !IS_AM) { if (!empty(tp_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(',', config()->get('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(',', tp_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']] . '">' . config()->get('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']] . '">' . tp_config()->get('tor_icons')[$tor_status['tor_status']] . '&nbsp;' . $lang['TOR_STATUS_NAME'][$tor_status['tor_status']] . '</span>.');
} }
} }
@ -285,7 +285,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 " . config()->get('posts_per_page'); LIMIT " . tp_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;
@ -295,7 +295,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'], config()->get('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'], tp_config()->get('post_date_format')) . '</a>',
'MESSAGE' => get_parsed_post($row) 'MESSAGE' => get_parsed_post($row)
]); ]);
} }
@ -378,9 +378,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') && config()->get('bt_newtopic_auto_reg') && !$error_msg) { if (defined('TORRENT_ATTACH_ID') && tp_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 (config()->get('premod')) { if (tp_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']) {
@ -472,7 +472,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('#(?<=[\?&;]' . config()->get('passkey_key') . '=)[a-zA-Z0-9]#', 'passkey', $message); $message = preg_replace('#(?<=[\?&;]' . tp_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);
@ -622,7 +622,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 && !config()->get('captcha.disabled')) ? bb_captcha('get') : '', 'CAPTCHA_HTML' => (IS_GUEST && !tp_config()->get('captcha.disabled')) ? bb_captcha('get') : '',
'SUBJECT' => $subject, 'SUBJECT' => $subject,
'MESSAGE' => $message, 'MESSAGE' => $message,

View file

@ -28,7 +28,7 @@ $page_cfg['load_tpl_vars'] = [
// //
// Is PM disabled? // Is PM disabled?
// //
if (config()->get('privmsg_disable')) { if (tp_config()->get('privmsg_disable')) {
bb_die('PM_DISABLED'); bb_die('PM_DISABLED');
} }
@ -63,13 +63,13 @@ $user->session_start(['req_login' => true]);
$template->assign_vars([ $template->assign_vars([
'IN_PM' => true, 'IN_PM' => true,
'QUICK_REPLY' => config()->get('show_quick_reply') && $folder == 'inbox' && $mode == 'read', 'QUICK_REPLY' => tp_config()->get('show_quick_reply') && $folder == 'inbox' && $mode == 'read',
]); ]);
// //
// Set mode for quick reply // Set mode for quick reply
// //
if (empty($mode) && config()->get('show_quick_reply') && $folder == 'inbox' && $preview) { if (empty($mode) && tp_config()->get('show_quick_reply') && $folder == 'inbox' && $preview) {
$mode = 'reply'; $mode = 'reply';
} }
@ -210,7 +210,7 @@ if ($mode == 'read') {
} }
if ($sent_info = DB()->sql_fetchrow($result)) { if ($sent_info = DB()->sql_fetchrow($result)) {
if (config()->get('max_sentbox_privmsgs') && $sent_info['sent_items'] >= config()->get('max_sentbox_privmsgs')) { if (tp_config()->get('max_sentbox_privmsgs') && $sent_info['sent_items'] >= tp_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'] . "
@ -608,7 +608,7 @@ if ($mode == 'read') {
} }
if ($saved_info = DB()->sql_fetchrow($result)) { if ($saved_info = DB()->sql_fetchrow($result)) {
if (config()->get('max_savebox_privmsgs') && $saved_info['savebox_items'] >= config()->get('max_savebox_privmsgs')) { if (tp_config()->get('max_savebox_privmsgs') && $saved_info['savebox_items'] >= tp_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 . " )
@ -753,7 +753,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) < config()->get('flood_interval')) { if (($current_time - $last_post_time) < tp_config()->get('flood_interval')) {
bb_die($lang['FLOOD_ERROR']); bb_die($lang['FLOOD_ERROR']);
} }
} }
@ -806,11 +806,11 @@ if ($mode == 'read') {
} }
// Check smilies limit // Check smilies limit
if (config()->get('max_smilies_pm')) { if (tp_config()->get('max_smilies_pm')) {
$count_smilies = substr_count(bbcode2html($privmsg_message), '<img class="smile" src="' . config()->get('smilies_path')); $count_smilies = substr_count(bbcode2html($privmsg_message), '<img class="smile" src="' . tp_config()->get('smilies_path'));
if ($count_smilies > config()->get('max_smilies_pm')) { if ($count_smilies > tp_config()->get('max_smilies_pm')) {
$error = true; $error = true;
$error_msg .= ((!empty($error_msg)) ? '<br />' : '') . sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies_pm')); $error_msg .= ((!empty($error_msg)) ? '<br />' : '') . sprintf($lang['MAX_SMILIES_PER_POST'], tp_config()->get('max_smilies_pm'));
} }
} }
} }
@ -838,7 +838,7 @@ if ($mode == 'read') {
} }
if ($inbox_info = DB()->sql_fetchrow($result)) { if ($inbox_info = DB()->sql_fetchrow($result)) {
if (config()->get('max_inbox_privmsgs') && $inbox_info['inbox_items'] >= config()->get('max_inbox_privmsgs')) { if (tp_config()->get('max_inbox_privmsgs') && $inbox_info['inbox_items'] >= tp_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 . "
@ -906,7 +906,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'] && config()->get('pm_notify_enabled')) { if (bf($to_userdata['user_opt'], 'user_opt', 'user_notify_pm') && $to_userdata['user_active'] && tp_config()->get('pm_notify_enabled')) {
// Sending email // Sending email
$emailer = new TorrentPier\Emailer(); $emailer = new TorrentPier\Emailer();
@ -1256,7 +1256,7 @@ if ($mode == 'read') {
$msg_days = 0; $msg_days = 0;
} }
$sql .= $limit_msg_time . " ORDER BY pm.privmsgs_date DESC LIMIT $start, " . config()->get('topics_per_page'); $sql .= $limit_msg_time . " ORDER BY pm.privmsgs_date DESC LIMIT $start, " . tp_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;
@ -1312,11 +1312,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') ? config()->get("max_{$folder}_privmsgs") : null; $max_pm = ($folder != 'outbox') ? tp_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) * config()->get('privmsg_graphic_length')), config()->get('privmsg_graphic_length')); $box_limit_img_length = min(round(($pm_all_total / $max_pm) * tp_config()->get('privmsg_graphic_length')), tp_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');
@ -1414,7 +1414,7 @@ if ($mode == 'read') {
]); ]);
} while ($row = DB()->sql_fetchrow($result)); } while ($row = DB()->sql_fetchrow($result));
generate_pagination(PM_URL . "?folder=$folder", $pm_total, config()->get('topics_per_page'), $start); generate_pagination(PM_URL . "?folder=$folder", $pm_total, tp_config()->get('topics_per_page'), $start);
} else { } else {
$template->assign_block_vars('switch_no_messages', []); $template->assign_block_vars('switch_no_messages', []);
} }

View file

@ -24,7 +24,7 @@ $page_cfg['load_tpl_vars'] = [
]; ];
// Start session management // Start session management
$user->session_start(array('req_login' => config()->get('disable_search_for_guest'))); $user->session_start(array('req_login' => tp_config()->get('disable_search_for_guest')));
set_die_append_msg(); set_die_append_msg();
@ -293,7 +293,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, config()->get('disable_ft_search_in_posts')), 'TITLE_ONLY_CHBOX' => build_checkbox($title_only_key, $lang['SEARCH_TITLES_ONLY'], true, tp_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'),
@ -425,7 +425,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 || config()->get('disable_ft_search_in_posts'))); $title_match = ($text_match_sql && ($title_only_val || tp_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'])));
@ -437,7 +437,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 = config()->get('posts_per_page'); $per_page = tp_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
@ -598,7 +598,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'], config()->get('post_date_format')), 'POST_DATE' => bb_date($post['post_time'], tp_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' => '',
@ -617,7 +617,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 = config()->get('topics_per_page'); $per_page = tp_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
@ -743,7 +743,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 = (config()->get('show_dl_status_in_search') && !IS_GUEST); $join_dl = (tp_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,
@ -800,7 +800,7 @@ else {
'TOPIC_TITLE' => censor()->censorString($topic['topic_title']), 'TOPIC_TITLE' => censor()->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'], config()->get('posts_per_page')), 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], tp_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'],
@ -898,13 +898,13 @@ function fetch_search_ids($sql, $search_type = SEARCH_TYPE_POST)
function prevent_huge_searches($SQL) function prevent_huge_searches($SQL)
{ {
if (config()->get('limit_max_search_results')) { if (tp_config()->get('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'] > config()->get('limit_max_search_results')) { if ($row['rows_count'] > tp_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

@ -18,13 +18,13 @@ require INC_DIR . '/bbcode.php';
// Start session management // Start session management
$user->session_start(); $user->session_start();
if (!config()->get('terms') && !IS_ADMIN) { if (!tp_config()->get('terms') && !IS_ADMIN) {
redirect('index.php'); redirect('index.php');
} }
$template->assign_vars([ $template->assign_vars([
'TERMS_EDIT' => bbcode2html(sprintf($lang['TERMS_EMPTY_TEXT'], make_url('admin/admin_terms.php'))), 'TERMS_EDIT' => bbcode2html(sprintf($lang['TERMS_EMPTY_TEXT'], make_url('admin/admin_terms.php'))),
'TERMS_HTML' => bbcode2html(config()->get('terms')), 'TERMS_HTML' => bbcode2html(tp_config()->get('terms')),
]); ]);
print_page('terms.tpl'); print_page('terms.tpl');

View file

@ -22,7 +22,7 @@ $page_cfg['load_tpl_vars'] = [
]; ];
// Session start // Session start
$user->session_start(array('req_login' => config()->get('bt_tor_browse_only_reg'))); $user->session_start(array('req_login' => tp_config()->get('bt_tor_browse_only_reg')));
set_die_append_msg(); set_die_append_msg();
@ -33,7 +33,7 @@ $max_forums_selected = 50;
$title_match_max_len = 60; $title_match_max_len = 60;
$poster_name_max_len = 25; $poster_name_max_len = 25;
$tor_colspan = 12; // torrents table colspan with all columns $tor_colspan = 12; // torrents table colspan with all columns
$per_page = config()->get('topics_per_page'); $per_page = tp_config()->get('topics_per_page');
$tracker_url = basename(__FILE__); $tracker_url = basename(__FILE__);
$time_format = 'H:i'; $time_format = 'H:i';
@ -302,8 +302,8 @@ if (isset($_GET[$user_releases_key])) {
} }
// Random release // Random release
if (config()->get('tracker.random_release_button') && isset($_GET['random_release'])) { if (tp_config()->get('tracker.random_release_button') && isset($_GET['random_release'])) {
if ($random_release = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE tor_status NOT IN(" . implode(', ', array_keys(config()->get('tor_frozen'))) . ") ORDER BY RAND() LIMIT 1")) { if ($random_release = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE tor_status NOT IN(" . implode(', ', array_keys(tp_config()->get('tor_frozen'))) . ") ORDER BY RAND() LIMIT 1")) {
redirect(TOPIC_URL . $random_release['topic_id']); redirect(TOPIC_URL . $random_release['topic_id']);
} else { } else {
bb_die($lang['NO_MATCH']); bb_die($lang['NO_MATCH']);
@ -752,8 +752,8 @@ if ($allowed_forums) {
'MAGNET' => $tor_magnet, 'MAGNET' => $tor_magnet,
'TOR_TYPE' => is_gold($tor['tor_type']), 'TOR_TYPE' => is_gold($tor['tor_type']),
'TOR_FROZEN' => !IS_AM ? isset(config()->get('tor_frozen')[$tor['tor_status']]) : '', 'TOR_FROZEN' => !IS_AM ? isset(tp_config()->get('tor_frozen')[$tor['tor_status']]) : '',
'TOR_STATUS_ICON' => config()->get('tor_icons')[$tor['tor_status']], 'TOR_STATUS_ICON' => tp_config()->get('tor_icons')[$tor['tor_status']],
'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor['tor_status']], 'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor['tor_status']],
'TOR_SIZE_RAW' => $size, 'TOR_SIZE_RAW' => $size,
@ -822,9 +822,9 @@ $search_all_opt = '<option value="' . $search_all . '" value="fs-' . $search_all
$cat_forum_select = "\n" . '<select id="fs-main" style="width: 100%;" name="' . $forum_key . '[]" multiple size="' . $forum_select_size . "\">\n" . $search_all_opt . $opt . "</select>\n"; $cat_forum_select = "\n" . '<select id="fs-main" style="width: 100%;" name="' . $forum_key . '[]" multiple size="' . $forum_select_size . "\">\n" . $search_all_opt . $opt . "</select>\n";
// Status select // Status select
if (config()->get('tracker.search_by_tor_status')) { if (tp_config()->get('tracker.search_by_tor_status')) {
$statuses = '<table border="0" cellpadding="0" cellspacing="0">'; $statuses = '<table border="0" cellpadding="0" cellspacing="0">';
foreach (array_chunk(config()->get('tor_icons'), 2, true) as $statuses_part) { foreach (array_chunk(tp_config()->get('tor_icons'), 2, true) as $statuses_part) {
$statuses .= '<tr>'; $statuses .= '<tr>';
foreach ($statuses_part as $status_id => $status_styles) { foreach ($statuses_part as $status_id => $status_styles) {
$checked_status = in_array($status_id, $status) ? 'checked' : ''; $checked_status = in_array($status_id, $status) ? 'checked' : '';

View file

@ -124,7 +124,7 @@ if ($mark_read && !IS_GUEST) {
} }
// Subforums // Subforums
$show_subforums = config()->get('sf_on_first_page_only') ? !$start : true; $show_subforums = tp_config()->get('sf_on_first_page_only') ? !$start : true;
if (!$forums = $datastore->get('cat_forums')) { if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums'); $datastore->update('cat_forums');
@ -182,7 +182,7 @@ if (!$forum_data['forum_parent'] && isset($forums['f'][$forum_id]['subforums'])
$last_post_user = profile_url(['username' => $sf_data['sf_last_username'], 'user_id' => $sf_data['sf_last_user_id'], 'user_rank' => $sf_data['user_rank']]); $last_post_user = profile_url(['username' => $sf_data['sf_last_username'], 'user_id' => $sf_data['sf_last_user_id'], 'user_rank' => $sf_data['user_rank']]);
if ($sf_data['forum_last_post_id']) { if ($sf_data['forum_last_post_id']) {
$last_post = bb_date($sf_data['topic_last_post_time'], config()->get('last_post_date_format')); $last_post = bb_date($sf_data['topic_last_post_time'], tp_config()->get('last_post_date_format'));
$last_post .= "<br />$last_post_user"; $last_post .= "<br />$last_post_user";
$last_post .= '<a href="' . POST_URL . $sf_data['forum_last_post_id'] . '#' . $sf_data['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" class="icon2" alt="latest" title="' . $lang['VIEW_LATEST_POST'] . '" /></a>'; $last_post .= '<a href="' . POST_URL . $sf_data['forum_last_post_id'] . '#' . $sf_data['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" class="icon2" alt="latest" title="' . $lang['VIEW_LATEST_POST'] . '" /></a>';
} }
@ -206,7 +206,7 @@ if (!$forum_data['forum_parent'] && isset($forums['f'][$forum_id]['subforums'])
'LAST_TOPIC_ID' => $sf_data['last_topic_id'], 'LAST_TOPIC_ID' => $sf_data['last_topic_id'],
'LAST_TOPIC_TIP' => $sf_data['last_topic_title'], 'LAST_TOPIC_TIP' => $sf_data['last_topic_title'],
'LAST_TOPIC_TITLE' => str_short($sf_data['last_topic_title'], $last_topic_max_len), 'LAST_TOPIC_TITLE' => str_short($sf_data['last_topic_title'], $last_topic_max_len),
'LAST_POST_TIME' => bb_date($sf_data['topic_last_post_time'], config()->get('last_post_date_format')), 'LAST_POST_TIME' => bb_date($sf_data['topic_last_post_time'], tp_config()->get('last_post_date_format')),
'LAST_POST_ID' => $sf_data['forum_last_post_id'], 'LAST_POST_ID' => $sf_data['forum_last_post_id'],
'LAST_POST_USER' => $last_post_user, 'LAST_POST_USER' => $last_post_user,
'ICON_LATEST_REPLY' => $images['icon_latest_reply'] 'ICON_LATEST_REPLY' => $images['icon_latest_reply']
@ -220,16 +220,16 @@ unset($rowset);
$datastore->rm('cat_forums'); $datastore->rm('cat_forums');
// Topics per page // Topics per page
$topics_per_page = config()->get('topics_per_page'); $topics_per_page = tp_config()->get('topics_per_page');
$select_tpp = ''; $select_tpp = '';
if ($is_auth['auth_mod']) { if ($is_auth['auth_mod']) {
if ($req_tpp = abs((int)(@$_REQUEST['tpp'])) and in_array($req_tpp, config()->get('allowed_topics_per_page'))) { if ($req_tpp = abs((int)(@$_REQUEST['tpp'])) and in_array($req_tpp, tp_config()->get('allowed_topics_per_page'))) {
$topics_per_page = $req_tpp; $topics_per_page = $req_tpp;
} }
$select_tpp = []; $select_tpp = [];
foreach (config()->get('allowed_topics_per_page') as $tpp) { foreach (tp_config()->get('allowed_topics_per_page') as $tpp) {
$select_tpp[$tpp] = $tpp; $select_tpp[$tpp] = $tpp;
} }
} }
@ -285,7 +285,7 @@ $order_sql = "ORDER BY t.topic_type DESC, $sort_method $order_method";
$limit_topics_time_sql = ($topic_days) ? "AND t.topic_last_post_time > " . (TIMENOW - 86400 * $topic_days) : ''; $limit_topics_time_sql = ($topic_days) ? "AND t.topic_last_post_time > " . (TIMENOW - 86400 * $topic_days) : '';
$select_tor_sql = $join_tor_sql = ''; $select_tor_sql = $join_tor_sql = '';
$join_dl = (config()->get('show_dl_status_in_forum') && !IS_GUEST); $join_dl = (tp_config()->get('show_dl_status_in_forum') && !IS_GUEST);
$where_tor_sql = ''; $where_tor_sql = '';
if ($forum_data['allow_reg_tracker']) { if ($forum_data['allow_reg_tracker']) {
@ -426,7 +426,7 @@ foreach ($topic_rowset as $topic) {
$topic_id = $topic['topic_id']; $topic_id = $topic['topic_id'];
$moved = ($topic['topic_status'] == TOPIC_MOVED); $moved = ($topic['topic_status'] == TOPIC_MOVED);
$replies = $topic['topic_replies']; $replies = $topic['topic_replies'];
$t_hot = ($replies >= config()->get('hot_threshold')); $t_hot = ($replies >= tp_config()->get('hot_threshold'));
$t_type = $topic['topic_type']; $t_type = $topic['topic_type'];
$separator = ''; $separator = '';
$is_unread = is_unread($topic['topic_last_post_time'], $topic_id, $forum_id); $is_unread = is_unread($topic['topic_last_post_time'], $topic_id, $forum_id);
@ -452,14 +452,14 @@ foreach ($topic_rowset as $topic) {
'TOPICS_SEPARATOR' => $separator, 'TOPICS_SEPARATOR' => $separator,
'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, $replies, config()->get('posts_per_page')), 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $replies, tp_config()->get('posts_per_page')),
'REPLIES' => $moved ? '' : $replies, 'REPLIES' => $moved ? '' : $replies,
'VIEWS' => $moved ? '' : $topic['topic_views'], 'VIEWS' => $moved ? '' : $topic['topic_views'],
'TOR_STALED' => ($forum_data['allow_reg_tracker'] && !($t_type == POST_ANNOUNCE || $t_type == POST_STICKY || $topic['tor_size'])), 'TOR_STALED' => ($forum_data['allow_reg_tracker'] && !($t_type == POST_ANNOUNCE || $t_type == POST_STICKY || $topic['tor_size'])),
'TOR_FROZEN' => isset($topic['tor_status']) ? ((!IS_AM) ? isset(config()->get('tor_frozen')[$topic['tor_status']]) : '') : '', 'TOR_FROZEN' => isset($topic['tor_status']) ? ((!IS_AM) ? isset(tp_config()->get('tor_frozen')[$topic['tor_status']]) : '') : '',
'TOR_TYPE' => isset($topic['tor_type']) ? is_gold($topic['tor_type']) : '', 'TOR_TYPE' => isset($topic['tor_type']) ? is_gold($topic['tor_type']) : '',
'TOR_STATUS_ICON' => isset($topic['tor_status']) ? config()->get('tor_icons')[$topic['tor_status']] : '', 'TOR_STATUS_ICON' => isset($topic['tor_status']) ? tp_config()->get('tor_icons')[$topic['tor_status']] : '',
'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '', 'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '',
'ATTACH' => $topic['topic_attachment'] ?? false, 'ATTACH' => $topic['topic_attachment'] ?? false,
@ -471,7 +471,7 @@ foreach ($topic_rowset as $topic) {
'TOPIC_AUTHOR' => profile_url(['username' => str_short($topic['first_username'], 15), 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank']]), 'TOPIC_AUTHOR' => profile_url(['username' => str_short($topic['first_username'], 15), 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank']]),
'LAST_POSTER' => profile_url(['username' => str_short($topic['last_username'], 15), 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank']]), 'LAST_POSTER' => profile_url(['username' => str_short($topic['last_username'], 15), 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank']]),
'LAST_POST_TIME' => bb_date($topic['topic_last_post_time'], config()->get('last_post_date_format')), 'LAST_POST_TIME' => bb_date($topic['topic_last_post_time'], tp_config()->get('last_post_date_format')),
'LAST_POST_ID' => $topic['topic_last_post_id'], 'LAST_POST_ID' => $topic['topic_last_post_id'],
]); ]);
@ -501,7 +501,7 @@ $pg_url .= $topic_days ? "&amp;topicdays=$topic_days" : '';
$pg_url .= $sort_value ? "&amp;sort=$sort_value" : ''; $pg_url .= $sort_value ? "&amp;sort=$sort_value" : '';
$pg_url .= $order_value ? "&amp;order=$order_value" : ''; $pg_url .= $order_value ? "&amp;order=$order_value" : '';
$pg_url .= $moderation ? "&amp;mod=1" : ''; $pg_url .= $moderation ? "&amp;mod=1" : '';
$pg_url .= ($topics_per_page != config()->get('topics_per_page')) ? "&amp;tpp=$topics_per_page" : ''; $pg_url .= ($topics_per_page != tp_config()->get('topics_per_page')) ? "&amp;tpp=$topics_per_page" : '';
if ($found_topics) { if ($found_topics) {
generate_pagination($pg_url, $forum_topics, $topics_per_page, $start); generate_pagination($pg_url, $forum_topics, $topics_per_page, $start);

View file

@ -38,16 +38,16 @@ $user->session_start();
set_die_append_msg(); set_die_append_msg();
// Posts per page // Posts per page
$posts_per_page = config()->get('posts_per_page'); $posts_per_page = tp_config()->get('posts_per_page');
$select_ppp = ''; $select_ppp = '';
if ($userdata['session_admin']) { if ($userdata['session_admin']) {
if ($req_ppp = abs((int)(@$_REQUEST['ppp'])) and in_array($req_ppp, config()->get('allowed_posts_per_page'))) { if ($req_ppp = abs((int)(@$_REQUEST['ppp'])) and in_array($req_ppp, tp_config()->get('allowed_posts_per_page'))) {
$posts_per_page = $req_ppp; $posts_per_page = $req_ppp;
} }
$select_ppp = []; $select_ppp = [];
foreach (config()->get('allowed_posts_per_page') as $ppp) { foreach (tp_config()->get('allowed_posts_per_page') as $ppp) {
$select_ppp[$ppp] = $ppp; $select_ppp[$ppp] = $ppp;
} }
} }
@ -240,7 +240,7 @@ if ($post_id && !empty($t_data['prev_posts'])) {
// Is user watching this thread? // Is user watching this thread?
$can_watch_topic = $is_watching_topic = false; $can_watch_topic = $is_watching_topic = false;
if (config()->get('topic_notify_enabled')) { if (tp_config()->get('topic_notify_enabled')) {
if (!IS_GUEST) { if (!IS_GUEST) {
$can_watch_topic = true; $can_watch_topic = true;
@ -430,7 +430,7 @@ $pg_url .= $post_days ? "&amp;postdays=$post_days" : '';
$pg_url .= ($post_order != 'asc') ? "&amp;postorder=$post_order" : ''; $pg_url .= ($post_order != 'asc') ? "&amp;postorder=$post_order" : '';
$pg_url .= isset($_REQUEST['single']) ? "&amp;single=1" : ''; $pg_url .= isset($_REQUEST['single']) ? "&amp;single=1" : '';
$pg_url .= $moderation ? "&amp;mod=1" : ''; $pg_url .= $moderation ? "&amp;mod=1" : '';
$pg_url .= ($posts_per_page != config()->get('posts_per_page')) ? "&amp;ppp=$posts_per_page" : ''; $pg_url .= ($posts_per_page != tp_config()->get('posts_per_page')) ? "&amp;ppp=$posts_per_page" : '';
generate_pagination($pg_url, $total_replies, $posts_per_page, $start); generate_pagination($pg_url, $total_replies, $posts_per_page, $start);
@ -452,7 +452,7 @@ $sel_post_order_ary = [
]; ];
$topic_has_poll = $t_data['topic_vote']; $topic_has_poll = $t_data['topic_vote'];
$poll_time_expired = ($t_data['topic_time'] < TIMENOW - config()->get('poll_max_days') * 86400); $poll_time_expired = ($t_data['topic_time'] < TIMENOW - tp_config()->get('poll_max_days') * 86400);
$can_manage_poll = ($t_data['topic_poster'] == $userdata['user_id'] || $is_auth['auth_mod']); $can_manage_poll = ($t_data['topic_poster'] == $userdata['user_id'] || $is_auth['auth_mod']);
$can_add_poll = ($can_manage_poll && !$topic_has_poll && !$poll_time_expired && !$start); $can_add_poll = ($can_manage_poll && !$topic_has_poll && !$poll_time_expired && !$start);
@ -474,19 +474,19 @@ $template->assign_vars([
'TOPIC_TITLE' => $topic_title, 'TOPIC_TITLE' => $topic_title,
'PORNO_FORUM' => $t_data['allow_porno_topic'], 'PORNO_FORUM' => $t_data['allow_porno_topic'],
'REPLY_IMG' => $reply_img, 'REPLY_IMG' => $reply_img,
'SHOW_BOT_NICK' => config()->get('show_bot_nick'), 'SHOW_BOT_NICK' => tp_config()->get('show_bot_nick'),
'T_POST_REPLY' => $reply_alt, 'T_POST_REPLY' => $reply_alt,
'HIDE_FROM' => $user->opt_js['h_from'], 'HIDE_FROM' => $user->opt_js['h_from'],
'HIDE_AVATAR' => $user->opt_js['h_av'], 'HIDE_AVATAR' => $user->opt_js['h_av'],
'HIDE_RANK_IMG' => ($user->opt_js['h_rnk_i'] && config()->get('show_rank_image')), 'HIDE_RANK_IMG' => ($user->opt_js['h_rnk_i'] && tp_config()->get('show_rank_image')),
'HIDE_POST_IMG' => $user->opt_js['h_post_i'], 'HIDE_POST_IMG' => $user->opt_js['h_post_i'],
'HIDE_SMILE' => $user->opt_js['h_smile'], 'HIDE_SMILE' => $user->opt_js['h_smile'],
'HIDE_SIGNATURE' => $user->opt_js['h_sig'], 'HIDE_SIGNATURE' => $user->opt_js['h_sig'],
'SPOILER_OPENED' => $user->opt_js['sp_op'], 'SPOILER_OPENED' => $user->opt_js['sp_op'],
'SHOW_IMG_AFTER_LOAD' => $user->opt_js['i_aft_l'], 'SHOW_IMG_AFTER_LOAD' => $user->opt_js['i_aft_l'],
'HIDE_RANK_IMG_DIS' => !config()->get('show_rank_image'), 'HIDE_RANK_IMG_DIS' => !tp_config()->get('show_rank_image'),
'PINNED_FIRST_POST' => $t_data['topic_show_first_post'], 'PINNED_FIRST_POST' => $t_data['topic_show_first_post'],
'PIN_HREF' => $t_data['topic_show_first_post'] ? "modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=post_unpin" : "modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=post_pin", 'PIN_HREF' => $t_data['topic_show_first_post'] ? "modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=post_unpin" : "modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=post_pin",
@ -563,7 +563,7 @@ for ($i = 0; $i < $total_posts; $i++) {
$poster_bot = ($poster_id == BOT_UID); $poster_bot = ($poster_id == BOT_UID);
$poster = $poster_guest ? $lang['GUEST'] : $postrow[$i]['username']; $poster = $poster_guest ? $lang['GUEST'] : $postrow[$i]['username'];
$post_date = bb_date($postrow[$i]['post_time'], config()->get('post_date_format')); $post_date = bb_date($postrow[$i]['post_time'], tp_config()->get('post_date_format'));
$max_post_time = max($max_post_time, $postrow[$i]['post_time']); $max_post_time = max($max_post_time, $postrow[$i]['post_time']);
$poster_posts = !$poster_guest ? $postrow[$i]['user_posts'] : ''; $poster_posts = !$poster_guest ? $postrow[$i]['user_posts'] : '';
$poster_from = ($postrow[$i]['user_from'] && !$poster_guest) ? $postrow[$i]['user_from'] : ''; $poster_from = ($postrow[$i]['user_from'] && !$poster_guest) ? $postrow[$i]['user_from'] : '';
@ -588,8 +588,8 @@ for ($i = 0; $i < $total_posts; $i++) {
$poster_rank = $rank_image = ''; $poster_rank = $rank_image = '';
$user_rank = $postrow[$i]['user_rank']; $user_rank = $postrow[$i]['user_rank'];
if (!$user->opt_js['h_rnk_i'] and isset($ranks[$user_rank])) { if (!$user->opt_js['h_rnk_i'] and isset($ranks[$user_rank])) {
$rank_image = (config()->get('show_rank_image') && $ranks[$user_rank]['rank_image']) ? '<img src="' . $ranks[$user_rank]['rank_image'] . '" alt="" title="" border="0" />' : ''; $rank_image = (tp_config()->get('show_rank_image') && $ranks[$user_rank]['rank_image']) ? '<img src="' . $ranks[$user_rank]['rank_image'] . '" alt="" title="" border="0" />' : '';
$poster_rank = config()->get('show_rank_text') ? $ranks[$user_rank]['rank_title'] : ''; $poster_rank = tp_config()->get('show_rank_text') ? $ranks[$user_rank]['rank_title'] : '';
} }
// Handle anon users posting with usernames // Handle anon users posting with usernames
@ -615,7 +615,7 @@ for ($i = 0; $i < $total_posts; $i++) {
// Parse message and sig // Parse message and sig
$message = get_parsed_post($postrow[$i]); $message = get_parsed_post($postrow[$i]);
$user_sig = (config()->get('allow_sig') && !$user->opt_js['h_sig'] && $postrow[$i]['user_sig']) ? $postrow[$i]['user_sig'] : ''; $user_sig = (tp_config()->get('allow_sig') && !$user->opt_js['h_sig'] && $postrow[$i]['user_sig']) ? $postrow[$i]['user_sig'] : '';
if (bf($postrow[$i]['user_opt'], 'user_opt', 'dis_sig')) { if (bf($postrow[$i]['user_opt'], 'user_opt', 'dis_sig')) {
$user_sig = $lang['SIGNATURE_DISABLE']; $user_sig = $lang['SIGNATURE_DISABLE'];
@ -646,7 +646,7 @@ for ($i = 0; $i < $total_posts; $i++) {
// Replace newlines (we use this rather than nl2br because till recently it wasn't XHTML compliant) // Replace newlines (we use this rather than nl2br because till recently it wasn't XHTML compliant)
if ($user_sig) { if ($user_sig) {
$user_sig = config()->get('user_signature_start') . $user_sig . config()->get('user_signature_end'); $user_sig = tp_config()->get('user_signature_start') . $user_sig . tp_config()->get('user_signature_end');
} }
// Editing information // Editing information
@ -690,11 +690,11 @@ for ($i = 0; $i < $total_posts; $i++) {
'POSTER_NAME_JS' => addslashes($poster), 'POSTER_NAME_JS' => addslashes($poster),
'POSTER_RANK' => $poster_rank, 'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image, 'RANK_IMAGE' => $rank_image,
'POSTER_JOINED' => config()->get('show_poster_joined') ? $poster_longevity : '', 'POSTER_JOINED' => tp_config()->get('show_poster_joined') ? $poster_longevity : '',
'POSTER_JOINED_DATE' => $poster_joined, 'POSTER_JOINED_DATE' => $poster_joined,
'POSTER_POSTS' => (config()->get('show_poster_posts') && $poster_posts) ? '<a href="search.php?search_author=1&amp;uid=' . $poster_id . '" target="_blank">' . $poster_posts . '</a>' : '', 'POSTER_POSTS' => (tp_config()->get('show_poster_posts') && $poster_posts) ? '<a href="search.php?search_author=1&amp;uid=' . $poster_id . '" target="_blank">' . $poster_posts . '</a>' : '',
'POSTER_FROM' => config()->get('show_poster_from') ? render_flag($poster_from, false) : '', 'POSTER_FROM' => tp_config()->get('show_poster_from') ? render_flag($poster_from, false) : '',
'POSTER_BOT' => $poster_bot, 'POSTER_BOT' => $poster_bot,
'POSTER_GUEST' => $poster_guest, 'POSTER_GUEST' => $poster_guest,
'POSTER_ID' => $poster_id, 'POSTER_ID' => $poster_id,
@ -768,13 +768,13 @@ if (defined('SPLIT_FORM_START')) {
} }
// Quick Reply // Quick Reply
if (config()->get('show_quick_reply')) { if (tp_config()->get('show_quick_reply')) {
if ($is_auth['auth_reply'] && !$locked) { if ($is_auth['auth_reply'] && !$locked) {
$template->assign_vars([ $template->assign_vars([
'QUICK_REPLY' => true, 'QUICK_REPLY' => true,
'QR_POST_ACTION' => POSTING_URL, 'QR_POST_ACTION' => POSTING_URL,
'QR_TOPIC_ID' => $topic_id, 'QR_TOPIC_ID' => $topic_id,
'CAPTCHA_HTML' => (IS_GUEST && !config()->get('captcha.disabled')) ? bb_captcha('get') : '' 'CAPTCHA_HTML' => (IS_GUEST && !tp_config()->get('captcha.disabled')) ? bb_captcha('get') : ''
]); ]);
if (!IS_GUEST) { if (!IS_GUEST) {
@ -792,7 +792,7 @@ foreach ($is_auth as $name => $is) {
$template->assign_vars(['PG_ROW_CLASS' => $pg_row_class ?? 'row1']); $template->assign_vars(['PG_ROW_CLASS' => $pg_row_class ?? 'row1']);
if (IS_ADMIN) { if (IS_ADMIN) {
$template->assign_vars(['U_LOGS' => "admin/admin_log.php?" . POST_TOPIC_URL . "=$topic_id&amp;db=" . config()->get('log_days_keep')]); $template->assign_vars(['U_LOGS' => "admin/admin_log.php?" . POST_TOPIC_URL . "=$topic_id&amp;db=" . tp_config()->get('log_days_keep')]);
} }
print_page('viewtopic.tpl'); print_page('viewtopic.tpl');

View file

@ -13,7 +13,7 @@ if (!defined('IN_AJAX')) {
global $userdata, $lang; global $userdata, $lang;
if (!config()->get('callseed')) { if (!tp_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(config()->get('tor_no_tor_act')[$t_data['tor_status']])) { } elseif (isset(tp_config()->get('tor_no_tor_act')[$t_data['tor_status']])) {
$this->ajax_die($lang['NOT_AVAILABLE']); $this->ajax_die($lang['NOT_AVAILABLE']);
} }

View file

@ -22,7 +22,7 @@ if (!$mode = (string)$this->request['mode']) {
} }
$comment = false; $comment = false;
if (config()->get('tor_comment')) { if (tp_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'], 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>'); $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], tp_config()->get('tor_icons')[$new_status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b>', tp_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'] = 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>'; $this->response['status'] = tp_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 (config()->get('tor_comment') && (($comment && $comment != $lang['COMMENT']) || in_array($new_status, config()->get('tor_reply')))) { if (tp_config()->get('tor_comment') && (($comment && $comment != $lang['COMMENT']) || in_array($new_status, tp_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']), config()->get('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']), tp_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 (!config()->get('tor_comment')) { if (!tp_config()->get('tor_comment')) {
$this->ajax_die($lang['MODULE_OFF']); $this->ajax_die($lang['MODULE_OFF']);
} }

View file

@ -55,7 +55,7 @@ switch ($field) {
break; break;
case 'user_gender': case 'user_gender':
if (!config()->get('gender')) { if (!tp_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 (!config()->get('birthday_enabled')) { if (!tp_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'] > config()->get('birthday_max_age')) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > tp_config()->get('birthday_max_age')) {
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], config()->get('birthday_max_age'))); $this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], tp_config()->get('birthday_max_age')));
} elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < config()->get('birthday_min_age')) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < tp_config()->get('birthday_min_age')) {
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], config()->get('birthday_min_age'))); $this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], tp_config()->get('birthday_min_age')));
} }
} }

View file

@ -13,11 +13,11 @@ if (!defined('IN_AJAX')) {
global $lang; global $lang;
if (!config()->get('torr_server.enabled')) { if (!tp_config()->get('torr_server.enabled')) {
$this->ajax_die($lang['MODULE_OFF']); $this->ajax_die($lang['MODULE_OFF']);
} }
if (config()->get('torr_server.disable_for_guest') && IS_GUEST) { if (tp_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

@ -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'], config()->get('birthday_check_day'), implode(', ', $users)); $html = sprintf($lang['BIRTHDAY_WEEK'], tp_config()->get('birthday_check_day'), implode(', ', $users));
} else { } else {
$html = sprintf($lang['NOBIRTHDAY_WEEK'], config()->get('birthday_check_day')); $html = sprintf($lang['NOBIRTHDAY_WEEK'], tp_config()->get('birthday_check_day'));
} }
break; break;
@ -84,7 +84,7 @@ switch ($mode) {
break; break;
case 'null_ratio': case 'null_ratio':
if (!config()->get('ratio_null_enabled') || !RATIO_ENABLED) { if (!tp_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 >= config()->get('ratio_to_null')) && !IS_ADMIN) { if (($user_ratio >= tp_config()->get('ratio_to_null')) && !IS_ADMIN) {
$this->ajax_die(sprintf($lang['BT_NULL_RATIO_NOT_NEEDED'], config()->get('ratio_to_null'))); $this->ajax_die(sprintf($lang['BT_NULL_RATIO_NOT_NEEDED'], tp_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 .= config()->get('seed_bonus_enabled') ? '<th>' . $lang['SEED_BONUS'] . '</th>' : ''; $html .= tp_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 .= config()->get('seed_bonus_enabled') ? '<td id="user_points"><span class="editable bold points">' . $profiledata['user_points'] . '</b></td>' : ''; $html .= tp_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 .= config()->get('seed_bonus_enabled') ? '<td colspan="1"></td>' : ''; $html .= tp_config()->get('seed_bonus_enabled') ? '<td colspan="1"></td>' : '';
$html .= '</tr>'; $html .= '</tr>';
$this->response['user_ratio'] = ' $this->response['user_ratio'] = '
<th><a href="' . config()->get('ratio_url_help') . '" class="bold">' . $lang['USER_RATIO'] . '</a>:</th> <th><a href="' . tp_config()->get('ratio_url_help') . '" class="bold">' . $lang['USER_RATIO'] . '</a>:</th>
<td>' . $user_ratio . '</td> <td>' . $user_ratio . '</td>
'; ';
break; break;

View file

@ -19,7 +19,7 @@ if (!$mode = (string)$this->request['mode']) {
switch ($mode) { switch ($mode) {
case 'clear_cache': case 'clear_cache':
foreach (config()->get('cache.engines') as $cache_name => $cache_val) { foreach (tp_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 " . config()->get('sphinx_config_path') . " --all --rotate", $result); exec("indexer --config " . tp_config()->get('sphinx_config_path') . " --all --rotate", $result);
if (!is_file(config()->get('sphinx_config_path') . ".log")) { if (!is_file(tp_config()->get('sphinx_config_path') . ".log")) {
file_put_contents(config()->get('sphinx_config_path') . ".log", "##############################" . date("H:i:s", TIMENOW) . "##############################\r\n\r\n\r\n\r\n", FILE_APPEND); file_put_contents(tp_config()->get('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", FILE_APPEND); file_put_contents(tp_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(config()->get('sphinx_config_path') . ".log", $row . "\r\n", FILE_APPEND); file_put_contents(tp_config()->get('sphinx_config_path') . ".log", $row . "\r\n", FILE_APPEND);
} }
file_put_contents(config()->get('sphinx_config_path') . ".log", "\r\n", FILE_APPEND); file_put_contents(tp_config()->get('sphinx_config_path') . ".log", "\r\n", FILE_APPEND);
file_put_contents(config()->get('sphinx_config_path') . ".log", "\r\n", FILE_APPEND); file_put_contents(tp_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

@ -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'], 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_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], tp_config()->get('tor_icons')[$status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$status] . '</b>', tp_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'] = config()->get('tor_icons')[$status]; $this->response['status'] = tp_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(',', config()->get('latest_news_forum_id'))); $news_forums = array_flip(explode(',', tp_config()->get('latest_news_forum_id')));
if (isset($news_forums[$t_data['forum_id']]) && config()->get('show_latest_news')) { if (isset($news_forums[$t_data['forum_id']]) && tp_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(',', config()->get('network_news_forum_id'))); $net_forums = array_flip(explode(',', tp_config()->get('network_news_forum_id')));
if (isset($net_forums[$t_data['forum_id']]) && config()->get('show_network_news')) { if (isset($net_forums[$t_data['forum_id']]) && tp_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="' . config()->get('whois_info') . $user_reg_ip . '" class="gen" target="_blank">' . $user_reg_ip . '</a>'; $reg_ip = '<a href="' . tp_config()->get('whois_info') . $user_reg_ip . '" class="gen" target="_blank">' . $user_reg_ip . '</a>';
$last_ip = '<a href="' . config()->get('whois_info') . $user_last_ip . '" class="gen" target="_blank">' . $user_last_ip . '</a>'; $last_ip = '<a href="' . tp_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

@ -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('#(?<=[\?&;]' . config()->get('passkey_key') . '=)[a-zA-Z0-9]#', 'passkey', $message); $message = preg_replace('#(?<=[\?&;]' . tp_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 (config()->get('max_smilies')) { if (tp_config()->get('max_smilies')) {
$count_smilies = substr_count(bbcode2html($text), '<img class="smile" src="' . config()->get('smilies_path')); $count_smilies = substr_count(bbcode2html($text), '<img class="smile" src="' . tp_config()->get('smilies_path'));
if ($count_smilies > config()->get('max_smilies')) { if ($count_smilies > tp_config()->get('max_smilies')) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies'))); $this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], tp_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']) < config()->get('flood_interval')) { if ((TIMENOW - $row['last_post_time']) < tp_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 (config()->get('max_smilies')) { if (tp_config()->get('max_smilies')) {
$count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . config()->get('smilies_path')); $count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . tp_config()->get('smilies_path'));
if ($count_smilies > config()->get('max_smilies')) { if ($count_smilies > tp_config()->get('max_smilies')) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies'))); $this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], tp_config()->get('max_smilies')));
} }
} }
@ -272,7 +272,7 @@ switch ($this->request['type']) {
'post_text' => $message 'post_text' => $message
]); ]);
if (config()->get('topic_notify_enabled')) { if (tp_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

@ -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, config()->get('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, tp_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

@ -13,7 +13,7 @@ if (!defined('IN_AJAX')) {
global $lang, $userdata; global $lang, $userdata;
if (!config()->get('tor_thank')) { if (!tp_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)config()->get('tor_thank_limit_per_topic')) { if ($thanks_count > (int)tp_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 && !config()->get('tor_thanks_list_guests')) { if (IS_GUEST && !tp_config()->get('tor_thanks_list_guests')) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']); $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
} }

View file

@ -15,7 +15,7 @@ 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 = config()->get('show_post_bbcode_button.enabled') && isset($this->request['return_text']) && (bool)$this->request['return_text']; $return_text = tp_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

@ -27,9 +27,9 @@ function attach_mod_get_lang($language_file)
{ {
global $attach_config; global $attach_config;
$file = LANG_ROOT_DIR . '/' . config()->get('default_lang') . '/' . $language_file . '.php'; $file = LANG_ROOT_DIR . '/' . tp_config()->get('default_lang') . '/' . $language_file . '.php';
if (file_exists($file)) { if (file_exists($file)) {
return config()->get('default_lang'); return tp_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';
@ -58,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(config()->get('default_lang')); $attach_config['board_lang'] = trim(tp_config()->get('default_lang'));
return $attach_config; return $attach_config;
} }

View file

@ -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 = config()->get('bt_show_peers_mode'); $cfg_sp_mode = tp_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 (config()->get('bt_allow_spmode_change')) { if (tp_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)config()->get('bt_show_peers'); $show_peers = (bool)tp_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 (config()->get('tracker.use_old_torrent_name_format')) { if (tp_config()->get('tracker.use_old_torrent_name_format')) {
$display_name = '[' . config()->get('server_name') . '].t' . $bt_topic_id . '.' . TORRENT_EXT; $display_name = '[' . tp_config()->get('server_name') . '].t' . $bt_topic_id . '.' . TORRENT_EXT;
} else { } else {
$display_name = $t_data['topic_title'] . ' [' . config()->get('server_name') . '-' . $bt_topic_id . ']' . '.' . TORRENT_EXT; $display_name = $t_data['topic_title'] . ' [' . tp_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 = config()->get('bt_min_ratio_allow_dl_tor'); $min_ratio_dl = tp_config()->get('bt_min_ratio_allow_dl_tor');
$min_ratio_warn = config()->get('bt_min_ratio_warning'); $min_ratio_warn = tp_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, config()->get('ratio_url_help')), 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, tp_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(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_FROZEN' => !IS_AM ? (isset(tp_config()->get('tor_frozen')[$tor_info['tor_status']]) && !(isset(tp_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' => config()->get('tor_icons')[$tor_info['tor_status']], 'TOR_STATUS_ICON' => tp_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' => 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, 'TOR_STATUS_REPLY' => tp_config()->get('tor_comment') && !IS_GUEST && in_array($tor_info['tor_status'], tp_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 (config()->get('torr_server.enabled') && (!IS_GUEST || !config()->get('torr_server.disable_for_guest')) && (new \TorrentPier\TorrServerAPI())->getM3UPath($attach_id)) { if (tp_config()->get('torr_server.enabled') && (!IS_GUEST || !tp_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 (config()->get('show_tor_info_in_dl_list')) { if (tp_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 (config()->get('ip2country_settings.enabled')) { if (tp_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' => config()->get('whois_info') . $ip, 'U_WHOIS_IP' => tp_config()->get('whois_info') . $ip,
'IP' => $ip 'IP' => $ip
]); ]);
} }
@ -563,7 +563,7 @@ if ($tor_reged && $tor_info) {
} }
} }
if (config()->get('bt_allow_spmode_change') && $s_mode != 'full') { if (tp_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 (config()->get('bt_allow_spmode_change') && $s_mode != 'full') {
} }
$template->assign_vars([ $template->assign_vars([
'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_DL_LIST_LINK' => ((tp_config()->get('bt_show_dl_list') || tp_config()->get('allow_dl_list_names_mode')) && $t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL),
'SHOW_TOR_ACT' => ($tor_reged && $show_peers && (!isset(config()->get('tor_no_tor_act')[$tor_info['tor_status']]) || IS_AM)), 'SHOW_TOR_ACT' => ($tor_reged && $show_peers && (!isset(tp_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' => config()->get('tor_help_links'), 'TOR_HELP_LINKS' => tp_config()->get('tor_help_links'),
'CALL_SEED' => (!IS_GUEST && config()->get('callseed') && $tor_reged && !isset(config()->get('tor_no_tor_act')[$tor_info['tor_status']]) && $seed_count < 3 && $tor_info['call_seed_time'] < (TIMENOW - 86400)), 'CALL_SEED' => (!IS_GUEST && tp_config()->get('callseed') && $tor_reged && !isset(tp_config()->get('tor_no_tor_act')[$tor_info['tor_status']]) && $seed_count < 3 && $tor_info['call_seed_time'] < (TIMENOW - 86400)),
]); ]);

View file

@ -215,7 +215,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
} }
// TorrServer integration // TorrServer integration
if (config()->get('torr_server.enabled')) { if (tp_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

@ -15,8 +15,8 @@ if (!defined('BB_ROOT')) {
define('ADMIN_DIR', BB_PATH . '/admin'); define('ADMIN_DIR', BB_PATH . '/admin');
define('DATA_DIR', BB_PATH . '/data'); define('DATA_DIR', BB_PATH . '/data');
define('INT_DATA_DIR', BB_PATH . '/internal_data'); define('INT_DATA_DIR', BB_PATH . '/internal_data');
define('CACHE_DIR', BB_PATH . '/internal_data/cache'); define('CACHE_DIR', BB_PATH . '/storage/framework/cache');
define('LOG_DIR', BB_PATH . '/internal_data/log'); define('LOG_DIR', BB_PATH . '/storage/logs');
define('TRIGGERS_DIR', BB_PATH . '/internal_data/triggers'); define('TRIGGERS_DIR', BB_PATH . '/internal_data/triggers');
define('AJAX_DIR', BB_PATH . '/library/ajax'); define('AJAX_DIR', BB_PATH . '/library/ajax');
define('ATTACH_DIR', BB_PATH . '/library/attach_mod'); define('ATTACH_DIR', BB_PATH . '/library/attach_mod');
@ -24,7 +24,7 @@ define('INC_DIR', BB_PATH . '/library/includes');
define('UCP_DIR', BB_PATH . '/library/includes/ucp'); define('UCP_DIR', BB_PATH . '/library/includes/ucp');
define('LANG_ROOT_DIR', BB_PATH . '/library/language'); define('LANG_ROOT_DIR', BB_PATH . '/library/language');
define('SITEMAP_DIR', BB_PATH . '/sitemap'); define('SITEMAP_DIR', BB_PATH . '/sitemap');
define('IMAGES_DIR', BB_PATH . '/styles/images'); define('IMAGES_DIR', BB_PATH . '/public/styles/images');
define('TEMPLATES_DIR', BB_PATH . '/styles/templates'); define('TEMPLATES_DIR', BB_PATH . '/styles/templates');
// System // System

View file

@ -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' => config()->get('smilies_path') . '/' . $smile_url, 'SMILEY_IMG' => tp_config()->get('smilies_path') . '/' . $smile_url,
'SMILEY_DESC' => $data['emoticon'], 'SMILEY_DESC' => $data['emoticon'],
]); ]);
@ -341,9 +341,9 @@ function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $s
function extract_search_words($text) function extract_search_words($text)
{ {
$max_words_count = config()->get('max_search_words_per_post'); $max_words_count = tp_config()->get('max_search_words_per_post');
$min_word_len = max(2, config()->get('search_min_word_len') - 1); $min_word_len = max(2, tp_config()->get('search_min_word_len') - 1);
$max_word_len = config()->get('search_max_word_len'); $max_word_len = tp_config()->get('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);
@ -383,7 +383,7 @@ function add_search_words($post_id, $post_message, $topic_title = '', $only_retu
$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 || config()->get('search_engine_type') == 'sphinx') { if ($only_return_words || tp_config()->get('search_engine_type') == 'sphinx') {
return implode("\n", $words); return implode("\n", $words);
} }
@ -421,19 +421,19 @@ function get_words_rate($text)
function hide_passkey($str) function hide_passkey($str)
{ {
return preg_replace("#\?{config()->get('passkey_key')}=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?{config()->get('passkey_key')}=passkey", $str); return preg_replace("#\?{tp_config()->get('passkey_key')}=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?{tp_config()->get('passkey_key')}=passkey", $str);
} }
function get_parsed_post($postrow, $mode = 'full', $return_chars = 600) function get_parsed_post($postrow, $mode = 'full', $return_chars = 600)
{ {
if (config()->get('use_posts_cache') && !empty($postrow['post_html'])) { if (tp_config()->get('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 (config()->get('use_posts_cache')) { if (tp_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 (config()->get('torr_server.enabled') && $fix_errors) { if (tp_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)config()->get('poll_max_days')) { if ($poll_max_days = (int)tp_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)config()->get('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)config()->get('posts_cache_days_keep')) { if ($posts_days = (int)tp_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(config()->get('bt_announce_url')) || (config()->get('bt_announce_url') === 'https://localhost/bt/announce.php')) { if (empty(tp_config()->get('bt_announce_url')) || (tp_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)config()->get('dl_will_days_keep'), DL_STATUS_WILL => (int)tp_config()->get('dl_will_days_keep'),
DL_STATUS_DOWN => (int)config()->get('dl_down_days_keep'), DL_STATUS_DOWN => (int)tp_config()->get('dl_down_days_keep'),
DL_STATUS_COMPLETE => (int)config()->get('dl_complete_days_keep'), DL_STATUS_COMPLETE => (int)tp_config()->get('dl_complete_days_keep'),
DL_STATUS_CANCEL => (int)config()->get('dl_cancel_days_keep') DL_STATUS_CANCEL => (int)tp_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)config()->get('torstat_days_keep')) { if ($torstat_days_keep = (int)tp_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)config()->get('log_days_keep'); $log_days_keep = (int)tp_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)config()->get('pm_days_keep'); $pm_days_keep = (int)tp_config()->get('pm_days_keep');
if ($pm_days_keep !== 0) { if ($pm_days_keep !== 0) {
$per_cycle = 20000; $per_cycle = 20000;

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
if (config()->get('prune_enable')) { if (tp_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)config()->get('user_not_activated_days_keep')) { if ($not_activated_days = (int)tp_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)config()->get('user_not_active_days_keep')) { if ($not_active_days = (int)tp_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 (config()->get('topic_moved_days_keep')) { if (tp_config()->get('topic_moved_days_keep')) {
$prune_time = TIMENOW - 86400 * config()->get('topic_moved_days_keep'); $prune_time = TIMENOW - 86400 * tp_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)config()->get('user_session_duration'); $user_session_expire_time = TIMENOW - (int)tp_config()->get('user_session_duration');
$admin_session_expire_time = TIMENOW - (int)config()->get('admin_session_duration'); $admin_session_expire_time = TIMENOW - (int)tp_config()->get('admin_session_duration');
$user_session_gc_time = $user_session_expire_time - (int)config()->get('user_session_gc_ttl'); $user_session_gc_time = $user_session_expire_time - (int)tp_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 (config()->get('tracker.update_dlstat')) { if (tp_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 (config()->get('tracker.autoclean')) { if (tp_config()->get('tracker.autoclean')) {
$announce_interval = max((int)config()->get('announce_interval'), 60); $announce_interval = max((int)tp_config()->get('announce_interval'), 60);
$expire_factor = max((float)config()->get('tracker.expire_factor'), 1); $expire_factor = max((float)tp_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 (config()->get('tracker.update_dlstat')) { if (tp_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(config()->get('seeder_last_seen_days_keep')) || empty(config()->get('seeder_never_seen_days_keep'))) { if (empty(tp_config()->get('seeder_last_seen_days_keep')) || empty(tp_config()->get('seeder_never_seen_days_keep'))) {
return; return;
} }
$last_seen_time = TIMENOW - 86400 * config()->get('seeder_last_seen_days_keep'); $last_seen_time = TIMENOW - 86400 * tp_config()->get('seeder_last_seen_days_keep');
$never_seen_time = TIMENOW - 86400 * config()->get('seeder_never_seen_days_keep'); $never_seen_time = TIMENOW - 86400 * tp_config()->get('seeder_never_seen_days_keep');
$limit_sql = 3000; $limit_sql = 3000;
$topics_sql = $attach_sql = []; $topics_sql = $attach_sql = [];

View file

@ -79,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 (config()->get('bt_show_dl_list') && config()->get('bt_dl_list_only_count')) { if (tp_config()->get('bt_show_dl_list') && tp_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)
@ -102,7 +102,7 @@ DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_DLSTATUS_SNAP . ", " . OLD_BB_BT
// //
// TORHELP // TORHELP
// //
if (config()->get('torhelp_enabled')) { if (tp_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; // ">="
@ -145,7 +145,7 @@ if (config()->get('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)config()->get('trash_forum_id') . " AND tor.forum_id != " . (int)tp_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 (config()->get('seed_bonus_enabled') && config()->get('seed_bonus_points') && config()->get('seed_bonus_release')) { if (tp_config()->get('seed_bonus_enabled') && tp_config()->get('seed_bonus_points') && tp_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 (config()->get('seed_bonus_enabled') && config()->get('seed_bonus_points') &&
) ENGINE = MEMORY ) ENGINE = MEMORY
"); ");
$tor_size = (config()->get('seed_bonus_tor_size') * 1073741824); $tor_size = (tp_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 (config()->get('seed_bonus_enabled') && config()->get('seed_bonus_points') &&
GROUP BY bt.user_id GROUP BY bt.user_id
"); ");
$seed_bonus = unserialize(config()->get('seed_bonus_points')); $seed_bonus = unserialize(tp_config()->get('seed_bonus_points'));
$seed_release = unserialize(config()->get('seed_bonus_release')); $seed_release = unserialize(tp_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 (config()->get('seed_bonus_enabled') && config()->get('seed_bonus_points') &&
$user_points = ((float)$points / 4); $user_points = ((float)$points / 4);
$release = (int)$seed_release[$i]; $release = (int)$seed_release[$i];
$user_regdate = (TIMENOW - config()->get('seed_bonus_user_regdate') * 86400); $user_regdate = (TIMENOW - tp_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

@ -14,8 +14,8 @@ if (!defined('BB_ROOT')) {
$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(config()->get('atom.path') . '/f/0.atom')) { if (is_file(tp_config()->get('atom.path') . '/f/0.atom')) {
if (filemtime(config()->get('atom.path') . '/f/0.atom') <= $timecheck) { if (filemtime(tp_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 {
@ -23,8 +23,8 @@ if (is_file(config()->get('atom.path') . '/f/0.atom')) {
} }
foreach ($forums_data as $forum_data) { foreach ($forums_data as $forum_data) {
if (is_file(config()->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom')) { if (is_file(tp_config()->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom')) {
if (filemtime(config()->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom') <= $timecheck) { if (filemtime(tp_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

@ -106,7 +106,7 @@ $this->store('cat_forums', $data);
// //
// jumpbox // jumpbox
// //
if (config()->get('show_jumpbox')) { if (tp_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 (config()->get('show_latest_news') and $news_forum_ids = config()->get('latest_news_forum_id')) { if (tp_config()->get('show_latest_news') and $news_forum_ids = tp_config()->get('latest_news_forum_id')) {
$news_count = max(config()->get('latest_news_count'), 1); $news_count = max(tp_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 (config()->get('show_latest_news') and $news_forum_ids = config()->get('lates
// //
// Network_news // Network_news
// //
if (config()->get('show_network_news') and $net_forum_ids = config()->get('network_news_forum_id')) { if (tp_config()->get('show_network_news') and $net_forum_ids = tp_config()->get('network_news_forum_id')) {
$net_count = max(config()->get('network_news_count'), 1); $net_count = max(tp_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,17 +11,17 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
if (!config()->get('tp_updater_settings.enabled')) { if (!tp_config()->get('tp_updater_settings.enabled')) {
return; return;
} }
$data = []; $data = [];
$updaterDownloader = new \TorrentPier\Updater(); $updaterDownloader = new \TorrentPier\Updater();
$updaterDownloader = $updaterDownloader->getLastVersion(config()->get('tp_updater_settings.allow_pre_releases')); $updaterDownloader = $updaterDownloader->getLastVersion(tp_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(config()->get('tp_version')); $currentVersion = \TorrentPier\Helpers\VersionHelper::removerPrefix(tp_config()->get('tp_version'));
// Has update! // Has update!
if (\z4kn4fein\SemVer\Version::greaterThan($getVersion, $currentVersion)) { if (\z4kn4fein\SemVer\Version::greaterThan($getVersion, $currentVersion)) {

View file

@ -18,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="' . config()->get('smilies_path') . '/' . $smile['smile_url'] . '" alt="' . $smile['code'] . '" title="' . $smile['emoticon'] . '" align="absmiddle" border="0" />'; $smilies['repl'][] = ' <img class="smile" src="' . tp_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

@ -27,7 +27,7 @@ $data['postcount'] = commify($row['postcount']);
$data['topiccount'] = commify($row['topiccount']); $data['topiccount'] = commify($row['topiccount']);
// Tracker stats // Tracker stats
if (config()->get('tor_stats')) { if (tp_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']);
@ -42,7 +42,7 @@ if (config()->get('tor_stats')) {
} }
// gender stat // gender stat
if (config()->get('gender')) { if (tp_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 . ")");
@ -53,7 +53,7 @@ if (config()->get('gender')) {
} }
// birthday stat // birthday stat
if (config()->get('birthday_check_day') && config()->get('birthday_enabled')) { if (tp_config()->get('birthday_check_day') && tp_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 . ")
@ -64,7 +64,7 @@ if (config()->get('birthday_check_day') && config()->get('birthday_enabled')) {
"); ");
$date_today = bb_date(TIMENOW, 'md', false); $date_today = bb_date(TIMENOW, 'md', false);
$date_forward = bb_date(TIMENOW + (config()->get('birthday_check_day') * 86400), 'md', false); $date_forward = bb_date(TIMENOW + (tp_config()->get('birthday_check_day') * 86400), 'md', false);
$birthday_today_list = $birthday_week_list = []; $birthday_today_list = $birthday_week_list = [];

View file

@ -13,19 +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)
{ {
$ext = config()->get('file_id_ext')[$ext_id] ?? ''; $ext = tp_config()->get('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)
{ {
$base_path ??= config()->get('avatars.upload_path'); $base_path ??= tp_config()->get('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)
{ {
$base_path ??= config()->get('attach.upload_path'); $base_path ??= tp_config()->get('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);
} }
@ -612,7 +612,7 @@ function bt_show_ip($ip, $port = '')
return $ip; return $ip;
} }
return config()->get('bt_show_ip_only_moder') ? false : \TorrentPier\Helpers\IPHelper::anonymizeIP($ip); return tp_config()->get('bt_show_ip_only_moder') ? false : \TorrentPier\Helpers\IPHelper::anonymizeIP($ip);
} }
function bt_show_port($port) function bt_show_port($port)
@ -621,7 +621,7 @@ function bt_show_port($port)
return $port; return $port;
} }
return config()->get('bt_show_port_only_moder') ? false : $port; return tp_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)
@ -801,18 +801,18 @@ function generate_user_info($row, bool $have_auth = IS_ADMIN): array
$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 = 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>'; $pm = tp_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 = (config()->get('board_email_form')) ? ("profile.php?mode=email&amp;" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email']; $email_uri = (tp_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 = 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>'; $www = tp_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'];
} }
@ -991,7 +991,7 @@ function make_jumpbox(): void
{ {
global $datastore, $template; global $datastore, $template;
if (!config()->get('show_jumpbox')) { if (!tp_config()->get('show_jumpbox')) {
return; return;
} }
@ -1072,11 +1072,11 @@ function setup_style()
global $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(config()->get('tpl_name')); $tpl_dir_name = defined('IN_ADMIN') ? 'default' : basename(tp_config()->get('tpl_name'));
$stylesheet = defined('IN_ADMIN') ? 'main.css' : basename(config()->get('stylesheet')); $stylesheet = defined('IN_ADMIN') ? 'main.css' : basename(tp_config()->get('stylesheet'));
if (!IS_GUEST && !empty($userdata['tpl_name'])) { if (!IS_GUEST && !empty($userdata['tpl_name'])) {
foreach (config()->get('templates') as $folder => $name) { foreach (tp_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']);
} }
@ -1089,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' => config()->get('ext_link_new_win'), 'EXT_LINK_NEW_WIN' => tp_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('/')
]); ]);
@ -1107,14 +1107,14 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
$gmepoch = (int)$gmepoch; $gmepoch = (int)$gmepoch;
if (!$format) { if (!$format) {
$format = config()->get('default_dateformat'); $format = tp_config()->get('default_dateformat');
} }
if (empty($lang)) { if (empty($lang)) {
lang()->initializeLanguage(); lang()->initializeLanguage();
} }
if (!defined('IS_GUEST') || IS_GUEST) { if (!defined('IS_GUEST') || IS_GUEST) {
$tz = config()->get('board_timezone'); $tz = tp_config()->get('board_timezone');
} else { } else {
$tz = $userdata['user_timezone']; $tz = $userdata['user_timezone'];
} }
@ -1149,7 +1149,7 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
} }
} }
return (config()->get('translate_dates')) ? strtr(strtoupper($date), $lang['DATETIME']) : $date; return (tp_config()->get('translate_dates')) ? strtr(strtoupper($date), $lang['DATETIME']) : $date;
} }
/** /**
@ -1164,7 +1164,7 @@ function get_user_torrent_client(string $peer_id): string
$bestMatch = null; $bestMatch = null;
$bestMatchLength = 0; $bestMatchLength = 0;
foreach (config()->get('tor_clients') as $key => $clientName) { foreach (tp_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);
@ -1219,7 +1219,7 @@ function birthday_age($date)
return ''; return '';
} }
$tz = TIMENOW + (3600 * config()->get('board_timezone')); $tz = TIMENOW + (3600 * tp_config()->get('board_timezone'));
return delta_time(strtotime($date, $tz)); return delta_time(strtotime($date, $tz));
} }
@ -1360,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/" . config()->get('tpl_name')); $template = new TorrentPier\Legacy\Template(BB_ROOT . "templates/" . tp_config()->get('tpl_name'));
} }
if (empty($theme)) { if (empty($theme)) {
$theme = setup_style(); $theme = setup_style();
@ -1426,11 +1426,11 @@ function redirect($url)
} }
$url = trim($url); $url = trim($url);
$server_protocol = (config()->get('cookie_secure')) ? 'https://' : 'http://'; $server_protocol = (tp_config()->get('cookie_secure')) ? 'https://' : 'http://';
$server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(config()->get('server_name'))); $server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(tp_config()->get('server_name')));
$server_port = (config()->get('server_port') <> 80) ? ':' . trim(config()->get('server_port')) : ''; $server_port = (tp_config()->get('server_port') <> 80) ? ':' . trim(tp_config()->get('server_port')) : '';
$script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(config()->get('script_path'))); $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim(tp_config()->get('script_path')));
if ($script_name) { if ($script_name) {
$script_name = "/$script_name"; $script_name = "/$script_name";
@ -1543,7 +1543,7 @@ function get_topic_icon($topic, $is_unread = null)
{ {
global $images; global $images;
$t_hot = ($topic['topic_replies'] >= config()->get('hot_threshold')); $t_hot = ($topic['topic_replies'] >= tp_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 +1684,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 (config()->get('search_engine_type') == 'sphinx') { if (tp_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,12 +1742,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 (config()->get('search_engine_type') == 'sphinx') { if (tp_config()->get('search_engine_type') == 'sphinx') {
$sphinx = init_sphinx(); $sphinx = init_sphinx();
$where = $title_match ? 'topics' : 'posts'; $where = $title_match ? 'topics' : 'posts';
$sphinx->setServer(config()->get('sphinx_topic_titles_host'), config()->get('sphinx_topic_titles_port')); $sphinx->setServer(tp_config()->get('sphinx_topic_titles_host'), tp_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);
} }
@ -1767,9 +1767,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 (config()->get('search_engine_type') == 'mysql') { } elseif (tp_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 = (config()->get('allow_search_in_bool_mode')) ? ' IN BOOLEAN MODE' : ''; $search_bool_mode = (tp_config()->get('allow_search_in_bool_mode')) ? ' IN BOOLEAN MODE' : '';
if ($title_match) { if ($title_match) {
$where_id = 'topic_id'; $where_id = 'topic_id';
@ -1826,12 +1826,12 @@ function create_magnet(string $infohash, string $infohash_v2, string $auth_key,
{ {
global $images, $lang; global $images, $lang;
if (!config()->get('magnet_links_enabled')) { if (!tp_config()->get('magnet_links_enabled')) {
return false; return false;
} }
// Only for registered users // Only for registered users
if (!config()->get('magnet_links_for_guests') && IS_GUEST) { if (!tp_config()->get('magnet_links_for_guests') && IS_GUEST) {
return false; return false;
} }
@ -1856,7 +1856,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(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>'; return '<a title="' . ($v2_support ? $lang['MAGNET_v2'] : $lang['MAGNET']) . '" href="' . $magnet . '&tr=' . urlencode(tp_config()->get('bt_announce_url') . "?" . tp_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)
@ -1932,7 +1932,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 (config()->get('color_nick')) { if (tp_config()->get('color_nick')) {
$style = $ranks[$user_rank]['rank_style']; $style = $ranks[$user_rank]['rank_style'];
} }
} }
@ -1963,13 +1963,13 @@ function get_avatar($user_id, $ext_id, $allow_avatar = true, $height = '', $widt
$height = $height ? 'height="' . $height . '"' : ''; $height = $height ? 'height="' . $height . '"' : '';
$width = $width ? 'width="' . $width . '"' : ''; $width = $width ? 'width="' . $width . '"' : '';
$user_avatar = '<img src="' . make_url(config()->get('avatars.display_path') . config()->get('avatars.no_avatar')) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />'; $user_avatar = '<img src="' . make_url(tp_config()->get('avatars.display_path') . tp_config()->get('avatars.no_avatar')) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
if ($user_id == BOT_UID && config()->get('avatars.bot_avatar')) { if ($user_id == BOT_UID && tp_config()->get('avatars.bot_avatar')) {
$user_avatar = '<img src="' . make_url(config()->get('avatars.display_path') . config()->get('avatars.bot_avatar')) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />'; $user_avatar = '<img src="' . make_url(tp_config()->get('avatars.display_path') . tp_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, config()->get('avatars.display_path'))) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />'; $user_avatar = '<img src="' . make_url(get_avatar_path($user_id, $ext_id, tp_config()->get('avatars.display_path'))) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
} }
} }
@ -1986,7 +1986,7 @@ function genderImage(int $gender): ?string
{ {
global $lang, $images; global $lang, $images;
if (!config()->get('gender')) { if (!tp_config()->get('gender')) {
return false; return false;
} }
@ -2004,7 +2004,7 @@ function is_gold($type): string
$type = (int)$type; $type = (int)$type;
$is_gold = ''; $is_gold = '';
if (!config()->get('tracker.gold_silver_enabled')) { if (!tp_config()->get('tracker.gold_silver_enabled')) {
return $is_gold; return $is_gold;
} }
@ -2075,8 +2075,8 @@ function bb_captcha(string $mode): bool|string
{ {
global $lang; global $lang;
$settings = config()->get('captcha'); $settings = tp_config()->get('captcha');
$settings['language'] = config()->get('default_lang'); $settings['language'] = tp_config()->get('default_lang');
// Checking captcha settings // Checking captcha settings
if (!$settings['disabled'] && $settings['service'] !== 'text') { if (!$settings['disabled'] && $settings['service'] !== 'text') {
@ -2134,7 +2134,7 @@ function user_birthday_icon($user_birthday, $user_id): string
$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 (config()->get('birthday_enabled') && $current_date == $user_birthday) ? '<img src="' . $images['icon_birthday'] . '" alt="' . $lang['HAPPY_BIRTHDAY'] . '" title="' . $lang['HAPPY_BIRTHDAY'] . '" border="0" />' : ''; return (tp_config()->get('birthday_enabled') && $current_date == $user_birthday) ? '<img src="' . $images['icon_birthday'] . '" alt="' . $lang['HAPPY_BIRTHDAY'] . '" title="' . $lang['HAPPY_BIRTHDAY'] . '" border="0" />' : '';
} }
/** /**
@ -2180,7 +2180,7 @@ function readUpdaterFile(): array|bool
*/ */
function infoByIP(string $ipAddress, int $port = 0): array function infoByIP(string $ipAddress, int $port = 0): array
{ {
if (!config()->get('ip2country_settings.enabled')) { if (!tp_config()->get('ip2country_settings.enabled')) {
return []; return [];
} }
@ -2191,14 +2191,14 @@ function infoByIP(string $ipAddress, int $port = 0): array
$data = []; $data = [];
$contextOptions = []; $contextOptions = [];
if (!empty(config()->get('ip2country_settings.api_token'))) { if (!empty(tp_config()->get('ip2country_settings.api_token'))) {
$contextOptions['http'] = [ $contextOptions['http'] = [
'header' => "Authorization: Bearer " . config()->get('ip2country_settings.api_token') . "\r\n" 'header' => "Authorization: Bearer " . tp_config()->get('ip2country_settings.api_token') . "\r\n"
]; ];
} }
$context = stream_context_create($contextOptions); $context = stream_context_create($contextOptions);
$response = file_get_contents(config()->get('ip2country_settings.endpoint') . $ipAddress, context: $context); $response = file_get_contents(tp_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,7 +39,7 @@ function send_page($contents)
*/ */
function compress_output($contents) function compress_output($contents)
{ {
if (config()->get('gzip_compress') && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) { if (tp_config()->get('gzip_compress') && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
if (UA_GZIP_SUPPORTED && strlen($contents) > 2000) { if (UA_GZIP_SUPPORTED && strlen($contents) > 2000) {
if (!defined('MODERN_ROUTING')) { if (!defined('MODERN_ROUTING')) {
header('Content-Encoding: gzip'); header('Content-Encoding: gzip');
@ -59,7 +59,7 @@ if (!defined('IN_AJAX')) {
} }
// Cookie params // Cookie params
$c = config()->get('cookie_prefix'); $c = tp_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');
@ -86,13 +86,13 @@ 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
{ {
$cookie = new \Josantonius\Cookie\Cookie( $cookie = new \Josantonius\Cookie\Cookie(
domain: config()->get('cookie_domain'), domain: tp_config()->get('cookie_domain'),
expires: $lifetime, expires: $lifetime,
httpOnly: $httponly, httpOnly: $httponly,
path: config()->get('script_path'), path: tp_config()->get('script_path'),
raw: $isRaw, raw: $isRaw,
sameSite: config()->get('cookie_same_site'), sameSite: tp_config()->get('cookie_same_site'),
secure: config()->get('cookie_secure') secure: tp_config()->get('cookie_secure')
); );
if (!empty($val)) { if (!empty($val)) {
@ -272,14 +272,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', config()->get('dl_url')); define('DL_URL', tp_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', config()->get('login_url')); define('LOGIN_URL', tp_config()->get('login_url'));
define('MODCP_URL', 'modcp.php?' . POST_FORUM_URL . '='); define('MODCP_URL', 'modcp.php?' . POST_FORUM_URL . '=');
define('PM_URL', config()->get('pm_url')); define('PM_URL', tp_config()->get('pm_url'));
define('POST_URL', 'viewtopic.php?' . POST_POST_URL . '='); define('POST_URL', 'viewtopic.php?' . POST_POST_URL . '=');
define('POSTING_URL', config()->get('posting_url')); define('POSTING_URL', tp_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 . '=');
@ -379,8 +379,8 @@ require_once INC_DIR . '/functions.php';
// Merge database configuration with base configuration using singleton // Merge database configuration with base configuration using singleton
// bb_cfg deprecated, but kept for compatibility with non-adapted code // bb_cfg deprecated, but kept for compatibility with non-adapted code
config()->merge(bb_get_config(BB_CONFIG)); tp_config()->merge(bb_get_config(BB_CONFIG));
$bb_cfg = config()->all(); $bb_cfg = tp_config()->all();
// wordCensor deprecated, but kept for compatibility with non-adapted code // wordCensor deprecated, but kept for compatibility with non-adapted code
$wordCensor = censor(); $wordCensor = censor();
@ -400,7 +400,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 - config()->get('cron_last_check') > config()->get('cron_check_interval')) { if (TIMENOW - tp_config()->get('cron_last_check') > tp_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]);
@ -440,8 +440,8 @@ if (
/** /**
* Exit if board is disabled via trigger * Exit if board is disabled via trigger
*/ */
if ((config()->get('board_disable') || is_file(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN')) { if ((tp_config()->get('board_disable') || is_file(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN')) {
if (config()->get('board_disable')) { if (tp_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 > config()->get('record_online_users')) { if ($total_online > tp_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

@ -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 (!config()->get('gzip_compress')) { if (!tp_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 .= config()->get('gzip_compress') ? $lang['ON'] : $lang['OFF']; $gzip_text .= tp_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'];
@ -55,7 +55,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(config()->get('mem_on_start'), 2) . ' / '; $stat .= humn_size(tp_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);
@ -87,7 +87,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_' . config()->get('default_lang')); caching_output(true, 'store', REQUESTED_PAGE . '_guest_' . tp_config()->get('default_lang'));
} }
} }

View file

@ -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'], config()->get('record_online_users'), bb_date(config()->get('record_online_date'))), 'RECORD_USERS' => sprintf($lang['RECORD_ONLINE_USERS'], tp_config()->get('record_online_users'), bb_date(tp_config()->get('record_online_date'))),
]); ]);
} }
@ -125,12 +125,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' => !config()->get('board_disable') && (!isset($page_cfg['allow_robots']) || $page_cfg['allow_robots'] === true), 'ALLOW_ROBOTS' => !tp_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' => config()->get('sitename'), 'SITENAME' => tp_config()->get('sitename'),
'U_INDEX' => BB_ROOT . 'index.php', 'U_INDEX' => BB_ROOT . 'index.php',
'T_INDEX' => sprintf($lang['FORUM_INDEX'], config()->get('sitename')), 'T_INDEX' => sprintf($lang['FORUM_INDEX'], tp_config()->get('sitename')),
'IS_GUEST' => IS_GUEST, 'IS_GUEST' => IS_GUEST,
'IS_USER' => IS_USER, 'IS_USER' => IS_USER,
@ -141,9 +141,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, config()->get('last_visit_date_format'), false)), 'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, tp_config()->get('last_visit_date_format'), false)),
'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', (float)config()->get('board_timezone'))])), 'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', (float)tp_config()->get('board_timezone'))])),
'BOARD_TIMEZONE' => config()->get('board_timezone'), 'BOARD_TIMEZONE' => tp_config()->get('board_timezone'),
'PM_INFO' => $pm_info, 'PM_INFO' => $pm_info,
'PRIVMSG_IMG' => $icon_pm, 'PRIVMSG_IMG' => $icon_pm,
@ -154,7 +154,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' => !config()->get('allow_autologin'), 'AUTOLOGIN_DISABLED' => !tp_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'],
@ -170,11 +170,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' => config()->get('terms_and_conditions_url'), 'U_TERMS' => tp_config()->get('terms_and_conditions_url'),
'U_TRACKER' => 'tracker.php', 'U_TRACKER' => 'tracker.php',
'SHOW_SIDEBAR1' => !empty(config()->get('page.show_sidebar1')[$bb_script]) || config()->get('show_sidebar1_on_every_page'), 'SHOW_SIDEBAR1' => !empty(tp_config()->get('page.show_sidebar1')[$bb_script]) || tp_config()->get('show_sidebar1_on_every_page'),
'SHOW_SIDEBAR2' => !empty(config()->get('page.show_sidebar2')[$bb_script]) || config()->get('show_sidebar2_on_every_page'), 'SHOW_SIDEBAR2' => !empty(tp_config()->get('page.show_sidebar2')[$bb_script]) || tp_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',
@ -188,11 +188,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' => config()->get('login_url'), 'LOGIN_URL' => tp_config()->get('login_url'),
'NEWEST_URL' => '&amp;view=newest#newest', 'NEWEST_URL' => '&amp;view=newest#newest',
'PM_URL' => config()->get('pm_url'), 'PM_URL' => tp_config()->get('pm_url'),
'POST_URL' => BB_ROOT . POST_URL, 'POST_URL' => BB_ROOT . POST_URL,
'POSTING_URL' => config()->get('posting_url'), 'POSTING_URL' => tp_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,
@ -211,7 +211,7 @@ $template->assign_vars([
'U_WATCHED_TOPICS' => 'profile.php?mode=watch' 'U_WATCHED_TOPICS' => 'profile.php?mode=watch'
]); ]);
if (!empty(config()->get('page.show_torhelp')[$bb_script]) && !empty($userdata['torhelp'])) { if (!empty(tp_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) {
@ -252,6 +252,6 @@ $template->pparse('page_header');
define('PAGE_HEADER_SENT', true); define('PAGE_HEADER_SENT', true);
if (!config()->get('gzip_compress')) { if (!tp_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 = (config()->get('bt_dl_list_only_count') && !(@$_GET['dl'] === 'names')); $count_mode = (tp_config()->get('bt_dl_list_only_count') && !(@$_GET['dl'] === 'names'));
$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')); $have_dl_buttons_enabled = (tp_config()->get('bt_show_dl_but_will') || tp_config()->get('bt_show_dl_but_down') || tp_config()->get('bt_show_dl_but_compl') || tp_config()->get('bt_show_dl_but_cancel'));
$dl_topic = ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL && !(config()->get('bt_dl_list_only_1st_page') && $start)); $dl_topic = ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL && !(tp_config()->get('bt_dl_list_only_1st_page') && $start));
$show_dl_list = ($dl_topic && (config()->get('bt_show_dl_list') || (config()->get('allow_dl_list_names_mode') && @$_GET['dl'] === 'names'))); $show_dl_list = ($dl_topic && (tp_config()->get('bt_show_dl_list') || (tp_config()->get('allow_dl_list_names_mode') && @$_GET['dl'] === 'names')));
$show_dl_buttons = (!IS_GUEST && $dl_topic && config()->get('bt_show_dl_list_buttons')); $show_dl_buttons = (!IS_GUEST && $dl_topic && tp_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 (config()->get('bt_show_dl_list_buttons') && $have_dl_buttons_enabled) { } elseif (tp_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' => config()->get('bt_show_dl_but_will'), 'DL_BUT_WILL' => tp_config()->get('bt_show_dl_but_will'),
'DL_BUT_DOWN' => config()->get('bt_show_dl_but_down'), 'DL_BUT_DOWN' => tp_config()->get('bt_show_dl_but_down'),
'DL_BUT_COMPL' => config()->get('bt_show_dl_but_compl'), 'DL_BUT_COMPL' => tp_config()->get('bt_show_dl_but_compl'),
'DL_BUT_CANCEL' => config()->get('bt_show_dl_but_cancel') 'DL_BUT_CANCEL' => tp_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 (config()->get('seed_bonus_enabled') && config()->get('bonus_upload') && config()->get('bonus_upload_price')) { if (tp_config()->get('seed_bonus_enabled') && tp_config()->get('bonus_upload') && tp_config()->get('bonus_upload_price')) {
$upload_row = unserialize(config()->get('bonus_upload')); $upload_row = unserialize(tp_config()->get('bonus_upload'));
$price_row = unserialize(config()->get('bonus_upload_price')); $price_row = unserialize(tp_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 (!config()->get('board_email_form')) { if (!tp_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) {
config()->set('reg_email_activation', false); tp_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 (config()->get('unique_ip')) { if (tp_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>', config()->get('tech_admin_email'))); bb_die(sprintf($lang['ALREADY_REG_IP'], '<a href="' . PROFILE_URL . $users['user_id'] . '"><b>' . $users['username'] . '</b></a>', tp_config()->get('tech_admin_email')));
} }
} }
// Disabling registration // Disabling registration
if (config()->get('new_user_reg_disabled') || (config()->get('reg_email_activation') && !config()->get('emailer.enabled'))) { if (tp_config()->get('new_user_reg_disabled') || (tp_config()->get('reg_email_activation') && !tp_config()->get('emailer.enabled'))) {
bb_die($lang['NEW_USER_REG_DISABLED']); bb_die($lang['NEW_USER_REG_DISABLED']);
} // Time limit } // Time limit
elseif (config()->get('new_user_reg_restricted')) { elseif (tp_config()->get('new_user_reg_restricted')) {
if (in_array(date('G'), config()->get('new_user_reg_interval'), true)) { if (in_array(date('G'), tp_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' => config()->get('board_timezone'), 'user_timezone' => tp_config()->get('board_timezone'),
'user_lang' => config()->get('default_lang'), 'user_lang' => tp_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 || config()->get('allow_namechange')) && !IN_DEMO_MODE, 'username' => (IS_ADMIN || tp_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' => config()->get('allow_change.language'), 'user_lang' => tp_config()->get('allow_change.language'),
'user_gender' => config()->get('gender'), 'user_gender' => tp_config()->get('gender'),
'user_birthday' => config()->get('birthday_enabled'), 'user_birthday' => tp_config()->get('birthday_enabled'),
'user_timezone' => config()->get('allow_change.timezone'), 'user_timezone' => tp_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 && !config()->get('captcha.disabled')); $need_captcha = ($mode == 'register' && !IS_ADMIN && !tp_config()->get('captcha.disabled'));
if ($submit) { if ($submit) {
if ($need_captcha && !bb_captcha('check')) { if ($need_captcha && !bb_captcha('check')) {
@ -203,10 +203,10 @@ foreach ($profile_fields as $field => $can_edit) {
* Invite code (reg) * Invite code (reg)
*/ */
case 'invite_code': case 'invite_code':
if (config()->get('invites_system.enabled')) { if (tp_config()->get('invites_system.enabled')) {
$invite_code = $_POST['invite_code'] ?? ''; $invite_code = $_POST['invite_code'] ?? '';
if ($submit) { if ($submit) {
$inviteCodes = config()->get('invites_system.codes'); $inviteCodes = tp_config()->get('invites_system.codes');
if (isset($inviteCodes[$invite_code])) { if (isset($inviteCodes[$invite_code])) {
if ($inviteCodes[$invite_code] !== 'permanent') { if ($inviteCodes[$invite_code] !== 'permanent') {
if (TIMENOW > strtotime($inviteCodes[$invite_code])) { if (TIMENOW > strtotime($inviteCodes[$invite_code])) {
@ -265,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 (config()->get('email_change_disabled') && !$adm_edit && !IS_ADMIN) { if (tp_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) {
@ -274,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 (config()->get('reg_email_activation')) { if (tp_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;
} }
@ -337,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'] > config()->get('birthday_max_age')) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > tp_config()->get('birthday_max_age')) {
$errors[] = sprintf($lang['BIRTHDAY_TO_HIGH'], config()->get('birthday_max_age')); $errors[] = sprintf($lang['BIRTHDAY_TO_HIGH'], tp_config()->get('birthday_max_age'));
} elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < config()->get('birthday_min_age')) { } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < tp_config()->get('birthday_min_age')) {
$errors[] = sprintf($lang['BIRTHDAY_TO_LOW'], config()->get('birthday_min_age')); $errors[] = sprintf($lang['BIRTHDAY_TO_LOW'], tp_config()->get('birthday_min_age'));
} }
} }
@ -358,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 || config()->get('show_email_visibility_settings')), 'user_viewemail' => $reg_mode ? false : (IS_ADMIN || tp_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 : config()->get('pm_notify_enabled'), 'user_notify_pm' => $reg_mode ? true : tp_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 : config()->get('ip2country_settings.enabled'), 'user_hide_peer_country' => $reg_mode ? true : tp_config()->get('ip2country_settings.enabled'),
'user_hide_peer_username' => $reg_mode ? false : true, 'user_hide_peer_username' => $reg_mode ? false : true,
]; ];
@ -391,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'], config()->get('avatars.max_height')); $monsterAvatar = new Arokettu\MonsterID\Monster($pr_data['user_email'], tp_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);
@ -413,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']) && config()->get('avatars.up_allowed')) { } elseif (!empty($_FILES['avatar']['name']) && tp_config()->get('avatars.up_allowed')) {
$upload = new TorrentPier\Legacy\Common\Upload(); $upload = new TorrentPier\Legacy\Common\Upload();
if ($upload->init(config()->getSection('avatars'), $_FILES['avatar'], !isset($_POST['use_monster_avatar'])) and $upload->store('avatar', $pr_data)) { if ($upload->init(tp_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 {
@ -424,7 +424,7 @@ foreach ($profile_fields as $field => $can_edit) {
} }
} }
} }
$tp_data['AVATARS_MAX_SIZE'] = humn_size(config()->get('avatars.max_size')); $tp_data['AVATARS_MAX_SIZE'] = humn_size(tp_config()->get('avatars.max_size'));
break; break;
/** /**
@ -485,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) > config()->get('max_sig_chars')) { if (mb_strlen($sig, DEFAULT_CHARSET) > tp_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'];
@ -560,9 +560,9 @@ 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'] = config()->get('tpl_name'); $pr_data['tpl_name'] = tp_config()->get('tpl_name');
$db_data['tpl_name'] = (string)config()->get('tpl_name'); $db_data['tpl_name'] = (string)tp_config()->get('tpl_name');
$availableTemplates = config()->get('templates'); $availableTemplates = tp_config()->get('templates');
foreach ($availableTemplates as $folder => $name) { foreach ($availableTemplates as $folder => $name) {
if ($templates == $folder) { if ($templates == $folder) {
$pr_data['tpl_name'] = $templates; $pr_data['tpl_name'] = $templates;
@ -587,7 +587,7 @@ if ($submit && !$errors) {
* Создание нового профиля * Создание нового профиля
*/ */
if ($mode == 'register') { if ($mode == 'register') {
if (config()->get('reg_email_activation')) { if (tp_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;
@ -602,7 +602,7 @@ if ($submit && !$errors) {
} }
if (!isset($db_data['tpl_name'])) { if (!isset($db_data['tpl_name'])) {
$db_data['tpl_name'] = (string)config()->get('tpl_name'); $db_data['tpl_name'] = (string)tp_config()->get('tpl_name');
} }
$sql_args = DB()->build_array('INSERT', $db_data); $sql_args = DB()->build_array('INSERT', $db_data);
@ -624,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 (config()->get('reg_email_activation')) { if (tp_config()->get('reg_email_activation')) {
$message = $lang['ACCOUNT_INACTIVE']; $message = $lang['ACCOUNT_INACTIVE'];
$email_subject = sprintf($lang['EMAILER_SUBJECT']['USER_WELCOME_INACTIVE'], config()->get('sitename')); $email_subject = sprintf($lang['EMAILER_SUBJECT']['USER_WELCOME_INACTIVE'], tp_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'], config()->get('sitename')); $email_subject = sprintf($lang['EMAILER_SUBJECT']['USER_WELCOME'], tp_config()->get('sitename'));
$email_template = 'user_welcome'; $email_template = 'user_welcome';
} }
@ -642,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'], config()->get('sitename')), 'WELCOME_MSG' => sprintf($lang['WELCOME_SUBJECT'], tp_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'])
@ -730,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'], config()->get('avatars.max_width'), config()->get('avatars.max_height'), humn_size(config()->get('avatars.max_size'))), 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], tp_config()->get('avatars.max_width'), tp_config()->get('avatars.max_height'), humn_size(tp_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'], config()->get('terms_and_conditions_url')), 'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], tp_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'], config()->get('max_sig_chars')), 'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], tp_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 (!config()->get('emailer.enabled')) { if (!tp_config()->get('emailer.enabled')) {
bb_die($lang['EMAILER_DISABLED']); bb_die($lang['EMAILER_DISABLED']);
} }
$need_captcha = ($_GET['mode'] == 'sendpassword' && !IS_ADMIN && !config()->get('captcha.disabled')); $need_captcha = ($_GET['mode'] == 'sendpassword' && !IS_ADMIN && !tp_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 (!config()->get('topic_notify_enabled')) { if (!tp_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 = config()->get('topics_per_page'); $per_page = tp_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'], config()->get('posts_per_page')) 'PAGINATION' => ($watch[$i]['topic_status'] == TOPIC_MOVED) ? '' : build_topic_pagination(TOPIC_URL . $watch[$i]['topic_id'], $watch[$i]['topic_replies'], tp_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 = (config()->get('board_email_form')) ? 'profile.php?mode=email&amp;' . POST_USERS_URL . '=' . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email']; $email_uri = (tp_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 = (config()->get('allow_sig') && $profiledata['user_sig']) ? $profiledata['user_sig'] : ''; $signature = (tp_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 (config()->get('ratio_null_enabled') && $btu = get_bt_userdata($profiledata['user_id'])) { if (tp_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' => config()->get('gender') ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', 'GENDER' => tp_config()->get('gender') ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '',
'BIRTHDAY' => (config()->get('birthday_enabled') && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? $profiledata['user_birthday'] : '', 'BIRTHDAY' => (tp_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' => (config()->get('birthday_enabled') && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? birthday_age($profiledata['user_birthday']) : '', 'AGE' => (tp_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

@ -25,7 +25,7 @@ The system follows TorrentPier's consistent singleton pattern, similar to `confi
```php ```php
// Main singleton instance // Main singleton instance
TorrentPier\Cache\UnifiedCacheSystem::getInstance(config()->all()); TorrentPier\Cache\UnifiedCacheSystem::getInstance(tp_config()->all());
// Clean global functions with proper return types // Clean global functions with proper return types
function CACHE(string $cache_name): \TorrentPier\Cache\CacheManager function CACHE(string $cache_name): \TorrentPier\Cache\CacheManager
@ -134,7 +134,7 @@ The system integrates seamlessly in `library/includes/functions.php`:
```php ```php
// Singleton initialization (done once) // Singleton initialization (done once)
TorrentPier\Cache\UnifiedCacheSystem::getInstance(config()->all()); TorrentPier\Cache\UnifiedCacheSystem::getInstance(tp_config()->all());
// Global functions provide backward compatibility // Global functions provide backward compatibility
function CACHE(string $cache_name): \TorrentPier\Cache\CacheManager { function CACHE(string $cache_name): \TorrentPier\Cache\CacheManager {
@ -142,7 +142,7 @@ function CACHE(string $cache_name): \TorrentPier\Cache\CacheManager {
} }
function datastore(): \TorrentPier\Cache\DatastoreManager { function datastore(): \TorrentPier\Cache\DatastoreManager {
return TorrentPier\Cache\UnifiedCacheSystem::getInstance()->getDatastore(config()->get('datastore_type', 'file')); return TorrentPier\Cache\UnifiedCacheSystem::getInstance()->getDatastore(tp_config()->get('datastore_type', 'file'));
} }
``` ```

View file

@ -82,8 +82,8 @@ The database configuration is handled through the existing TorrentPier config sy
```php ```php
// Initialized in common.php // Initialized in common.php
TorrentPier\Database\DatabaseFactory::init( TorrentPier\Database\DatabaseFactory::init(
config()->get('db'), // Database configurations tp_config()->get('db'), // Database configurations
config()->get('db_alias', []) // Database aliases tp_config()->get('db_alias', []) // Database aliases
); );
``` ```

View file

@ -115,7 +115,7 @@ class Dev
$telegramSender->loggerOnly(true); $telegramSender->loggerOnly(true);
$telegramSender->setLogger((new Logger( $telegramSender->setLogger((new Logger(
APP_NAME, APP_NAME,
[(new TelegramHandler(tp_config()->get('telegram_sender.token'), (int)tp_config()->get('telegram_sender.chat_id'), timeout: (int)config()->get('telegram_sender.timeout'))) [(new TelegramHandler(tp_config()->get('telegram_sender.token'), (int)tp_config()->get('telegram_sender.chat_id'), timeout: (int)tp_config()->get('telegram_sender.timeout')))
->setFormatter(new TelegramFormatter())] ->setFormatter(new TelegramFormatter())]
))); )));
$this->whoops->pushHandler($telegramSender); $this->whoops->pushHandler($telegramSender);

View file

@ -59,7 +59,7 @@ class Language
// Determine language to use // Determine language to use
if (empty($userLang)) { if (empty($userLang)) {
$userLang = config()->get('default_lang', 'en'); $userLang = tp_config()->get('default_lang', 'en');
} }
$this->currentLanguage = $userLang; $this->currentLanguage = $userLang;
@ -71,7 +71,7 @@ class Language
$this->loadUserLanguage($userLang); $this->loadUserLanguage($userLang);
// Set locale // Set locale
$locale = config()->get("lang.{$userLang}.locale", 'en_US.UTF-8'); $locale = tp_config()->get("lang.{$userLang}.locale", 'en_US.UTF-8');
setlocale(LC_ALL, $locale); setlocale(LC_ALL, $locale);
$this->initialized = true; $this->initialized = true;
@ -105,7 +105,7 @@ class Language
$this->userLanguage = $lang; $this->userLanguage = $lang;
} else { } else {
// Fall back to default language if user language doesn't exist // Fall back to default language if user language doesn't exist
$defaultFile = LANG_ROOT_DIR . '/' . config()->get('default_lang', 'source') . '/main.php'; $defaultFile = LANG_ROOT_DIR . '/' . tp_config()->get('default_lang', 'source') . '/main.php';
if (is_file($defaultFile)) { if (is_file($defaultFile)) {
$lang = []; $lang = [];
require $defaultFile; require $defaultFile;
@ -192,7 +192,7 @@ class Language
*/ */
public function getAvailableLanguages(): array public function getAvailableLanguages(): array
{ {
return config()->get('lang', []); return tp_config()->get('lang', []);
} }
/** /**
@ -287,7 +287,7 @@ class Language
$code = $this->currentLanguage; $code = $this->currentLanguage;
} }
return config()->get("lang.{$code}.name", $code); return tp_config()->get("lang.{$code}.name", $code);
} }
/** /**
@ -299,7 +299,7 @@ class Language
$code = $this->currentLanguage; $code = $this->currentLanguage;
} }
return config()->get("lang.{$code}.locale", 'en_US.UTF-8'); return tp_config()->get("lang.{$code}.locale", 'en_US.UTF-8');
} }
/** /**

View file

@ -393,7 +393,7 @@ class BBCode
*/ */
private function nofollow_url(string $href, string $name): string private function nofollow_url(string $href, string $name): string
{ {
if (\in_array(parse_url($href, PHP_URL_HOST), tp_config()->get('nofollow.allowed_url')) || config()->get('nofollow.disabled')) { if (\in_array(parse_url($href, PHP_URL_HOST), tp_config()->get('nofollow.allowed_url')) || tp_config()->get('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

@ -530,8 +530,8 @@ class User
return $this->create_autologin_id($userdata); return $this->create_autologin_id($userdata);
} }
if ($autologin_id && $userdata['user_session_time'] && config()->get('max_autologin_time')) { if ($autologin_id && $userdata['user_session_time'] && tp_config()->get('max_autologin_time')) {
if (TIMENOW - $userdata['user_session_time'] > config()->get('max_autologin_time') * 86400) { if (TIMENOW - $userdata['user_session_time'] > tp_config()->get('max_autologin_time') * 86400) {
return $this->create_autologin_id($userdata, $create_new); return $this->create_autologin_id($userdata, $create_new);
} }
} }
@ -590,32 +590,32 @@ class User
} // prevent multiple calling } // prevent multiple calling
// Apply browser language // Apply browser language
if (config()->get('auto_language_detection') && IS_GUEST && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { if (tp_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(config()->get('lang')[$http_accept_language])) { if (isset(tp_config()->get('lang')[$http_accept_language])) {
config()->set('default_lang', $http_accept_language); tp_config()->set('default_lang', $http_accept_language);
} }
} }
define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . config()->get('default_lang') . '/'); define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . tp_config()->get('default_lang') . '/');
define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/en/'); define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/en/');
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'] != config()->get('default_lang')) { if ($this->data['user_lang'] && $this->data['user_lang'] != tp_config()->get('default_lang')) {
config()->set('default_lang', basename($this->data['user_lang'])); tp_config()->set('default_lang', basename($this->data['user_lang']));
define('LANG_DIR', LANG_ROOT_DIR . '/' . config()->get('default_lang') . '/'); define('LANG_DIR', LANG_ROOT_DIR . '/' . tp_config()->get('default_lang') . '/');
} }
if (isset($this->data['user_timezone'])) { if (isset($this->data['user_timezone'])) {
config()->set('board_timezone', $this->data['user_timezone']); tp_config()->set('board_timezone', $this->data['user_timezone']);
} }
} }
$this->data['user_lang'] = config()->get('default_lang'); $this->data['user_lang'] = tp_config()->get('default_lang');
$this->data['user_timezone'] = config()->get('board_timezone'); $this->data['user_timezone'] = tp_config()->get('board_timezone');
if (!defined('LANG_DIR')) { if (!defined('LANG_DIR')) {
define('LANG_DIR', DEFAULT_LANG_DIR); define('LANG_DIR', DEFAULT_LANG_DIR);
@ -795,7 +795,7 @@ class User
public function checkPassword(string $enteredPassword, array $userdata): bool public function checkPassword(string $enteredPassword, array $userdata): bool
{ {
if (password_verify($enteredPassword, $userdata['user_password'])) { if (password_verify($enteredPassword, $userdata['user_password'])) {
if (password_needs_rehash($userdata['user_password'], config()->get('password_hash_options.algo'), config()->get('password_hash_options.options'))) { if (password_needs_rehash($userdata['user_password'], tp_config()->get('password_hash_options.algo'), tp_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");
} }
@ -821,6 +821,6 @@ class User
*/ */
public function password_hash(string $enteredPassword): string public function password_hash(string $enteredPassword): string
{ {
return password_hash($enteredPassword, config()->get('password_hash_options.algo'), config()->get('password_hash_options.options')); return password_hash($enteredPassword, tp_config()->get('password_hash_options.algo'), tp_config()->get('password_hash_options.options'));
} }
} }

View file

@ -343,7 +343,7 @@ class Post
{ {
global $lang, $userdata; global $lang, $userdata;
if (!config()->get('topic_notify_enabled')) { if (!tp_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' => config()->get('sitename'), 'SITENAME' => tp_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,
@ -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 " . config()->get('posts_per_page') . " LIMIT " . tp_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'], config()->get('post_date_format')), 'POST_DATE' => bb_date($post['post_time'], tp_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

@ -109,7 +109,7 @@ class Template
$this->tpl = basename($root); $this->tpl = basename($root);
// Use Language singleton but maintain backward compatibility with global $lang // Use Language singleton but maintain backward compatibility with global $lang
$this->lang =& $lang; $this->lang =& $lang;
$this->use_cache = config()->get('xs_use_cache'); $this->use_cache = tp_config()->get('xs_use_cache');
// Check template exists // Check template exists
if (!is_dir($this->root)) { if (!is_dir($this->root)) {
@ -996,7 +996,7 @@ class Template
{ {
// 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'] ??= config()->get('default_lang'); $this->vars['LANG'] ??= tp_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

@ -132,7 +132,7 @@ class Torrent
} }
// Unset DL-Type for topic // Unset DL-Type for topic
if (config()->get('bt_unset_dltype_on_tor_unreg') && $topic_id) { if (tp_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 (config()->get('torr_server.enabled')) { if (tp_config()->get('torr_server.enabled')) {
$torrServer = new TorrServerAPI(); $torrServer = new TorrServerAPI();
$torrServer->removeM3U($attach_id); $torrServer->removeM3U($attach_id);
} }
@ -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 (config()->get('bt_disable_dht')) { if (tp_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 (config()->get('bt_check_announce_url')) { if (tp_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'] = config()->get('bt_announce_url'); $announce_urls['main_url'] = tp_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 (config()->get('tracker.disabled_v1_torrents') && isset($bt_v1) && !isset($bt_v2)) { if (tp_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 (config()->get('tracker.disabled_v2_torrents') && !isset($bt_v1) && isset($bt_v2)) { if (tp_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 (config()->get('torr_server.enabled')) { if (tp_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 (config()->get('bt_set_dltype_on_tor_reg')) { if (tp_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 (config()->get('tracker.tor_topic_up')) { if (tp_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");
} }
@ -496,7 +496,7 @@ class Torrent
{ {
global $attachment, $auth_pages, $userdata, $lang; global $attachment, $auth_pages, $userdata, $lang;
if (!config()->get('bt_add_auth_key') || $attachment['extension'] !== TORRENT_EXT || !$size = @filesize($filename)) { if (!tp_config()->get('bt_add_auth_key') || $attachment['extension'] !== TORRENT_EXT || !$size = @filesize($filename)) {
return; return;
} }
@ -504,7 +504,7 @@ 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 = config()->get('passkey_key')) { if (!$passkey_key = tp_config()->get('passkey_key')) {
bb_die('Could not add passkey (wrong config passkey_key)'); bb_die('Could not add passkey (wrong config passkey_key)');
} }
@ -543,7 +543,7 @@ class Torrent
} }
// Ratio limits // Ratio limits
$min_ratio = config()->get('bt_min_ratio_allow_dl_tor'); $min_ratio = tp_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 = config()->get('bt_announce_url') . "?$passkey_key=$passkey_val"; $announce_url = tp_config()->get('bt_announce_url') . "?$passkey_key=$passkey_val";
// Replace original announce url with tracker default // Replace original announce url with tracker default
if (config()->get('bt_replace_ann_url') || !isset($tor['announce'])) { if (tp_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']) || config()->get('bt_del_addit_ann_urls') || config()->get('bt_disable_dht')) { if (!isset($tor['announce-list']) || !is_array($tor['announce-list']) || tp_config()->get('bt_del_addit_ann_urls') || tp_config()->get('bt_disable_dht')) {
$tor['announce-list'] = []; $tor['announce-list'] = [];
} }
@ -597,15 +597,15 @@ class Torrent
} }
// Add retracker // Add retracker
if (!empty(config()->get('tracker.retracker_host')) && config()->get('tracker.retracker')) { if (!empty(tp_config()->get('tracker.retracker_host')) && tp_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'], [[config()->get('tracker.retracker_host')]]); $tor['announce-list'] = array_merge($tor['announce-list'], [[tp_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 (config()->get('bt_replace_ann_url')) { if (tp_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 = config()->get('server_name'); $publisher_name = tp_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 (config()->get('tracker.use_old_torrent_name_format')) { if (tp_config()->get('tracker.use_old_torrent_name_format')) {
$dl_fname = '[' . config()->get('server_name') . '].t' . $topic_id . '.' . TORRENT_EXT; $dl_fname = '[' . tp_config()->get('server_name') . '].t' . $topic_id . '.' . TORRENT_EXT;
} else { } else {
$dl_fname = html_ent_decode($topic_title) . ' [' . config()->get('server_name') . '-' . $topic_id . ']' . '.' . TORRENT_EXT; $dl_fname = html_ent_decode($topic_title) . ' [' . tp_config()->get('server_name') . '-' . $topic_id . ']' . '.' . TORRENT_EXT;
} }
if (!empty($_COOKIE['explain'])) { if (!empty($_COOKIE['explain'])) {

View file

@ -46,7 +46,7 @@ class TorrentFileList
$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'] ?? '', config()->get('flist_timeout')); return $this->fileTreeList($info['file tree'], $info['name'] ?? '', tp_config()->get('flist_timeout'));
} }
} }
@ -93,7 +93,7 @@ class TorrentFileList
continue; continue;
} }
$structure = array_deep($f['path'], 'clean_tor_dirname', timeout: config()->get('flist_timeout')); $structure = array_deep($f['path'], 'clean_tor_dirname', timeout: tp_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

@ -56,7 +56,7 @@ class Sessions
} }
$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, config()->get('session_update_intrv')); return CACHE('session_cache')->set($id, $userdata, tp_config()->get('session_update_intrv'));
} }
/** /**

View file

@ -52,7 +52,7 @@ class TorrServerAPI
*/ */
public function __construct() public function __construct()
{ {
$this->url = config()->get('torr_server.url') . '/'; $this->url = tp_config()->get('torr_server.url') . '/';
} }
/** /**
@ -70,7 +70,7 @@ class TorrServerAPI
} }
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout(config()->get('torr_server.timeout')); $curl->setTimeout(tp_config()->get('torr_server.timeout'));
$curl->setHeaders([ $curl->setHeaders([
'Accept' => 'application/json', 'Accept' => 'application/json',
@ -109,7 +109,7 @@ class TorrServerAPI
} }
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout(config()->get('torr_server.timeout')); $curl->setTimeout(tp_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]);
@ -206,7 +206,7 @@ class TorrServerAPI
} }
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout(config()->get('torr_server.timeout')); $curl->setTimeout(tp_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);
@ -231,7 +231,7 @@ class TorrServerAPI
private function getStream(string $hash): bool private function getStream(string $hash): bool
{ {
$curl = new Curl(); $curl = new Curl();
$curl->setTimeout(config()->get('torr_server.timeout')); $curl->setTimeout(tp_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

@ -117,7 +117,7 @@ class Validate
} }
// Extended email validation // Extended email validation
if (config()->get('extended_email_validation')) { if (tp_config()->get('extended_email_validation')) {
$validator = new EmailValidator(); $validator = new EmailValidator();
$multipleValidations = new MultipleValidationWithAnd([ $multipleValidations = new MultipleValidationWithAnd([
@ -175,9 +175,9 @@ class Validate
} }
// Symbols check // Symbols check
if (config()->get('password_symbols')) { if (tp_config()->get('password_symbols')) {
// Numbers // Numbers
if (config()->get('password_symbols.nums')) { if (tp_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'];
} }

View file

@ -14,7 +14,7 @@ $template_name = basename(__DIR__);
$_img = BB_ROOT . 'styles/images/'; $_img = BB_ROOT . 'styles/images/';
$_main = BB_ROOT . 'styles/' . basename(TEMPLATES_DIR) . '/' . $template_name . '/images/'; $_main = BB_ROOT . 'styles/' . basename(TEMPLATES_DIR) . '/' . $template_name . '/images/';
$_lang = $_main . 'lang/' . basename(config()->get('default_lang')) . '/'; $_lang = $_main . 'lang/' . basename(tp_config()->get('default_lang')) . '/';
// post_buttons // post_buttons
$images['icon_code'] = $_lang . 'icon_code.gif'; $images['icon_code'] = $_lang . 'icon_code.gif';
@ -117,13 +117,13 @@ $images['progress_bar_full'] = $_main . 'progress_bar_full.gif';
$template->assign_vars([ $template->assign_vars([
'IMG' => $_main, 'IMG' => $_main,
'TEXT_BUTTONS' => config()->get('text_buttons'), 'TEXT_BUTTONS' => tp_config()->get('text_buttons'),
'POST_BTN_SPACER' => config()->get('text_buttons') ? '&nbsp;' : '', 'POST_BTN_SPACER' => tp_config()->get('text_buttons') ? '&nbsp;' : '',
'TOPIC_ATTACH_ICON' => '<img src="' . $_img . 'icon_clip.gif" alt="" />', 'TOPIC_ATTACH_ICON' => '<img src="' . $_img . 'icon_clip.gif" alt="" />',
'OPEN_MENU_IMG_ALT' => '<img src="' . $_main . 'menu_open_1.gif" class="menu-alt1" alt="" />', 'OPEN_MENU_IMG_ALT' => '<img src="' . $_main . 'menu_open_1.gif" class="menu-alt1" alt="" />',
'TOPIC_LEFT_COL_SPACER_WITDH' => config()->get('topic_left_column_witdh') - 8, // 8px padding 'TOPIC_LEFT_COL_SPACER_WITDH' => tp_config()->get('topic_left_column_witdh') - 8, // 8px padding
'POST_IMG_WIDTH_DECR_JS' => config()->get('topic_left_column_witdh') + config()->get('post_img_width_decr'), 'POST_IMG_WIDTH_DECR_JS' => tp_config()->get('topic_left_column_witdh') + tp_config()->get('post_img_width_decr'),
'ATTACH_IMG_WIDTH_DECR_JS' => config()->get('topic_left_column_witdh') + config()->get('attach_img_width_decr'), 'ATTACH_IMG_WIDTH_DECR_JS' => tp_config()->get('topic_left_column_witdh') + tp_config()->get('attach_img_width_decr'),
'FEED_IMG' => '<img src="' . $_main . 'feed.png" class="feed-small" alt="' . $lang['ATOM_FEED'] . '" />', 'FEED_IMG' => '<img src="' . $_main . 'feed.png" class="feed-small" alt="' . $lang['ATOM_FEED'] . '" />',
]); ]);
@ -131,25 +131,25 @@ $template->assign_vars([
if (!empty($page_cfg['load_tpl_vars']) and $vars = array_flip($page_cfg['load_tpl_vars'])) { if (!empty($page_cfg['load_tpl_vars']) and $vars = array_flip($page_cfg['load_tpl_vars'])) {
if (isset($vars['post_buttons'])) { if (isset($vars['post_buttons'])) {
$template->assign_vars([ $template->assign_vars([
'CODE_IMG' => config()->get('text_buttons') ? $lang['CODE_TOPIC_TXTB'] : '<img src="' . $images['icon_code'] . '" alt="' . $lang['CODE_TOPIC_TXTB'] . '" title="' . $lang['CODE'] . '" />', 'CODE_IMG' => tp_config()->get('text_buttons') ? $lang['CODE_TOPIC_TXTB'] : '<img src="' . $images['icon_code'] . '" alt="' . $lang['CODE_TOPIC_TXTB'] . '" title="' . $lang['CODE'] . '" />',
'QUOTE_IMG' => config()->get('text_buttons') ? $lang['REPLY_WITH_QUOTE_TXTB'] : '<img src="' . $images['icon_quote'] . '" alt="' . $lang['REPLY_WITH_QUOTE_TXTB'] . '" title="' . $lang['REPLY_WITH_QUOTE'] . '" />', 'QUOTE_IMG' => tp_config()->get('text_buttons') ? $lang['REPLY_WITH_QUOTE_TXTB'] : '<img src="' . $images['icon_quote'] . '" alt="' . $lang['REPLY_WITH_QUOTE_TXTB'] . '" title="' . $lang['REPLY_WITH_QUOTE'] . '" />',
'EDIT_POST_IMG' => config()->get('text_buttons') ? $lang['EDIT_DELETE_POST_TXTB'] : '<img src="' . $images['icon_edit'] . '" alt="' . $lang['EDIT_DELETE_POST_TXTB'] . '" title="' . $lang['EDIT_POST'] . '" />', 'EDIT_POST_IMG' => tp_config()->get('text_buttons') ? $lang['EDIT_DELETE_POST_TXTB'] : '<img src="' . $images['icon_edit'] . '" alt="' . $lang['EDIT_DELETE_POST_TXTB'] . '" title="' . $lang['EDIT_POST'] . '" />',
'DELETE_POST_IMG' => config()->get('text_buttons') ? $lang['DELETE_POST_TXTB'] : '<img src="' . $images['icon_delpost'] . '" alt="' . $lang['DELETE_POST_TXTB'] . '" title="' . $lang['DELETE_POST'] . '" />', 'DELETE_POST_IMG' => tp_config()->get('text_buttons') ? $lang['DELETE_POST_TXTB'] : '<img src="' . $images['icon_delpost'] . '" alt="' . $lang['DELETE_POST_TXTB'] . '" title="' . $lang['DELETE_POST'] . '" />',
'IP_POST_IMG' => config()->get('text_buttons') ? $lang['VIEW_IP_TXTB'] : '<img src="' . $images['icon_ip'] . '" alt="' . $lang['VIEW_IP_TXTB'] . '" title="' . $lang['VIEW_IP'] . '" />', 'IP_POST_IMG' => tp_config()->get('text_buttons') ? $lang['VIEW_IP_TXTB'] : '<img src="' . $images['icon_ip'] . '" alt="' . $lang['VIEW_IP_TXTB'] . '" title="' . $lang['VIEW_IP'] . '" />',
'MOD_POST_IMG' => config()->get('text_buttons') ? $lang['MODERATE_POST_TXTB'] : '<img src="' . $images['icon_mod'] . '" alt="' . $lang['MODERATE_POST_TXTB'] . '" title="' . $lang['MODERATE_POST'] . '" />', 'MOD_POST_IMG' => tp_config()->get('text_buttons') ? $lang['MODERATE_POST_TXTB'] : '<img src="' . $images['icon_mod'] . '" alt="' . $lang['MODERATE_POST_TXTB'] . '" title="' . $lang['MODERATE_POST'] . '" />',
'MC_IMG' => config()->get('text_buttons') ? '[' . $lang['COMMENT'] . ']' : '<img src="' . $images['icon_mc'] . '" alt="[' . $lang['COMMENT'] . ']" title="' . $lang['COMMENT'] . '" />', 'MC_IMG' => tp_config()->get('text_buttons') ? '[' . $lang['COMMENT'] . ']' : '<img src="' . $images['icon_mc'] . '" alt="[' . $lang['COMMENT'] . ']" title="' . $lang['COMMENT'] . '" />',
'POLL_IMG' => config()->get('text_buttons') ? $lang['TOPIC_POLL'] : '<img src="' . $images['icon_poll'] . '" alt="' . $lang['TOPIC_POLL'] . '" title="' . $lang['ADD_POLL'] . '" />', 'POLL_IMG' => tp_config()->get('text_buttons') ? $lang['TOPIC_POLL'] : '<img src="' . $images['icon_poll'] . '" alt="' . $lang['TOPIC_POLL'] . '" title="' . $lang['ADD_POLL'] . '" />',
'QUOTE_URL' => BB_ROOT . POSTING_URL . '?mode=quote&amp;' . POST_POST_URL . '=', 'QUOTE_URL' => BB_ROOT . POSTING_URL . '?mode=quote&amp;' . POST_POST_URL . '=',
'EDIT_POST_URL' => BB_ROOT . POSTING_URL . '?mode=editpost&amp;' . POST_POST_URL . '=', 'EDIT_POST_URL' => BB_ROOT . POSTING_URL . '?mode=editpost&amp;' . POST_POST_URL . '=',
'DELETE_POST_URL' => BB_ROOT . POSTING_URL . '?mode=delete&amp;' . POST_POST_URL . '=', 'DELETE_POST_URL' => BB_ROOT . POSTING_URL . '?mode=delete&amp;' . POST_POST_URL . '=',
'IP_POST_URL' => BB_ROOT . 'modcp.php?mode=ip&amp;' . POST_POST_URL . '=', 'IP_POST_URL' => BB_ROOT . 'modcp.php?mode=ip&amp;' . POST_POST_URL . '=',
'PROFILE_IMG' => config()->get('text_buttons') ? $lang['READ_PROFILE_TXTB'] : '<img src="' . $images['icon_profile'] . '" alt="' . $lang['READ_PROFILE_TXTB'] . '" title="' . $lang['READ_PROFILE'] . '" />', 'PROFILE_IMG' => tp_config()->get('text_buttons') ? $lang['READ_PROFILE_TXTB'] : '<img src="' . $images['icon_profile'] . '" alt="' . $lang['READ_PROFILE_TXTB'] . '" title="' . $lang['READ_PROFILE'] . '" />',
'PM_IMG' => config()->get('text_buttons') ? $lang['SEND_PM_TXTB'] : '<img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PM_TXTB'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" />', 'PM_IMG' => tp_config()->get('text_buttons') ? $lang['SEND_PM_TXTB'] : '<img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PM_TXTB'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" />',
'EMAIL_IMG' => config()->get('text_buttons') ? $lang['SEND_EMAIL_TXTB'] : '<img src="' . $images['icon_email'] . '" alt="' . $lang['SEND_EMAIL_TXTB'] . '" title="' . $lang['SEND_EMAIL'] . '" />', 'EMAIL_IMG' => tp_config()->get('text_buttons') ? $lang['SEND_EMAIL_TXTB'] : '<img src="' . $images['icon_email'] . '" alt="' . $lang['SEND_EMAIL_TXTB'] . '" title="' . $lang['SEND_EMAIL'] . '" />',
'WWW_IMG' => config()->get('text_buttons') ? $lang['VISIT_WEBSITE_TXTB'] : '<img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE_TXTB'] . '" title="' . $lang['VISIT_WEBSITE'] . '" />', 'WWW_IMG' => tp_config()->get('text_buttons') ? $lang['VISIT_WEBSITE_TXTB'] : '<img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE_TXTB'] . '" title="' . $lang['VISIT_WEBSITE'] . '" />',
'ICQ_IMG' => config()->get('text_buttons') ? $lang['ICQ_TXTB'] : '<img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ_TXTB'] . '" title="' . $lang['ICQ'] . '" />', 'ICQ_IMG' => tp_config()->get('text_buttons') ? $lang['ICQ_TXTB'] : '<img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ_TXTB'] . '" title="' . $lang['ICQ'] . '" />',
'EMAIL_URL' => BB_ROOT . 'profile.php?mode=email&amp;' . POST_USERS_URL . '=', 'EMAIL_URL' => BB_ROOT . 'profile.php?mode=email&amp;' . POST_USERS_URL . '=',
'FORUM_URL' => BB_ROOT . FORUM_URL, 'FORUM_URL' => BB_ROOT . FORUM_URL,