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