Issues (380)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

viewtopic.php (11 issues)

1
<?php
2
//
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                  Copyright (c) 2000-2020 XOOPS.org                        //
6
//                       <https://xoops.org>                             //
7
//  ------------------------------------------------------------------------ //
8
//  This program is free software; you can redistribute it and/or modify     //
9
//  it under the terms of the GNU General Public License as published by     //
10
//  the Free Software Foundation; either version 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
//  Author: phppp (D.J., [email protected])                                  //
28
//  URL: https://xoops.org                                                    //
29
//  Project: Article Project                                                 //
30
//  ------------------------------------------------------------------------ //
31
// irmtfan enhance include
32
33
use Xmf\Request;
34
use XoopsModules\Newbb;
35
use XoopsModules\Xoopspoll;
0 ignored issues
show
The type XoopsModules\Xoopspoll was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
37
require_once __DIR__ . '/header.php';
38
$xoopsLogger->startTime('newBB_viewtopic');
39
require_once __DIR__ . '/include/functions.read.php';
40
require_once __DIR__ . '/include/functions.render.php';
41
xoops_loadLanguage('user');
42
43
/*Build the page query*/
44
$query_vars  = ['post_id', 'topic_id', 'status', 'order', 'start', 'move', 'mode'];
45
$query_array = [];
46
foreach ($query_vars as $var) {
47
    if (Request::getString($var, '', 'GET')) {
48
        $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
49
    }
50
}
51
$page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
52
unset($query_array);
53
54
$forum_id = Request::getInt('forum', 0, 'GET');
55
$read     = (Request::getString('read', '', 'GET')
56
             && 'new' === Request::getString('read', '', 'GET')) ? Request::getString('read', '', 'GET') : '';
57
$topic_id = Request::getInt('topic_id', 0, 'GET'); // isset($_GET['topic_id']) ? (int)($_GET['topic_id']) : 0;
58
$post_id  = Request::getInt('post_id', 0, 'GET'); // !empty($_GET['post_id']) ? (int)($_GET['post_id']) : 0;
59
$move     = mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move']) ? strtolower($_GET['move']) : '';
60
$start    = Request::getInt('start', 0, 'GET'); // !empty($_GET['start']) ? (int)($_GET['start']) : 0;
61
$status   = (Request::getString('status', '', 'GET')
62
             && in_array(Request::getString('status', '', 'GET'), ['active', 'pending', 'deleted'])) ? Request::getString('status', '', 'GET') : '';
63
$mode     = Request::getInt('mode', (!empty($status) ? 2 : 0), 'GET'); // !empty($_GET['mode']) ? (int)($_GET['mode']) : (!empty($status) ? 2 : 0);
64
$order    = (Request::getString('order', '', 'GET')
65
             && in_array(Request::getString('order', '', 'GET'), ['ASC', 'DESC'])) ? Request::getString('order', '', 'GET') : '';
66
67
if ('' === $order) {
68
    if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) {
69
        $order = (1 == $GLOBALS['xoopsUser']->getVar('uorder')) ? 'DESC' : 'ASC';
70
    } else {
71
        $order = (1 == $GLOBALS['xoopsConfig']['com_order']) ? 'DESC' : 'ASC';
72
    }
73
}
74
75
if (!$topic_id && !$post_id) {
76
    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
77
    redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
78
}
79
80
///** @var Newbb\TopicHandler $topicHandler */
81
//$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
82
if (!empty($post_id)) {
83
    $topicObject = $topicHandler->getByPost($post_id);
84
    $topic_id    = $topicObject->getVar('topic_id');
85
} elseif (!empty($move)) {
86
    $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id);
87
    $topic_id    = $topicObject->getVar('topic_id');
