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.

searchmembers.php (1 issue)

Severity
1
<?php declare(strict_types=1);
2
3
/**
4
 * Xoops Members Module
5
 *
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 *
13
 * @copyright XOOPS Project (https://xoops.org)
14
 * @license   https://www.fsf.org/copyleft/gpl.html GNU public license
15
 * @since     2.3.0
16
 * @author    onokazu
17
 * @author    John Neill
18
 */
19
require_once __DIR__ . '/header.php';
20
21
global $xoopsModule;
22
23
$op = (isset($_POST['op']) && 'submit' == $_POST['op']) ? 'submit' : 'form';
24
/** @var \XoopsMemberHandler $memberHandler */
25
$memberHandler = xoops_getHandler('member');
26
27
if ('form' == $op) {
28
    $GLOBALS['xoopsOption']['template_main'] = 'xoopsmembers_searchform.tpl';
29
    require XOOPS_ROOT_PATH . '/header.php';
30
31
    $total = $memberHandler->getUserCount(new \Criteria('level', 0, '>'));
32
33
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
34
35
    $form        = new \XoopsThemeForm('', 'searchform', 'searchmembers.php');
36
    $uname_text  = new \XoopsFormText('', 'user_uname', 30, 60);
37
    $uname_match = new \XoopsFormSelectMatchOption('', 'user_uname_match');
38
    $uname_tray  = new \XoopsFormElementTray(_MD_XOOPSMEMBERS_UNAME, '&nbsp;');
39
    $uname_tray->addElement($uname_match);
40
    $uname_tray->addElement($uname_text);
41
    $form->addElement($uname_tray);
42
43
    if (1 == $xoopsModuleConfig['displayrealname']) {
44
        $name_text  = new \XoopsFormText('', 'user_name', 30, 60);
45
        $name_match = new \XoopsFormSelectMatchOption('', 'user_name_match');
46
        $name_tray  = new \XoopsFormElementTray(_MD_XOOPSMEMBERS_REALNAME, '&nbsp;');
47
        $name_tray->addElement($name_match);
48
        $name_tray->addElement($name_text);
49
        $form->addElement($name_tray);
50
    }
51
52
    if (1 == $xoopsModuleConfig['displayemail']) {
53
        $email_text  = new \XoopsFormText('', 'user_email', 30, 60);
54
        $email_match = new \XoopsFormSelectMatchOption('', 'user_email_match');
55
        $email_tray  = new \XoopsFormElementTray(_MD_XOOPSMEMBERS_EMAIL, '&nbsp;');
56
        $email_tray->addElement($email_match);
57
        $email_tray->addElement($email_text);
58
        $form->addElement($email_tray);
59
    }
60
61
    if (1 == $xoopsModuleConfig['displayurl']) {
62
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_URLCONTAINS, 'user_url', 30, 100));
63
    }
64
    if (1 == $xoopsModuleConfig['displayfrom']) {
65
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_LOCATIONCONTAINS, 'user_from', 30, 100));
66
    }
67
    if (1 == $xoopsModuleConfig['displayoccupation']) {
68
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_OCCUPATIONCONTAINS, 'user_occ', 30, 100));
69
    }
70
    if (1 == $xoopsModuleConfig['displayinterest']) {
71
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_INTERESTCONTAINS, 'user_intrest', 30, 100));
72
    }
73
    if (1 == $xoopsModuleConfig['displayextrainfo']) {
74
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_EXTRAINFOCONTAINS, 'bio', 30, 100));
75
    }
76
    if (1 == $xoopsModuleConfig['displaysignature']) {
77
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_SIGNATURECONTAINS, 'user_sig', 30, 100));
78
    }
79
    if (1 == $xoopsModuleConfig['displaylastlogin']) {
80
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_LASTLOGMORE, 'user_lastlog_more', 10, 5));
81
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_LASTLOGLESS, 'user_lastlog_less', 10, 5));
82
    }
83
    if (1 == $xoopsModuleConfig['displayregdate']) {
84
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_REGMORE, 'user_reg_more', 10, 5));
85
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_REGLESS, 'user_reg_less', 10, 5));
86
    }
87
    if (1 == $xoopsModuleConfig['displayposts']) {
88
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_POSTSMORE, 'user_posts_more', 10, 5));
89
        $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_POSTSLESS, 'user_posts_less', 10, 5));
90
    }
91
92
    $sort_select = new \XoopsFormSelect(_MD_XOOPSMEMBERS_SORT, 'user_sort');
93
    $sort_select->addOptionArray(['uname' => _MD_XOOPSMEMBERS_UNAME, 'name' => _MD_XOOPSMEMBERS_REALNAME, 'last_login' => _MD_XOOPSMEMBERS_LASTLOGIN, 'user_regdate' => _MD_XOOPSMEMBERS_REGDATE, 'posts' => _MD_XOOPSMEMBERS_POSTS]);
