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.

searchmembers.php (1 issue)

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

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

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...
342
{
343
    global $criteria;
344
345
    switch ($match) {
346
        case XOOPS_MATCH_START:
347
            $criteria->add(new \Criteria($name, $ret . '%', 'LIKE'));
348
            break;
349
        case XOOPS_MATCH_END:
350
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
351
            break;
352
        case XOOPS_MATCH_EQUAL:
353
            $criteria->add(new \Criteria($name, $ret));
354
            break;
355
        case XOOPS_MATCH_CONTAIN:
356
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
357
            break;
358
    }
359
}
360