88
} else {
89
    $topicObject = $topicHandler->get($topic_id);
90
}
91
92
if (!is_object($topicObject) || !$topic_id = $topicObject->getVar('topic_id')) {
93
    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
94
    redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
95
}
96
$forum_id = $topicObject->getVar('forum_id');
97
///** @var Newbb\ForumHandler $forumHandler */
98
//$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
99
$forumObject = $forumHandler->get($forum_id);
100
101
$isAdmin = newbbIsAdmin($forumObject);
102
103
if ((!$isAdmin && $topicObject->getVar('approved') < 0) || (!$forumHandler->getPermission($forumObject))
104
    || (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view'))) {
105
    redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
106
}
107
108
// START irmtfan - find if topic is read or unread - for all users (member and anon)
109
$topic_is_unread = true;
110
/* if $GLOBALS['xoopsModuleConfig']["read_mode"] === 0 ||
111
 * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] === 1 ||
112
 * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] === 2 ||
113
 * => $topic_last_post_time_or_id_read = NULL
114
 * if !$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']["read_mode"] === 2
115
 * => $topic_last_post_time_or_id_read = false
116
 * if !$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']["read_mode"] === 1
117
 * => $topic_last_post_time_or_id_read = lastview(newbb_IP{ip}LT)
118
*/
119
$topic_last_post_time_or_id_read = newbbGetRead('topic', $topic_id);
120
if (!empty($topic_last_post_time_or_id_read)) {
121
    if (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
122
        //        $postHandler     = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
123
        $postObject      = $postHandler->get($topicObject->getVar('topic_last_post_id'));
124
        $topic_is_unread = ($topic_last_post_time_or_id_read < $postObject->getVar('post_time'));
125
    }
126
    if (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
127
        $topic_is_unread = ($topic_last_post_time_or_id_read < $topicObject->getVar('topic_last_post_id'));
128
        // hack jump to last post read if post_id is empty - is there any better way?
129
        if (empty($post_id) && $topic_is_unread
130
            && !empty($GLOBALS['xoopsModuleConfig']['jump_to_topic_last_post_read_enabled'])) {
131
            header('Location: ' . Request::getString('REQUEST_URI', '', 'SERVER') . '&post_id=' . $topic_last_post_time_or_id_read);
132
        }
133
    }
134
}
135
// END irmtfan - find if topic is read or unread - for all users (member and anon)
136
137
/* Only admin has access to admin mode */
138
if (!$isAdmin) {
139
    $status = '';
140
    $mode   = 0;
141
}
142
143
if (!empty($GLOBALS['xoopsModuleConfig']['enable_karma'])) {
144
    //    /** @var Newbb\KarmaHandler $karmaHandler */
145
    //    $karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma');
146
    $user_karma = $karmaHandler->getUserKarma();
147
}
148
149
//$viewmode = "flat";
150
151
$total_posts = $topicHandler->getPostCount($topicObject, $status);
152
$postsArray  = [];
153
$postsArray  = $topicHandler->getAllPosts($topicObject, $order, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, $post_id, $status);
154
155
//irmtfan - increment topic_views only if the topic is unread
156
if ($topic_is_unread) {
157
    $topicObject->incrementCounter();
158
}
159
newbbSetRead('topic', $topic_id, $topicObject->getVar('topic_last_post_id'));
160
161
$GLOBALS['xoopsOption']['template_main'] = 'newbb_viewtopic.tpl';
162
// irmtfan remove and move to footer.php
163
//$xoopsOption['xoops_module_header']= $xoops_module_header;
164
// irmtfan include header.php after defining $xoopsOption['template_main']
165
require_once $GLOBALS['xoops']->path('header.php');
166
//$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
167
// irmtfan new method
168
if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
169
    $xoopsTpl->assign(
170
        'xoops_module_header',
171
        '
172
    <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forumObject->getVar('forum_id') . '" >
173
    ' . @$xoopsTpl->get_template_vars('xoops_module_header')
174
    );
175
}
176
177
if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
178
    /** @var Newbb\OnlineHandler $onlineHandler */
179
    $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online');
180
    $onlineHandler->init($forumObject, $topicObject);
181
    $xoopsTpl->assign('online', $onlineHandler->showOnline());
