Test Failed
Pull Request — master (#60)
by
unknown
03:30
created

index.php (72 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * NewBB 5.0x,  the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (https://xoops.org)
6
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
7
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
8
 * @since          4.00
9
 * @package        module::newbb
10
 */
11
12
use Xmf\Request;
13
14
include_once __DIR__ . '/header.php';
15
16
/* deal with marks */
17
if (Request::getInt('mark_read', 0)) {
18 View Code Duplication
    if (1 === Request::getInt('mark_read', 0)) { // marked as read
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
        $markvalue  = 1;
20
        $markresult = _MD_NEWBB_MARK_READ;
21
    } else { // marked as unread
22
        $markvalue  = 0;
23
        $markresult = _MD_NEWBB_MARK_UNREAD;
24
    }
25
    include_once __DIR__ . '/include/functions.read.php';
26
    newbbSetReadForum($markvalue);
27
    $url = XOOPS_URL . '/modules/newbb/index.php';
28
    redirect_header($url, 2, _MD_NEWBB_ALL_FORUM_MARKED . ' ' . $markresult);
29
}
30
31
$viewcat = Request::getInt('cat', 0, 'GET');//TODO mb check if this is GET or POST?
32
///** @var \NewbbCategoryHandler $categoryHandler */
33
//$categoryHandler = xoops_getModuleHandler('category', 'newbb');
34
35
$categories = [];
36
if (!$viewcat) {
37
    $categories        = $categoryHandler->getByPermission('access', null, false);
38
    $forum_index_title = '';
0 ignored issues
show
$forum_index_title does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
39
    $xoops_pagetitle   = $xoopsModule->getVar('name');
0 ignored issues
show
$xoops_pagetitle does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
40
} else {
41
    $categoryObject = $categoryHandler->get($viewcat);
42
    if ($categoryHandler->getPermission($categoryObject)) {
43
        $categories[$viewcat] = $categoryObject->getValues();
44
    }
45
    $forum_index_title = sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES));
0 ignored issues
show
$forum_index_title does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
46
    $xoops_pagetitle   = $categoryObject->getVar('cat_title') . ' [' . $xoopsModule->getVar('name') . ']';
0 ignored issues
show
$xoops_pagetitle does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
47
}
48
49
if (0 === count($categories)) {
50
    redirect_header(XOOPS_URL, 2, _MD_NEWBB_NORIGHTTOACCESS);
51
}
52
53
$xoopsOption['template_main']   = 'newbb_index.tpl';
54
$xoopsOption['xoops_pagetitle'] = $xoops_pagetitle;
0 ignored issues
show
$xoops_pagetitle does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
55
// irmtfan remove and move to footer.php
56
//$xoopsOption['xoops_module_header'] = $xoops_module_header;
57
// irmtfan include header.php after defining $xoopsOption['template_main']
58
include_once $GLOBALS['xoops']->path('header.php');
59
include_once __DIR__ . '/include/functions.render.php';
60
/* rss feed */
61
// irmtfan new method
62 View Code Duplication
if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
    $xoopsTpl->assign('xoops_module_header', '
64
    <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/rss.php" />
65
    ' . @$xoopsTpl->get_template_vars('xoops_module_header'));
66
}
67
$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
0 ignored issues
show
$xoops_pagetitle does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
68
// irmtfan remove and move to footer.php
69
//$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
70
$xoopsTpl->assign('forum_index_title', $forum_index_title);
0 ignored issues
show
$forum_index_title does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
71
//if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
72
if (!empty($GLOBALS['xoopsModuleConfig']['wol_enabled'])) {
73
//    /** @var \NewbbOnlineHandler $onlineHandler */
74
//    $onlineHandler = xoops_getModuleHandler('online', 'newbb');
75
    $onlineHandler->init();
76
    $xoopsTpl->assign('online', $onlineHandler->showOnline());
77
}
78
///** @var \NewbbForumHandler $forumHandler */
79
//$forumHandler = xoops_getModuleHandler('forum', 'newbb');
80
///** @var \NewbbPostHandler $postHandler */
81
//$postHandler = xoops_getModuleHandler('post', 'newbb');
82
83
/* Allowed forums */
84
$forums_allowed = $forumHandler->getIdsByPermission();
0 ignored issues
show
$forums_allowed does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
85
86
/* fetch top forums */
87
$forums_top = [];
0 ignored issues
show
$forums_top does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
88
89
if (!empty($forums_allowed)) {
0 ignored issues
show
$forums_allowed does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
90
    $crit_top = new CriteriaCompo(new Criteria('parent_forum', 0));
0 ignored issues
show
$crit_top does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
91
    $crit_top->add(new Criteria('cat_id', '(' . implode(', ', array_keys($categories)) . ')', 'IN'));
0 ignored issues
show
$crit_top does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
92
    $crit_top->add(new Criteria('forum_id', '(' . implode(', ', $forums_allowed) . ')', 'IN'));
0 ignored issues
show
$crit_top does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
93
    $forums_top = $forumHandler->getIds($crit_top);
0 ignored issues
show
$forums_top does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
94
}
95
96
/* fetch subforums if required to display */
97
if ('hidden' === $GLOBALS['xoopsModuleConfig']['subforum_display'] || 0 === count($forums_top)) {
0 ignored issues
show
$forums_top does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
98
    $forums_sub = [];
0 ignored issues
show
$forums_sub does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
99
} else {
100
    $crit_sub = new CriteriaCompo(new Criteria('parent_forum', '(' . implode(', ', $forums_top) . ')', 'IN'));
0 ignored issues
show
$crit_sub does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
101
    $crit_sub->add(new Criteria('forum_id', '(' . implode(', ', $forums_allowed) . ')', 'IN'));
0 ignored issues
show
$crit_sub does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
102
    $forums_sub = $forumHandler->getIds($crit_sub);
0 ignored issues
show
$forums_sub does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
103
}
104
105
/* Fetch forum data */
106
$forums_available = array_merge($forums_top, $forums_sub);
0 ignored issues
show
$forums_available does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
107
$forums_array     = [];
0 ignored issues
show
$forums_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
108
$newtopics        = 0;
109
$deletetopics     = 0;
110
$newposts         = 0;
111
$deleteposts      = 0;
112
if (0 !== count($forums_available)) {
0 ignored issues
show
$forums_available does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
113
    $crit_forum = new Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN');
0 ignored issues
show
$crit_forum does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
114
    $crit_forum->setSort('cat_id ASC, parent_forum ASC, forum_order');
0 ignored issues
show
$crit_forum does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
115
    $crit_forum->setOrder('ASC');
0 ignored issues
show
$crit_forum does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
116
    $forums       = $forumHandler->getAll($crit_forum, null, false);
0 ignored issues
show
$crit_forum does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
117
    $newtopics    = $forumHandler->getTopicCount($forums, 0, 'pending');
118
    $deletetopics = $forumHandler->getTopicCount($forums, 0, 'deleted');
119
    $forums_array = $forumHandler->display($forums, $GLOBALS['xoopsModuleConfig']['length_title_index'], $GLOBALS['xoopsModuleConfig']['count_subforum']);
0 ignored issues
show
$forums_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
120
    $crit         = new CriteriaCompo(new Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN'));
0 ignored issues
show
$forums_available does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
121
    $crit->add(new Criteria('approved', '-1'));
122
    $deleteposts = $postHandler->getCount($crit);
123
    $crit        = new CriteriaCompo(new Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN'));
0 ignored issues
show
$forums_available does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
124
    $crit->add(new Criteria('approved', '0'));
125
    $newposts = $postHandler->getCount($crit);
126
}
127
128
if ($newtopics > 0) {
129
    $xoopsTpl->assign('wait_new_topic', $newtopics);
130
}
131
if ($deletetopics > 0) {
132
    $xoopsTpl->assign('delete_topic', $deletetopics);
133
}
134
if ($newposts > 0) {
135
    $xoopsTpl->assign('wait_new_post', $newposts);
136
}
137
if ($deleteposts > 0) {
138
    $xoopsTpl->assign('delete_post', $deleteposts);
139
}
140
141
///** @var \NewbbReportHandler $reportHandler */
142
//$reportHandler = xoops_getModuleHandler('report', 'newbb');
143
$reported      = $reportHandler->getCount(new Criteria('report_result', 0));
144
$xoopsTpl->assign('reported_count', $reported);
145
if ($reported > 0) {
146
    $xoopsTpl->assign('report_post', sprintf(_MD_NEWBB_SEEWAITREPORT, $reported));
147
}
148
149
if (count($forums_array) > 0) {
0 ignored issues
show
$forums_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
150
    foreach ($forums_array[0] as $parent => $forum) {
0 ignored issues
show
$forums_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
151
        if (isset($forums_array[$forum['forum_id']])) {
0 ignored issues
show
$forums_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
152
            $forum['subforum'] = $forums_array[$forum['forum_id']];
0 ignored issues
show
$forums_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
153
        }
154
        $forumsByCat[$forum['forum_cid']][] = $forum;
155
    }
156
}
157
158
$category_array = [];
0 ignored issues
show
$category_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
159
$toggles        = newbbGetCookie('G', true);
160
$iconHandler    = newbbGetIconHandler();
161
$category_icon  = [
0 ignored issues
show
$category_icon does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
162
    'expand'   => $iconHandler->getImageSource('minus'),
163
    'collapse' => $iconHandler->getImageSource('plus')
164
];
165
166
foreach (array_keys($categories) as $id) {
167
    $forums = [];
168
    $onecat = $categories[$id];
169
170
    $cat_element_id = 'cat_' . $onecat['cat_id'];
0 ignored issues
show
$cat_element_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
171
    $expand         = (count($toggles) > 0) ? (in_array($cat_element_id, $toggles) ? false : true) : true;
0 ignored issues
show
$cat_element_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
172
    // START irmtfan to improve newbbDisplayImage
173
    if ($expand) {
174
        $cat_display      = 'block';        //irmtfan move semicolon
0 ignored issues
show
$cat_display does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
175
        $cat_icon_display = 'minus';
0 ignored issues
show
$cat_icon_display does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
176
        $cat_alt          = _MD_NEWBB_HIDE;
0 ignored issues
show
$cat_alt does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
177
    } else {
178
        $cat_display      = 'none';        //irmtfan move semicolon
0 ignored issues
show
$cat_display does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
179
        $cat_icon_display = 'plus';
0 ignored issues
show
$cat_icon_display does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
180
        $cat_alt          = _MD_NEWBB_SEE;
0 ignored issues
show
$cat_alt does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
181
    }
182
    $cat_displayImage = newbbDisplayImage($cat_icon_display, $cat_alt);
0 ignored issues
show
$cat_displayImage does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
183
184
    if (isset($forumsByCat[$onecat['cat_id']])) {
185
        $forums = $forumsByCat[$onecat['cat_id']];
186
    }
187
188
    $cat_sponsor = [];
0 ignored issues
show
$cat_sponsor does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
189
    @list($url, $title) = array_map('trim', preg_split('/ /', $onecat['cat_url'], 2));
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
190
    if ('' === $title) {
191
        $title = $url;
192
    }
193
    $title = $myts->htmlSpecialChars($title);
194
    if ('' !== $url) {
195
        $cat_sponsor = ['title' => $title, 'link' => formatURL($url)];
0 ignored issues
show
$cat_sponsor does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
196
    }
197
    //$cat_image = $onecat['cat_image'];
198
    $cat_image = '';
0 ignored issues
show
$cat_image does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
199
    $cat_image = $onecat['cat_image'];
0 ignored issues
show
$cat_image does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
200
    if ('' !== $cat_image && 'blank.gif' !== $cat_image && $cat_image) {
0 ignored issues
show
$cat_image does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
201
        $cat_image = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/assets/images/category/' . $cat_image;
0 ignored issues
show
$cat_image does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
202
    }
203
    $category_array[] = [
0 ignored issues
show
$category_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
204
        'cat_id'           => $onecat['cat_id'],
205
        'cat_title'        => $myts->displayTarea($onecat['cat_title'], 1),
206
        'cat_image'        => $cat_image,
0 ignored issues
show
$cat_image does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
207
        'cat_sponsor'      => $cat_sponsor,
0 ignored issues
show
$cat_sponsor does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
208
        'cat_description'  => $myts->displayTarea($onecat['cat_description'], 1),
209
        'cat_element_id'   => $cat_element_id,
0 ignored issues
show
$cat_element_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
210
        'cat_display'      => $cat_display,
0 ignored issues
show
$cat_display does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
211
        'cat_displayImage' => $cat_displayImage,
0 ignored issues
show
$cat_displayImage does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
212
        'forums'           => $forums
213
    ];
214
}
215
216
unset($categories, $forums_array, $forumsByCat);
0 ignored issues
show
$forums_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
217
$xoopsTpl->assign_by_ref('category_icon', $category_icon);
0 ignored issues
show
$category_icon does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
218
$xoopsTpl->assign_by_ref('categories', $category_array);
0 ignored issues
show
$category_array does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
219
$xoopsTpl->assign('notifyicon', $category_icon);
0 ignored issues
show
$category_icon does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
220
221
$xoopsTpl->assign([
222
                      'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
223
                      'index_desc'  => _MD_NEWBB_TOSTART
224
                  ]);
225
226
/* display user stats */
227
if (!empty($GLOBALS['xoopsModuleConfig']['statistik_enabled'])) {
228
    $userstats = [];
229
    if (is_object($GLOBALS['xoopsUser'])) {
230
//        /** @var \NewbbUserstatsHandler $userstatsHandler */
231
//        $userstatsHandler         = xoops_getModuleHandler('userstats');
232
        $userstats_row            = $userstatsHandler->getStats($GLOBALS['xoopsUser']->getVar('uid'));
0 ignored issues
show
$userstats_row does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
233
        $userstats['topics']      = sprintf(_MD_NEWBB_USER_TOPICS, (int)(@$userstats_row['user_topics']));
0 ignored issues
show
$userstats_row does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
234
        $userstats['posts']       = sprintf(_MD_NEWBB_USER_POSTS, (int)(@$userstats_row['user_posts']));
0 ignored issues
show
$userstats_row does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
235
        $userstats['digests']     = sprintf(_MD_NEWBB_USER_DIGESTS, (int)(@$userstats_row['user_digests']));
0 ignored issues
show
$userstats_row does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
236
        $userstats['currenttime'] = sprintf(_MD_NEWBB_TIMENOW, formatTimestamp(time(), 's')); // irmtfan should be removed because it is for anon users too
237
        $userstats['lastvisit']   = sprintf(_MD_NEWBB_USER_LASTVISIT, formatTimestamp($last_visit, 's')); // irmtfan should be removed because it is for anon users too
0 ignored issues
show
$last_visit does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
238
        $userstats['lastpost']    = empty($userstats_row['user_lastpost']) ? _MD_NEWBB_USER_NOLASTPOST : sprintf(_MD_NEWBB_USER_LASTPOST, formatTimestamp($userstats_row['user_lastpost'], 's'));
0 ignored issues
show
$userstats_row does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
239
    }
240
    $xoopsTpl->assign_by_ref('userstats', $userstats);
241
    // irmtfan add lastvisit smarty variable for all users
242
    $xoopsTpl->assign('lastvisit', sprintf(_MD_NEWBB_USER_LASTVISIT, formatTimestamp($last_visit, 'l')));
0 ignored issues
show
$last_visit does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
243
    $xoopsTpl->assign('currenttime', sprintf(_MD_NEWBB_TIMENOW, formatTimestamp(time(), 'm')));
244
}
245
246
/* display forum stats */
247
///** @var \NewbbStatsHandler $statsHandler */
248
//$statsHandler = xoops_getModuleHandler('stats', 'newbb');
249
$stats        = $statsHandler->getStats(array_merge([0], $forums_available));
0 ignored issues
show
$forums_available does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
250
$xoopsTpl->assign_by_ref('stats', $stats);
251
$xoopsTpl->assign('subforum_display', $GLOBALS['xoopsModuleConfig']['subforum_display']);
252
$xoopsTpl->assign('mark_read', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?mark_read=1');
253
$xoopsTpl->assign('mark_unread', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?mark_read=2');
254
255
$xoopsTpl->assign('all_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=all');
256
$xoopsTpl->assign('post_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewpost.php?status=all');
257
$xoopsTpl->assign('newpost_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewpost.php?status=new');
258
$xoopsTpl->assign('digest_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=digest');
259
$xoopsTpl->assign('unreplied_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=unreplied');
260
$xoopsTpl->assign('unread_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=unread');
261
$xoopsTpl->assign('menumode', $menumode);
262
$xoopsTpl->assign('menumode_other', $menumode_other);
0 ignored issues
show
$menumode_other does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
263
264
$isAdmin = $GLOBALS['xoopsUserIsAdmin'];
265
$xoopsTpl->assign('viewer_level', $isAdmin ? 2 : is_object($GLOBALS['xoopsUser']));
266
$mode = Request::getInt('mode', 0, 'GET');
267
$xoopsTpl->assign('mode', $mode);
268
269
$xoopsTpl->assign('viewcat', $viewcat);
270
$xoopsTpl->assign('version', $xoopsModule->getVar('version'));
271
272
/* To be removed */
273
if ($isAdmin) {
274
    $xoopsTpl->assign('forum_index_cpanel', ['link' => 'admin/index.php', 'name' => _MD_NEWBB_ADMINCP]);
275
}
276
277
if (1 == $GLOBALS['xoopsModuleConfig']['rss_enable']) {
278
    $xoopsTpl->assign('rss_enable', 1);
279
    $xoopsTpl->assign('rss_button', newbbDisplayImage('rss', 'RSS feed'));
280
}
281
$xoopsTpl->assign([
282
                      'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS),
283
                      'img_forum'     => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS),
284
                      'img_subforum'  => newbbDisplayImage('subforum')
285
                  ]);
286
287
// irmtfan move to footer.php
288
include_once __DIR__ . '/footer.php';
289
include $GLOBALS['xoops']->path('footer.php');
290