Issues (67)

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/membersstats_block.php (4 issues)

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
The condition false === $requestIp is always false.
Loading history...
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
The assignment to $today is dead and can be removed.
Loading history...
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 ignore-call  annotation

67
        /** @scrutinizer ignore-call */ 
68
        $users_reg_24 = $memberHandler->getUserCount($criteria24->add(new \Criteria('user_regdate', (mktime(0, 0, 0) - (24 * 3600)), '>=')), 'AND');

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.

Loading history...
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 . '&nbsp;';
124
    if (1 == $options[0]) {
125
        $chk = ' checked';
126
    }
127
    $form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $chk does not seem to be defined for all execution paths leading up to this point.
Loading history...
128
    $chk  = '';
129
    if (0 == $options[0]) {
130
        $chk = ' checked';
131
    }
132
    $form .= "&nbsp;<input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>';
133
134
    $form .= _MB_XOOPSMEMBERS_SHOWTOTALONLINE . '&nbsp;';
135
    if (1 == $options[1]) {
136
        $chk = ' checked';
137
    }
138
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
139
    $chk  = '';
140
    if (0 == $options[1]) {
141
        $chk = ' checked';
142
    }
143
    $form .= "&nbsp;<input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>';
144
145
    $form .= _MB_XOOPSMEMBERS_SHOWREGHISTORY . '&nbsp;';
146
    if (1 == $options[2]) {
147
        $chk = ' checked';
148
    }
149
    $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
150
    $chk  = '';
151
    if (0 == $options[2]) {
152
        $chk = ' checked';
153
    }
154
    $form .= "&nbsp;<input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>';
155
156
    $form .= _MB_XOOPSMEMBERS_SHOWNEWMEMBER . '&nbsp;';
157
    if (1 == $options[3]) {
158
        $chk = ' checked';
159
    }
160
    $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
161
    $chk  = '';
162
    if (0 == $options[3]) {
163
        $chk = ' checked';
164
    }
165
    $form .= "&nbsp;<input type='radio' name='options[3]' value='0'" . $chk . ' >' . _NO . '<br>';
166
167
    $form .= _MB_XOOPSMEMBERS_USEREALNAME . '&nbsp;';
168
    if (1 == $options[4]) {
169
        $chk = ' checked';
170
    }
171
    $form .= "<input type='radio' name='options[4]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
172
    $chk  = '';
173
    if (0 == $options[4]) {
174
        $chk = ' checked';
175
    }
176
    $form .= "&nbsp;<input type='radio' name='options[4]' value='0'" . $chk . ' >' . _NO . '<br>';
177
178
    return $form;
179
}
180