182
}
183
$xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject));
184
// irmtfan - remove icon_path and use newbbDisplayImage
185
$xoopsTpl->assign('anonym_avatar', newbbDisplayImage('anonym'));
186
187
// START irmtfan improve infobox
188
$infobox         = [];
189
$infobox['show'] = (int)$GLOBALS['xoopsModuleConfig']['show_infobox']; //4.05
190
// irmtfan removed then define after array
191
//$xoopsTpl->assign('infobox', $infobox); //4.05
192
$iconHandler = newbbGetIconHandler(); // can be use in the follwing codes in this file
193
194
if ($infobox['show'] > 0) {
195
    // irmtfan - remove icon_path and use newbbDisplayImage
196
    $infobox['icon'] = [
197
        'expand'   => $iconHandler->getImageSource('less'),
198
        'collapse' => $iconHandler->getImageSource('more'),
199
    ];
200
    if (1 == $infobox['show']) {
201
        $infobox['style'] = 'none';        //irmtfan move semicolon
202
        $infobox['alt']   = _MD_NEWBB_SEEUSERDATA;
203
        $infobox['src']   = 'more';
204
    } else {
205
        $infobox['style'] = 'block';        //irmtfan move semicolon
206
        $infobox['alt']   = _MD_NEWBB_HIDEUSERDATA;
207
        $infobox['src']   = 'less';
208
    }
209
    $infobox['displayImage'] = newbbDisplayImage($infobox['src'], $infobox['alt']);
210
}
211
$xoopsTpl->assign('infobox', $infobox);
212
// END irmtfan improve infobox
213
214
$xoopsTpl->assign(
215
    [
216
        'topic_title'    => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?topic_id=' . $topic_id . '">' . $topicObject->getFullTitle() . '</a>',
217
        'forum_name'     => $forumObject->getVar('forum_name'),
218
        'lang_nexttopic' => _MD_NEWBB_NEXTTOPIC,
219
        'lang_prevtopic' => _MD_NEWBB_PREVTOPIC,
220
        'topic_status'   => $topicObject->getVar('topic_status'),
221
    ]
222
);
223
224
//$categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
225
$categoryObject = $categoryHandler->get($forumObject->getVar('cat_id'), ['cat_title']);
226
$xoopsTpl->assign('category', ['id' => $forumObject->getVar('cat_id'), 'title' => $categoryObject->getVar('cat_title')]);
227
228
$xoopsTpl->assign('post_id', $post_id);
229
$xoopsTpl->assign('topic_id', $topic_id);
230
$xoopsTpl->assign('forum_id', $forum_id);
231
232
$order_current = ('DESC' === $order) ? 'DESC' : 'ASC';
233
$xoopsTpl->assign('order_current', $order_current);
234
235
$t_new   = newbbDisplayImage('t_new', _MD_NEWBB_POSTNEW);
236
$t_reply = newbbDisplayImage('t_reply', _MD_NEWBB_REPLY);
237
// irmtfan show topic status if show reg is 0 and revise forum_post_or_register
238
if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'post')) {
239
    $xoopsTpl->assign('forum_post', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/newtopic.php?forum=' . $forum_id . '"> ' . $t_new . '</a>');
240
} else {
241
    if ($topicObject->getVar('topic_status')) {
242
        $xoopsTpl->assign('topic_lock', _MD_NEWBB_TOPICLOCKED);
243
    }
244
    if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) {
245
        $xoopsTpl->assign('forum_register', '<a href="' . XOOPS_URL . '/user.php?xoops_redirect=' . htmlspecialchars($xoopsRequestUri, ENT_QUOTES | ENT_HTML5) . '">' . _MD_NEWBB_REGTOPOST . '</a>');
246
    }
247
}
248
// irmtfan for backward compatibility assign forum_post_or_register smarty again.
249
$xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post') . @$xoopsTpl->get_template_vars('forum_register') . @$xoopsTpl->get_template_vars('topic_lock'));
250
251
if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')) {
252
    $xoopsTpl->assign('forum_reply', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/reply.php?topic_id=' . $topic_id . '"> ' . $t_reply . '</a>');
253
}
254
255
$poster_array  = [];
256
$require_reply = false;
257
/** @var Post $eachpost */
258
foreach ($postsArray as $eachpost) {
259
    if ($eachpost->getVar('uid') > 0) {
260
        $poster_array[$eachpost->getVar('uid')] = 1;
261
    }
262
    if ($eachpost->getVar('require_reply') > 0) {
263
        $require_reply = true;
264
    }
265
}
266
267
$userid_array = [];
268
$online       = [];
269
if ($poster_array && is_array($poster_array)) {
270
    /** @var \XoopsMemberHandler $memberHandler */
271
    $memberHandler = xoops_getHandler('member');
272
    $userid_array  = array_keys($poster_array);
273
    $user_criteria = '(' . implode(',', $userid_array) . ')';
274
    $users         = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true);
275
} else {
276
    $users = [];
277
}
278
279
$viewtopic_users = [];
280
if ($userid_array && is_array($userid_array)) {
281
    //    require_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php');
282
    $userHandler         = new Newbb\UserHandler($GLOBALS['xoopsModuleConfig']['groupbar_enabled'], $GLOBALS['xoopsModuleConfig']['wol_enabled']);
283
    $userHandler->users  = $users;
284
    $userHandler->online = $online;
0 ignored issues
show
The property online does not seem to exist on XoopsModules\Newbb\UserHandler.
Loading history...
285
    $viewtopic_users     = $userHandler->getUsers();
286
}
287
unset($users);
288
289
if ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $require_reply) {
290
    if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) {
291
        $viewtopic_posters = newbbGetSession('t' . $topic_id, true);
292
        if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) {
293
            $viewtopic_posters = $topicHandler->getAllPosters($topicObject);
294
            newbbSetSession('t' . $topic_id, $viewtopic_posters);
295
        }
296
    } else {
297
        $viewtopic_posters = $topicHandler->getAllPosters($topicObject);
298
    }
299
} else {
300
    $viewtopic_posters = [];
301
}
302
303
if ($GLOBALS['xoopsModuleConfig']['show_advertising']) {
304
    $post_werbung = [
305
        'post_id'         => 0,
306
        'post_parent_id'  => 0,
307
        'post_date'       => 0,
308
        'post_image'      => '',
309
        'post_title'      => '',
310
        'post_text'       => '<div style="text-align: center;vertical-align: middle;"><br>' . xoops_getbanner() . '</div>',
311
        'post_attachment' => '',
312
        'post_edit'       => 0,
313
        'post_no'         => 0,
314
        'post_signature'  => _MD_NEWBB_ADVERTISING_BLOCK,
315
        'poster_ip'       => '',
316
        'thread_action'   => '',
317
        'thread_buttons'  => '',
318
        'mod_buttons'     => '',
319
        'poster'          => [
320
            'uid'        => -1,
321
            'link'       => _MD_NEWBB_ADVERTISING_USER,
322
            'avatar'     => 'avatars/blank.gif',
323
            'regdate'    => 0,
324
            'last_login' => 0,
325
            'rank'       => ['title' => ''],
326
        ],
327
        // irmtfan add last_login
328
        'post_permalink'  => '',
329
    ];
330
}
331
332
$i = 0;
333
/** @var Post $eachpost */
334
foreach ($postsArray as $eachpost) {
335
    if ($GLOBALS['xoopsModuleConfig']['show_advertising']) {
336
        if (2 === $i) {
337
            $xoopsTpl->append('topic_posts', $post_werbung);
338
        }
339
        ++$i;
340
    }
341
    $xoopsTpl->append('topic_posts', $eachpost->showPost($isAdmin));
342
}
343
344
if ($total_posts > $GLOBALS['xoopsModuleConfig']['posts_per_page']) {
345
    require_once $GLOBALS['xoops']->path('class/pagenav.php');
346
347
    $nav = new \XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&amp;order=' . $order . '&amp;status=' . $status . '&amp;mode=' . $mode);
348
    //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite']) && $GLOBALS['xoopsModuleConfig']['do_rewrite'] === 1) $nav->url = XOOPS_URL . $nav->url;
349
    if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
350
        $navi = $nav->renderSelect();
351
    } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
