mambax7 /
newbb5
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * NewBB 5.0x, the forum module for XOOPS project |
||||
| 4 | * |
||||
| 5 | * @copyright XOOPS Project (https://xoops.org) |
||||
| 6 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||||
| 7 | * @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
||||
| 8 | * @since 4.00 |
||||
| 9 | * @package module::newbb |
||||
| 10 | */ |
||||
| 11 | |||||
| 12 | use Xmf\Request; |
||||
| 13 | |||||
| 14 | include dirname(dirname(__DIR__)) . '/mainfile.php'; |
||||
| 15 | require_once __DIR__ . '/include/common.php'; |
||||
| 16 | |||||
| 17 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||
| 18 | /** @var \XoopsLogger $xoopsLogger */ |
||||
| 19 | $xoopsLogger->startTime('newBB_Header'); |
||||
| 20 | // irmtfan assign newbb dirname then replace all. include xoops header.php (now commented and removed) |
||||
| 21 | //$dirname = $xoopsModule->getVar('dirname'); |
||||
| 22 | $moduleDirName = basename(__DIR__); |
||||
| 23 | //require_once $GLOBALS['xoops']->path('header.php'); |
||||
| 24 | |||||
| 25 | if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
||||
| 26 | require_once __DIR__ . '/seo_url.php'; |
||||
| 27 | /* for seo */ |
||||
| 28 | $toseo_url = ['index.php', 'viewforum.php', 'viewtopic.php', 'rss.php']; |
||||
| 29 | |||||
| 30 | if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite']) && (!isset($_POST) || count($_POST) <= 0) |
||||
| 31 | && (false === strpos(getenv('REQUEST_URI'), '.html'))) { |
||||
| 32 | $redir = false; |
||||
| 33 | if (true === strpos(getenv('REQUEST_URI'), 'mark_read=') || true === strpos(getenv('REQUEST_URI'), 'mark=')) { |
||||
| 34 | // Mark Forums |
||||
| 35 | } else { |
||||
| 36 | if (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url)) { |
||||
| 37 | //rewrite only for files |
||||
| 38 | |||||
| 39 | if ('' !== trim(getenv('SCRIPT_NAME'))) { |
||||
| 40 | if (false === strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) { |
||||
| 41 | $redir = true; |
||||
| 42 | } elseif (getenv('QUERY_STRING')) { |
||||
| 43 | $redir = true; |
||||
| 44 | } |
||||
| 45 | } |
||||
| 46 | } |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | if (true === $redir) { |
||||
| 50 | $s = 'http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
Are you sure
getenv('REQUEST_URI') of type false|string|array can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 51 | $s = str_replace('/' . REAL_MODULE_NAME . '/', '/' . SEO_MODULE_NAME . '/', $s); |
||||
| 52 | $newurl = seo_urls('<a href="' . $s . '"></a>'); |
||||
| 53 | $newurl = str_replace('<a href="', '', $newurl); |
||||
| 54 | $newurl = str_replace('"></a>', '', $newurl); |
||||
| 55 | if (!headers_sent()) { |
||||
| 56 | header('HTTP/1.1 301 Moved Permanently'); |
||||
| 57 | header("Location: $newurl"); |
||||
| 58 | exit(); |
||||
| 59 | } |
||||
| 60 | } |
||||
| 61 | } |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | require_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/vars.php'); |
||||
| 65 | |||||
| 66 | require_once __DIR__ . '/include/functions.user.php'; |
||||
| 67 | require_once __DIR__ . '/include/functions.topic.php'; |
||||
| 68 | |||||
| 69 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||||
| 70 | require_once $GLOBALS['xoops']->path('class/module.textsanitizer.php'); |
||||
| 71 | $myts = \MyTextSanitizer::getInstance(); |
||||
| 72 | |||||
| 73 | $menumode = 0; |
||||
| 74 | $menumode_other = []; |
||||
| 75 | $menu_url = htmlspecialchars(preg_replace('/&menumode=[^&]/', '', Request::getString('REQUEST_URI', '', 'SERVER'))); |
||||
| 76 | $menu_url .= (false === strpos($menu_url, '?')) ? '?menumode=' : '&menumode='; |
||||
| 77 | //foreach ($GLOBALS['xoopsModuleConfig']['valid_menumodes'] as $key => $val) { |
||||
| 78 | // if ($key !== $menumode) { |
||||
| 79 | // $menumode_other[] = array('title' => $val, 'link' => $menu_url . $key); |
||||
| 80 | // } |
||||
| 81 | //} |
||||
| 82 | |||||
| 83 | if (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['welcome_forum']) |
||||
| 84 | && !$GLOBALS['xoopsUser']->getVar('posts')) { |
||||
| 85 | require_once __DIR__ . '/include/functions.welcome.php'; |
||||
| 86 | } |
||||
| 87 | // irmtfan for backward compatibility |
||||
| 88 | $pollmodules = $GLOBALS['xoopsModuleConfig']['poll_module']; |
||||
| 89 | |||||
| 90 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||
| 91 | $moduleHandler = xoops_getHandler('module'); |
||||
| 92 | $xoopspoll = $moduleHandler->getByDirname($pollmodules); |
||||
| 93 | |||||
| 94 | $xoopsLogger->stopTime('newBB_Header'); |
||||
| 95 |