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