352
        $navi = $nav->renderImageNav(4);
353
    } else {
354
        $navi = $nav->renderNav(4);
355
    }
356
    $xoopsTpl->assign('forum_page_nav', $navi);
357
} else {
358
    $xoopsTpl->assign('forum_page_nav', '');
359
}
360
361
if (empty($post_id)) {
362
    $first   = array_keys($postsArray);
363
    $post_id = !empty($first[0]) ? $first[0] : 0;
364
}
365
366
if (!empty($postsArray[$post_id])) {
367
    $xoops_pagetitle = $postsArray[$post_id]->getVar('subject') . ' [' . $forumObject->getVar('forum_name') . ']';
368
    $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
369
    $xoopsOption['xoops_pagetitle'] = $xoops_pagetitle;
370
    $kw                             = array_unique(explode(' ', strip_tags($postsArray[$post_id]->getVar('post_text')), 150));
371
    asort($kw);
372
    $kwort = '';
373
    $z     = 0;
374
    foreach ($kw as $k) {
375
        if ($z < 30 && mb_strlen(trim($k)) > 5) {
376
            $kwort .= trim($k) . ' ';
377
            ++$z;
378
        }
379
    }
380
    $xoTheme->addMeta('meta', 'keywords', $kwort);
381
    $xoTheme->addMeta('meta', 'description', mb_substr(strip_tags($postsArray[$post_id]->getVar('post_text')), 0, 120));
382
}
383
unset($postsArray);
384
385
$xoopsTpl->assign('topic_print_link', "print.php?form=1&amp;{$page_query}");
386
387
$admin_actions = [];
388
$ad_merge      = '';
389
$ad_move       = '';
390
$ad_delete     = '';
391
// irmtfan add restore to viewtopic
392
$ad_restore  = '';
393
$ad_lock     = '';
394
$ad_unlock   = '';
395
$ad_sticky   = '';
396
$ad_unsticky = '';
397
$ad_digest   = '';
398
$ad_undigest = '';
399
400
// START irmtfan add restore to viewtopic
401
// if the topic is active
402
if ($topicObject->getVar('approved') > 0) {
403
    $admin_actions['merge']  = [
404
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=merge&amp;topic_id=' . $topic_id,
405
        'name'  => _MD_NEWBB_MERGETOPIC,
406
        'image' => $ad_merge,
407
    ];
408
    $admin_actions['move']   = [
409
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=move&amp;topic_id=' . $topic_id,
410
        'name'  => _MD_NEWBB_MOVETOPIC,
411
        'image' => $ad_move,
412
    ];
413
    $admin_actions['delete'] = [
414
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=delete&amp;topic_id=' . $topic_id,
415
        'name'  => _MD_NEWBB_DELETETOPIC,
416
        'image' => $ad_delete,
417
    ];
418
    if (!$topicObject->getVar('topic_status')) {
419
        $admin_actions['lock'] = [
420
            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=lock&amp;topic_id=' . $topic_id,
421
            'image' => $ad_lock,
422
            'name'  => _MD_NEWBB_LOCKTOPIC,
423
        ];
424
    } else {
425
        $admin_actions['unlock'] = [
426
            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unlock&amp;topic_id=' . $topic_id,
427
            'image' => $ad_unlock,
428
            'name'  => _MD_NEWBB_UNLOCKTOPIC,
429
        ];
430
    }
431
    if (!$topicObject->getVar('topic_sticky')) {
432
        $admin_actions['sticky'] = [
433
            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=sticky&amp;topic_id=' . $topic_id,
434
            'image' => $ad_sticky,
435
            'name'  => _MD_NEWBB_STICKYTOPIC,
436
        ];
437
    } else {
438
        $admin_actions['unsticky'] = [
439
            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unsticky&amp;topic_id=' . $topic_id,
440
            'image' => $ad_unsticky,
441
            'name'  => _MD_NEWBB_UNSTICKYTOPIC,
442
        ];
443
    }
444
    if (!$topicObject->getVar('topic_digest')) {
445
        $admin_actions['digest'] = [
446
            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=digest&amp;topic_id=' . $topic_id,
447
            'image' => $ad_digest,
448
            'name'  => _MD_NEWBB_DIGESTTOPIC,
449
        ];
450
    } else {
451
        $admin_actions['undigest'] = [
452
            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=undigest&amp;topic_id=' . $topic_id,
453
            'image' => $ad_undigest,
454
            'name'  => _MD_NEWBB_UNDIGESTTOPIC,
455
        ];
456
    }
457
    // if the topic is pending/deleted then restore/approve
458
} else {
459
    $admin_actions['restore'] = [
460
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=restore&amp;topic_id=' . $topic_id,
461
        'name'  => _MD_NEWBB_RESTORETOPIC,
462
        'image' => $ad_restore,
463
    ];
464
}
465
// END irmtfan add restore to viewtopic
466
467
$xoopsTpl->assign_by_ref('admin_actions', $admin_actions);
468
$xoopsTpl->assign('viewer_level', (int)($isAdmin ? 2 : is_object($GLOBALS['xoopsUser'])));
469
470
if ($GLOBALS['xoopsModuleConfig']['show_permissiontable']) {
471
    //    /** var Newbb\PermissionHandler $permHandler */
472
    //    $permHandler      = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
473
    $permission_table = $permHandler->getPermissionTable($forumObject, $topicObject->getVar('topic_status'), $isAdmin);
474
    $xoopsTpl->assign_by_ref('permission_table', $permission_table);
475
}
476
477
///////////////////////////////
478
// show Poll
479
// START irmtfan poll_module
480
// irmtfan remove
481
/*
482
$pollmodul = false;
483
$moduleHandler = xoops_getHandler( 'module' );
484
$PollModule = $moduleHandler->getByDirname('xoopspoll');
485
if ($PollModule && $PollModule->getVar('isactive')) {
486
    $pollmodul = 'xoopspoll';
487
} else {
488
    $PollModule = $moduleHandler->getByDirname('umfrage');
489
    if ($PollModule && $PollModule->getVar('isactive')) {
490
        $pollmodul = 'umfrage';
491
    }
492
}
493
*/
494
//irmtfan remove
495
$pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
496
if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) {
497
    $poll_id = $topicObject->getVar('poll_id');
498
    // can vote in poll
499
    $pollVote = ($topicObject->getVar('topic_haspoll') && $poll_id > 0
500
                 && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'vote'));
