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