1 | <?php |
---|
2 | |
---|
3 | global $user, $lang, $conf, $errors; |
---|
4 | |
---|
5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | Check Access and exit when user status is not ok | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | check_status(ACCESS_ADMINISTRATOR); |
---|
10 | |
---|
11 | if (!defined('NBC_UAM_PATH')) define('NBC_UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
12 | |
---|
13 | //ini_set('error_reporting', E_ALL); |
---|
14 | //ini_set('display_errors', true); |
---|
15 | |
---|
16 | include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
17 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
18 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
19 | |
---|
20 | load_language('plugin.lang', NBC_UAM_PATH); |
---|
21 | load_language('help/plugin.lang', NBC_UAM_PATH); |
---|
22 | |
---|
23 | $page['global'] = array(); |
---|
24 | $error = array(); |
---|
25 | $UserAdvManager_Password_Test_Score = 0; |
---|
26 | $pattern = '/;/'; |
---|
27 | $replacement = '.'; |
---|
28 | |
---|
29 | $UserAdvManager_MailInfo_Error_Txt = false; |
---|
30 | $UserAdvManager_ConfirmMail_Error_Txt = false; |
---|
31 | $UserAdvManager_Reminder_Error_Txt = false; |
---|
32 | $UserAdvManager_ConfirmMail_Error_Txt1 = false; |
---|
33 | $UserAdvManager_ConfirmMail_Error_Txt2 = false; |
---|
34 | $UserAdvManager_Exclusionlist_Error = false; |
---|
35 | |
---|
36 | // +-----------------------------------------------------------------------+ |
---|
37 | // | Tabssheet | |
---|
38 | // +-----------------------------------------------------------------------+ |
---|
39 | if (!isset($_GET['tab'])) |
---|
40 | $page['tab'] = 'global'; |
---|
41 | else |
---|
42 | $page['tab'] = $_GET['tab']; |
---|
43 | |
---|
44 | $tabsheet = new tabsheet(); |
---|
45 | $tabsheet->add('global', |
---|
46 | l10n('Tab_Global'), |
---|
47 | $my_base_url.'&tab=global'); |
---|
48 | //if (isset($conf_nbc_UserAdvManager[20]) and $conf_nbc_UserAdvManager[20]=='true') |
---|
49 | //{ |
---|
50 | $tabsheet->add('userlist', |
---|
51 | l10n('Tab_UserList'), |
---|
52 | $my_base_url.'&tab=userlist'); |
---|
53 | //} |
---|
54 | $tabsheet->add('usermanager', |
---|
55 | l10n('Tab_UserManager'), |
---|
56 | $my_base_url.'&tab=usermanager'); |
---|
57 | $tabsheet->add('ghosttracker', |
---|
58 | l10n('Tab_GhostTracker'), |
---|
59 | $my_base_url.'&tab=ghosttracker'); |
---|
60 | $tabsheet->select($page['tab']); |
---|
61 | $tabsheet->assign(); |
---|
62 | |
---|
63 | // +-----------------------------------------------------------------------+ |
---|
64 | // | Getting plugin version | |
---|
65 | // +-----------------------------------------------------------------------+ |
---|
66 | $plugin = PluginVer(NBC_UAM_PATH); |
---|
67 | $version = $plugin['version'] ; |
---|
68 | |
---|
69 | // +-----------------------------------------------------------------------+ |
---|
70 | // | Tabssheet select | |
---|
71 | // +-----------------------------------------------------------------------+ |
---|
72 | |
---|
73 | switch ($page['tab']) |
---|
74 | { |
---|
75 | // ************************************************************************* |
---|
76 | // +-----------------------------------------------------------------------+ |
---|
77 | // | Global Config | |
---|
78 | // +-----------------------------------------------------------------------+ |
---|
79 | // ************************************************************************* |
---|
80 | case 'global': |
---|
81 | |
---|
82 | if (isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_Mail_Info']) and isset($_POST['UserAdvManager_No_Casse']) and isset($_POST['UserAdvManager_Username_Char']) and isset($_POST['UserAdvManager_Confirm_Mail']) and isset($_POST['UserAdvManager_No_Comment_Anonymous']) and isset($_POST['UserAdvManager_Password_Enforced']) and isset($_POST['UserAdvManager_AdminPassword_Enforced']) and isset($_POST['UserAdvManager_GhostUser_Tracker'])) |
---|
83 | { |
---|
84 | |
---|
85 | /* General configuration settings */ |
---|
86 | $_POST['UserAdvManager_MailInfo_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_MailInfo_Text'])); |
---|
87 | |
---|
88 | $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text'])); |
---|
89 | |
---|
90 | $_POST['UserAdvManager_GhostTracker_ReminderText'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_GhostTracker_ReminderText'])); |
---|
91 | |
---|
92 | |
---|
93 | /* Control of semicolons - Replaced by dots - Warning message is displayed */ |
---|
94 | if ((preg_match($pattern, $_POST['UserAdvManager_MailInfo_Text'])) or (preg_match($pattern, $_POST['UserAdvManager_GhostTracker_ReminderText'])) or (preg_match($pattern, $_POST['UserAdvManager_ConfirmMail_Text']))) |
---|
95 | { |
---|
96 | if (preg_match($pattern, $_POST['UserAdvManager_MailInfo_Text'])) |
---|
97 | { |
---|
98 | $_POST['UserAdvManager_MailInfo_Text'] = preg_replace($pattern, $replacement, $_POST['UserAdvManager_MailInfo_Text']); |
---|
99 | $UserAdvManager_MailInfo_Error_Txt = true; |
---|
100 | } |
---|
101 | |
---|
102 | if (preg_match($pattern, $_POST['UserAdvManager_ConfirmMail_Text'])) |
---|
103 | { |
---|
104 | $_POST['UserAdvManager_ConfirmMail_Text'] = preg_replace($pattern, $replacement, $_POST['UserAdvManager_ConfirmMail_Text']); |
---|
105 | $UserAdvManager_ConfirmMail_Error_Txt = true; |
---|
106 | } |
---|
107 | |
---|
108 | if (preg_match($pattern, $_POST['UserAdvManager_GhostTracker_ReminderText'])) |
---|
109 | { |
---|
110 | $_POST['UserAdvManager_GhostTracker_ReminderText'] = preg_replace($pattern, $replacement, $_POST['UserAdvManager_GhostTracker_ReminderText']); |
---|
111 | $UserAdvManager_Reminder_Error_Txt = true; |
---|
112 | } |
---|
113 | |
---|
114 | array_push($page['errors'], l10n('mail_text_error')); |
---|
115 | } |
---|
116 | |
---|
117 | /* Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them */ |
---|
118 | if (preg_match('/^[\s]+/', $_POST['UserAdvManager_MailExclusion_List'])) |
---|
119 | { |
---|
120 | array_push($page['errors'], l10n('mail_exclusionlist_error')); |
---|
121 | $UserAdvManager_Exclusionlist_Error = true; |
---|
122 | } |
---|
123 | |
---|
124 | $newconf_nbc_UserAdvManager = |
---|
125 | $_POST['UserAdvManager_Mail_Info'].';' |
---|
126 | .$_POST['UserAdvManager_No_Casse'].';' |
---|
127 | .$_POST['UserAdvManager_Confirm_Mail'].';' |
---|
128 | .(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';' |
---|
129 | .(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';' |
---|
130 | .(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';' |
---|
131 | .$_POST['UserAdvManager_No_Comment_Anonymous'].';' |
---|
132 | .$_POST['UserAdvManager_Username_Char'].';' |
---|
133 | .$_POST['UserAdvManager_Username_List'].';' |
---|
134 | .(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';' |
---|
135 | .$_POST['UserAdvManager_MailInfo_Text'].';' |
---|
136 | .$_POST['UserAdvManager_ConfirmMail_Text'].';' |
---|
137 | .$_POST['UserAdvManager_MailExclusion'].';' |
---|
138 | .$_POST['UserAdvManager_MailExclusion_List'].';' |
---|
139 | .$_POST['UserAdvManager_Password_Enforced'].';' |
---|
140 | .$_POST['UserAdvManager_Password_Score'].';' |
---|
141 | .$_POST['UserAdvManager_AdminPassword_Enforced'].';' |
---|
142 | .$_POST['UserAdvManager_GhostUser_Tracker'].';' |
---|
143 | .$_POST['UserAdvManager_GhostTracker_DayLimit'].';' |
---|
144 | .$_POST['UserAdvManager_GhostTracker_ReminderText'].';' |
---|
145 | .$_POST['UserAdvManager_Add_LastVisit_Column']; |
---|
146 | |
---|
147 | $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager; |
---|
148 | |
---|
149 | $query = ' |
---|
150 | UPDATE '.CONFIG_TABLE.' |
---|
151 | SET value="'.$newconf_nbc_UserAdvManager.'" |
---|
152 | WHERE param="nbc_UserAdvManager" |
---|
153 | LIMIT 1 |
---|
154 | ;'; |
---|
155 | |
---|
156 | pwg_query($query); |
---|
157 | |
---|
158 | |
---|
159 | |
---|
160 | /* Email confirmation settings */ |
---|
161 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'])); |
---|
162 | |
---|
163 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'])); |
---|
164 | |
---|
165 | /* Control of semicolons - Replaced by dots - Warning message displayed */ |
---|
166 | if ((preg_match($pattern, $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'])) or (preg_match($pattern, $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2']))) |
---|
167 | { |
---|
168 | if ((preg_match($pattern, $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1']))) |
---|
169 | { |
---|
170 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'] = preg_replace($pattern, $replacement, $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1']); |
---|
171 | $UserAdvManager_ConfirmMail_Error_Txt1 = true; |
---|
172 | } |
---|
173 | |
---|
174 | if ((preg_match($pattern, $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2']))) |
---|
175 | { |
---|
176 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'] = preg_replace($pattern, $replacement, $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2']); |
---|
177 | |
---|
178 | $UserAdvManager_ConfirmMail_Error_Txt2 = true; |
---|
179 | } |
---|
180 | |
---|
181 | array_push($page['errors'], l10n('mail_text_error')); |
---|
182 | } |
---|
183 | |
---|
184 | $newconf_nbc_UserAdvManager_ConfirmMail = |
---|
185 | $_POST['UserAdvManager_ConfirmMail_TimeOut'].';' |
---|
186 | .$_POST['UserAdvManager_ConfirmMail_Delay'].';' |
---|
187 | .$_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'].';' |
---|
188 | .$_POST['UserAdvManager_ConfirmMail_Remail'].';' |
---|
189 | .$_POST['UserAdvManager_ConfirmMail_ReMail_Txt2']; |
---|
190 | |
---|
191 | $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail; |
---|
192 | |
---|
193 | $query = ' |
---|
194 | UPDATE '.CONFIG_TABLE.' |
---|
195 | SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'" |
---|
196 | WHERE param="nbc_UserAdvManager_ConfirmMail" |
---|
197 | LIMIT 1 |
---|
198 | ;'; |
---|
199 | |
---|
200 | pwg_query($query); |
---|
201 | |
---|
202 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
---|
203 | } |
---|
204 | |
---|
205 | |
---|
206 | /* Testing password enforcement */ |
---|
207 | if (isset($_POST['PasswordTest']) and !is_adviser() and isset($_POST['UserAdvManager_Password_Test']) and !empty($_POST['UserAdvManager_Password_Test'])) |
---|
208 | { |
---|
209 | $UserAdvManager_Password_Test_Score = testpassword($_POST['UserAdvManager_Password_Test']); |
---|
210 | } |
---|
211 | else if (isset($_POST['PasswordTest']) and !is_adviser() and empty($_POST['UserAdvManager_Password_Test'])) |
---|
212 | { |
---|
213 | array_push($page['errors'], l10n('reg_err_login3')); |
---|
214 | } |
---|
215 | |
---|
216 | |
---|
217 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
218 | |
---|
219 | /* Group setting for unvalidated and validated users */ |
---|
220 | $groups[-1] = '---------'; |
---|
221 | $No_Valid = -1; |
---|
222 | $Valid = -1; |
---|
223 | |
---|
224 | /* Check groups list in database */ |
---|
225 | $query = ' |
---|
226 | SELECT id, name |
---|
227 | FROM '.GROUPS_TABLE.' |
---|
228 | ORDER BY name ASC |
---|
229 | ;'; |
---|
230 | |
---|
231 | $result = pwg_query($query); |
---|
232 | |
---|
233 | while ($row = mysql_fetch_assoc($result)) |
---|
234 | { |
---|
235 | $groups[$row['id']] = $row['name']; |
---|
236 | /* configuration value for unvalidated users */ |
---|
237 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == $row['id']) |
---|
238 | { |
---|
239 | $No_Valid = $row['id']; |
---|
240 | } |
---|
241 | /* configuration value for validated users */ |
---|
242 | if (isset($conf_nbc_UserAdvManager[4]) and $conf_nbc_UserAdvManager[4] == $row['id']) |
---|
243 | { |
---|
244 | $Valid = $row['id']; |
---|
245 | } |
---|
246 | } |
---|
247 | |
---|
248 | /* Template initialization for unvalidated users group */ |
---|
249 | $template->assign( |
---|
250 | 'No_Confirm_Group', |
---|
251 | array( |
---|
252 | 'group_options'=> $groups, |
---|
253 | 'group_selected' => $No_Valid |
---|
254 | ) |
---|
255 | ); |
---|
256 | /* Template initialization for validated users group */ |
---|
257 | $template->assign( |
---|
258 | 'Validated_Group', |
---|
259 | array( |
---|
260 | 'group_options'=> $groups, |
---|
261 | 'group_selected' => $Valid |
---|
262 | ) |
---|
263 | ); |
---|
264 | |
---|
265 | /* Status setting for unvalidated and validated users */ |
---|
266 | $status_options[-1] = '------------'; |
---|
267 | $No_Valid_Status = -1; |
---|
268 | $Valid_Status = -1; |
---|
269 | |
---|
270 | /* Get status values */ |
---|
271 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
272 | { |
---|
273 | $status_options[$status] = l10n('user_status_'.$status); |
---|
274 | if (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] == $status) |
---|
275 | { |
---|
276 | $No_Valid_Status = $status; |
---|
277 | } |
---|
278 | |
---|
279 | /* Template initialization for unvalidated users group */ |
---|
280 | $template->assign( |
---|
281 | 'No_Confirm_Status', |
---|
282 | array( |
---|
283 | 'Status_options' => $status_options, |
---|
284 | 'Status_selected' => $No_Valid_Status |
---|
285 | ) |
---|
286 | ); |
---|
287 | } |
---|
288 | |
---|
289 | /* Get status values */ |
---|
290 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
291 | { |
---|
292 | $status_options[$status] = l10n('user_status_'.$status); |
---|
293 | if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status) |
---|
294 | { |
---|
295 | $Valid_Status = $status; |
---|
296 | } |
---|
297 | |
---|
298 | /* Template initialization for unvalidated users group */ |
---|
299 | $template->assign( |
---|
300 | 'Confirm_Status', |
---|
301 | array( |
---|
302 | 'Status_options' => $status_options, |
---|
303 | 'Status_selected' => $Valid_Status |
---|
304 | ) |
---|
305 | ); |
---|
306 | } |
---|
307 | |
---|
308 | $template->assign( |
---|
309 | array( |
---|
310 | /* Plugin version inserted */ |
---|
311 | 'UAM_VERSION' => $version, |
---|
312 | 'UserAdvManager_MAIL_INFO_TRUE' => $conf_nbc_UserAdvManager[0]=='true' ? 'checked="checked"' : '' , |
---|
313 | 'UserAdvManager_MAIL_INFO_FALSE' => $conf_nbc_UserAdvManager[0]=='false' ? 'checked="checked"' : '' , |
---|
314 | 'UserAdvManager_MAILINFO_TEXT' => $conf_nbc_UserAdvManager[10], |
---|
315 | 'UserAdvManager_NO_CASSE_TRUE' => $conf_nbc_UserAdvManager[1]=='true' ? 'checked="checked"' : '' , |
---|
316 | 'UserAdvManager_NO_CASSE_FALSE' => $conf_nbc_UserAdvManager[1]=='false' ? 'checked="checked"' : '' , |
---|
317 | 'UserAdvManager_USERNAME_CHAR_TRUE' => $conf_nbc_UserAdvManager[7]=='true' ? 'checked="checked"' : '' , |
---|
318 | 'UserAdvManager_USERNAME_CHAR_FALSE' => $conf_nbc_UserAdvManager[7]=='false' ? 'checked="checked"' : '' , |
---|
319 | 'UserAdvManager_USERNAME_CHAR_LIST' => $conf_nbc_UserAdvManager[8], |
---|
320 | 'UserAdvManager_CONFIRM_MAIL_TRUE' => $conf_nbc_UserAdvManager[2]=='true' ? 'checked="checked"' : '' , |
---|
321 | 'UserAdvManager_CONFIRM_MAIL_FALSE' => $conf_nbc_UserAdvManager[2]=='false' ? 'checked="checked"' : '' , |
---|
322 | 'UserAdvManager_CONFIRMMAIL_TEXT' => $conf_nbc_UserAdvManager[11], |
---|
323 | 'UserAdvManager_No_Confirm_Group' => $conf_nbc_UserAdvManager[3], |
---|
324 | 'UserAdvManager_Validated_Group' => $conf_nbc_UserAdvManager[4], |
---|
325 | 'UserAdvManager_No_Confirm_Status' => $conf_nbc_UserAdvManager[9], |
---|
326 | 'UserAdvManager_Validated_Status' => $conf_nbc_UserAdvManager[5], |
---|
327 | 'UserAdvManager_NO_COMMENT_ANO_TRUE' => $conf_nbc_UserAdvManager[6]=='true' ? 'checked="checked"' : '' , |
---|
328 | 'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ? 'checked="checked"' : '' , |
---|
329 | 'UserAdvManager_MAILEXCLUSION_TRUE' => $conf_nbc_UserAdvManager[12]=='true' ? 'checked="checked"' : '' , |
---|
330 | 'UserAdvManager_MAILEXCLUSION_FALSE' => $conf_nbc_UserAdvManager[12]=='false' ? 'checked="checked"' : '' , |
---|
331 | 'UserAdvManager_MAILEXCLUSION_LIST' => $conf_nbc_UserAdvManager[13], |
---|
332 | 'UserAdvManager_PASSWORDENF_TRUE' => $conf_nbc_UserAdvManager[14]=='true' ? 'checked="checked"' : '' , |
---|
333 | 'UserAdvManager_PASSWORDENF_FALSE' => $conf_nbc_UserAdvManager[14]=='false' ? 'checked="checked"' : '' , |
---|
334 | 'UserAdvManager_PASSWORD_SCORE' => $conf_nbc_UserAdvManager[15], |
---|
335 | 'UserAdvManager_ADMINPASSWENF_TRUE' => $conf_nbc_UserAdvManager[16]=='true' ? 'checked="checked"' : '' , |
---|
336 | 'UserAdvManager_ADMINPASSWENF_FALSE' => $conf_nbc_UserAdvManager[16]=='false' ? 'checked="checked"' : '' , |
---|
337 | 'UserAdvManager_GHOSTRACKER_TRUE' => $conf_nbc_UserAdvManager[17]=='true' ? 'checked="checked"' : '' , |
---|
338 | 'UserAdvManager_GHOSTRACKER_FALSE' => $conf_nbc_UserAdvManager[17]=='false' ? 'checked="checked"' : '' , |
---|
339 | 'UserAdvManager_GHOSTRACKER_DAYLIMIT' => $conf_nbc_UserAdvManager[18], |
---|
340 | 'UserAdvManager_GHOSTRACKER_REMINDERTEXT' => $conf_nbc_UserAdvManager[19], |
---|
341 | 'UserAdvManager_ADDLASTVISIT_TRUE' => $conf_nbc_UserAdvManager[20]=='true' ? 'checked="checked"' : '' , |
---|
342 | 'UserAdvManager_ADDLASTVISIT_FALSE' => $conf_nbc_UserAdvManager[20]=='false' ? 'checked="checked"' : '' , |
---|
343 | 'UserAdvManager_PASSWORD_TEST_SCORE' => $UserAdvManager_Password_Test_Score, |
---|
344 | 'UserAdvManager_ERROR_REPORTS1' => $UserAdvManager_MailInfo_Error_Txt, |
---|
345 | 'UserAdvManager_ERROR_REPORTS2' => $UserAdvManager_ConfirmMail_Error_Txt, |
---|
346 | 'UserAdvManager_ERROR_REPORTS3' => $UserAdvManager_Reminder_Error_Txt, |
---|
347 | 'UserAdvManager_ERROR_REPORTS4' => $UserAdvManager_Exclusionlist_Error, |
---|
348 | ) |
---|
349 | ); |
---|
350 | |
---|
351 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
352 | |
---|
353 | $template->assign( |
---|
354 | array( |
---|
355 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ? 'checked="checked"' : '' , |
---|
356 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ? 'checked="checked"' : '' , |
---|
357 | 'UserAdvManager_CONFIRMMAIL_DELAY' => $conf_nbc_UserAdvManager_ConfirmMail[1], |
---|
358 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[3]=='true' ? 'checked="checked"' : '', |
---|
359 | 'UserAdvManager_CONFIRMMAIL_REMAIL_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[3]=='false' ? 'checked="checked"' : '', |
---|
360 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TXT1' => $conf_nbc_UserAdvManager_ConfirmMail[2], |
---|
361 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TXT2' => $conf_nbc_UserAdvManager_ConfirmMail[4], |
---|
362 | 'UserAdvManager_ERROR_REPORTS1' => $UserAdvManager_ConfirmMail_Error_Txt1, |
---|
363 | 'UserAdvManager_ERROR_REPORTS2' => $UserAdvManager_ConfirmMail_Error_Txt2, |
---|
364 | ) |
---|
365 | ); |
---|
366 | |
---|
367 | |
---|
368 | if (isset($_POST['audit'])) |
---|
369 | { |
---|
370 | $msg_error1 = ''; |
---|
371 | |
---|
372 | /* username insensible a la casse */ |
---|
373 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true') |
---|
374 | { |
---|
375 | $query = " |
---|
376 | SELECT ".$conf['user_fields']['username']." |
---|
377 | FROM ".USERS_TABLE." p1 |
---|
378 | WHERE EXISTS( |
---|
379 | SELECT ".$conf['user_fields']['username']." |
---|
380 | FROM ".USERS_TABLE." p2 |
---|
381 | WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']." |
---|
382 | AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].") |
---|
383 | ) |
---|
384 | ;"; |
---|
385 | |
---|
386 | $result = pwg_query($query); |
---|
387 | |
---|
388 | while($row = mysql_fetch_assoc($result)) |
---|
389 | { |
---|
390 | $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').stripslashes($row['username']); |
---|
391 | } |
---|
392 | } |
---|
393 | |
---|
394 | $msg_error2 = ''; |
---|
395 | |
---|
396 | /* Username without forbidden keys */ |
---|
397 | if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' ) |
---|
398 | { |
---|
399 | $query = " |
---|
400 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
401 | FROM ".USERS_TABLE." |
---|
402 | ;"; |
---|
403 | |
---|
404 | $result = pwg_query($query); |
---|
405 | |
---|
406 | while($row = mysql_fetch_assoc($result)) |
---|
407 | { |
---|
408 | if (!ValidateUsername(stripslashes($row['username']))) |
---|
409 | $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').stripslashes($row['username']); |
---|
410 | } |
---|
411 | } |
---|
412 | |
---|
413 | $msg_error3 = ''; |
---|
414 | |
---|
415 | /* Email without forbidden domain */ |
---|
416 | if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' ) |
---|
417 | { |
---|
418 | $query = " |
---|
419 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
420 | FROM ".USERS_TABLE." |
---|
421 | ;"; |
---|
422 | |
---|
423 | $result = pwg_query($query); |
---|
424 | |
---|
425 | while($row = mysql_fetch_assoc($result)) |
---|
426 | { |
---|
427 | $conf_nbc_MailExclusion = preg_split("/[\s,]+/",$conf_nbc_UserAdvManager[13]); |
---|
428 | for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) |
---|
429 | { |
---|
430 | $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; |
---|
431 | if (preg_match($pattern, $row['mail_address'])) |
---|
432 | { |
---|
433 | $msg_error3 .= (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
434 | } |
---|
435 | } |
---|
436 | } |
---|
437 | } |
---|
438 | |
---|
439 | if ($msg_error1 <> '') |
---|
440 | $errors[] = $msg_error1.'<br/><br/>'; |
---|
441 | |
---|
442 | if ($msg_error2 <> '') |
---|
443 | $errors[] = $msg_error2.'<br/><br/>'; |
---|
444 | |
---|
445 | if ($msg_error3 <> '') |
---|
446 | $errors[] = $msg_error3.'<br/><br/>'; |
---|
447 | |
---|
448 | if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') |
---|
449 | array_push($page['errors'], l10n('Err_audit_advise')); |
---|
450 | else |
---|
451 | array_push($page['infos'], l10n('UserAdvManager_audit_ok')); |
---|
452 | } |
---|
453 | |
---|
454 | |
---|
455 | // +-----------------------------------------------------------------------+ |
---|
456 | // | errors display | |
---|
457 | // +-----------------------------------------------------------------------+ |
---|
458 | if (isset ($errors) and count($errors) != 0) |
---|
459 | { |
---|
460 | $template->assign('errors',array()); |
---|
461 | foreach ($errors as $error) |
---|
462 | { |
---|
463 | array_push($page['errors'], $error); |
---|
464 | } |
---|
465 | } |
---|
466 | |
---|
467 | // +-----------------------------------------------------------------------+ |
---|
468 | // | templates display | |
---|
469 | // +-----------------------------------------------------------------------+ |
---|
470 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl'); |
---|
471 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
472 | |
---|
473 | break; |
---|
474 | |
---|
475 | |
---|
476 | // ************************************************************************* |
---|
477 | // +-----------------------------------------------------------------------+ |
---|
478 | // | Users list page | |
---|
479 | // +-----------------------------------------------------------------------+ |
---|
480 | // ************************************************************************* |
---|
481 | case 'userlist': |
---|
482 | |
---|
483 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
484 | |
---|
485 | if (isset($conf_nbc_UserAdvManager[20]) and $conf_nbc_UserAdvManager[20]=='true') |
---|
486 | { |
---|
487 | // +-----------------------------------------------------------------------+ |
---|
488 | // | initialization | |
---|
489 | // +-----------------------------------------------------------------------+ |
---|
490 | |
---|
491 | if (!defined('PHPWG_ROOT_PATH')) |
---|
492 | { |
---|
493 | die('Hacking attempt!'); |
---|
494 | } |
---|
495 | |
---|
496 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
497 | |
---|
498 | // +-----------------------------------------------------------------------+ |
---|
499 | // | Check Access and exit when user status is not ok | |
---|
500 | // +-----------------------------------------------------------------------+ |
---|
501 | check_status(ACCESS_ADMINISTRATOR); |
---|
502 | |
---|
503 | |
---|
504 | // +-----------------------------------------------------------------------+ |
---|
505 | // | user list | |
---|
506 | // +-----------------------------------------------------------------------+ |
---|
507 | |
---|
508 | $page['filtered_users'] = get_user_list(); |
---|
509 | |
---|
510 | // +-----------------------------------------------------------------------+ |
---|
511 | // | Template Init | |
---|
512 | // +-----------------------------------------------------------------------+ |
---|
513 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
---|
514 | |
---|
515 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
---|
516 | { |
---|
517 | $start = $_GET['start']; |
---|
518 | } |
---|
519 | else |
---|
520 | { |
---|
521 | $start = 0; |
---|
522 | } |
---|
523 | |
---|
524 | // +-----------------------------------------------------------------------+ |
---|
525 | // | navigation bar | |
---|
526 | // +-----------------------------------------------------------------------+ |
---|
527 | |
---|
528 | $url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start')); |
---|
529 | |
---|
530 | $navbar = create_navigation_bar( |
---|
531 | $url, |
---|
532 | count($page['filtered_users']), |
---|
533 | $start, |
---|
534 | $conf['users_page'] |
---|
535 | ); |
---|
536 | |
---|
537 | $template->assign('NAVBAR', $navbar); |
---|
538 | |
---|
539 | // +-----------------------------------------------------------------------+ |
---|
540 | // | user list | |
---|
541 | // +-----------------------------------------------------------------------+ |
---|
542 | |
---|
543 | $visible_user_list = array(); |
---|
544 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
545 | { |
---|
546 | /* simulate LIMIT $start, $conf['users_page'] */ |
---|
547 | if ($num < $start) |
---|
548 | { |
---|
549 | continue; |
---|
550 | } |
---|
551 | if ($num >= $start + $conf['users_page']) |
---|
552 | { |
---|
553 | break; |
---|
554 | } |
---|
555 | |
---|
556 | $visible_user_list[] = $local_user; |
---|
557 | } |
---|
558 | |
---|
559 | foreach ($visible_user_list as $local_user) |
---|
560 | { |
---|
561 | // dates formating and compare |
---|
562 | $today = date("d-m-Y"); // Get today's date |
---|
563 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
564 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
565 | |
---|
566 | list($regdate, $regtime) = explode(' ', $local_user['lastvisit']); // Explode date and time from registration date |
---|
567 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
568 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
569 | |
---|
570 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
571 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
572 | |
---|
573 | if (isset($conf_nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17]=='true' and $conf_nbc_UserAdvManager[18] <> '') |
---|
574 | { |
---|
575 | if ($deltadays <= ($conf_nbc_UserAdvManager[18]/2)) |
---|
576 | { |
---|
577 | $display = 'green'; |
---|
578 | } |
---|
579 | |
---|
580 | if (($deltadays > ($conf_nbc_UserAdvManager[18]/2)) and ($deltadays < $conf_nbc_UserAdvManager[18])) |
---|
581 | { |
---|
582 | $display = 'orange'; |
---|
583 | } |
---|
584 | |
---|
585 | if ($deltadays >= $conf_nbc_UserAdvManager[18]) |
---|
586 | { |
---|
587 | $display = 'red'; |
---|
588 | } |
---|
589 | |
---|
590 | } |
---|
591 | /* Plugin version inserted */ |
---|
592 | $template->assign( |
---|
593 | array( |
---|
594 | 'UAM_VERSION' => $version, |
---|
595 | ) |
---|
596 | ); |
---|
597 | |
---|
598 | $template->append( |
---|
599 | 'users', |
---|
600 | array( |
---|
601 | 'ID' => $local_user['id'], |
---|
602 | 'USERNAME' => stripslashes($local_user['username']), |
---|
603 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
604 | 'LASTVISIT' => $local_user['lastvisit'], |
---|
605 | 'DAYS' => $deltadays, |
---|
606 | 'DISPLAY' => $display, |
---|
607 | ) |
---|
608 | ); |
---|
609 | } |
---|
610 | // +-----------------------------------------------------------------------+ |
---|
611 | // | errors display | |
---|
612 | // +-----------------------------------------------------------------------+ |
---|
613 | if ( isset ($errors) and count($errors) != 0) |
---|
614 | { |
---|
615 | $template->assign('errors',array()); |
---|
616 | foreach ($errors as $error) |
---|
617 | { |
---|
618 | array_push($page['errors'], $error); |
---|
619 | } |
---|
620 | } |
---|
621 | |
---|
622 | // +-----------------------------------------------------------------------+ |
---|
623 | // | templates display | |
---|
624 | // +-----------------------------------------------------------------------+ |
---|
625 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/userlist.tpl'); |
---|
626 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
627 | } |
---|
628 | else |
---|
629 | { |
---|
630 | array_push($page['infos'], l10n('Err_Userlist_Settings')); |
---|
631 | } |
---|
632 | break; |
---|
633 | |
---|
634 | |
---|
635 | // ************************************************************************* |
---|
636 | // +-----------------------------------------------------------------------+ |
---|
637 | // | Users manager page | |
---|
638 | // +-----------------------------------------------------------------------+ |
---|
639 | // ************************************************************************* |
---|
640 | case 'usermanager': |
---|
641 | |
---|
642 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
643 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
644 | |
---|
645 | if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' and ((isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] <> '-1') or (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] <> '-1')) and isset($conf_nbc_UserAdvManager_ConfirmMail[0]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true') |
---|
646 | { |
---|
647 | // +-----------------------------------------------------------------------+ |
---|
648 | // | initialization | |
---|
649 | // +-----------------------------------------------------------------------+ |
---|
650 | |
---|
651 | if (!defined('PHPWG_ROOT_PATH')) |
---|
652 | { |
---|
653 | die('Hacking attempt!'); |
---|
654 | } |
---|
655 | |
---|
656 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
657 | |
---|
658 | // +-----------------------------------------------------------------------+ |
---|
659 | // | Check Access and exit when user status is not ok | |
---|
660 | // +-----------------------------------------------------------------------+ |
---|
661 | check_status(ACCESS_ADMINISTRATOR); |
---|
662 | |
---|
663 | // +-----------------------------------------------------------------------+ |
---|
664 | // | user list | |
---|
665 | // +-----------------------------------------------------------------------+ |
---|
666 | |
---|
667 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
668 | |
---|
669 | // +-----------------------------------------------------------------------+ |
---|
670 | // | selected users | |
---|
671 | // +-----------------------------------------------------------------------+ |
---|
672 | if (isset($_POST['Del_Selected'])) |
---|
673 | { |
---|
674 | $collection = array(); |
---|
675 | |
---|
676 | switch ($_POST['target']) |
---|
677 | { |
---|
678 | case 'all' : |
---|
679 | { |
---|
680 | foreach($page['filtered_users'] as $local_user) |
---|
681 | { |
---|
682 | array_push($collection, $local_user['id']); |
---|
683 | } |
---|
684 | break; |
---|
685 | } |
---|
686 | case 'selection' : |
---|
687 | { |
---|
688 | if (isset($_POST['selection'])) |
---|
689 | { |
---|
690 | $collection = $_POST['selection']; |
---|
691 | } |
---|
692 | break; |
---|
693 | } |
---|
694 | } |
---|
695 | |
---|
696 | if (count($collection) == 0) |
---|
697 | { |
---|
698 | array_push($page['errors'], l10n('Select at least one user')); |
---|
699 | } |
---|
700 | } |
---|
701 | |
---|
702 | // +-----------------------------------------------------------------------+ |
---|
703 | // | delete users | |
---|
704 | // +-----------------------------------------------------------------------+ |
---|
705 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
---|
706 | { |
---|
707 | if (in_array($conf['guest_id'], $collection)) |
---|
708 | { |
---|
709 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
710 | } |
---|
711 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
712 | in_array($conf['default_user_id'], $collection)) |
---|
713 | { |
---|
714 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
715 | } |
---|
716 | if (in_array($conf['webmaster_id'], $collection)) |
---|
717 | { |
---|
718 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
719 | } |
---|
720 | if (in_array($user['id'], $collection)) |
---|
721 | { |
---|
722 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
723 | } |
---|
724 | |
---|
725 | if (count($page['errors']) == 0) |
---|
726 | { |
---|
727 | foreach ($collection as $user_id) |
---|
728 | { |
---|
729 | delete_user($user_id); |
---|
730 | } |
---|
731 | array_push( |
---|
732 | $page['infos'], |
---|
733 | l10n_dec( |
---|
734 | '%d user deleted', '%d users deleted', |
---|
735 | count($collection) |
---|
736 | ) |
---|
737 | ); |
---|
738 | |
---|
739 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
740 | { |
---|
741 | if (in_array($filter_user['id'], $collection)) |
---|
742 | { |
---|
743 | unset($page['filtered_users'][$filter_key]); |
---|
744 | } |
---|
745 | } |
---|
746 | } |
---|
747 | } |
---|
748 | |
---|
749 | // +-----------------------------------------------------------------------+ |
---|
750 | // | Resend new validation key to users | |
---|
751 | // +-----------------------------------------------------------------------+ |
---|
752 | // +-----------------------------------------------------------------------+ |
---|
753 | // | selected users | |
---|
754 | // +-----------------------------------------------------------------------+ |
---|
755 | if (isset($_POST['Mail_With_Key'])) |
---|
756 | { |
---|
757 | $collection = array(); |
---|
758 | |
---|
759 | switch ($_POST['target']) |
---|
760 | { |
---|
761 | case 'all' : |
---|
762 | { |
---|
763 | foreach($page['filtered_users'] as $local_user) |
---|
764 | { |
---|
765 | array_push($collection, $local_user['id']); |
---|
766 | } |
---|
767 | break; |
---|
768 | } |
---|
769 | case 'selection' : |
---|
770 | { |
---|
771 | if (isset($_POST['selection'])) |
---|
772 | { |
---|
773 | $collection = $_POST['selection']; |
---|
774 | } |
---|
775 | break; |
---|
776 | } |
---|
777 | } |
---|
778 | |
---|
779 | if (count($collection) == 0) |
---|
780 | { |
---|
781 | array_push($page['errors'], l10n('Select at least one user')); |
---|
782 | } |
---|
783 | } |
---|
784 | // +-----------------------------------------------------------------------+ |
---|
785 | // | Resend new validation key to users | |
---|
786 | // +-----------------------------------------------------------------------+ |
---|
787 | if (isset($_POST['Mail_With_Key']) and count($collection) > 0) |
---|
788 | { |
---|
789 | if (in_array($conf['guest_id'], $collection)) |
---|
790 | { |
---|
791 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
---|
792 | } |
---|
793 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
794 | in_array($conf['default_user_id'], $collection)) |
---|
795 | { |
---|
796 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
---|
797 | } |
---|
798 | if (in_array($conf['webmaster_id'], $collection)) |
---|
799 | { |
---|
800 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
---|
801 | } |
---|
802 | if (in_array($user['id'], $collection)) |
---|
803 | { |
---|
804 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
---|
805 | } |
---|
806 | |
---|
807 | if (count($page['errors']) == 0) |
---|
808 | { |
---|
809 | foreach ($collection as $user_id) |
---|
810 | { |
---|
811 | $typemail = 1; |
---|
812 | $query = " |
---|
813 | SELECT id, username, mail_address |
---|
814 | FROM ".USERS_TABLE." |
---|
815 | WHERE id = '".$user_id."' |
---|
816 | ;"; |
---|
817 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
818 | |
---|
819 | ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],true); |
---|
820 | } |
---|
821 | array_push( |
---|
822 | $page['infos'], |
---|
823 | l10n_dec( |
---|
824 | '%d_Mail_With_Key', '%d_Mails_With_Key', |
---|
825 | count($collection) |
---|
826 | ) |
---|
827 | ); |
---|
828 | |
---|
829 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
830 | } |
---|
831 | } |
---|
832 | |
---|
833 | // +-----------------------------------------------------------------------+ |
---|
834 | // | Send reminder without new key to users | |
---|
835 | // +-----------------------------------------------------------------------+ |
---|
836 | // +-----------------------------------------------------------------------+ |
---|
837 | // | selected users | |
---|
838 | // +-----------------------------------------------------------------------+ |
---|
839 | if (isset($_POST['Mail_Without_Key'])) |
---|
840 | { |
---|
841 | $collection = array(); |
---|
842 | |
---|
843 | switch ($_POST['target']) |
---|
844 | { |
---|
845 | case 'all' : |
---|
846 | { |
---|
847 | foreach($page['filtered_users'] as $local_user) |
---|
848 | { |
---|
849 | array_push($collection, $local_user['id']); |
---|
850 | } |
---|
851 | break; |
---|
852 | } |
---|
853 | case 'selection' : |
---|
854 | { |
---|
855 | if (isset($_POST['selection'])) |
---|
856 | { |
---|
857 | $collection = $_POST['selection']; |
---|
858 | } |
---|
859 | break; |
---|
860 | } |
---|
861 | } |
---|
862 | |
---|
863 | if (count($collection) == 0) |
---|
864 | { |
---|
865 | array_push($page['errors'], l10n('Select at least one user')); |
---|
866 | } |
---|
867 | } |
---|
868 | // +-----------------------------------------------------------------------+ |
---|
869 | // | Send reminder without new key to users | |
---|
870 | // +-----------------------------------------------------------------------+ |
---|
871 | if (isset($_POST['Mail_Without_Key']) and count($collection) > 0) |
---|
872 | { |
---|
873 | if (in_array($conf['guest_id'], $collection)) |
---|
874 | { |
---|
875 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
---|
876 | } |
---|
877 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
878 | in_array($conf['default_user_id'], $collection)) |
---|
879 | { |
---|
880 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
---|
881 | } |
---|
882 | if (in_array($conf['webmaster_id'], $collection)) |
---|
883 | { |
---|
884 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
---|
885 | } |
---|
886 | if (in_array($user['id'], $collection)) |
---|
887 | { |
---|
888 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
---|
889 | } |
---|
890 | |
---|
891 | if (count($page['errors']) == 0) |
---|
892 | { |
---|
893 | foreach ($collection as $user_id) |
---|
894 | { |
---|
895 | $typemail = 2; |
---|
896 | $query = " |
---|
897 | SELECT id, username, mail_address |
---|
898 | FROM ".USERS_TABLE." |
---|
899 | WHERE id = '".$user_id."' |
---|
900 | ;"; |
---|
901 | |
---|
902 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
903 | |
---|
904 | ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],false); |
---|
905 | } |
---|
906 | array_push( |
---|
907 | $page['infos'], |
---|
908 | l10n_dec( |
---|
909 | '%d_Reminder_Sent', '%d_Reminders_Sent', |
---|
910 | count($collection) |
---|
911 | ) |
---|
912 | ); |
---|
913 | |
---|
914 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
915 | } |
---|
916 | } |
---|
917 | |
---|
918 | // +-----------------------------------------------------------------------+ |
---|
919 | // | Force validation | |
---|
920 | // +-----------------------------------------------------------------------+ |
---|
921 | // +-----------------------------------------------------------------------+ |
---|
922 | // | selected users | |
---|
923 | // +-----------------------------------------------------------------------+ |
---|
924 | if (isset($_POST['Force_Validation'])) |
---|
925 | { |
---|
926 | $collection = array(); |
---|
927 | |
---|
928 | switch ($_POST['target']) |
---|
929 | { |
---|
930 | case 'all' : |
---|
931 | { |
---|
932 | foreach($page['filtered_users'] as $local_user) |
---|
933 | { |
---|
934 | array_push($collection, $local_user['id']); |
---|
935 | } |
---|
936 | break; |
---|
937 | } |
---|
938 | case 'selection' : |
---|
939 | { |
---|
940 | if (isset($_POST['selection'])) |
---|
941 | { |
---|
942 | $collection = $_POST['selection']; |
---|
943 | } |
---|
944 | break; |
---|
945 | } |
---|
946 | } |
---|
947 | |
---|
948 | if (count($collection) == 0) |
---|
949 | { |
---|
950 | array_push($page['errors'], l10n('Select at least one user')); |
---|
951 | } |
---|
952 | } |
---|
953 | // +-----------------------------------------------------------------------+ |
---|
954 | // | Force validation | |
---|
955 | // +-----------------------------------------------------------------------+ |
---|
956 | if (isset($_POST['Force_Validation']) and count($collection) > 0) |
---|
957 | { |
---|
958 | if (in_array($conf['guest_id'], $collection)) |
---|
959 | { |
---|
960 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
---|
961 | } |
---|
962 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
963 | in_array($conf['default_user_id'], $collection)) |
---|
964 | { |
---|
965 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
---|
966 | } |
---|
967 | if (in_array($conf['webmaster_id'], $collection)) |
---|
968 | { |
---|
969 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
---|
970 | } |
---|
971 | if (in_array($user['id'], $collection)) |
---|
972 | { |
---|
973 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
---|
974 | } |
---|
975 | |
---|
976 | if (count($page['errors']) == 0) |
---|
977 | { |
---|
978 | foreach ($collection as $user_id) |
---|
979 | { |
---|
980 | $query = " |
---|
981 | SELECT id, username, mail_address |
---|
982 | FROM ".USERS_TABLE." |
---|
983 | WHERE id = '".$user_id."' |
---|
984 | ;"; |
---|
985 | |
---|
986 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
987 | |
---|
988 | ForceValidation($data['id']); |
---|
989 | } |
---|
990 | array_push( |
---|
991 | $page['infos'], |
---|
992 | l10n_dec( |
---|
993 | '%d_Validated_User', '%d_Validated_Users', |
---|
994 | count($collection) |
---|
995 | ) |
---|
996 | ); |
---|
997 | |
---|
998 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
999 | } |
---|
1000 | } |
---|
1001 | |
---|
1002 | |
---|
1003 | // +-----------------------------------------------------------------------+ |
---|
1004 | // | groups list | |
---|
1005 | // +-----------------------------------------------------------------------+ |
---|
1006 | |
---|
1007 | $groups[-1] = '------------'; |
---|
1008 | |
---|
1009 | $query = ' |
---|
1010 | SELECT id, name |
---|
1011 | FROM '.GROUPS_TABLE.' |
---|
1012 | ORDER BY name ASC |
---|
1013 | ;'; |
---|
1014 | |
---|
1015 | $result = pwg_query($query); |
---|
1016 | |
---|
1017 | while ($row = mysql_fetch_assoc($result)) |
---|
1018 | { |
---|
1019 | $groups[$row['id']] = $row['name']; |
---|
1020 | } |
---|
1021 | |
---|
1022 | // +-----------------------------------------------------------------------+ |
---|
1023 | // | Template Init | |
---|
1024 | // +-----------------------------------------------------------------------+ |
---|
1025 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
---|
1026 | |
---|
1027 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
---|
1028 | { |
---|
1029 | $start = $_GET['start']; |
---|
1030 | } |
---|
1031 | else |
---|
1032 | { |
---|
1033 | $start = 0; |
---|
1034 | } |
---|
1035 | |
---|
1036 | /* Hide radio-button if not allow to assign adviser */ |
---|
1037 | if ($conf['allow_adviser']) |
---|
1038 | { |
---|
1039 | $template->assign('adviser', true); |
---|
1040 | } |
---|
1041 | |
---|
1042 | // +-----------------------------------------------------------------------+ |
---|
1043 | // | navigation bar | |
---|
1044 | // +-----------------------------------------------------------------------+ |
---|
1045 | |
---|
1046 | $url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start')); |
---|
1047 | |
---|
1048 | $navbar = create_navigation_bar( |
---|
1049 | $url, |
---|
1050 | count($page['filtered_users']), |
---|
1051 | $start, |
---|
1052 | $conf['users_page'] |
---|
1053 | ); |
---|
1054 | |
---|
1055 | $template->assign('NAVBAR', $navbar); |
---|
1056 | |
---|
1057 | // +-----------------------------------------------------------------------+ |
---|
1058 | // | user list | |
---|
1059 | // +-----------------------------------------------------------------------+ |
---|
1060 | |
---|
1061 | $profile_url = get_root_url().'admin.php?page=profile&user_id='; |
---|
1062 | $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; |
---|
1063 | |
---|
1064 | $visible_user_list = array(); |
---|
1065 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
1066 | { |
---|
1067 | /* simulate LIMIT $start, $conf['users_page'] */ |
---|
1068 | if ($num < $start) |
---|
1069 | { |
---|
1070 | continue; |
---|
1071 | } |
---|
1072 | if ($num >= $start + $conf['users_page']) |
---|
1073 | { |
---|
1074 | break; |
---|
1075 | } |
---|
1076 | |
---|
1077 | $visible_user_list[] = $local_user; |
---|
1078 | } |
---|
1079 | |
---|
1080 | foreach ($visible_user_list as $local_user) |
---|
1081 | { |
---|
1082 | $groups_string = preg_replace( |
---|
1083 | '/(\d+)/e', |
---|
1084 | "\$groups['$1']", |
---|
1085 | implode( |
---|
1086 | ', ', |
---|
1087 | $local_user['groups'] |
---|
1088 | ) |
---|
1089 | ); |
---|
1090 | |
---|
1091 | $query = ' |
---|
1092 | SELECT user_id, reminder |
---|
1093 | FROM '.USER_CONFIRM_MAIL_TABLE.' |
---|
1094 | WHERE user_id = '.$local_user['id'].' |
---|
1095 | ;'; |
---|
1096 | $result = pwg_query($query); |
---|
1097 | |
---|
1098 | $row = mysql_fetch_assoc($result); |
---|
1099 | |
---|
1100 | if (isset($row['reminder']) and $row['reminder'] == 'true') |
---|
1101 | { |
---|
1102 | $reminder = l10n('Reminder_Sent_OK'); |
---|
1103 | } |
---|
1104 | else if ((isset($row['reminder']) and $row['reminder'] == 'false') or !isset($row['reminder'])) |
---|
1105 | { |
---|
1106 | $reminder = l10n('Reminder_Sent_NOK'); |
---|
1107 | } |
---|
1108 | |
---|
1109 | |
---|
1110 | if (isset($_POST['pref_submit']) |
---|
1111 | and isset($_POST['selection']) |
---|
1112 | and in_array($local_user['id'], $_POST['selection'])) |
---|
1113 | { |
---|
1114 | $checked = 'checked="checked"'; |
---|
1115 | } |
---|
1116 | else |
---|
1117 | { |
---|
1118 | $checked = ''; |
---|
1119 | } |
---|
1120 | |
---|
1121 | $properties = array(); |
---|
1122 | if ( $local_user['level'] != 0 ) |
---|
1123 | { |
---|
1124 | $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); |
---|
1125 | } |
---|
1126 | $properties[] = |
---|
1127 | (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) |
---|
1128 | ? l10n('is_high_enabled') : l10n('is_high_disabled'); |
---|
1129 | |
---|
1130 | $expiration = expiration($local_user['id']); |
---|
1131 | |
---|
1132 | $template->append( |
---|
1133 | 'users', |
---|
1134 | array( |
---|
1135 | 'ID' => $local_user['id'], |
---|
1136 | 'CHECKED' => $checked, |
---|
1137 | 'U_PROFILE' => $profile_url.$local_user['id'], |
---|
1138 | 'U_PERM' => $perm_url.$local_user['id'], |
---|
1139 | 'USERNAME' => stripslashes($local_user['username']) |
---|
1140 | .($local_user['id'] == $conf['guest_id'] |
---|
1141 | ? '<BR>['.l10n('is_the_guest').']' : '') |
---|
1142 | .($local_user['id'] == $conf['default_user_id'] |
---|
1143 | ? '<BR>['.l10n('is_the_default').']' : ''), |
---|
1144 | 'STATUS' => l10n('user_status_' |
---|
1145 | .$local_user['status']).(($local_user['adviser'] == 'true') |
---|
1146 | ? '<BR>['.l10n('adviser').']' : ''), |
---|
1147 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
1148 | 'GROUPS' => $groups_string, |
---|
1149 | 'REGISTRATION' => $local_user['registration_date'], |
---|
1150 | 'REMINDER' => $reminder, |
---|
1151 | 'EXPIRATION' => $expiration, |
---|
1152 | ) |
---|
1153 | ); |
---|
1154 | } |
---|
1155 | /* Plugin version inserted */ |
---|
1156 | $template->assign( |
---|
1157 | array( |
---|
1158 | 'UAM_VERSION' => $version, |
---|
1159 | ) |
---|
1160 | ); |
---|
1161 | |
---|
1162 | // +-----------------------------------------------------------------------+ |
---|
1163 | // | errors display | |
---|
1164 | // +-----------------------------------------------------------------------+ |
---|
1165 | if ( isset ($errors) and count($errors) != 0) |
---|
1166 | { |
---|
1167 | $template->assign('errors',array()); |
---|
1168 | foreach ($errors as $error) |
---|
1169 | { |
---|
1170 | array_push($page['errors'], $error); |
---|
1171 | } |
---|
1172 | } |
---|
1173 | |
---|
1174 | // +-----------------------------------------------------------------------+ |
---|
1175 | // | templates display | |
---|
1176 | // +-----------------------------------------------------------------------+ |
---|
1177 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/usermanager.tpl'); |
---|
1178 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
1179 | } |
---|
1180 | else |
---|
1181 | { |
---|
1182 | array_push($page['infos'], l10n('Err_UserManager_Settings')); |
---|
1183 | } |
---|
1184 | break; |
---|
1185 | |
---|
1186 | |
---|
1187 | // ************************************************************************* |
---|
1188 | // +-----------------------------------------------------------------------+ |
---|
1189 | // | Ghost Tracker page | |
---|
1190 | // +-----------------------------------------------------------------------+ |
---|
1191 | // ************************************************************************* |
---|
1192 | case 'ghosttracker': |
---|
1193 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
1194 | |
---|
1195 | if (isset($conf_nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17]=='true') |
---|
1196 | { |
---|
1197 | // +-----------------------------------------------------------------------+ |
---|
1198 | // | initialization | |
---|
1199 | // +-----------------------------------------------------------------------+ |
---|
1200 | |
---|
1201 | if (!defined('PHPWG_ROOT_PATH')) |
---|
1202 | { |
---|
1203 | die('Hacking attempt!'); |
---|
1204 | } |
---|
1205 | |
---|
1206 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
1207 | |
---|
1208 | // +-----------------------------------------------------------------------+ |
---|
1209 | // | Check Access and exit when user status is not ok | |
---|
1210 | // +-----------------------------------------------------------------------+ |
---|
1211 | check_status(ACCESS_ADMINISTRATOR); |
---|
1212 | |
---|
1213 | // +-----------------------------------------------------------------------+ |
---|
1214 | // | user list | |
---|
1215 | // +-----------------------------------------------------------------------+ |
---|
1216 | |
---|
1217 | $page['filtered_users'] = get_ghost_user_list(); |
---|
1218 | |
---|
1219 | // +-----------------------------------------------------------------------+ |
---|
1220 | // | selected users | |
---|
1221 | // +-----------------------------------------------------------------------+ |
---|
1222 | if (isset($_POST['Del_Selected'])) |
---|
1223 | { |
---|
1224 | $collection = array(); |
---|
1225 | |
---|
1226 | switch ($_POST['target']) |
---|
1227 | { |
---|
1228 | case 'all' : |
---|
1229 | { |
---|
1230 | foreach($page['filtered_users'] as $local_user) |
---|
1231 | { |
---|
1232 | array_push($collection, $local_user['id']); |
---|
1233 | } |
---|
1234 | break; |
---|
1235 | } |
---|
1236 | case 'selection' : |
---|
1237 | { |
---|
1238 | if (isset($_POST['selection'])) |
---|
1239 | { |
---|
1240 | $collection = $_POST['selection']; |
---|
1241 | } |
---|
1242 | break; |
---|
1243 | } |
---|
1244 | } |
---|
1245 | |
---|
1246 | if (count($collection) == 0) |
---|
1247 | { |
---|
1248 | array_push($page['errors'], l10n('Select at least one user')); |
---|
1249 | } |
---|
1250 | } |
---|
1251 | |
---|
1252 | // +-----------------------------------------------------------------------+ |
---|
1253 | // | delete users | |
---|
1254 | // +-----------------------------------------------------------------------+ |
---|
1255 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
---|
1256 | { |
---|
1257 | if (in_array($conf['guest_id'], $collection)) |
---|
1258 | { |
---|
1259 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
1260 | } |
---|
1261 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
1262 | in_array($conf['default_user_id'], $collection)) |
---|
1263 | { |
---|
1264 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
1265 | } |
---|
1266 | if (in_array($conf['webmaster_id'], $collection)) |
---|
1267 | { |
---|
1268 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
1269 | } |
---|
1270 | if (in_array($user['id'], $collection)) |
---|
1271 | { |
---|
1272 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
1273 | } |
---|
1274 | |
---|
1275 | if (count($page['errors']) == 0) |
---|
1276 | { |
---|
1277 | foreach ($collection as $user_id) |
---|
1278 | { |
---|
1279 | delete_user($user_id); |
---|
1280 | } |
---|
1281 | array_push( |
---|
1282 | $page['infos'], |
---|
1283 | l10n_dec( |
---|
1284 | '%d user deleted', '%d users deleted', |
---|
1285 | count($collection) |
---|
1286 | ) |
---|
1287 | ); |
---|
1288 | |
---|
1289 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
1290 | { |
---|
1291 | if (in_array($filter_user['id'], $collection)) |
---|
1292 | { |
---|
1293 | unset($page['filtered_users'][$filter_key]); |
---|
1294 | } |
---|
1295 | } |
---|
1296 | } |
---|
1297 | } |
---|
1298 | |
---|
1299 | // +-----------------------------------------------------------------------+ |
---|
1300 | // | Send ghost reminder | |
---|
1301 | // +-----------------------------------------------------------------------+ |
---|
1302 | // +-----------------------------------------------------------------------+ |
---|
1303 | // | selected users | |
---|
1304 | // +-----------------------------------------------------------------------+ |
---|
1305 | if (isset($_POST['Reminder_Email'])) |
---|
1306 | { |
---|
1307 | $collection = array(); |
---|
1308 | |
---|
1309 | switch ($_POST['target']) |
---|
1310 | { |
---|
1311 | case 'all' : |
---|
1312 | { |
---|
1313 | foreach($page['filtered_users'] as $local_user) |
---|
1314 | { |
---|
1315 | array_push($collection, $local_user['id']); |
---|
1316 | } |
---|
1317 | break; |
---|
1318 | } |
---|
1319 | case 'selection' : |
---|
1320 | { |
---|
1321 | if (isset($_POST['selection'])) |
---|
1322 | { |
---|
1323 | $collection = $_POST['selection']; |
---|
1324 | } |
---|
1325 | break; |
---|
1326 | } |
---|
1327 | } |
---|
1328 | |
---|
1329 | if (count($collection) == 0) |
---|
1330 | { |
---|
1331 | array_push($page['errors'], l10n('Select at least one user')); |
---|
1332 | } |
---|
1333 | } |
---|
1334 | // +-----------------------------------------------------------------------+ |
---|
1335 | // | Send ghost reminder | |
---|
1336 | // +-----------------------------------------------------------------------+ |
---|
1337 | if (isset($_POST['Reminder_Email']) and count($collection) > 0) |
---|
1338 | { |
---|
1339 | if (in_array($conf['guest_id'], $collection)) |
---|
1340 | { |
---|
1341 | array_push($page['errors'], l10n('No_reminder_for_Guest')); |
---|
1342 | } |
---|
1343 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
1344 | in_array($conf['default_user_id'], $collection)) |
---|
1345 | { |
---|
1346 | array_push($page['errors'], l10n('No_reminder_for_default_user')); |
---|
1347 | } |
---|
1348 | if (in_array($conf['webmaster_id'], $collection)) |
---|
1349 | { |
---|
1350 | array_push($page['errors'], l10n('No_reminder_for_Webmaster')); |
---|
1351 | } |
---|
1352 | if (in_array($user['id'], $collection)) |
---|
1353 | { |
---|
1354 | array_push($page['errors'], l10n('No_reminder_for_your_account')); |
---|
1355 | } |
---|
1356 | |
---|
1357 | if (count($page['errors']) == 0) |
---|
1358 | { |
---|
1359 | foreach ($collection as $user_id) |
---|
1360 | { |
---|
1361 | $query = " |
---|
1362 | SELECT id, username, mail_address |
---|
1363 | FROM ".USERS_TABLE." |
---|
1364 | WHERE id = '".$user_id."' |
---|
1365 | ;"; |
---|
1366 | |
---|
1367 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
1368 | |
---|
1369 | ghostreminder($user_id,stripslashes($data['username']),$data['mail_address']); |
---|
1370 | } |
---|
1371 | array_push( |
---|
1372 | $page['infos'], |
---|
1373 | l10n_dec( |
---|
1374 | '%d_Reminder_Sent', '%d_Reminders_Sent', |
---|
1375 | count($collection) |
---|
1376 | ) |
---|
1377 | ); |
---|
1378 | |
---|
1379 | $page['filtered_users'] = get_ghost_user_list(); |
---|
1380 | } |
---|
1381 | } |
---|
1382 | |
---|
1383 | if (isset($_POST['GhostTracker_Init'])) |
---|
1384 | { |
---|
1385 | /* Reset is only allowed for admins ! */ |
---|
1386 | if (is_admin() and !is_adviser()) |
---|
1387 | { |
---|
1388 | $query1 = ' |
---|
1389 | SELECT * |
---|
1390 | FROM '.USER_LASTVISIT_TABLE.';'; |
---|
1391 | |
---|
1392 | $count = mysql_num_rows(pwg_query($query1)); |
---|
1393 | |
---|
1394 | if ($count <> 0) |
---|
1395 | { |
---|
1396 | $query = ' |
---|
1397 | SELECT DISTINCT u.id, |
---|
1398 | ui.status AS status |
---|
1399 | FROM '.USERS_TABLE.' AS u |
---|
1400 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
1401 | ON u.id = ui.user_id |
---|
1402 | WHERE u.id NOT IN (SELECT user_id FROM '.USER_LASTVISIT_TABLE.') |
---|
1403 | AND status != "webmaster" |
---|
1404 | AND status != "guest" |
---|
1405 | AND status != "admin" |
---|
1406 | ORDER BY u.id ASC |
---|
1407 | ;'; |
---|
1408 | |
---|
1409 | $result = pwg_query($query); |
---|
1410 | |
---|
1411 | while ($row = mysql_fetch_assoc($result)) |
---|
1412 | { |
---|
1413 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
1414 | |
---|
1415 | $query = " |
---|
1416 | INSERT INTO ".USER_LASTVISIT_TABLE." (user_id, lastvisit, reminder) |
---|
1417 | VALUES ('".$row['id']."','".$dbnow."','false') |
---|
1418 | ;"; |
---|
1419 | pwg_query($query); |
---|
1420 | } |
---|
1421 | } |
---|
1422 | else if ($count == 0) |
---|
1423 | { |
---|
1424 | $query = ' |
---|
1425 | SELECT DISTINCT u.id, |
---|
1426 | ui.status AS status |
---|
1427 | FROM '.USERS_TABLE.' AS u |
---|
1428 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
1429 | ON u.id = ui.user_id |
---|
1430 | WHERE status != "webmaster" |
---|
1431 | AND status != "guest" |
---|
1432 | AND status != "admin" |
---|
1433 | ORDER BY u.id ASC |
---|
1434 | ;'; |
---|
1435 | |
---|
1436 | $result = pwg_query($query); |
---|
1437 | |
---|
1438 | while($row = mysql_fetch_assoc($result)) |
---|
1439 | { |
---|
1440 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
1441 | |
---|
1442 | $query = " |
---|
1443 | INSERT INTO ".USER_LASTVISIT_TABLE." (user_id, lastvisit, reminder) |
---|
1444 | VALUES ('".$row['id']."','".$dbnow."','false') |
---|
1445 | ;"; |
---|
1446 | pwg_query($query); |
---|
1447 | } |
---|
1448 | } |
---|
1449 | |
---|
1450 | array_push($page['infos'], l10n('GhostTracker_Init_OK')); |
---|
1451 | } |
---|
1452 | } |
---|
1453 | |
---|
1454 | // +-----------------------------------------------------------------------+ |
---|
1455 | // | Template Init | |
---|
1456 | // +-----------------------------------------------------------------------+ |
---|
1457 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
---|
1458 | |
---|
1459 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
---|
1460 | { |
---|
1461 | $start = $_GET['start']; |
---|
1462 | } |
---|
1463 | else |
---|
1464 | { |
---|
1465 | $start = 0; |
---|
1466 | } |
---|
1467 | |
---|
1468 | /* Hide radio-button if not allow to assign adviser */ |
---|
1469 | if ($conf['allow_adviser']) |
---|
1470 | { |
---|
1471 | $template->assign('adviser', true); |
---|
1472 | } |
---|
1473 | |
---|
1474 | // +-----------------------------------------------------------------------+ |
---|
1475 | // | navigation bar | |
---|
1476 | // +-----------------------------------------------------------------------+ |
---|
1477 | |
---|
1478 | $url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start')); |
---|
1479 | |
---|
1480 | $navbar = create_navigation_bar( |
---|
1481 | $url, |
---|
1482 | count($page['filtered_users']), |
---|
1483 | $start, |
---|
1484 | $conf['users_page'] |
---|
1485 | ); |
---|
1486 | |
---|
1487 | $template->assign('NAVBAR', $navbar); |
---|
1488 | |
---|
1489 | // +-----------------------------------------------------------------------+ |
---|
1490 | // | user list | |
---|
1491 | // +-----------------------------------------------------------------------+ |
---|
1492 | |
---|
1493 | $visible_user_list = array(); |
---|
1494 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
1495 | { |
---|
1496 | /* simulate LIMIT $start, $conf['users_page'] */ |
---|
1497 | if ($num < $start) |
---|
1498 | { |
---|
1499 | continue; |
---|
1500 | } |
---|
1501 | if ($num >= $start + $conf['users_page']) |
---|
1502 | { |
---|
1503 | break; |
---|
1504 | } |
---|
1505 | |
---|
1506 | $visible_user_list[] = $local_user; |
---|
1507 | } |
---|
1508 | |
---|
1509 | foreach ($visible_user_list as $local_user) |
---|
1510 | { |
---|
1511 | $reminder = ''; |
---|
1512 | |
---|
1513 | if (isset($local_user['reminder']) and $local_user['reminder'] == 'true') |
---|
1514 | { |
---|
1515 | $reminder = l10n('Reminder_Sent_OK'); |
---|
1516 | } |
---|
1517 | else if (isset($local_user['reminder']) and $local_user['reminder'] == 'false') |
---|
1518 | { |
---|
1519 | $reminder = l10n('Reminder_Sent_NOK'); |
---|
1520 | } |
---|
1521 | |
---|
1522 | if (isset($_POST['pref_submit']) and isset($_POST['selection']) and in_array($local_user['id'], $_POST['selection'])) |
---|
1523 | { |
---|
1524 | $checked = 'checked="checked"'; |
---|
1525 | } |
---|
1526 | else |
---|
1527 | { |
---|
1528 | $checked = ''; |
---|
1529 | } |
---|
1530 | /* Plugin version inserted */ |
---|
1531 | $template->assign( |
---|
1532 | array( |
---|
1533 | 'UAM_VERSION' => $version, |
---|
1534 | ) |
---|
1535 | ); |
---|
1536 | |
---|
1537 | $template->append( |
---|
1538 | 'users', |
---|
1539 | array( |
---|
1540 | 'ID' => $local_user['id'], |
---|
1541 | 'CHECKED' => $checked, |
---|
1542 | 'USERNAME' => stripslashes($local_user['username']), |
---|
1543 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
1544 | 'LASTVISIT' => $local_user['lastvisit'], |
---|
1545 | 'REMINDER' => $reminder, |
---|
1546 | ) |
---|
1547 | ); |
---|
1548 | } |
---|
1549 | |
---|
1550 | // +-----------------------------------------------------------------------+ |
---|
1551 | // | errors display | |
---|
1552 | // +-----------------------------------------------------------------------+ |
---|
1553 | if ( isset ($errors) and count($errors) != 0) |
---|
1554 | { |
---|
1555 | $template->assign('errors',array()); |
---|
1556 | foreach ($errors as $error) |
---|
1557 | { |
---|
1558 | array_push($page['errors'], $error); |
---|
1559 | } |
---|
1560 | } |
---|
1561 | |
---|
1562 | // +-----------------------------------------------------------------------+ |
---|
1563 | // | templates display | |
---|
1564 | // +-----------------------------------------------------------------------+ |
---|
1565 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/ghosttracker.tpl'); |
---|
1566 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
1567 | } |
---|
1568 | else |
---|
1569 | { |
---|
1570 | array_push($page['infos'], l10n('Err_GhostTracker_Settings')); |
---|
1571 | } |
---|
1572 | |
---|
1573 | break; |
---|
1574 | } |
---|
1575 | ?> |
---|