501
    // can add poll
502
    $pollAdd = $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll');
503
    if ($pollVote || $pollAdd) {
504
        $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
505
        // new xoopspoll module
506
        if ($pollModuleHandler->getVar('version') >= 201) {
507
            $classPoll = new Xoopspoll\Poll();
0 ignored issues
show
The type XoopsModules\Xoopspoll\Poll was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
508
        }
509
        elseif ($pollModuleHandler->getVar('version') >= 140) {
510
            //            xoops_load('renderer', $GLOBALS['xoopsModuleConfig']['poll_module']);
511
            xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']);
512
            // old xoopspoll or umfrage or any clone from them
513
        } else {
514
            $classPoll = $topicObject->loadOldPoll();
515
        }
516
    }
517
    // START can vote in poll
518
    if ($pollVote) {
519
        $xoopsTpl->assign('topic_poll', 1);
520
        $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
521
        // new xoopspoll module
522
        if ($pollModuleHandler->getVar('version') >= 201) {
523
            $xpollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll');
0 ignored issues
show
The type XoopsModules\Xoopspoll\Helper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
524
            /** @var Xoopspoll\Poll $pollObject */
525
            $pollObject = $xpollHandler->get($poll_id);
526
            if (is_object($pollObject)) {
527
                /* check to see if user has rights to view the results */
528
                $vis_return = $pollObject->isResultVisible();
529
                $isVisible  = $vis_return;
530
                $visibleMsg = $isVisible ? '' : $vis_return;
531
532
                /* setup the module config handler */
533
                /** @var \XoopsConfigHandler $configHandler */
534
                $configHandler = xoops_getHandler('config');
535
                $xp_config     = $configHandler->getConfigsByCat(0, $pollModuleHandler->getVar('mid'));
536
537
                $GLOBALS['xoopsTpl']->assign(
538
                    [
539
                        'is_visible'      => $isVisible,
540
                        'visible_message' => $visibleMsg,
541
                        'disp_votes'      => $xp_config['disp_vote_nums'],
542
                        'lang_vote'       => constant('_MD_' . mb_strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE'),
543
                        'lang_results'    => constant('_MD_' . mb_strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_RESULTS'),
544
                        'back_link'       => '',
545
                    ]
546
                );
547
                $classRenderer = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Renderer';
548
                /** @var Xoopspoll\Renderer $renderer */
549
                $renderer = new Xoopspoll\Renderer($pollObject);
0 ignored issues
show
The type XoopsModules\Xoopspoll\Renderer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
550
                // check to see if user has voted, show form if not, otherwise get results for form
551
552
                /** @var \XoopsModules\Xoopspoll\LogHandler $logHandler */
553
                $logHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Log');
554
                if ($pollObject->isAllowedToVote()
555
                    && (!$logHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $uid))) {
556
                    $myTpl = new \XoopsTpl();
557
                    $renderer->assignForm($myTpl);
558
                    $myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&amp;poll_id={$poll_id}"));
559
                    $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/templates/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '_view.tpl'));
560
                    $GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform);
561
                } else {
562
                    $GLOBALS['xoopsTpl']->assign('can_vote', false);
563
                    $xoopsTpl->assign('topic_pollresult', 1);
564
                    $GLOBALS['xoopsTpl']->assign('topic_resultform', $renderer->renderResults());
565
                }
566
            }
