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