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