mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -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('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';
|
||||
|
||||
$datastore->enqueue([
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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;
|
||||
$topic_id = $_REQUEST[POST_TOPIC_URL] ?? 0;
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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
|
||||
$user->session_start(['req_login' => true]);
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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
|
||||
$user->session_start();
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
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';
|
||||
|
||||
$page_cfg['use_tablesorter'] = true;
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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;
|
||||
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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
|
||||
$user->session_start();
|
|
@ -10,7 +10,10 @@
|
|||
define('BB_SCRIPT', 'login');
|
||||
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');
|
||||
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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]);
|
||||
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
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';
|
||||
|
||||
//
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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')) {
|
||||
redirect('index.php');
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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
|
||||
$user->session_start(['req_login' => true]);
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
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 ATTACH_DIR . '/attachment_mod.php';
|
||||
|
|
@ -10,7 +10,11 @@
|
|||
define('BB_SCRIPT', 'pm');
|
||||
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';
|
||||
|
||||
$privmsg_sent_id = $l_box_name = $to_username = $privmsg_subject = $privmsg_message = $error_msg = '';
|
|
@ -10,7 +10,10 @@
|
|||
define('BB_SCRIPT', 'profile');
|
||||
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
|
||||
$user->session_start();
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
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';
|
||||
|
||||
$page_cfg['use_tablesorter'] = true;
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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_cfg['include_bbcode_js'] = true;
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
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;
|
||||
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
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';
|
||||
|
||||
$datastore->enqueue([
|
|
@ -1332,7 +1332,7 @@ function bb_die($msg_text, $status_code = null)
|
|||
{
|
||||
global $ajax, $lang, $template, $theme, $userdata, $user;
|
||||
|
||||
if (isset($status_code)) {
|
||||
if (isset($status_code) && !defined('MODERN_ROUTING')) {
|
||||
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)
|
||||
{
|
||||
header('Content-Type: text/plain; charset=' . DEFAULT_CHARSET);
|
||||
if (!defined('MODERN_ROUTING')) {
|
||||
header('Content-Type: text/plain; charset=' . DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
if (isset($status_code)) {
|
||||
if (isset($status_code) && !defined('MODERN_ROUTING')) {
|
||||
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 (UA_GZIP_SUPPORTED && strlen($contents) > 2000) {
|
||||
header('Content-Encoding: gzip');
|
||||
if (!defined('MODERN_ROUTING')) {
|
||||
header('Content-Encoding: gzip');
|
||||
}
|
||||
$contents = gzencode($contents, 1);
|
||||
}
|
||||
}
|
||||
|
@ -312,11 +314,13 @@ define('SELECT', 6);
|
|||
// Functions
|
||||
function send_no_cache_headers()
|
||||
{
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 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: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
if (!defined('MODERN_ROUTING')) {
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 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: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -241,7 +241,7 @@ if (!empty(config()->get('page.show_torhelp')[$bb_script]) && !empty($userdata['
|
|||
$in_out = ($logged_in) ? '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('Expires: 0');
|
||||
header('Pragma: no-cache');
|
||||
|
|
|
@ -62,8 +62,24 @@ class LegacyController
|
|||
$originalGet = $_GET;
|
||||
$originalPost = $_POST;
|
||||
|
||||
// Make legacy globals available in the included file's scope
|
||||
global $bb_cfg, $config, $user, $template, $datastore, $lang, $userdata, $userinfo, $images;
|
||||
// Import essential legacy globals into local scope
|
||||
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
|
||||
// Note: We don't use require_once to allow multiple includes if needed
|
||||
|
|
|
@ -136,13 +136,17 @@ class Kernel
|
|||
|
||||
private function sendResponse(ResponseInterface $response): void
|
||||
{
|
||||
// Send status line
|
||||
http_response_code($response->getStatusCode());
|
||||
// Send status line (only if headers haven't been sent already)
|
||||
if (!headers_sent()) {
|
||||
http_response_code($response->getStatusCode());
|
||||
}
|
||||
|
||||
// Send headers
|
||||
foreach ($response->getHeaders() as $name => $values) {
|
||||
foreach ($values as $value) {
|
||||
header("{$name}: {$value}", false);
|
||||
// Send headers (only if headers haven't been sent already)
|
||||
if (!headers_sent()) {
|
||||
foreach ($response->getHeaders() as $name => $values) {
|
||||
foreach ($values as $value) {
|
||||
header("{$name}: {$value}", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,12 +14,27 @@ return function (Router $router): void {
|
|||
// Legacy controller routes (hacky but organized approach)
|
||||
$legacyRoutes = [
|
||||
'ajax.php',
|
||||
'dl.php',
|
||||
'dl_list.php',
|
||||
'feed.php',
|
||||
'filelist.php',
|
||||
'group.php',
|
||||
'group_edit.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',
|
||||
// Add more legacy controllers here as needed:
|
||||
// 'login.php',
|
||||
// 'search.php',
|
||||
// 'tracker.php',
|
||||
'tracker.php',
|
||||
'viewforum.php',
|
||||
'viewtopic.php',
|
||||
];
|
||||
|
||||
foreach ($legacyRoutes as $route) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue