Issues (340)

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.

blocks/newbb_block.php (14 issues)

1
<?php declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    XOOPS Project (https://xoops.org)
15
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       XOOPS Development Team
17
 */
18
19
use XoopsModules\Newbb\{
20
    Helper,
21
    PermissionHandler,
22
    TypeHandler
23
};
24
25
/** @var Helper $helper */
26
/** @var TypeHandler $typeHandler */
27
28
// irmtfan use full path because block maybe used outside newbb
29
30
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
31
32
if (defined('NEWBB_BLOCK_DEFINED')) {
33
    return;
34
}
35
define('NEWBB_BLOCK_DEFINED', true);
36
37
/**
38
 * @param int $var
39
 * @return bool
40
 */
41
function b_newbb_array_filter(int $var): bool
42
{
43
    return $var > 0;
44
}
45
46
// options[0] - Citeria valid: time(by default)
47
// options[1] - NumberToDisplay: any positive integer
48
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
49
// options[3] - DisplayMode: 0-full view;1-compact view;2-lite view
50
// options[4] - Display Navigator: 1 (by default), 0 (No)
51
// options[5] - Title Length : 0 - no limit
52
// options[6] - SelectedForumIDs: null for all
53
54
/**
55
 * @param array $options
56
 *
57
 * @return ((mixed|string)[][]|int|mixed)[]|false
58
 *
59
 * @psalm-return array{disp_mode?: mixed, topics?: non-empty-list<array{topic_subject: string, post_id: mixed, topic_status: mixed, forum_id: mixed, forum_name: string, id: mixed, title: string, replies: mixed, views: mixed, time: string, topic_poster: mixed|string, topic_page_jump: mixed, seo_url: mixed|string, seo_topic_url: mixed|string, seo_forum_url: mixed|string}>, seo_top_allforums?: mixed, seo_top_alltopics?: mixed, seo_top_allposts?: mixed, indexNav?: int}|false
60
 */
61
function b_newbb_show(array $options )
62
{
63
    global $accessForums;
64
    global $xoopsLogger;
65
66
    require_once \dirname(__DIR__) . '/include/functions.config.php';
67
    require_once \dirname(__DIR__) . '/include/functions.time.php';
68
69
    $myts          = \MyTextSanitizer::getInstance();
0 ignored issues
show
The assignment to $myts is dead and can be removed.
Loading history...
70
    $block         = [];
71
    $i             = 0;
0 ignored issues
show
The assignment to $i is dead and can be removed.
Loading history...
72
    $order         = '';
0 ignored issues
show
The assignment to $order is dead and can be removed.
Loading history...
73
    $extraCriteria = '';
74
    if (!empty($options[2])) {
75
        //require_once  \dirname(__DIR__) . '/include/functions.time.php';
76
        $extraCriteria .= ' AND p.post_time>' . (time() - newbbGetSinceTime((int)$options[2]));
77
    }
78
    switch ($options[0]) {
79
        default:
80
            $order = 't.topic_last_post_id';
81
            break;
82
    }
83
84
    if (!isset($accessForums)) {
85
        $permissionHandler = Helper::getInstance()->getHandler('Permission');
86
        assert($permissionHandler instanceof PermissionHandler);
87
        if (!$accessForums = $permissionHandler->getForums()) {
88
            return $block;
89
        }
90
    }
91
    if (!empty($options[6])) {
92
        $myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
93
        $allowedForums   = array_intersect($myallowedForums, $accessForums);
94
    } else {
95
        $allowedForums = $accessForums;
96
    }
97
    if (empty($allowedForums)) {
98
        return $block;
99
    }
100
101
    $forumCriteria   = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')';
102
    $approveCriteria = ' AND t.approved = 1';
103
104
    $newbbConfig = newbbLoadConfig();
105
    if (!empty($newbbConfig['do_rewrite'])) {
106
        require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php');
107
    } elseif (!defined('SEO_MODULE_NAME')) {
108
        define('SEO_MODULE_NAME', 'modules/newbb');
109
    }
110
111
    $query = 'SELECT'
112
             . '    t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id,'
113
             . '    f.forum_name,t.topic_status,'
114
             . '    p.post_id, p.post_time, p.icon, p.uid, p.poster_name'
115
             . '    FROM '
116
             . $GLOBALS['xoopsDB']->prefix('newbb_topics')
117
             . ' AS t '
118
             . '    LEFT JOIN '
119
             . $GLOBALS['xoopsDB']->prefix('newbb_posts')
120
             . ' AS p ON t.topic_last_post_id=p.post_id'
121
             . '    LEFT JOIN '
122
             . $GLOBALS['xoopsDB']->prefix('newbb_forums')
123
             . ' AS f ON f.forum_id=t.forum_id'
124
             . '    WHERE 1=1 '
125
             . $forumCriteria
126
             . $approveCriteria
127
             . $extraCriteria
128
             . ' ORDER BY '
129
             . $order
130
             . ' DESC';
131
132
    $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0);
133
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
134
        //\trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
135
        return false;
136
    }
137
138
    $block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view;
139
    $rows               = [];
140
    $author             = [];
141
    $types              = [];
142
143
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
144
        $rows[]              = $row;
145
        $author[$row['uid']] = 1;
146
        if ($row['type_id'] > 0) {
147
            $types[$row['type_id']] = 1;
148
        }
149
    }
150
151
    if (count($rows) < 1) {
152
        return $block;
153
    }
154
155
    require_once \dirname(__DIR__) . '/include/functions.user.php';
156
    $author_name = newbbGetUnameFromIds(array_keys($author), (bool)$newbbConfig['show_realname'], true);
157
158
    $type_list = null;
159
    if (count($types) > 0) {
160
        $typeHandler = Helper::getInstance()->getHandler('Type');
161
        assert($typeHandler instanceof TypeHandler);
162
        $type_list   = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN'));
163
    }
164
165
    foreach ($rows as $arr) {
166
        // irmtfan add lastposticon - load main lang
167
        xoops_loadLanguage('main', 'newbb');
168
        $topic                  = [];
169
        $topic_page_jump        = newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST);
170
        $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . ']';
171
172
        $topic['post_id']      = $arr['post_id'];
173
        $topic['topic_status'] = $arr['topic_status'];
174
        $topic['forum_id']     = $arr['forum_id'];
175
        $topic['forum_name']   = htmlspecialchars((string)$arr['forum_name'], ENT_QUOTES | ENT_HTML5);
176
        $topic['id']           = $arr['topic_id'];
177
178
        $title = htmlspecialchars((string)$arr['topic_title'], ENT_QUOTES | ENT_HTML5);
179
        if (!empty($options[5])) {
180
            $title = xoops_substr($title, 0, $options[5]);
181
        }
182
        $topic['title']   = $topic['topic_subject'] . ' ' . $title;
183
        $topic['replies'] = $arr['topic_replies'];
184
        $topic['views']   = $arr['topic_views'];
185
        $topic['time']    = newbbFormatTimestamp((int)$arr['post_time']);
186
        if (!empty($author_name[$arr['uid']])) {
187
            $topic_poster = $author_name[$arr['uid']];
188
        } else {
189
            $topic_poster = htmlspecialchars((string) ((string)$arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), ENT_QUOTES | ENT_HTML5);
190
        }
191
        $topic['topic_poster']    = $topic_poster;
192
        $topic['topic_page_jump'] = $topic_page_jump;
193
        // START irmtfan remove hardcoded html in URLs - add $seo_topic_url
194
        //$seo_url       = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id'];
195
        //BigKev73 > Change to support jumping directly to that post, vs just the page that the topic is on
196
        $seo_url       = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'] . '&amp;post_id=' . $topic['post_id'] . '#forumpost' . $topic['post_id'];
197
        $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'];
198
        $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id'];
199
        if (!empty($newbbConfig['do_rewrite'])) {
200
            $topic['seo_url']       = seo_urls($seo_url);
201
            $topic['seo_topic_url'] = seo_urls($seo_topic_url);
202
            $topic['seo_forum_url'] = seo_urls($seo_forum_url);
203
        } else {
204
            $topic['seo_url']       = $seo_url;
205
            $topic['seo_topic_url'] = $seo_topic_url;
206
            $topic['seo_forum_url'] = $seo_forum_url;
207
        }
208
        // END irmtfan remove hardcoded html in URLs - add $seo_topic_url
209
        $block['topics'][] = $topic;
210
        unset($topic);
211
    }
212
    // START irmtfan remove hardcoded html in URLs
213
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME;
214
    $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
215
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php';
216
    $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
217
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php';
218
    $block['seo_top_allposts']  = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
219
    // END irmtfan remove hardcoded html in URLs
220
    $block['indexNav'] = (int)$options[4];
221
222
    return $block;
223
}
224
225
// options[0] - Citeria valid: time(by default), views, replies, digest, sticky
226
// options[1] - NumberToDisplay: any positive integer
227
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
228
// options[3] - DisplayMode: 0-full view;1-compact view;2-lite view
229
// options[4] - Display Navigator: 1 (by default), 0 (No)
230
// options[5] - Title Length : 0 - no limit
231
// options[6] - SelectedForumIDs: null for all
232
233
/**
234
 * @param array $options
235
 *
236
 * @return ((mixed|string)[][]|int|mixed)[]|false
237
 *
238
 * @psalm-return array{disp_mode?: mixed, topics?: non-empty-list<array{topic_subject: string, forum_id: mixed, forum_name: string, id: mixed, title: string, replies: mixed, views: mixed, time: string, topic_poster: mixed|string, seo_topic_url: mixed|string, seo_forum_url: mixed|string}>, seo_top_allforums?: mixed, seo_top_alltopics?: mixed, seo_top_allposts?: mixed, indexNav?: int}|false
239
 */
240
function b_newbb_topic_show(array $options)
241
{
242
    global $accessForums;
243
    require_once \dirname(__DIR__) . '/include/functions.time.php';
244
    $myts          = \MyTextSanitizer::getInstance();
0 ignored issues
show
The assignment to $myts is dead and can be removed.
Loading history...
245
    $block         = [];
246
    $i             = 0;
0 ignored issues
show
The assignment to $i is dead and can be removed.
Loading history...
247
    $order         = '';
248
    $extraCriteria = '';
249
    $time_criteria = null;
250
    if (!empty($options[2])) {
251
        $time_criteria = time() - newbbGetSinceTime($options[2]);
252
        $extraCriteria = ' AND t.topic_time>' . $time_criteria;
253
    }
254
    switch ($options[0]) {
255
        case 'views':
256
            $order = 't.topic_views';
257
            break;
258
        case 'replies':
259
            $order = 't.topic_replies';
260
            break;
261
        case 'digest':
262
            $order         = 't.digest_time';
263
            $extraCriteria = ' AND t.topic_digest=1';
264
            if (null !== $time_criteria) {
265
                $extraCriteria .= ' AND t.digest_time>' . $time_criteria;
266
            }
267
            break;
268
        case 'sticky':
269
            $order         = 't.topic_id';
270
            $extraCriteria .= ' AND t.topic_sticky=1';
271
            break;
272
        case 'time':
273
        default:
274
            $order = 't.topic_id';
275
            break;
276
    }
277
278
    $newbbConfig = newbbLoadConfig();
279
    if (!empty($newbbConfig['do_rewrite'])) {
280
        require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php');
281
    } elseif (!defined('SEO_MODULE_NAME')) {
282
        define('SEO_MODULE_NAME', 'modules/newbb');
283
    }
284
285
    if (!isset($accessForums)) {
286
        $permissionHandler = Helper::getInstance()->getHandler('Permission');
287
        assert($permissionHandler instanceof PermissionHandler);
288
        if (!$accessForums = $permissionHandler->getForums()) {
289
            return $block;
290
        }
291
    }
292
293
    if (!empty($options[6])) {
294
        $myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
295
        $allowedForums   = array_intersect($myallowedForums, $accessForums);
296
    } else {
297
        $allowedForums = $accessForums;
298
    }
299
    if (empty($allowedForums)) {
300
        return false;
301
    }
302
303
    $forumCriteria   = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')';
304
    $approveCriteria = ' AND t.approved = 1';
305
306
    $query = 'SELECT' . '    t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id, t.topic_time, t.topic_poster, t.poster_name,' . '    f.forum_name' . '    FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' AS t ' . '    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix(
307
            'newbb_forums'
308
        ) . ' AS f ON f.forum_id=t.forum_id' . '    WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC';
309
310
    $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0);
311
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
312
        //xoops_error($GLOBALS['xoopsDB']->error());
313
        return $block;
314
    }
315
    $block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view;
316
    $rows               = [];
317
    $author             = [];
318
    $types              = [];
319
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
320
        $rows[]                       = $row;
321
        $author[$row['topic_poster']] = 1;
322
        if ($row['type_id'] > 0) {
323
            $types[$row['type_id']] = 1;
324
        }
325
    }
326
    if (count($rows) < 1) {
327
        return $block;
328
    }
329
    require_once \dirname(__DIR__) . '/include/functions.user.php';
330
    $author_name = newbbGetUnameFromIds(array_keys($author), (bool)$newbbConfig['show_realname'], true);
331
    $type_list = null;
332
    if (count($types) > 0) {
333
        $typeHandler = Helper::getInstance()->getHandler('Type');
334
        assert($typeHandler instanceof TypeHandler);
335
        $type_list   = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN'));
336
    }
337
338
    foreach ($rows as $arr) {
339
        // irmtfan remove $topic_page_jump because there is no last post
340
        //$topic_page_jump = '';
341
        $topic                  = [];
342
        $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . '] ';
343
        $topic['forum_id']      = $arr['forum_id'];
344
        $topic['forum_name']    = htmlspecialchars((string)$arr['forum_name'], ENT_QUOTES | ENT_HTML5);
345
        $topic['id']            = $arr['topic_id'];
346
347
        $title = htmlspecialchars((string)$arr['topic_title'], ENT_QUOTES | ENT_HTML5);
348
        if (!empty($options[5])) {
349
            $title = xoops_substr($title, 0, $options[5]);
350
        }
351
        $topic['title']   = $topic['topic_subject'] . $title;
352
        $topic['replies'] = $arr['topic_replies'];
353
        $topic['views']   = $arr['topic_views'];
354
        $topic['time']    = newbbFormatTimestamp((int)$arr['topic_time']);
355
        if (!empty($author_name[$arr['topic_poster']])) {
356
            $topic_poster = $author_name[$arr['topic_poster']];
357
        } else {
358
            $topic_poster = htmlspecialchars((string) ((string)$arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), ENT_QUOTES | ENT_HTML5);
359
        }
360
        $topic['topic_poster'] = $topic_poster;
361
        // irmtfan remove $topic_page_jump because there is no last post
362
        //$topic['topic_page_jump'] = $topic_page_jump;
363
        // START irmtfan remove hardcoded html in URLs - add $seo_topic_url
364
        $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'];
365
        $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id'];
366
367
        if (!empty($newbbConfig['do_rewrite'])) {
368
            $topic['seo_topic_url'] = seo_urls($seo_topic_url);
369
            $topic['seo_forum_url'] = seo_urls($seo_forum_url);
370
        } else {
371
            $topic['seo_topic_url'] = $seo_topic_url;
372
            $topic['seo_forum_url'] = $seo_forum_url;
373
        }
374
        // END irmtfan remove hardcoded html in URLs - add $seo_topic_url
375
        $block['topics'][] = $topic;
376
        unset($topic);
377
    }
378
    // START irmtfan remove hardcoded html in URLs
379
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME;
380
    $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
381
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php';
382
    $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
383
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php';
384
    $block['seo_top_allposts']  = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
385
    // END irmtfan remove hardcoded html in URLs
386
    $block['indexNav'] = (int)$options[4];
387
388
    return $block;
389
}
390
391
// options[0] - Citeria valid: title(by default), text
392
// options[1] - NumberToDisplay: any positive integer
393
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
394
// options[3] - DisplayMode: 0-full view;1-compact view;2-lite view; Only valid for "time"
395
// options[4] - Display Navigator: 1 (by default), 0 (No)
396
// options[5] - Title/Text Length : 0 - no limit
397
// options[6] - SelectedForumIDs: null for all
398
399
/**
400
 * @param array $options
401
 *
402
 * @return ((mixed|string)[][]|int|mixed)[]
403
 *
404
 * @psalm-return array{disp_mode?: 3|mixed, topics?: non-empty-list<array{forum_id: mixed, forum_name: string, title: mixed|string, post_id: mixed, time: string, topic_poster: mixed|string, post_text?: mixed, seo_url: mixed|string, seo_forum_url: mixed|string}>, seo_top_allforums?: mixed, seo_top_alltopics?: mixed, seo_top_allposts?: mixed, indexNav?: int}
405
 */
406
function b_newbb_post_show(array $options ): array
407
{
408
    global $accessForums;
409
    global $newbbConfig;
410
411
    require_once \dirname(__DIR__) . '/include/functions.time.php';
412
    $myts          = \MyTextSanitizer::getInstance();
413
    $block         = [];
414
    $i             = 0;
0 ignored issues
show
The assignment to $i is dead and can be removed.
Loading history...
415
    $order         = '';
0 ignored issues
show
The assignment to $order is dead and can be removed.
Loading history...
416
    $extraCriteria = '';
417
    $time_criteria = null;
0 ignored issues
show
The assignment to $time_criteria is dead and can be removed.
Loading history...
418
    if (!empty($options[2])) {
419
        $time_criteria = time() - newbbGetSinceTime((int)$options[2]);
420
        $extraCriteria = ' AND p.post_time>' . $time_criteria;
421
    }
422
423
    switch ($options[0]) {
424
        case 'text':
425
            if (!empty($newbbConfig['enable_karma'])) {
426
                $extraCriteria .= ' AND p.post_karma = 0';
427
            }
428
            if (!empty($newbbConfig['allow_require_reply'])) {
429
                $extraCriteria .= ' AND p.require_reply = 0';
430
            }
431
        // no break
432
        default:
433
            $order = 'p.post_id';
434
            break;
435
    }
436
437
    if (!isset($accessForums)) {
438
        $permissionHandler = Helper::getInstance()->getHandler('Permission');
439
        assert($permissionHandler instanceof PermissionHandler);
440
        if (!$accessForums = $permissionHandler->getForums()) {
441
            return $block;
442
        }
443
    }
444
445
    $newbbConfig = newbbLoadConfig();
446
    if (!empty($newbbConfig['do_rewrite'])) {
447
        require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php');
448
    } elseif (!defined('SEO_MODULE_NAME')) {
449
        define('SEO_MODULE_NAME', 'modules/newbb');
450
    }
451
452
    if (!empty($options[6])) {
453
        $myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
454
        $allowedForums   = array_intersect($myallowedForums, $accessForums);
455
    } else {
456
        $allowedForums = $accessForums;
457
    }
458
    if (empty($allowedForums)) {
459
        return $block;
460
    }
461
462
    $forumCriteria   = ' AND p.forum_id IN (' . implode(',', $allowedForums) . ')';
463
    $approveCriteria = ' AND p.approved = 1';
464
465
    $query = 'SELECT';
466
    $query .= '    p.post_id, p.subject, p.post_time, p.icon, p.uid, p.poster_name,';
467
    if ('text' === $options[0]) {
468
        $query .= '    pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr, pt.post_text,';
469
    }
470
    $query .= '    f.forum_id, f.forum_name' . '    FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' AS p ' . '    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' AS f ON f.forum_id=p.forum_id';
471
    if ('text' === $options[0]) {
472
        $query .= '    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_posts_text') . ' AS pt ON pt.post_id=p.post_id';
473
    }
474
    $query .= '    WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC';
475
476
    $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0);
477
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
478
        //xoops_error($GLOBALS['xoopsDB']->error());
479
        return $block;
480
    }
481
482
    $block['disp_mode'] = ('text' === $options[0]) ? 3 : $options[3]; // 0 - full view; 1 - compact view; 2 - lite view;
483
    $rows               = [];
484
    $author             = [];
485
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
486
        $rows[]              = $row;
487
        $author[$row['uid']] = 1;
488
    }
489
    if (count($rows) < 1) {
490
        return $block;
491
    }
492
    require_once \dirname(__DIR__) . '/include/functions.user.php';
493
    $author_name = newbbGetUnameFromIds(array_keys($author), (bool)$newbbConfig['show_realname'], true);
494
495
    foreach ($rows as $arr) {
496
        //if ($arr['icon'] && is_file($GLOBALS['xoops']->path('images/subject/' . $arr['icon']))) {
497
        if (!empty($arr['icon'])) {
498
            $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars((string)$arr['icon'], ENT_QUOTES | ENT_HTML5) . '" alt="" >';
0 ignored issues
show
The assignment to $last_post_icon is dead and can be removed.
Loading history...
499
        } else {
500
            $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/icon1.gif" alt="" >';
501
        }
502
        //$topic['jump_post'] = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=" . $arr['post_id'] ."#forumpost" . $arr['post_id'] . "'>" . $last_post_icon . '</a>';
503
        $topic               = [];
504
        $topic['forum_id']   = $arr['forum_id'];
505
        $topic['forum_name'] = htmlspecialchars((string)$arr['forum_name'], ENT_QUOTES | ENT_HTML5);
506
        //$topic['id'] = $arr['topic_id'];
507
508
        $title = htmlspecialchars((string)$arr['subject'], ENT_QUOTES | ENT_HTML5);
509
        if ('text' !== $options[0] && !empty($options[5])) {
510
            $title = xoops_substr($title, 0, $options[5]);
511
        }
512
        $topic['title']   = $title;
513
        $topic['post_id'] = $arr['post_id'];
514
        $topic['time']    = newbbFormatTimestamp((int)$arr['post_time']);
515
        if (!empty($author_name[$arr['uid']])) {
516
            $topic_poster = $author_name[$arr['uid']];
517
        } else {
518
            $topic_poster = htmlspecialchars((string) ((string)$arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), ENT_QUOTES | ENT_HTML5);
519
        }
520
        $topic['topic_poster'] = $topic_poster;
521
522
        if ('text' === $options[0]) {
523
            $post_text = $myts->displayTarea($arr['post_text'], $arr['dohtml'], $arr['dosmiley'], $arr['doxcode'], 1, $arr['dobr']);
524
            if (!empty($options[5])) {
525
                $post_text = xoops_substr(strip_tags((string) $post_text), 0, $options[5]);
526
            }
527
            $topic['post_text'] = $post_text;
528
        }
529
        // START irmtfan remove hardcoded html in URLs
530
        //$seo_url       = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id'];
531
        //BigKev73 > Change to support jumping directly to that post, vs just the page that the topic is on
532
        $seo_url       = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id'] . '#forumpost' . $topic['post_id'];
533
        $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id'];
534
        // END irmtfan remove hardcoded html in URLs
535
        if (!empty($newbbConfig['do_rewrite'])) {
536
            $topic['seo_url']       = seo_urls($seo_url);
537
            $topic['seo_forum_url'] = seo_urls($seo_forum_url);
538
        } else {
539
            $topic['seo_url']       = $seo_url;
540
            $topic['seo_forum_url'] = $seo_forum_url;
541
        }
542
543
        $block['topics'][] = $topic;
544
        unset($topic);
545
    }
546
    // START irmtfan remove hardcoded html in URLs
547
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME;
548
    $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
549
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php';
550
    $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
551
    $seo_top_allforums          = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php';
552
    $block['seo_top_allposts']  = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums;
553
    // END irmtfan remove hardcoded html in URLs
554
555
    $block['indexNav'] = (int)$options[4];
556
557
    return $block;
558
}
559
560
// options[0] - Citeria valid: post(by default), topic, digest, sticky
561
// options[1] - NumberToDisplay: any positive integer
562
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
563
// options[3] - DisplayMode: 0-full view;1-compact view;
564
// options[4] - Display Navigator: 1 (by default), 0 (No)
565
// options[5] - Title Length : 0 - no limit
566
// options[6] - SelectedForumIDs: null for all
567
568
/**
569
 * @param array $options
570
 *
571
 * @return ((mixed|string)[][]|int|mixed)[]|false
572
 *
573
 * @psalm-return array{authors?: array<array{count: mixed, name?: string}>, disp_mode?: mixed, indexNav?: int}|false
574
 */
