Completed
Push — master ( 9803ae...780aff )
by Michael
27s queued 10s
created

index.php (17 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Xoops Members Module
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
13
 * @license http://www.fsf.org/copyleft/gpl.html GNU public license
14
 * @package Xoops Members
15
 * @since 2.3.0
16
 * @author onokazu
17
 * @author John Neill
18
 * @version $Id: index.php catzwolf$
19
 */
20
include dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR . 'mainfile.php';
21
//include_once 'header.php';
22
//global $pathIcon16;
23
24
global $xoopsModule;
25
$pathIcon16 = $xoopsModule->getInfo('icons16');
26
27
    $xoopsOption['template_main'] = 'xoopsmembers_index.tpl';
28
    include XOOPS_ROOT_PATH . '/header.php';
29
30
    $iamadmin = $xoopsUserIsAdmin;
31
    $myts = &MyTextSanitizer::getInstance();
32
    $criteria = new CriteriaCompo();
33
34 View Code Duplication
    if ( !empty( $_POST['user_uname'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
        $match = ( !empty( $_POST['user_uname_match'] ) ) ? intval( $_POST['user_uname_match'] ) : XOOPS_MATCH_START;
36
        $ret = $myts->addSlashes( trim( $_POST['user_uname'] ) );
37
        xoops_Criteria( $criteria, 'uname', $ret, $match );
38
    }
39
40 View Code Duplication
    if ( !empty( $_POST['user_name'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
        $match = ( !empty( $_POST['user_name_match'] ) ) ? intval( $_POST['user_name_match'] ) : XOOPS_MATCH_START;
42
        $ret = $myts->addSlashes( trim( $_POST['user_uname'] ) );
43
        xoops_Criteria( $criteria, 'name', $ret, $match );
44
    }
45
46 View Code Duplication
    if ( !empty( $_POST['user_email'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
        $match = ( !empty( $_POST['user_email_match'] ) ) ? intval( $_POST['user_email_match'] ) : XOOPS_MATCH_START;
48
        $ret = $myts->addSlashes( trim( $_POST['user_email'] ) );
49
        xoops_Criteria( $criteria, 'name', $ret, $match );
50
        if ( !$iamadmin ) {
51
            $criteria->add( new Criteria( 'user_viewemail', 1 ) );
52
        }
53
    }
54
55 View Code Duplication
    if ( !empty( $_POST['user_url'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
        $url = formatURL( trim( $_POST['user_url'] ) );
57
        $criteria->add( new Criteria( 'url', $myts->addSlashes( $url ) . '%', 'LIKE' ) );
58
    }
59
60 View Code Duplication
    if ( !empty( $_POST['user_icq'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
        $match = ( !empty( $_POST['user_icq_match'] ) ) ? intval( $_POST['user_icq_match'] ) : XOOPS_MATCH_START;
62
        $ret = $myts->addSlashes( trim( $_POST['user_icq'] ) );
63
        xoops_Criteria( $criteria, 'user_icq', $ret, $match );
64
    }
65
66 View Code Duplication
    if ( !empty( $_POST['user_aim'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
        $match = ( !empty( $_POST['user_aim_match'] ) ) ? intval( $_POST['user_aim_match'] ) : XOOPS_MATCH_START;
68
        $ret = $myts->addSlashes( trim( $_POST['user_aim'] ) );
69
        xoops_Criteria( $criteria, 'user_aim', $ret, $match );
70
    }
71
72 View Code Duplication
    if ( !empty( $_POST['user_yim'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
        $match = ( !empty( $_POST['user_yim_match'] ) ) ? intval( $_POST['user_yim_match'] ) : XOOPS_MATCH_START;
74
        $ret = $myts->addSlashes( trim( $_POST['user_yim'] ) );
75
        xoops_Criteria( $criteria, 'user_yim', $ret, $match );
76
    }
77
78 View Code Duplication
    if ( !empty( $_POST['user_msnm'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
79
        $match = ( !empty( $_POST['user_msnm_match'] ) ) ? intval( $_POST['user_msnm_match'] ) : XOOPS_MATCH_START;
80
        $ret = $myts->addSlashes( trim( $_POST['user_msnm'] ) );
81
        xoops_Criteria( $criteria, 'user_msnm', $ret, $match );
82
    }
83
84 View Code Duplication
    if ( !empty( $_POST['user_from'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
        $criteria->add( new Criteria( 'user_from', '%' . $myts->addSlashes( trim( $_POST['user_from'] ) ) . '%', 'LIKE' ) );
86
    }
87
88 View Code Duplication
    if ( !empty( $_POST['user_intrest'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
        $criteria->add( new Criteria( 'user_intrest', '%' . $myts->addSlashes( trim( $_POST['user_intrest'] ) ) . '%', 'LIKE' ) );
90
    }
91
92 View Code Duplication
    if ( !empty( $_POST['user_occ'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
93
        $criteria->add( new Criteria( 'user_occ', '%' . $myts->addSlashes( trim( $_POST['user_occ'] ) ) . '%', 'LIKE' ) );
94
    }
95
96 View Code Duplication
    if ( !empty( $_POST['user_lastlog_more'] ) && is_numeric( $_POST['user_lastlog_more'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
97
        $f_user_lastlog_more = intval( trim( $_POST['user_lastlog_more'] ) );
98
        $time = time() - ( 60 * 60 * 24 * $f_user_lastlog_more );
99
        if ( $time > 0 ) {
100
            $criteria->add( new Criteria( 'last_login', $time, '<' ) );
101
        }
102
    }
103
104 View Code Duplication
    if ( !empty( $_POST['user_lastlog_less'] ) && is_numeric( $_POST['user_lastlog_less'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
105
        $f_user_lastlog_less = intval( trim( $_POST['user_lastlog_less'] ) );
106
        $time = time() - ( 60 * 60 * 24 * $f_user_lastlog_less );
107
        if ( $time > 0 ) {
108
            $criteria->add( new Criteria( 'last_login', $time, '>' ) );
109
        }
110
    }
111
112 View Code Duplication
    if ( !empty( $_POST['user_reg_more'] ) && is_numeric( $_POST['user_reg_more'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
        $f_user_reg_more = intval( trim( $_POST['user_reg_more'] ) );
114
        $time = time() - ( 60 * 60 * 24 * $f_user_reg_more );
115
        if ( $time > 0 ) {
116
            $criteria->add( new Criteria( 'user_regdate', $time, '<' ) );
117
        }
118
    }
119
120 View Code Duplication
    if ( !empty( $_POST['user_reg_less'] ) && is_numeric( $_POST['user_reg_less'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
121
        $f_user_reg_less = intval( $_POST['user_reg_less'] );
122
        $time = time() - ( 60 * 60 * 24 * $f_user_reg_less );
123
        if ( $time > 0 ) {
124
            $criteria->add( new Criteria( 'user_regdate', $time, '>' ) );
125
        }
126
    }
127
128 View Code Duplication
    if ( isset( $_POST['user_posts_more'] ) && is_numeric( $_POST['user_posts_more'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
129
        $criteria->add( new Criteria( 'posts', intval( $_POST['user_posts_more'] ), '>' ) );
130
    }
131
132 View Code Duplication
    if ( !empty( $_POST['user_posts_less'] ) && is_numeric( $_POST['user_posts_less'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
133
        $criteria->add( new Criteria( 'posts', intval( $_POST['user_posts_less'] ), '<' ) );
134
    }
135
136
    $criteria->add( new Criteria( 'level', 0, '>' ) );
137
    $validsort = array( 'uname', 'email', 'last_login', 'user_regdate', 'posts' );
138
    $sort = ( !in_array( $_POST['user_sort'], $validsort ) ) ? 'uname' : $_POST['user_sort'];
139
    $order = 'ASC';
140
    if ( isset( $_POST['user_order'] ) && $_POST['user_order'] == 'DESC' ) {
141
        $order = 'DESC';
142
    }
143
    $limit = ( !empty( $_POST['limit'] ) ) ? intval( $_POST['limit'] ) : 20;
144
    if ( $limit == 0 || $limit > 50 ) {
145
        $limit = 50;
146
    }
147
148
    $start = ( !empty( $_POST['start'] ) ) ? intval( $_POST['start'] ) : 0;
149
    $member_handler = &xoops_gethandler( 'member' );
150
    $total = $member_handler->getUserCount( $criteria );
151
    $xoopsTpl->assign( 'total_found', $total );
152
153 View Code Duplication
    if ( $total == 0 ) {
154
    } elseif ( $start < $total ) {
155
        if ( $iamadmin ) {
156
            $xoopsTpl->assign( 'is_admin', true );
157
        }
158
        $criteria->setSort( $sort );
159
        $criteria->setOrder( $order );
160
        $criteria->setStart( $start );
161
        $criteria->setLimit( $limit );
162
        $foundusers = &$member_handler->getUsers( $criteria, true );
163
        foreach ( array_keys( $foundusers ) as $j ) {
164
            $userdata["avatar"] = $foundusers[$j]->getVar( 'user_avatar' ) ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar( 'user_avatar' ) . '" alt="" />' : '&nbsp;';
165
            $userdata["realname"] = $foundusers[$j]->getVar( 'name' ) ? $foundusers[$j]->getVar( 'name' ) : '&nbsp;';
166
            $userdata["name"] = $foundusers[$j]->getVar( 'uname' );
167
            $userdata["id"] = $foundusers[$j]->getVar( 'uid' );
168
            if ( $foundusers[$j]->getVar( 'user_viewemail' ) == 1 || $iamadmin ) {
169
                $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>';
170
            } else {
171
                $userdata["email"] = '&nbsp;';
172
            }
173
            if ( $xoopsUser ) {
174
                $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>';
175
            } else {
176
                $userdata["pmlink"] = '&nbsp;';
177
            }
178
            if ( $foundusers[$j]->getVar( 'url', "e" ) != '' ) {
179
                $userdata["website"] = '<a href="' . $foundusers[$j]->getVar( 'url', "e" ) . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '" /></a>';
180
            } else {
181
                $userdata["website"] = '&nbsp;';
182
            }
183
            $userdata["registerdate"] = formatTimeStamp( $foundusers[$j]->getVar( 'user_regdate' ), 's' );
184
            if ( $foundusers[$j]->getVar( 'last_login' ) != 0 ) {
185
                $userdata["lastlogin"] = formatTimeStamp( $foundusers[$j]->getVar( 'last_login' ), "m" );
186
            } else {
187
                $userdata["lastlogin"] = '&nbsp;';
188
            }
189
            $userdata["posts"] = $foundusers[$j]->getVar( 'posts' );
190
            if ( $iamadmin ) {
191
                $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 . "' />"
192
193
                . '</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>';
194
            }
195
            $xoopsTpl->append( "users", $userdata );
196
        }
197
198
        $totalpages = ceil( $total / $limit );
199
        if ( $totalpages > 1 ) {
200
            $hiddenform = '<form name="findnext" action="index.php" method="post">';
201
            foreach ( $_POST as $k => $v ) {
202
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars( $k ) . '" value="' . $myts->previewTarea( $v ) . '" />';
203
            }
204
            if ( !isset( $_POST['limit'] ) ) {
205
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" />';
206
            }
207
            if ( !isset( $_POST['start'] ) ) {
208
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" />';
209
            }
210
            $prev = $start - $limit;
211
            if ( $start - $limit >= 0 ) {
212
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XM_PREVIOUS . '</a>&nbsp;';
213
            }
214
            $counter = 1;
215
            $currentpage = ( $start + $limit ) / $limit;
216
            while ( $counter <= $totalpages ) {
217
                if ( $counter == $currentpage ) {
218
                    $hiddenform .= '<b>' . $counter . '</b> ';
219
                } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) {
220
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
221
                        $hiddenform .= '... ';
222
                    }
223
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
224
                    if ( $counter == 1 && $currentpage > 5 ) {
225
                        $hiddenform .= '... ';
226
                    }
227
                }
228
                $counter++;
229
            }
230
            $next = $start + $limit;
231
            if ( $total > $next ) {
232
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XM_NEXT . '</a>';
233
            }
234
            $hiddenform .= '</form>';
235
            $xoopsTpl->assign( 'pagenav', $hiddenform );
236
            $xoopsTpl->assign( 'lang_numfound', sprintf( _MD_XM_USERSFOUND, $total ) );
237
        }
238
    }
239
240
241
include_once XOOPS_ROOT_PATH . '/footer.php';
242
exit();
243
244
/**
245
 * xoops_Criteria()
246
 *
247
 * @return
248
 */
249 View Code Duplication
function xoops_Criteria( &$criteria, $name = '', $ret = '', $match = '' ) {
250
    global $criteria;
251
252
    switch ( $match ) {
253
        case XOOPS_MATCH_START:
254
            $criteria->add( new Criteria( $name, $ret . '%', 'LIKE' ) );
255
            break;
256
        case XOOPS_MATCH_END:
257
            $criteria->add( new Criteria( $name, '%' . $ret . '%', 'LIKE' ) );
258
            break;
259
        case XOOPS_MATCH_EQUAL:
260
            $criteria->add( new Criteria( $name, $ret ) );
261
            break;
262
        case XOOPS_MATCH_CONTAIN:
263
            $criteria->add( new Criteria( $name, '%' . $ret . '%', 'LIKE' ) );
264
            break;
265
    }
266
}
267