Issues (68)

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
2
//  Author: SMD & Trabis
3
//  URL: http://www.xoopsmalaysia.org  & http://www.xuups.com
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
85
        // data
86
        $block['activeusers']    = $total_active_users. ' ' . _MB_XOOPSMEMBERS_REGISTEREDMEMBERS;
87
        $block['todayreg']       = $users_reg_24   . ' ' . _MB_XOOPSMEMBERS_REGISTEREDTODAY . ' ' . _MB_XOOPSMEMBERS_AND;
88
        $block['yesterdayreg']   = $users_reg_48 - $users_reg_24    . ' ' . _MB_XOOPSMEMBERS_REGISTEREDYESTERDAY;
89
        $block['online_names']   = $members;
90
        $block['online_members'] = $total - $guests  . ' ' . _MB_XOOPSMEMBERS_MEMBERS . ' ' . _MB_XOOPSMEMBERS_CURRENTONLINE;
91
        $block['online_guests']  = $guests . ' ' . _MB_XOOPSMEMBERS_GUESTS . ' ' . _MB_XOOPSMEMBERS_AND;
92
        $block['lang_more']      = _MB_XOOPSMEMBERS_MORE;
93
94
        $block['total_online'] = $total;
95
96
        if ('1' == $options[4] && '' != $lastrealname) {
97
            $block['latestmember'] = $lastrealname;
98
        } else {
99
            $block['latestmember'] = $lastusername;
100
        }
101
        $block['latest_id'] = $lastid;
102
103
        // Language Definition
104
        $block['membership_lang']          = _MB_XOOPSMEMBERS_MEMBERSHIP;
105
        $block['newestmember_lang']        = _MB_XOOPSMEMBERS_NEWESTMEMBER;
106
        $block['showtotalpost']            = $options[0];
107
        $block['showtotalonline']          = $options[1];
108
        $block['showreghistory']           = $options[2];
109
        $block['shownewmember']            = $options[3];
110
        $block['userealname']              = $options[4];
111
112
        return $block;
113
    } else {
114
        return false;
115
    }
116
}
117
118
/**
119
 * @param $options
120
 * @return string
121
 */
122
function membersstats_edit($options)
123
{
124
    $form = _MB_XOOPSMEMBERS_SHOWTOTALPOST . '&nbsp;';
125
    if (1 == $options[0]) {
126
        $chk = " checked";
127
    }
128
    $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...
129
    $chk  = '';
130
    if (0 == $options[0]) {
131
        $chk = " checked";
132
    }
133
    $form .= "&nbsp;<input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>';
134
135
    $form .= _MB_XOOPSMEMBERS_SHOWTOTALONLINE . '&nbsp;';
136
    if (1 == $options[1]) {
137
        $chk = " checked";
138
    }
139
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
140
    $chk  = '';
141
    if (0 == $options[1]) {
142
        $chk = " checked";
143
    }
144
    $form .= "&nbsp;<input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>';
145
146
    $form .= _MB_XOOPSMEMBERS_SHOWREGHISTORY . '&nbsp;';
147
    if (1 == $options[2]) {
148
        $chk = " checked";
149
    }
150
    $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
151
    $chk  = '';
152
    if (0 == $options[2]) {
153
        $chk = " checked";
154
    }
155
    $form .= "&nbsp;<input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>';
156
157
    $form .= _MB_XOOPSMEMBERS_SHOWNEWMEMBER . '&nbsp;';
158
    if (1 == $options[3]) {
159
        $chk = " checked";
160
    }
161
    $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
162
    $chk  = '';
163
    if (0 == $options[3]) {
164
        $chk = " checked";
165
    }
166
    $form .= "&nbsp;<input type='radio' name='options[3]' value='0'" . $chk . ' >' . _NO . '<br>';
167
168
    $form .= _MB_XOOPSMEMBERS_USEREALNAME . '&nbsp;';
169
    if (1 == $options[4]) {
170
        $chk = " checked";
171
    }
172
    $form .= "<input type='radio' name='options[4]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
173
    $chk  = '';
174
    if (0 == $options[4]) {
175
        $chk = " checked";
176
    }
177
    $form .= "&nbsp;<input type='radio' name='options[4]' value='0'" . $chk . ' >' . _NO . '<br>';
178
179
    return $form;
180
}
181