567
            // old xoopspoll or umfrage or any clone from them
568
        } else {
569
            $pollObject    = new $classPoll($poll_id);
570
//            $classRenderer = $classPoll . 'Renderer';
571
            $renderer      = new Xoopspoll\Renderer($pollObject);
572
            $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2);
0 ignored issues
show
The constant _PL_ALREADYVOTED2 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
573
            $xoopsTpl->assign('has_ended', $pollObject->getVar('end_time') < time() ? 1 : 0);
574
            // umfrage has polltype
575
            $polltype = $pollObject->getVar('polltype');
576
            if (!empty($polltype)) {
577
                $xoopsTpl->assign('polltype', $polltype);
578
                switch ($polltype) {
579
                    case 1:
580
                        $xoopsTpl->assign('polltypecomment', '');
581
                        break;
582
                    case 2:
583
                        $xoopsTpl->assign('polltypecomment', _PL_FULLBLIND);
0 ignored issues
show
The constant _PL_FULLBLIND was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
584
                        break;
585
                    case 3:
586
                        $xoopsTpl->assign('polltypecomment', _PL_HALFBLIND);
0 ignored issues
show
The constant _PL_HALFBLIND was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
587
                        break;
588
                }
589
            }
590
            $classLog = $classPoll . 'Log';
591
            $hasvoted = 0;
592
            if ($GLOBALS['xoopsUser']) {
593
                if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $uid)) {
594
                    $hasvoted = 1;
595
                }
596
            } else {
597
                $hasvoted = 1;
598
            }
599
            $xoopsTpl->assign('hasVoted', $hasvoted);
600
            $xoopsTpl->assign('lang_vote', _PL_VOTE);
0 ignored issues
show
The constant _PL_VOTE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
601
            $xoopsTpl->assign('lang_results', $pollObject->getVar('end_time') < time() ? _PL_RESULTS : _PL_STANDINGS);
0 ignored issues
show
The constant _PL_RESULTS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
The constant _PL_STANDINGS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
602
            // irmtfan - if the poll is expired show the result
603
            if ($hasvoted || $pollObject->hasExpired()) {
604
                $renderer->assignResults($xoopsTpl);
605
                $xoopsTpl->assign('topic_pollresult', 1);
606
                setcookie('newbb_polls[' . $poll_id . ']', 1);
607
            } else {
608
                $renderer->assignForm($xoopsTpl);
609
                $xoopsTpl->assign('lang_vote', _PL_VOTE);
610
                $xoopsTpl->assign('lang_results', _PL_RESULTS);
611
                setcookie('newbb_polls[' . $poll_id . ']', 1);
612
            }
613
        }
614
    }
615
    // END can vote in poll
616
    // START can add poll
617
    if ($pollAdd) {
618
        if (!$topicObject->getVar('topic_haspoll')) {
619
            if (is_object($GLOBALS['xoopsUser'])
620
                && $GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster')) {
621
                $t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL);
622
                $xoopsTpl->assign('forum_addpoll', '<a href=\'' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=add&amp;topic_id=' . $topic_id . '\'>' . $t_poll . '</a>');
623
            }
624
        } elseif ($isAdmin
625
                  || (is_object($pollObject) && is_object($GLOBALS['xoopsUser'])
626
                      && $GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) {
627
            $poll_edit    = '';
628
            $poll_delete  = '';
629
            $poll_restart = '';
630
            $poll_log     = '';
631
632
            $adminpoll_actions                = [];
633
            $adminpoll_actions['editpoll']    = [
634
                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
635
                'image' => $poll_edit,
636
                'name'  => _MD_NEWBB_EDITPOLL,
637
            ];
638
            $adminpoll_actions['deletepoll']  = [
639
                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
640
                'image' => $poll_delete,
641
                'name'  => _MD_NEWBB_DELETEPOLL,
642
            ];
643
            $adminpoll_actions['restartpoll'] = [
644
                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
645
                'image' => $poll_restart,
646
                'name'  => _MD_NEWBB_RESTARTPOLL,
647
            ];
648
            $adminpoll_actions['logpoll']     = [
649
                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=log&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
650
                'image' => $poll_log,
651
                'name'  => _MD_NEWBB_POLL_VIEWLOG,
652
            ];
653
654
            $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions);
655
        }
656
    }
657
    // END can add poll