94
    $form->addElement($sort_select);
95
96
    $order_select = new \XoopsFormSelect(_MD_XOOPSMEMBERS_ORDER, 'user_order');
97
    $order_select->addOptionArray(['ASC' => _MD_XOOPSMEMBERS_ASC, 'DESC' => _MD_XOOPSMEMBERS_DESC]);
98
    $form->addElement($order_select);
99
100
    $form->addElement(new \XoopsFormText(_MD_XOOPSMEMBERS_LIMIT, 'limit', 6, 2));
101
    $form->addElement(new \XoopsFormHidden('op', 'submit'));
102
    $form->addElement(new \XoopsFormButton('', 'user_submit', _SUBMIT, 'submit'));
103
    $form->assign($xoopsTpl);
104
    $xoopsTpl->assign('totalmember', $total);
105
}
106
107
if ('submit' == $op) {
108
    $GLOBALS['xoopsOption']['template_main'] = 'xoopsmembers_searchresults.tpl';
109
    require XOOPS_ROOT_PATH . '/header.php';
110
111
    $iamadmin = $xoopsUserIsAdmin;
112
    $myts     = MyTextSanitizer::getInstance();
113
    $criteria = new \CriteriaCompo();
114
115
    if (!empty($_POST['user_uname'])) {
116
        $match = (!empty($_POST['user_uname_match'])) ? (int)$_POST['user_uname_match'] : XOOPS_MATCH_START;
117
        $ret   = $GLOBALS['xoopsDB']->escape(trim($_POST['user_uname']));
118
        xoops_Criteria($criteria, 'uname', $ret, $match);
119
    }
120
121
    if (!empty($_POST['user_name'])) {
122
        $match = (!empty($_POST['user_name_match'])) ? (int)$_POST['user_name_match'] : XOOPS_MATCH_START;
123
        $ret   = $GLOBALS['xoopsDB']->escape(trim($_POST['user_uname']));
124
        xoops_Criteria($criteria, 'name', $ret, $match);
125
    }
126
127
    if (!empty($_POST['user_email'])) {
128
        $match = (!empty($_POST['user_email_match'])) ? (int)$_POST['user_email_match'] : XOOPS_MATCH_START;
129
        $ret   = $GLOBALS['xoopsDB']->escape(trim($_POST['user_email']));
130
        xoops_Criteria($criteria, 'name', $ret, $match);
131
        if (!$iamadmin) {
132
            $criteria->add(new \Criteria('user_viewemail', 1));
133
        }
134
    }
135
136
    if (!empty($_POST['user_url'])) {
137
        $url = formatURL(trim($_POST['user_url']));
138
        $criteria->add(new \Criteria('url', $GLOBALS['xoopsDB']->escape($url) . '%', 'LIKE'));
139
    }
140
141
    if (!empty($_POST['user_from'])) {
142
        $criteria->add(new \Criteria('user_from', '%' . $GLOBALS['xoopsDB']->escape(trim($_POST['user_from'])) . '%', 'LIKE'));
143
    }
144
145
    if (!empty($_POST['user_intrest'])) {
146
        $criteria->add(new \Criteria('user_intrest', '%' . $GLOBALS['xoopsDB']->escape(trim($_POST['user_intrest'])) . '%', 'LIKE'));
147
    }
148
149
    if (!empty($_POST['user_occ'])) {
150
        $criteria->add(new \Criteria('user_occ', '%' . $GLOBALS['xoopsDB']->escape(trim($_POST['user_occ'])) . '%', 'LIKE'));
151
    }
152
    if (!empty($_POST['bio'])) {
153
        $criteria->add(new \Criteria('bio', '%' . $GLOBALS['xoopsDB']->escape(trim($_POST['bio'])) . '%', 'LIKE'));
154
    }
155
    if (!empty($_POST['user_sig'])) {
156
        $criteria->add(new \Criteria('user_sig', '%' . $GLOBALS['xoopsDB']->escape(trim($_POST['user_sig'])) . '%', 'LIKE'));
157
    }
158
159
    if (!empty($_POST['user_lastlog_more']) && is_numeric($_POST['user_lastlog_more'])) {
160
        $f_user_lastlog_more = (int)trim($_POST['user_lastlog_more']);
161
        $time                = time() - (60 * 60 * 24 * $f_user_lastlog_more);
162
        if ($time > 0) {
163
            $criteria->add(new \Criteria('last_login', $time, '<'));
164
        }
165
    }
166
167
    if (!empty($_POST['user_lastlog_less']) && is_numeric($_POST['user_lastlog_less'])) {
168
        $f_user_lastlog_less = (int)trim($_POST['user_lastlog_less']);
169
        $time                = time() - (60 * 60 * 24 * $f_user_lastlog_less);
170
        if ($time > 0) {
171
            $criteria->add(new \Criteria('last_login', $time, '>'));
172
        }
173
    }
174
175
    if (!empty($_POST['user_reg_more']) && is_numeric($_POST['user_reg_more'])) {
176
        $f_user_reg_more = (int)trim($_POST['user_reg_more']);
177
        $time            = time() - (60 * 60 * 24 * $f_user_reg_more);
178
        if ($time > 0) {
179
            $criteria->add(new \Criteria('user_regdate', $time, '<'));
180
        }
181
    }
182
183
    if (!empty($_POST['user_reg_less']) && is_numeric($_POST['user_reg_less'])) {
184
        $f_user_reg_less = (int)$_POST['user_reg_less'];
185
        $time            = time() - (60 * 60 * 24 * $f_user_reg_less);
186
        if ($time > 0) {
187
            $criteria->add(new \Criteria('user_regdate', $time, '>'));
188
        }
189
    }
190
191
    if (isset($_POST['user_posts_more']) && is_numeric($_POST['user_posts_more'])) {
192
        $criteria->add(new \Criteria('posts', (int)$_POST['user_posts_more'], '>'));
193
    }
194
195
    if (!empty($_POST['user_posts_less']) && is_numeric($_POST['user_posts_less'])) {
196
        $criteria->add(new \Criteria('posts', (int)$_POST['user_posts_less'], '<'));
197
    }
198
199
    $criteria->add(new \Criteria('level', 0, '>'));
200
    $validsort = ['uname', 'email', 'last_login', 'user_regdate', 'posts'];
201
    $sort      = (!in_array($_POST['user_sort'], $validsort, true)) ? 'uname' : $_POST['user_sort'];
202
    $order     = 'ASC';
203
    if (isset($_POST['user_order']) && 'DESC' == $_POST['user_order']) {
204
        $order = 'DESC';
205
    }
206
    $limit = (!empty($_POST['limit'])) ? (int)$_POST['limit'] : 20;
207
    if (0 == $limit || $limit > 50) {
208
        $limit = 50;
209
    }
210
211
    $start = (!empty($_POST['start'])) ? (int)$_POST['start'] : 0;
212
    $total = $memberHandler->getUserCount($criteria);
213
    $xoopsTpl->assign('total_found', $total);
214
215
    if (0 == $total) {
216
    } elseif ($start < $total) {
217
        if ($iamadmin) {
218
            $xoopsTpl->assign('is_admin', true);
219
        }
220
        $criteria->setSort($sort);
221
        $criteria->setOrder($order);
222
        $criteria->setStart($start);
223
        $criteria->setLimit($limit);
224
        $foundusers = $memberHandler->getUsers($criteria, true);
225
        foreach (array_keys($foundusers) as $j) {
226
            $userdata['avatar']   = $foundusers[$j]->getVar('user_avatar');
227
            $userdata['realname'] = $foundusers[$j]->getVar('name');
228
            $userdata['name']     = $foundusers[$j]->getVar('uname');
229
            $userdata['id']       = $foundusers[$j]->getVar('uid');
230
            if (1 == $foundusers[$j]->getVar('user_viewemail') || $iamadmin) {
231
                $userdata['email']        = '<a href="mailto:' . $foundusers[$j]->getVar('email') . '"><img src="' . XOOPS_URL . '/images/icons/email.gif" border="0" alt="' . sprintf(_SENDEMAILTO, $foundusers[$j]->getVar('uname', 'e')) . '"></a>';
232
                $userdata['emailaddress'] = $foundusers[$j]->getVar('email');
233
            }
234
            if ($xoopsUser) {
235
                $userdata['pmlink'] = '<a href="javascript:openWithSelfMain(\'' . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . $foundusers[$j]->getVar('uid') . '\',\'pmlite\',450,370);"><img src="' . XOOPS_URL . '/images/icons/pm.gif" border="0" alt="' . sprintf(
236
                        _SENDPMTO,
237
                        $foundusers[$j]->getVar(
238
                            'uname',
239
                            'e'
240
                        )
241
                    ) . '"></a>';
242
                $userdata['pm']     = $foundusers[$j]->getVar('uid');
243
            }
244
            if ('' != $foundusers[$j]->getVar('url', 'e')) {
245
                $userdata['website'] = '<a href="' . $foundusers[$j]->getVar('url', 'e') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '"></a>';
246
            }
247
            $userdata['url']          = $foundusers[$j]->getVar('url', 'e');
248
            $userdata['registerdate'] = formatTimestamp($foundusers[$j]->getVar('user_regdate'), 's');
249
            if (0 != $foundusers[$j]->getVar('last_login')) {
250
                $userdata['lastlogin'] = formatTimestamp($foundusers[$j]->getVar('last_login'), 'm');
251
            } else {
252
                $userdata['lastlogin'] = _MD_XOOPSMEMBERS_NEVERLOGIN;
253
            }
254
            $userdata['posts'] = $foundusers[$j]->getVar('posts');
255
            if ($iamadmin) {
256
                $userdata['adminlink'] = '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;uid=' . $foundusers[$j]->getVar('uid') . '&amp;op=users_edit">' . '<img src=' . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "' >"
257
258
                                         . '</a>  <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;op=users_delete&amp;uid=' . $foundusers[$j]->getVar('uid') . '">' . '<img src=' . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "' >" . '</a>';
259
            }
260
            $userdata['location']     = $foundusers[$j]->getVar('user_from');
261
            $userdata['occupation']   = $foundusers[$j]->getVar('user_occ');
262
            $userdata['interest']     = $foundusers[$j]->getVar('user_intrest');
263
            $userdata['extrainfo']    = $foundusers[$j]->getVar('bio');
264
            $userdata['signature']    = $foundusers[$j]->getVar('user_sig');
265
            $userdata['onlinestatus'] = $foundusers[$j]->isOnline();
266
            $userrank                 = $foundusers[$j]->rank();
267
            if ($userrank['image']) {
268
                $userdata['rankimage'] = '<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="">';
269
            }
270
            $userdata['ranktitle'] = $userrank['title'];
271
272
            $uid        = $userdata['id'];
273
            $groups     = $memberHandler->getGroupsByUser($uid, true);
274
            $usergroups = [];
275
            foreach ($groups as $group) {
276
                $usergroups[] = $group->getVar('name');
277
            }
278
            $userdata['groups'] = implode(', ', $usergroups);
279
280
            $xoopsTpl->append('users', $userdata);
281
        }
282
283
        $totalpages = ceil($total / $limit);
284
        if ($totalpages > 1) {
285
            $hiddenform = '<form name="findnext" action="searchmembers.php" method="post">';
286
            foreach ($_POST as $k => $v) {
287
                $hiddenform .= '<input type="hidden" name="' . htmlspecialchars($k) . '" value="' . $myts->previewTarea($v) . '" >';
288
            }
289
            if (!isset($_POST['limit'])) {
290
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" >';
291
            }
292
            if (!isset($_POST['start'])) {
293
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" >';
294
            }
295
            $prev = $start - $limit;
296
            if ($start - $limit >= 0) {
297
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_PREVIOUS . '</a>&nbsp;';
298
            }
299
            $counter     = 1;
300
            $currentpage = ($start + $limit) / $limit;
301
            while ($counter <= $totalpages) {
302
                if ($counter == $currentpage) {
303
                    $hiddenform .= '<b>' . $counter . '</b> ';
304
                } elseif (($counter > $currentpage - 4 && $counter < $currentpage + 4) || 1 == $counter || $counter == $totalpages) {
305
                    if ($counter == $totalpages && $currentpage < $totalpages - 4) {
306
                        $hiddenform .= '... ';
307
                    }
308
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ($counter - 1) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
309
                    if (1 == $counter && $currentpage > 5) {
310
                        $hiddenform .= '... ';
311
                    }
312
                }
313
                $counter++;
314
            }
315
            $next = $start + $limit;
316
            if ($total > $next) {
317
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_NEXT . '</a>';
318
            }
319
            $hiddenform .= '</form>';
320
            $xoopsTpl->assign('pagenav', $hiddenform);
321
            $xoopsTpl->assign('lang_numfound', sprintf(_MD_XOOPSMEMBERS_USERSFOUND, $total));
322
        }
323
    }
324
}
325
326
require __DIR__ . '/footer.php';
327
require_once XOOPS_ROOT_PATH . '/footer.php';
328
exit();
329
330
/**
331
 * xoops_Criteria()
332
 *
333
 * @param \CriteriaCompo $criteria
334
 * @param string         $name
335
 * @param string         $ret
336
 * @param string         $match
337
 * @return void
338
 */
339
function xoops_Criteria(&$criteria, $name = '', $ret = '', $match = ''): void
0 ignored issues
show
The parameter $criteria is not used and could be removed. ( Ignorable by Annotation )

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

339
function xoops_Criteria(/** @scrutinizer ignore-unused */ &$criteria, $name = '', $ret = '', $match = ''): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
340
{
341
    global $criteria;
342
343
    switch ($match) {
344
        case XOOPS_MATCH_START:
345
            $criteria->add(new \Criteria($name, $ret . '%', 'LIKE'));
346
            break;
347
        case XOOPS_MATCH_END:
348
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
349
            break;
350
        case XOOPS_MATCH_EQUAL:
351
            $criteria->add(new \Criteria($name, $ret));
352
            break;
353
        case XOOPS_MATCH_CONTAIN:
354
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
355
            break;
356
    }
357
}
358