These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
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 XOOPS Project (https://xoops.org) |
||
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 | */ |
||
19 | include dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'mainfile.php'; |
||
20 | //require_once __DIR__ . '/header.php'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
21 | //global $pathIcon16; |
||
22 | |||
23 | global $xoopsModule; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
24 | $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); |
||
25 | |||
26 | $op = (isset($_POST['op']) && $_POST['op'] === 'submit') ? 'submit' : 'form'; |
||
27 | |||
28 | if ($op === 'form') { |
||
29 | $GLOBALS['xoopsOption']['template_main'] = 'xoopsmembers_searchform.html'; |
||
30 | include XOOPS_ROOT_PATH . '/header.php'; |
||
31 | |||
32 | $memberHandler = xoops_getHandler('member'); |
||
33 | $total = $memberHandler->getUserCount(new Criteria('level', 0, '>')); |
||
34 | |||
35 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
36 | |||
37 | $form = new XoopsThemeForm('', 'searchform', 'index.php'); |
||
38 | $uname_text = new XoopsFormText('', 'user_uname', 30, 60); |
||
39 | $uname_match = new XoopsFormSelectMatchOption('', 'user_uname_match'); |
||
40 | $uname_tray = new XoopsFormElementTray(_XO_LA_UNAME, ' '); |
||
41 | $uname_tray->addElement($uname_match); |
||
42 | $uname_tray->addElement($uname_text); |
||
43 | $form->addElement($uname_tray); |
||
44 | |||
45 | $name_text = new XoopsFormText('', 'user_name', 30, 60); |
||
46 | $name_match = new XoopsFormSelectMatchOption('', 'user_name_match'); |
||
47 | $name_tray = new XoopsFormElementTray(_XO_LA_REALNAME, ' '); |
||
48 | $name_tray->addElement($name_match); |
||
49 | $name_tray->addElement($name_text); |
||
50 | $form->addElement($name_tray); |
||
51 | |||
52 | $email_text = new XoopsFormText('', 'user_email', 30, 60); |
||
53 | $email_match = new XoopsFormSelectMatchOption('', 'user_email_match'); |
||
54 | $email_tray = new XoopsFormElementTray(_XO_LA_EMAIL, ' '); |
||
55 | $email_tray->addElement($email_match); |
||
56 | $email_tray->addElement($email_text); |
||
57 | $form->addElement($email_tray); |
||
58 | |||
59 | $form->addElement(new XoopsFormText(_XO_LA_URLC, 'user_url', 30, 100)); |
||
60 | |||
61 | $icq_text = new XoopsFormText('', 'user_icq', 30, 100); |
||
62 | $icq_match = new XoopsFormSelectMatchOption('', 'user_icq_match'); |
||
63 | $icq_tray = new XoopsFormElementTray(_XO_LA_ICQ, ' '); |
||
64 | $icq_tray->addElement($icq_match); |
||
65 | $icq_tray->addElement($icq_text); |
||
66 | $form->addElement($icq_tray); |
||
67 | |||
68 | $aim_text = new XoopsFormText('', 'user_aim', 30, 100); |
||
69 | $aim_match = new XoopsFormSelectMatchOption('', 'user_aim_match'); |
||
70 | $aim_tray = new XoopsFormElementTray(_XO_LA_AIM, ' '); |
||
71 | $aim_tray->addElement($aim_match); |
||
72 | $aim_tray->addElement($aim_text); |
||
73 | $form->addElement($aim_tray); |
||
74 | |||
75 | $yim_text = new XoopsFormText('', 'user_yim', 30, 100); |
||
76 | $yim_match = new XoopsFormSelectMatchOption('', 'user_yim_match'); |
||
77 | $yim_tray = new XoopsFormElementTray(_XO_LA_YIM, ' '); |
||
78 | $yim_tray->addElement($yim_match); |
||
79 | $yim_tray->addElement($yim_text); |
||
80 | $form->addElement($yim_tray); |
||
81 | |||
82 | $msnm_text = new XoopsFormText('', 'user_msnm', 30, 100); |
||
83 | $msnm_match = new XoopsFormSelectMatchOption('', 'user_msnm_match'); |
||
84 | $msnm_tray = new XoopsFormElementTray(_XO_LA_MSNM, ' '); |
||
85 | $msnm_tray->addElement($msnm_match); |
||
86 | $msnm_tray->addElement($msnm_text); |
||
87 | $form->addElement($msnm_tray); |
||
88 | |||
89 | $form->addElement(new XoopsFormText(_XO_LA_LOCATION, 'user_from', 30, 100)); |
||
90 | $form->addElement(new XoopsFormText(_XO_LA_OCCUPATION, 'user_occ', 30, 100)); |
||
91 | $form->addElement(new XoopsFormText(_XO_LA_INTEREST, 'user_intrest', 30, 100)); |
||
92 | $form->addElement(new XoopsFormText(_XO_LA_LASTLOGMORE, 'user_lastlog_more', 10, 5)); |
||
93 | $form->addElement(new XoopsFormText(_XO_LA_LASTLOGLESS, 'user_lastlog_less', 10, 5)); |
||
94 | $form->addElement(new XoopsFormText(_XO_LA_REGMORE, 'user_reg_more', 10, 5)); |
||
95 | $form->addElement(new XoopsFormText(_XO_LA_REGLESS, 'user_reg_less', 10, 5)); |
||
96 | $form->addElement(new XoopsFormText(_XO_LA_POSTSMORE, 'user_posts_more', 10, 5)); |
||
97 | $form->addElement(new XoopsFormText(_XO_LA_POSTSLESS, 'user_posts_less', 10, 5)); |
||
98 | |||
99 | $sort_select = new XoopsFormSelect(_XO_LA_SORT, 'user_sort'); |
||
100 | $sort_select->addOptionArray(array( |
||
101 | 'uname' => _XO_LA_UNAME, |
||
102 | 'email' => _XO_LA_EMAIL, |
||
103 | 'last_login' => _XO_LA_LASTLOGIN, |
||
104 | 'user_regdate' => _XO_LA_REGDATE, |
||
105 | 'posts' => _XO_LA_POSTS |
||
106 | )); |
||
107 | $form->addElement($sort_select); |
||
108 | |||
109 | $order_select = new XoopsFormSelect(_XO_LA_ORDER, 'user_order'); |
||
110 | $order_select->addOptionArray(array('ASC' => _XO_LA_ASC, 'DESC' => _XO_LA_DESC)); |
||
111 | $form->addElement($order_select); |
||
112 | |||
113 | $form->addElement(new XoopsFormText(_XO_LA_LIMIT, 'limit', 6, 2)); |
||
114 | $form->addElement(new XoopsFormHidden('op', 'submit')); |
||
115 | $form->addElement(new XoopsFormButton('', 'user_submit', _SUBMIT, 'submit')); |
||
116 | $form->assign($xoopsTpl); |
||
117 | $xoopsTpl->assign('totalmember', $total); |
||
118 | } |
||
119 | |||
120 | if ($op === 'submit') { |
||
121 | $GLOBALS['xoopsOption']['template_main'] = 'xoopsmembers_searchresults.html'; |
||
122 | include XOOPS_ROOT_PATH . '/header.php'; |
||
123 | |||
124 | $iamadmin = $xoopsUserIsAdmin; |
||
125 | $myts = MyTextSanitizer::getInstance(); |
||
126 | $criteria = new CriteriaCompo(); |
||
127 | |||
128 | 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. ![]() |
|||
129 | $match = (!empty($_POST['user_uname_match'])) ? (int)$_POST['user_uname_match'] : XOOPS_MATCH_START; |
||
130 | $ret = $myts->addSlashes(trim($_POST['user_uname'])); |
||
131 | xoops_Criteria($criteria, 'uname', $ret, $match); |
||
132 | } |
||
133 | |||
134 | 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. ![]() |
|||
135 | $match = (!empty($_POST['user_name_match'])) ? (int)$_POST['user_name_match'] : XOOPS_MATCH_START; |
||
136 | $ret = $myts->addSlashes(trim($_POST['user_uname'])); |
||
137 | xoops_Criteria($criteria, 'name', $ret, $match); |
||
138 | } |
||
139 | |||
140 | if (!empty($_POST['user_email'])) { |
||
141 | $match = (!empty($_POST['user_email_match'])) ? (int)$_POST['user_email_match'] : XOOPS_MATCH_START; |
||
142 | $ret = $myts->addSlashes(trim($_POST['user_email'])); |
||
143 | xoops_Criteria($criteria, 'name', $ret, $match); |
||
144 | if (!$iamadmin) { |
||
145 | $criteria->add(new Criteria('user_viewemail', 1)); |
||
146 | } |
||
147 | } |
||
148 | |||
149 | 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. ![]() |
|||
150 | $url = formatURL(trim($_POST['user_url'])); |
||
151 | $criteria->add(new Criteria('url', $myts->addSlashes($url) . '%', 'LIKE')); |
||
152 | } |
||
153 | |||
154 | 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. ![]() |
|||
155 | $match = (!empty($_POST['user_icq_match'])) ? (int)$_POST['user_icq_match'] : XOOPS_MATCH_START; |
||
156 | $ret = $myts->addSlashes(trim($_POST['user_icq'])); |
||
157 | xoops_Criteria($criteria, 'user_icq', $ret, $match); |
||
158 | } |
||
159 | |||
160 | 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. ![]() |
|||
161 | $match = (!empty($_POST['user_aim_match'])) ? (int)$_POST['user_aim_match'] : XOOPS_MATCH_START; |
||
162 | $ret = $myts->addSlashes(trim($_POST['user_aim'])); |
||
163 | xoops_Criteria($criteria, 'user_aim', $ret, $match); |
||
164 | } |
||
165 | |||
166 | 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. ![]() |
|||
167 | $match = (!empty($_POST['user_yim_match'])) ? (int)$_POST['user_yim_match'] : XOOPS_MATCH_START; |
||
168 | $ret = $myts->addSlashes(trim($_POST['user_yim'])); |
||
169 | xoops_Criteria($criteria, 'user_yim', $ret, $match); |
||
170 | } |
||
171 | |||
172 | 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. ![]() |
|||
173 | $match = (!empty($_POST['user_msnm_match'])) ? (int)$_POST['user_msnm_match'] : XOOPS_MATCH_START; |
||
174 | $ret = $myts->addSlashes(trim($_POST['user_msnm'])); |
||
175 | xoops_Criteria($criteria, 'user_msnm', $ret, $match); |
||
176 | } |
||
177 | |||
178 | 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. ![]() |
|||
179 | $criteria->add(new Criteria('user_from', '%' . $myts->addSlashes(trim($_POST['user_from'])) . '%', 'LIKE')); |
||
180 | } |
||
181 | |||
182 | 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. ![]() |
|||
183 | $criteria->add(new Criteria('user_intrest', '%' . $myts->addSlashes(trim($_POST['user_intrest'])) . '%', 'LIKE')); |
||
184 | } |
||
185 | |||
186 | 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. ![]() |
|||
187 | $criteria->add(new Criteria('user_occ', '%' . $myts->addSlashes(trim($_POST['user_occ'])) . '%', 'LIKE')); |
||
188 | } |
||
189 | |||
190 | 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. ![]() |
|||
191 | $f_user_lastlog_more = (int)trim($_POST['user_lastlog_more']); |
||
192 | $time = time() - (60 * 60 * 24 * $f_user_lastlog_more); |
||
193 | if ($time > 0) { |
||
194 | $criteria->add(new Criteria('last_login', $time, '<')); |
||
195 | } |
||
196 | } |
||
197 | |||
198 | 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. ![]() |
|||
199 | $f_user_lastlog_less = (int)trim($_POST['user_lastlog_less']); |
||
200 | $time = time() - (60 * 60 * 24 * $f_user_lastlog_less); |
||
201 | if ($time > 0) { |
||
202 | $criteria->add(new Criteria('last_login', $time, '>')); |
||
203 | } |
||
204 | } |
||
205 | |||
206 | 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. ![]() |
|||
207 | $f_user_reg_more = (int)trim($_POST['user_reg_more']); |
||
208 | $time = time() - (60 * 60 * 24 * $f_user_reg_more); |
||
209 | if ($time > 0) { |
||
210 | $criteria->add(new Criteria('user_regdate', $time, '<')); |
||
211 | } |
||
212 | } |
||
213 | |||
214 | 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. ![]() |
|||
215 | $f_user_reg_less = (int)$_POST['user_reg_less']; |
||
216 | $time = time() - (60 * 60 * 24 * $f_user_reg_less); |
||
217 | if ($time > 0) { |
||
218 | $criteria->add(new Criteria('user_regdate', $time, '>')); |
||
219 | } |
||
220 | } |
||
221 | |||
222 | 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. ![]() |
|||
223 | $criteria->add(new Criteria('posts', (int)$_POST['user_posts_more'], '>')); |
||
224 | } |
||
225 | |||
226 | 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. ![]() |
|||
227 | $criteria->add(new Criteria('posts', (int)$_POST['user_posts_less'], '<')); |
||
228 | } |
||
229 | |||
230 | $criteria->add(new Criteria('level', 0, '>')); |
||
231 | $validsort = array('uname', 'email', 'last_login', 'user_regdate', 'posts'); |
||
232 | $sort = (!in_array($_POST['user_sort'], $validsort)) ? 'uname' : $_POST['user_sort']; |
||
233 | $order = 'ASC'; |
||
234 | if (isset($_POST['user_order']) && $_POST['user_order'] === 'DESC') { |
||
235 | $order = 'DESC'; |
||
236 | } |
||
237 | $limit = (!empty($_POST['limit'])) ? (int)$_POST['limit'] : 20; |
||
238 | if ($limit == 0 || $limit > 50) { |
||
239 | $limit = 50; |
||
240 | } |
||
241 | |||
242 | $start = (!empty($_POST['start'])) ? (int)$_POST['start'] : 0; |
||
243 | $memberHandler = xoops_getHandler('member'); |
||
244 | $total = $memberHandler->getUserCount($criteria); |
||
245 | $xoopsTpl->assign('total_found', $total); |
||
246 | |||
247 | if ($total == 0) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
248 | } elseif ($start < $total) { |
||
249 | if ($iamadmin) { |
||
250 | $xoopsTpl->assign('is_admin', true); |
||
251 | } |
||
252 | $criteria->setSort($sort); |
||
253 | $criteria->setOrder($order); |
||
254 | $criteria->setStart($start); |
||
255 | $criteria->setLimit($limit); |
||
256 | $foundusers = $memberHandler->getUsers($criteria, true); |
||
257 | foreach (array_keys($foundusers) as $j) { |
||
258 | $userdata['avatar'] = $foundusers[$j]->getVar('user_avatar') ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar('user_avatar') . '" alt="">' : ' '; |
||
259 | $userdata['realname'] = $foundusers[$j]->getVar('name') ?: ' '; |
||
260 | $userdata['name'] = $foundusers[$j]->getVar('uname'); |
||
261 | $userdata['id'] = $foundusers[$j]->getVar('uid'); |
||
262 | if ($foundusers[$j]->getVar('user_viewemail') == 1 || $iamadmin) { |
||
263 | $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>'; |
||
264 | } else { |
||
265 | $userdata['email'] = ' '; |
||
266 | } |
||
267 | if ($xoopsUser) { |
||
268 | $userdata['pmlink'] = '<a href="javascript:openWithSelfMain(\'' |
||
269 | . XOOPS_URL |
||
270 | . '/pmlite.php?send2=1&to_userid=' |
||
271 | . $foundusers[$j]->getVar('uid') |
||
272 | . '\',\'pmlite\',450,370);"><img src="' |
||
273 | . XOOPS_URL |
||
274 | . '/images/icons/pm.gif" border="0" alt="' |
||
275 | . sprintf(_SENDPMTO, $foundusers[$j]->getVar('uname', 'e')) |
||
276 | . '"></a>'; |
||
277 | } else { |
||
278 | $userdata['pmlink'] = ' '; |
||
279 | } |
||
280 | if ($foundusers[$j]->getVar('url', 'e') != '') { |
||
281 | $userdata['website'] = '<a href="' . $foundusers[$j]->getVar('url', 'e') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '"></a>'; |
||
282 | } else { |
||
283 | $userdata['website'] = ' '; |
||
284 | } |
||
285 | $userdata['registerdate'] = formatTimestamp($foundusers[$j]->getVar('user_regdate'), 's'); |
||
286 | if ($foundusers[$j]->getVar('last_login') != 0) { |
||
287 | $userdata['lastlogin'] = formatTimestamp($foundusers[$j]->getVar('last_login'), 'm'); |
||
288 | } else { |
||
289 | $userdata['lastlogin'] = ' '; |
||
290 | } |
||
291 | $userdata['posts'] = $foundusers[$j]->getVar('posts'); |
||
292 | if ($iamadmin) { |
||
293 | $userdata['adminlink'] = '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&uid=' . $foundusers[$j]->getVar('uid') . '&op=users_edit">' . '<img src=' . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'>" |
||
294 | |||
295 | . '</a> | <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&op=users_delete&uid=' . $foundusers[$j]->getVar('uid') . '">' . '<img src=' . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>" . '</a>'; |
||
296 | } |
||
297 | $xoopsTpl->append('users', $userdata); |
||
298 | } |
||
299 | |||
300 | $totalpages = ceil($total / $limit); |
||
301 | if ($totalpages > 1) { |
||
302 | $hiddenform = '<form name="findnext" action="index.php" method="post">'; |
||
303 | foreach ($_POST as $k => $v) { |
||
304 | $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars($k) . '" value="' . $myts->previewTarea($v) . '">'; |
||
305 | } |
||
306 | if (!isset($_POST['limit'])) { |
||
307 | $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '">'; |
||
308 | } |
||
309 | if (!isset($_POST['start'])) { |
||
310 | $hiddenform .= '<input type="hidden" name="start" value="' . $start . '">'; |
||
311 | } |
||
312 | $prev = $start - $limit; |
||
313 | if ($start - $limit >= 0) { |
||
314 | $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _XO_LA_PREVIOUS . '</a> '; |
||
315 | } |
||
316 | $counter = 1; |
||
317 | $currentpage = ($start + $limit) / $limit; |
||
318 | while ($counter <= $totalpages) { |
||
319 | if ($counter == $currentpage) { |
||
320 | $hiddenform .= '<b>' . $counter . '</b> '; |
||
321 | } elseif (($counter > $currentpage - 4 && $counter < $currentpage + 4) || $counter == 1 |
||
322 | || $counter == $totalpages) { |
||
323 | if ($counter == $totalpages && $currentpage < $totalpages - 4) { |
||
324 | $hiddenform .= '... '; |
||
325 | } |
||
326 | $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ($counter - 1) * $limit . ';document.findnext.submit();">' . $counter . '</a> '; |
||
327 | if ($counter == 1 && $currentpage > 5) { |
||
328 | $hiddenform .= '... '; |
||
329 | } |
||
330 | } |
||
331 | $counter++; |
||
332 | } |
||
333 | $next = $start + $limit; |
||
334 | if ($total > $next) { |
||
335 | $hiddenform .= ' <a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _XO_LA_NEXT . '</a>'; |
||
336 | } |
||
337 | $hiddenform .= '</form>'; |
||
338 | $xoopsTpl->assign('pagenav', $hiddenform); |
||
339 | $xoopsTpl->assign('lang_numfound', sprintf(_XO_LA_USERSFOUND, $total)); |
||
340 | } |
||
341 | } |
||
342 | } |
||
343 | |||
344 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
345 | exit(); |
||
346 | |||
347 | /** |
||
348 | * xoops_Criteria() |
||
349 | * |
||
350 | * @param $criteria |
||
351 | * @param string $name |
||
352 | * @param string $ret |
||
353 | * @param string $match |
||
354 | */ |
||
355 | function xoops_Criteria(&$criteria, $name = '', $ret = '', $match = '') |
||
356 | { |
||
357 | global $criteria; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
358 | |||
359 | switch ($match) { |
||
360 | case XOOPS_MATCH_START: |
||
361 | $criteria->add(new Criteria($name, $ret . '%', 'LIKE')); |
||
362 | break; |
||
363 | case XOOPS_MATCH_END: |
||
364 | $criteria->add(new Criteria($name, '%' . $ret . '%', 'LIKE')); |
||
365 | break; |
||
366 | case XOOPS_MATCH_EQUAL: |
||
367 | $criteria->add(new Criteria($name, $ret)); |
||
368 | break; |
||
369 | case XOOPS_MATCH_CONTAIN: |
||
370 | $criteria->add(new Criteria($name, '%' . $ret . '%', 'LIKE')); |
||
371 | break; |
||
372 | } |
||
373 | } |
||
374 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.