575
function b_newbb_author_show(array $options )
576
{
577
    global $accessForums;
578
    global $newbbConfig;
579
    $myts  = \MyTextSanitizer::getInstance();
0 ignored issues
show
The assignment to $myts is dead and can be removed.
Loading history...
580
    $block = [];
581
    //    $i              = 0;
582
    $type          = 'topic';
583
    $order         = 'count';
584
    $extraCriteria = '';
585
    $time_criteria = null;
586
    if (!empty($options[2])) {
587
        require_once \dirname(__DIR__) . '/include/functions.time.php';
588
        $time_criteria = time() - newbbGetSinceTime($options[2]);
589
        $extraCriteria = ' AND topic_time > ' . $time_criteria;
590
    }
591
    switch ($options[0]) {
592
        case 'topic':
593
            break;
594
        case 'digest':
595
            $extraCriteria = ' AND topic_digest = 1';
596
            if (null !== $time_criteria) {
597
                $extraCriteria .= ' AND digest_time > ' . $time_criteria;
598
            }
599
            break;
600
        case 'sticky':
601
            $extraCriteria .= ' AND topic_sticky = 1';
602
            break;
603
        case 'post':
604
        default:
605
            $type = 'post';
606
            if (null !== $time_criteria) {
607
                $extraCriteria = ' AND post_time > ' . $time_criteria;
608
            }
609
            break;
610
    }
611
612
    if (!isset($accessForums)) {
613
        $permissionHandler = Helper::getInstance()->getHandler('Permission');
614
        assert($permissionHandler instanceof PermissionHandler);
615
        if (!$accessForums = $permissionHandler->getForums()) {
616
            return $block;
617
        }
618
    }
619
620
    if (!empty($options[5])) {
621
        $myallowedForums = array_filter(array_slice($options, 5), '\b_newbb_array_filter'); // get allowed forums
622
        $allowedForums   = array_intersect($myallowedForums, $accessForums);
623
    } else {
624
        $allowedForums = $accessForums;
625
    }
626
    if (empty($allowedForums)) {
627
        return false;
628
    }
629
630
    $forumCriteria   = ' AND forum_id IN (' . implode(',', $allowedForums) . ')';
631
    $approveCriteria = ' AND approved = 1';
632
    if ('topic' === $type) {
633
        $query           = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count
634
                    FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . '
635
                    WHERE topic_poster>0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC';
636
    } else {
637
        $query           = 'SELECT DISTINCT uid AS author, COUNT(*) AS count
638
                    FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . '
639
                    WHERE uid > 0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC';
640
    }
641
642
    $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0);
643
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
644
        //xoops_error($GLOBALS['xoopsDB']->error());
645
        return $block;
646
    }
647
    $author = [];
648
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
649
        $author[$row['author']]['count'] = $row['count'];
650
    }
651
    if (count($author) < 1) {
652
        return $block;
653
    }
654
    require_once \dirname(__DIR__) . '/include/functions.user.php';
655
    $author_name = newbbGetUnameFromIds(array_keys($author), (bool)(isset($newbbConfig['show_realname'])??0));
656
    foreach (array_keys($author) as $uid) {
657
        $author[$uid]['name'] = htmlspecialchars((string)$author_name[$uid], ENT_QUOTES | ENT_HTML5);
658
    }
659
    $block['authors']   = &$author;
660
    $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view;
661
    $block['indexNav']  = (int)$options[4];
662
663
    return $block;
664
}
665
666
/**
667
 * @param array $options
668
 * @return string
669
 */
670
function b_newbb_edit(array $options ): string
671
{
672
    require_once \dirname(__DIR__) . '/include/functions.forum.php';
673
674
    $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>";
675
    $form .= "<option value='time'";
676
    if ('time' === $options[0]) {
677
        $form .= " selected='selected' ";
678
    }
679
    $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>';
680
    $form .= '</select>';
681
    $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >";
682
    $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >";
683
    $form .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;<small>' . _MB_NEWBB_TIME_DESC . '</small>';
684
    $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'";
685
    if (0 == $options[3]) {
686
        $form .= ' checked';
687
    }
688
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'";
689
    if (1 == $options[3]) {
690
        $form .= ' checked';
691
    }
692
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'";
693
    if (2 == $options[3]) {
694
        $form .= ' checked';
695
    }
696
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_LITE;
697
698
    $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"';
699
    if (1 == $options[4]) {
700
        $form .= ' checked';
701
    }
702
    $form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"';
703
    if (0 == $options[4]) {
704
        $form .= ' checked';
705
    }
706
    $form .= ' >' . _NO;
707
708
    $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' >";
709
710
    $form .= '<br><br>' . _MB_NEWBB_FORUMLIST;
711
712
    $optionsForum = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
713
    $isAll        = (0 === count($optionsForum) || empty($optionsForum[0]));
714
    $form         .= '<br>&nbsp;&nbsp;<select name="options[]" multiple="multiple">';
715
    $form         .= '<option value="0" ';
716
    if ($isAll) {
717
        $form .= ' selected';
718
    }
719
    $form .= '>' . _ALL . '</option>';
720
    $form .= newbbForumSelectBox($optionsForum);
721
    $form .= '</select><br>';
722
723
    return $form;
724
}
725
726
/**
727
 * @param array $options
728
 * @return string
729
 */
