[5056] | 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 | |
---|
[5181] | 11 | if (!defined('UAM_PATH')) define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
[5056] | 12 | |
---|
| 13 | //ini_set('error_reporting', E_ALL); |
---|
| 14 | //ini_set('display_errors', true); |
---|
| 15 | |
---|
[5593] | 16 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
[5056] | 17 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
| 18 | |
---|
[5181] | 19 | load_language('plugin.lang', UAM_PATH); |
---|
| 20 | load_language('help/plugin.lang', UAM_PATH); |
---|
[5056] | 21 | |
---|
[7955] | 22 | |
---|
| 23 | // +-----------------------------------------------------------------------+ |
---|
| 24 | // | Variables initialization | |
---|
| 25 | // +-----------------------------------------------------------------------+ |
---|
| 26 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
| 27 | |
---|
[5056] | 28 | $page['global'] = array(); |
---|
| 29 | $error = array(); |
---|
| 30 | $pattern = '/;/'; |
---|
| 31 | $replacement = '.'; |
---|
| 32 | |
---|
| 33 | $UAM_Password_Test_Score = 0; |
---|
| 34 | $UAM_Exclusionlist_Error = false; |
---|
| 35 | |
---|
[7955] | 36 | |
---|
[5056] | 37 | // +-----------------------------------------------------------------------+ |
---|
| 38 | // | Tabssheet | |
---|
| 39 | // +-----------------------------------------------------------------------+ |
---|
| 40 | if (!isset($_GET['tab'])) |
---|
| 41 | $page['tab'] = 'global'; |
---|
| 42 | else |
---|
| 43 | $page['tab'] = $_GET['tab']; |
---|
| 44 | |
---|
| 45 | $tabsheet = new tabsheet(); |
---|
| 46 | $tabsheet->add('global', |
---|
[9178] | 47 | l10n('UAM_Tab_Global'), |
---|
[5056] | 48 | $my_base_url.'&tab=global'); |
---|
| 49 | $tabsheet->add('userlist', |
---|
[9178] | 50 | l10n('UAM_Tab_UserList'), |
---|
[5056] | 51 | $my_base_url.'&tab=userlist'); |
---|
| 52 | $tabsheet->add('usermanager', |
---|
[9178] | 53 | l10n('UAM_Tab_UserManager'), |
---|
[5056] | 54 | $my_base_url.'&tab=usermanager'); |
---|
| 55 | $tabsheet->add('ghosttracker', |
---|
[9178] | 56 | l10n('UAM_Tab_GhostTracker'), |
---|
[5056] | 57 | $my_base_url.'&tab=ghosttracker'); |
---|
| 58 | $tabsheet->select($page['tab']); |
---|
| 59 | $tabsheet->assign(); |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | // +-----------------------------------------------------------------------+ |
---|
| 63 | // | Getting plugin version | |
---|
| 64 | // +-----------------------------------------------------------------------+ |
---|
[5181] | 65 | $plugin = PluginInfos(UAM_PATH); |
---|
[5762] | 66 | $version = $plugin['version']; |
---|
[5056] | 67 | |
---|
| 68 | |
---|
| 69 | // +----------------------------------------------------------+ |
---|
| 70 | // | FCK Editor for email text fields | |
---|
| 71 | // +----------------------------------------------------------+ |
---|
[5181] | 72 | $toolbar = 'Basic'; |
---|
[5073] | 73 | $width = '750px'; |
---|
| 74 | $height = '300px'; |
---|
| 75 | $areas = array(); |
---|
[9267] | 76 | array_push( $areas,'UAM_ConfirmMail_Custom_Txt1','UAM_ConfirmMail_Custom_Txt2','UAM_GTAutoDelText','UAM_USRAutoDelText'); |
---|
[5084] | 77 | |
---|
[5073] | 78 | if (function_exists('set_fckeditor_instance')) |
---|
[5084] | 79 | { |
---|
| 80 | $fcke_config = unserialize($conf['FCKEditor']); |
---|
| 81 | foreach($areas as $area) |
---|
| 82 | { |
---|
| 83 | if (!isset($fcke_config[$area])) |
---|
| 84 | { |
---|
| 85 | $fcke_config[$area] = false; |
---|
| 86 | } |
---|
| 87 | } |
---|
| 88 | $conf['FCKEditor'] = serialize($fcke_config); |
---|
| 89 | |
---|
[5073] | 90 | set_fckeditor_instance($areas, $toolbar, $width, $height); |
---|
[5181] | 91 | } |
---|
[5056] | 92 | |
---|
| 93 | |
---|
| 94 | // +-----------------------------------------------------------------------+ |
---|
| 95 | // | Tabssheet select | |
---|
| 96 | // +-----------------------------------------------------------------------+ |
---|
| 97 | |
---|
| 98 | switch ($page['tab']) |
---|
| 99 | { |
---|
| 100 | // ************************************************************************* |
---|
| 101 | // +-----------------------------------------------------------------------+ |
---|
| 102 | // | Global Config | |
---|
| 103 | // +-----------------------------------------------------------------------+ |
---|
| 104 | // ************************************************************************* |
---|
| 105 | case 'global': |
---|
| 106 | |
---|
[9909] | 107 | if (isset($_POST['submit']) and isset($_POST['UAM_Mail_Info']) and isset($_POST['UAM_Username_Char']) and isset($_POST['UAM_Confirm_Mail']) and isset($_POST['UAM_No_Comment_Anonymous']) and isset($_POST['UAM_Password_Enforced']) and isset($_POST['UAM_AdminPassword_Enforced']) and isset($_POST['UAM_GhostUser_Tracker']) and isset($_POST['UAM_Admin_ConfMail']) and isset($_POST['UAM_RedirToProfile']) and isset($_POST['UAM_GTAuto']) and isset($_POST['UAM_GTAutoMail']) and isset($_POST['UAM_CustomPasswRetr']) and isset($_POST['UAM_USRAuto']) and isset($_POST['UAM_USRAutoMail']) and isset($_POST['UAM_Stuffs'])) |
---|
[5056] | 108 | { |
---|
| 109 | |
---|
[7955] | 110 | //General configuration settings |
---|
[6753] | 111 | $_POST['UAM_MailInfo_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_MailInfo_Text']))); |
---|
[5056] | 112 | |
---|
[6753] | 113 | $_POST['UAM_ConfirmMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Text']))); |
---|
[5056] | 114 | |
---|
[6753] | 115 | $_POST['UAM_GhostTracker_ReminderText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GhostTracker_ReminderText']))); |
---|
[8065] | 116 | |
---|
| 117 | $_POST['UAM_GTAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText']))); |
---|
[5056] | 118 | |
---|
[8065] | 119 | $_POST['UAM_GTAutoMailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMailText']))); |
---|
[9136] | 120 | |
---|
[8092] | 121 | $_POST['UAM_AdminValidationMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Text']))); |
---|
[5056] | 122 | |
---|
[9136] | 123 | $_POST['UAM_CustomPasswRetr_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomPasswRetr_Text']))); |
---|
| 124 | |
---|
[9267] | 125 | $_POST['UAM_USRAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText']))); |
---|
| 126 | |
---|
[9154] | 127 | // Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them |
---|
[5056] | 128 | if (preg_match('/^[\s]+/', $_POST['UAM_MailExclusion_List'])) |
---|
| 129 | { |
---|
[9178] | 130 | array_push($page['errors'], l10n('UAM_mail_exclusionlist_error')); |
---|
[5056] | 131 | $UAM_Exclusionlist_Error = true; |
---|
| 132 | } |
---|
[6754] | 133 | |
---|
[8065] | 134 | // Consistency check between ConfirmMail and AutoMail - We cannot use GTAutoMail if ConfirmMail is disabled |
---|
| 135 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 136 | |
---|
| 137 | if (((isset($conf_UAM['1']) and ($conf_UAM['1'] == 'false' or $conf_UAM['1'] == 'local')) or ($_POST['UAM_Confirm_Mail'] == 'false' or $_POST['UAM_Confirm_Mail'] == 'local')) and $_POST['UAM_GTAutoMail'] == 'true') |
---|
| 138 | { |
---|
| 139 | $newvalue = 'false'; |
---|
| 140 | $_POST['UAM_GTAutoMail'] = $newvalue; |
---|
[9178] | 141 | array_push($page['errors'], l10n('UAM_Error_GTAutoMail_cannot_be_set_without_ConfirmMail')); |
---|
[8065] | 142 | } |
---|
| 143 | |
---|
[5056] | 144 | $newconf_UAM = array( |
---|
| 145 | $_POST['UAM_Mail_Info'], |
---|
| 146 | $_POST['UAM_Confirm_Mail'], |
---|
| 147 | (isset($_POST['UAM_No_Confirm_Group'])?$_POST['UAM_No_Confirm_Group']:''), |
---|
| 148 | (isset($_POST['UAM_Validated_Group'])?$_POST['UAM_Validated_Group']:''), |
---|
| 149 | (isset($_POST['UAM_Validated_Status'])?$_POST['UAM_Validated_Status']:''), |
---|
| 150 | $_POST['UAM_No_Comment_Anonymous'], |
---|
| 151 | $_POST['UAM_Username_Char'], |
---|
| 152 | $_POST['UAM_Username_List'], |
---|
| 153 | (isset($_POST['UAM_No_Confirm_Status'])?$_POST['UAM_No_Confirm_Status']:''), |
---|
| 154 | $_POST['UAM_MailInfo_Text'], |
---|
| 155 | $_POST['UAM_ConfirmMail_Text'], |
---|
| 156 | $_POST['UAM_MailExclusion'], |
---|
| 157 | $_POST['UAM_MailExclusion_List'], |
---|
| 158 | $_POST['UAM_Password_Enforced'], |
---|
| 159 | $_POST['UAM_Password_Score'], |
---|
| 160 | $_POST['UAM_AdminPassword_Enforced'], |
---|
| 161 | $_POST['UAM_GhostUser_Tracker'], |
---|
| 162 | $_POST['UAM_GhostTracker_DayLimit'], |
---|
| 163 | $_POST['UAM_GhostTracker_ReminderText'], |
---|
[5064] | 164 | $_POST['UAM_Add_LastVisit_Column'], |
---|
[6775] | 165 | $_POST['UAM_Admin_ConfMail'], |
---|
[8065] | 166 | $_POST['UAM_RedirToProfile'], |
---|
| 167 | $_POST['UAM_GTAuto'], |
---|
| 168 | $_POST['UAM_GTAutoMail'], |
---|
| 169 | $_POST['UAM_GTAutoDelText'], |
---|
| 170 | $_POST['UAM_GTAutoMailText'], |
---|
| 171 | (isset($_POST['UAM_Downgrade_Group'])?$_POST['UAM_Downgrade_Group']:''), |
---|
[8092] | 172 | (isset($_POST['UAM_Downgrade_Status'])?$_POST['UAM_Downgrade_Status']:''), |
---|
[9136] | 173 | $_POST['UAM_AdminValidationMail_Text'], |
---|
| 174 | $_POST['UAM_CustomPasswRetr'], |
---|
[9267] | 175 | $_POST['UAM_CustomPasswRetr_Text'], |
---|
| 176 | $_POST['UAM_USRAuto'], |
---|
| 177 | $_POST['UAM_USRAutoDelText'], |
---|
[9909] | 178 | $_POST['UAM_USRAutoMail'], |
---|
| 179 | $_POST['UAM_Stuffs'] |
---|
[8092] | 180 | ); |
---|
[5056] | 181 | |
---|
[5181] | 182 | $conf['UserAdvManager'] = serialize($newconf_UAM); |
---|
[5056] | 183 | |
---|
| 184 | $query = ' |
---|
| 185 | UPDATE '.CONFIG_TABLE.' |
---|
[5181] | 186 | SET value="'.addslashes($conf['UserAdvManager']).'" |
---|
| 187 | WHERE param="UserAdvManager" |
---|
[5056] | 188 | LIMIT 1 |
---|
| 189 | ;'; |
---|
| 190 | |
---|
| 191 | pwg_query($query); |
---|
| 192 | |
---|
[7955] | 193 | //Email confirmation settings |
---|
[6753] | 194 | $_POST['UAM_ConfirmMail_ReMail_Txt1'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_ReMail_Txt1']))); |
---|
[5056] | 195 | |
---|
[6753] | 196 | $_POST['UAM_ConfirmMail_ReMail_Txt2'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_ReMail_Txt2']))); |
---|
[5181] | 197 | |
---|
[6753] | 198 | $_POST['UAM_ConfirmMail_Custom_Txt1'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Custom_Txt1']))); |
---|
[5181] | 199 | |
---|
[6753] | 200 | $_POST['UAM_ConfirmMail_Custom_Txt2'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Custom_Txt2']))); |
---|
[6754] | 201 | |
---|
[5056] | 202 | $newconf_UAM_ConfirmMail = array ( |
---|
| 203 | $_POST['UAM_ConfirmMail_TimeOut'], |
---|
| 204 | $_POST['UAM_ConfirmMail_Delay'], |
---|
| 205 | $_POST['UAM_ConfirmMail_ReMail_Txt1'], |
---|
| 206 | $_POST['UAM_ConfirmMail_Remail'], |
---|
[5181] | 207 | $_POST['UAM_ConfirmMail_ReMail_Txt2'], |
---|
| 208 | $_POST['UAM_ConfirmMail_Custom_Txt1'], |
---|
| 209 | $_POST['UAM_ConfirmMail_Custom_Txt2']); |
---|
[5056] | 210 | |
---|
[5181] | 211 | $conf['UserAdvManager_ConfirmMail'] = serialize($newconf_UAM_ConfirmMail); |
---|
[5056] | 212 | |
---|
| 213 | $query = ' |
---|
| 214 | UPDATE '.CONFIG_TABLE.' |
---|
[5181] | 215 | SET value="'.addslashes($conf['UserAdvManager_ConfirmMail']).'" |
---|
| 216 | WHERE param="UserAdvManager_ConfirmMail" |
---|
[5056] | 217 | LIMIT 1 |
---|
| 218 | ;'; |
---|
| 219 | |
---|
| 220 | pwg_query($query); |
---|
| 221 | |
---|
| 222 | array_push($page['infos'], l10n('UAM_save_config')); |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | |
---|
[7955] | 226 | //Testing password enforcement |
---|
[8841] | 227 | if (isset($_POST['PasswordTest']) and isset($_POST['UAM_Password_Test']) and !empty($_POST['UAM_Password_Test'])) |
---|
[5056] | 228 | { |
---|
| 229 | $UAM_Password_Test_Score = testpassword($_POST['UAM_Password_Test']); |
---|
| 230 | } |
---|
[8841] | 231 | else if (isset($_POST['PasswordTest']) and empty($_POST['UAM_Password_Test'])) |
---|
[5056] | 232 | { |
---|
[9178] | 233 | array_push($page['errors'], l10n('UAM_reg_err_login3')); |
---|
[5056] | 234 | } |
---|
| 235 | |
---|
[5181] | 236 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 237 | |
---|
[8065] | 238 | //Group setting for unvalidated, validated users and downgrade group |
---|
[5056] | 239 | $groups[-1] = '---------'; |
---|
| 240 | $No_Valid = -1; |
---|
| 241 | $Valid = -1; |
---|
[8065] | 242 | $Downgrade = -1; |
---|
[5056] | 243 | |
---|
[7955] | 244 | //Check groups list in database |
---|
[5056] | 245 | $query = ' |
---|
| 246 | SELECT id, name |
---|
| 247 | FROM '.GROUPS_TABLE.' |
---|
| 248 | ORDER BY name ASC |
---|
| 249 | ;'; |
---|
| 250 | |
---|
| 251 | $result = pwg_query($query); |
---|
| 252 | |
---|
[5633] | 253 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 254 | { |
---|
| 255 | $groups[$row['id']] = $row['name']; |
---|
[7955] | 256 | //configuration value for unvalidated users |
---|
[6354] | 257 | if (isset($conf_UAM[2]) and $conf_UAM[2] == $row['id']) |
---|
[5056] | 258 | { |
---|
| 259 | $No_Valid = $row['id']; |
---|
| 260 | } |
---|
[7955] | 261 | //configuration value for validated users |
---|
[6354] | 262 | if (isset($conf_UAM[3]) and $conf_UAM[3] == $row['id']) |
---|
[5056] | 263 | { |
---|
| 264 | $Valid = $row['id']; |
---|
| 265 | } |
---|
[8065] | 266 | //configuration value for downgrade users |
---|
[8092] | 267 | if (isset($conf_UAM[26]) and $conf_UAM[26] == $row['id']) |
---|
[8065] | 268 | { |
---|
| 269 | $Downgrade = $row['id']; |
---|
| 270 | } |
---|
[5056] | 271 | } |
---|
| 272 | |
---|
[7955] | 273 | //Template initialization for unvalidated users group |
---|
[5056] | 274 | $template->assign( |
---|
| 275 | 'No_Confirm_Group', |
---|
| 276 | array( |
---|
| 277 | 'group_options'=> $groups, |
---|
| 278 | 'group_selected' => $No_Valid |
---|
| 279 | ) |
---|
| 280 | ); |
---|
[7955] | 281 | //Template initialization for validated users group |
---|
[5056] | 282 | $template->assign( |
---|
| 283 | 'Validated_Group', |
---|
| 284 | array( |
---|
| 285 | 'group_options'=> $groups, |
---|
| 286 | 'group_selected' => $Valid |
---|
| 287 | ) |
---|
| 288 | ); |
---|
[8065] | 289 | //Template initialization for downgrade group |
---|
| 290 | $template->assign( |
---|
| 291 | 'Downgrade_Group', |
---|
| 292 | array( |
---|
| 293 | 'group_options'=> $groups, |
---|
| 294 | 'group_selected' => $Downgrade |
---|
| 295 | ) |
---|
| 296 | ); |
---|
[5056] | 297 | |
---|
[8065] | 298 | //Status setting for unvalidated, validated users and downgrade status |
---|
[5056] | 299 | $status_options[-1] = '------------'; |
---|
| 300 | $No_Valid_Status = -1; |
---|
| 301 | $Valid_Status = -1; |
---|
[8065] | 302 | $Downgrade_Status = -1; |
---|
[5056] | 303 | |
---|
[8065] | 304 | //Get unvalidate status values |
---|
[5056] | 305 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
| 306 | { |
---|
| 307 | $status_options[$status] = l10n('user_status_'.$status); |
---|
[6354] | 308 | if (isset($conf_UAM[8]) and $conf_UAM[8] == $status) |
---|
[5056] | 309 | { |
---|
| 310 | $No_Valid_Status = $status; |
---|
| 311 | } |
---|
| 312 | |
---|
[8065] | 313 | //Template initialization for unvalidated users status |
---|
[5056] | 314 | $template->assign( |
---|
| 315 | 'No_Confirm_Status', |
---|
| 316 | array( |
---|
| 317 | 'Status_options' => $status_options, |
---|
| 318 | 'Status_selected' => $No_Valid_Status |
---|
| 319 | ) |
---|
| 320 | ); |
---|
| 321 | } |
---|
| 322 | |
---|
[8065] | 323 | //Get validate status values |
---|
[5056] | 324 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
| 325 | { |
---|
| 326 | $status_options[$status] = l10n('user_status_'.$status); |
---|
[6354] | 327 | if (isset($conf_UAM[4]) and $conf_UAM[4] == $status) |
---|
[5056] | 328 | { |
---|
| 329 | $Valid_Status = $status; |
---|
| 330 | } |
---|
| 331 | |
---|
[8065] | 332 | //Template initialization for validated users status |
---|
[5056] | 333 | $template->assign( |
---|
| 334 | 'Confirm_Status', |
---|
| 335 | array( |
---|
| 336 | 'Status_options' => $status_options, |
---|
| 337 | 'Status_selected' => $Valid_Status |
---|
| 338 | ) |
---|
| 339 | ); |
---|
| 340 | } |
---|
| 341 | |
---|
[8065] | 342 | //Get downgrade status values |
---|
| 343 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
| 344 | { |
---|
| 345 | $status_options[$status] = l10n('user_status_'.$status); |
---|
[8092] | 346 | if (isset($conf_UAM[27]) and $conf_UAM[27] == $status) |
---|
[8065] | 347 | { |
---|
| 348 | $Downgrade_Status = $status; |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | //Template initialization for validated users status |
---|
| 352 | $template->assign( |
---|
| 353 | 'Downgrade_Status', |
---|
| 354 | array( |
---|
| 355 | 'Status_options' => $status_options, |
---|
| 356 | 'Status_selected' => $Downgrade_Status |
---|
| 357 | ) |
---|
| 358 | ); |
---|
| 359 | } |
---|
| 360 | |
---|
[7955] | 361 | //Save last opened paragraph in configuration tab |
---|
[5056] | 362 | $nb_para=(isset($_POST["nb_para"])) ? $_POST["nb_para"]:""; |
---|
| 363 | $nb_para2=(isset($_POST["nb_para2"])) ? $_POST["nb_para2"]:""; |
---|
| 364 | |
---|
[5181] | 365 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[7955] | 366 | |
---|
| 367 | // Template initialization for forms and data |
---|
[5056] | 368 | $template->assign( |
---|
| 369 | array( |
---|
| 370 | 'nb_para' => $nb_para, |
---|
| 371 | 'nb_para2' => $nb_para2, |
---|
| 372 | 'UAM_VERSION' => $version, |
---|
[5181] | 373 | 'UAM_PATH' => UAM_PATH, |
---|
[5056] | 374 | 'UAM_MAIL_INFO_TRUE' => $conf_UAM[0]=='true' ? 'checked="checked"' : '' , |
---|
| 375 | 'UAM_MAIL_INFO_FALSE' => $conf_UAM[0]=='false' ? 'checked="checked"' : '' , |
---|
[6354] | 376 | 'UAM_MAILINFO_TEXT' => $conf_UAM[9], |
---|
| 377 | 'UAM_USERNAME_CHAR_TRUE' => $conf_UAM[6]=='true' ? 'checked="checked"' : '' , |
---|
| 378 | 'UAM_USERNAME_CHAR_FALSE' => $conf_UAM[6]=='false' ? 'checked="checked"' : '' , |
---|
| 379 | 'UAM_USERNAME_CHAR_LIST' => $conf_UAM[7], |
---|
| 380 | 'UAM_CONFIRM_MAIL_TRUE' => $conf_UAM[1]=='true' ? 'checked="checked"' : '' , |
---|
| 381 | 'UAM_CONFIRM_MAIL_FALSE' => $conf_UAM[1]=='false' ? 'checked="checked"' : '' , |
---|
[6754] | 382 | 'UAM_CONFIRM_MAIL_LOCAL' => $conf_UAM[1]=='local' ? 'checked="checked"' : '' , |
---|
[6354] | 383 | 'UAM_CONFIRMMAIL_TEXT' => $conf_UAM[10], |
---|
| 384 | 'UAM_No_Confirm_Group' => $conf_UAM[2], |
---|
| 385 | 'UAM_Validated_Group' => $conf_UAM[3], |
---|
| 386 | 'UAM_No_Confirm_Status' => $conf_UAM[8], |
---|
| 387 | 'UAM_Validated_Status' => $conf_UAM[4], |
---|
| 388 | 'UAM_NO_COMMENT_ANO_TRUE' => $conf_UAM[5]=='true' ? 'checked="checked"' : '' , |
---|
| 389 | 'UAM_NO_COMMENT_ANO_FALSE' => $conf_UAM[5]=='false' ? 'checked="checked"' : '' , |
---|
| 390 | 'UAM_MAILEXCLUSION_TRUE' => $conf_UAM[11]=='true' ? 'checked="checked"' : '' , |
---|
| 391 | 'UAM_MAILEXCLUSION_FALSE' => $conf_UAM[11]=='false' ? 'checked="checked"' : '' , |
---|
| 392 | 'UAM_MAILEXCLUSION_LIST' => $conf_UAM[12], |
---|
| 393 | 'UAM_PASSWORDENF_TRUE' => $conf_UAM[13]=='true' ? 'checked="checked"' : '' , |
---|
| 394 | 'UAM_PASSWORDENF_FALSE' => $conf_UAM[13]=='false' ? 'checked="checked"' : '' , |
---|
| 395 | 'UAM_PASSWORD_SCORE' => $conf_UAM[14], |
---|
| 396 | 'UAM_ADMINPASSWENF_TRUE' => $conf_UAM[15]=='true' ? 'checked="checked"' : '' , |
---|
| 397 | 'UAM_ADMINPASSWENF_FALSE' => $conf_UAM[15]=='false' ? 'checked="checked"' : '' , |
---|
| 398 | 'UAM_GHOSTRACKER_TRUE' => $conf_UAM[16]=='true' ? 'checked="checked"' : '' , |
---|
| 399 | 'UAM_GHOSTRACKER_FALSE' => $conf_UAM[16]=='false' ? 'checked="checked"' : '' , |
---|
| 400 | 'UAM_GHOSTRACKER_DAYLIMIT' => $conf_UAM[17], |
---|
| 401 | 'UAM_GHOSTRACKER_REMINDERTEXT' => $conf_UAM[18], |
---|
| 402 | 'UAM_ADDLASTVISIT_TRUE' => $conf_UAM[19]=='true' ? 'checked="checked"' : '' , |
---|
| 403 | 'UAM_ADDLASTVISIT_FALSE' => $conf_UAM[19]=='false' ? 'checked="checked"' : '' , |
---|
| 404 | 'UAM_ADMINCONFMAIL_TRUE' => $conf_UAM[20]=='true' ? 'checked="checked"' : '' , |
---|
| 405 | 'UAM_ADMINCONFMAIL_FALSE' => $conf_UAM[20]=='false' ? 'checked="checked"' : '' , |
---|
[6775] | 406 | 'UAM_REDIRTOPROFILE_TRUE' => $conf_UAM[21]=='true' ? 'checked="checked"' : '' , |
---|
| 407 | 'UAM_REDIRTOPROFILE_FALSE' => $conf_UAM[21]=='false' ? 'checked="checked"' : '' , |
---|
[8065] | 408 | 'UAM_GTAUTO_TRUE' => $conf_UAM[22]=='true' ? 'checked="checked"' : '' , |
---|
| 409 | 'UAM_GTAUTO_FALSE' => $conf_UAM[22]=='false' ? 'checked="checked"' : '' , |
---|
[8092] | 410 | 'UAM_GTAUTOMAIL_TRUE' => $conf_UAM[23]=='true' ? 'checked="checked"' : '' , |
---|
| 411 | 'UAM_GTAUTOMAIL_FALSE' => $conf_UAM[23]=='false' ? 'checked="checked"' : '' , |
---|
| 412 | 'UAM_GTAUTODEL_TEXT' => $conf_UAM[24], |
---|
| 413 | 'UAM_GTAUTOMAILTEXT' => $conf_UAM[25], |
---|
| 414 | 'UAM_Downgrade_Group' => $conf_UAM[26], |
---|
| 415 | 'UAM_Downgrade_Status' => $conf_UAM[27], |
---|
| 416 | 'UAM_ADMINVALIDATIONMAIL_TEXT' => $conf_UAM[28], |
---|
[9136] | 417 | 'UAM_CUSTOMPASSWRETR_TRUE' => $conf_UAM[29]=='true' ? 'checked="checked"' : '' , |
---|
| 418 | 'UAM_CUSTOMPASSWRETR_FALSE' => $conf_UAM[29]=='false' ? 'checked="checked"' : '' , |
---|
| 419 | 'UAM_CUSTOMPASSWRETR_TEXT' => $conf_UAM[30], |
---|
[9267] | 420 | 'UAM_USRAUTO_TRUE' => $conf_UAM[31]=='true' ? 'checked="checked"' : '' , |
---|
| 421 | 'UAM_USRAUTO_FALSE' => $conf_UAM[31]=='false' ? 'checked="checked"' : '' , |
---|
| 422 | 'UAM_USRAUTODEL_TEXT' => $conf_UAM[32], |
---|
| 423 | 'UAM_USRAUTOMAIL_TRUE' => $conf_UAM[33]=='true' ? 'checked="checked"' : '' , |
---|
| 424 | 'UAM_USRAUTOMAIL_FALSE' => $conf_UAM[33]=='false' ? 'checked="checked"' : '' , |
---|
[9909] | 425 | 'UAM_STUFFS_TRUE' => $conf_UAM[34]=='true' ? 'checked="checked"' : '' , |
---|
| 426 | 'UAM_STUFFS_FALSE' => $conf_UAM[34]=='false' ? 'checked="checked"' : '' , |
---|
[5056] | 427 | 'UAM_PASSWORD_TEST_SCORE' => $UAM_Password_Test_Score, |
---|
| 428 | 'UAM_ERROR_REPORTS4' => $UAM_Exclusionlist_Error, |
---|
| 429 | 'UAM_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_UAM_ConfirmMail[0]=='true' ? 'checked="checked"' : '' , |
---|
| 430 | 'UAM_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_UAM_ConfirmMail[0]=='false' ? 'checked="checked"' : '' , |
---|
| 431 | 'UAM_CONFIRMMAIL_DELAY' => $conf_UAM_ConfirmMail[1], |
---|
| 432 | 'UAM_CONFIRMMAIL_REMAIL_TRUE' => $conf_UAM_ConfirmMail[3]=='true' ? 'checked="checked"' : '', |
---|
| 433 | 'UAM_CONFIRMMAIL_REMAIL_FALSE' => $conf_UAM_ConfirmMail[3]=='false' ? 'checked="checked"' : '', |
---|
| 434 | 'UAM_CONFIRMMAIL_REMAIL_TXT1' => $conf_UAM_ConfirmMail[2], |
---|
| 435 | 'UAM_CONFIRMMAIL_REMAIL_TXT2' => $conf_UAM_ConfirmMail[4], |
---|
[5181] | 436 | 'UAM_CONFIRMMAIL_CUSTOM_TXT1' => $conf_UAM_ConfirmMail[5], |
---|
| 437 | 'UAM_CONFIRMMAIL_CUSTOM_TXT2' => $conf_UAM_ConfirmMail[6], |
---|
[5056] | 438 | ) |
---|
| 439 | ); |
---|
| 440 | |
---|
| 441 | if (isset($_POST['audit'])) |
---|
| 442 | { |
---|
| 443 | $msg_error1 = ''; |
---|
| 444 | |
---|
[7955] | 445 | //Username without forbidden keys |
---|
[6354] | 446 | if ( isset($conf_UAM[6]) and $conf_UAM[6] == 'true' ) |
---|
[5056] | 447 | { |
---|
| 448 | $query = " |
---|
| 449 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
| 450 | FROM ".USERS_TABLE." |
---|
| 451 | ;"; |
---|
| 452 | |
---|
| 453 | $result = pwg_query($query); |
---|
| 454 | |
---|
[5633] | 455 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 456 | { |
---|
| 457 | if (!ValidateUsername(stripslashes($row['username']))) |
---|
[9178] | 458 | $msg_error1 .= (($msg_error1 <> '') ? '<br>' : '') . l10n('UAM_Err_audit_username_char').stripslashes($row['username']); |
---|
[5056] | 459 | } |
---|
| 460 | } |
---|
| 461 | |
---|
[6801] | 462 | $msg_error2 = ''; |
---|
[5056] | 463 | |
---|
[7955] | 464 | //Email without forbidden domain |
---|
[6354] | 465 | if ( isset($conf_UAM[11]) and $conf_UAM[11] == 'true' ) |
---|
[5056] | 466 | { |
---|
| 467 | $query = " |
---|
| 468 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
| 469 | FROM ".USERS_TABLE." |
---|
| 470 | ;"; |
---|
| 471 | |
---|
| 472 | $result = pwg_query($query); |
---|
| 473 | |
---|
[5633] | 474 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 475 | { |
---|
[6354] | 476 | $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[12]); |
---|
[5181] | 477 | for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++) |
---|
[5056] | 478 | { |
---|
[5181] | 479 | $pattern = '/'.$conf_MailExclusion[$i].'/'; |
---|
[5056] | 480 | if (preg_match($pattern, $row['mail_address'])) |
---|
| 481 | { |
---|
[9178] | 482 | $msg_error2 .= (($msg_error2 <> '') ? '<br>' : '') . l10n('UAM_Err_audit_email_forbidden').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
[5056] | 483 | } |
---|
| 484 | } |
---|
| 485 | } |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | if ($msg_error1 <> '') |
---|
[6784] | 489 | $errors[] = $msg_error1.'<br><br>'; |
---|
[5056] | 490 | |
---|
| 491 | if ($msg_error2 <> '') |
---|
[6784] | 492 | $errors[] = $msg_error2.'<br><br>'; |
---|
[5056] | 493 | |
---|
[6801] | 494 | if ($msg_error1 <> '' or $msg_error2 <> '') |
---|
[9178] | 495 | array_push($page['errors'], l10n('UAM_Err_audit_advise')); |
---|
[5056] | 496 | else |
---|
| 497 | array_push($page['infos'], l10n('UAM_audit_ok')); |
---|
| 498 | } |
---|
| 499 | |
---|
| 500 | |
---|
| 501 | // +-----------------------------------------------------------------------+ |
---|
| 502 | // | errors display | |
---|
| 503 | // +-----------------------------------------------------------------------+ |
---|
| 504 | if (isset ($errors) and count($errors) != 0) |
---|
| 505 | { |
---|
| 506 | $template->assign('errors',array()); |
---|
| 507 | foreach ($errors as $error) |
---|
| 508 | { |
---|
| 509 | array_push($page['errors'], $error); |
---|
| 510 | } |
---|
| 511 | } |
---|
| 512 | |
---|
| 513 | // +-----------------------------------------------------------------------+ |
---|
| 514 | // | templates display | |
---|
| 515 | // +-----------------------------------------------------------------------+ |
---|
[5593] | 516 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl'); |
---|
[5056] | 517 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 518 | |
---|
| 519 | break; |
---|
| 520 | |
---|
| 521 | |
---|
| 522 | // ************************************************************************* |
---|
| 523 | // +-----------------------------------------------------------------------+ |
---|
| 524 | // | Users list page | |
---|
| 525 | // +-----------------------------------------------------------------------+ |
---|
| 526 | // ************************************************************************* |
---|
| 527 | case 'userlist': |
---|
| 528 | |
---|
[5181] | 529 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 530 | |
---|
[6354] | 531 | if (isset($conf_UAM[19]) and $conf_UAM[19]=='true') |
---|
[5056] | 532 | { |
---|
| 533 | // +-----------------------------------------------------------------------+ |
---|
| 534 | // | initialization | |
---|
| 535 | // +-----------------------------------------------------------------------+ |
---|
| 536 | |
---|
| 537 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 538 | { |
---|
| 539 | die('Hacking attempt!'); |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 543 | |
---|
| 544 | // +-----------------------------------------------------------------------+ |
---|
| 545 | // | Check Access and exit when user status is not ok | |
---|
| 546 | // +-----------------------------------------------------------------------+ |
---|
| 547 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 548 | |
---|
| 549 | |
---|
| 550 | // +-----------------------------------------------------------------------+ |
---|
| 551 | // | user list | |
---|
| 552 | // +-----------------------------------------------------------------------+ |
---|
| 553 | |
---|
| 554 | $page['filtered_users'] = get_user_list(); |
---|
| 555 | |
---|
| 556 | // +-----------------------------------------------------------------------+ |
---|
| 557 | // | user list | |
---|
| 558 | // +-----------------------------------------------------------------------+ |
---|
| 559 | |
---|
| 560 | $visible_user_list = array(); |
---|
| 561 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
| 562 | { |
---|
| 563 | $visible_user_list[] = $local_user; |
---|
| 564 | } |
---|
| 565 | |
---|
| 566 | foreach ($visible_user_list as $local_user) |
---|
| 567 | { |
---|
| 568 | // dates formating and compare |
---|
| 569 | $today = date("d-m-Y"); // Get today's date |
---|
| 570 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
| 571 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
| 572 | |
---|
| 573 | list($regdate, $regtime) = explode(' ', $local_user['lastvisit']); // Explode date and time from registration date |
---|
| 574 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
| 575 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
| 576 | |
---|
| 577 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
| 578 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
| 579 | |
---|
[6354] | 580 | if (isset($conf_UAM[16]) and $conf_UAM[16]=='true' and $conf_UAM[17] <> '') |
---|
[5056] | 581 | { |
---|
[6354] | 582 | if ($deltadays <= ($conf_UAM[17]/2)) |
---|
[5056] | 583 | { |
---|
| 584 | $display = 'green'; |
---|
| 585 | } |
---|
| 586 | |
---|
[6354] | 587 | if (($deltadays > ($conf_UAM[17]/2)) and ($deltadays < $conf_UAM[17])) |
---|
[5056] | 588 | { |
---|
| 589 | $display = 'orange'; |
---|
| 590 | } |
---|
| 591 | |
---|
[6354] | 592 | if ($deltadays >= $conf_UAM[17]) |
---|
[5056] | 593 | { |
---|
| 594 | $display = 'red'; |
---|
| 595 | } |
---|
| 596 | } |
---|
[5105] | 597 | else $display = ''; |
---|
[5056] | 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 | } |
---|
[7955] | 611 | //Plugin version inserted |
---|
[5593] | 612 | $template->assign( |
---|
| 613 | array( |
---|
| 614 | 'UAM_VERSION' => $version, |
---|
| 615 | 'UAM_PATH' => UAM_PATH, |
---|
| 616 | ) |
---|
| 617 | ); |
---|
[5056] | 618 | // +-----------------------------------------------------------------------+ |
---|
| 619 | // | errors display | |
---|
| 620 | // +-----------------------------------------------------------------------+ |
---|
| 621 | if ( isset ($errors) and count($errors) != 0) |
---|
| 622 | { |
---|
| 623 | $template->assign('errors',array()); |
---|
| 624 | foreach ($errors as $error) |
---|
| 625 | { |
---|
| 626 | array_push($page['errors'], $error); |
---|
| 627 | } |
---|
| 628 | } |
---|
| 629 | |
---|
| 630 | // +-----------------------------------------------------------------------+ |
---|
| 631 | // | templates display | |
---|
| 632 | // +-----------------------------------------------------------------------+ |
---|
[5593] | 633 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/userlist.tpl'); |
---|
[5056] | 634 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 635 | } |
---|
| 636 | else |
---|
| 637 | { |
---|
[9178] | 638 | array_push($page['errors'], l10n('UAM_Err_Userlist_Settings')); |
---|
[5056] | 639 | } |
---|
| 640 | break; |
---|
| 641 | |
---|
| 642 | |
---|
| 643 | // ************************************************************************* |
---|
| 644 | // +-----------------------------------------------------------------------+ |
---|
| 645 | // | Users manager page | |
---|
| 646 | // +-----------------------------------------------------------------------+ |
---|
| 647 | // ************************************************************************* |
---|
| 648 | case 'usermanager': |
---|
| 649 | |
---|
[5181] | 650 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 651 | |
---|
[5181] | 652 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 653 | |
---|
[6754] | 654 | if (isset($conf_UAM[1]) and ($conf_UAM[1]=='true' or $conf_UAM[1]=='local') and ((isset($conf_UAM[2]) and $conf_UAM[2] <> '-1') or (isset($conf_UAM[8]) and $conf_UAM[8] <> '-1'))) |
---|
[8072] | 655 | { |
---|
[5056] | 656 | // +-----------------------------------------------------------------------+ |
---|
| 657 | // | initialization | |
---|
| 658 | // +-----------------------------------------------------------------------+ |
---|
| 659 | |
---|
| 660 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 661 | { |
---|
| 662 | die('Hacking attempt!'); |
---|
| 663 | } |
---|
[8072] | 664 | |
---|
[5056] | 665 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 666 | |
---|
| 667 | // +-----------------------------------------------------------------------+ |
---|
| 668 | // | Check Access and exit when user status is not ok | |
---|
| 669 | // +-----------------------------------------------------------------------+ |
---|
| 670 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 671 | |
---|
| 672 | // +-----------------------------------------------------------------------+ |
---|
| 673 | // | user list | |
---|
| 674 | // +-----------------------------------------------------------------------+ |
---|
| 675 | |
---|
| 676 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 677 | |
---|
| 678 | // +-----------------------------------------------------------------------+ |
---|
| 679 | // | selected users | |
---|
| 680 | // +-----------------------------------------------------------------------+ |
---|
| 681 | if (isset($_POST['Del_Selected'])) |
---|
| 682 | { |
---|
| 683 | $collection = array(); |
---|
| 684 | |
---|
| 685 | switch ($_POST['target']) |
---|
| 686 | { |
---|
| 687 | case 'all' : |
---|
| 688 | { |
---|
| 689 | foreach($page['filtered_users'] as $local_user) |
---|
| 690 | { |
---|
| 691 | array_push($collection, $local_user['id']); |
---|
| 692 | } |
---|
| 693 | break; |
---|
| 694 | } |
---|
| 695 | case 'selection' : |
---|
| 696 | { |
---|
| 697 | if (isset($_POST['selection'])) |
---|
| 698 | { |
---|
| 699 | $collection = $_POST['selection']; |
---|
| 700 | } |
---|
| 701 | break; |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | |
---|
| 705 | if (count($collection) == 0) |
---|
| 706 | { |
---|
| 707 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 708 | } |
---|
| 709 | } |
---|
| 710 | |
---|
| 711 | // +-----------------------------------------------------------------------+ |
---|
| 712 | // | delete users | |
---|
| 713 | // +-----------------------------------------------------------------------+ |
---|
| 714 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
---|
| 715 | { |
---|
| 716 | if (in_array($conf['guest_id'], $collection)) |
---|
| 717 | { |
---|
| 718 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
| 719 | } |
---|
| 720 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 721 | in_array($conf['default_user_id'], $collection)) |
---|
| 722 | { |
---|
| 723 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
| 724 | } |
---|
| 725 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 726 | { |
---|
| 727 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
| 728 | } |
---|
| 729 | if (in_array($user['id'], $collection)) |
---|
| 730 | { |
---|
| 731 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
| 732 | } |
---|
| 733 | |
---|
| 734 | if (count($page['errors']) == 0) |
---|
| 735 | { |
---|
| 736 | foreach ($collection as $user_id) |
---|
| 737 | { |
---|
| 738 | delete_user($user_id); |
---|
| 739 | } |
---|
| 740 | array_push( |
---|
| 741 | $page['infos'], |
---|
| 742 | l10n_dec( |
---|
| 743 | '%d user deleted', '%d users deleted', |
---|
| 744 | count($collection) |
---|
| 745 | ) |
---|
| 746 | ); |
---|
| 747 | |
---|
| 748 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
| 749 | { |
---|
| 750 | if (in_array($filter_user['id'], $collection)) |
---|
| 751 | { |
---|
| 752 | unset($page['filtered_users'][$filter_key]); |
---|
| 753 | } |
---|
| 754 | } |
---|
| 755 | } |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | // +-----------------------------------------------------------------------+ |
---|
| 759 | // | Resend new validation key to users | |
---|
| 760 | // +-----------------------------------------------------------------------+ |
---|
| 761 | // +-----------------------------------------------------------------------+ |
---|
| 762 | // | selected users | |
---|
| 763 | // +-----------------------------------------------------------------------+ |
---|
| 764 | if (isset($_POST['Mail_With_Key'])) |
---|
| 765 | { |
---|
| 766 | $collection = array(); |
---|
| 767 | |
---|
| 768 | switch ($_POST['target']) |
---|
| 769 | { |
---|
| 770 | case 'all' : |
---|
| 771 | { |
---|
| 772 | foreach($page['filtered_users'] as $local_user) |
---|
| 773 | { |
---|
| 774 | array_push($collection, $local_user['id']); |
---|
| 775 | } |
---|
| 776 | break; |
---|
| 777 | } |
---|
| 778 | case 'selection' : |
---|
| 779 | { |
---|
| 780 | if (isset($_POST['selection'])) |
---|
| 781 | { |
---|
| 782 | $collection = $_POST['selection']; |
---|
| 783 | } |
---|
| 784 | break; |
---|
| 785 | } |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | if (count($collection) == 0) |
---|
| 789 | { |
---|
| 790 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 791 | } |
---|
| 792 | } |
---|
| 793 | // +-----------------------------------------------------------------------+ |
---|
| 794 | // | Resend new validation key to users | |
---|
| 795 | // +-----------------------------------------------------------------------+ |
---|
| 796 | if (isset($_POST['Mail_With_Key']) and count($collection) > 0) |
---|
| 797 | { |
---|
| 798 | if (in_array($conf['guest_id'], $collection)) |
---|
| 799 | { |
---|
[9178] | 800 | array_push($page['errors'], l10n('UAM_No_validation_for_Guest')); |
---|
[5056] | 801 | } |
---|
| 802 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 803 | in_array($conf['default_user_id'], $collection)) |
---|
| 804 | { |
---|
[9178] | 805 | array_push($page['errors'], l10n('UAM_No_validation_for_default_user')); |
---|
[5056] | 806 | } |
---|
| 807 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 808 | { |
---|
[9178] | 809 | array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster')); |
---|
[5056] | 810 | } |
---|
| 811 | if (in_array($user['id'], $collection)) |
---|
| 812 | { |
---|
[9178] | 813 | array_push($page['errors'], l10n('UAM_No_validation_for_your_account')); |
---|
[5056] | 814 | } |
---|
| 815 | |
---|
| 816 | if (count($page['errors']) == 0) |
---|
| 817 | { |
---|
| 818 | foreach ($collection as $user_id) |
---|
| 819 | { |
---|
| 820 | $typemail = 1; |
---|
| 821 | $query = " |
---|
| 822 | SELECT id, username, mail_address |
---|
| 823 | FROM ".USERS_TABLE." |
---|
| 824 | WHERE id = '".$user_id."' |
---|
| 825 | ;"; |
---|
[5633] | 826 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 827 | |
---|
| 828 | ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],true); |
---|
| 829 | } |
---|
| 830 | array_push( |
---|
| 831 | $page['infos'], |
---|
| 832 | l10n_dec( |
---|
[9178] | 833 | 'UAM_%d_Mail_With_Key', 'UAM_%d_Mails_With_Key', |
---|
[5056] | 834 | count($collection) |
---|
| 835 | ) |
---|
| 836 | ); |
---|
| 837 | |
---|
| 838 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 839 | } |
---|
| 840 | } |
---|
| 841 | |
---|
| 842 | // +-----------------------------------------------------------------------+ |
---|
| 843 | // | Send reminder without new key to users | |
---|
| 844 | // +-----------------------------------------------------------------------+ |
---|
| 845 | // +-----------------------------------------------------------------------+ |
---|
| 846 | // | selected users | |
---|
| 847 | // +-----------------------------------------------------------------------+ |
---|
| 848 | if (isset($_POST['Mail_Without_Key'])) |
---|
| 849 | { |
---|
| 850 | $collection = array(); |
---|
| 851 | |
---|
| 852 | switch ($_POST['target']) |
---|
| 853 | { |
---|
| 854 | case 'all' : |
---|
| 855 | { |
---|
| 856 | foreach($page['filtered_users'] as $local_user) |
---|
| 857 | { |
---|
| 858 | array_push($collection, $local_user['id']); |
---|
| 859 | } |
---|
| 860 | break; |
---|
| 861 | } |
---|
| 862 | case 'selection' : |
---|
| 863 | { |
---|
| 864 | if (isset($_POST['selection'])) |
---|
| 865 | { |
---|
| 866 | $collection = $_POST['selection']; |
---|
| 867 | } |
---|
| 868 | break; |
---|
| 869 | } |
---|
| 870 | } |
---|
| 871 | |
---|
| 872 | if (count($collection) == 0) |
---|
| 873 | { |
---|
| 874 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 875 | } |
---|
| 876 | } |
---|
| 877 | // +-----------------------------------------------------------------------+ |
---|
| 878 | // | Send reminder without new key to users | |
---|
| 879 | // +-----------------------------------------------------------------------+ |
---|
| 880 | if (isset($_POST['Mail_Without_Key']) and count($collection) > 0) |
---|
| 881 | { |
---|
| 882 | if (in_array($conf['guest_id'], $collection)) |
---|
| 883 | { |
---|
[9178] | 884 | array_push($page['errors'], l10n('UAM_No_validation_for_Guest')); |
---|
[5056] | 885 | } |
---|
| 886 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 887 | in_array($conf['default_user_id'], $collection)) |
---|
| 888 | { |
---|
[9178] | 889 | array_push($page['errors'], l10n('UAM_No_validation_for_default_user')); |
---|
[5056] | 890 | } |
---|
| 891 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 892 | { |
---|
[9178] | 893 | array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster')); |
---|
[5056] | 894 | } |
---|
| 895 | if (in_array($user['id'], $collection)) |
---|
| 896 | { |
---|
[9178] | 897 | array_push($page['errors'], l10n('UAM_No_validation_for_your_account')); |
---|
[5056] | 898 | } |
---|
| 899 | |
---|
| 900 | if (count($page['errors']) == 0) |
---|
| 901 | { |
---|
| 902 | foreach ($collection as $user_id) |
---|
| 903 | { |
---|
| 904 | $typemail = 2; |
---|
| 905 | $query = " |
---|
| 906 | SELECT id, username, mail_address |
---|
| 907 | FROM ".USERS_TABLE." |
---|
| 908 | WHERE id = '".$user_id."' |
---|
| 909 | ;"; |
---|
| 910 | |
---|
[5633] | 911 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 912 | |
---|
| 913 | ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],false); |
---|
| 914 | } |
---|
| 915 | array_push( |
---|
| 916 | $page['infos'], |
---|
| 917 | l10n_dec( |
---|
[9178] | 918 | 'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent', |
---|
[5056] | 919 | count($collection) |
---|
| 920 | ) |
---|
| 921 | ); |
---|
| 922 | |
---|
| 923 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 924 | } |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | // +-----------------------------------------------------------------------+ |
---|
| 928 | // | Force validation | |
---|
| 929 | // +-----------------------------------------------------------------------+ |
---|
| 930 | // +-----------------------------------------------------------------------+ |
---|
| 931 | // | selected users | |
---|
| 932 | // +-----------------------------------------------------------------------+ |
---|
| 933 | if (isset($_POST['Force_Validation'])) |
---|
| 934 | { |
---|
| 935 | $collection = array(); |
---|
| 936 | |
---|
| 937 | switch ($_POST['target']) |
---|
| 938 | { |
---|
| 939 | case 'all' : |
---|
| 940 | { |
---|
| 941 | foreach($page['filtered_users'] as $local_user) |
---|
| 942 | { |
---|
| 943 | array_push($collection, $local_user['id']); |
---|
| 944 | } |
---|
| 945 | break; |
---|
| 946 | } |
---|
| 947 | case 'selection' : |
---|
| 948 | { |
---|
| 949 | if (isset($_POST['selection'])) |
---|
| 950 | { |
---|
| 951 | $collection = $_POST['selection']; |
---|
| 952 | } |
---|
| 953 | break; |
---|
| 954 | } |
---|
| 955 | } |
---|
| 956 | |
---|
| 957 | if (count($collection) == 0) |
---|
| 958 | { |
---|
| 959 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 960 | } |
---|
| 961 | } |
---|
| 962 | // +-----------------------------------------------------------------------+ |
---|
| 963 | // | Force validation | |
---|
| 964 | // +-----------------------------------------------------------------------+ |
---|
| 965 | if (isset($_POST['Force_Validation']) and count($collection) > 0) |
---|
| 966 | { |
---|
| 967 | if (in_array($conf['guest_id'], $collection)) |
---|
| 968 | { |
---|
[9178] | 969 | array_push($page['errors'], l10n('UAM_No_validation_for_Guest')); |
---|
[5056] | 970 | } |
---|
| 971 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 972 | in_array($conf['default_user_id'], $collection)) |
---|
| 973 | { |
---|
[9178] | 974 | array_push($page['errors'], l10n('UAM_No_validation_for_default_user')); |
---|
[5056] | 975 | } |
---|
| 976 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 977 | { |
---|
[9178] | 978 | array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster')); |
---|
[5056] | 979 | } |
---|
| 980 | if (in_array($user['id'], $collection)) |
---|
| 981 | { |
---|
[9178] | 982 | array_push($page['errors'], l10n('UAM_No_validation_for_your_account')); |
---|
[5056] | 983 | } |
---|
| 984 | |
---|
| 985 | if (count($page['errors']) == 0) |
---|
| 986 | { |
---|
| 987 | foreach ($collection as $user_id) |
---|
| 988 | { |
---|
[8072] | 989 | ForceValidation($user_id); |
---|
[8092] | 990 | validation_mail($user_id); |
---|
[5056] | 991 | } |
---|
| 992 | array_push( |
---|
| 993 | $page['infos'], |
---|
| 994 | l10n_dec( |
---|
[9178] | 995 | 'UAM_%d_Validated_User', 'UAM_%d_Validated_Users', |
---|
[5056] | 996 | count($collection) |
---|
| 997 | ) |
---|
| 998 | ); |
---|
| 999 | |
---|
| 1000 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 1001 | } |
---|
| 1002 | } |
---|
| 1003 | |
---|
| 1004 | |
---|
| 1005 | // +-----------------------------------------------------------------------+ |
---|
| 1006 | // | groups list | |
---|
| 1007 | // +-----------------------------------------------------------------------+ |
---|
| 1008 | |
---|
| 1009 | $groups[-1] = '------------'; |
---|
| 1010 | |
---|
| 1011 | $query = ' |
---|
| 1012 | SELECT id, name |
---|
| 1013 | FROM '.GROUPS_TABLE.' |
---|
| 1014 | ORDER BY name ASC |
---|
| 1015 | ;'; |
---|
| 1016 | |
---|
| 1017 | $result = pwg_query($query); |
---|
| 1018 | |
---|
[5633] | 1019 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 1020 | { |
---|
| 1021 | $groups[$row['id']] = $row['name']; |
---|
| 1022 | } |
---|
| 1023 | |
---|
| 1024 | // +-----------------------------------------------------------------------+ |
---|
| 1025 | // | user list | |
---|
| 1026 | // +-----------------------------------------------------------------------+ |
---|
| 1027 | |
---|
| 1028 | $profile_url = get_root_url().'admin.php?page=profile&user_id='; |
---|
| 1029 | $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; |
---|
| 1030 | |
---|
| 1031 | $visible_user_list = array(); |
---|
| 1032 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
| 1033 | { |
---|
| 1034 | $visible_user_list[] = $local_user; |
---|
| 1035 | } |
---|
| 1036 | |
---|
| 1037 | foreach ($visible_user_list as $local_user) |
---|
| 1038 | { |
---|
| 1039 | $groups_string = preg_replace( |
---|
| 1040 | '/(\d+)/e', |
---|
| 1041 | "\$groups['$1']", |
---|
| 1042 | implode( |
---|
| 1043 | ', ', |
---|
| 1044 | $local_user['groups'] |
---|
| 1045 | ) |
---|
| 1046 | ); |
---|
| 1047 | |
---|
| 1048 | $query = ' |
---|
| 1049 | SELECT user_id, reminder |
---|
| 1050 | FROM '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 1051 | WHERE user_id = '.$local_user['id'].' |
---|
| 1052 | ;'; |
---|
| 1053 | $result = pwg_query($query); |
---|
| 1054 | |
---|
[5633] | 1055 | $row = pwg_db_fetch_assoc($result); |
---|
[5056] | 1056 | |
---|
| 1057 | if (isset($row['reminder']) and $row['reminder'] == 'true') |
---|
| 1058 | { |
---|
[9178] | 1059 | $reminder = l10n('UAM_Reminder_Sent_OK'); |
---|
[5056] | 1060 | } |
---|
| 1061 | else if ((isset($row['reminder']) and $row['reminder'] == 'false') or !isset($row['reminder'])) |
---|
| 1062 | { |
---|
[9178] | 1063 | $reminder = l10n('UAM_Reminder_Sent_NOK'); |
---|
[5056] | 1064 | } |
---|
| 1065 | |
---|
| 1066 | |
---|
| 1067 | if (isset($_POST['pref_submit']) |
---|
| 1068 | and isset($_POST['selection']) |
---|
| 1069 | and in_array($local_user['id'], $_POST['selection'])) |
---|
| 1070 | { |
---|
| 1071 | $checked = 'checked="checked"'; |
---|
| 1072 | } |
---|
| 1073 | else |
---|
| 1074 | { |
---|
| 1075 | $checked = ''; |
---|
| 1076 | } |
---|
| 1077 | |
---|
| 1078 | $properties = array(); |
---|
| 1079 | if ( $local_user['level'] != 0 ) |
---|
| 1080 | { |
---|
| 1081 | $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); |
---|
| 1082 | } |
---|
| 1083 | $properties[] = |
---|
| 1084 | (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) |
---|
| 1085 | ? l10n('is_high_enabled') : l10n('is_high_disabled'); |
---|
| 1086 | |
---|
| 1087 | $expiration = expiration($local_user['id']); |
---|
[6754] | 1088 | |
---|
[5056] | 1089 | $template->append( |
---|
| 1090 | 'users', |
---|
| 1091 | array( |
---|
| 1092 | 'ID' => $local_user['id'], |
---|
| 1093 | 'CHECKED' => $checked, |
---|
| 1094 | 'U_PROFILE' => $profile_url.$local_user['id'], |
---|
| 1095 | 'U_PERM' => $perm_url.$local_user['id'], |
---|
| 1096 | 'USERNAME' => stripslashes($local_user['username']) |
---|
| 1097 | .($local_user['id'] == $conf['guest_id'] |
---|
| 1098 | ? '<BR>['.l10n('is_the_guest').']' : '') |
---|
| 1099 | .($local_user['id'] == $conf['default_user_id'] |
---|
| 1100 | ? '<BR>['.l10n('is_the_default').']' : ''), |
---|
| 1101 | 'STATUS' => l10n('user_status_' |
---|
[8841] | 1102 | .$local_user['status']), |
---|
[5056] | 1103 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
| 1104 | 'GROUPS' => $groups_string, |
---|
| 1105 | 'REGISTRATION' => $local_user['registration_date'], |
---|
| 1106 | 'REMINDER' => $reminder, |
---|
| 1107 | 'EXPIRATION' => $expiration, |
---|
| 1108 | ) |
---|
| 1109 | ); |
---|
[6754] | 1110 | } |
---|
| 1111 | |
---|
| 1112 | // Check if validation of register is made by admin or visitor |
---|
| 1113 | // If visitor, $Confirm_Local is used to mask useless buttons |
---|
| 1114 | $Confirm_Local = ""; |
---|
| 1115 | |
---|
| 1116 | if ($conf_UAM[1] == 'local') |
---|
| 1117 | { |
---|
| 1118 | $Confirm_Local = $conf_UAM[1]; |
---|
| 1119 | } |
---|
| 1120 | else |
---|
| 1121 | { |
---|
| 1122 | $Confirm_Local = ""; |
---|
| 1123 | } |
---|
| 1124 | |
---|
[7955] | 1125 | //Plugin version inserted |
---|
[5056] | 1126 | $template->assign( |
---|
| 1127 | array( |
---|
[6754] | 1128 | 'CONFIRM_LOCAL'=> $Confirm_Local, |
---|
[5181] | 1129 | 'UAM_VERSION' => $version, |
---|
| 1130 | 'UAM_PATH' => UAM_PATH, |
---|
[5056] | 1131 | ) |
---|
| 1132 | ); |
---|
| 1133 | |
---|
| 1134 | // +-----------------------------------------------------------------------+ |
---|
| 1135 | // | errors display | |
---|
| 1136 | // +-----------------------------------------------------------------------+ |
---|
| 1137 | if ( isset ($errors) and count($errors) != 0) |
---|
| 1138 | { |
---|
| 1139 | $template->assign('errors',array()); |
---|
| 1140 | foreach ($errors as $error) |
---|
| 1141 | { |
---|
| 1142 | array_push($page['errors'], $error); |
---|
| 1143 | } |
---|
| 1144 | } |
---|
| 1145 | |
---|
| 1146 | // +-----------------------------------------------------------------------+ |
---|
| 1147 | // | templates display | |
---|
| 1148 | // +-----------------------------------------------------------------------+ |
---|
[5593] | 1149 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/usermanager.tpl'); |
---|
[5056] | 1150 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 1151 | } |
---|
| 1152 | else |
---|
| 1153 | { |
---|
[9178] | 1154 | array_push($page['errors'], l10n('UAM_Err_UserManager_Settings')); |
---|
[5056] | 1155 | } |
---|
| 1156 | break; |
---|
| 1157 | |
---|
| 1158 | |
---|
| 1159 | // ************************************************************************* |
---|
| 1160 | // +-----------------------------------------------------------------------+ |
---|
| 1161 | // | Ghost Tracker page | |
---|
| 1162 | // +-----------------------------------------------------------------------+ |
---|
| 1163 | // ************************************************************************* |
---|
| 1164 | case 'ghosttracker': |
---|
| 1165 | |
---|
[5181] | 1166 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1167 | |
---|
[6354] | 1168 | if (isset($conf_UAM[16]) and $conf_UAM[16]=='true') |
---|
[5056] | 1169 | { |
---|
| 1170 | // +-----------------------------------------------------------------------+ |
---|
| 1171 | // | initialization | |
---|
| 1172 | // +-----------------------------------------------------------------------+ |
---|
| 1173 | |
---|
| 1174 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 1175 | { |
---|
| 1176 | die('Hacking attempt!'); |
---|
| 1177 | } |
---|
| 1178 | |
---|
| 1179 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 1180 | |
---|
| 1181 | // +-----------------------------------------------------------------------+ |
---|
| 1182 | // | Check Access and exit when user status is not ok | |
---|
| 1183 | // +-----------------------------------------------------------------------+ |
---|
| 1184 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 1185 | |
---|
| 1186 | // +-----------------------------------------------------------------------+ |
---|
| 1187 | // | user list | |
---|
| 1188 | // +-----------------------------------------------------------------------+ |
---|
| 1189 | |
---|
| 1190 | $page['filtered_users'] = get_ghost_user_list(); |
---|
| 1191 | |
---|
| 1192 | // +-----------------------------------------------------------------------+ |
---|
| 1193 | // | selected users | |
---|
| 1194 | // +-----------------------------------------------------------------------+ |
---|
| 1195 | if (isset($_POST['Del_Selected'])) |
---|
| 1196 | { |
---|
| 1197 | $collection = array(); |
---|
| 1198 | |
---|
| 1199 | switch ($_POST['target']) |
---|
| 1200 | { |
---|
| 1201 | case 'all' : |
---|
| 1202 | { |
---|
| 1203 | foreach($page['filtered_users'] as $local_user) |
---|
| 1204 | { |
---|
| 1205 | array_push($collection, $local_user['id']); |
---|
| 1206 | } |
---|
| 1207 | break; |
---|
| 1208 | } |
---|
| 1209 | case 'selection' : |
---|
| 1210 | { |
---|
| 1211 | if (isset($_POST['selection'])) |
---|
| 1212 | { |
---|
| 1213 | $collection = $_POST['selection']; |
---|
| 1214 | } |
---|
| 1215 | break; |
---|
| 1216 | } |
---|
| 1217 | } |
---|
| 1218 | |
---|
| 1219 | if (count($collection) == 0) |
---|
| 1220 | { |
---|
| 1221 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 1222 | } |
---|
| 1223 | } |
---|
| 1224 | |
---|
| 1225 | // +-----------------------------------------------------------------------+ |
---|
| 1226 | // | delete users | |
---|
| 1227 | // +-----------------------------------------------------------------------+ |
---|
| 1228 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
---|
| 1229 | { |
---|
| 1230 | if (in_array($conf['guest_id'], $collection)) |
---|
| 1231 | { |
---|
| 1232 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
| 1233 | } |
---|
| 1234 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 1235 | in_array($conf['default_user_id'], $collection)) |
---|
| 1236 | { |
---|
| 1237 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
| 1238 | } |
---|
| 1239 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 1240 | { |
---|
| 1241 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
| 1242 | } |
---|
| 1243 | if (in_array($user['id'], $collection)) |
---|
| 1244 | { |
---|
| 1245 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
| 1246 | } |
---|
| 1247 | |
---|
| 1248 | if (count($page['errors']) == 0) |
---|
| 1249 | { |
---|
| 1250 | foreach ($collection as $user_id) |
---|
| 1251 | { |
---|
| 1252 | delete_user($user_id); |
---|
| 1253 | } |
---|
| 1254 | array_push( |
---|
| 1255 | $page['infos'], |
---|
| 1256 | l10n_dec( |
---|
| 1257 | '%d user deleted', '%d users deleted', |
---|
| 1258 | count($collection) |
---|
| 1259 | ) |
---|
| 1260 | ); |
---|
| 1261 | |
---|
| 1262 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
| 1263 | { |
---|
| 1264 | if (in_array($filter_user['id'], $collection)) |
---|
| 1265 | { |
---|
| 1266 | unset($page['filtered_users'][$filter_key]); |
---|
| 1267 | } |
---|
| 1268 | } |
---|
| 1269 | } |
---|
| 1270 | } |
---|
| 1271 | |
---|
| 1272 | // +-----------------------------------------------------------------------+ |
---|
| 1273 | // | Send ghost reminder | |
---|
| 1274 | // +-----------------------------------------------------------------------+ |
---|
| 1275 | // +-----------------------------------------------------------------------+ |
---|
| 1276 | // | selected users | |
---|
| 1277 | // +-----------------------------------------------------------------------+ |
---|
| 1278 | if (isset($_POST['Reminder_Email'])) |
---|
| 1279 | { |
---|
| 1280 | $collection = array(); |
---|
| 1281 | |
---|
| 1282 | switch ($_POST['target']) |
---|
| 1283 | { |
---|
| 1284 | case 'all' : |
---|
| 1285 | { |
---|
| 1286 | foreach($page['filtered_users'] as $local_user) |
---|
| 1287 | { |
---|
| 1288 | array_push($collection, $local_user['id']); |
---|
| 1289 | } |
---|
| 1290 | break; |
---|
| 1291 | } |
---|
| 1292 | case 'selection' : |
---|
| 1293 | { |
---|
| 1294 | if (isset($_POST['selection'])) |
---|
| 1295 | { |
---|
| 1296 | $collection = $_POST['selection']; |
---|
| 1297 | } |
---|
| 1298 | break; |
---|
| 1299 | } |
---|
| 1300 | } |
---|
| 1301 | |
---|
| 1302 | if (count($collection) == 0) |
---|
| 1303 | { |
---|
| 1304 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 1305 | } |
---|
| 1306 | } |
---|
| 1307 | // +-----------------------------------------------------------------------+ |
---|
| 1308 | // | Send ghost reminder | |
---|
| 1309 | // +-----------------------------------------------------------------------+ |
---|
| 1310 | if (isset($_POST['Reminder_Email']) and count($collection) > 0) |
---|
| 1311 | { |
---|
| 1312 | if (in_array($conf['guest_id'], $collection)) |
---|
| 1313 | { |
---|
[9178] | 1314 | array_push($page['errors'], l10n('UAM_No_reminder_for_Guest')); |
---|
[5056] | 1315 | } |
---|
| 1316 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 1317 | in_array($conf['default_user_id'], $collection)) |
---|
| 1318 | { |
---|
[9178] | 1319 | array_push($page['errors'], l10n('UAM_No_reminder_for_default_user')); |
---|
[5056] | 1320 | } |
---|
| 1321 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 1322 | { |
---|
[9178] | 1323 | array_push($page['errors'], l10n('UAM_No_reminder_for_Webmaster')); |
---|
[5056] | 1324 | } |
---|
| 1325 | if (in_array($user['id'], $collection)) |
---|
| 1326 | { |
---|
[9178] | 1327 | array_push($page['errors'], l10n('UAM_No_reminder_for_your_account')); |
---|
[5056] | 1328 | } |
---|
| 1329 | |
---|
| 1330 | if (count($page['errors']) == 0) |
---|
| 1331 | { |
---|
| 1332 | foreach ($collection as $user_id) |
---|
| 1333 | { |
---|
| 1334 | $query = " |
---|
| 1335 | SELECT id, username, mail_address |
---|
| 1336 | FROM ".USERS_TABLE." |
---|
| 1337 | WHERE id = '".$user_id."' |
---|
| 1338 | ;"; |
---|
| 1339 | |
---|
[5633] | 1340 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 1341 | |
---|
| 1342 | ghostreminder($user_id,stripslashes($data['username']),$data['mail_address']); |
---|
| 1343 | } |
---|
| 1344 | array_push( |
---|
| 1345 | $page['infos'], |
---|
| 1346 | l10n_dec( |
---|
[9178] | 1347 | 'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent', |
---|
[5056] | 1348 | count($collection) |
---|
| 1349 | ) |
---|
| 1350 | ); |
---|
| 1351 | |
---|
| 1352 | $page['filtered_users'] = get_ghost_user_list(); |
---|
| 1353 | } |
---|
| 1354 | } |
---|
| 1355 | |
---|
[9254] | 1356 | if (isset($_POST['GhostTracker_Init']) and is_admin()) //Reset is only allowed for admins ! |
---|
[5056] | 1357 | { |
---|
[9254] | 1358 | $query1 = ' |
---|
[5056] | 1359 | SELECT * |
---|
| 1360 | FROM '.USER_LASTVISIT_TABLE.';'; |
---|
| 1361 | |
---|
[9254] | 1362 | $count = pwg_db_num_rows(pwg_query($query1)); |
---|
[5056] | 1363 | |
---|
[9254] | 1364 | if ($count <> 0) |
---|
| 1365 | { |
---|
| 1366 | $query = ' |
---|
[5056] | 1367 | SELECT DISTINCT u.id, |
---|
| 1368 | ui.status AS status |
---|
| 1369 | FROM '.USERS_TABLE.' AS u |
---|
| 1370 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 1371 | ON u.id = ui.user_id |
---|
| 1372 | WHERE u.id NOT IN (SELECT user_id FROM '.USER_LASTVISIT_TABLE.') |
---|
| 1373 | AND status != "webmaster" |
---|
| 1374 | AND status != "guest" |
---|
| 1375 | AND status != "admin" |
---|
| 1376 | ORDER BY u.id ASC |
---|
| 1377 | ;'; |
---|
| 1378 | |
---|
[9254] | 1379 | $result = pwg_query($query); |
---|
[5056] | 1380 | |
---|
[9254] | 1381 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 1382 | { |
---|
| 1383 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1384 | |
---|
[9254] | 1385 | $query = " |
---|
[5056] | 1386 | INSERT INTO ".USER_LASTVISIT_TABLE." (user_id, lastvisit, reminder) |
---|
| 1387 | VALUES ('".$row['id']."','".$dbnow."','false') |
---|
| 1388 | ;"; |
---|
[9254] | 1389 | pwg_query($query); |
---|
[5056] | 1390 | } |
---|
[9254] | 1391 | } |
---|
| 1392 | else if ($count == 0) |
---|
| 1393 | { |
---|
| 1394 | $query = ' |
---|
[5056] | 1395 | SELECT DISTINCT u.id, |
---|
| 1396 | ui.status AS status |
---|
| 1397 | FROM '.USERS_TABLE.' AS u |
---|
| 1398 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 1399 | ON u.id = ui.user_id |
---|
| 1400 | WHERE status != "webmaster" |
---|
| 1401 | AND status != "guest" |
---|
| 1402 | AND status != "admin" |
---|
| 1403 | ORDER BY u.id ASC |
---|
| 1404 | ;'; |
---|
| 1405 | |
---|
[9254] | 1406 | $result = pwg_query($query); |
---|
[5056] | 1407 | |
---|
[9254] | 1408 | while($row = pwg_db_fetch_assoc($result)) |
---|
| 1409 | { |
---|
| 1410 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1411 | |
---|
[9254] | 1412 | $query = " |
---|
[5056] | 1413 | INSERT INTO ".USER_LASTVISIT_TABLE." (user_id, lastvisit, reminder) |
---|
| 1414 | VALUES ('".$row['id']."','".$dbnow."','false') |
---|
| 1415 | ;"; |
---|
[9254] | 1416 | pwg_query($query); |
---|
[5056] | 1417 | } |
---|
[9254] | 1418 | } |
---|
[5056] | 1419 | |
---|
[9254] | 1420 | array_push($page['infos'], l10n('UAM_GhostTracker_Init_OK')); |
---|
[5056] | 1421 | } |
---|
| 1422 | |
---|
| 1423 | // +-----------------------------------------------------------------------+ |
---|
| 1424 | // | user list | |
---|
| 1425 | // +-----------------------------------------------------------------------+ |
---|
| 1426 | |
---|
| 1427 | $visible_user_list = array(); |
---|
| 1428 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
| 1429 | { |
---|
| 1430 | $visible_user_list[] = $local_user; |
---|
| 1431 | } |
---|
[9154] | 1432 | |
---|
[5056] | 1433 | foreach ($visible_user_list as $local_user) |
---|
| 1434 | { |
---|
| 1435 | $reminder = ''; |
---|
| 1436 | |
---|
| 1437 | if (isset($local_user['reminder']) and $local_user['reminder'] == 'true') |
---|
| 1438 | { |
---|
[9178] | 1439 | $reminder = l10n('UAM_Reminder_Sent_OK'); |
---|
[5056] | 1440 | } |
---|
| 1441 | else if (isset($local_user['reminder']) and $local_user['reminder'] == 'false') |
---|
| 1442 | { |
---|
[9178] | 1443 | $reminder = l10n('UAM_Reminder_Sent_NOK'); |
---|
[5056] | 1444 | } |
---|
| 1445 | |
---|
| 1446 | if (isset($_POST['pref_submit']) and isset($_POST['selection']) and in_array($local_user['id'], $_POST['selection'])) |
---|
| 1447 | { |
---|
| 1448 | $checked = 'checked="checked"'; |
---|
| 1449 | } |
---|
| 1450 | else |
---|
| 1451 | { |
---|
| 1452 | $checked = ''; |
---|
| 1453 | } |
---|
| 1454 | |
---|
| 1455 | $template->append( |
---|
| 1456 | 'users', |
---|
| 1457 | array( |
---|
| 1458 | 'ID' => $local_user['id'], |
---|
| 1459 | 'CHECKED' => $checked, |
---|
| 1460 | 'USERNAME' => stripslashes($local_user['username']), |
---|
| 1461 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
| 1462 | 'LASTVISIT' => $local_user['lastvisit'], |
---|
| 1463 | 'REMINDER' => $reminder, |
---|
| 1464 | ) |
---|
| 1465 | ); |
---|
| 1466 | } |
---|
| 1467 | |
---|
[9154] | 1468 | //Plugin version inserted |
---|
| 1469 | $template->assign( |
---|
| 1470 | array( |
---|
| 1471 | 'UAM_VERSION' => $version, |
---|
| 1472 | 'UAM_PATH' => UAM_PATH, |
---|
| 1473 | ) |
---|
| 1474 | ); |
---|
| 1475 | |
---|
[5056] | 1476 | // +-----------------------------------------------------------------------+ |
---|
| 1477 | // | errors display | |
---|
| 1478 | // +-----------------------------------------------------------------------+ |
---|
| 1479 | if ( isset ($errors) and count($errors) != 0) |
---|
| 1480 | { |
---|
| 1481 | $template->assign('errors',array()); |
---|
| 1482 | foreach ($errors as $error) |
---|
| 1483 | { |
---|
| 1484 | array_push($page['errors'], $error); |
---|
| 1485 | } |
---|
| 1486 | } |
---|
| 1487 | |
---|
| 1488 | // +-----------------------------------------------------------------------+ |
---|
| 1489 | // | templates display | |
---|
| 1490 | // +-----------------------------------------------------------------------+ |
---|
[5593] | 1491 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/ghosttracker.tpl'); |
---|
[5056] | 1492 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 1493 | } |
---|
| 1494 | else |
---|
| 1495 | { |
---|
[9178] | 1496 | array_push($page['errors'], l10n('UAM_Err_GhostTracker_Settings')); |
---|
[5056] | 1497 | } |
---|
| 1498 | |
---|
| 1499 | break; |
---|
| 1500 | } |
---|
| 1501 | ?> |
---|