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