730
function b_newbb_topic_edit(array $options ): string
731
{
732
    require_once \dirname(__DIR__) . '/include/functions.forum.php';
733
    $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>";
734
    $form .= "<option value='time'";
735
    if ('time' === $options[0]) {
736
        $form .= " selected='selected' ";
737
    }
738
    $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>';
739
    $form .= "<option value='views'";
740
    if ('views' === $options[0]) {
741
        $form .= " selected='selected' ";
742
    }
743
    $form .= '>' . _MB_NEWBB_CRITERIA_VIEWS . '</option>';
744
    $form .= "<option value='replies'";
745
    if ('replies' === $options[0]) {
746
        $form .= " selected='selected' ";
747
    }
748
    $form .= '>' . _MB_NEWBB_CRITERIA_REPLIES . '</option>';
749
    $form .= "<option value='digest'";
750
    if ('digest' === $options[0]) {
751
        $form .= " selected='selected' ";
752
    }
753
    $form .= '>' . _MB_NEWBB_CRITERIA_DIGEST . '</option>';
754
    $form .= "<option value='sticky'";
755
    if ('sticky' === $options[0]) {
756
        $form .= " selected='selected' ";
757
    }
758
    $form .= '>' . _MB_NEWBB_CRITERIA_STICKY . '</option>';
759
    $form .= '</select>';
760
    $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >";
761
    $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >";
762
    $form .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;<small>' . _MB_NEWBB_TIME_DESC . '</small>';
763
    $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'";
764
    if (0 == $options[3]) {
765
        $form .= ' checked';
766
    }
767
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'";
768
    if (1 == $options[3]) {
769
        $form .= ' checked';
770
    }
771
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'";
772
    if (2 == $options[3]) {
773
        $form .= ' checked';
774
    }
775
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_LITE;
776
777
    $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"';
778
    if (1 == $options[4]) {
779
        $form .= ' checked';
780
    }
781
    $form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"';
782
    if (0 == $options[4]) {
783
        $form .= ' checked';
784
    }
785
    $form .= ' >' . _NO;
786
787
    $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' >";
788
789
    $form .= '<br><br>' . _MB_NEWBB_FORUMLIST;
790
791
    $optionsForum = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
792
793
    $isAll = (0 === count($optionsForum) || empty($optionsForum[0]));
794
    $form  .= '<br>&nbsp;&nbsp;<select name="options[]" multiple="multiple">';
795
    $form  .= '<option value="0" ';
796
    if ($isAll) {
797
        $form .= ' selected="selected"';
798
    }
799
    $form .= '>' . _ALL . '</option>';
800
    $form .= newbbForumSelectBox($optionsForum);
801
    $form .= '</select><br>';
802
803
    return $form;
804
}
805
806
/**
807
 * @param array $options
808
 * @return string
809
 */
810
function b_newbb_post_edit(array $options ): string
811
{
812
    require_once \dirname(__DIR__) . '/include/functions.forum.php';
813
    $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>";
814
    $form .= "<option value='title'";
815
    if ('title' === $options[0]) {
816
        $form .= " selected='selected' ";
817
    }
818
    $form .= '>' . _MB_NEWBB_CRITERIA_TITLE . '</option>';
819
    $form .= "<option value='text'";
820
    if ('text' === $options[0]) {
821
        $form .= " selected='selected' ";
822
    }
823
    $form .= '>' . _MB_NEWBB_CRITERIA_TEXT . '</option>';
824
    $form .= '</select>';
825
    $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >";
826
    $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >";
827
    $form .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;<small>' . _MB_NEWBB_TIME_DESC . '</small>';
828
    $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'";
829
    if (0 == $options[3]) {
830
        $form .= ' checked';
831
    }
832
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'";
833
    if (1 == $options[3]) {
834
        $form .= ' checked';
835
    }
836
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'";
837
    if (2 == $options[3]) {
838
        $form .= ' checked';
839
    }
840
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_LITE;
841
842
    $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"';
843
    if (1 == $options[4]) {
844
        $form .= ' checked';
845
    }
846
    $form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"';
847
    if (0 == $options[4]) {
848
        $form .= ' checked';
849
    }
850
    $form .= ' >' . _NO;
851
852
    $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' >";
853
854
    $form .= '<br><br>' . _MB_NEWBB_FORUMLIST;
855
856
    $optionsForum = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
857
    $isAll        = (0 === count($optionsForum) || empty($optionsForum[0]));
858
    $form         .= '<br>&nbsp;&nbsp;<select name="options[]" multiple="multiple">';
859
    $form         .= '<option value="0" ';
860
    if ($isAll) {
861
        $form .= ' selected="selected"';
862
    }
863
    $form .= '>' . _ALL . '</option>';
864
    $form .= newbbForumSelectBox($optionsForum);
865
    $form .= '</select><br>';
866
867
    return $form;
868
}
869
870
/**
871
 * @param array $options
872
 * @return string
873
 */
