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