| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | global $user, $lang, $conf, $errors; |
|---|
| 4 | |
|---|
| 5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
|---|
| 6 | // +-----------------------------------------------------------------------+ |
|---|
| 7 | // | Check Access and exit when user status is not ok | |
|---|
| 8 | // +-----------------------------------------------------------------------+ |
|---|
| 9 | check_status(ACCESS_ADMINISTRATOR); |
|---|
| 10 | |
|---|
| 11 | //ini_set('error_reporting', E_ALL); |
|---|
| 12 | //ini_set('display_errors', true); |
|---|
| 13 | |
|---|
| 14 | include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
|---|
| 15 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
|---|
| 16 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
|---|
| 17 | |
|---|
| 18 | load_language('plugin.lang', NBC_UserAdvManager_PATH); |
|---|
| 19 | |
|---|
| 20 | // +-----------------------------------------------------------------------+ |
|---|
| 21 | // | Tabssheet | |
|---|
| 22 | // +-----------------------------------------------------------------------+ |
|---|
| 23 | if (!isset($_GET['tab'])) |
|---|
| 24 | $page['tab'] = 'global'; |
|---|
| 25 | else |
|---|
| 26 | $page['tab'] = $_GET['tab']; |
|---|
| 27 | |
|---|
| 28 | $tabsheet = new tabsheet(); |
|---|
| 29 | $tabsheet->add('global', |
|---|
| 30 | l10n('Tab_Global'), |
|---|
| 31 | $my_base_url.'&tab=global'); |
|---|
| 32 | $tabsheet->add('confirmmail', |
|---|
| 33 | l10n('Tab_ConfirmMail'), |
|---|
| 34 | $my_base_url.'&tab=confirmmail'); |
|---|
| 35 | $tabsheet->add('usermanager', |
|---|
| 36 | l10n('Tab_UserManager'), |
|---|
| 37 | $my_base_url.'&tab=usermanager'); |
|---|
| 38 | $tabsheet->add('ghosttracker', |
|---|
| 39 | l10n('Tab_GhostTracker'), |
|---|
| 40 | $my_base_url.'&tab=ghosttracker'); |
|---|
| 41 | $tabsheet->select($page['tab']); |
|---|
| 42 | $tabsheet->assign(); |
|---|
| 43 | |
|---|
| 44 | $page['global'] = array(); |
|---|
| 45 | $error = array(); |
|---|
| 46 | $UserAdvManager_Password_Test_Score = 0; |
|---|
| 47 | |
|---|
| 48 | // +-----------------------------------------------------------------------+ |
|---|
| 49 | // | Tabssheet select | |
|---|
| 50 | // +-----------------------------------------------------------------------+ |
|---|
| 51 | |
|---|
| 52 | switch ($page['tab']) |
|---|
| 53 | { |
|---|
| 54 | // ************************************************************************* |
|---|
| 55 | // +-----------------------------------------------------------------------+ |
|---|
| 56 | // | Global Config | |
|---|
| 57 | // +-----------------------------------------------------------------------+ |
|---|
| 58 | // ************************************************************************* |
|---|
| 59 | case 'global': |
|---|
| 60 | |
|---|
| 61 | 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'])) |
|---|
| 62 | { |
|---|
| 63 | $_POST['UserAdvManager_MailInfo_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_MailInfo_Text'])); |
|---|
| 64 | $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text'])); |
|---|
| 65 | |
|---|
| 66 | $_POST['UserAdvManager_GhostTracker_ReminderText'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_GhostTracker_ReminderText'])); |
|---|
| 67 | |
|---|
| 68 | $newconf_nbc_UserAdvManager = $_POST['UserAdvManager_Mail_Info'].';'.$_POST['UserAdvManager_No_Casse'].';'.$_POST['UserAdvManager_Confirm_Mail'].';'.(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';'.$_POST['UserAdvManager_No_Comment_Anonymous'].';'.$_POST['UserAdvManager_Username_Char'].';'.$_POST['UserAdvManager_Username_List'].';'.(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';'.$_POST['UserAdvManager_MailInfo_Text'].';'.$_POST['UserAdvManager_ConfirmMail_Text'].';'.$_POST['UserAdvManager_MailExclusion'].';'.$_POST['UserAdvManager_MailExclusion_List'].';'.$_POST['UserAdvManager_Password_Enforced'].';'.$_POST['UserAdvManager_Password_Score'].';'.$_POST['UserAdvManager_AdminPassword_Enforced'].';'.$_POST['UserAdvManager_GhostUser_Tracker'].';'.$_POST['UserAdvManager_GhostTracker_DayLimit'].';'.$_POST['UserAdvManager_GhostTracker_ReminderText']; |
|---|
| 69 | |
|---|
| 70 | $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager; |
|---|
| 71 | |
|---|
| 72 | $query = ' |
|---|
| 73 | UPDATE '.CONFIG_TABLE.' |
|---|
| 74 | SET value="'.$newconf_nbc_UserAdvManager.'" |
|---|
| 75 | WHERE param="nbc_UserAdvManager" |
|---|
| 76 | LIMIT 1 |
|---|
| 77 | ;'; |
|---|
| 78 | |
|---|
| 79 | pwg_query($query); |
|---|
| 80 | |
|---|
| 81 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | if (isset($_POST['PasswordTest']) and !is_adviser() and isset($_POST['UserAdvManager_Password_Test']) and !empty($_POST['UserAdvManager_Password_Test'])) |
|---|
| 85 | { |
|---|
| 86 | $UserAdvManager_Password_Test_Score = testpassword($_POST['UserAdvManager_Password_Test']); |
|---|
| 87 | } |
|---|
| 88 | else if (isset($_POST['PasswordTest']) and !is_adviser() and empty($_POST['UserAdvManager_Password_Test'])) |
|---|
| 89 | { |
|---|
| 90 | array_push($page['errors'], l10n('reg_err_login3')); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
|---|
| 94 | |
|---|
| 95 | /* Group setting for unvalidated and validated users */ |
|---|
| 96 | $groups[-1] = '---------'; |
|---|
| 97 | $No_Valid = -1; |
|---|
| 98 | $Valid = -1; |
|---|
| 99 | |
|---|
| 100 | /* Check groups list in database */ |
|---|
| 101 | $query = ' |
|---|
| 102 | SELECT id, name |
|---|
| 103 | FROM '.GROUPS_TABLE.' |
|---|
| 104 | ORDER BY name ASC |
|---|
| 105 | ;'; |
|---|
| 106 | |
|---|
| 107 | $result = pwg_query($query); |
|---|
| 108 | |
|---|
| 109 | while ($row = mysql_fetch_array($result)) |
|---|
| 110 | { |
|---|
| 111 | $groups[$row['id']] = $row['name']; |
|---|
| 112 | /* configuration value for unvalidated users */ |
|---|
| 113 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == $row['id']) |
|---|
| 114 | { |
|---|
| 115 | $No_Valid = $row['id']; |
|---|
| 116 | } |
|---|
| 117 | /* configuration value for validated users */ |
|---|
| 118 | if (isset($conf_nbc_UserAdvManager[4]) and $conf_nbc_UserAdvManager[4] == $row['id']) |
|---|
| 119 | { |
|---|
| 120 | $Valid = $row['id']; |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | /* Template initialization for unvalidated users group */ |
|---|
| 125 | $template->assign( |
|---|
| 126 | 'No_Confirm_Group', |
|---|
| 127 | array( |
|---|
| 128 | 'group_options'=> $groups, |
|---|
| 129 | 'group_selected' => $No_Valid |
|---|
| 130 | ) |
|---|
| 131 | ); |
|---|
| 132 | /* Template initialization for validated users group */ |
|---|
| 133 | $template->assign( |
|---|
| 134 | 'Validated_Group', |
|---|
| 135 | array( |
|---|
| 136 | 'group_options'=> $groups, |
|---|
| 137 | 'group_selected' => $Valid |
|---|
| 138 | ) |
|---|
| 139 | ); |
|---|
| 140 | |
|---|
| 141 | /* Status setting for unvalidated and validated users */ |
|---|
| 142 | $status_options[-1] = '------------'; |
|---|
| 143 | $No_Valid_Status = -1; |
|---|
| 144 | $Valid_Status = -1; |
|---|
| 145 | |
|---|
| 146 | /* Get status values */ |
|---|
| 147 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
|---|
| 148 | { |
|---|
| 149 | $status_options[$status] = l10n('user_status_'.$status); |
|---|
| 150 | if (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] == $status) |
|---|
| 151 | { |
|---|
| 152 | $No_Valid_Status = $status; |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | /* Template initialization for unvalidated users group */ |
|---|
| 156 | $template->assign( |
|---|
| 157 | 'No_Confirm_Status', |
|---|
| 158 | array( |
|---|
| 159 | 'Status_options' => $status_options, |
|---|
| 160 | 'Status_selected' => $No_Valid_Status |
|---|
| 161 | ) |
|---|
| 162 | ); |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | /* Get status values */ |
|---|
| 166 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
|---|
| 167 | { |
|---|
| 168 | $status_options[$status] = l10n('user_status_'.$status); |
|---|
| 169 | if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status) |
|---|
| 170 | { |
|---|
| 171 | $Valid_Status = $status; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | /* Template initialization for unvalidated users group */ |
|---|
| 175 | $template->assign( |
|---|
| 176 | 'Confirm_Status', |
|---|
| 177 | array( |
|---|
| 178 | 'Status_options' => $status_options, |
|---|
| 179 | 'Status_selected' => $Valid_Status |
|---|
| 180 | ) |
|---|
| 181 | ); |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | $template->assign( |
|---|
| 185 | array( |
|---|
| 186 | 'UserAdvManager_MAIL_INFO_TRUE' => $conf_nbc_UserAdvManager[0]=='true' ? 'checked="checked"' : '' , |
|---|
| 187 | 'UserAdvManager_MAIL_INFO_FALSE' => $conf_nbc_UserAdvManager[0]=='false' ? 'checked="checked"' : '' , |
|---|
| 188 | 'UserAdvManager_MAILINFO_TEXT' => $conf_nbc_UserAdvManager[10], |
|---|
| 189 | 'UserAdvManager_NO_CASSE_TRUE' => $conf_nbc_UserAdvManager[1]=='true' ? 'checked="checked"' : '' , |
|---|
| 190 | 'UserAdvManager_NO_CASSE_FALSE' => $conf_nbc_UserAdvManager[1]=='false' ? 'checked="checked"' : '' , |
|---|
| 191 | 'UserAdvManager_USERNAME_CHAR_TRUE' => $conf_nbc_UserAdvManager[7]=='true' ? 'checked="checked"' : '' , |
|---|
| 192 | 'UserAdvManager_USERNAME_CHAR_FALSE' => $conf_nbc_UserAdvManager[7]=='false' ? 'checked="checked"' : '' , |
|---|
| 193 | 'UserAdvManager_USERNAME_CHAR_LIST' => $conf_nbc_UserAdvManager[8], |
|---|
| 194 | 'UserAdvManager_CONFIRM_MAIL_TRUE' => $conf_nbc_UserAdvManager[2]=='true' ? 'checked="checked"' : '' , |
|---|
| 195 | 'UserAdvManager_CONFIRM_MAIL_FALSE' => $conf_nbc_UserAdvManager[2]=='false' ? 'checked="checked"' : '' , |
|---|
| 196 | 'UserAdvManager_CONFIRMMAIL_TEXT' => $conf_nbc_UserAdvManager[11], |
|---|
| 197 | 'UserAdvManager_No_Confirm_Group' => $conf_nbc_UserAdvManager[3], |
|---|
| 198 | 'UserAdvManager_Validated_Group' => $conf_nbc_UserAdvManager[4], |
|---|
| 199 | 'UserAdvManager_No_Confirm_Status' => $conf_nbc_UserAdvManager[9], |
|---|
| 200 | 'UserAdvManager_Validated_Status' => $conf_nbc_UserAdvManager[5], |
|---|
| 201 | 'UserAdvManager_NO_COMMENT_ANO_TRUE' => $conf_nbc_UserAdvManager[6]=='true' ? 'checked="checked"' : '' , |
|---|
| 202 | 'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ? 'checked="checked"' : '' , |
|---|
| 203 | 'UserAdvManager_MAILEXCLUSION_TRUE' => $conf_nbc_UserAdvManager[12]=='true' ? 'checked="checked"' : '' , |
|---|
| 204 | 'UserAdvManager_MAILEXCLUSION_FALSE' => $conf_nbc_UserAdvManager[12]=='false' ? 'checked="checked"' : '' , |
|---|
| 205 | 'UserAdvManager_MAILEXCLUSION_LIST' => $conf_nbc_UserAdvManager[13], |
|---|
| 206 | 'UserAdvManager_PASSWORDENF_TRUE' => $conf_nbc_UserAdvManager[14]=='true' ? 'checked="checked"' : '' , |
|---|
| 207 | 'UserAdvManager_PASSWORDENF_FALSE' => $conf_nbc_UserAdvManager[14]=='false' ? 'checked="checked"' : '' , |
|---|
| 208 | 'UserAdvManager_PASSWORD_SCORE' => $conf_nbc_UserAdvManager[15], |
|---|
| 209 | 'UserAdvManager_ADMINPASSWENF_TRUE' => $conf_nbc_UserAdvManager[16]=='true' ? 'checked="checked"' : '' , |
|---|
| 210 | 'UserAdvManager_ADMINPASSWENF_FALSE' => $conf_nbc_UserAdvManager[16]=='false' ? 'checked="checked"' : '' , |
|---|
| 211 | 'UserAdvManager_GHOSTRACKER_TRUE' => $conf_nbc_UserAdvManager[17]=='true' ? 'checked="checked"' : '' , |
|---|
| 212 | 'UserAdvManager_GHOSTRACKER_FALSE' => $conf_nbc_UserAdvManager[17]=='false' ? 'checked="checked"' : '' , |
|---|
| 213 | 'UserAdvManager_GHOSTRACKER_DAYLIMIT' => $conf_nbc_UserAdvManager[18], |
|---|
| 214 | 'UserAdvManager_GHOSTRACKER_REMINDERTEXT' => $conf_nbc_UserAdvManager[19], |
|---|
| 215 | 'UserAdvManager_PASSWORD_TEST_SCORE' => $UserAdvManager_Password_Test_Score, |
|---|
| 216 | ) |
|---|
| 217 | ); |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | if (isset($_POST['audit'])) |
|---|
| 221 | { |
|---|
| 222 | $msg_error1 = ''; |
|---|
| 223 | |
|---|
| 224 | /* username insensible a la casse */ |
|---|
| 225 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true') |
|---|
| 226 | { |
|---|
| 227 | $query = " |
|---|
| 228 | SELECT ".$conf['user_fields']['username']." |
|---|
| 229 | FROM ".USERS_TABLE." p1 |
|---|
| 230 | WHERE EXISTS( |
|---|
| 231 | SELECT ".$conf['user_fields']['username']." |
|---|
| 232 | FROM ".USERS_TABLE." p2 |
|---|
| 233 | WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']." |
|---|
| 234 | AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].") |
|---|
| 235 | ) |
|---|
| 236 | ;"; |
|---|
| 237 | |
|---|
| 238 | $result = pwg_query($query); |
|---|
| 239 | |
|---|
| 240 | while($row = mysql_fetch_array($result)) |
|---|
| 241 | { |
|---|
| 242 | $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username']; |
|---|
| 243 | } |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | $msg_error2 = ''; |
|---|
| 247 | |
|---|
| 248 | /* Username without forbidden keys */ |
|---|
| 249 | if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' ) |
|---|
| 250 | { |
|---|
| 251 | $query = " |
|---|
| 252 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
|---|
| 253 | FROM ".USERS_TABLE." |
|---|
| 254 | ;"; |
|---|
| 255 | |
|---|
| 256 | $result = pwg_query($query); |
|---|
| 257 | |
|---|
| 258 | while($row = mysql_fetch_array($result)) |
|---|
| 259 | { |
|---|
| 260 | if (!ValidateUsername($row['username'])) |
|---|
| 261 | $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username']; |
|---|
| 262 | } |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | $msg_error3 = ''; |
|---|
| 266 | |
|---|
| 267 | /* Email without forbidden domain */ |
|---|
| 268 | if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' ) |
|---|
| 269 | { |
|---|
| 270 | $query = " |
|---|
| 271 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
|---|
| 272 | FROM ".USERS_TABLE." |
|---|
| 273 | ;"; |
|---|
| 274 | |
|---|
| 275 | $result = pwg_query($query); |
|---|
| 276 | |
|---|
| 277 | while($row = mysql_fetch_array($result)) |
|---|
| 278 | { |
|---|
| 279 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
|---|
| 280 | $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]); |
|---|
| 281 | for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) |
|---|
| 282 | { |
|---|
| 283 | $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; |
|---|
| 284 | if (preg_match($pattern, $row['mail_address'])) |
|---|
| 285 | { |
|---|
| 286 | $msg_error3 .= (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')'; |
|---|
| 287 | } |
|---|
| 288 | } |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | if ($msg_error1 <> '') |
|---|
| 293 | $errors[] = $msg_error1.'<br/><br/>'; |
|---|
| 294 | |
|---|
| 295 | if ($msg_error2 <> '') |
|---|
| 296 | $errors[] = $msg_error2.'<br/><br/>'; |
|---|
| 297 | |
|---|
| 298 | if ($msg_error3 <> '') |
|---|
| 299 | $errors[] = $msg_error3.'<br/><br/>'; |
|---|
| 300 | |
|---|
| 301 | if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') |
|---|
| 302 | array_push($page['errors'], l10n('Err_audit_advise')); |
|---|
| 303 | else |
|---|
| 304 | array_push($page['infos'], l10n('UserAdvManager_audit_ok')); |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | // +-----------------------------------------------------------------------+ |
|---|
| 309 | // | errors display | |
|---|
| 310 | // +-----------------------------------------------------------------------+ |
|---|
| 311 | if (isset ($errors) and count($errors) != 0) |
|---|
| 312 | { |
|---|
| 313 | $template->assign('errors',array()); |
|---|
| 314 | foreach ($errors as $error) |
|---|
| 315 | { |
|---|
| 316 | array_push($page['errors'], $error); |
|---|
| 317 | } |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | // +-----------------------------------------------------------------------+ |
|---|
| 321 | // | templates display | |
|---|
| 322 | // +-----------------------------------------------------------------------+ |
|---|
| 323 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl'); |
|---|
| 324 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
|---|
| 325 | |
|---|
| 326 | break; |
|---|
| 327 | |
|---|
| 328 | // ************************************************************************* |
|---|
| 329 | // +-----------------------------------------------------------------------+ |
|---|
| 330 | // | ConfirmMail Config | |
|---|
| 331 | // +-----------------------------------------------------------------------+ |
|---|
| 332 | // ************************************************************************* |
|---|
| 333 | case 'confirmmail': |
|---|
| 334 | |
|---|
| 335 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
|---|
| 336 | |
|---|
| 337 | if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true') |
|---|
| 338 | { |
|---|
| 339 | if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) ) |
|---|
| 340 | { |
|---|
| 341 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'])); |
|---|
| 342 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'])); |
|---|
| 343 | |
|---|
| 344 | $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay'].';'.$_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'].';'.$_POST['UserAdvManager_ConfirmMail_Remail'].';'.$_POST['UserAdvManager_ConfirmMail_ReMail_Txt2']; |
|---|
| 345 | |
|---|
| 346 | //NODO:Adding new option [Auto deletion : True | False] - No access to cron functionnalities |
|---|
| 347 | |
|---|
| 348 | $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail; |
|---|
| 349 | |
|---|
| 350 | $query = ' |
|---|
| 351 | UPDATE '.CONFIG_TABLE.' |
|---|
| 352 | SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'" |
|---|
| 353 | WHERE param="nbc_UserAdvManager_ConfirmMail" |
|---|
| 354 | LIMIT 1 |
|---|
| 355 | ;'; |
|---|
| 356 | |
|---|
| 357 | pwg_query($query); |
|---|
| 358 | |
|---|
| 359 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
|---|
| 360 | } |
|---|
| 361 | |
|---|
| 362 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
|---|
| 363 | |
|---|
| 364 | $template->assign( |
|---|
| 365 | array( |
|---|
| 366 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ? 'checked="checked"' : '' , |
|---|
| 367 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ? 'checked="checked"' : '' , |
|---|
| 368 | 'UserAdvManager_CONFIRMMAIL_DELAY' => $conf_nbc_UserAdvManager_ConfirmMail[1], |
|---|
| 369 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[3]=='true' ? 'checked="checked"' : '', |
|---|
| 370 | 'UserAdvManager_CONFIRMMAIL_REMAIL_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[3]=='false' ? 'checked="checked"' : '', |
|---|
| 371 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TXT1' => $conf_nbc_UserAdvManager_ConfirmMail[2], |
|---|
| 372 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TXT2' => $conf_nbc_UserAdvManager_ConfirmMail[4], |
|---|
| 373 | ) |
|---|
| 374 | ); |
|---|
| 375 | |
|---|
| 376 | // +-----------------------------------------------------------------------+ |
|---|
| 377 | // | errors display | |
|---|
| 378 | // +-----------------------------------------------------------------------+ |
|---|
| 379 | if ( isset ($errors) and count($errors) != 0) |
|---|
| 380 | { |
|---|
| 381 | $template->assign('errors',array()); |
|---|
| 382 | foreach ($errors as $error) |
|---|
| 383 | { |
|---|
| 384 | array_push($page['errors'], $error); |
|---|
| 385 | } |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | // +-----------------------------------------------------------------------+ |
|---|
| 389 | // | templates display | |
|---|
| 390 | // +-----------------------------------------------------------------------+ |
|---|
| 391 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl'); |
|---|
| 392 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
|---|
| 393 | } |
|---|
| 394 | else |
|---|
| 395 | { |
|---|
| 396 | array_push($page['infos'], l10n('Err_ConfirmMail_Settings')); |
|---|
| 397 | } |
|---|
| 398 | break; |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | // ************************************************************************* |
|---|
| 402 | // +-----------------------------------------------------------------------+ |
|---|
| 403 | // | Users manager page | |
|---|
| 404 | // +-----------------------------------------------------------------------+ |
|---|
| 405 | // ************************************************************************* |
|---|
| 406 | case 'usermanager': |
|---|
| 407 | |
|---|
| 408 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
|---|
| 409 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
|---|
| 410 | |
|---|
| 411 | 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') |
|---|
| 412 | { |
|---|
| 413 | // +-----------------------------------------------------------------------+ |
|---|
| 414 | // | initialization | |
|---|
| 415 | // +-----------------------------------------------------------------------+ |
|---|
| 416 | |
|---|
| 417 | if (!defined('PHPWG_ROOT_PATH')) |
|---|
| 418 | { |
|---|
| 419 | die('Hacking attempt!'); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
|---|
| 423 | |
|---|
| 424 | // +-----------------------------------------------------------------------+ |
|---|
| 425 | // | Check Access and exit when user status is not ok | |
|---|
| 426 | // +-----------------------------------------------------------------------+ |
|---|
| 427 | check_status(ACCESS_ADMINISTRATOR); |
|---|
| 428 | |
|---|
| 429 | $page['order_by_items'] = array( |
|---|
| 430 | 'id' => l10n('registration_date'), |
|---|
| 431 | 'username' => l10n('Username'), |
|---|
| 432 | 'level' => l10n('Privacy level'), |
|---|
| 433 | 'language' => l10n('language'), |
|---|
| 434 | ); |
|---|
| 435 | |
|---|
| 436 | // +-----------------------------------------------------------------------+ |
|---|
| 437 | // | user list | |
|---|
| 438 | // +-----------------------------------------------------------------------+ |
|---|
| 439 | |
|---|
| 440 | $page['filtered_users'] = get_unvalid_user_list(); |
|---|
| 441 | |
|---|
| 442 | // +-----------------------------------------------------------------------+ |
|---|
| 443 | // | selected users | |
|---|
| 444 | // +-----------------------------------------------------------------------+ |
|---|
| 445 | if (isset($_POST['Del_Selected'])) |
|---|
| 446 | { |
|---|
| 447 | $collection = array(); |
|---|
| 448 | |
|---|
| 449 | switch ($_POST['target']) |
|---|
| 450 | { |
|---|
| 451 | case 'all' : |
|---|
| 452 | { |
|---|
| 453 | foreach($page['filtered_users'] as $local_user) |
|---|
| 454 | { |
|---|
| 455 | array_push($collection, $local_user['id']); |
|---|
| 456 | } |
|---|
| 457 | break; |
|---|
| 458 | } |
|---|
| 459 | case 'selection' : |
|---|
| 460 | { |
|---|
| 461 | if (isset($_POST['selection'])) |
|---|
| 462 | { |
|---|
| 463 | $collection = $_POST['selection']; |
|---|
| 464 | } |
|---|
| 465 | break; |
|---|
| 466 | } |
|---|
| 467 | } |
|---|
| 468 | |
|---|
| 469 | if (count($collection) == 0) |
|---|
| 470 | { |
|---|
| 471 | array_push($page['errors'], l10n('Select at least one user')); |
|---|
| 472 | } |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | // +-----------------------------------------------------------------------+ |
|---|
| 476 | // | delete users | |
|---|
| 477 | // +-----------------------------------------------------------------------+ |
|---|
| 478 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
|---|
| 479 | { |
|---|
| 480 | if (in_array($conf['guest_id'], $collection)) |
|---|
| 481 | { |
|---|
| 482 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
|---|
| 483 | } |
|---|
| 484 | if (($conf['guest_id'] != $conf['default_user_id']) and |
|---|
| 485 | in_array($conf['default_user_id'], $collection)) |
|---|
| 486 | { |
|---|
| 487 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
|---|
| 488 | } |
|---|
| 489 | if (in_array($conf['webmaster_id'], $collection)) |
|---|
| 490 | { |
|---|
| 491 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
|---|
| 492 | } |
|---|
| 493 | if (in_array($user['id'], $collection)) |
|---|
| 494 | { |
|---|
| 495 | array_push($page['errors'], l10n('You cannot delete your account')); |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | if (count($page['errors']) == 0) |
|---|
| 499 | { |
|---|
| 500 | foreach ($collection as $user_id) |
|---|
| 501 | { |
|---|
| 502 | delete_user($user_id); |
|---|
| 503 | } |
|---|
| 504 | array_push( |
|---|
| 505 | $page['infos'], |
|---|
| 506 | l10n_dec( |
|---|
| 507 | '%d user deleted', '%d users deleted', |
|---|
| 508 | count($collection) |
|---|
| 509 | ) |
|---|
| 510 | ); |
|---|
| 511 | |
|---|
| 512 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
|---|
| 513 | { |
|---|
| 514 | if (in_array($filter_user['id'], $collection)) |
|---|
| 515 | { |
|---|
| 516 | unset($page['filtered_users'][$filter_key]); |
|---|
| 517 | } |
|---|
| 518 | } |
|---|
| 519 | } |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | // +-----------------------------------------------------------------------+ |
|---|
| 523 | // | Resend new validation key to users | |
|---|
| 524 | // +-----------------------------------------------------------------------+ |
|---|
| 525 | // +-----------------------------------------------------------------------+ |
|---|
| 526 | // | selected users | |
|---|
| 527 | // +-----------------------------------------------------------------------+ |
|---|
| 528 | if (isset($_POST['Mail_With_Key'])) |
|---|
| 529 | { |
|---|
| 530 | $collection = array(); |
|---|
| 531 | |
|---|
| 532 | switch ($_POST['target']) |
|---|
| 533 | { |
|---|
| 534 | case 'all' : |
|---|
| 535 | { |
|---|
| 536 | foreach($page['filtered_users'] as $local_user) |
|---|
| 537 | { |
|---|
| 538 | array_push($collection, $local_user['id']); |
|---|
| 539 | } |
|---|
| 540 | break; |
|---|
| 541 | } |
|---|
| 542 | case 'selection' : |
|---|
| 543 | { |
|---|
| 544 | if (isset($_POST['selection'])) |
|---|
| 545 | { |
|---|
| 546 | $collection = $_POST['selection']; |
|---|
| 547 | } |
|---|
| 548 | break; |
|---|
| 549 | } |
|---|
| 550 | } |
|---|
| 551 | |
|---|
| 552 | if (count($collection) == 0) |
|---|
| 553 | { |
|---|
| 554 | array_push($page['errors'], l10n('Select at least one user')); |
|---|
| 555 | } |
|---|
| 556 | } |
|---|
| 557 | // +-----------------------------------------------------------------------+ |
|---|
| 558 | // | Resend new validation key to users | |
|---|
| 559 | // +-----------------------------------------------------------------------+ |
|---|
| 560 | if (isset($_POST['Mail_With_Key']) and count($collection) > 0) |
|---|
| 561 | { |
|---|
| 562 | if (in_array($conf['guest_id'], $collection)) |
|---|
| 563 | { |
|---|
| 564 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
|---|
| 565 | } |
|---|
| 566 | if (($conf['guest_id'] != $conf['default_user_id']) and |
|---|
| 567 | in_array($conf['default_user_id'], $collection)) |
|---|
| 568 | { |
|---|
| 569 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
|---|
| 570 | } |
|---|
| 571 | if (in_array($conf['webmaster_id'], $collection)) |
|---|
| 572 | { |
|---|
| 573 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
|---|
| 574 | } |
|---|
| 575 | if (in_array($user['id'], $collection)) |
|---|
| 576 | { |
|---|
| 577 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | if (count($page['errors']) == 0) |
|---|
| 581 | { |
|---|
| 582 | foreach ($collection as $user_id) |
|---|
| 583 | { |
|---|
| 584 | $typemail = 1; |
|---|
| 585 | $query = " |
|---|
| 586 | SELECT id, username, mail_address |
|---|
| 587 | FROM ".USERS_TABLE." |
|---|
| 588 | WHERE id = '".$user_id."' |
|---|
| 589 | ;"; |
|---|
| 590 | $data = mysql_fetch_array(pwg_query($query)); |
|---|
| 591 | |
|---|
| 592 | ResendMail2User($typemail,$user_id,$data['username'],$data['mail_address'],true); |
|---|
| 593 | } |
|---|
| 594 | array_push( |
|---|
| 595 | $page['infos'], |
|---|
| 596 | l10n_dec( |
|---|
| 597 | '%d_Mail_With_Key', '%d_Mails_With_Key', |
|---|
| 598 | count($collection) |
|---|
| 599 | ) |
|---|
| 600 | ); |
|---|
| 601 | |
|---|
| 602 | $page['filtered_users'] = get_unvalid_user_list(); |
|---|
| 603 | } |
|---|
| 604 | } |
|---|
| 605 | |
|---|
| 606 | // +-----------------------------------------------------------------------+ |
|---|
| 607 | // | Send reminder without new key to users | |
|---|
| 608 | // +-----------------------------------------------------------------------+ |
|---|
| 609 | // +-----------------------------------------------------------------------+ |
|---|
| 610 | // | selected users | |
|---|
| 611 | // +-----------------------------------------------------------------------+ |
|---|
| 612 | if (isset($_POST['Mail_Without_Key'])) |
|---|
| 613 | { |
|---|
| 614 | $collection = array(); |
|---|
| 615 | |
|---|
| 616 | switch ($_POST['target']) |
|---|
| 617 | { |
|---|
| 618 | case 'all' : |
|---|
| 619 | { |
|---|
| 620 | foreach($page['filtered_users'] as $local_user) |
|---|
| 621 | { |
|---|
| 622 | array_push($collection, $local_user['id']); |
|---|
| 623 | } |
|---|
| 624 | break; |
|---|
| 625 | } |
|---|
| 626 | case 'selection' : |
|---|
| 627 | { |
|---|
| 628 | if (isset($_POST['selection'])) |
|---|
| 629 | { |
|---|
| 630 | $collection = $_POST['selection']; |
|---|
| 631 | } |
|---|
| 632 | break; |
|---|
| 633 | } |
|---|
| 634 | } |
|---|
| 635 | |
|---|
| 636 | if (count($collection) == 0) |
|---|
| 637 | { |
|---|
| 638 | array_push($page['errors'], l10n('Select at least one user')); |
|---|
| 639 | } |
|---|
| 640 | } |
|---|
| 641 | // +-----------------------------------------------------------------------+ |
|---|
| 642 | // | Send reminder without new key to users | |
|---|
| 643 | // +-----------------------------------------------------------------------+ |
|---|
| 644 | if (isset($_POST['Mail_Without_Key']) and count($collection) > 0) |
|---|
| 645 | { |
|---|
| 646 | if (in_array($conf['guest_id'], $collection)) |
|---|
| 647 | { |
|---|
| 648 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
|---|
| 649 | } |
|---|
| 650 | if (($conf['guest_id'] != $conf['default_user_id']) and |
|---|
| 651 | in_array($conf['default_user_id'], $collection)) |
|---|
| 652 | { |
|---|
| 653 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
|---|
| 654 | } |
|---|
| 655 | if (in_array($conf['webmaster_id'], $collection)) |
|---|
| 656 | { |
|---|
| 657 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
|---|
| 658 | } |
|---|
| 659 | if (in_array($user['id'], $collection)) |
|---|
| 660 | { |
|---|
| 661 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
|---|
| 662 | } |
|---|
| 663 | |
|---|
| 664 | if (count($page['errors']) == 0) |
|---|
| 665 | { |
|---|
| 666 | foreach ($collection as $user_id) |
|---|
| 667 | { |
|---|
| 668 | $typemail = 2; |
|---|
| 669 | $query = " |
|---|
| 670 | SELECT id, username, mail_address |
|---|
| 671 | FROM ".USERS_TABLE." |
|---|
| 672 | WHERE id = '".$user_id."' |
|---|
| 673 | ;"; |
|---|
| 674 | |
|---|
| 675 | $data = mysql_fetch_array(pwg_query($query)); |
|---|
| 676 | |
|---|
| 677 | ResendMail2User($typemail,$user_id,$data['username'],$data['mail_address'],false); |
|---|
| 678 | } |
|---|
| 679 | array_push( |
|---|
| 680 | $page['infos'], |
|---|
| 681 | l10n_dec( |
|---|
| 682 | '%d_Reminder_Sent', '%d_Reminders_Sent', |
|---|
| 683 | count($collection) |
|---|
| 684 | ) |
|---|
| 685 | ); |
|---|
| 686 | |
|---|
| 687 | $page['filtered_users'] = get_unvalid_user_list(); |
|---|
| 688 | } |
|---|
| 689 | } |
|---|
| 690 | |
|---|
| 691 | // +-----------------------------------------------------------------------+ |
|---|
| 692 | // | Force validation | |
|---|
| 693 | // +-----------------------------------------------------------------------+ |
|---|
| 694 | // +-----------------------------------------------------------------------+ |
|---|
| 695 | // | selected users | |
|---|
| 696 | // +-----------------------------------------------------------------------+ |
|---|
| 697 | if (isset($_POST['Force_Validation'])) |
|---|
| 698 | { |
|---|
| 699 | $collection = array(); |
|---|
| 700 | |
|---|
| 701 | switch ($_POST['target']) |
|---|
| 702 | { |
|---|
| 703 | case 'all' : |
|---|
| 704 | { |
|---|
| 705 | foreach($page['filtered_users'] as $local_user) |
|---|
| 706 | { |
|---|
| 707 | array_push($collection, $local_user['id']); |
|---|
| 708 | } |
|---|
| 709 | break; |
|---|
| 710 | } |
|---|
| 711 | case 'selection' : |
|---|
| 712 | { |
|---|
| 713 | if (isset($_POST['selection'])) |
|---|
| 714 | { |
|---|
| 715 | $collection = $_POST['selection']; |
|---|
| 716 | } |
|---|
| 717 | break; |
|---|
| 718 | } |
|---|
| 719 | } |
|---|
| 720 | |
|---|
| 721 | if (count($collection) == 0) |
|---|
| 722 | { |
|---|
| 723 | array_push($page['errors'], l10n('Select at least one user')); |
|---|
| 724 | } |
|---|
| 725 | } |
|---|
| 726 | // +-----------------------------------------------------------------------+ |
|---|
| 727 | // | Force validation | |
|---|
| 728 | // +-----------------------------------------------------------------------+ |
|---|
| 729 | if (isset($_POST['Force_Validation']) and count($collection) > 0) |
|---|
| 730 | { |
|---|
| 731 | if (in_array($conf['guest_id'], $collection)) |
|---|
| 732 | { |
|---|
| 733 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
|---|
| 734 | } |
|---|
| 735 | if (($conf['guest_id'] != $conf['default_user_id']) and |
|---|
| 736 | in_array($conf['default_user_id'], $collection)) |
|---|
| 737 | { |
|---|
| 738 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
|---|
| 739 | } |
|---|
| 740 | if (in_array($conf['webmaster_id'], $collection)) |
|---|
| 741 | { |
|---|
| 742 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
|---|
| 743 | } |
|---|
| 744 | if (in_array($user['id'], $collection)) |
|---|
| 745 | { |
|---|
| 746 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
|---|
| 747 | } |
|---|
| 748 | |
|---|
| 749 | if (count($page['errors']) == 0) |
|---|
| 750 | { |
|---|
| 751 | foreach ($collection as $user_id) |
|---|
| 752 | { |
|---|
| 753 | $query = " |
|---|
| 754 | SELECT id, username, mail_address |
|---|
| 755 | FROM ".USERS_TABLE." |
|---|
| 756 | WHERE id = '".$user_id."' |
|---|
| 757 | ;"; |
|---|
| 758 | |
|---|
| 759 | $data = mysql_fetch_array(pwg_query($query)); |
|---|
| 760 | |
|---|
| 761 | ForceValidation($data['id']); |
|---|
| 762 | } |
|---|
| 763 | array_push( |
|---|
| 764 | $page['infos'], |
|---|
| 765 | l10n_dec( |
|---|
| 766 | '%d_Validated_User', '%d_Validated_Users', |
|---|
| 767 | count($collection) |
|---|
| 768 | ) |
|---|
| 769 | ); |
|---|
| 770 | |
|---|
| 771 | $page['filtered_users'] = get_unvalid_user_list(); |
|---|
| 772 | } |
|---|
| 773 | } |
|---|
| 774 | |
|---|
| 775 | |
|---|
| 776 | // +-----------------------------------------------------------------------+ |
|---|
| 777 | // | groups list | |
|---|
| 778 | // +-----------------------------------------------------------------------+ |
|---|
| 779 | |
|---|
| 780 | $groups[-1] = '------------'; |
|---|
| 781 | |
|---|
| 782 | $query = ' |
|---|
| 783 | SELECT id, name |
|---|
| 784 | FROM '.GROUPS_TABLE.' |
|---|
| 785 | ORDER BY name ASC |
|---|
| 786 | ;'; |
|---|
| 787 | |
|---|
| 788 | $result = pwg_query($query); |
|---|
| 789 | |
|---|
| 790 | while ($row = mysql_fetch_array($result)) |
|---|
| 791 | { |
|---|
| 792 | $groups[$row['id']] = $row['name']; |
|---|
| 793 | } |
|---|
| 794 | |
|---|
| 795 | // +-----------------------------------------------------------------------+ |
|---|
| 796 | // | Template Init | |
|---|
| 797 | // +-----------------------------------------------------------------------+ |
|---|
| 798 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
|---|
| 799 | |
|---|
| 800 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
|---|
| 801 | { |
|---|
| 802 | $start = $_GET['start']; |
|---|
| 803 | } |
|---|
| 804 | else |
|---|
| 805 | { |
|---|
| 806 | $start = 0; |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | $template->assign( |
|---|
| 810 | array( |
|---|
| 811 | 'F_ADD_ACTION' => $base_url, |
|---|
| 812 | 'F_USERNAME' => @htmlentities($_GET['username']), |
|---|
| 813 | 'F_FILTER_ACTION' => get_root_url().'admin.php' |
|---|
| 814 | ) |
|---|
| 815 | ); |
|---|
| 816 | |
|---|
| 817 | /* Hide radio-button if not allow to assign adviser */ |
|---|
| 818 | if ($conf['allow_adviser']) |
|---|
| 819 | { |
|---|
| 820 | $template->assign('adviser', true); |
|---|
| 821 | } |
|---|
| 822 | |
|---|
| 823 | // +-----------------------------------------------------------------------+ |
|---|
| 824 | // | user list | |
|---|
| 825 | // +-----------------------------------------------------------------------+ |
|---|
| 826 | |
|---|
| 827 | $profile_url = get_root_url().'admin.php?page=profile&user_id='; |
|---|
| 828 | $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; |
|---|
| 829 | |
|---|
| 830 | $visible_user_list = array(); |
|---|
| 831 | foreach ($page['filtered_users'] as $num => $local_user) |
|---|
| 832 | { |
|---|
| 833 | /* simulate LIMIT $start, $conf['users_page'] */ |
|---|
| 834 | if ($num < $start) |
|---|
| 835 | { |
|---|
| 836 | continue; |
|---|
| 837 | } |
|---|
| 838 | if ($num >= $start + $conf['users_page']) |
|---|
| 839 | { |
|---|
| 840 | break; |
|---|
| 841 | } |
|---|
| 842 | |
|---|
| 843 | $visible_user_list[] = $local_user; |
|---|
| 844 | } |
|---|
| 845 | |
|---|
| 846 | foreach ($visible_user_list as $local_user) |
|---|
| 847 | { |
|---|
| 848 | $groups_string = preg_replace( |
|---|
| 849 | '/(\d+)/e', |
|---|
| 850 | "\$groups['$1']", |
|---|
| 851 | implode( |
|---|
| 852 | ', ', |
|---|
| 853 | $local_user['groups'] |
|---|
| 854 | ) |
|---|
| 855 | ); |
|---|
| 856 | |
|---|
| 857 | if (isset($_POST['pref_submit']) |
|---|
| 858 | and isset($_POST['selection']) |
|---|
| 859 | and in_array($local_user['id'], $_POST['selection'])) |
|---|
| 860 | { |
|---|
| 861 | $checked = 'checked="checked"'; |
|---|
| 862 | } |
|---|
| 863 | else |
|---|
| 864 | { |
|---|
| 865 | $checked = ''; |
|---|
| 866 | } |
|---|
| 867 | |
|---|
| 868 | $properties = array(); |
|---|
| 869 | if ( $local_user['level'] != 0 ) |
|---|
| 870 | { |
|---|
| 871 | $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); |
|---|
| 872 | } |
|---|
| 873 | $properties[] = |
|---|
| 874 | (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) |
|---|
| 875 | ? l10n('is_high_enabled') : l10n('is_high_disabled'); |
|---|
| 876 | |
|---|
| 877 | $expiration = expiration($local_user['id']); |
|---|
| 878 | |
|---|
| 879 | $template->append( |
|---|
| 880 | 'users', |
|---|
| 881 | array( |
|---|
| 882 | 'ID' => $local_user['id'], |
|---|
| 883 | 'CHECKED' => $checked, |
|---|
| 884 | 'U_PROFILE' => $profile_url.$local_user['id'], |
|---|
| 885 | 'U_PERM' => $perm_url.$local_user['id'], |
|---|
| 886 | 'USERNAME' => $local_user['username'] |
|---|
| 887 | .($local_user['id'] == $conf['guest_id'] |
|---|
| 888 | ? '<BR />['.l10n('is_the_guest').']' : '') |
|---|
| 889 | .($local_user['id'] == $conf['default_user_id'] |
|---|
| 890 | ? '<BR />['.l10n('is_the_default').']' : ''), |
|---|
| 891 | 'STATUS' => l10n('user_status_'. |
|---|
| 892 | $local_user['status']).(($local_user['adviser'] == 'true') |
|---|
| 893 | ? '<BR />['.l10n('adviser').']' : ''), |
|---|
| 894 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
|---|
| 895 | 'GROUPS' => $groups_string, |
|---|
| 896 | 'REGISTRATION' => $local_user['registration_date'], |
|---|
| 897 | 'EXPIRATION' => $expiration, |
|---|
| 898 | ) |
|---|
| 899 | ); |
|---|
| 900 | } |
|---|
| 901 | |
|---|
| 902 | // +-----------------------------------------------------------------------+ |
|---|
| 903 | // | errors display | |
|---|
| 904 | // +-----------------------------------------------------------------------+ |
|---|
| 905 | if ( isset ($errors) and count($errors) != 0) |
|---|
| 906 | { |
|---|
| 907 | $template->assign('errors',array()); |
|---|
| 908 | foreach ($errors as $error) |
|---|
| 909 | { |
|---|
| 910 | array_push($page['errors'], $error); |
|---|
| 911 | } |
|---|
| 912 | } |
|---|
| 913 | |
|---|
| 914 | // +-----------------------------------------------------------------------+ |
|---|
| 915 | // | templates display | |
|---|
| 916 | // +-----------------------------------------------------------------------+ |
|---|
| 917 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/usermanager.tpl'); |
|---|
| 918 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
|---|
| 919 | } |
|---|
| 920 | else |
|---|
| 921 | { |
|---|
| 922 | array_push($page['infos'], l10n('Err_UserManager_Settings')); |
|---|
| 923 | } |
|---|
| 924 | break; |
|---|
| 925 | |
|---|
| 926 | |
|---|
| 927 | // ************************************************************************* |
|---|
| 928 | // +-----------------------------------------------------------------------+ |
|---|
| 929 | // | Ghost Tracker page | |
|---|
| 930 | // +-----------------------------------------------------------------------+ |
|---|
| 931 | // ************************************************************************* |
|---|
| 932 | case 'ghosttracker': |
|---|
| 933 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
|---|
| 934 | |
|---|
| 935 | if (isset($conf_nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17]=='true') |
|---|
| 936 | { |
|---|
| 937 | // +-----------------------------------------------------------------------+ |
|---|
| 938 | // | initialization | |
|---|
| 939 | // +-----------------------------------------------------------------------+ |
|---|
| 940 | |
|---|
| 941 | if (!defined('PHPWG_ROOT_PATH')) |
|---|
| 942 | { |
|---|
| 943 | die('Hacking attempt!'); |
|---|
| 944 | } |
|---|
| 945 | |
|---|
| 946 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
|---|
| 947 | |
|---|
| 948 | // +-----------------------------------------------------------------------+ |
|---|
| 949 | // | Check Access and exit when user status is not ok | |
|---|
| 950 | // +-----------------------------------------------------------------------+ |
|---|
| 951 | check_status(ACCESS_ADMINISTRATOR); |
|---|
| 952 | |
|---|
| 953 | $page['order_by_items'] = array( |
|---|
| 954 | 'id' => l10n('registration_date'), |
|---|
| 955 | 'username' => l10n('Username'), |
|---|
| 956 | 'level' => l10n('Privacy level'), |
|---|
| 957 | 'language' => l10n('language'), |
|---|
| 958 | ); |
|---|
| 959 | |
|---|
| 960 | // +-----------------------------------------------------------------------+ |
|---|
| 961 | // | user list | |
|---|
| 962 | // +-----------------------------------------------------------------------+ |
|---|
| 963 | |
|---|
| 964 | $page['filtered_users'] = get_ghost_user_list(); |
|---|
| 965 | |
|---|
| 966 | // +-----------------------------------------------------------------------+ |
|---|
| 967 | // | selected users | |
|---|
| 968 | // +-----------------------------------------------------------------------+ |
|---|
| 969 | if (isset($_POST['Del_Selected'])) |
|---|
| 970 | { |
|---|
| 971 | $collection = array(); |
|---|
| 972 | |
|---|
| 973 | switch ($_POST['target']) |
|---|
| 974 | { |
|---|
| 975 | case 'all' : |
|---|
| 976 | { |
|---|
| 977 | foreach($page['filtered_users'] as $local_user) |
|---|
| 978 | { |
|---|
| 979 | array_push($collection, $local_user['id']); |
|---|
| 980 | } |
|---|
| 981 | break; |
|---|
| 982 | } |
|---|
| 983 | case 'selection' : |
|---|
| 984 | { |
|---|
| 985 | if (isset($_POST['selection'])) |
|---|
| 986 | { |
|---|
| 987 | $collection = $_POST['selection']; |
|---|
| 988 | } |
|---|
| 989 | break; |
|---|
| 990 | } |
|---|
| 991 | } |
|---|
| 992 | |
|---|
| 993 | if (count($collection) == 0) |
|---|
| 994 | { |
|---|
| 995 | array_push($page['errors'], l10n('Select at least one user')); |
|---|
| 996 | } |
|---|
| 997 | } |
|---|
| 998 | |
|---|
| 999 | // +-----------------------------------------------------------------------+ |
|---|
| 1000 | // | delete users | |
|---|
| 1001 | // +-----------------------------------------------------------------------+ |
|---|
| 1002 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
|---|
| 1003 | { |
|---|
| 1004 | if (in_array($conf['guest_id'], $collection)) |
|---|
| 1005 | { |
|---|
| 1006 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
|---|
| 1007 | } |
|---|
| 1008 | if (($conf['guest_id'] != $conf['default_user_id']) and |
|---|
| 1009 | in_array($conf['default_user_id'], $collection)) |
|---|
| 1010 | { |
|---|
| 1011 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
|---|
| 1012 | } |
|---|
| 1013 | if (in_array($conf['webmaster_id'], $collection)) |
|---|
| 1014 | { |
|---|
| 1015 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
|---|
| 1016 | } |
|---|
| 1017 | if (in_array($user['id'], $collection)) |
|---|
| 1018 | { |
|---|
| 1019 | array_push($page['errors'], l10n('You cannot delete your account')); |
|---|
| 1020 | } |
|---|
| 1021 | |
|---|
| 1022 | if (count($page['errors']) == 0) |
|---|
| 1023 | { |
|---|
| 1024 | foreach ($collection as $user_id) |
|---|
| 1025 | { |
|---|
| 1026 | delete_user($user_id); |
|---|
| 1027 | } |
|---|
| 1028 | array_push( |
|---|
| 1029 | $page['infos'], |
|---|
| 1030 | l10n_dec( |
|---|
| 1031 | '%d user deleted', '%d users deleted', |
|---|
| 1032 | count($collection) |
|---|
| 1033 | ) |
|---|
| 1034 | ); |
|---|
| 1035 | |
|---|
| 1036 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
|---|
| 1037 | { |
|---|
| 1038 | if (in_array($filter_user['id'], $collection)) |
|---|
| 1039 | { |
|---|
| 1040 | unset($page['filtered_users'][$filter_key]); |
|---|
| 1041 | } |
|---|
| 1042 | } |
|---|
| 1043 | } |
|---|
| 1044 | } |
|---|
| 1045 | |
|---|
| 1046 | // +-----------------------------------------------------------------------+ |
|---|
| 1047 | // | Send ghost reminder | |
|---|
| 1048 | // +-----------------------------------------------------------------------+ |
|---|
| 1049 | // +-----------------------------------------------------------------------+ |
|---|
| 1050 | // | selected users | |
|---|
| 1051 | // +-----------------------------------------------------------------------+ |
|---|
| 1052 | if (isset($_POST['Reminder_Email'])) |
|---|
| 1053 | { |
|---|
| 1054 | $collection = array(); |
|---|
| 1055 | |
|---|
| 1056 | switch ($_POST['target']) |
|---|
| 1057 | { |
|---|
| 1058 | case 'all' : |
|---|
| 1059 | { |
|---|
| 1060 | foreach($page['filtered_users'] as $local_user) |
|---|
| 1061 | { |
|---|
| 1062 | array_push($collection, $local_user['id']); |
|---|
| 1063 | } |
|---|
| 1064 | break; |
|---|
| 1065 | } |
|---|
| 1066 | case 'selection' : |
|---|
| 1067 | { |
|---|
| 1068 | if (isset($_POST['selection'])) |
|---|
| 1069 | { |
|---|
| 1070 | $collection = $_POST['selection']; |
|---|
| 1071 | } |
|---|
| 1072 | break; |
|---|
| 1073 | } |
|---|
| 1074 | } |
|---|
| 1075 | |
|---|
| 1076 | if (count($collection) == 0) |
|---|
| 1077 | { |
|---|
| 1078 | array_push($page['errors'], l10n('Select at least one user')); |
|---|
| 1079 | } |
|---|
| 1080 | } |
|---|
| 1081 | // +-----------------------------------------------------------------------+ |
|---|
| 1082 | // | Send ghost reminder | |
|---|
| 1083 | // +-----------------------------------------------------------------------+ |
|---|
| 1084 | if (isset($_POST['Reminder_Email']) and count($collection) > 0) |
|---|
| 1085 | { |
|---|
| 1086 | if (in_array($conf['guest_id'], $collection)) |
|---|
| 1087 | { |
|---|
| 1088 | array_push($page['errors'], l10n('No_reminder_for_Guest')); |
|---|
| 1089 | } |
|---|
| 1090 | if (($conf['guest_id'] != $conf['default_user_id']) and |
|---|
| 1091 | in_array($conf['default_user_id'], $collection)) |
|---|
| 1092 | { |
|---|
| 1093 | array_push($page['errors'], l10n('No_reminder_for_default_user')); |
|---|
| 1094 | } |
|---|
| 1095 | if (in_array($conf['webmaster_id'], $collection)) |
|---|
| 1096 | { |
|---|
| 1097 | array_push($page['errors'], l10n('No_reminder_for_Webmaster')); |
|---|
| 1098 | } |
|---|
| 1099 | if (in_array($user['id'], $collection)) |
|---|
| 1100 | { |
|---|
| 1101 | array_push($page['errors'], l10n('No_reminder_for_your_account')); |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | if (count($page['errors']) == 0) |
|---|
| 1105 | { |
|---|
| 1106 | foreach ($collection as $user_id) |
|---|
| 1107 | { |
|---|
| 1108 | $query = " |
|---|
| 1109 | SELECT id, username, mail_address |
|---|
| 1110 | FROM ".USERS_TABLE." |
|---|
| 1111 | WHERE id = '".$user_id."' |
|---|
| 1112 | ;"; |
|---|
| 1113 | |
|---|
| 1114 | $data = mysql_fetch_array(pwg_query($query)); |
|---|
| 1115 | |
|---|
| 1116 | ghostreminder($user_id,$data['username'],$data['mail_address']); |
|---|
| 1117 | } |
|---|
| 1118 | array_push( |
|---|
| 1119 | $page['infos'], |
|---|
| 1120 | l10n_dec( |
|---|
| 1121 | '%d_Reminder_Sent', '%d_Reminders_Sent', |
|---|
| 1122 | count($collection) |
|---|
| 1123 | ) |
|---|
| 1124 | ); |
|---|
| 1125 | |
|---|
| 1126 | $page['filtered_users'] = get_ghost_user_list(); |
|---|
| 1127 | } |
|---|
| 1128 | } |
|---|
| 1129 | |
|---|
| 1130 | // +-----------------------------------------------------------------------+ |
|---|
| 1131 | // | Template Init | |
|---|
| 1132 | // +-----------------------------------------------------------------------+ |
|---|
| 1133 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
|---|
| 1134 | |
|---|
| 1135 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
|---|
| 1136 | { |
|---|
| 1137 | $start = $_GET['start']; |
|---|
| 1138 | } |
|---|
| 1139 | else |
|---|
| 1140 | { |
|---|
| 1141 | $start = 0; |
|---|
| 1142 | } |
|---|
| 1143 | |
|---|
| 1144 | $template->assign( |
|---|
| 1145 | array( |
|---|
| 1146 | 'F_ADD_ACTION' => $base_url, |
|---|
| 1147 | 'F_USERNAME' => @htmlentities($_GET['username']), |
|---|
| 1148 | 'F_FILTER_ACTION' => get_root_url().'admin.php' |
|---|
| 1149 | ) |
|---|
| 1150 | ); |
|---|
| 1151 | |
|---|
| 1152 | /* Hide radio-button if not allow to assign adviser */ |
|---|
| 1153 | if ($conf['allow_adviser']) |
|---|
| 1154 | { |
|---|
| 1155 | $template->assign('adviser', true); |
|---|
| 1156 | } |
|---|
| 1157 | |
|---|
| 1158 | |
|---|
| 1159 | // +-----------------------------------------------------------------------+ |
|---|
| 1160 | // | user list | |
|---|
| 1161 | // +-----------------------------------------------------------------------+ |
|---|
| 1162 | |
|---|
| 1163 | $visible_user_list = array(); |
|---|
| 1164 | foreach ($page['filtered_users'] as $num => $local_user) |
|---|
| 1165 | { |
|---|
| 1166 | /* simulate LIMIT $start, $conf['users_page'] */ |
|---|
| 1167 | if ($num < $start) |
|---|
| 1168 | { |
|---|
| 1169 | continue; |
|---|
| 1170 | } |
|---|
| 1171 | if ($num >= $start + $conf['users_page']) |
|---|
| 1172 | { |
|---|
| 1173 | break; |
|---|
| 1174 | } |
|---|
| 1175 | |
|---|
| 1176 | $visible_user_list[] = $local_user; |
|---|
| 1177 | } |
|---|
| 1178 | |
|---|
| 1179 | $reminder = ''; |
|---|
| 1180 | if (isset($local_user['reminder']) and $local_user['reminder'] == 'true') |
|---|
| 1181 | { |
|---|
| 1182 | $reminder = l10n('Reminder_Sent_OK'); |
|---|
| 1183 | } |
|---|
| 1184 | else if (isset($local_user['reminder']) and $local_user['reminder'] == 'false') |
|---|
| 1185 | { |
|---|
| 1186 | $reminder = l10n('Reminder_Sent_NOK'); |
|---|
| 1187 | } |
|---|
| 1188 | |
|---|
| 1189 | foreach ($visible_user_list as $local_user) |
|---|
| 1190 | { |
|---|
| 1191 | if (isset($_POST['pref_submit']) |
|---|
| 1192 | and isset($_POST['selection']) |
|---|
| 1193 | and in_array($local_user['id'], $_POST['selection'])) |
|---|
| 1194 | { |
|---|
| 1195 | $checked = 'checked="checked"'; |
|---|
| 1196 | } |
|---|
| 1197 | else |
|---|
| 1198 | { |
|---|
| 1199 | $checked = ''; |
|---|
| 1200 | } |
|---|
| 1201 | |
|---|
| 1202 | $template->append( |
|---|
| 1203 | 'users', |
|---|
| 1204 | array( |
|---|
| 1205 | 'ID' => $local_user['id'], |
|---|
| 1206 | 'CHECKED' => $checked, |
|---|
| 1207 | 'USERNAME' => $local_user['username'] |
|---|
| 1208 | .($local_user['id'] == $conf['guest_id'] |
|---|
| 1209 | ? '<BR />['.l10n('is_the_guest').']' : '') |
|---|
| 1210 | .($local_user['id'] == $conf['default_user_id'] |
|---|
| 1211 | ? '<BR />['.l10n('is_the_default').']' : ''), |
|---|
| 1212 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
|---|
| 1213 | 'LASTVISIT' => $local_user['lastvisit'], |
|---|
| 1214 | 'REMINDER' => $reminder, |
|---|
| 1215 | ) |
|---|
| 1216 | ); |
|---|
| 1217 | } |
|---|
| 1218 | |
|---|
| 1219 | // +-----------------------------------------------------------------------+ |
|---|
| 1220 | // | errors display | |
|---|
| 1221 | // +-----------------------------------------------------------------------+ |
|---|
| 1222 | if ( isset ($errors) and count($errors) != 0) |
|---|
| 1223 | { |
|---|
| 1224 | $template->assign('errors',array()); |
|---|
| 1225 | foreach ($errors as $error) |
|---|
| 1226 | { |
|---|
| 1227 | array_push($page['errors'], $error); |
|---|
| 1228 | } |
|---|
| 1229 | } |
|---|
| 1230 | |
|---|
| 1231 | // +-----------------------------------------------------------------------+ |
|---|
| 1232 | // | templates display | |
|---|
| 1233 | // +-----------------------------------------------------------------------+ |
|---|
| 1234 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/ghosttracker.tpl'); |
|---|
| 1235 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
|---|
| 1236 | } |
|---|
| 1237 | else |
|---|
| 1238 | { |
|---|
| 1239 | array_push($page['infos'], l10n('Err_GhostTracker_Settings')); |
|---|
| 1240 | } |
|---|
| 1241 | break; |
|---|
| 1242 | } |
|---|
| 1243 | ?> |
|---|