874
function b_newbb_author_edit(array $options ): string
875
{
876
    require_once \dirname(__DIR__) . '/include/functions.forum.php';
877
    $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>";
878
    $form .= "<option value='post'";
879
    if ('post' === $options[0]) {
880
        $form .= " selected='selected' ";
881
    }
882
    $form .= '>' . _MB_NEWBB_CRITERIA_POST . '</option>';
883
    $form .= "<option value='topic'";
884
    if ('topic' === $options[0]) {
885
        $form .= " selected='selected' ";
886
    }
887
    $form .= '>' . _MB_NEWBB_CRITERIA_TOPIC . '</option>';
888
    $form .= "<option value='digest'";
889
    if ('digest' === $options[0]) {
890
        $form .= " selected='selected' ";
891
    }
892
    $form .= '>' . _MB_NEWBB_CRITERIA_DIGESTS . '</option>';
893
    $form .= "<option value='sticky'";
894
    if ('sticky' === $options[0]) {
895
        $form .= " selected='selected' ";
896
    }
897
    $form .= '>' . _MB_NEWBB_CRITERIA_STICKYS . '</option>';
898
    $form .= '</select>';
899
    $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >";
900
    $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >";
901
    $form .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;<small>' . _MB_NEWBB_TIME_DESC . '</small>';
902
    $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'";
903
    if (0 == $options[3]) {
904
        $form .= ' checked';
905
    }
906
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='1'";
907
    if (1 == $options[3]) {
908
        $form .= ' checked';
909
    }
910
    $form .= ' >&nbsp;' . _MB_NEWBB_DISPLAYMODE_LITE;
911
912
    $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"';
913
    if (1 == $options[4]) {
914
        $form .= ' checked';
915
    }
916
    $form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"';
917
    if (0 == $options[4]) {
918
        $form .= ' checked';
919
    }
920
    $form .= ' >' . _NO;
921
922
    $form .= '<br><br>' . _MB_NEWBB_FORUMLIST;
923
924
    $optionsForum = array_filter(array_slice($options, 5), '\b_newbb_array_filter'); // get allowed forums
925
    $isAll        = (0 === count($optionsForum) || empty($optionsForum[0]));
926
    $form         .= '<br>&nbsp;&nbsp;<select name="options[]" multiple="multiple">';
927
    $form         .= '<option value="0" ';
928
    if ($isAll) {
929
        $form .= ' selected="selected"';
930
    }
931
    $form .= '>' . _ALL . '</option>';
932
    $form .= newbbForumSelectBox($optionsForum);
933
    $form .= '</select><br>';
934
935
    return $form;
936
}
937
938
/**
939
 * @param mixed[]|string $options
940
 * @return bool
941
 */
942
function b_newbb_custom($options ): bool
943
{
944
    // if no newbb module block set, we have to include the language file
945
    xoops_loadLanguage('blocks', 'newbb');
946
947
    $options = explode('|', $options);
0 ignored issues
show
It seems like $options can also be of type array<mixed,mixed>; however, parameter $string of explode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

947
    $options = explode('|', /** @scrutinizer ignore-type */ $options);
Loading history...
948
    $block   = b_newbb_show($options);
949
    if ((is_countable($block['topics']) ? count($block['topics']) : 0) < 1) {
950
        return false;
951
    }
952
953
    $tpl = new \XoopsTpl();
954
    $tpl->assign('block', $block);
955
    $tpl->display('db:newbb_block.tpl');
956
    return true;
957
}
958
959
/**
960
 * @param mixed[]|string $options
961
 * @return bool
962
 */
963
function b_newbb_custom_topic($options ): bool
964
{
965
    $helper = Helper::getInstance();
966
    // if no newbb module block set, we have to include the language file
967
    $helper->loadLanguage('blocks');
968
969
    $options = explode('|', $options);
0 ignored issues
show
It seems like $options can also be of type array<mixed,mixed>; however, parameter $string of explode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

969
    $options = explode('|', /** @scrutinizer ignore-type */ $options);
Loading history...
970
    $block   = b_newbb_topic_show($options);
971
    if ((is_countable($block['topics']) ? count($block['topics']) : 0) < 1) {
972
        return false;
973
    }
974
975
    $tpl = new \XoopsTpl();
976
    $tpl->assign('block', $block);
977
    $tpl->display('db:newbb_block_topic.tpl');
978
    return true;
979
}
980
981
/**
982
 * @param mixed[]|string $options
983
 * @return bool
984
 */
985
function b_newbb_custom_post($options ): bool
986
{
987
    $helper = Helper::getInstance();
988
    // if no newbb module block set, we have to include the language file
989
    $helper->loadLanguage('blocks');
990
991
    $options = explode('|', $options);
0 ignored issues
show
It seems like $options can also be of type array<mixed,mixed>; however, parameter $string of explode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

991
    $options = explode('|', /** @scrutinizer ignore-type */ $options);
Loading history...
992
    $block   = b_newbb_post_show($options);
993
    if ((is_countable($block['topics']) ? count($block['topics']) : 0) < 1) {
994
        return false;
995
    }
996
997
    $tpl = new \XoopsTpl();
998
    $tpl->assign('block', $block);
999
    $tpl->display('db:newbb_block_post.tpl');
1000
    return true;
1001
}
1002
1003
/**
1004
 * @param mixed[]|string $options
1005
 * @return bool
1006
 */
1007
function b_newbb_custom_author($options ): bool
1008
{
1009
    $helper = Helper::getInstance();
1010
    // if no newbb module block set, we have to include the language file
1011
    $helper->loadLanguage('blocks');
1012
1013
    $options = explode('|', $options);
0 ignored issues
show
It seems like $options can also be of type array<mixed,mixed>; however, parameter $string of explode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1013
    $options = explode('|', /** @scrutinizer ignore-type */ $options);
Loading history...
1014
    $block   = b_newbb_author_show($options);
1015
    if ((is_countable($block['authors']) ? count($block['authors']) : 0) < 1) {
1016
        return false;
1017
    }
1018
1019
    $tpl = new \XoopsTpl();
1020
    $tpl->assign('block', $block);
1021
    $tpl->display('db:newbb_block_author.tpl');
1022
    return true;
1023
}
1024
1025
// irmtfan add local stylesheet and js footer.php
1026
require_once $GLOBALS['xoops']->path('modules/newbb/footer.php');
1027