mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-24 15:15:46 -07:00
refactor(controllers): move legacy PHP controllers to dedicated directory
- Move 19 controller files from root to controllers/ directory - Update routing and include paths in supporting files - Maintain backward compatibility through legacy controller handling Moved files: - dl.php, dl_list.php, feed.php, filelist.php, group.php - group_edit.php, info.php, login.php, memberlist.php - modcp.php, playback_m3u.php, poll.php, posting.php - privmsg.php, profile.php, search.php, tracker.php - viewforum.php, viewtopic.php Updated supporting files to handle new structure: - library/includes/functions.php - library/includes/init_bb.php - library/includes/page_header.php - src/Presentation/Http/Controllers/Web/LegacyController.php - src/Presentation/Http/Kernel.php - src/Presentation/Http/Routes/web.php
This commit is contained in:
parent
1890215278
commit
e6e80145cc
25 changed files with 146 additions and 41 deletions
|
@ -10,7 +10,11 @@
|
||||||
define('BB_SCRIPT', 'dl');
|
define('BB_SCRIPT', 'dl');
|
||||||
define('NO_GZIP', true);
|
define('NO_GZIP', true);
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
require ATTACH_DIR . '/attachment_mod.php';
|
require ATTACH_DIR . '/attachment_mod.php';
|
||||||
|
|
||||||
$datastore->enqueue([
|
$datastore->enqueue([
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'dl_list');
|
define('BB_SCRIPT', 'dl_list');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
$forum_id = $_REQUEST[POST_FORUM_URL] ?? 0;
|
$forum_id = $_REQUEST[POST_FORUM_URL] ?? 0;
|
||||||
$topic_id = $_REQUEST[POST_TOPIC_URL] ?? 0;
|
$topic_id = $_REQUEST[POST_TOPIC_URL] ?? 0;
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'feed');
|
define('BB_SCRIPT', 'feed');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Init userdata
|
// Init userdata
|
||||||
$user->session_start(['req_login' => true]);
|
$user->session_start(['req_login' => true]);
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'filelist');
|
define('BB_SCRIPT', 'filelist');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Start session management
|
// Start session management
|
||||||
$user->session_start();
|
$user->session_start();
|
|
@ -9,7 +9,11 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'group');
|
define('BB_SCRIPT', 'group');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
require INC_DIR . '/bbcode.php';
|
require INC_DIR . '/bbcode.php';
|
||||||
|
|
||||||
$page_cfg['use_tablesorter'] = true;
|
$page_cfg['use_tablesorter'] = true;
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'group_edit');
|
define('BB_SCRIPT', 'group_edit');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
$page_cfg['include_bbcode_js'] = true;
|
$page_cfg['include_bbcode_js'] = true;
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'info');
|
define('BB_SCRIPT', 'info');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Start session management
|
// Start session management
|
||||||
$user->session_start();
|
$user->session_start();
|
|
@ -10,7 +10,10 @@
|
||||||
define('BB_SCRIPT', 'login');
|
define('BB_SCRIPT', 'login');
|
||||||
define('IN_LOGIN', true);
|
define('IN_LOGIN', true);
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
array_deep($_POST, 'trim');
|
array_deep($_POST, 'trim');
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'memberlist');
|
define('BB_SCRIPT', 'memberlist');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
$user->session_start(['req_login' => true]);
|
$user->session_start(['req_login' => true]);
|
||||||
|
|
|
@ -9,7 +9,11 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'modcp');
|
define('BB_SCRIPT', 'modcp');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
require INC_DIR . '/bbcode.php';
|
require INC_DIR . '/bbcode.php';
|
||||||
|
|
||||||
//
|
//
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'playback_m3u');
|
define('BB_SCRIPT', 'playback_m3u');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
if (!config()->get('torr_server.enabled')) {
|
if (!config()->get('torr_server.enabled')) {
|
||||||
redirect('index.php');
|
redirect('index.php');
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'vote');
|
define('BB_SCRIPT', 'vote');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Start session management
|
// Start session management
|
||||||
$user->session_start(['req_login' => true]);
|
$user->session_start(['req_login' => true]);
|
|
@ -9,7 +9,11 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'posting');
|
define('BB_SCRIPT', 'posting');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
require INC_DIR . '/bbcode.php';
|
require INC_DIR . '/bbcode.php';
|
||||||
require ATTACH_DIR . '/attachment_mod.php';
|
require ATTACH_DIR . '/attachment_mod.php';
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
define('BB_SCRIPT', 'pm');
|
define('BB_SCRIPT', 'pm');
|
||||||
define('IN_PM', true);
|
define('IN_PM', true);
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
require INC_DIR . '/bbcode.php';
|
require INC_DIR . '/bbcode.php';
|
||||||
|
|
||||||
$privmsg_sent_id = $l_box_name = $to_username = $privmsg_subject = $privmsg_message = $error_msg = '';
|
$privmsg_sent_id = $l_box_name = $to_username = $privmsg_subject = $privmsg_message = $error_msg = '';
|
|
@ -10,7 +10,10 @@
|
||||||
define('BB_SCRIPT', 'profile');
|
define('BB_SCRIPT', 'profile');
|
||||||
define('IN_PROFILE', true);
|
define('IN_PROFILE', true);
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Start session management
|
// Start session management
|
||||||
$user->session_start();
|
$user->session_start();
|
|
@ -9,7 +9,11 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'search');
|
define('BB_SCRIPT', 'search');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
require INC_DIR . '/bbcode.php';
|
require INC_DIR . '/bbcode.php';
|
||||||
|
|
||||||
$page_cfg['use_tablesorter'] = true;
|
$page_cfg['use_tablesorter'] = true;
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'tracker');
|
define('BB_SCRIPT', 'tracker');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Page config
|
// Page config
|
||||||
$page_cfg['include_bbcode_js'] = true;
|
$page_cfg['include_bbcode_js'] = true;
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'forum');
|
define('BB_SCRIPT', 'forum');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
$page_cfg['include_bbcode_js'] = true;
|
$page_cfg['include_bbcode_js'] = true;
|
||||||
|
|
|
@ -9,7 +9,11 @@
|
||||||
|
|
||||||
define('BB_SCRIPT', 'topic');
|
define('BB_SCRIPT', 'topic');
|
||||||
|
|
||||||
require __DIR__ . '/common.php';
|
// Skip loading common.php if already loaded (when run through routing system)
|
||||||
|
if (!defined('IN_TORRENTPIER')) {
|
||||||
|
require __DIR__ . '/../common.php';
|
||||||
|
}
|
||||||
|
|
||||||
require INC_DIR . '/bbcode.php';
|
require INC_DIR . '/bbcode.php';
|
||||||
|
|
||||||
$datastore->enqueue([
|
$datastore->enqueue([
|
|
@ -1332,7 +1332,7 @@ function bb_die($msg_text, $status_code = null)
|
||||||
{
|
{
|
||||||
global $ajax, $lang, $template, $theme, $userdata, $user;
|
global $ajax, $lang, $template, $theme, $userdata, $user;
|
||||||
|
|
||||||
if (isset($status_code)) {
|
if (isset($status_code) && !defined('MODERN_ROUTING')) {
|
||||||
http_response_code($status_code);
|
http_response_code($status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,9 +1388,11 @@ function bb_die($msg_text, $status_code = null)
|
||||||
|
|
||||||
function bb_simple_die($txt, $status_code = null)
|
function bb_simple_die($txt, $status_code = null)
|
||||||
{
|
{
|
||||||
|
if (!defined('MODERN_ROUTING')) {
|
||||||
header('Content-Type: text/plain; charset=' . DEFAULT_CHARSET);
|
header('Content-Type: text/plain; charset=' . DEFAULT_CHARSET);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($status_code)) {
|
if (isset($status_code) && !defined('MODERN_ROUTING')) {
|
||||||
http_response_code($status_code);
|
http_response_code($status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ function compress_output($contents)
|
||||||
{
|
{
|
||||||
if (config()->get('gzip_compress') && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
|
if (config()->get('gzip_compress') && GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
|
||||||
if (UA_GZIP_SUPPORTED && strlen($contents) > 2000) {
|
if (UA_GZIP_SUPPORTED && strlen($contents) > 2000) {
|
||||||
|
if (!defined('MODERN_ROUTING')) {
|
||||||
header('Content-Encoding: gzip');
|
header('Content-Encoding: gzip');
|
||||||
|
}
|
||||||
$contents = gzencode($contents, 1);
|
$contents = gzencode($contents, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,12 +314,14 @@ define('SELECT', 6);
|
||||||
// Functions
|
// Functions
|
||||||
function send_no_cache_headers()
|
function send_no_cache_headers()
|
||||||
{
|
{
|
||||||
|
if (!defined('MODERN_ROUTING')) {
|
||||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||||
header('Pragma: no-cache');
|
header('Pragma: no-cache');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts "<br/>" / "<br>" tags to "\n" line breaks
|
* Converts "<br/>" / "<br>" tags to "\n" line breaks
|
||||||
|
|
|
@ -241,7 +241,7 @@ if (!empty(config()->get('page.show_torhelp')[$bb_script]) && !empty($userdata['
|
||||||
$in_out = ($logged_in) ? 'in' : 'out';
|
$in_out = ($logged_in) ? 'in' : 'out';
|
||||||
$template->assign_block_vars("switch_user_logged_{$in_out}", []);
|
$template->assign_block_vars("switch_user_logged_{$in_out}", []);
|
||||||
|
|
||||||
if (!IS_GUEST) {
|
if (!IS_GUEST && !defined('MODERN_ROUTING')) {
|
||||||
header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
|
header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
|
||||||
header('Expires: 0');
|
header('Expires: 0');
|
||||||
header('Pragma: no-cache');
|
header('Pragma: no-cache');
|
||||||
|
|
|
@ -62,8 +62,24 @@ class LegacyController
|
||||||
$originalGet = $_GET;
|
$originalGet = $_GET;
|
||||||
$originalPost = $_POST;
|
$originalPost = $_POST;
|
||||||
|
|
||||||
// Make legacy globals available in the included file's scope
|
// Import essential legacy globals into local scope
|
||||||
global $bb_cfg, $config, $user, $template, $datastore, $lang, $userdata, $userinfo, $images;
|
global $bb_cfg, $config, $user, $template, $datastore, $lang, $userdata, $userinfo, $images,
|
||||||
|
$tracking_topics, $tracking_forums, $theme, $bf, $attach_config, $gen_simple_header,
|
||||||
|
$client_ip, $user_ip, $log_action, $html, $wordCensor, $forum_key, $search_id,
|
||||||
|
$session_id, $items_found, $per_page, $topic_id, $req_topics, $forum_id, $mode,
|
||||||
|
$is_auth, $t_data, $postrow, $group_id, $group_info, $post_id, $folder, $post_info,
|
||||||
|
$tor, $post_data, $privmsg, $forums, $redirect, $attachment, $forum_data, $search_all,
|
||||||
|
$redirect_url, $topic_csv, $poster_id, $emailer, $s_hidden_fields, $opt, $msg, $stats,
|
||||||
|
$poster_id_key, $text_match_key, $poster_name_key, $my_topics_key, $my_topics_val, $title_only_key,
|
||||||
|
$all_words_key, $dl_cancel_key, $dl_cancel_val, $dl_compl_key, $dl_compl_val, $dl_down_key, $dl_down_val,
|
||||||
|
$dl_will_key, $dl_will_val, $new_key, $new_val, $new_topics_key, $new_topics_val, $time_key, $time_val,
|
||||||
|
$order_key, $order_val, $sort_key, $sort_val, $display_as_key, $display_as_val, $topic_key, $topic_val,
|
||||||
|
$poster_id_val, $poster_id_key, $forum_val, $forum_key;
|
||||||
|
|
||||||
|
// Signal to legacy code that we're running through modern routing
|
||||||
|
if (!defined('MODERN_ROUTING')) {
|
||||||
|
define('MODERN_ROUTING', true);
|
||||||
|
}
|
||||||
|
|
||||||
// Include the legacy controller
|
// Include the legacy controller
|
||||||
// Note: We don't use require_once to allow multiple includes if needed
|
// Note: We don't use require_once to allow multiple includes if needed
|
||||||
|
|
|
@ -136,15 +136,19 @@ class Kernel
|
||||||
|
|
||||||
private function sendResponse(ResponseInterface $response): void
|
private function sendResponse(ResponseInterface $response): void
|
||||||
{
|
{
|
||||||
// Send status line
|
// Send status line (only if headers haven't been sent already)
|
||||||
|
if (!headers_sent()) {
|
||||||
http_response_code($response->getStatusCode());
|
http_response_code($response->getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
// Send headers
|
// Send headers (only if headers haven't been sent already)
|
||||||
|
if (!headers_sent()) {
|
||||||
foreach ($response->getHeaders() as $name => $values) {
|
foreach ($response->getHeaders() as $name => $values) {
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
header("{$name}: {$value}", false);
|
header("{$name}: {$value}", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send body
|
// Send body
|
||||||
echo $response->getBody()->getContents();
|
echo $response->getBody()->getContents();
|
||||||
|
|
|
@ -14,12 +14,27 @@ return function (Router $router): void {
|
||||||
// Legacy controller routes (hacky but organized approach)
|
// Legacy controller routes (hacky but organized approach)
|
||||||
$legacyRoutes = [
|
$legacyRoutes = [
|
||||||
'ajax.php',
|
'ajax.php',
|
||||||
|
'dl.php',
|
||||||
|
'dl_list.php',
|
||||||
|
'feed.php',
|
||||||
|
'filelist.php',
|
||||||
|
'group.php',
|
||||||
|
'group_edit.php',
|
||||||
'index.php',
|
'index.php',
|
||||||
|
'info.php',
|
||||||
|
'login.php',
|
||||||
|
'memberlist.php',
|
||||||
|
'modcp.php',
|
||||||
|
'playback_m3u.php',
|
||||||
|
'poll.php',
|
||||||
|
'posting.php',
|
||||||
|
'privmsg.php',
|
||||||
|
'profile.php',
|
||||||
|
'search.php',
|
||||||
'terms.php',
|
'terms.php',
|
||||||
// Add more legacy controllers here as needed:
|
'tracker.php',
|
||||||
// 'login.php',
|
'viewforum.php',
|
||||||
// 'search.php',
|
'viewtopic.php',
|
||||||
// 'tracker.php',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($legacyRoutes as $route) {
|
foreach ($legacyRoutes as $route) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue