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