Passed
Push — master ( 5b6aeb...d1690a )
by Michael
03:51 queued 01:58
created

index.php (2 issues)

Labels
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
$pathIcon16    = \Xmf\Module\Admin::iconUrl('', 16);
28
29
30
	
31
$memberHandler = xoops_getHandler('member');
32
    $total = $memberHandler->getUserCount( new Criteria( 'level', 0, '>' ) );
0 ignored issues
show
The method getUserCount() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

32
    $total = $memberHandler->/** @scrutinizer ignore-call */ getUserCount( new Criteria( 'level', 0, '>' ) );
Loading history...
33
34
    $iamadmin = $xoopsUserIsAdmin;
35
$myts     = \MyTextSanitizer::getInstance();
36
$criteria = new \CriteriaCompo();
37
38
$criteria->add(new \Criteria('level', 0, '>'));
39
$validsort = ['uname', 'name', 'last_login', 'user_regdate', 'posts'];
40
$sort      = (!in_array($helper->getModule()->getInfo('sortmembers'), $validsort)) ? 'uname' : $helper->getModule()->getInfo('sortmembers');
41
    
42
	$order = 'ASC';
43
$temp  = $helper->getModule()->getInfo('membersorder');
44
if (isset($temp) && 'DESC' == $temp) {
45
        $order = 'DESC';
46
    }
47
    $limit = \Xmf\Request::getInt('limit', 20, 'POST');
48
if (0 == $limit || $limit > 50) {
49
        $limit = 50;
50
    }
51
52
    $start         = \Xmf\Request::getInt('start', 0, 'POST');
53
    $memberHandler = xoops_getHandler('member');
54
    $total         = $memberHandler->getUserCount($criteria);
55
	$xoopsTpl->assign( 'totalmember', $total );
56
	
57
	//Show last member
58
	$result = $GLOBALS['xoopsDB']->query("SELECT uid, uname FROM ".$GLOBALS['xoopsDB']->prefix("users")." WHERE level > 0 ORDER BY uid DESC",1,0);
59
	list($latestuid, $latestuser) = $GLOBALS['xoopsDB']->fetchRow($result);
60
	$xoopsTpl->assign('latestmember', " <a href='".XOOPS_URL."/userinfo.php?uid=".$latestuid."'>".$latestuser."</a>");
61
	$xoopsTpl->assign('welcomemessage', $xoopsModuleConfig['welcomemessage']);
62
63
if (0 == $total) {
64
    } elseif ( $start < $total ) {
65
        if ( $iamadmin ) {
66
            $xoopsTpl->assign( 'is_admin', true );
67
        }
68
        $criteria->setSort( $sort );
69
        $criteria->setOrder( $order );
70
        $criteria->setStart( $start );
71
        $criteria->setLimit( $limit );
72
        $foundusers = $memberHandler->getUsers($criteria, true);
0 ignored issues
show
The method getUsers() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

72
        /** @scrutinizer ignore-call */ 
73
        $foundusers = $memberHandler->getUsers($criteria, true);
Loading history...
73
        foreach ( array_keys( $foundusers ) as $j ) {
74
            $userdata['avatar']   = $foundusers[$j]->getVar('user_avatar') ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar('user_avatar') . '" alt="">' : '&nbsp;';
75
        $userdata['realname'] = $foundusers[$j]->getVar('name') ?: '&nbsp;';
76
        $userdata['name']     = $foundusers[$j]->getVar('uname');
77
        $userdata['id']       = $foundusers[$j]->getVar('uid');
78
        if (1 == $foundusers[$j]->getVar('user_viewemail') || $iamadmin) {
79
                $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>';
80
            } else {
81
            $userdata['email'] = '&nbsp;';
82
            }
83
            if ( $xoopsUser ) {
84
            $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>';
85
            } else {
86
            $userdata['pmlink'] = '&nbsp;';
87
            }
88
        if ('' != $foundusers[$j]->getVar('url', 'e')) {
89
                $userdata['website'] = '<a href="' . $foundusers[$j]->getVar('url', 'e') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '"></a>';
90
            } else {
91
            $userdata['website'] = '&nbsp;';
92
            }
93
        $userdata['registerdate'] = formatTimestamp($foundusers[$j]->getVar('user_regdate'), 's');
94
        if (0 != $foundusers[$j]->getVar('last_login')) {
95
            $userdata['lastlogin'] = formatTimestamp($foundusers[$j]->getVar('last_login'), 'm');
96
            } else {
97
            $userdata['lastlogin'] = '&nbsp;';
98
            }
99
        $userdata['posts'] = $foundusers[$j]->getVar('posts');
100
            if ( $iamadmin ) {
101
                $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 . "'>"
102
103
                                         . '</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>';
104
            }
105
        $xoopsTpl->append('users', $userdata);
106
        }
107
108
        $totalpages = ceil( $total / $limit );
109
        if ( $totalpages > 1 ) {
110
            $hiddenform = '<form name="findnext" action="index.php" method="post">';
111
            foreach ( $_POST as $k => $v ) {
112
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars($k) . '" value="' . $myts->previewTarea($v) . '">';
113
            }
114
            if ( !isset( $_POST['limit'] ) ) {
115
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '">';
116
            }
117
            if ( !isset( $_POST['start'] ) ) {
118
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '">';
119
            }
120
            $prev = $start - $limit;
121
            if ( $start - $limit >= 0 ) {
122
            $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_PREVIOUS . '</a>&nbsp;';
123
            }
124
            $counter = 1;
125
            $currentpage = ( $start + $limit ) / $limit;
126
            while ( $counter <= $totalpages ) {
127
                if ( $counter == $currentpage ) {
128
                    $hiddenform .= '<b>' . $counter . '</b> ';
129
            } elseif (($counter > $currentpage - 4 && $counter < $currentpage + 4) || 1 == $counter || $counter == $totalpages) {
130
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
131
                        $hiddenform .= '... ';
132
                    }
133
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
134
                if (1 == $counter && $currentpage > 5) {
135
                        $hiddenform .= '... ';
136
                    }
137
                }
138
                $counter++;
139
            }
140
            $next = $start + $limit;
141
            if ( $total > $next ) {
142
            $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_NEXT . '</a>';
143
            }
144
            $hiddenform .= '</form>';
145
            $xoopsTpl->assign( 'pagenav', $hiddenform );
146
        $xoopsTpl->assign('lang_numfound', sprintf(_MD_XOOPSMEMBERS_USERSFOUND, $total));
147
        }
148
    }
149
150
include 'footer.php';
151
include_once XOOPS_ROOT_PATH . '/footer.php';
152
exit();
153
154
/**
155
 * xoops_Criteria()
156
 *
157
 * @param        $criteria
158
 * @param string $name
159
 * @param string $ret
160
 * @param string $match
161
 * @return void
162
 */
163
function xoops_Criteria(&$criteria, $name = '', $ret = '', $match = '')
164
{
165
    global $criteria;
166
167
    switch ( $match ) {
168
        case XOOPS_MATCH_START:
169
            $criteria->add(new \Criteria($name, $ret . '%', 'LIKE'));
170
            break;
171
        case XOOPS_MATCH_END:
172
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
173
            break;
174
        case XOOPS_MATCH_EQUAL:
175
            $criteria->add(new \Criteria($name, $ret));
176
            break;
177
        case XOOPS_MATCH_CONTAIN:
178
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
179
            break;
180
    }
181
}
182