658
}
659
if (isset($pollObject)) {
660
    unset($pollObject);
661
}
662
// END irmtfan poll_module
663
664
$xoopsTpl->assign('p_up', newbbDisplayImage('up', _MD_NEWBB_TOP));
665
$xoopsTpl->assign('rating_enable', $GLOBALS['xoopsModuleConfig']['rating_enabled']);
666
$xoopsTpl->assign('groupbar_enable', $GLOBALS['xoopsModuleConfig']['groupbar_enabled']);
667
$xoopsTpl->assign('anonymous_prefix', $GLOBALS['xoopsModuleConfig']['anonymous_prefix']);
668
// irmtfan add alt for prev next and down icons.
669
$xoopsTpl->assign('previous', newbbDisplayImage('previous', _MD_NEWBB_PREVTOPIC));
670
$xoopsTpl->assign('next', newbbDisplayImage('next', _MD_NEWBB_NEXTTOPIC));
671
$xoopsTpl->assign('down', newbbDisplayImage('down', _MD_NEWBB_BOTTOM));
672
$xoopsTpl->assign('post_content', newbbDisplayImage('post'));
673
674
if (!empty($GLOBALS['xoopsModuleConfig']['rating_enabled'])) {
675
    $xoopsTpl->assign('votes', $topicObject->getVar('votes'));
676
    $rating = number_format($topicObject->getVar('rating') / 2, 0);
677
    if ($rating < 1) {
678
        $rating_img = newbbDisplayImage('blank');
679
    } else {
680
        // irmtfan - add alt key for rating
681
        $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating));
682
    }
683
    $xoopsTpl->assign('rating_img', $rating_img);
684
    $xoopsTpl->assign('rate1', newbbDisplayImage('rate1', _MD_NEWBB_RATE1));
685
    $xoopsTpl->assign('rate2', newbbDisplayImage('rate2', _MD_NEWBB_RATE2));
686
    $xoopsTpl->assign('rate3', newbbDisplayImage('rate3', _MD_NEWBB_RATE3));
687
    $xoopsTpl->assign('rate4', newbbDisplayImage('rate4', _MD_NEWBB_RATE4));
688
    $xoopsTpl->assign('rate5', newbbDisplayImage('rate5', _MD_NEWBB_RATE5));
689
}
690
691
// create jump box
692
if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) {
693
    require_once __DIR__ . '/include/functions.forum.php';
694
    $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id));
695
}
696
697
$xoopsTpl->assign(
698
    [
699
        'lang_forum_index' => sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
700
        'lang_from'        => _MD_NEWBB_FROM,
701
        'lang_joined'      => _MD_NEWBB_JOINED,
702
        'lang_posts'       => _MD_NEWBB_POSTS,
703
        'lang_poster'      => _MD_NEWBB_POSTER,
704
        'lang_thread'      => _MD_NEWBB_THREAD,
705
        'lang_edit'        => _EDIT,
706
        'lang_delete'      => _DELETE,
707
        'lang_reply'       => _REPLY,
708
        'lang_postedon'    => _MD_NEWBB_POSTEDON,
709
        'lang_groups'      => _MD_NEWBB_GROUPS,
710
    ]
711
);
712
713
$viewmode_options = [];
714
if ('DESC' === $order) {
715
    $viewmode_options[] = [
716
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=ASC&amp;status=$status&amp;topic_id=' . $topic_id,
717
        'title' => _OLDESTFIRST,
718
    ];
719
} else {
720
    $viewmode_options[] = [
721
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=DESC&amp;status=$status&amp;topic_id=' . $topic_id,
722
        'title' => _NEWESTFIRST,
723
    ];
724
}
725
726
switch ($status) {
727
    case 'active':
728
        $current_status = '[' . _MD_NEWBB_TYPE_ADMIN . ']';
729
        break;
730
    case 'pending':
731
        $current_status = '[' . _MD_NEWBB_TYPE_PENDING . ']';
732
        break;
733
    case 'deleted':
734
        $current_status = '[' . _MD_NEWBB_TYPE_DELETED . ']';
735
        break;
736
    default:
737
        $current_status = '';
738
        break;
739
}
740
$xoopsTpl->assign('topicstatus', $current_status);
741
742
$xoopsTpl->assign('mode', $mode);
743
$xoopsTpl->assign('status', $status);
744
//$xoopsTpl->assign('viewmode_compact', ($viewmode=="compact")?1:0);
745
$xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options);
746
unset($viewmode_options);
747
$xoopsTpl->assign('menumode', $menumode);
748
$xoopsTpl->assign('menumode_other', $menumode_other);
749
$xoopsTpl->assign('facebookstyle', $helper->getConfig('facebookstyle'));
750
751
// START irmtfan add verifyUser to quick reply
752
//check banning
753
//$moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate');
754
if (!empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled'])
755
    && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')
756
    && $moderateHandler->verifyUser(-1, '', $forumObject->getVar('forum_id'))) {
757
    // END irmtfan add verifyUser to quick reply
758
    $forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php', 'post', true);
759
    if (!is_object($GLOBALS['xoopsUser'])) {
760
        //$configHandler = xoops_getHandler('config');
761
        $user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT);
762
        $user_tray->addElement(new \XoopsFormText(_MD_NEWBB_NAME, 'uname', 26, 255));
763
        $user_tray->addElement(new \XoopsFormPassword(_MD_NEWBB_PASSWORD, 'pass', 10, 32));
764
        $login_checkbox = new \XoopsFormCheckBox('', 'login', 1);
765
        $login_checkbox->addOption(1, _MD_NEWBB_LOGIN);
766
        $user_tray->addElement($login_checkbox);
767
        $forum_form->addElement($user_tray);
768
        $captcha = new \XoopsFormCaptcha('', "topic_{$topic_id}_{$start}");
769
        $captcha->setConfig('mode', 'text');
770
        $forum_form->addElement($captcha);
771
    }
