feat: integrate Laravel Illuminate packages and modernize legacy code

- Add illuminate/collections, illuminate/config, illuminate/database, illuminate/events, illuminate/routing, and illuminate/validation packages
- Introduce comprehensive Illuminate integration documentation
- Add fakerphp/faker for testing data generation
- Resolve naming conflicts (config() -> tp_config()) for compatibility
- Update autoloader to use new app/helpers.php location

This integration provides Laravel-style features while maintaining backward compatibility with existing TorrentPier functionality.
This commit is contained in:
Yury Pikhtarev 2025-06-22 23:53:40 +04:00
commit b02aaf7255
No known key found for this signature in database
23 changed files with 988 additions and 102 deletions

View file

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

View file

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

View file

@ -14,7 +14,7 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php'; require __DIR__ . '/pagestart.php';
if (!config()->get('use_word_censor')) { if (!tp_config()->get('use_word_censor')) {
bb_die('Word censor disabled <br /><br /> (use_word_censor in config.php)'); bb_die('Word censor disabled <br /><br /> (use_word_censor in config.php)');
} }

View file

@ -18,8 +18,8 @@ if (empty($userAgent)) {
die; die;
} }
$announce_interval = config()->get('announce_interval'); $announce_interval = tp_config()->get('announce_interval');
$passkey_key = config()->get('passkey_key'); $passkey_key = tp_config()->get('passkey_key');
// Recover info_hash // Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) { if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
@ -65,10 +65,10 @@ if (strlen($peer_id) !== 20) {
} }
// Check for client ban // Check for client ban
if (config()->get('client_ban.enabled')) { if (tp_config()->get('client_ban.enabled')) {
$targetClient = []; $targetClient = [];
foreach (config()->get('client_ban.clients') as $clientId => $banReason) { foreach (tp_config()->get('client_ban.clients') as $clientId => $banReason) {
if (str_starts_with($peer_id, $clientId)) { if (str_starts_with($peer_id, $clientId)) {
$targetClient = [ $targetClient = [
'peer_id' => $clientId, 'peer_id' => $clientId,
@ -78,7 +78,7 @@ if (config()->get('client_ban.enabled')) {
} }
} }
if (config()->get('client_ban.only_allow_mode')) { if (tp_config()->get('client_ban.only_allow_mode')) {
if (empty($targetClient['peer_id'])) { if (empty($targetClient['peer_id'])) {
msg_die('Your BitTorrent client has been banned!'); msg_die('Your BitTorrent client has been banned!');
} }
@ -129,7 +129,7 @@ if (
|| !is_numeric($port) || !is_numeric($port)
|| ($port < 1024 && !$stopped) || ($port < 1024 && !$stopped)
|| $port > 0xFFFF || $port > 0xFFFF
|| (!empty(config()->get('disallowed_ports')) && in_array($port, config()->get('disallowed_ports'))) || (!empty(tp_config()->get('disallowed_ports')) && in_array($port, tp_config()->get('disallowed_ports')))
) { ) {
msg_die('Invalid port: ' . $port); msg_die('Invalid port: ' . $port);
} }
@ -168,13 +168,13 @@ if (preg_match('/(Mozilla|Browser|Chrome|Safari|AppleWebKit|Opera|Links|Lynx|Bot
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
// 'ip' query handling // 'ip' query handling
if (!config()->get('ignore_reported_ip') && isset($_GET['ip']) && $ip !== $_GET['ip']) { if (!tp_config()->get('ignore_reported_ip') && isset($_GET['ip']) && $ip !== $_GET['ip']) {
if (!config()->get('verify_reported_ip') && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { if (!tp_config()->get('verify_reported_ip') && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$x_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; $x_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if ($x_ip === $_GET['ip']) { if ($x_ip === $_GET['ip']) {
$filteredIp = filter_var($x_ip, FILTER_VALIDATE_IP); $filteredIp = filter_var($x_ip, FILTER_VALIDATE_IP);
if ($filteredIp !== false && (config()->get('allow_internal_ip') || !filter_var($filteredIp, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) { if ($filteredIp !== false && (tp_config()->get('allow_internal_ip') || !filter_var($filteredIp, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) {
$ip = $filteredIp; $ip = $filteredIp;
} }
} }
@ -270,7 +270,7 @@ if ($lp_info) {
define('IS_MOD', !IS_GUEST && (int)$row['user_level'] === MOD); define('IS_MOD', !IS_GUEST && (int)$row['user_level'] === MOD);
define('IS_GROUP_MEMBER', !IS_GUEST && (int)$row['user_level'] === GROUP_MEMBER); define('IS_GROUP_MEMBER', !IS_GUEST && (int)$row['user_level'] === GROUP_MEMBER);
define('IS_USER', !IS_GUEST && (int)$row['user_level'] === USER); define('IS_USER', !IS_GUEST && (int)$row['user_level'] === USER);
define('IS_SUPER_ADMIN', IS_ADMIN && isset(config()->get('super_admins')[$user_id])); define('IS_SUPER_ADMIN', IS_ADMIN && isset(tp_config()->get('super_admins')[$user_id]));
define('IS_AM', IS_ADMIN || IS_MOD); define('IS_AM', IS_ADMIN || IS_MOD);
$topic_id = $row['topic_id']; $topic_id = $row['topic_id'];
$releaser = (int)($user_id == $row['poster_id']); $releaser = (int)($user_id == $row['poster_id']);
@ -278,13 +278,13 @@ if ($lp_info) {
$tor_status = $row['tor_status']; $tor_status = $row['tor_status'];
// Check tor status // Check tor status
if (!IS_AM && isset(config()->get('tor_frozen')[$tor_status]) && !(isset(config()->get('tor_frozen_author_download')[$tor_status]) && $releaser)) { if (!IS_AM && isset(tp_config()->get('tor_frozen')[$tor_status]) && !(isset(tp_config()->get('tor_frozen_author_download')[$tor_status]) && $releaser)) {
msg_die('Torrent frozen and cannot be downloaded'); msg_die('Torrent frozen and cannot be downloaded');
} }
// Check hybrid status // Check hybrid status
if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) { if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) {
$stat_protocol = match ((int)config()->get('tracker.hybrid_stat_protocol')) { $stat_protocol = match ((int)tp_config()->get('tracker.hybrid_stat_protocol')) {
2 => substr($row['info_hash_v2'], 0, 20), 2 => substr($row['info_hash_v2'], 0, 20),
default => $row['info_hash'] // 1 default => $row['info_hash'] // 1
}; };
@ -294,7 +294,7 @@ if ($lp_info) {
} }
// Ratio limits // Ratio limits
if ((RATIO_ENABLED || config()->get('tracker.limit_concurrent_ips')) && !$stopped) { if ((RATIO_ENABLED || tp_config()->get('tracker.limit_concurrent_ips')) && !$stopped) {
$user_ratio = get_bt_ratio($row); $user_ratio = get_bt_ratio($row);
if ($user_ratio === null) { if ($user_ratio === null) {
$user_ratio = 1; $user_ratio = 1;
@ -302,10 +302,10 @@ if ($lp_info) {
$rating_msg = ''; $rating_msg = '';
if (!$seeder) { if (!$seeder) {
foreach (config()->get('rating') as $ratio => $limit) { foreach (tp_config()->get('rating') as $ratio => $limit) {
if ($user_ratio < $ratio) { if ($user_ratio < $ratio) {
config()->set('tracker.limit_active_tor', 1); tp_config()->set('tracker.limit_active_tor', 1);
config()->set('tracker.limit_leech_count', $limit); tp_config()->set('tracker.limit_leech_count', $limit);
$rating_msg = " (ratio < $ratio)"; $rating_msg = " (ratio < $ratio)";
break; break;
} }
@ -313,23 +313,23 @@ if ($lp_info) {
} }
// Limit active torrents // Limit active torrents
if (!isset(config()->get('unlimited_users')[$user_id]) && config()->get('tracker.limit_active_tor') && ((config()->get('tracker.limit_seed_count') && $seeder) || (config()->get('tracker.limit_leech_count') && !$seeder))) { 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))) {
$sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents $sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
FROM " . BB_BT_TRACKER . " FROM " . BB_BT_TRACKER . "
WHERE user_id = $user_id WHERE user_id = $user_id
AND seeder = $seeder AND seeder = $seeder
AND topic_id != $topic_id"; AND topic_id != $topic_id";
if (!$seeder && 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 * config()->get('tracker.leech_expire_factor'));
} }
$sql .= " GROUP BY user_id"; $sql .= " GROUP BY user_id";
if ($row = DB()->fetch_row($sql)) { if ($row = DB()->fetch_row($sql)) {
if ($seeder && config()->get('tracker.limit_seed_count') && $row['active_torrents'] >= config()->get('tracker.limit_seed_count')) { if ($seeder && tp_config()->get('tracker.limit_seed_count') && $row['active_torrents'] >= tp_config()->get('tracker.limit_seed_count')) {
msg_die('Only ' . config()->get('tracker.limit_seed_count') . ' torrent(s) allowed for seeding'); msg_die('Only ' . tp_config()->get('tracker.limit_seed_count') . ' torrent(s) allowed for seeding');
} elseif (!$seeder && config()->get('tracker.limit_leech_count') && $row['active_torrents'] >= config()->get('tracker.limit_leech_count')) { } elseif (!$seeder && tp_config()->get('tracker.limit_leech_count') && $row['active_torrents'] >= tp_config()->get('tracker.limit_leech_count')) {
msg_die('Only ' . config()->get('tracker.limit_leech_count') . ' torrent(s) allowed for leeching' . $rating_msg); msg_die('Only ' . tp_config()->get('tracker.limit_leech_count') . ' torrent(s) allowed for leeching' . $rating_msg);
} }
} }
} }

View file

@ -12,8 +12,8 @@ if (!defined('IN_TRACKER')) {
} }
// Exit if tracker is disabled // Exit if tracker is disabled
if (config()->get('tracker.bt_off')) { if (tp_config()->get('tracker.bt_off')) {
msg_die(config()->get('tracker.bt_off_reason')); msg_die(tp_config()->get('tracker.bt_off_reason'));
} }
// //

View file

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

View file

@ -55,13 +55,20 @@
"bugsnag/bugsnag": "^v3.29.1", "bugsnag/bugsnag": "^v3.29.1",
"claviska/simpleimage": "^4.0", "claviska/simpleimage": "^4.0",
"egulias/email-validator": "^4.0.1", "egulias/email-validator": "^4.0.1",
"fakerphp/faker": "^1.24",
"filp/whoops": "^2.15", "filp/whoops": "^2.15",
"gemorroj/m3u-parser": "^6.0.1", "gemorroj/m3u-parser": "^6.0.1",
"gigablah/sphinxphp": "2.0.8", "gigablah/sphinxphp": "2.0.8",
"google/recaptcha": "^1.3", "google/recaptcha": "^1.3",
"illuminate/collections": "^12.19",
"illuminate/config": "^12.19",
"illuminate/container": "^12.19", "illuminate/container": "^12.19",
"illuminate/database": "^12.19",
"illuminate/events": "^12.19",
"illuminate/http": "^12.19", "illuminate/http": "^12.19",
"illuminate/routing": "^12.19",
"illuminate/support": "^12.19", "illuminate/support": "^12.19",
"illuminate/validation": "^12.19",
"jacklul/monolog-telegram": "^3.1", "jacklul/monolog-telegram": "^3.1",
"josantonius/cookie": "^2.0", "josantonius/cookie": "^2.0",
"league/flysystem": "^3.28", "league/flysystem": "^3.28",
@ -88,7 +95,6 @@
"App\\": "app/" "App\\": "app/"
}, },
"files": [ "files": [
"src/helpers.php",
"app/helpers.php" "app/helpers.php"
] ]
}, },

670
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "99433ae342bb6c1dc1d9a8e9f933d1f1", "content-hash": "b6064b3dc730bc6bf800fdf90be38b43",
"packages": [ "packages": [
{ {
"name": "arokettu/bencode", "name": "arokettu/bencode",
@ -480,6 +480,66 @@
}, },
"time": "2025-03-10T13:15:53+00:00" "time": "2025-03-10T13:15:53+00:00"
}, },
{
"name": "brick/math",
"version": "0.13.1",
"source": {
"type": "git",
"url": "https://github.com/brick/math.git",
"reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/brick/math/zipball/fc7ed316430118cc7836bf45faff18d5dfc8de04",
"reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04",
"shasum": ""
},
"require": {
"php": "^8.1"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^10.1",
"vimeo/psalm": "6.8.8"
},
"type": "library",
"autoload": {
"psr-4": {
"Brick\\Math\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Arbitrary-precision arithmetic library",
"keywords": [
"Arbitrary-precision",
"BigInteger",
"BigRational",
"arithmetic",
"bigdecimal",
"bignum",
"bignumber",
"brick",
"decimal",
"integer",
"math",
"mathematics",
"rational"
],
"support": {
"issues": "https://github.com/brick/math/issues",
"source": "https://github.com/brick/math/tree/0.13.1"
},
"funding": [
{
"url": "https://github.com/BenMorel",
"type": "github"
}
],
"time": "2025-03-29T13:50:30+00:00"
},
{ {
"name": "bugsnag/bugsnag", "name": "bugsnag/bugsnag",
"version": "v3.29.3", "version": "v3.29.3",
@ -1300,6 +1360,69 @@
], ],
"time": "2025-03-06T22:45:56+00:00" "time": "2025-03-06T22:45:56+00:00"
}, },
{
"name": "fakerphp/faker",
"version": "v1.24.1",
"source": {
"type": "git",
"url": "https://github.com/FakerPHP/Faker.git",
"reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5",
"reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"psr/container": "^1.0 || ^2.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"conflict": {
"fzaninotto/faker": "*"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"doctrine/persistence": "^1.3 || ^2.0",
"ext-intl": "*",
"phpunit/phpunit": "^9.5.26",
"symfony/phpunit-bridge": "^5.4.16"
},
"suggest": {
"doctrine/orm": "Required to use Faker\\ORM\\Doctrine",
"ext-curl": "Required by Faker\\Provider\\Image to download images.",
"ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.",
"ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.",
"ext-mbstring": "Required for multibyte Unicode string functionality."
},
"type": "library",
"autoload": {
"psr-4": {
"Faker\\": "src/Faker/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Zaninotto"
}
],
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": [
"data",
"faker",
"fixtures"
],
"support": {
"issues": "https://github.com/FakerPHP/Faker/issues",
"source": "https://github.com/FakerPHP/Faker/tree/v1.24.1"
},
"time": "2024-11-21T13:46:39+00:00"
},
{ {
"name": "filp/whoops", "name": "filp/whoops",
"version": "2.18.3", "version": "2.18.3",
@ -2071,6 +2194,59 @@
], ],
"time": "2025-02-03T10:55:03+00:00" "time": "2025-02-03T10:55:03+00:00"
}, },
{
"name": "illuminate/bus",
"version": "v12.19.3",
"source": {
"type": "git",
"url": "https://github.com/illuminate/bus.git",
"reference": "60da78ea881c539ce56c5b66321be73755c5918c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/bus/zipball/60da78ea881c539ce56c5b66321be73755c5918c",
"reference": "60da78ea881c539ce56c5b66321be73755c5918c",
"shasum": ""
},
"require": {
"illuminate/collections": "^12.0",
"illuminate/contracts": "^12.0",
"illuminate/pipeline": "^12.0",
"illuminate/support": "^12.0",
"php": "^8.2"
},
"suggest": {
"illuminate/queue": "Required to use closures when chaining jobs (^12.0)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "12.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Bus\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Bus package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-05-13T15:08:45+00:00"
},
{ {
"name": "illuminate/collections", "name": "illuminate/collections",
"version": "v12.19.3", "version": "v12.19.3",
@ -2273,6 +2449,131 @@
}, },
"time": "2025-06-12T15:07:31+00:00" "time": "2025-06-12T15:07:31+00:00"
}, },
{
"name": "illuminate/database",
"version": "v12.19.3",
"source": {
"type": "git",
"url": "https://github.com/illuminate/database.git",
"reference": "758dcd2128af1bc9427a6f72d247a4f0c078a24a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/758dcd2128af1bc9427a6f72d247a4f0c078a24a",
"reference": "758dcd2128af1bc9427a6f72d247a4f0c078a24a",
"shasum": ""
},
"require": {
"brick/math": "^0.11|^0.12|^0.13",
"ext-pdo": "*",
"illuminate/collections": "^12.0",
"illuminate/container": "^12.0",
"illuminate/contracts": "^12.0",
"illuminate/macroable": "^12.0",
"illuminate/support": "^12.0",
"laravel/serializable-closure": "^1.3|^2.0",
"php": "^8.2"
},
"suggest": {
"ext-filter": "Required to use the Postgres database driver.",
"fakerphp/faker": "Required to use the eloquent factory builder (^1.24).",
"illuminate/console": "Required to use the database commands (^12.0).",
"illuminate/events": "Required to use the observers with Eloquent (^12.0).",
"illuminate/filesystem": "Required to use the migrations (^12.0).",
"illuminate/http": "Required to convert Eloquent models to API resources (^12.0).",
"illuminate/pagination": "Required to paginate the result set (^12.0).",
"symfony/finder": "Required to use Eloquent model factories (^7.2)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "12.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Database\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Database package.",
"homepage": "https://laravel.com",
"keywords": [
"database",
"laravel",
"orm",
"sql"
],
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-06-18T12:55:09+00:00"
},
{
"name": "illuminate/events",
"version": "v12.19.3",
"source": {
"type": "git",
"url": "https://github.com/illuminate/events.git",
"reference": "bf1f121ea51e077e893d32e2848e102513d4b1b5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/events/zipball/bf1f121ea51e077e893d32e2848e102513d4b1b5",
"reference": "bf1f121ea51e077e893d32e2848e102513d4b1b5",
"shasum": ""
},
"require": {
"illuminate/bus": "^12.0",
"illuminate/collections": "^12.0",
"illuminate/container": "^12.0",
"illuminate/contracts": "^12.0",
"illuminate/macroable": "^12.0",
"illuminate/support": "^12.0",
"php": "^8.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "12.x-dev"
}
},
"autoload": {
"files": [
"functions.php"
],
"psr-4": {
"Illuminate\\Events\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Events package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-05-13T15:08:45+00:00"
},
{ {
"name": "illuminate/filesystem", "name": "illuminate/filesystem",
"version": "v12.19.3", "version": "v12.19.3",
@ -2447,6 +2748,118 @@
}, },
"time": "2024-07-23T16:31:01+00:00" "time": "2024-07-23T16:31:01+00:00"
}, },
{
"name": "illuminate/pipeline",
"version": "v12.19.3",
"source": {
"type": "git",
"url": "https://github.com/illuminate/pipeline.git",
"reference": "a1039dfe54854470cdda37782bab0901aa588dd4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/pipeline/zipball/a1039dfe54854470cdda37782bab0901aa588dd4",
"reference": "a1039dfe54854470cdda37782bab0901aa588dd4",
"shasum": ""
},
"require": {
"illuminate/contracts": "^12.0",
"illuminate/support": "^12.0",
"php": "^8.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "12.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Pipeline\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Pipeline package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-05-13T15:08:45+00:00"
},
{
"name": "illuminate/routing",
"version": "v12.19.3",
"source": {
"type": "git",
"url": "https://github.com/illuminate/routing.git",
"reference": "f4cc40e27fb8771fec7ff6f1daf8a13020a9eba5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/routing/zipball/f4cc40e27fb8771fec7ff6f1daf8a13020a9eba5",
"reference": "f4cc40e27fb8771fec7ff6f1daf8a13020a9eba5",
"shasum": ""
},
"require": {
"ext-filter": "*",
"ext-hash": "*",
"illuminate/collections": "^12.0",
"illuminate/container": "^12.0",
"illuminate/contracts": "^12.0",
"illuminate/http": "^12.0",
"illuminate/macroable": "^12.0",
"illuminate/pipeline": "^12.0",
"illuminate/session": "^12.0",
"illuminate/support": "^12.0",
"php": "^8.2",
"symfony/http-foundation": "^7.2.0",
"symfony/http-kernel": "^7.2.0",
"symfony/routing": "^7.2.0"
},
"suggest": {
"illuminate/console": "Required to use the make commands (^12.0).",
"php-http/discovery": "Required to use PSR-7 bridging features (^1.15).",
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^7.2)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "12.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Routing\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Routing package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-06-17T17:01:27+00:00"
},
{ {
"name": "illuminate/session", "name": "illuminate/session",
"version": "v12.19.3", "version": "v12.19.3",
@ -2581,6 +2994,119 @@
}, },
"time": "2025-06-12T15:07:56+00:00" "time": "2025-06-12T15:07:56+00:00"
}, },
{
"name": "illuminate/translation",
"version": "v12.19.3",
"source": {
"type": "git",
"url": "https://github.com/illuminate/translation.git",
"reference": "705bdc5e8616ac76d247302831d05ac5ba352b44"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/translation/zipball/705bdc5e8616ac76d247302831d05ac5ba352b44",
"reference": "705bdc5e8616ac76d247302831d05ac5ba352b44",
"shasum": ""
},
"require": {
"illuminate/collections": "^12.0",
"illuminate/contracts": "^12.0",
"illuminate/filesystem": "^12.0",
"illuminate/macroable": "^12.0",
"illuminate/support": "^12.0",
"php": "^8.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "12.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Translation\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Translation package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-05-26T17:31:37+00:00"
},
{
"name": "illuminate/validation",
"version": "v12.19.3",
"source": {
"type": "git",
"url": "https://github.com/illuminate/validation.git",
"reference": "42ac1d782c8541c3e779f7ffff33093edd5739a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/validation/zipball/42ac1d782c8541c3e779f7ffff33093edd5739a4",
"reference": "42ac1d782c8541c3e779f7ffff33093edd5739a4",
"shasum": ""
},
"require": {
"brick/math": "^0.11|^0.12|^0.13",
"egulias/email-validator": "^3.2.5|^4.0",
"ext-filter": "*",
"ext-mbstring": "*",
"illuminate/collections": "^12.0",
"illuminate/container": "^12.0",
"illuminate/contracts": "^12.0",
"illuminate/macroable": "^12.0",
"illuminate/support": "^12.0",
"illuminate/translation": "^12.0",
"php": "^8.2",
"symfony/http-foundation": "^7.2",
"symfony/mime": "^7.2"
},
"suggest": {
"illuminate/database": "Required to use the database presence verifier (^12.0).",
"ramsey/uuid": "Required to use Validator::validateUuid() (^4.7)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "12.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Validation\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Validation package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-06-13T13:58:47+00:00"
},
{ {
"name": "jacklul/monolog-telegram", "name": "jacklul/monolog-telegram",
"version": "3.2.0", "version": "3.2.0",
@ -2706,6 +3232,67 @@
], ],
"time": "2024-09-11T14:15:04+00:00" "time": "2024-09-11T14:15:04+00:00"
}, },
{
"name": "laravel/serializable-closure",
"version": "v2.0.4",
"source": {
"type": "git",
"url": "https://github.com/laravel/serializable-closure.git",
"reference": "b352cf0534aa1ae6b4d825d1e762e35d43f8a841"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/b352cf0534aa1ae6b4d825d1e762e35d43f8a841",
"reference": "b352cf0534aa1ae6b4d825d1e762e35d43f8a841",
"shasum": ""
},
"require": {
"php": "^8.1"
},
"require-dev": {
"illuminate/support": "^10.0|^11.0|^12.0",
"nesbot/carbon": "^2.67|^3.0",
"pestphp/pest": "^2.36|^3.0",
"phpstan/phpstan": "^2.0",
"symfony/var-dumper": "^6.2.0|^7.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Laravel\\SerializableClosure\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
},
{
"name": "Nuno Maduro",
"email": "nuno@laravel.com"
}
],
"description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.",
"keywords": [
"closure",
"laravel",
"serializable"
],
"support": {
"issues": "https://github.com/laravel/serializable-closure/issues",
"source": "https://github.com/laravel/serializable-closure"
},
"time": "2025-03-19T13:51:03+00:00"
},
{ {
"name": "league/color-extractor", "name": "league/color-extractor",
"version": "0.4.0", "version": "0.4.0",
@ -5496,6 +6083,87 @@
], ],
"time": "2025-05-02T09:40:28+00:00" "time": "2025-05-02T09:40:28+00:00"
}, },
{
"name": "symfony/routing",
"version": "v7.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "8e213820c5fea844ecea29203d2a308019007c15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/8e213820c5fea844ecea29203d2a308019007c15",
"reference": "8e213820c5fea844ecea29203d2a308019007c15",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3"
},
"conflict": {
"symfony/config": "<6.4",
"symfony/dependency-injection": "<6.4",
"symfony/yaml": "<6.4"
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/expression-language": "^6.4|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Routing\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Maps an HTTP request to a set of configuration variables",
"homepage": "https://symfony.com",
"keywords": [
"router",
"routing",
"uri",
"url"
],
"support": {
"source": "https://github.com/symfony/routing/tree/v7.3.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2025-05-24T20:43:28+00:00"
},
{ {
"name": "symfony/service-contracts", "name": "symfony/service-contracts",
"version": "v3.6.0", "version": "v3.6.0",

View file

@ -0,0 +1,212 @@
# Illuminate Package Integration Guide
This document outlines the integration of Laravel's Illuminate packages in TorrentPier 3.0.
> **Note**: After these changes, run `composer update` to install the newly added `illuminate/config` package.
## Installed Illuminate Packages
The following Illuminate packages are available in TorrentPier:
1. **illuminate/collections** - Powerful array/collection manipulation
2. **illuminate/config** - Configuration repository system
3. **illuminate/container** - Dependency injection container
4. **illuminate/database** - Database query builder and Eloquent ORM
5. **illuminate/events** - Event dispatcher system
6. **illuminate/http** - HTTP request/response handling
7. **illuminate/routing** - Routing system
8. **illuminate/support** - Support utilities (Str, Arr, etc.)
9. **illuminate/validation** - Data validation
## Current Integration Status
### ✅ Fully Integrated
1. **Container (illuminate/container)**
- Used as the core DI container via `bootstrap/container.php`
- Custom wrapper in `App\Container\Container`
- Global `app()` helper function available
2. **Support (illuminate/support)**
- Helper functions: `collect()`, `str()`, `data_get()`, `data_set()`, `tap()`, `optional()`
- String and array manipulation utilities
- Collection class for data manipulation
3. **Events (illuminate/events)**
- Event dispatcher registered in `AppServiceProvider`
- Event classes in `app/Events/`
- Listener classes in `app/Listeners/`
- `EventServiceProvider` for registering event listeners
- Global `event()` helper function
4. **Config (illuminate/config)**
- Configuration repository registered in `AppServiceProvider`
- Global `config()` helper function
- Loads all PHP files from `/config/` directory
5. **Validation (illuminate/validation)**
- Used in `App\Http\Requests\FormRequest` base class
- Provides Laravel-style request validation
### ⚠️ Partially Integrated
1. **HTTP (illuminate/http)**
- Request/Response classes used in routing
- Not fully utilizing all HTTP features
2. **Collections (illuminate/collections)**
- Available via `collect()` helper
- Could be used more extensively in models/services
### ❌ Not Yet Integrated
1. **Database (illuminate/database)**
- Package installed but not used
- Project uses Nette Database instead
- Could migrate to Eloquent ORM in future
2. **Routing (illuminate/routing)**
- Package installed but custom router is used
- Could migrate to full Illuminate routing
## Usage Examples
### Using the Event System
```php
// Dispatch an event
use App\Events\UserRegistered;
event(new UserRegistered(
userId: $userId,
username: $username,
email: $email,
registeredAt: new DateTime()
));
// In a listener
class SendWelcomeEmail
{
public function handle(UserRegistered $event): void
{
// Send welcome email
mail($event->getEmail(), 'Welcome!', 'Welcome to TorrentPier!');
}
}
```
### Using Configuration
```php
// Get a config value
$appName = config('app.name');
$debug = config('app.debug', false);
// Set a config value
config(['app.timezone' => 'UTC']);
// Get entire config array
$databaseConfig = config('database');
```
### Using Collections
```php
// Create a collection
$users = collect($userArray);
// Chain methods
$activeAdmins = $users
->where('status', 'active')
->where('role', 'admin')
->sortBy('name')
->values();
// Use collection helpers
$names = $users->pluck('name');
$grouped = $users->groupBy('role');
```
### Using Validation
```php
use App\Http\Requests\FormRequest;
class RegisterRequest extends FormRequest
{
public function rules(): array
{
return [
'username' => 'required|string|min:3|max:25',
'email' => 'required|email',
'password' => 'required|min:8|confirmed',
];
}
}
// In controller
public function register(RegisterRequest $request)
{
$validated = $request->validated();
// Process registration with validated data
}
```
## Service Providers
Service providers bootstrap the Illuminate packages:
1. **AppServiceProvider** - Registers config and events
2. **EventServiceProvider** - Maps events to listeners
3. **RouteServiceProvider** - Loads route files
Register new providers in `bootstrap/container.php`.
## Future Integration Opportunities
1. **Migrate to Eloquent ORM**
- Replace Nette Database with Eloquent
- Use migrations and model relationships
- Leverage query scopes and mutators
2. **Full Routing Integration**
- Replace custom router with Illuminate routing
- Use route model binding
- Implement route caching
3. **Add Queue System**
- Install `illuminate/queue`
- Process long-running tasks asynchronously
- Integrate with event listeners
4. **Add Cache Integration**
- Install `illuminate/cache`
- Replace custom cache with Laravel's cache
- Use cache tags and TTL
5. **Add Filesystem Integration**
- Already have `league/flysystem`
- Add `illuminate/filesystem` for Laravel integration
- Unified file operations
## Best Practices
1. **Use Dependency Injection**
- Inject services via constructor
- Use the container for resolution
- Avoid service location pattern
2. **Leverage Events**
- Decouple components with events
- Use listeners for side effects
- Consider queued listeners for heavy tasks
3. **Configuration Management**
- Keep environment-specific values in `.env`
- Use config files for application settings
- Cache configuration in production
4. **Follow Laravel Conventions**
- Use Laravel naming conventions
- Structure code like a Laravel app
- Leverage Laravel patterns and practices

View file

@ -91,8 +91,8 @@ class Ajax
} }
// Exit if board is disabled via ON/OFF trigger or by admin // Exit if board is disabled via ON/OFF trigger or by admin
if (config()->get('board_disable') || is_file(BB_DISABLED)) { if (tp_config()->get('board_disable') || is_file(BB_DISABLED)) {
if (config()->get('board_disable')) { if (tp_config()->get('board_disable')) {
$this->ajax_die($lang['BOARD_DISABLE']); $this->ajax_die($lang['BOARD_DISABLE']);
} elseif (is_file(BB_DISABLED) && $this->action !== 'manage_admin') { } elseif (is_file(BB_DISABLED) && $this->action !== 'manage_admin') {
$this->ajax_die($lang['BOARD_DISABLE_CRON']); $this->ajax_die($lang['BOARD_DISABLE_CRON']);

View file

@ -111,7 +111,7 @@ class Censor
*/ */
public function isEnabled(): bool public function isEnabled(): bool
{ {
return config()->get('use_word_censor', false); return tp_config()->get('use_word_censor', false);
} }
/** /**

View file

@ -90,11 +90,11 @@ class Dev
*/ */
private function getBugsnag(): void private function getBugsnag(): void
{ {
if (!config()->get('bugsnag.enabled')) { if (!tp_config()->get('bugsnag.enabled')) {
return; return;
} }
$bugsnag = Client::make(config()->get('bugsnag.api_key')); $bugsnag = Client::make(tp_config()->get('bugsnag.api_key'));
$this->whoops->pushHandler(function ($e) use ($bugsnag) { $this->whoops->pushHandler(function ($e) use ($bugsnag) {
$bugsnag->notifyException($e); $bugsnag->notifyException($e);
}); });
@ -107,7 +107,7 @@ class Dev
*/ */
private function getTelegramSender(): void private function getTelegramSender(): void
{ {
if (!config()->get('telegram_sender.enabled')) { if (!tp_config()->get('telegram_sender.enabled')) {
return; return;
} }
@ -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(config()->get('telegram_sender.token'), (int)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)config()->get('telegram_sender.timeout')))
->setFormatter(new TelegramFormatter())] ->setFormatter(new TelegramFormatter())]
))); )));
$this->whoops->pushHandler($telegramSender); $this->whoops->pushHandler($telegramSender);
@ -132,7 +132,7 @@ class Dev
* Show errors on page with enhanced database information * Show errors on page with enhanced database information
*/ */
$prettyPageHandler = new \TorrentPier\Whoops\EnhancedPrettyPageHandler(); $prettyPageHandler = new \TorrentPier\Whoops\EnhancedPrettyPageHandler();
foreach (config()->get('whoops.blacklist', []) as $key => $secrets) { foreach (tp_config()->get('whoops.blacklist', []) as $key => $secrets) {
foreach ($secrets as $secret) { foreach ($secrets as $secret) {
$prettyPageHandler->blacklist($key, $secret); $prettyPageHandler->blacklist($key, $secret);
} }
@ -181,7 +181,7 @@ class Dev
private function getWhoopsPlaceholder(): void private function getWhoopsPlaceholder(): void
{ {
$this->whoops->pushHandler(function ($e) { $this->whoops->pushHandler(function ($e) {
echo config()->get('whoops.error_message'); echo tp_config()->get('whoops.error_message');
echo "<hr/>Error: {$e->getMessage()}."; echo "<hr/>Error: {$e->getMessage()}.";
}); });
} }

View file

@ -88,14 +88,14 @@ class Emailer
public function set_template(string $template_file, string $template_lang = ''): void public function set_template(string $template_file, string $template_lang = ''): void
{ {
if (!$template_lang) { if (!$template_lang) {
$template_lang = config()->get('default_lang'); $template_lang = tp_config()->get('default_lang');
} }
if (empty($this->tpl_msg[$template_lang . $template_file])) { if (empty($this->tpl_msg[$template_lang . $template_file])) {
$tpl_file = LANG_ROOT_DIR . '/' . $template_lang . '/email/' . $template_file . '.html'; $tpl_file = LANG_ROOT_DIR . '/' . $template_lang . '/email/' . $template_file . '.html';
if (!is_file($tpl_file)) { if (!is_file($tpl_file)) {
$tpl_file = LANG_ROOT_DIR . '/' . config()->get('default_lang') . '/email/' . $template_file . '.html'; $tpl_file = LANG_ROOT_DIR . '/' . tp_config()->get('default_lang') . '/email/' . $template_file . '.html';
if (!is_file($tpl_file)) { if (!is_file($tpl_file)) {
throw new Exception('Could not find email template file: ' . $template_file); throw new Exception('Could not find email template file: ' . $template_file);
@ -125,7 +125,7 @@ class Emailer
{ {
global $lang; global $lang;
if (!config()->get('emailer.enabled')) { if (!tp_config()->get('emailer.enabled')) {
return false; return false;
} }
@ -140,25 +140,25 @@ class Emailer
$this->subject = !empty($this->subject) ? $this->subject : $lang['EMAILER_SUBJECT']['EMPTY']; $this->subject = !empty($this->subject) ? $this->subject : $lang['EMAILER_SUBJECT']['EMPTY'];
/** Prepare message */ /** Prepare message */
if (config()->get('emailer.smtp.enabled')) { if (tp_config()->get('emailer.smtp.enabled')) {
if (!empty(config()->get('emailer.smtp.host'))) { if (!empty(tp_config()->get('emailer.smtp.host'))) {
$sslType = config()->get('emailer.smtp.ssl_type'); $sslType = tp_config()->get('emailer.smtp.ssl_type');
if (empty($sslType)) { if (empty($sslType)) {
$sslType = null; $sslType = null;
} }
/** @var EsmtpTransport $transport external SMTP with SSL */ /** @var EsmtpTransport $transport external SMTP with SSL */
$transport = (new EsmtpTransport( $transport = (new EsmtpTransport(
config()->get('emailer.smtp.host'), tp_config()->get('emailer.smtp.host'),
config()->get('emailer.smtp.port'), tp_config()->get('emailer.smtp.port'),
$sslType $sslType
)) ))
->setUsername(config()->get('emailer.smtp.username')) ->setUsername(tp_config()->get('emailer.smtp.username'))
->setPassword(config()->get('emailer.smtp.password')); ->setPassword(tp_config()->get('emailer.smtp.password'));
} else { } else {
$transport = new EsmtpTransport('localhost', 25); $transport = new EsmtpTransport('localhost', 25);
} }
} else { } else {
$transport = new SendmailTransport(config()->get('emailer.sendmail_command')); $transport = new SendmailTransport(tp_config()->get('emailer.sendmail_command'));
} }
$mailer = new Mailer($transport); $mailer = new Mailer($transport);
@ -167,9 +167,9 @@ class Emailer
$message = (new Email()) $message = (new Email())
->subject($this->subject) ->subject($this->subject)
->to($this->to) ->to($this->to)
->from(new Address(config()->get('board_email'), config()->get('board_email_sitename'))) ->from(new Address(tp_config()->get('board_email'), tp_config()->get('board_email_sitename')))
->returnPath(new Address(config()->get('bounce_email'))) ->returnPath(new Address(tp_config()->get('bounce_email')))
->replyTo($this->reply ?? new Address(config()->get('board_email'))); ->replyTo($this->reply ?? new Address(tp_config()->get('board_email')));
/** /**
* This non-standard header tells compliant autoresponders ("email holiday mode") to not * This non-standard header tells compliant autoresponders ("email holiday mode") to not
@ -209,9 +209,9 @@ class Emailer
public function assign_vars($vars): void public function assign_vars($vars): void
{ {
$this->vars = array_merge([ $this->vars = array_merge([
'BOARD_EMAIL' => config()->get('board_email'), 'BOARD_EMAIL' => tp_config()->get('board_email'),
'SITENAME' => config()->get('board_email_sitename'), 'SITENAME' => tp_config()->get('board_email_sitename'),
'EMAIL_SIG' => !empty(config()->get('board_email_sig')) ? "-- \n" . config()->get('board_email_sig') : '', 'EMAIL_SIG' => !empty(tp_config()->get('board_email_sig')) ? "-- \n" . tp_config()->get('board_email_sig') : '',
], $vars); ], $vars);
} }
} }

View file

@ -348,7 +348,7 @@ class Common
@unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename); @unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename);
} }
// TorrServer integration // TorrServer integration
if (config()->get('torr_server.enabled')) { if (tp_config()->get('torr_server.enabled')) {
$torrServer = new \TorrentPier\TorrServerAPI(); $torrServer = new \TorrentPier\TorrServerAPI();
$torrServer->removeM3U($row['attach_id']); $torrServer->removeM3U($row['attach_id']);
} }
@ -779,7 +779,7 @@ class Common
// Delete user feed // Delete user feed
foreach (explode(',', $user_csv) as $user_id) { foreach (explode(',', $user_csv) as $user_id) {
$file_path = config()->get('atom.path') . '/u/' . floor($user_id / 5000) . '/' . ($user_id % 100) . '/' . $user_id . '.atom'; $file_path = tp_config()->get('atom.path') . '/u/' . floor($user_id / 5000) . '/' . ($user_id % 100) . '/' . $user_id . '.atom';
@unlink($file_path); @unlink($file_path);
} }
} }

View file

@ -27,7 +27,7 @@ class Atom
{ {
global $lang, $datastore; global $lang, $datastore;
$sql = null; $sql = null;
$file_path = config()->get('atom.path') . '/f/' . $forum_id . '.atom'; $file_path = tp_config()->get('atom.path') . '/f/' . $forum_id . '.atom';
$select_tor_sql = $join_tor_sql = ''; $select_tor_sql = $join_tor_sql = '';
if (!$forums = $datastore->get('cat_forums')) { if (!$forums = $datastore->get('cat_forums')) {
@ -37,7 +37,7 @@ class Atom
$not_forums_id = $forums['not_auth_forums']['guest_view']; $not_forums_id = $forums['not_auth_forums']['guest_view'];
if ($forum_id == 0) { if ($forum_id == 0) {
$forum_data['forum_name'] = $lang['ATOM_GLOBAL_FEED'] ?? config()->get('server_name'); $forum_data['forum_name'] = $lang['ATOM_GLOBAL_FEED'] ?? tp_config()->get('server_name');
} }
if ($forum_id > 0 && $forum_data['allow_reg_tracker']) { if ($forum_id > 0 && $forum_data['allow_reg_tracker']) {
$select_tor_sql = ', tor.size AS tor_size, tor.tor_status, tor.attach_id'; $select_tor_sql = ', tor.size AS tor_size, tor.tor_status, tor.attach_id';
@ -93,7 +93,7 @@ class Atom
} }
} }
if (isset($topic['tor_status'])) { if (isset($topic['tor_status'])) {
if (isset(config()->get('tor_frozen')[$topic['tor_status']])) { if (isset(tp_config()->get('tor_frozen')[$topic['tor_status']])) {
continue; continue;
} }
} }
@ -121,7 +121,7 @@ class Atom
public static function update_user_feed($user_id, $username) public static function update_user_feed($user_id, $username)
{ {
global $lang, $datastore; global $lang, $datastore;
$file_path = config()->get('atom.path') . '/u/' . floor($user_id / 5000) . '/' . ($user_id % 100) . '/' . $user_id . '.atom'; $file_path = tp_config()->get('atom.path') . '/u/' . floor($user_id / 5000) . '/' . ($user_id % 100) . '/' . $user_id . '.atom';
$sql = " $sql = "
SELECT SELECT
t.topic_id, t.topic_title, t.topic_status, t.topic_id, t.topic_title, t.topic_status,
@ -149,7 +149,7 @@ class Atom
} }
} }
if (isset($topic['tor_status'])) { if (isset($topic['tor_status'])) {
if (isset(config()->get('tor_frozen')[$topic['tor_status']])) { if (isset(tp_config()->get('tor_frozen')[$topic['tor_status']])) {
continue; continue;
} }
} }
@ -233,13 +233,13 @@ class Atom
$atom .= " </author>\n"; $atom .= " </author>\n";
$atom .= " <updated>" . $date . "T$time+00:00</updated>\n"; $atom .= " <updated>" . $date . "T$time+00:00</updated>\n";
$atom .= " <id>tag:rto.feed," . $date . ":/t/$topic_id</id>\n"; $atom .= " <id>tag:rto.feed," . $date . ":/t/$topic_id</id>\n";
if (config()->get('atom.direct_down') && isset($topic['attach_id'])) { if (tp_config()->get('atom.direct_down') && isset($topic['attach_id'])) {
$atom .= " <link href=\"" . DL_URL . $topic['attach_id'] . "\" />\n"; $atom .= " <link href=\"" . DL_URL . $topic['attach_id'] . "\" />\n";
} else { } else {
$atom .= " <link href=\"" . TOPIC_URL . $topic_id . "\" />\n"; $atom .= " <link href=\"" . TOPIC_URL . $topic_id . "\" />\n";
} }
if (config()->get('atom.direct_view')) { if (tp_config()->get('atom.direct_view')) {
$atom .= " <description>" . $topic['post_html'] . "\n\nNews URL: " . FULL_URL . TOPIC_URL . $topic_id . "</description>\n"; $atom .= " <description>" . $topic['post_html'] . "\n\nNews URL: " . FULL_URL . TOPIC_URL . $topic_id . "</description>\n";
} }

View file

@ -163,7 +163,7 @@ class BBCode
$text = $this->smilies_pass($text); $text = $this->smilies_pass($text);
$text = $this->new_line2html($text); $text = $this->new_line2html($text);
if (config()->get('tidy_post')) { if (tp_config()->get('tidy_post')) {
$text = $this->tidy($text); $text = $this->tidy($text);
} }
@ -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), config()->get('nofollow.allowed_url')) || config()->get('nofollow.disabled')) { if (\in_array(parse_url($href, PHP_URL_HOST), tp_config()->get('nofollow.allowed_url')) || 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

@ -26,7 +26,7 @@ class Select
public static function language(string $default_lang, string $select_name = 'language'): mixed public static function language(string $default_lang, string $select_name = 'language'): mixed
{ {
$lang_select = '<select name="' . $select_name . '">'; $lang_select = '<select name="' . $select_name . '">';
foreach (config()->get('lang') as $key => $data) { foreach (tp_config()->get('lang') as $key => $data) {
$selected = ''; $selected = '';
if ($key == $default_lang) { if ($key == $default_lang) {
$selected = ' selected'; $selected = ' selected';
@ -74,7 +74,7 @@ class Select
public static function template(string $default_style, string $select_name = 'tpl_name'): mixed public static function template(string $default_style, string $select_name = 'tpl_name'): mixed
{ {
$templates_select = '<select name="' . $select_name . '">'; $templates_select = '<select name="' . $select_name . '">';
foreach (config()->get('templates') as $folder => $name) { foreach (tp_config()->get('templates') as $folder => $name) {
$selected = ''; $selected = '';
if ($folder == $default_style) { if ($folder == $default_style) {
$selected = ' selected'; $selected = ' selected';

View file

@ -150,7 +150,7 @@ class Upload
$file_name_ary = explode('.', $this->file['name']); $file_name_ary = explode('.', $this->file['name']);
$this->file_ext = strtolower(end($file_name_ary)); $this->file_ext = strtolower(end($file_name_ary));
$this->ext_ids = array_flip(config()->get('file_id_ext')); $this->ext_ids = array_flip(tp_config()->get('file_id_ext'));
// Actions for images [E.g. Change avatar] // Actions for images [E.g. Change avatar]
if ($this->cfg['max_width'] || $this->cfg['max_height']) { if ($this->cfg['max_width'] || $this->cfg['max_height']) {

View file

@ -130,7 +130,7 @@ class User
if ($session_id) { if ($session_id) {
$SQL['WHERE'][] = "s.session_id = '$session_id'"; $SQL['WHERE'][] = "s.session_id = '$session_id'";
if (config()->get('torhelp_enabled')) { if (tp_config()->get('torhelp_enabled')) {
$SQL['SELECT'][] = "th.topic_id_csv AS torhelp"; $SQL['SELECT'][] = "th.topic_id_csv AS torhelp";
$SQL['LEFT JOIN'][] = BB_BT_TORHELP . " th ON(u.user_id = th.user_id)"; $SQL['LEFT JOIN'][] = BB_BT_TORHELP . " th ON(u.user_id = th.user_id)";
} }
@ -146,7 +146,7 @@ class User
if (!$this->data = Sessions::cache_get_userdata($userdata_cache_id)) { if (!$this->data = Sessions::cache_get_userdata($userdata_cache_id)) {
$this->data = DB()->fetch_row($SQL); $this->data = DB()->fetch_row($SQL);
if ($this->data && (TIMENOW - $this->data['session_time']) > config()->get('session_update_intrv')) { if ($this->data && (TIMENOW - $this->data['session_time']) > tp_config()->get('session_update_intrv')) {
$this->data['session_time'] = TIMENOW; $this->data['session_time'] = TIMENOW;
$update_sessions_table = true; $update_sessions_table = true;
} }
@ -189,7 +189,7 @@ class User
// using the cookie user_id if available to pull basic user prefs. // using the cookie user_id if available to pull basic user prefs.
if (!$this->data) { if (!$this->data) {
$login = false; $login = false;
$user_id = (config()->get('allow_autologin') && $this->sessiondata['uk'] && $this->sessiondata['uid']) ? $this->sessiondata['uid'] : GUEST_UID; $user_id = (tp_config()->get('allow_autologin') && $this->sessiondata['uk'] && $this->sessiondata['uid']) ? $this->sessiondata['uid'] : GUEST_UID;
if ($userdata = get_userdata((int)$user_id, false, true)) { if ($userdata = get_userdata((int)$user_id, false, true)) {
if ($userdata['user_id'] != GUEST_UID && $userdata['user_active']) { if ($userdata['user_id'] != GUEST_UID && $userdata['user_active']) {
@ -210,7 +210,7 @@ class User
define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD); define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD);
define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER); define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER);
define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER); define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER);
define('IS_SUPER_ADMIN', IS_ADMIN && isset(config()->get('super_admins')[$this->data['user_id']])); define('IS_SUPER_ADMIN', IS_ADMIN && isset(tp_config()->get('super_admins')[$this->data['user_id']]));
define('IS_AM', IS_ADMIN || IS_MOD); define('IS_AM', IS_ADMIN || IS_MOD);
$this->set_shortcuts(); $this->set_shortcuts();
@ -281,8 +281,8 @@ class User
if (!$session_time = $this->data['user_session_time']) { if (!$session_time = $this->data['user_session_time']) {
$last_visit = TIMENOW; $last_visit = TIMENOW;
define('FIRST_LOGON', true); define('FIRST_LOGON', true);
} elseif ($session_time < (TIMENOW - config()->get('last_visit_update_intrv'))) { } elseif ($session_time < (TIMENOW - tp_config()->get('last_visit_update_intrv'))) {
$last_visit = max($session_time, (TIMENOW - 86400 * config()->get('max_last_visit_days'))); $last_visit = max($session_time, (TIMENOW - 86400 * tp_config()->get('max_last_visit_days')));
} }
if ($last_visit != $this->data['user_lastvisit']) { if ($last_visit != $this->data['user_lastvisit']) {
@ -301,7 +301,7 @@ class User
$this->data['user_lastvisit'] = $last_visit; $this->data['user_lastvisit'] = $last_visit;
} }
if (!empty($_POST['autologin']) && config()->get('allow_autologin')) { if (!empty($_POST['autologin']) && tp_config()->get('allow_autologin')) {
if (!$auto_created) { if (!$auto_created) {
$this->verify_autologin_id($this->data, true, true); $this->verify_autologin_id($this->data, true, true);
} }
@ -487,10 +487,10 @@ class User
} }
} }
} else { } else {
if (!isset(config()->get('dbg_users')[$this->data['user_id']]) && DBG_USER) { if (!isset(tp_config()->get('dbg_users')[$this->data['user_id']]) && DBG_USER) {
bb_setcookie(COOKIE_DBG, null); bb_setcookie(COOKIE_DBG, null);
} elseif (isset(config()->get('dbg_users')[$this->data['user_id']]) && !DBG_USER) { } elseif (isset(tp_config()->get('dbg_users')[$this->data['user_id']]) && !DBG_USER) {
bb_setcookie(COOKIE_DBG, hash('xxh128', config()->get('dbg_users')[$this->data['user_id']]), COOKIE_SESSION); bb_setcookie(COOKIE_DBG, hash('xxh128', tp_config()->get('dbg_users')[$this->data['user_id']]), COOKIE_SESSION);
} }
// Unset sql debug cookies if SQL_DEBUG is disabled or DBG_USER cookie not present // Unset sql debug cookies if SQL_DEBUG is disabled or DBG_USER cookie not present

View file

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

View file

@ -60,15 +60,15 @@ class Post
} }
// Check smilies limit // Check smilies limit
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')) {
$to_many_smilies = sprintf($lang['MAX_SMILIES_PER_POST'], config()->get('max_smilies')); $to_many_smilies = sprintf($lang['MAX_SMILIES_PER_POST'], tp_config()->get('max_smilies'));
$error_msg .= (!empty($error_msg)) ? '<br />' . $to_many_smilies : $to_many_smilies; $error_msg .= (!empty($error_msg)) ? '<br />' . $to_many_smilies : $to_many_smilies;
} }
} }
if (IS_GUEST && !config()->get('captcha.disabled') && !bb_captcha('check')) { if (IS_GUEST && !tp_config()->get('captcha.disabled') && !bb_captcha('check')) {
$error_msg .= (!empty($error_msg)) ? '<br />' . $lang['CAPTCHA_WRONG'] : $lang['CAPTCHA_WRONG']; $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['CAPTCHA_WRONG'] : $lang['CAPTCHA_WRONG'];
} }
} }
@ -108,7 +108,7 @@ class Post
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql"; $sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql";
if ($row = DB()->fetch_row($sql) and $row['last_post_time']) { if ($row = DB()->fetch_row($sql) and $row['last_post_time']) {
if ($userdata['user_level'] == USER) { if ($userdata['user_level'] == USER) {
if ((TIMENOW - $row['last_post_time']) < config()->get('flood_interval')) { if ((TIMENOW - $row['last_post_time']) < tp_config()->get('flood_interval')) {
bb_die($lang['FLOOD_ERROR']); bb_die($lang['FLOOD_ERROR']);
} }
} }
@ -200,9 +200,9 @@ class Post
update_post_html(['post_id' => $post_id, 'post_text' => $post_message]); update_post_html(['post_id' => $post_id, 'post_text' => $post_message]);
// Updating news cache on index page // Updating news cache on index page
if (config()->get('show_latest_news')) { if (tp_config()->get('show_latest_news')) {
$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') && $mode == 'newtopic') { if (isset($news_forums[$forum_id]) && tp_config()->get('show_latest_news') && $mode == 'newtopic') {
$datastore->enqueue([ $datastore->enqueue([
'latest_news' 'latest_news'
]); ]);
@ -210,9 +210,9 @@ class Post
} }
} }
if (config()->get('show_network_news')) { if (tp_config()->get('show_network_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') && $mode == 'newtopic') { if (isset($net_forums[$forum_id]) && tp_config()->get('show_network_news') && $mode == 'newtopic') {
$datastore->enqueue([ $datastore->enqueue([
'network_news' 'network_news'
]); ]);

View file

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

View file

@ -183,18 +183,18 @@ class Validate
} }
} }
// Letters // Letters
if (config()->get('password_symbols.letters.lowercase')) { if (tp_config()->get('password_symbols.letters.lowercase')) {
if (!StringHelper::isContainsLetters($password)) { if (!StringHelper::isContainsLetters($password)) {
return $lang['CHOOSE_PASS_ERR_LETTER']; return $lang['CHOOSE_PASS_ERR_LETTER'];
} }
} }
if (config()->get('password_symbols.letters.uppercase')) { if (tp_config()->get('password_symbols.letters.uppercase')) {
if (!StringHelper::isContainsLetters($password, true)) { if (!StringHelper::isContainsLetters($password, true)) {
return $lang['CHOOSE_PASS_ERR_LETTER_UPPERCASE']; return $lang['CHOOSE_PASS_ERR_LETTER_UPPERCASE'];
} }
} }
// Spec symbols // Spec symbols
if (config()->get('password_symbols.spec_symbols')) { if (tp_config()->get('password_symbols.spec_symbols')) {
if (!StringHelper::isContainsSpecSymbols($password)) { if (!StringHelper::isContainsSpecSymbols($password)) {
return $lang['CHOOSE_PASS_ERR_SPEC_SYMBOL']; return $lang['CHOOSE_PASS_ERR_SPEC_SYMBOL'];
} }