Passed
Push — master ( 221bdd...5b32ea )
by Michael
03:08
created
Severity
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
$xoopsOption['template_main'] = 'xoopsmembers_index.tpl';
22
require_once __DIR__ . '/header.php';
23
//global $pathIcon16;
24
25
global $xoopsModule;
26
27
/** @var \XoopsMemberHandler $memberHandler */
28
$memberHandler = xoops_getHandler('member');
29
$total         = $memberHandler->getUserCount(new \Criteria('level', 0, '>'));
30
31
$iamadmin = $xoopsUserIsAdmin;
32
$myts     = \MyTextSanitizer::getInstance();
33
$criteria = new \CriteriaCompo();
34
35
$criteria->add(new \Criteria('level', 0, '>'));
36
$validsort = ['uname', 'name', 'last_login', 'user_regdate', 'posts'];
37
//$sort      = (!in_array($helper->getModule()->getInfo('sortmembers'), $validsort)) ? 'uname' : $helper->getModule()->getInfo('sortmembers');
38
//temp solution
39
$sort = (!in_array($xoopsModuleConfig['sortmembers'], $validsort ) ) ? 'uname' : $xoopsModuleConfig['sortmembers'];
40
    
41
$order = 'ASC';
42
//$temp  = $helper->getModule()->getInfo('membersorder');
43
//temp solution
44
if ( isset( $xoopsModuleConfig['membersorder'] ) && $xoopsModuleConfig['membersorder'] == 'DESC' ) {
45
//if (isset($temp) && 'DESC' == $temp) {
46
    $order = 'DESC';
47
}
48
49
//temp solution
50
$limit = (!empty($xoopsModuleConfig['membersperpage'])) ? intval($xoopsModuleConfig['membersperpage']) : 20;
51
//$limit = \Xmf\Request::getInt('limit', 20, 'POST');
52
if (0 == $limit || $limit > 50) {
53
    $limit = 50;
54
}
55
56
$start = \Xmf\Request::getInt('start', 0, 'POST');
57
$total = $memberHandler->getUserCount($criteria);
58
$xoopsTpl->assign('totalmember', $total);
59
60
//Show last member
61
$result = $GLOBALS['xoopsDB']->query('SELECT uid, uname FROM ' . $GLOBALS['xoopsDB']->prefix('users') . ' WHERE level > 0 ORDER BY uid DESC', 1, 0);
62
list($latestuid, $latestuser) = $GLOBALS['xoopsDB']->fetchRow($result);
63
$xoopsTpl->assign('latestmember', " <a href='" . XOOPS_URL . '/userinfo.php?uid=' . $latestuid . "'>" . $latestuser . '</a>');
64
$xoopsTpl->assign('welcomemessage', $xoopsModuleConfig['welcomemessage']);
65
66
if (0 == $total) {
67
} elseif ($start < $total) {
68
    if ($iamadmin) {
69
        $xoopsTpl->assign('is_admin', true);
70
    }
71
    $criteria->setSort($sort);
72
    $criteria->setOrder($order);
73
    $criteria->setStart($start);
74
    $criteria->setLimit($limit);
75
    $foundusers = $memberHandler->getUsers($criteria, true);
76
    foreach (array_keys($foundusers) as $j) {
77
        $userdata['avatar']   = $foundusers[$j]->getVar('user_avatar');
78
        $userdata['realname'] = $foundusers[$j]->getVar('name');
79
        $userdata['name']     = $foundusers[$j]->getVar('uname');
80
        $userdata['id']       = $foundusers[$j]->getVar('uid');
81
        if (1 == $foundusers[$j]->getVar('user_viewemail') || $iamadmin) {
82
            $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>';
83
        } else {
84
            $userdata['email'] = '&nbsp;';
85
        }
86
        if ($xoopsUser) {
87
            $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(_SENDPMTO, $foundusers[$j]->getVar('uname', 'e')) . '"></a>';
88
        } else {
89
            $userdata['pmlink'] = '&nbsp;';
90
        }
91
        if ('' != $foundusers[$j]->getVar('url', 'e')) {
92
            $userdata['website'] = '<a href="' . $foundusers[$j]->getVar('url', 'e') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '"></a>';
93
        } else {
94
            $userdata['website'] = '&nbsp;';
95
        }
96
        $userdata['registerdate'] = formatTimestamp($foundusers[$j]->getVar('user_regdate'), 's');
97
        if (0 != $foundusers[$j]->getVar('last_login')) {
98
            $userdata['lastlogin'] = formatTimestamp($foundusers[$j]->getVar('last_login'), 'm');
99
        } else {
100
            $userdata['lastlogin'] = _MD_XOOPSMEMBERS_NEVERLOGIN;
101
        }
102
        $userdata['posts'] = $foundusers[$j]->getVar('posts');
103
        if ($iamadmin) {
104
            $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 . "'>"
105
106
                                     . '</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>';
107
        }
108
		
109
		$userdata['location']       = $foundusers[$j]->getVar('user_from');
110
		$userdata['occupation']     = $foundusers[$j]->getVar('user_occ');
111
		$userdata['interest']       = $foundusers[$j]->getVar('user_intrest');
112
        $xoopsTpl->append('users', $userdata);
113
    }
114
115
    $totalpages = ceil($total / $limit);
116
    if ($totalpages > 1) {
117
        $hiddenform = '<form name="findnext" action="index.php" method="post">';
118
        foreach ($_POST as $k => $v) {
119
            $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars($k) . '" value="' . $myts->previewTarea($v) . '">';
120
        }
121
        if (!isset($_POST['limit'])) {
122
            $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '">';
123
        }
124
        if (!isset($_POST['start'])) {
125
            $hiddenform .= '<input type="hidden" name="start" value="' . $start . '">';
126
        }
127
        $prev = $start - $limit;
128
        if ($start - $limit >= 0) {
129
            $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_PREVIOUS . '</a>&nbsp;';
130
        }
131
        $counter     = 1;
132
        $currentpage = ($start + $limit) / $limit;
133
        while ($counter <= $totalpages) {
134
            if ($counter == $currentpage) {
135
                $hiddenform .= '<b>' . $counter . '</b> ';
136
            } elseif (($counter > $currentpage - 4 && $counter < $currentpage + 4) || 1 == $counter || $counter == $totalpages) {
137
                if ($counter == $totalpages && $currentpage < $totalpages - 4) {
138
                    $hiddenform .= '... ';
139
                }
140
                $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ($counter - 1) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
141
                if (1 == $counter && $currentpage > 5) {
142
                    $hiddenform .= '... ';
143
                }
144
            }
145
            $counter++;
146
        }
147
        $next = $start + $limit;
148
        if ($total > $next) {
149
            $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_NEXT . '</a>';
150
        }
151
        $hiddenform .= '</form>';
152
        $xoopsTpl->assign('pagenav', $hiddenform);
153
        $xoopsTpl->assign('lang_numfound', sprintf(_MD_XOOPSMEMBERS_USERSFOUND, $total));
154
    }
155
}
156
157
require __DIR__ . '/footer.php';
158
require_once XOOPS_ROOT_PATH . '/footer.php';
159
exit();
160
161
/**
162
 * xoops_Criteria()
163
 *
164
 * @param \CriteriaCompo       $criteria
165
 * @param string $name
166
 * @param string $ret
167
 * @param string $match
168
 * @return void
169
 */
170
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

170
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...
171
{
172
    global $criteria;
173
174
    switch ($match) {
175
        case XOOPS_MATCH_START:
176
            $criteria->add(new \Criteria($name, $ret . '%', 'LIKE'));
177
            break;
178
        case XOOPS_MATCH_END:
179
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
180
            break;
181
        case XOOPS_MATCH_EQUAL:
182
            $criteria->add(new \Criteria($name, $ret));
183
            break;
184
        case XOOPS_MATCH_CONTAIN:
185
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
186
            break;
187
    }
188
}
189