772
773
    //$quickform = ( !empty($GLOBALS['xoopsModuleConfig']["editor_default"]) ) ? $GLOBALS['xoopsModuleConfig']["editor_default"] : "textarea";
774
    $quickform               = !empty($GLOBALS['xoopsModuleConfig']['editor_quick_default']) ? $GLOBALS['xoopsModuleConfig']['editor_quick_default'] : 'textarea';
775
    $editor_configs          = [];
776
    $editor_configs ['name'] = 'message';
777
    //$editor_configs [ "value" ]     = $message ;
778
    $editor_configs ['rows']   = empty($GLOBALS['xoopsModuleConfig'] ['editor_rows']) ? 10 : $GLOBALS['xoopsModuleConfig'] ['editor_rows'];
779
    $editor_configs ['cols']   = empty($GLOBALS['xoopsModuleConfig'] ['editor_cols']) ? 30 : $GLOBALS['xoopsModuleConfig'] ['editor_cols'];
780
    $editor_configs ['width']  = empty($GLOBALS['xoopsModuleConfig'] ['editor_width']) ? '100%' : $GLOBALS['xoopsModuleConfig'] ['editor_width'];
781
    $editor_configs ['height'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_height']) ? '400px' : $GLOBALS['xoopsModuleConfig'] ['editor_height'];
782
    $_editor                   = new \XoopsFormEditor(_MD_NEWBB_MESSAGEC, $quickform, $editor_configs, true);
783
    $forum_form->addElement($_editor, true);
784
785
    $forum_form->addElement(new \XoopsFormHidden('dohtml', 0));
786
    $forum_form->addElement(new \XoopsFormHidden('dosmiley', 1));
787
    $forum_form->addElement(new \XoopsFormHidden('doxcode', 1));
788
    $forum_form->addElement(new \XoopsFormHidden('dobr', 1));
789
    $forum_form->addElement(new \XoopsFormHidden('attachsig', 1));
790
791
    $forum_form->addElement(new \XoopsFormHidden('isreply', 1));
792
793
    $forum_form->addElement(new \XoopsFormHidden('subject', _MD_NEWBB_RE . ': ' . $topicObject->getVar('topic_title', 'e')));
794
    $forum_form->addElement(new \XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id));
795
    $forum_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
796
    $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id));
797
    //$forum_form->addElement(new \XoopsFormHidden('viewmode', $viewmode));
798
    $forum_form->addElement(new \XoopsFormHidden('order', $order));
799
    $forum_form->addElement(new \XoopsFormHidden('start', $start));
800
801
    $forum_form->addElement(new \XoopsFormHidden('notify', -1));
802
    $forum_form->addElement(new \XoopsFormHidden('contents_submit', 1));
803
804
    $submit_button = new \XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit');
805
    $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value === \'RE\' || document.forms.quick_reply.message.value === \'\') { alert(\'' . _MD_NEWBB_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"');
806
    $forum_form->addElement($submit_button);
807
808
    $toggles = newbbGetCookie('G', true);
809
    // START irmtfan improve quickreply smarty variable - add alt key to quick reply button - change $display to $style for more comprehension - add toggle $quickreply['expand']
810
    $quickreply           = [];
811
    $qr_collapse          = 't_qr';
812
    $qr_expand            = 't_qr_expand'; // change this
813
    $quickreply['icon']   = [
814
        'expand'   => $iconHandler->getImageSource($qr_expand),
815
        'collapse' => $iconHandler->getImageSource($qr_collapse),
816
    ];
817
    $quickreply['show']   = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled']
818
    $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles) ? false : true) : true;
819
    if ($quickreply['expand']) {
820
        $quickreply['style']     = 'block';        //irmtfan move semicolon
821
        $quickreply_icon_display = $qr_expand;
822
        $quickreply_alt          = _MD_NEWBB_HIDE . ' ' . _MD_NEWBB_QUICKREPLY;
823
    } else {
824
        $quickreply['style']     = 'none';        //irmtfan move semicolon
825
        $quickreply_icon_display = $qr_collapse;
826
        $quickreply_alt          = _MD_NEWBB_SEE . ' ' . _MD_NEWBB_QUICKREPLY;
827
    }
828
    $quickreply['displayImage'] = newbbDisplayImage($quickreply_icon_display, $quickreply_alt);
829
    $quickreply['form']         = $forum_form->render();
830
    $xoopsTpl->assign('quickreply', $quickreply);
831
    // END irmtfan improve quickreply smarty variable
832
    unset($forum_form);
833
} else {
834
    $xoopsTpl->assign('quickreply', ['show' => 0]);
835
}
836
837
if ($GLOBALS['xoopsModuleConfig']['do_tag'] && class_exists('TagFormTag')
838
    && @require $GLOBALS['xoops']->path('modules/tag/include/tagbar.php')) {
839
    $xoopsTpl->assign('tagbar', tagBar($topicObject->getVar('topic_tags', 'n')));
840
}
841
// irmtfan move to footer.php
842
require_once __DIR__ . '/footer.php';
843
require_once $GLOBALS['xoops']->path('footer.php');
844
$xoopsLogger->stopTime('newBB_viewtopic');
845