|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* NewBB, the forum module for XOOPS project |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
7
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
8
|
|
|
* @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
|
9
|
|
|
* @since 4.00 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
use Xmf\Request; |
|
13
|
|
|
use XoopsModules\Newbb\{ |
|
14
|
|
|
ForumHandler, |
|
15
|
|
|
Helper, |
|
16
|
|
|
PostHandler, |
|
17
|
|
|
TopicHandler |
|
18
|
|
|
}; |
|
19
|
|
|
|
|
20
|
|
|
/** @var Helper $helper */ |
|
21
|
|
|
/** @var ForumHandler $forumHandler */ |
|
22
|
|
|
/** @var TopicHandler $topicHandler */ |
|
23
|
|
|
/** @var PostHandler $postHandler */ |
|
24
|
|
|
require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
|
25
|
|
|
require_once __DIR__ . '/include/common.php'; |
|
26
|
|
|
|
|
27
|
|
|
$moduleDirName = basename(__DIR__); |
|
28
|
|
|
|
|
29
|
|
|
$helper = Helper::getInstance(); |
|
30
|
|
|
// Load language files |
|
31
|
|
|
$helper->loadLanguage('main'); |
|
32
|
|
|
|
|
33
|
|
|
$forumHandler = Helper::getInstance()->getHandler('Forum'); |
|
34
|
|
|
$topicHandler = Helper::getInstance()->getHandler('Topic'); |
|
35
|
|
|
$postHandler = Helper::getInstance()->getHandler('Post'); |
|
36
|
|
|
|
|
37
|
|
|
/** @var \XoopsLogger $xoopsLogger */ |
|
38
|
|
|
$xoopsLogger->startTime('newBB_Header'); |
|
39
|
|
|
// irmtfan assign newbb dirname then replace all. include xoops header.php (now commented and removed) |
|
40
|
|
|
//$dirname = $xoopsModule->getVar('dirname'); |
|
41
|
|
|
$moduleDirName = basename(__DIR__); |
|
42
|
|
|
//require_once $GLOBALS['xoops']->path('header.php'); |
|
43
|
|
|
|
|
44
|
|
|
if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
45
|
|
|
require_once __DIR__ . '/seo_url.php'; |
|
46
|
|
|
/* for seo */ |
|
47
|
|
|
$toseo_url = ['index.php', 'viewforum.php', 'viewtopic.php', 'rss.php']; |
|
48
|
|
|
|
|
49
|
|
|
if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite']) && (!isset($_POST) || count($_POST) <= 0) |
|
50
|
|
|
&& (false === mb_strpos(getenv('REQUEST_URI'), '.html'))) { |
|
51
|
|
|
$redir = false; |
|
52
|
|
|
if (is_int(mb_strpos(getenv('REQUEST_URI'), 'mark_read=')) || is_int(mb_strpos(getenv('REQUEST_URI'), 'mark='))) { |
|
|
|
|
|
|
53
|
|
|
// Mark Forums |
|
54
|
|
|
} elseif (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url, true)) { |
|
55
|
|
|
//rewrite only for files |
|
56
|
|
|
|
|
57
|
|
|
if ('' !== trim(getenv('SCRIPT_NAME'))) { |
|
58
|
|
|
if (false === mb_strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) { |
|
59
|
|
|
$redir = true; |
|
60
|
|
|
} elseif (getenv('QUERY_STRING')) { |
|
61
|
|
|
$redir = true; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
if (true === $redir) { |
|
|
|
|
|
|
67
|
|
|
$s = 'https://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'); |
|
68
|
|
|
$s = str_replace('/' . REAL_MODULE_NAME . '/', '/' . SEO_MODULE_NAME . '/', $s); |
|
69
|
|
|
$newurl = seo_urls('<a href="' . $s . '"></a>'); |
|
70
|
|
|
$newurl = str_replace('<a href="', '', $newurl); |
|
71
|
|
|
$newurl = str_replace('"></a>', '', $newurl); |
|
72
|
|
|
if (!headers_sent()) { |
|
73
|
|
|
header('HTTP/1.1 301 Moved Permanently'); |
|
74
|
|
|
header("Location: $newurl"); |
|
75
|
|
|
exit(); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
require_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/vars.php'); |
|
82
|
|
|
|
|
83
|
|
|
require_once __DIR__ . '/include/functions.user.php'; |
|
84
|
|
|
require_once __DIR__ . '/include/functions.topic.php'; |
|
85
|
|
|
|
|
86
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
87
|
|
|
require_once $GLOBALS['xoops']->path('class/module.textsanitizer.php'); |
|
88
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
89
|
|
|
|
|
90
|
|
|
$menumode = 0; |
|
91
|
|
|
$menumode_other = []; |
|
92
|
|
|
$menu_url = htmlspecialchars(preg_replace('/&menumode=[^&]/', '', (string) Request::getString('REQUEST_URI', '', 'SERVER')), ENT_QUOTES | ENT_HTML5); |
|
93
|
|
|
$menu_url .= (false === mb_strpos($menu_url, '?')) ? '?menumode=' : '&menumode='; |
|
94
|
|
|
//foreach ($GLOBALS['xoopsModuleConfig']['valid_menumodes'] as $key => $val) { |
|
95
|
|
|
// if ($key !== $menumode) { |
|
96
|
|
|
// $menumode_other[] = array('title' => $val, 'link' => $menu_url . $key); |
|
97
|
|
|
// } |
|
98
|
|
|
//} |
|
99
|
|
|
|
|
100
|
|
|
if (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['welcome_forum']) |
|
101
|
|
|
&& !$GLOBALS['xoopsUser']->getVar('posts')) { |
|
102
|
|
|
require_once __DIR__ . '/include/functions.welcome.php'; |
|
103
|
|
|
} |
|
104
|
|
|
// irmtfan for backward compatibility |
|
105
|
|
|
$pollmodules = $GLOBALS['xoopsModuleConfig']['poll_module']; |
|
106
|
|
|
|
|
107
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
108
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
109
|
|
|
$xoopspoll = $moduleHandler->getByDirname($pollmodules); |
|
110
|
|
|
|
|
111
|
|
|
$xoopsLogger->stopTime('newBB_Header'); |
|
112
|
|
|
|