This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php declare(strict_types=1); |
||||||
2 | // Author: SMD & Trabis |
||||||
3 | // URL: https://www.xoopsmalaysia.org & https://www.xoops.org |
||||||
4 | // E-Mail: [email protected] & [email protected] |
||||||
5 | |||||||
6 | use Xmf\IPAddress; |
||||||
7 | |||||||
8 | if (!defined('XOOPS_ROOT_PATH')) { |
||||||
9 | exit; |
||||||
10 | } |
||||||
11 | |||||||
12 | /** |
||||||
13 | * @param $options |
||||||
14 | * @return array|bool |
||||||
15 | */ |
||||||
16 | function show_membersstats_block($options) |
||||||
17 | { |
||||||
18 | global $xoopsConfig, $xoopsUser, $xoopsModule, $xoopsDB, $_SERVER; |
||||||
19 | /** @var XoopsOnlineHandler $onlineHandler */ |
||||||
20 | $onlineHandler = xoops_getHandler('online'); |
||||||
21 | // set gc probabillity to 10% for now.. |
||||||
22 | if (mt_rand(1, 100) < 11) { |
||||||
23 | $onlineHandler->gc(300); |
||||||
24 | } |
||||||
25 | if (is_object($xoopsUser)) { |
||||||
26 | $uid = $xoopsUser->getVar('uid'); |
||||||
27 | $uname = $xoopsUser->getVar('uname'); |
||||||
28 | } else { |
||||||
29 | $uid = 0; |
||||||
30 | $uname = ''; |
||||||
31 | } |
||||||
32 | $requestIp = IPAddress::fromRequest()->asReadable(); |
||||||
33 | $requestIp = (false === $requestIp) ? '0.0.0.0' : $requestIp; |
||||||
0 ignored issues
–
show
introduced
by
![]() |
|||||||
34 | if (is_object($xoopsModule)) { |
||||||
35 | $onlineHandler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), $requestIp); |
||||||
36 | } else { |
||||||
37 | $onlineHandler->write($uid, $uname, time(), 0, $requestIp); |
||||||
38 | } |
||||||
39 | $onlines = $onlineHandler->getAll(); |
||||||
40 | if (!empty($onlines)) { |
||||||
41 | $total = count($onlines); |
||||||
42 | $block = []; |
||||||
43 | $guests = 0; |
||||||
44 | $members = ''; |
||||||
45 | for ($i = 0; $i < $total; ++$i) { |
||||||
46 | if ($onlines[$i]['online_uid'] > 0) { |
||||||
47 | $members .= ' <a href="' . XOOPS_URL . '/userinfo.php?uid=' . $onlines[$i]['online_uid'] . '" title="' . $onlines[$i]['online_uname'] . '">' . $onlines[$i]['online_uname'] . '</a>,'; |
||||||
48 | } else { |
||||||
49 | ++$guests; |
||||||
50 | } |
||||||
51 | } |
||||||
52 | $block['online_total'] = sprintf(_ONLINEPHRASE, $total); |
||||||
53 | if (is_object($xoopsModule)) { |
||||||
54 | $mytotal = $onlineHandler->getCount(new \Criteria('online_module', $xoopsModule->getVar('mid'))); |
||||||
55 | $block['online_total'] .= ' (' . sprintf(_ONLINEPHRASEX, $mytotal, $xoopsModule->getVar('name')) . ')'; |
||||||
56 | } |
||||||
57 | // Membership Statistic |
||||||
58 | /** @var \XoopsMemberHandler $memberHandler */ |
||||||
59 | $memberHandler = xoops_getHandler('member'); |
||||||
60 | $today = formatTimestamp(time()); |
||||||
0 ignored issues
–
show
|
|||||||
61 | $level_criteria = new \Criteria('level', 0, '>'); |
||||||
62 | $criteria = new \CriteriaCompo($level_criteria); |
||||||
63 | $criteria24 = new \CriteriaCompo($level_criteria); |
||||||
64 | $criteria48 = new \CriteriaCompo($level_criteria); |
||||||
65 | $total_active_users = $memberHandler->getUserCount($level_criteria); |
||||||
66 | //Fixing stats for last 24 and 48 hours |
||||||
67 | $users_reg_24 = $memberHandler->getUserCount($criteria24->add(new \Criteria('user_regdate', (mktime(0, 0, 0) - (24 * 3600)), '>=')), 'AND'); |
||||||
0 ignored issues
–
show
The call to
XoopsMemberHandler::getUserCount() has too many arguments starting with 'AND' .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
68 | $users_reg_48 = $memberHandler->getUserCount($criteria48->add(new \Criteria('user_regdate', (mktime(0, 0, 0) - (48 * 3600)), '>=')), 'AND'); |
||||||
69 | $limit = 1; |
||||||
70 | $criteria->setOrder('DESC'); |
||||||
71 | $criteria->setSort('user_regdate'); |
||||||
72 | $criteria->setLimit($limit); |
||||||
73 | $lastmembers = $memberHandler->getUsers($criteria); |
||||||
74 | $lastusername = $lastmembers[0]->getVar('uname'); |
||||||
75 | $lastrealname = $lastmembers[0]->getVar('name'); |
||||||
76 | $lastid = $lastmembers[0]->getVar('uid'); |
||||||
77 | |||||||
78 | //Total Post Count |
||||||
79 | $sql = 'SELECT SUM(posts) AS totalposts FROM ' . $GLOBALS['xoopsDB']->prefix('users') . ' WHERE level > 0'; |
||||||
80 | $result = $GLOBALS['xoopsDB']->query($sql); |
||||||
81 | $myrow = $GLOBALS['xoopsDB']->fetchArray($result); |
||||||
82 | $block['totalposts'] = $myrow['totalposts'] . ' ' . _MB_XOOPSMEMBERS_TOTALPOSTS; |
||||||
83 | |||||||
84 | // data |
||||||
85 | $block['activeusers'] = $total_active_users . ' ' . _MB_XOOPSMEMBERS_REGISTEREDMEMBERS; |
||||||
86 | $block['todayreg'] = $users_reg_24 . ' ' . _MB_XOOPSMEMBERS_REGISTEREDTODAY . ' ' . _MB_XOOPSMEMBERS_AND; |
||||||
87 | $block['yesterdayreg'] = $users_reg_48 - $users_reg_24 . ' ' . _MB_XOOPSMEMBERS_REGISTEREDYESTERDAY; |
||||||
88 | $block['online_names'] = $members; |
||||||
89 | $block['online_members'] = $total - $guests . ' ' . _MB_XOOPSMEMBERS_MEMBERS . ' ' . _MB_XOOPSMEMBERS_CURRENTONLINE; |
||||||
90 | $block['online_guests'] = $guests . ' ' . _MB_XOOPSMEMBERS_GUESTS . ' ' . _MB_XOOPSMEMBERS_AND; |
||||||
91 | $block['lang_more'] = _MB_XOOPSMEMBERS_MORE; |
||||||
92 | |||||||
93 | $block['total_online'] = $total; |
||||||
94 | |||||||
95 | if ('1' == $options[4] && '' != $lastrealname) { |
||||||
96 | $block['latestmember'] = $lastrealname; |
||||||
97 | } else { |
||||||
98 | $block['latestmember'] = $lastusername; |
||||||
99 | } |
||||||
100 | $block['latest_id'] = $lastid; |
||||||
101 | |||||||
102 | // Language Definition |
||||||
103 | $block['membership_lang'] = _MB_XOOPSMEMBERS_MEMBERSHIP; |
||||||
104 | $block['newestmember_lang'] = _MB_XOOPSMEMBERS_NEWESTMEMBER; |
||||||
105 | $block['showtotalpost'] = $options[0]; |
||||||
106 | $block['showtotalonline'] = $options[1]; |
||||||
107 | $block['showreghistory'] = $options[2]; |
||||||
108 | $block['shownewmember'] = $options[3]; |
||||||
109 | $block['userealname'] = $options[4]; |
||||||
110 | |||||||
111 | return $block; |
||||||
112 | } |
||||||
113 | |||||||
114 | return false; |
||||||
115 | } |
||||||
116 | |||||||
117 | /** |
||||||
118 | * @param $options |
||||||
119 | * @return string |
||||||
120 | */ |
||||||
121 | function membersstats_edit($options) |
||||||
122 | { |
||||||
123 | $form = _MB_XOOPSMEMBERS_SHOWTOTALPOST . ' '; |
||||||
124 | if (1 == $options[0]) { |
||||||
125 | $chk = ' checked'; |
||||||
126 | } |
||||||
127 | $form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' > ' . _YES . ''; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
128 | $chk = ''; |
||||||
129 | if (0 == $options[0]) { |
||||||
130 | $chk = ' checked'; |
||||||
131 | } |
||||||
132 | $form .= " <input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||||||
133 | |||||||
134 | $form .= _MB_XOOPSMEMBERS_SHOWTOTALONLINE . ' '; |
||||||
135 | if (1 == $options[1]) { |
||||||
136 | $chk = ' checked'; |
||||||
137 | } |
||||||
138 | $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' > ' . _YES . ''; |
||||||
139 | $chk = ''; |
||||||
140 | if (0 == $options[1]) { |
||||||
141 | $chk = ' checked'; |
||||||
142 | } |
||||||
143 | $form .= " <input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||||||
144 | |||||||
145 | $form .= _MB_XOOPSMEMBERS_SHOWREGHISTORY . ' '; |
||||||
146 | if (1 == $options[2]) { |
||||||
147 | $chk = ' checked'; |
||||||
148 | } |
||||||
149 | $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' > ' . _YES . ''; |
||||||
150 | $chk = ''; |
||||||
151 | if (0 == $options[2]) { |
||||||
152 | $chk = ' checked'; |
||||||
153 | } |
||||||
154 | $form .= " <input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||||||
155 | |||||||
156 | $form .= _MB_XOOPSMEMBERS_SHOWNEWMEMBER . ' '; |
||||||
157 | if (1 == $options[3]) { |
||||||
158 | $chk = ' checked'; |
||||||
159 | } |
||||||
160 | $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' > ' . _YES . ''; |
||||||
161 | $chk = ''; |
||||||
162 | if (0 == $options[3]) { |
||||||
163 | $chk = ' checked'; |
||||||
164 | } |
||||||
165 | $form .= " <input type='radio' name='options[3]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||||||
166 | |||||||
167 | $form .= _MB_XOOPSMEMBERS_USEREALNAME . ' '; |
||||||
168 | if (1 == $options[4]) { |
||||||
169 | $chk = ' checked'; |
||||||
170 | } |
||||||
171 | $form .= "<input type='radio' name='options[4]' value='1'" . $chk . ' > ' . _YES . ''; |
||||||
172 | $chk = ''; |
||||||
173 | if (0 == $options[4]) { |
||||||
174 | $chk = ' checked'; |
||||||
175 | } |
||||||
176 | $form .= " <input type='radio' name='options[4]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||||||
177 | |||||||
178 | return $form; |
||||||
179 | } |
||||||
180 |