[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); |
---|
[12205] | 20 | load_language('help.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; |
---|
[11318] | 35 | $UAM_Illegal_Flag_Error1 = false; |
---|
| 36 | $UAM_Illegal_Flag_Error2 = false; |
---|
| 37 | $UAM_Illegal_Flag_Error3 = false; |
---|
[12689] | 38 | $UAM_Email_Mandatory_Check = false; |
---|
[5056] | 39 | |
---|
[10342] | 40 | $dump_download = ''; |
---|
[7955] | 41 | |
---|
[5056] | 42 | // +-----------------------------------------------------------------------+ |
---|
| 43 | // | Tabssheet | |
---|
| 44 | // +-----------------------------------------------------------------------+ |
---|
| 45 | if (!isset($_GET['tab'])) |
---|
| 46 | $page['tab'] = 'global'; |
---|
| 47 | else |
---|
[17918] | 48 | $page['tab'] = $_GET['tab']; |
---|
[5056] | 49 | |
---|
| 50 | $tabsheet = new tabsheet(); |
---|
| 51 | $tabsheet->add('global', |
---|
[9177] | 52 | l10n('UAM_Tab_Global'), |
---|
[5056] | 53 | $my_base_url.'&tab=global'); |
---|
[17918] | 54 | $tabsheet->add('userlist', |
---|
| 55 | l10n('UAM_Tracking registered users'), |
---|
| 56 | $my_base_url.'&tab=userlist'); |
---|
[5056] | 57 | $tabsheet->add('usermanager', |
---|
[13107] | 58 | l10n('UAM_Tracking confirmations'), |
---|
[5056] | 59 | $my_base_url.'&tab=usermanager'); |
---|
| 60 | $tabsheet->add('ghosttracker', |
---|
[9177] | 61 | l10n('UAM_Tab_GhostTracker'), |
---|
[5056] | 62 | $my_base_url.'&tab=ghosttracker'); |
---|
| 63 | $tabsheet->select($page['tab']); |
---|
| 64 | $tabsheet->assign(); |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | // +-----------------------------------------------------------------------+ |
---|
| 68 | // | Getting plugin version | |
---|
| 69 | // +-----------------------------------------------------------------------+ |
---|
[5181] | 70 | $plugin = PluginInfos(UAM_PATH); |
---|
[5762] | 71 | $version = $plugin['version']; |
---|
[5056] | 72 | |
---|
| 73 | |
---|
| 74 | // +----------------------------------------------------------+ |
---|
| 75 | // | FCK Editor for email text fields | |
---|
| 76 | // +----------------------------------------------------------+ |
---|
[5181] | 77 | $toolbar = 'Basic'; |
---|
[5073] | 78 | $width = '750px'; |
---|
| 79 | $height = '300px'; |
---|
| 80 | $areas = array(); |
---|
[12661] | 81 | array_push( $areas,'UAM_ConfirmMail_Custom_Txt1','UAM_ConfirmMail_Custom_Txt2','UAM_GTAutoDelText','UAM_USRAutoDelText','UAM_CustomRejectConnexion_Text'); |
---|
[5084] | 82 | |
---|
[5073] | 83 | if (function_exists('set_fckeditor_instance')) |
---|
[5084] | 84 | { |
---|
[20591] | 85 | $fcke_config = unserialize($conf['FCKEditor']); |
---|
[5084] | 86 | foreach($areas as $area) |
---|
| 87 | { |
---|
[20591] | 88 | if (!isset($fcke_config[$area])) |
---|
[5084] | 89 | { |
---|
| 90 | $fcke_config[$area] = false; |
---|
| 91 | } |
---|
| 92 | } |
---|
[20591] | 93 | $conf['FCKEditor'] = serialize($fcke_config); |
---|
[5084] | 94 | |
---|
[20591] | 95 | set_fckeditor_instance($areas, $toolbar, $width, $height); |
---|
[5181] | 96 | } |
---|
[5056] | 97 | |
---|
| 98 | |
---|
| 99 | // +-----------------------------------------------------------------------+ |
---|
| 100 | // | Tabssheet select | |
---|
| 101 | // +-----------------------------------------------------------------------+ |
---|
| 102 | |
---|
| 103 | switch ($page['tab']) |
---|
| 104 | { |
---|
| 105 | // ************************************************************************* |
---|
| 106 | // +-----------------------------------------------------------------------+ |
---|
| 107 | // | Global Config | |
---|
| 108 | // +-----------------------------------------------------------------------+ |
---|
| 109 | // ************************************************************************* |
---|
[20591] | 110 | case 'global': |
---|
[5056] | 111 | |
---|
[20591] | 112 | 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_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']) and isset($_POST['UAM_HidePassw']) and isset($_POST['UAM_PwdReset']) and isset($_POST['UAM_RejectConnexion'])) |
---|
| 113 | { |
---|
[5056] | 114 | |
---|
[20591] | 115 | // Render email contents fields |
---|
| 116 | // ---------------------------- |
---|
| 117 | $_POST['UAM_MailInfo_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_MailInfo_Text']))); |
---|
[11318] | 118 | |
---|
[20591] | 119 | $_POST['UAM_ConfirmMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Text']))); |
---|
[5056] | 120 | |
---|
[20591] | 121 | $_POST['UAM_GhostTracker_ReminderText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GhostTracker_ReminderText']))); |
---|
[14729] | 122 | |
---|
[20591] | 123 | $_POST['UAM_GTAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText']))); |
---|
[5056] | 124 | |
---|
[20591] | 125 | $_POST['UAM_GTAutoMailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMailText']))); |
---|
[9135] | 126 | |
---|
[20591] | 127 | $_POST['UAM_AdminValidationMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Text']))); |
---|
[5056] | 128 | |
---|
[20591] | 129 | $_POST['UAM_CustomPasswRetr_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomPasswRetr_Text']))); |
---|
[9135] | 130 | |
---|
[20591] | 131 | $_POST['UAM_USRAutoDelText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoDelText']))); |
---|
[9266] | 132 | |
---|
[20591] | 133 | $_POST['UAM_CustomRejectConnexion_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomRejectConnexion_Text']))); |
---|
[12661] | 134 | |
---|
[20591] | 135 | // Render email subjects fields |
---|
| 136 | // --------------------------- |
---|
| 137 | $_POST['UAM_ConfirmMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Subject']))); |
---|
[14635] | 138 | |
---|
[20591] | 139 | $_POST['UAM_ConfirmMail_Remail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Remail_Subject']))); |
---|
[14729] | 140 | |
---|
[20591] | 141 | $_POST['UAM_InfoMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_InfoMail_Subject']))); |
---|
[14729] | 142 | |
---|
[20591] | 143 | $_POST['UAM_GTAutoMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMail_Subject']))); |
---|
[14729] | 144 | |
---|
[20591] | 145 | $_POST['UAM_GTReminder_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTReminder_Subject']))); |
---|
[14729] | 146 | |
---|
[20591] | 147 | $_POST['UAM_AdminValidationMail_Subject'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Subject']))); |
---|
[14729] | 148 | |
---|
| 149 | |
---|
[20591] | 150 | // Check if emails are mandatory for registrations (needed for email exclusion option) |
---|
| 151 | // ----------------------------------------------------------------------------------- |
---|
| 152 | if ($conf['obligatory_user_mail_address']) |
---|
| 153 | { |
---|
| 154 | // Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them |
---|
| 155 | // -------------------------------------------------------------------------------------- |
---|
| 156 | if (preg_match('/^[\s]+/', $_POST['UAM_MailExclusion_List'])) |
---|
| 157 | { |
---|
| 158 | array_push($page['errors'], l10n('UAM_mail_exclusionlist_error')); |
---|
| 159 | $UAM_Exclusionlist_Error = true; |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | elseif (!$conf['obligatory_user_mail_address']) |
---|
| 163 | { |
---|
| 164 | $_POST['UAM_MailExclusion_List'] = ''; |
---|
| 165 | } |
---|
[6754] | 166 | |
---|
[8065] | 167 | // Consistency check between ConfirmMail and AutoMail - We cannot use GTAutoMail if ConfirmMail is disabled |
---|
[12271] | 168 | // --------------------------------------------------------------------------------------------------------- |
---|
[8065] | 169 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[11318] | 170 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[8065] | 171 | |
---|
| 172 | 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') |
---|
| 173 | { |
---|
[20591] | 174 | $newvalue = 'false'; |
---|
[8065] | 175 | $_POST['UAM_GTAutoMail'] = $newvalue; |
---|
[9177] | 176 | array_push($page['errors'], l10n('UAM_Error_GTAutoMail_cannot_be_set_without_ConfirmMail')); |
---|
[8065] | 177 | } |
---|
| 178 | |
---|
[11318] | 179 | // Check if [Kdays] flag is used in a legal way (ConfirmMail Time out have to be set) |
---|
[12271] | 180 | // ---------------------------------------------------------------------------------- |
---|
[21075] | 181 | if (isset($conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT']) and $conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT'] == 'false' and preg_match('#\[Kdays\]#i',$_POST['UAM_ConfirmMail_Text']) != 0) |
---|
[11318] | 182 | { |
---|
| 183 | $UAM_Illegal_Flag_Error1 = true; |
---|
| 184 | array_push($page['errors'], l10n('UAM_Error_Using_illegal_Kdays')); |
---|
| 185 | } |
---|
| 186 | |
---|
[21611] | 187 | // Check if VALIDATED_GROUP is set as the gallery's default group and set it as default if not |
---|
| 188 | // Experimental : It's better the "validated users" group is the gallery's default group |
---|
| 189 | // ------------------------------------------------------------------------------------------- |
---|
| 190 | if (isset($_POST['UAM_Validated_Group']) and $_POST['UAM_Validated_Group'] <> '-1') |
---|
| 191 | { |
---|
| 192 | $query = ' |
---|
| 193 | SELECT name, is_default |
---|
| 194 | FROM '.GROUPS_TABLE.' |
---|
| 195 | WHERE id = '.$_POST['UAM_Validated_Group'].' |
---|
| 196 | ;'; |
---|
| 197 | |
---|
| 198 | $UAM_group = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 199 | |
---|
| 200 | if (isset($UAM_group['is_default']) and $UAM_group['is_default'] == "false") |
---|
| 201 | { |
---|
| 202 | $query = ' |
---|
| 203 | UPDATE '.GROUPS_TABLE.' |
---|
| 204 | SET is_default = true |
---|
| 205 | WHERE id = '.$_POST['UAM_Validated_Group'].' |
---|
| 206 | ;'; |
---|
| 207 | pwg_query($query); |
---|
| 208 | |
---|
| 209 | array_push( |
---|
| 210 | $page['infos'], |
---|
| 211 | sprintf(l10n('UAM_group "%s" updated'), $UAM_group['name']) |
---|
| 212 | ); |
---|
| 213 | } |
---|
| 214 | } |
---|
| 215 | |
---|
[12205] | 216 | // Save global UAM configuration |
---|
[12271] | 217 | // ----------------------------- |
---|
[21075] | 218 | $newconf_UAM['MAIL_INFO'] = (isset($_POST['UAM_Mail_Info']) ? $_POST['UAM_Mail_Info'] : 'false'); |
---|
| 219 | $newconf_UAM['CONFIRM_MAIL'] = (isset($_POST['UAM_Confirm_Mail']) ? $_POST['UAM_Confirm_Mail'] : 'false'); |
---|
| 220 | $newconf_UAM['NO_CONFIRM_GROUP'] = (isset($_POST['UAM_No_Confirm_Group']) ? $_POST['UAM_No_Confirm_Group'] : ''); |
---|
| 221 | $newconf_UAM['VALIDATED_GROUP'] = (isset($_POST['UAM_Validated_Group']) ? $_POST['UAM_Validated_Group'] : ''); |
---|
| 222 | $newconf_UAM['VALIDATED_STATUS'] = (isset($_POST['UAM_Validated_Status'])?$_POST['UAM_Validated_Status'] : ''); |
---|
| 223 | $newconf_UAM['USERNAME_CHAR'] = $_POST['UAM_Username_Char']; |
---|
| 224 | $newconf_UAM['USERNAME_CHAR_LIST'] = (isset($_POST['UAM_Username_List']) ? $_POST['UAM_Username_List'] : ''); |
---|
| 225 | $newconf_UAM['NO_CONFIRM_STATUS'] = (isset($_POST['UAM_No_Confirm_Status']) ? $_POST['UAM_No_Confirm_Status'] : ''); |
---|
| 226 | $newconf_UAM['MAILINFO_TEXT'] = (isset($_POST['UAM_MailInfo_Text']) ? $_POST['UAM_MailInfo_Text'] : l10n('UAM_Default_InfoMail_Txt')); |
---|
| 227 | $newconf_UAM['CONFIRMMAIL_TEXT'] = (isset($_POST['UAM_ConfirmMail_Text']) ? $_POST['UAM_ConfirmMail_Text'] : l10n('UAM_Default_ConfirmMail_Txt')); |
---|
| 228 | $newconf_UAM['MAILEXCLUSION'] = (isset($_POST['UAM_MailExclusion']) ? $_POST['UAM_MailExclusion'] : 'false'); |
---|
| 229 | $newconf_UAM['MAILEXCLUSION_LIST'] = (isset($_POST['UAM_MailExclusion_List']) ? $_POST['UAM_MailExclusion_List'] : ''); |
---|
| 230 | $newconf_UAM['PASSWORDENF'] = (isset($_POST['UAM_Password_Enforced']) ? $_POST['UAM_Password_Enforced'] : 'false'); |
---|
| 231 | $newconf_UAM['PASSWORD_SCORE'] = (isset($_POST['UAM_Password_Score']) ? $_POST['UAM_Password_Score'] : '100'); |
---|
| 232 | $newconf_UAM['ADMINPASSWENF'] = (isset($_POST['UAM_AdminPassword_Enforced']) ? $_POST['UAM_AdminPassword_Enforced'] : 'false'); |
---|
| 233 | $newconf_UAM['GHOSTRACKER'] = (isset($_POST['UAM_GhostUser_Tracker']) ? $_POST['UAM_GhostUser_Tracker'] : 'false'); |
---|
| 234 | $newconf_UAM['GHOSTRACKER_DAYLIMIT'] = (isset($_POST['UAM_GhostTracker_DayLimit']) ? $_POST['UAM_GhostTracker_DayLimit'] : '10'); |
---|
| 235 | $newconf_UAM['GHOSTRACKER_REMINDERTEXT'] = (isset($_POST['UAM_GhostTracker_ReminderText']) ? $_POST['UAM_GhostTracker_ReminderText'] : l10n('UAM_Default_GhstReminder_Txt')); |
---|
| 236 | $newconf_UAM['ADDLASTVISIT'] = (isset($_POST['UAM_Add_LastVisit_Column']) ? $_POST['UAM_Add_LastVisit_Column'] : 'false'); |
---|
| 237 | $newconf_UAM['ADMINCONFMAIL'] = (isset($_POST['UAM_Admin_ConfMail']) ? $_POST['UAM_Admin_ConfMail'] : 'false'); |
---|
| 238 | $newconf_UAM['REDIRTOPROFILE'] = (isset($_POST['UAM_RedirToProfile']) ? $_POST['UAM_RedirToProfile'] : 'false'); |
---|
| 239 | $newconf_UAM['GTAUTO'] = (isset($_POST['UAM_GTAuto']) ? $_POST['UAM_GTAuto'] : 'false'); |
---|
| 240 | $newconf_UAM['GTAUTOMAIL'] = (isset($_POST['UAM_GTAutoMail']) ? $_POST['UAM_GTAutoMail'] : 'false'); |
---|
| 241 | $newconf_UAM['GTAUTODEL'] = (isset($_POST['UAM_GTAutoDelText']) ? $_POST['UAM_GTAutoDelText'] : l10n('UAM_Default_GhstDeletion_Txt')); |
---|
| 242 | $newconf_UAM['GTAUTOMAILTEXT'] = (isset($_POST['UAM_GTAutoMailText']) ? $_POST['UAM_GTAutoMailText'] : l10n('UAM_Default_GhstDemotion_Txt')); |
---|
| 243 | $newconf_UAM['DOWNGRADE_GROUP'] = (isset($_POST['UAM_Downgrade_Group']) ? $_POST['UAM_Downgrade_Group'] : ''); |
---|
| 244 | $newconf_UAM['DOWNGRADE_STATUS'] = (isset($_POST['UAM_Downgrade_Status']) ? $_POST['UAM_Downgrade_Status'] : ''); |
---|
| 245 | $newconf_UAM['ADMINVALIDATIONMAIL'] = (isset($_POST['UAM_AdminValidationMail_Text']) ? $_POST['UAM_AdminValidationMail_Text'] : l10n('UAM_Default_AdminValidation_Txt')); |
---|
| 246 | $newconf_UAM['CUSTOMPASSWRETR'] = (isset($_POST['UAM_CustomPasswRetr']) ? $_POST['UAM_CustomPasswRetr'] : 'false'); |
---|
| 247 | $newconf_UAM['CUSTOMPASSWRETR_TEXT'] = (isset($_POST['UAM_CustomPasswRetr_Text']) ? $_POST['UAM_CustomPasswRetr_Text'] : l10n('UAM_Default_PwdRequest_Txt')); |
---|
| 248 | $newconf_UAM['USRAUTO'] = (isset($_POST['UAM_USRAuto']) ? $_POST['UAM_USRAuto'] : 'false'); |
---|
| 249 | $newconf_UAM['USRAUTODEL'] = (isset($_POST['UAM_USRAutoDelText']) ? $_POST['UAM_USRAutoDelText'] : l10n('UAM_Default_ValidationTimeout_Txt')); |
---|
| 250 | $newconf_UAM['USRAUTOMAIL'] = (isset($_POST['UAM_USRAutoMail']) ? $_POST['UAM_USRAutoMail'] : 'false'); |
---|
| 251 | $newconf_UAM['STUFFS'] = (isset($_POST['UAM_Stuffs']) ? $_POST['UAM_Stuffs'] : 'false'); |
---|
| 252 | $newconf_UAM['HIDEPASSW'] = (isset($_POST['UAM_HidePassw']) ? $_POST['UAM_HidePassw'] : 'false'); |
---|
| 253 | $newconf_UAM['NO_VALID_LEVEL'] = (isset($_POST['UAM_No_Valid_Level']) ? $_POST['UAM_No_Valid_Level'] : ''); |
---|
| 254 | $newconf_UAM['VALID_LEVEL'] = (isset($_POST['UAM_Valid_Level']) ? $_POST['UAM_Valid_Level'] : ''); |
---|
| 255 | $newconf_UAM['DOWNGRADE_LEVEL'] = (isset($_POST['UAM_Downgrade_Level']) ? $_POST['UAM_Downgrade_Level'] : ''); |
---|
| 256 | $newconf_UAM['PWDRESET'] = (isset($_POST['UAM_PwdReset']) ? $_POST['UAM_PwdReset'] : 'false'); |
---|
| 257 | $newconf_UAM['REJECTCONNECT'] = (isset($_POST['UAM_RejectConnexion']) ? $_POST['UAM_RejectConnexion'] : 'false'); |
---|
| 258 | $newconf_UAM['REJECTCONNECT_TEXT'] = (isset($_POST['UAM_CustomRejectConnexion_Text']) ? $_POST['UAM_CustomRejectConnexion_Text'] : l10n('UAM_Default_RejectConnexion_Txt')); |
---|
| 259 | $newconf_UAM['CONFIRMMAIL_SUBJECT'] = (isset($_POST['UAM_ConfirmMail_Subject']) ? $_POST['UAM_ConfirmMail_Subject'] : l10n('UAM_Default_ConfirmMail_Subject')); |
---|
| 260 | $newconf_UAM['CONFIRMMAIL_REMAIL_SUBJECT'] = (isset($_POST['UAM_ConfirmMail_Remail_Subject']) ? $_POST['UAM_ConfirmMail_Remail_Subject'] : l10n('UAM_Default_ConfirmMail_Remail_Subject')); |
---|
| 261 | $newconf_UAM['INFOMAIL_SUBJECT'] = (isset($_POST['UAM_InfoMail_Subject']) ? $_POST['UAM_InfoMail_Subject'] : l10n('UAM_Default_InfoMail_Subject')); |
---|
| 262 | $newconf_UAM['GTAUTOMAIL_SUBJECT'] = (isset($_POST['UAM_GTAutoMail_Subject']) ? $_POST['UAM_GTAutoMail_Subject'] : l10n('UAM_Default_GTAutoMail_Subject')); |
---|
| 263 | $newconf_UAM['GTREMINDER_SUBJECT'] = (isset($_POST['UAM_GTReminder_Subject']) ? $_POST['UAM_GTReminder_Subject'] : l10n('UAM_Default_GTReminder_Subject')); |
---|
| 264 | $newconf_UAM['ADMINVALIDATIONMAIL_SUBJECT'] = (isset($_POST['UAM_AdminValidationMail_Subject']) ? $_POST['UAM_AdminValidationMail_Subject'] : l10n('UAM_Default_AdminValidationMail_Subject')); |
---|
[5056] | 265 | |
---|
[5181] | 266 | $conf['UserAdvManager'] = serialize($newconf_UAM); |
---|
[5056] | 267 | |
---|
[21075] | 268 | conf_update_param('UserAdvManager', pwg_db_real_escape_string($conf['UserAdvManager'])); |
---|
[5056] | 269 | |
---|
[12271] | 270 | // Email confirmation settings |
---|
| 271 | // -------------------------- |
---|
[6753] | 272 | $_POST['UAM_ConfirmMail_ReMail_Txt1'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_ReMail_Txt1']))); |
---|
[5056] | 273 | |
---|
[6753] | 274 | $_POST['UAM_ConfirmMail_ReMail_Txt2'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_ReMail_Txt2']))); |
---|
[17918] | 275 | |
---|
[6753] | 276 | $_POST['UAM_ConfirmMail_Custom_Txt1'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Custom_Txt1']))); |
---|
[17918] | 277 | |
---|
[6753] | 278 | $_POST['UAM_ConfirmMail_Custom_Txt2'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_Custom_Txt2']))); |
---|
[11318] | 279 | |
---|
| 280 | // Check if [Kdays] flag is used in a legal way (ConfirmMail Time out have to be set) |
---|
[12271] | 281 | // ---------------------------------------------------------------------------------- |
---|
[21075] | 282 | if (isset($conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT']) and $conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT'] == 'false' and preg_match('#\[Kdays\]#i',$_POST['UAM_ConfirmMail_ReMail_Txt1']) == 1) |
---|
[11318] | 283 | { |
---|
| 284 | $UAM_Illegal_Flag_Error2 = true; |
---|
| 285 | array_push($page['errors'], l10n('UAM_Error_Using_illegal_flag')); |
---|
| 286 | } |
---|
[21075] | 287 | elseif (isset($conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT']) and $conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT'] == 'false' and preg_match('#\[Kdays\]#i',$_POST['UAM_ConfirmMail_ReMail_Txt2']) == 1) |
---|
[11318] | 288 | { |
---|
| 289 | $UAM_Illegal_Flag_Error3 = true; |
---|
| 290 | array_push($page['errors'], l10n('UAM_Error_Using_illegal_flag')); |
---|
| 291 | } |
---|
[12205] | 292 | |
---|
| 293 | // Save ConfirmMail settings |
---|
[12271] | 294 | // ------------------------- |
---|
[21075] | 295 | $newconf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT'] = (isset($_POST['UAM_ConfirmMail_TimeOut']) ? $_POST['UAM_ConfirmMail_TimeOut'] : 'false'); |
---|
| 296 | $newconf_UAM_ConfirmMail['CONFIRMMAIL_DELAY'] = (isset($_POST['UAM_ConfirmMail_Delay']) ? $_POST['UAM_ConfirmMail_Delay'] : '5'); |
---|
| 297 | $newconf_UAM_ConfirmMail['CONFIRMMAIL_REMAIL_TXT1'] = (isset($_POST['UAM_ConfirmMail_ReMail_Txt1']) ? $_POST['UAM_ConfirmMail_ReMail_Txt1'] : l10n('UAM_Default_CfmMail_Remail_Txt1')); |
---|
| 298 | $newconf_UAM_ConfirmMail['CONFIRMMAIL_REMAIL'] = (isset($_POST['UAM_ConfirmMail_Remail']) ? $_POST['UAM_ConfirmMail_Remail'] : 'false'); |
---|
| 299 | $newconf_UAM_ConfirmMail['CONFIRMMAIL_REMAIL_TXT2'] = (isset($_POST['UAM_ConfirmMail_ReMail_Txt2']) ? $_POST['UAM_ConfirmMail_ReMail_Txt2'] : l10n('UAM_Default_CfmMail_Remail_Txt2')); |
---|
| 300 | $newconf_UAM_ConfirmMail['CONFIRMMAIL_CUSTOM_TXT1'] = (isset($_POST['UAM_ConfirmMail_Custom_Txt1']) ? $_POST['UAM_ConfirmMail_Custom_Txt1'] : l10n('UAM_Default_CfmMail_Custom_Txt1')); |
---|
| 301 | $newconf_UAM_ConfirmMail['CONFIRMMAIL_CUSTOM_TXT2'] = (isset($_POST['UAM_ConfirmMail_Custom_Txt2']) ? $_POST['UAM_ConfirmMail_Custom_Txt2'] : l10n('UAM_Default_CfmMail_Custom_Txt2')); |
---|
[5056] | 302 | |
---|
[5181] | 303 | $conf['UserAdvManager_ConfirmMail'] = serialize($newconf_UAM_ConfirmMail); |
---|
[5056] | 304 | |
---|
[10976] | 305 | conf_update_param('UserAdvManager_ConfirmMail', pwg_db_real_escape_string($conf['UserAdvManager_ConfirmMail'])); |
---|
[5056] | 306 | |
---|
[20591] | 307 | array_push($page['infos'], l10n('UAM_save_config')); |
---|
[5056] | 308 | } |
---|
| 309 | |
---|
[10342] | 310 | // Saving UAM tables and configuration settings |
---|
[12271] | 311 | // -------------------------------------------- |
---|
[10342] | 312 | if (isset($_POST['save'])) |
---|
| 313 | { |
---|
| 314 | $dump_download = (isset($_POST['dump_download'])) ? 'true' : 'false'; |
---|
| 315 | |
---|
[12239] | 316 | if(UAM_dump($dump_download) and $dump_download == 'false') |
---|
[10342] | 317 | { |
---|
| 318 | array_push($page['infos'], l10n('UAM_Dump_OK')); |
---|
| 319 | } |
---|
| 320 | else |
---|
| 321 | { |
---|
| 322 | array_push($page['errors'], l10n('UAM_Dump_NOK')); |
---|
| 323 | } |
---|
| 324 | } |
---|
[5056] | 325 | |
---|
[12275] | 326 | // Restoring UAM tables and configuration settings |
---|
| 327 | // ----------------------------------------------- |
---|
| 328 | if (isset($_POST['restore'])) |
---|
| 329 | { |
---|
| 330 | $Backup_File = UAM_PATH.'/include/backup/UAM_dbbackup.sql'; |
---|
| 331 | |
---|
[12314] | 332 | if (file_exists($Backup_File) and $file = file($Backup_File, FILE_IGNORE_NEW_LINES) and !empty($file)) |
---|
[12275] | 333 | { |
---|
[12314] | 334 | // Check backup file version |
---|
| 335 | // ------------------------- |
---|
| 336 | if ($file[0] == "-- ".$version." --") |
---|
[12275] | 337 | { |
---|
[12314] | 338 | $restore = UAM_Restore_backup_file(); |
---|
| 339 | if(empty($restore)) |
---|
| 340 | { |
---|
| 341 | array_push($page['infos'], l10n('UAM_Restoration_OK')); |
---|
| 342 | } |
---|
| 343 | else |
---|
| 344 | { |
---|
| 345 | array_push($page['errors'], l10n('UAM_Restoration_NOK')); |
---|
| 346 | } |
---|
[12275] | 347 | } |
---|
[12314] | 348 | else array_push($page['errors'], l10n('UAM_Bad_version_backup')); |
---|
[12275] | 349 | } |
---|
| 350 | else |
---|
| 351 | { |
---|
| 352 | array_push($page['errors'], l10n('UAM_No_Backup_File')); |
---|
| 353 | } |
---|
| 354 | } |
---|
| 355 | |
---|
[12271] | 356 | // Testing password enforcement |
---|
| 357 | // ---------------------------- |
---|
[8841] | 358 | if (isset($_POST['PasswordTest']) and isset($_POST['UAM_Password_Test']) and !empty($_POST['UAM_Password_Test'])) |
---|
[5056] | 359 | { |
---|
| 360 | $UAM_Password_Test_Score = testpassword($_POST['UAM_Password_Test']); |
---|
| 361 | } |
---|
[8841] | 362 | else if (isset($_POST['PasswordTest']) and empty($_POST['UAM_Password_Test'])) |
---|
[5056] | 363 | { |
---|
[9177] | 364 | array_push($page['errors'], l10n('UAM_reg_err_login3')); |
---|
[5056] | 365 | } |
---|
| 366 | |
---|
[5181] | 367 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 368 | |
---|
[12271] | 369 | // Group setting for unvalidated, validated users and downgrade group |
---|
| 370 | // ------------------------------------------------------------------ |
---|
[5056] | 371 | $groups[-1] = '---------'; |
---|
| 372 | $No_Valid = -1; |
---|
| 373 | $Valid = -1; |
---|
[8065] | 374 | $Downgrade = -1; |
---|
[5056] | 375 | |
---|
[12271] | 376 | // Get groups list in database |
---|
| 377 | // --------------------------- |
---|
[5056] | 378 | $query = ' |
---|
| 379 | SELECT id, name |
---|
[20591] | 380 | FROM '.GROUPS_TABLE.' |
---|
[5056] | 381 | ORDER BY name ASC |
---|
| 382 | ;'; |
---|
| 383 | |
---|
| 384 | $result = pwg_query($query); |
---|
| 385 | |
---|
[5633] | 386 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 387 | { |
---|
| 388 | $groups[$row['id']] = $row['name']; |
---|
[7955] | 389 | //configuration value for unvalidated users |
---|
[21075] | 390 | if (isset($conf_UAM['NO_CONFIRM_GROUP']) and $conf_UAM['NO_CONFIRM_GROUP'] == $row['id']) |
---|
[5056] | 391 | { |
---|
[20591] | 392 | $No_Valid = $row['id']; |
---|
| 393 | } |
---|
[7955] | 394 | //configuration value for validated users |
---|
[21075] | 395 | if (isset($conf_UAM['VALIDATED_GROUP']) and $conf_UAM['VALIDATED_GROUP'] == $row['id']) |
---|
[20591] | 396 | { |
---|
| 397 | $Valid = $row['id']; |
---|
| 398 | } |
---|
[8065] | 399 | //configuration value for downgrade users |
---|
[21075] | 400 | if (isset($conf_UAM['DOWNGRADE_GROUP']) and $conf_UAM['DOWNGRADE_GROUP'] == $row['id']) |
---|
[20591] | 401 | { |
---|
| 402 | $Downgrade = $row['id']; |
---|
| 403 | } |
---|
[5056] | 404 | } |
---|
| 405 | |
---|
[12271] | 406 | // Template initialization for unvalidated users group |
---|
| 407 | // --------------------------------------------------- |
---|
[5056] | 408 | $template->assign( |
---|
[20591] | 409 | 'No_Confirm_Group', |
---|
| 410 | array( |
---|
| 411 | 'group_options'=> $groups, |
---|
| 412 | 'group_selected' => $No_Valid |
---|
| 413 | ) |
---|
| 414 | ); |
---|
[12271] | 415 | |
---|
| 416 | // Template initialization for validated users group |
---|
| 417 | // ------------------------------------------------- |
---|
[5056] | 418 | $template->assign( |
---|
[20591] | 419 | 'Validated_Group', |
---|
| 420 | array( |
---|
| 421 | 'group_options'=> $groups, |
---|
| 422 | 'group_selected' => $Valid |
---|
| 423 | ) |
---|
| 424 | ); |
---|
[12271] | 425 | |
---|
| 426 | // Template initialization for downgrade group |
---|
| 427 | // ------------------------------------------- |
---|
[8065] | 428 | $template->assign( |
---|
| 429 | 'Downgrade_Group', |
---|
[20591] | 430 | array( |
---|
| 431 | 'group_options'=> $groups, |
---|
| 432 | 'group_selected' => $Downgrade |
---|
| 433 | ) |
---|
[8065] | 434 | ); |
---|
[5056] | 435 | |
---|
[12271] | 436 | // Status setting for unvalidated, validated users and downgrade status |
---|
| 437 | // -------------------------------------------------------------------- |
---|
[5056] | 438 | $status_options[-1] = '------------'; |
---|
| 439 | $No_Valid_Status = -1; |
---|
| 440 | $Valid_Status = -1; |
---|
[8065] | 441 | $Downgrade_Status = -1; |
---|
[5056] | 442 | |
---|
[12271] | 443 | // Get unvalidate status values |
---|
| 444 | // ---------------------------- |
---|
[5056] | 445 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
| 446 | { |
---|
| 447 | $status_options[$status] = l10n('user_status_'.$status); |
---|
[21075] | 448 | if (isset($conf_UAM['NO_CONFIRM_STATUS']) and $conf_UAM['NO_CONFIRM_STATUS'] == $status) |
---|
[5056] | 449 | { |
---|
| 450 | $No_Valid_Status = $status; |
---|
| 451 | } |
---|
| 452 | |
---|
[12271] | 453 | // Template initialization for unvalidated users status |
---|
| 454 | // ---------------------------------------------------- |
---|
| 455 | $template->assign( |
---|
[20591] | 456 | 'No_Confirm_Status', |
---|
| 457 | array( |
---|
| 458 | 'Status_options' => $status_options, |
---|
| 459 | 'Status_selected' => $No_Valid_Status |
---|
| 460 | ) |
---|
| 461 | ); |
---|
[5056] | 462 | } |
---|
| 463 | |
---|
[12271] | 464 | // Get validate status values |
---|
| 465 | // -------------------------- |
---|
[5056] | 466 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
[20591] | 467 | { |
---|
| 468 | $status_options[$status] = l10n('user_status_'.$status); |
---|
[21075] | 469 | if (isset($conf_UAM['VALIDATED_STATUS']) and $conf_UAM['VALIDATED_STATUS'] == $status) |
---|
[20591] | 470 | { |
---|
| 471 | $Valid_Status = $status; |
---|
| 472 | } |
---|
[5056] | 473 | |
---|
[12271] | 474 | // Template initialization for validated users status |
---|
| 475 | // -------------------------------------------------- |
---|
| 476 | $template->assign( |
---|
[20591] | 477 | 'Confirm_Status', |
---|
| 478 | array( |
---|
| 479 | 'Status_options' => $status_options, |
---|
| 480 | 'Status_selected' => $Valid_Status |
---|
| 481 | ) |
---|
| 482 | ); |
---|
| 483 | } |
---|
[5056] | 484 | |
---|
[12271] | 485 | // Get downgrade status values |
---|
| 486 | // --------------------------- |
---|
[8065] | 487 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
| 488 | { |
---|
[20591] | 489 | $status_options[$status] = l10n('user_status_'.$status); |
---|
[21075] | 490 | if (isset($conf_UAM['DOWNGRADE_STATUS']) and $conf_UAM['DOWNGRADE_STATUS'] == $status) |
---|
[20591] | 491 | { |
---|
| 492 | $Downgrade_Status = $status; |
---|
| 493 | } |
---|
[8065] | 494 | |
---|
[12271] | 495 | // Template initialization for validated users status |
---|
| 496 | // -------------------------------------------------- |
---|
| 497 | $template->assign( |
---|
[20591] | 498 | 'Downgrade_Status', |
---|
| 499 | array( |
---|
| 500 | 'Status_options' => $status_options, |
---|
| 501 | 'Status_selected' => $Downgrade_Status |
---|
| 502 | ) |
---|
| 503 | ); |
---|
| 504 | } |
---|
[8065] | 505 | |
---|
[12189] | 506 | |
---|
[12271] | 507 | // Level setting for unvalidated, validated users and downgrade level |
---|
| 508 | // ------------------------------------------------------------------ |
---|
[12189] | 509 | $level_options[-1] = '------------'; |
---|
| 510 | $No_Valid_Level = -1; |
---|
| 511 | $Valid_Level = -1; |
---|
| 512 | $Downgrade_Level = -1; |
---|
| 513 | |
---|
| 514 | // Get unvalidated privacy levels values |
---|
[12271] | 515 | // ------------------------------------- |
---|
[12189] | 516 | foreach ($conf['available_permission_levels'] as $level) |
---|
| 517 | { |
---|
[20591] | 518 | $level_options[$level] = l10n(sprintf('Level %d', $level)); |
---|
[21075] | 519 | if (isset($conf_UAM['NO_VALID_LEVEL']) and $conf_UAM['NO_VALID_LEVEL'] == $level) |
---|
[20591] | 520 | { |
---|
| 521 | $No_Valid_Level = $level; |
---|
| 522 | } |
---|
[12271] | 523 | |
---|
| 524 | // Template initialization for unvalidated users level |
---|
| 525 | // --------------------------------------------------- |
---|
| 526 | $template->assign( |
---|
[20591] | 527 | 'No_Valid_Level', |
---|
| 528 | array( |
---|
| 529 | 'Level_options' => $level_options, |
---|
| 530 | 'Level_selected' => $No_Valid_Level |
---|
| 531 | ) |
---|
| 532 | ); |
---|
[12189] | 533 | } |
---|
| 534 | |
---|
| 535 | // Get validated privacy levels values |
---|
[12271] | 536 | // ----------------------------------- |
---|
[12189] | 537 | foreach ($conf['available_permission_levels'] as $level) |
---|
| 538 | { |
---|
[20591] | 539 | $level_options[$level] = l10n(sprintf('Level %d', $level)); |
---|
[21075] | 540 | if (isset($conf_UAM['VALID_LEVEL']) and $conf_UAM['VALID_LEVEL'] == $level) |
---|
[20591] | 541 | { |
---|
| 542 | $Valid_Level = $level; |
---|
| 543 | } |
---|
[12271] | 544 | |
---|
| 545 | // Template initialization for unvalidated users level |
---|
| 546 | // --------------------------------------------------- |
---|
| 547 | $template->assign( |
---|
[20591] | 548 | 'Valid_Level', |
---|
| 549 | array( |
---|
| 550 | 'Level_options' => $level_options, |
---|
| 551 | 'Level_selected' => $Valid_Level |
---|
| 552 | ) |
---|
| 553 | ); |
---|
[12189] | 554 | } |
---|
| 555 | |
---|
| 556 | // Get downgrade privacy levels values |
---|
[12271] | 557 | // ----------------------------------- |
---|
[12189] | 558 | foreach ($conf['available_permission_levels'] as $level) |
---|
| 559 | { |
---|
[20591] | 560 | $level_options[$level] = l10n(sprintf('Level %d', $level)); |
---|
[21075] | 561 | if (isset($conf_UAM['DOWNGRADE_LEVEL']) and $conf_UAM['DOWNGRADE_LEVEL'] == $level) |
---|
[20591] | 562 | { |
---|
| 563 | $Downgrade_Level = $level; |
---|
| 564 | } |
---|
[12271] | 565 | |
---|
| 566 | // Template initialization for unvalidated users level |
---|
| 567 | // --------------------------------------------------- |
---|
| 568 | $template->assign( |
---|
[20591] | 569 | 'Downgrade_Level', |
---|
| 570 | array( |
---|
| 571 | 'Level_options' => $level_options, |
---|
| 572 | 'Level_selected' => $Downgrade_Level |
---|
| 573 | ) |
---|
| 574 | ); |
---|
[12189] | 575 | } |
---|
| 576 | |
---|
[12689] | 577 | // Check if emails are mandatory for registrations (needed for email exclusion option) |
---|
| 578 | // ----------------------------------------------------------------------------------- |
---|
| 579 | if (!$conf['obligatory_user_mail_address']) |
---|
| 580 | { |
---|
| 581 | $UAM_Email_Mandatory_Check = true; |
---|
| 582 | } |
---|
| 583 | |
---|
[12271] | 584 | // Save last opened paragraph in configuration tab |
---|
| 585 | // ----------------------------------------------- |
---|
[5056] | 586 | $nb_para=(isset($_POST["nb_para"])) ? $_POST["nb_para"]:""; |
---|
| 587 | $nb_para2=(isset($_POST["nb_para2"])) ? $_POST["nb_para2"]:""; |
---|
| 588 | |
---|
[5181] | 589 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[7955] | 590 | |
---|
[12271] | 591 | // ------------------------------------------ |
---|
[7955] | 592 | // Template initialization for forms and data |
---|
[12271] | 593 | // ------------------------------------------ |
---|
[10359] | 594 | $themeconf=$template->get_template_vars('themeconf'); |
---|
| 595 | $UAM_theme=$themeconf['id']; |
---|
| 596 | |
---|
[5056] | 597 | $template->assign( |
---|
[20591] | 598 | array( |
---|
[17918] | 599 | 'nb_para' => $nb_para, |
---|
[20591] | 600 | 'nb_para2' => $nb_para2, |
---|
| 601 | 'UAM_VERSION' => $version, |
---|
| 602 | 'UAM_PATH' => UAM_PATH, |
---|
| 603 | 'UAM_DUMP_DOWNLOAD' => $dump_download, |
---|
| 604 | 'UAM_THEME' => $UAM_theme, |
---|
[21075] | 605 | 'UAM_MAIL_INFO_TRUE' => $conf_UAM['MAIL_INFO']=='true' ? 'checked="checked"' : '' , |
---|
| 606 | 'UAM_MAIL_INFO_FALSE' => $conf_UAM['MAIL_INFO']=='false' ? 'checked="checked"' : '' , |
---|
| 607 | 'UAM_MAILINFO_TEXT' => $conf_UAM['MAILINFO_TEXT'], |
---|
| 608 | 'UAM_USERNAME_CHAR_TRUE' => $conf_UAM['USERNAME_CHAR']=='true' ? 'checked="checked"' : '' , |
---|
| 609 | 'UAM_USERNAME_CHAR_FALSE' => $conf_UAM['USERNAME_CHAR']=='false' ? 'checked="checked"' : '' , |
---|
| 610 | 'UAM_USERNAME_CHAR_LIST' => $conf_UAM['USERNAME_CHAR_LIST'], |
---|
| 611 | 'UAM_CONFIRM_MAIL_TRUE' => $conf_UAM['CONFIRM_MAIL']=='true' ? 'checked="checked"' : '' , |
---|
| 612 | 'UAM_CONFIRM_MAIL_FALSE' => $conf_UAM['CONFIRM_MAIL']=='false' ? 'checked="checked"' : '' , |
---|
| 613 | 'UAM_CONFIRM_MAIL_LOCAL' => $conf_UAM['CONFIRM_MAIL']=='local' ? 'checked="checked"' : '' , |
---|
| 614 | 'UAM_CONFIRMMAIL_TEXT' => $conf_UAM['CONFIRMMAIL_TEXT'], |
---|
| 615 | 'UAM_No_Confirm_Group' => $conf_UAM['NO_CONFIRM_GROUP'], |
---|
| 616 | 'UAM_Validated_Group' => $conf_UAM['VALIDATED_GROUP'], |
---|
| 617 | 'UAM_No_Confirm_Status' => $conf_UAM['NO_CONFIRM_STATUS'], |
---|
| 618 | 'UAM_Validated_Status' => $conf_UAM['VALIDATED_STATUS'], |
---|
| 619 | 'UAM_MAILEXCLUSION_TRUE' => $conf_UAM['MAILEXCLUSION']=='true' ? 'checked="checked"' : '' , |
---|
| 620 | 'UAM_MAILEXCLUSION_FALSE' => $conf_UAM['MAILEXCLUSION']=='false' ? 'checked="checked"' : '' , |
---|
| 621 | 'UAM_MAILEXCLUSION_LIST' => $conf_UAM['MAILEXCLUSION_LIST'], |
---|
| 622 | 'UAM_PASSWORDENF_TRUE' => $conf_UAM['PASSWORDENF']=='true' ? 'checked="checked"' : '' , |
---|
| 623 | 'UAM_PASSWORDENF_FALSE' => $conf_UAM['PASSWORDENF']=='false' ? 'checked="checked"' : '' , |
---|
| 624 | 'UAM_PASSWORD_SCORE' => $conf_UAM['PASSWORD_SCORE'], |
---|
| 625 | 'UAM_ADMINPASSWENF_TRUE' => $conf_UAM['ADMINPASSWENF']=='true' ? 'checked="checked"' : '' , |
---|
| 626 | 'UAM_ADMINPASSWENF_FALSE' => $conf_UAM['ADMINPASSWENF']=='false' ? 'checked="checked"' : '' , |
---|
| 627 | 'UAM_GHOSTRACKER_TRUE' => $conf_UAM['GHOSTRACKER']=='true' ? 'checked="checked"' : '' , |
---|
| 628 | 'UAM_GHOSTRACKER_FALSE' => $conf_UAM['GHOSTRACKER']=='false' ? 'checked="checked"' : '' , |
---|
| 629 | 'UAM_GHOSTRACKER_DAYLIMIT' => $conf_UAM['GHOSTRACKER_DAYLIMIT'], |
---|
| 630 | 'UAM_GHOSTRACKER_REMINDERTEXT' => $conf_UAM['GHOSTRACKER_REMINDERTEXT'], |
---|
| 631 | 'UAM_ADDLASTVISIT_TRUE' => $conf_UAM['ADDLASTVISIT']=='true' ? 'checked="checked"' : '' , |
---|
| 632 | 'UAM_ADDLASTVISIT_FALSE' => $conf_UAM['ADDLASTVISIT']=='false' ? 'checked="checked"' : '' , |
---|
| 633 | 'UAM_ADMINCONFMAIL_TRUE' => $conf_UAM['ADMINCONFMAIL']=='true' ? 'checked="checked"' : '' , |
---|
| 634 | 'UAM_ADMINCONFMAIL_FALSE' => $conf_UAM['ADMINCONFMAIL']=='false' ? 'checked="checked"' : '' , |
---|
| 635 | 'UAM_REDIRTOPROFILE_TRUE' => $conf_UAM['REDIRTOPROFILE']=='true' ? 'checked="checked"' : '' , |
---|
| 636 | 'UAM_REDIRTOPROFILE_FALSE' => $conf_UAM['REDIRTOPROFILE']=='false' ? 'checked="checked"' : '' , |
---|
| 637 | 'UAM_GTAUTO_TRUE' => $conf_UAM['GTAUTO']=='true' ? 'checked="checked"' : '' , |
---|
| 638 | 'UAM_GTAUTO_FALSE' => $conf_UAM['GTAUTO']=='false' ? 'checked="checked"' : '' , |
---|
| 639 | 'UAM_GTAUTOMAIL_TRUE' => $conf_UAM['GTAUTOMAIL']=='true' ? 'checked="checked"' : '' , |
---|
| 640 | 'UAM_GTAUTOMAIL_FALSE' => $conf_UAM['GTAUTOMAIL']=='false' ? 'checked="checked"' : '' , |
---|
| 641 | 'UAM_GTAUTODEL_TEXT' => $conf_UAM['GTAUTODEL'], |
---|
| 642 | 'UAM_GTAUTOMAILTEXT' => $conf_UAM['GTAUTOMAILTEXT'], |
---|
| 643 | 'UAM_Downgrade_Group' => $conf_UAM['DOWNGRADE_GROUP'], |
---|
| 644 | 'UAM_Downgrade_Status' => $conf_UAM['DOWNGRADE_STATUS'], |
---|
| 645 | 'UAM_ADMINVALIDATIONMAIL_TEXT' => $conf_UAM['ADMINVALIDATIONMAIL'], |
---|
| 646 | 'UAM_CUSTOMPASSWRETR_TRUE' => $conf_UAM['CUSTOMPASSWRETR']=='true' ? 'checked="checked"' : '' , |
---|
| 647 | 'UAM_CUSTOMPASSWRETR_FALSE' => $conf_UAM['CUSTOMPASSWRETR']=='false' ? 'checked="checked"' : '' , |
---|
| 648 | 'UAM_CUSTOMPASSWRETR_TEXT' => $conf_UAM['CUSTOMPASSWRETR_TEXT'], |
---|
| 649 | 'UAM_USRAUTO_TRUE' => $conf_UAM['USRAUTO']=='true' ? 'checked="checked"' : '' , |
---|
| 650 | 'UAM_USRAUTO_FALSE' => $conf_UAM['USRAUTO']=='false' ? 'checked="checked"' : '' , |
---|
| 651 | 'UAM_USRAUTODEL_TEXT' => $conf_UAM['USRAUTODEL'], |
---|
| 652 | 'UAM_USRAUTOMAIL_TRUE' => $conf_UAM['USRAUTOMAIL']=='true' ? 'checked="checked"' : '' , |
---|
| 653 | 'UAM_USRAUTOMAIL_FALSE' => $conf_UAM['USRAUTOMAIL']=='false' ? 'checked="checked"' : '' , |
---|
| 654 | 'UAM_STUFFS_TRUE' => $conf_UAM['STUFFS']=='true' ? 'checked="checked"' : '' , |
---|
| 655 | 'UAM_STUFFS_FALSE' => $conf_UAM['STUFFS']=='false' ? 'checked="checked"' : '' , |
---|
| 656 | 'UAM_HIDEPASSW_TRUE' => $conf_UAM['HIDEPASSW']=='true' ? 'checked="checked"' : '' , |
---|
| 657 | 'UAM_HIDEPASSW_FALSE' => $conf_UAM['HIDEPASSW']=='false' ? 'checked="checked"' : '' , |
---|
| 658 | 'UAM_NO_VALID_LEVEL' => $conf_UAM['NO_VALID_LEVEL'], |
---|
| 659 | 'UAM_VALID_LEVEL' => $conf_UAM['VALID_LEVEL'], |
---|
| 660 | 'UAM_DOWNGRADE_LEVEL' => $conf_UAM['DOWNGRADE_LEVEL'], |
---|
| 661 | 'UAM_PWDRESET_TRUE' => $conf_UAM['PWDRESET']=='true' ? 'checked="checked"' : '' , |
---|
| 662 | 'UAM_PWDRESET_FALSE' => $conf_UAM['PWDRESET']=='false' ? 'checked="checked"' : '' , |
---|
| 663 | 'UAM_REJECTCONNECT_TRUE' => $conf_UAM['REJECTCONNECT']=='true' ? 'checked="checked"' : '' , |
---|
| 664 | 'UAM_REJECTCONNECT_FALSE' => $conf_UAM['REJECTCONNECT']=='false' ? 'checked="checked"' : '' , |
---|
| 665 | 'UAM_REJECTCONNECT_TEXT' => $conf_UAM['REJECTCONNECT_TEXT'], |
---|
| 666 | 'UAM_CONFIRMMAIL_SUBJECT' => $conf_UAM['CONFIRMMAIL_SUBJECT'], |
---|
| 667 | 'UAM_CONFIRMMAIL_REMAIL_SUBJECT' => $conf_UAM['CONFIRMMAIL_REMAIL_SUBJECT'], |
---|
| 668 | 'UAM_INFOMAIL_SUBJECT' => $conf_UAM['INFOMAIL_SUBJECT'], |
---|
| 669 | 'UAM_GTAUTOMAIL_SUBJECT' => $conf_UAM['GTAUTOMAIL_SUBJECT'], |
---|
| 670 | 'UAM_GTREMINDER_SUBJECT' => $conf_UAM['GTREMINDER_SUBJECT'], |
---|
| 671 | 'UAM_ADMINVALIDATIONMAIL_SUBJECT' => $conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'], |
---|
[17918] | 672 | 'UAM_PASSWORD_TEST_SCORE' => $UAM_Password_Test_Score, |
---|
[20591] | 673 | 'UAM_ERROR_REPORTS1' => $UAM_Exclusionlist_Error, |
---|
| 674 | 'UAM_ERROR_REPORTS2' => $UAM_Illegal_Flag_Error1, |
---|
| 675 | 'UAM_ERROR_REPORTS3' => $UAM_Illegal_Flag_Error2, |
---|
| 676 | 'UAM_ERROR_REPORTS4' => $UAM_Illegal_Flag_Error3, |
---|
| 677 | 'UAM_EMAIL_MANDATORY' => $UAM_Email_Mandatory_Check, |
---|
[21075] | 678 | 'UAM_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT']=='true' ? 'checked="checked"' : '' , |
---|
| 679 | 'UAM_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_UAM_ConfirmMail['CONFIRMMAIL_TIMEOUT']=='false' ? 'checked="checked"' : '' , |
---|
| 680 | 'UAM_CONFIRMMAIL_DELAY' => $conf_UAM_ConfirmMail['CONFIRMMAIL_DELAY'], |
---|
| 681 | 'UAM_CONFIRMMAIL_REMAIL_TRUE' => $conf_UAM_ConfirmMail['CONFIRMMAIL_REMAIL']=='true' ? 'checked="checked"' : '', |
---|
| 682 | 'UAM_CONFIRMMAIL_REMAIL_FALSE' => $conf_UAM_ConfirmMail['CONFIRMMAIL_REMAIL']=='false' ? 'checked="checked"' : '', |
---|
| 683 | 'UAM_CONFIRMMAIL_REMAIL_TXT1' => $conf_UAM_ConfirmMail['CONFIRMMAIL_REMAIL_TXT1'], |
---|
| 684 | 'UAM_CONFIRMMAIL_REMAIL_TXT2' => $conf_UAM_ConfirmMail['CONFIRMMAIL_REMAIL_TXT2'], |
---|
| 685 | 'UAM_CONFIRMMAIL_CUSTOM_TXT1' => $conf_UAM_ConfirmMail['CONFIRMMAIL_CUSTOM_TXT1'], |
---|
| 686 | 'UAM_CONFIRMMAIL_CUSTOM_TXT2' => $conf_UAM_ConfirmMail['CONFIRMMAIL_CUSTOM_TXT2'], |
---|
[5056] | 687 | ) |
---|
| 688 | ); |
---|
| 689 | |
---|
| 690 | if (isset($_POST['audit'])) |
---|
[20591] | 691 | { |
---|
| 692 | $msg_error1 = ''; |
---|
[5056] | 693 | |
---|
[12271] | 694 | // Username without forbidden keys |
---|
| 695 | // ------------------------------- |
---|
[21075] | 696 | if ( isset($conf_UAM['USERNAME_CHAR']) and $conf_UAM['USERNAME_CHAR'] == 'true' ) |
---|
[20591] | 697 | { |
---|
| 698 | $query = ' |
---|
[17918] | 699 | SELECT '.$conf['user_fields']['username'].', '.$conf['user_fields']['email'].' |
---|
[20591] | 700 | FROM '.USERS_TABLE.' |
---|
[17918] | 701 | ;'; |
---|
[5056] | 702 | |
---|
[20591] | 703 | $result = pwg_query($query); |
---|
| 704 | |
---|
| 705 | while($row = pwg_db_fetch_assoc($result)) |
---|
| 706 | { |
---|
| 707 | if (!ValidateUsername(stripslashes($row['username']))) |
---|
| 708 | $msg_error1 .= (($msg_error1 <> '') ? '<br>' : '').l10n('UAM_Err_audit_username_char').stripslashes($row['username']); |
---|
| 709 | } |
---|
| 710 | } |
---|
| 711 | |
---|
| 712 | $msg_error2 = ''; |
---|
[5056] | 713 | |
---|
[12271] | 714 | // Email without forbidden domain |
---|
| 715 | // ------------------------------ |
---|
[21075] | 716 | if ( isset($conf_UAM['MAILEXCLUSION']) and $conf_UAM['MAILEXCLUSION'] == 'true' ) |
---|
[20591] | 717 | { |
---|
| 718 | $query = ' |
---|
[17918] | 719 | SELECT '.$conf['user_fields']['username'].', '.$conf['user_fields']['email'].' |
---|
[20591] | 720 | FROM '.USERS_TABLE.' |
---|
[17918] | 721 | ;'; |
---|
[20591] | 722 | |
---|
| 723 | $result = pwg_query($query); |
---|
| 724 | |
---|
| 725 | while($row = pwg_db_fetch_assoc($result)) |
---|
| 726 | { |
---|
[21075] | 727 | $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM['MAILEXCLUSION_LIST']); |
---|
[20591] | 728 | for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++) |
---|
| 729 | { |
---|
| 730 | $pattern = '/'.$conf_MailExclusion[$i].'/'; |
---|
| 731 | if (preg_match($pattern, $row['mail_address'])) |
---|
| 732 | { |
---|
| 733 | $msg_error2 .= (($msg_error2 <> '') ? '<br>' : '').l10n('UAM_Err_audit_email_forbidden').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | } |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | if ($msg_error1 <> '') |
---|
| 740 | $errors[] = $msg_error1.'<br><br>'; |
---|
| 741 | |
---|
| 742 | if ($msg_error2 <> '') |
---|
| 743 | $errors[] = $msg_error2.'<br><br>'; |
---|
| 744 | |
---|
| 745 | if ($msg_error1 <> '' or $msg_error2 <> '') |
---|
| 746 | array_push($page['errors'], l10n('UAM_Err_audit_advise')); |
---|
| 747 | else |
---|
| 748 | array_push($page['infos'], l10n('UAM_audit_ok')); |
---|
[17918] | 749 | } |
---|
[5056] | 750 | |
---|
| 751 | |
---|
| 752 | // +-----------------------------------------------------------------------+ |
---|
| 753 | // | errors display | |
---|
| 754 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 755 | if (isset ($errors) and count($errors) != 0) |
---|
[5056] | 756 | { |
---|
[20591] | 757 | $template->assign('errors',array()); |
---|
| 758 | foreach ($errors as $error) |
---|
| 759 | { |
---|
| 760 | array_push($page['errors'], $error); |
---|
| 761 | } |
---|
| 762 | } |
---|
[5056] | 763 | |
---|
| 764 | // +-----------------------------------------------------------------------+ |
---|
| 765 | // | templates display | |
---|
| 766 | // +-----------------------------------------------------------------------+ |
---|
[5593] | 767 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl'); |
---|
[5056] | 768 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 769 | |
---|
| 770 | break; |
---|
| 771 | |
---|
| 772 | |
---|
| 773 | // ************************************************************************* |
---|
| 774 | // +-----------------------------------------------------------------------+ |
---|
| 775 | // | Users list page | |
---|
| 776 | // +-----------------------------------------------------------------------+ |
---|
| 777 | // ************************************************************************* |
---|
| 778 | case 'userlist': |
---|
| 779 | |
---|
[5181] | 780 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 781 | |
---|
[21075] | 782 | if (isset($conf_UAM['ADDLASTVISIT']) and $conf_UAM['ADDLASTVISIT']=='true') |
---|
[5056] | 783 | { |
---|
| 784 | // +-----------------------------------------------------------------------+ |
---|
| 785 | // | initialization | |
---|
| 786 | // +-----------------------------------------------------------------------+ |
---|
| 787 | |
---|
[20591] | 788 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 789 | { |
---|
| 790 | die('Hacking attempt!'); |
---|
| 791 | } |
---|
[5056] | 792 | |
---|
[20591] | 793 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[5056] | 794 | |
---|
| 795 | // +-----------------------------------------------------------------------+ |
---|
| 796 | // | Check Access and exit when user status is not ok | |
---|
| 797 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 798 | check_status(ACCESS_ADMINISTRATOR); |
---|
[5056] | 799 | |
---|
| 800 | |
---|
| 801 | // +-----------------------------------------------------------------------+ |
---|
| 802 | // | user list | |
---|
| 803 | // +-----------------------------------------------------------------------+ |
---|
| 804 | |
---|
[20591] | 805 | $page['filtered_users'] = get_user_list(); |
---|
[5056] | 806 | |
---|
| 807 | // +-----------------------------------------------------------------------+ |
---|
| 808 | // | user list | |
---|
| 809 | // +-----------------------------------------------------------------------+ |
---|
| 810 | |
---|
[20591] | 811 | $visible_user_list = array(); |
---|
[17918] | 812 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
| 813 | { |
---|
[20591] | 814 | $visible_user_list[] = $local_user; |
---|
| 815 | } |
---|
[5056] | 816 | |
---|
[20591] | 817 | foreach ($visible_user_list as $local_user) |
---|
| 818 | { |
---|
| 819 | // dates formating and compare |
---|
[17918] | 820 | // --------------------------- |
---|
| 821 | $today = date("d-m-Y"); // Get today's date |
---|
| 822 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
| 823 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
[5056] | 824 | |
---|
[17918] | 825 | list($regdate, $regtime) = explode(' ', $local_user['lastvisit']); // Explode date and time from registration date |
---|
| 826 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
| 827 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
| 828 | |
---|
[20591] | 829 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
[17918] | 830 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
| 831 | |
---|
[21075] | 832 | if (isset($conf_UAM['GHOSTRACKER']) and $conf_UAM['GHOSTRACKER']=='true' and !empty($conf_UAM['GHOSTRACKER_DAYLIMIT'])) |
---|
[17918] | 833 | { |
---|
[21075] | 834 | if ($deltadays <= ($conf_UAM['GHOSTRACKER_DAYLIMIT']/2)) |
---|
[17918] | 835 | { |
---|
[20591] | 836 | $display = 'green'; |
---|
[17918] | 837 | } |
---|
| 838 | |
---|
[21075] | 839 | if (($deltadays > ($conf_UAM['GHOSTRACKER_DAYLIMIT']/2)) and ($deltadays < $conf_UAM['GHOSTRACKER_DAYLIMIT'])) |
---|
[17918] | 840 | { |
---|
[20591] | 841 | $display = 'orange'; |
---|
[17918] | 842 | } |
---|
| 843 | |
---|
[21075] | 844 | if ($deltadays >= $conf_UAM['GHOSTRACKER_DAYLIMIT']) |
---|
[17918] | 845 | { |
---|
[20591] | 846 | $display = 'red'; |
---|
[17918] | 847 | } |
---|
[20591] | 848 | } |
---|
[17918] | 849 | else $display = ''; |
---|
| 850 | |
---|
| 851 | // Template initialization |
---|
| 852 | // ----------------------- |
---|
| 853 | $template->append( |
---|
| 854 | 'users', |
---|
| 855 | array( |
---|
| 856 | 'ID' => $local_user['id'], |
---|
[20591] | 857 | 'USERNAME' => stripslashes($local_user['username']), |
---|
| 858 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
| 859 | 'LASTVISIT' => $local_user['lastvisit'], |
---|
| 860 | 'DAYS' => $deltadays, |
---|
| 861 | 'DISPLAY' => $display, |
---|
| 862 | ) |
---|
| 863 | ); |
---|
| 864 | } |
---|
[17918] | 865 | |
---|
[20591] | 866 | // Plugin version inserted |
---|
[17918] | 867 | // ----------------------- |
---|
| 868 | $template->assign( |
---|
| 869 | array( |
---|
| 870 | 'UAM_VERSION' => $version, |
---|
[20591] | 871 | 'UAM_PATH' => UAM_PATH, |
---|
| 872 | ) |
---|
| 873 | ); |
---|
| 874 | |
---|
[5056] | 875 | // +-----------------------------------------------------------------------+ |
---|
| 876 | // | errors display | |
---|
| 877 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 878 | if ( isset ($errors) and count($errors) != 0) |
---|
| 879 | { |
---|
| 880 | $template->assign('errors',array()); |
---|
| 881 | foreach ($errors as $error) |
---|
| 882 | { |
---|
| 883 | array_push($page['errors'], $error); |
---|
| 884 | } |
---|
| 885 | } |
---|
[5056] | 886 | |
---|
| 887 | // +-----------------------------------------------------------------------+ |
---|
| 888 | // | templates display | |
---|
| 889 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 890 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/userlist.tpl'); |
---|
| 891 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 892 | } |
---|
| 893 | else |
---|
| 894 | { |
---|
| 895 | array_push($page['errors'], l10n('UAM_Err_Userlist_Settings')); |
---|
| 896 | } |
---|
[5056] | 897 | |
---|
[17918] | 898 | break; |
---|
[5056] | 899 | |
---|
[17918] | 900 | |
---|
[5056] | 901 | // ************************************************************************* |
---|
| 902 | // +-----------------------------------------------------------------------+ |
---|
| 903 | // | Users manager page | |
---|
| 904 | // +-----------------------------------------------------------------------+ |
---|
| 905 | // ************************************************************************* |
---|
| 906 | case 'usermanager': |
---|
| 907 | |
---|
[5181] | 908 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 909 | |
---|
[5181] | 910 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 911 | |
---|
[21075] | 912 | if (isset($conf_UAM['CONFIRM_MAIL']) and ($conf_UAM['CONFIRM_MAIL']=='true' or $conf_UAM['CONFIRM_MAIL']=='local')) |
---|
[8072] | 913 | { |
---|
[5056] | 914 | // +-----------------------------------------------------------------------+ |
---|
| 915 | // | initialization | |
---|
| 916 | // +-----------------------------------------------------------------------+ |
---|
| 917 | |
---|
[20591] | 918 | if (!defined('PHPWG_ROOT_PATH')) |
---|
[5056] | 919 | { |
---|
[20591] | 920 | die('Hacking attempt!'); |
---|
[5056] | 921 | } |
---|
[8072] | 922 | |
---|
[5056] | 923 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 924 | |
---|
| 925 | // +-----------------------------------------------------------------------+ |
---|
| 926 | // | Check Access and exit when user status is not ok | |
---|
| 927 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 928 | check_status(ACCESS_ADMINISTRATOR); |
---|
[5056] | 929 | |
---|
| 930 | // +-----------------------------------------------------------------------+ |
---|
| 931 | // | user list | |
---|
| 932 | // +-----------------------------------------------------------------------+ |
---|
| 933 | |
---|
[20591] | 934 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
[5056] | 935 | |
---|
| 936 | // +-----------------------------------------------------------------------+ |
---|
| 937 | // | selected users | |
---|
| 938 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 939 | if (isset($_POST['Del_Selected'])) |
---|
| 940 | { |
---|
| 941 | $collection = array(); |
---|
[5056] | 942 | |
---|
[20591] | 943 | switch ($_POST['target']) |
---|
| 944 | { |
---|
| 945 | case 'all' : |
---|
| 946 | { |
---|
| 947 | foreach($page['filtered_users'] as $local_user) |
---|
| 948 | { |
---|
| 949 | array_push($collection, $local_user['id']); |
---|
| 950 | } |
---|
| 951 | break; |
---|
| 952 | } |
---|
| 953 | case 'selection' : |
---|
| 954 | { |
---|
| 955 | if (isset($_POST['selection'])) |
---|
| 956 | { |
---|
| 957 | $collection = $_POST['selection']; |
---|
| 958 | } |
---|
| 959 | break; |
---|
| 960 | } |
---|
| 961 | } |
---|
[17918] | 962 | |
---|
[20591] | 963 | if (count($collection) == 0) |
---|
| 964 | { |
---|
| 965 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 966 | } |
---|
| 967 | } |
---|
[5056] | 968 | |
---|
| 969 | // +-----------------------------------------------------------------------+ |
---|
| 970 | // | delete users | |
---|
| 971 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 972 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
---|
| 973 | { |
---|
| 974 | if (in_array($conf['guest_id'], $collection)) |
---|
| 975 | { |
---|
| 976 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
| 977 | } |
---|
| 978 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 979 | in_array($conf['default_user_id'], $collection)) |
---|
| 980 | { |
---|
| 981 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
| 982 | } |
---|
| 983 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 984 | { |
---|
| 985 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
| 986 | } |
---|
| 987 | if (in_array($user['id'], $collection)) |
---|
| 988 | { |
---|
| 989 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
| 990 | } |
---|
[5056] | 991 | |
---|
[20591] | 992 | if (count($page['errors']) == 0) |
---|
| 993 | { |
---|
| 994 | foreach ($collection as $user_id) |
---|
| 995 | { |
---|
| 996 | delete_user($user_id); |
---|
| 997 | } |
---|
| 998 | array_push( |
---|
| 999 | $page['infos'], |
---|
| 1000 | l10n_dec( |
---|
| 1001 | '%d user deleted', '%d users deleted', |
---|
| 1002 | count($collection) |
---|
| 1003 | ) |
---|
| 1004 | ); |
---|
[5056] | 1005 | |
---|
[20591] | 1006 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
| 1007 | { |
---|
| 1008 | if (in_array($filter_user['id'], $collection)) |
---|
| 1009 | { |
---|
| 1010 | unset($page['filtered_users'][$filter_key]); |
---|
| 1011 | } |
---|
| 1012 | } |
---|
| 1013 | } |
---|
| 1014 | } |
---|
[5056] | 1015 | |
---|
| 1016 | // +-----------------------------------------------------------------------+ |
---|
| 1017 | // | Resend new validation key to users | |
---|
| 1018 | // +-----------------------------------------------------------------------+ |
---|
| 1019 | // +-----------------------------------------------------------------------+ |
---|
| 1020 | // | selected users | |
---|
| 1021 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1022 | if (isset($_POST['Mail_With_Key'])) |
---|
| 1023 | { |
---|
| 1024 | $collection = array(); |
---|
[5056] | 1025 | |
---|
[20591] | 1026 | switch ($_POST['target']) |
---|
| 1027 | { |
---|
| 1028 | case 'all' : |
---|
| 1029 | { |
---|
| 1030 | foreach($page['filtered_users'] as $local_user) |
---|
| 1031 | { |
---|
| 1032 | array_push($collection, $local_user['id']); |
---|
| 1033 | } |
---|
| 1034 | break; |
---|
| 1035 | } |
---|
| 1036 | case 'selection' : |
---|
| 1037 | { |
---|
| 1038 | if (isset($_POST['selection'])) |
---|
| 1039 | { |
---|
| 1040 | $collection = $_POST['selection']; |
---|
| 1041 | } |
---|
| 1042 | break; |
---|
| 1043 | } |
---|
| 1044 | } |
---|
[17918] | 1045 | |
---|
[20591] | 1046 | if (count($collection) == 0) |
---|
| 1047 | { |
---|
| 1048 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 1049 | } |
---|
| 1050 | } |
---|
[5056] | 1051 | // +-----------------------------------------------------------------------+ |
---|
| 1052 | // | Resend new validation key to users | |
---|
| 1053 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1054 | if (isset($_POST['Mail_With_Key']) and count($collection) > 0) |
---|
| 1055 | { |
---|
| 1056 | if (in_array($conf['guest_id'], $collection)) |
---|
| 1057 | { |
---|
| 1058 | array_push($page['errors'], l10n('UAM_No_validation_for_Guest')); |
---|
| 1059 | } |
---|
| 1060 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 1061 | in_array($conf['default_user_id'], $collection)) |
---|
| 1062 | { |
---|
| 1063 | array_push($page['errors'], l10n('UAM_No_validation_for_default_user')); |
---|
| 1064 | } |
---|
| 1065 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 1066 | { |
---|
| 1067 | array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster')); |
---|
| 1068 | } |
---|
| 1069 | if (in_array($user['id'], $collection)) |
---|
| 1070 | { |
---|
| 1071 | array_push($page['errors'], l10n('UAM_No_validation_for_your_account')); |
---|
| 1072 | } |
---|
[5056] | 1073 | |
---|
[20591] | 1074 | if (count($page['errors']) == 0) |
---|
| 1075 | { |
---|
| 1076 | foreach ($collection as $user_id) |
---|
| 1077 | { |
---|
| 1078 | $typemail = 1; |
---|
| 1079 | $query = ' |
---|
[5056] | 1080 | SELECT id, username, mail_address |
---|
[20591] | 1081 | FROM '.USERS_TABLE.' |
---|
[17918] | 1082 | WHERE id = '.$user_id.' |
---|
| 1083 | ;'; |
---|
[20591] | 1084 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 1085 | |
---|
[20591] | 1086 | ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],true); |
---|
| 1087 | } |
---|
| 1088 | array_push( |
---|
| 1089 | $page['infos'], |
---|
| 1090 | l10n_dec( |
---|
| 1091 | 'UAM_%d_Mail_With_Key', 'UAM_%d_Mails_With_Key', |
---|
| 1092 | count($collection) |
---|
| 1093 | ) |
---|
| 1094 | ); |
---|
| 1095 | |
---|
| 1096 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 1097 | } |
---|
| 1098 | } |
---|
| 1099 | |
---|
[5056] | 1100 | // +-----------------------------------------------------------------------+ |
---|
| 1101 | // | Send reminder without new key to users | |
---|
| 1102 | // +-----------------------------------------------------------------------+ |
---|
| 1103 | // +-----------------------------------------------------------------------+ |
---|
| 1104 | // | selected users | |
---|
| 1105 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1106 | if (isset($_POST['Mail_Without_Key'])) |
---|
| 1107 | { |
---|
| 1108 | $collection = array(); |
---|
[5056] | 1109 | |
---|
[20591] | 1110 | switch ($_POST['target']) |
---|
| 1111 | { |
---|
| 1112 | case 'all' : |
---|
| 1113 | { |
---|
| 1114 | foreach($page['filtered_users'] as $local_user) |
---|
| 1115 | { |
---|
| 1116 | array_push($collection, $local_user['id']); |
---|
| 1117 | } |
---|
| 1118 | break; |
---|
| 1119 | } |
---|
| 1120 | case 'selection' : |
---|
| 1121 | { |
---|
| 1122 | if (isset($_POST['selection'])) |
---|
| 1123 | { |
---|
| 1124 | $collection = $_POST['selection']; |
---|
| 1125 | } |
---|
| 1126 | break; |
---|
| 1127 | } |
---|
| 1128 | } |
---|
[17918] | 1129 | |
---|
[20591] | 1130 | if (count($collection) == 0) |
---|
| 1131 | { |
---|
| 1132 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 1133 | } |
---|
| 1134 | } |
---|
[5056] | 1135 | // +-----------------------------------------------------------------------+ |
---|
| 1136 | // | Send reminder without new key to users | |
---|
| 1137 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1138 | if (isset($_POST['Mail_Without_Key']) and count($collection) > 0) |
---|
| 1139 | { |
---|
| 1140 | if (in_array($conf['guest_id'], $collection)) |
---|
| 1141 | { |
---|
| 1142 | array_push($page['errors'], l10n('UAM_No_validation_for_Guest')); |
---|
| 1143 | } |
---|
| 1144 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 1145 | in_array($conf['default_user_id'], $collection)) |
---|
| 1146 | { |
---|
| 1147 | array_push($page['errors'], l10n('UAM_No_validation_for_default_user')); |
---|
| 1148 | } |
---|
| 1149 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 1150 | { |
---|
| 1151 | array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster')); |
---|
| 1152 | } |
---|
| 1153 | if (in_array($user['id'], $collection)) |
---|
| 1154 | { |
---|
| 1155 | array_push($page['errors'], l10n('UAM_No_validation_for_your_account')); |
---|
| 1156 | } |
---|
[5056] | 1157 | |
---|
[20591] | 1158 | if (count($page['errors']) == 0) |
---|
| 1159 | { |
---|
| 1160 | foreach ($collection as $user_id) |
---|
| 1161 | { |
---|
| 1162 | $typemail = 2; |
---|
| 1163 | $query = ' |
---|
[5056] | 1164 | SELECT id, username, mail_address |
---|
[20591] | 1165 | FROM '.USERS_TABLE.' |
---|
[17918] | 1166 | WHERE id = '.$user_id.' |
---|
| 1167 | ;'; |
---|
[5056] | 1168 | |
---|
[20591] | 1169 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 1170 | |
---|
| 1171 | ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],false); |
---|
| 1172 | } |
---|
| 1173 | array_push( |
---|
| 1174 | $page['infos'], |
---|
| 1175 | l10n_dec( |
---|
| 1176 | 'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent', |
---|
[17918] | 1177 | count($collection) |
---|
[20591] | 1178 | ) |
---|
| 1179 | ); |
---|
[5056] | 1180 | |
---|
[20591] | 1181 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 1182 | } |
---|
| 1183 | } |
---|
| 1184 | |
---|
[5056] | 1185 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1186 | // | Manual validation by admins | |
---|
[5056] | 1187 | // +-----------------------------------------------------------------------+ |
---|
| 1188 | // +-----------------------------------------------------------------------+ |
---|
| 1189 | // | selected users | |
---|
| 1190 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1191 | if (isset($_POST['Manual_Validation'])) |
---|
| 1192 | { |
---|
| 1193 | $collection = array(); |
---|
[5056] | 1194 | |
---|
[20591] | 1195 | switch ($_POST['target']) |
---|
| 1196 | { |
---|
| 1197 | case 'all' : |
---|
| 1198 | { |
---|
| 1199 | foreach($page['filtered_users'] as $local_user) |
---|
| 1200 | { |
---|
| 1201 | array_push($collection, $local_user['id']); |
---|
| 1202 | } |
---|
| 1203 | break; |
---|
| 1204 | } |
---|
| 1205 | case 'selection' : |
---|
| 1206 | { |
---|
| 1207 | if (isset($_POST['selection'])) |
---|
| 1208 | { |
---|
| 1209 | $collection = $_POST['selection']; |
---|
| 1210 | } |
---|
[17918] | 1211 | break; |
---|
[20591] | 1212 | } |
---|
| 1213 | } |
---|
[17918] | 1214 | |
---|
[20591] | 1215 | if (count($collection) == 0) |
---|
| 1216 | { |
---|
| 1217 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 1218 | } |
---|
| 1219 | } |
---|
[5056] | 1220 | // +-----------------------------------------------------------------------+ |
---|
| 1221 | // | Force validation | |
---|
| 1222 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1223 | if (isset($_POST['Manual_Validation']) and count($collection) > 0) |
---|
| 1224 | { |
---|
| 1225 | if (in_array($conf['guest_id'], $collection)) |
---|
| 1226 | { |
---|
| 1227 | array_push($page['errors'], l10n('UAM_No_validation_for_Guest')); |
---|
| 1228 | } |
---|
| 1229 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 1230 | in_array($conf['default_user_id'], $collection)) |
---|
| 1231 | { |
---|
| 1232 | array_push($page['errors'], l10n('UAM_No_validation_for_default_user')); |
---|
| 1233 | } |
---|
| 1234 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 1235 | { |
---|
| 1236 | array_push($page['errors'], l10n('UAM_No_validation_for_Webmaster')); |
---|
| 1237 | } |
---|
| 1238 | if (in_array($user['id'], $collection)) |
---|
| 1239 | { |
---|
| 1240 | array_push($page['errors'], l10n('UAM_No_validation_for_your_account')); |
---|
| 1241 | } |
---|
[5056] | 1242 | |
---|
[20591] | 1243 | if (count($page['errors']) == 0) |
---|
| 1244 | { |
---|
| 1245 | foreach ($collection as $user_id) |
---|
| 1246 | { |
---|
| 1247 | ManualValidation($user_id); |
---|
[8092] | 1248 | validation_mail($user_id); |
---|
[20591] | 1249 | } |
---|
| 1250 | array_push( |
---|
| 1251 | $page['infos'], |
---|
| 1252 | l10n_dec( |
---|
| 1253 | 'UAM_%d_Validated_User', 'UAM_%d_Validated_Users', |
---|
[17918] | 1254 | count($collection) |
---|
[20591] | 1255 | ) |
---|
| 1256 | ); |
---|
[5056] | 1257 | |
---|
[20591] | 1258 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 1259 | } |
---|
| 1260 | } |
---|
[5056] | 1261 | |
---|
[20591] | 1262 | |
---|
[5056] | 1263 | // +-----------------------------------------------------------------------+ |
---|
| 1264 | // | groups list | |
---|
| 1265 | // +-----------------------------------------------------------------------+ |
---|
| 1266 | |
---|
[20591] | 1267 | $groups[-1] = '------------'; |
---|
[5056] | 1268 | |
---|
| 1269 | $query = ' |
---|
| 1270 | SELECT id, name |
---|
[20591] | 1271 | FROM '.GROUPS_TABLE.' |
---|
[5056] | 1272 | ORDER BY name ASC |
---|
| 1273 | ;'; |
---|
| 1274 | |
---|
[20591] | 1275 | $result = pwg_query($query); |
---|
| 1276 | |
---|
[5633] | 1277 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 1278 | { |
---|
[20591] | 1279 | $groups[$row['id']] = $row['name']; |
---|
[5056] | 1280 | } |
---|
| 1281 | |
---|
| 1282 | // +-----------------------------------------------------------------------+ |
---|
| 1283 | // | user list | |
---|
| 1284 | // +-----------------------------------------------------------------------+ |
---|
| 1285 | |
---|
[20591] | 1286 | $profile_url = get_root_url().'admin.php?page=profile&user_id='; |
---|
| 1287 | $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; |
---|
[5056] | 1288 | |
---|
| 1289 | $visible_user_list = array(); |
---|
| 1290 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
| 1291 | { |
---|
[20591] | 1292 | $visible_user_list[] = $local_user; |
---|
| 1293 | } |
---|
[5056] | 1294 | |
---|
[20591] | 1295 | foreach ($visible_user_list as $local_user) |
---|
[5056] | 1296 | { |
---|
[20591] | 1297 | $groups_string = preg_replace( |
---|
| 1298 | '/(\d+)/e', |
---|
[5056] | 1299 | "\$groups['$1']", |
---|
| 1300 | implode( |
---|
[20591] | 1301 | ', ', |
---|
| 1302 | $local_user['groups'] |
---|
| 1303 | ) |
---|
| 1304 | ); |
---|
[5056] | 1305 | |
---|
| 1306 | $query = ' |
---|
| 1307 | SELECT user_id, reminder |
---|
| 1308 | FROM '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 1309 | WHERE user_id = '.$local_user['id'].' |
---|
| 1310 | ;'; |
---|
| 1311 | $result = pwg_query($query); |
---|
| 1312 | |
---|
[5633] | 1313 | $row = pwg_db_fetch_assoc($result); |
---|
[5056] | 1314 | |
---|
| 1315 | if (isset($row['reminder']) and $row['reminder'] == 'true') |
---|
| 1316 | { |
---|
[9177] | 1317 | $reminder = l10n('UAM_Reminder_Sent_OK'); |
---|
[5056] | 1318 | } |
---|
[21695] | 1319 | else if ((isset($row['reminder']) and $row['reminder'] == 'false') or $row['reminder'] == null) |
---|
[5056] | 1320 | { |
---|
[9177] | 1321 | $reminder = l10n('UAM_Reminder_Sent_NOK'); |
---|
[5056] | 1322 | } |
---|
| 1323 | |
---|
[20591] | 1324 | if (isset($_POST['pref_submit']) |
---|
| 1325 | and isset($_POST['selection']) |
---|
| 1326 | and in_array($local_user['id'], $_POST['selection'])) |
---|
| 1327 | { |
---|
| 1328 | $checked = 'checked="checked"'; |
---|
| 1329 | } |
---|
| 1330 | else |
---|
| 1331 | { |
---|
| 1332 | $checked = ''; |
---|
| 1333 | } |
---|
[5056] | 1334 | |
---|
[20591] | 1335 | $properties = array(); |
---|
[5056] | 1336 | |
---|
[20591] | 1337 | if ($local_user['level'] != 0) |
---|
| 1338 | { |
---|
| 1339 | $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); |
---|
| 1340 | } |
---|
[12271] | 1341 | |
---|
[20591] | 1342 | $properties[] = (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) |
---|
| 1343 | ? l10n('is_high_enabled') : l10n('is_high_disabled'); |
---|
| 1344 | |
---|
| 1345 | $expiration = expiration($local_user['id']); |
---|
| 1346 | |
---|
[12271] | 1347 | // Template initialization |
---|
| 1348 | // ----------------------- |
---|
[20591] | 1349 | $template->append( |
---|
| 1350 | 'users', |
---|
| 1351 | array( |
---|
| 1352 | 'ID' => $local_user['id'], |
---|
| 1353 | 'CHECKED' => $checked, |
---|
| 1354 | 'U_PROFILE' => $profile_url.$local_user['id'], |
---|
| 1355 | 'U_PERM' => $perm_url.$local_user['id'], |
---|
| 1356 | 'USERNAME' => stripslashes($local_user['username']) |
---|
| 1357 | .($local_user['id'] == $conf['guest_id'] |
---|
| 1358 | ? '<BR>['.l10n('is_the_guest').']' : '') |
---|
| 1359 | .($local_user['id'] == $conf['default_user_id'] |
---|
| 1360 | ? '<BR>['.l10n('is_the_default').']' : ''), |
---|
| 1361 | 'STATUS' => l10n('user_status_' |
---|
| 1362 | .$local_user['status']), |
---|
| 1363 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
| 1364 | 'GROUPS' => $groups_string, |
---|
| 1365 | 'REGISTRATION' => $local_user['registration_date'], |
---|
[21598] | 1366 | 'REMINDER' => $reminder, |
---|
[20591] | 1367 | 'EXPIRATION' => $expiration, |
---|
| 1368 | ) |
---|
| 1369 | ); |
---|
| 1370 | } |
---|
[6754] | 1371 | |
---|
| 1372 | // Check if validation of register is made by admin or visitor |
---|
| 1373 | // If visitor, $Confirm_Local is used to mask useless buttons |
---|
[12271] | 1374 | // ----------------------------------------------------------- |
---|
[6754] | 1375 | $Confirm_Local = ""; |
---|
| 1376 | |
---|
[21075] | 1377 | if ($conf_UAM['CONFIRM_MAIL'] == 'local') |
---|
[6754] | 1378 | { |
---|
[21075] | 1379 | $Confirm_Local = $conf_UAM['CONFIRM_MAIL']; |
---|
[6754] | 1380 | } |
---|
| 1381 | else |
---|
| 1382 | { |
---|
| 1383 | $Confirm_Local = ""; |
---|
| 1384 | } |
---|
| 1385 | |
---|
[12271] | 1386 | // Plugin version inserted |
---|
| 1387 | // ----------------------- |
---|
[5056] | 1388 | $template->assign( |
---|
[20591] | 1389 | array( |
---|
[6754] | 1390 | 'CONFIRM_LOCAL'=> $Confirm_Local, |
---|
[5181] | 1391 | 'UAM_VERSION' => $version, |
---|
| 1392 | 'UAM_PATH' => UAM_PATH, |
---|
[5056] | 1393 | ) |
---|
| 1394 | ); |
---|
| 1395 | |
---|
| 1396 | // +-----------------------------------------------------------------------+ |
---|
| 1397 | // | errors display | |
---|
| 1398 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1399 | if ( isset ($errors) and count($errors) != 0) |
---|
| 1400 | { |
---|
| 1401 | $template->assign('errors',array()); |
---|
| 1402 | foreach ($errors as $error) |
---|
| 1403 | { |
---|
| 1404 | array_push($page['errors'], $error); |
---|
| 1405 | } |
---|
| 1406 | } |
---|
[5056] | 1407 | |
---|
| 1408 | // +-----------------------------------------------------------------------+ |
---|
| 1409 | // | templates display | |
---|
| 1410 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1411 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/usermanager.tpl'); |
---|
| 1412 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 1413 | } |
---|
[5056] | 1414 | else |
---|
| 1415 | { |
---|
[20591] | 1416 | array_push($page['errors'], l10n('UAM_Err_UserManager_Settings')); |
---|
[5056] | 1417 | } |
---|
| 1418 | break; |
---|
| 1419 | |
---|
| 1420 | |
---|
| 1421 | // ************************************************************************* |
---|
| 1422 | // +-----------------------------------------------------------------------+ |
---|
| 1423 | // | Ghost Tracker page | |
---|
| 1424 | // +-----------------------------------------------------------------------+ |
---|
| 1425 | // ************************************************************************* |
---|
[20591] | 1426 | case 'ghosttracker': |
---|
[5056] | 1427 | |
---|
[5181] | 1428 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1429 | |
---|
[21075] | 1430 | if (isset($conf_UAM['GHOSTRACKER_DAYLIMIT']) and $conf_UAM['GHOSTRACKER']=='true') |
---|
[5056] | 1431 | { |
---|
| 1432 | // +-----------------------------------------------------------------------+ |
---|
| 1433 | // | initialization | |
---|
| 1434 | // +-----------------------------------------------------------------------+ |
---|
| 1435 | |
---|
[20591] | 1436 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 1437 | { |
---|
| 1438 | die('Hacking attempt!'); |
---|
| 1439 | } |
---|
| 1440 | |
---|
| 1441 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[5056] | 1442 | |
---|
| 1443 | // +-----------------------------------------------------------------------+ |
---|
| 1444 | // | Check Access and exit when user status is not ok | |
---|
| 1445 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1446 | check_status(ACCESS_ADMINISTRATOR); |
---|
[5056] | 1447 | |
---|
| 1448 | // +-----------------------------------------------------------------------+ |
---|
| 1449 | // | user list | |
---|
| 1450 | // +-----------------------------------------------------------------------+ |
---|
| 1451 | |
---|
[20591] | 1452 | $page['filtered_users'] = get_ghost_user_list(); |
---|
[5056] | 1453 | |
---|
| 1454 | // +-----------------------------------------------------------------------+ |
---|
| 1455 | // | selected users | |
---|
| 1456 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1457 | if (isset($_POST['Del_Selected'])) |
---|
| 1458 | { |
---|
| 1459 | $collection = array(); |
---|
[5056] | 1460 | |
---|
[20591] | 1461 | switch ($_POST['target']) |
---|
| 1462 | { |
---|
| 1463 | case 'all' : |
---|
| 1464 | { |
---|
| 1465 | foreach($page['filtered_users'] as $local_user) |
---|
| 1466 | { |
---|
| 1467 | array_push($collection, $local_user['id']); |
---|
| 1468 | } |
---|
| 1469 | break; |
---|
| 1470 | } |
---|
| 1471 | case 'selection' : |
---|
| 1472 | { |
---|
| 1473 | if (isset($_POST['selection'])) |
---|
| 1474 | { |
---|
| 1475 | $collection = $_POST['selection']; |
---|
| 1476 | } |
---|
| 1477 | break; |
---|
| 1478 | } |
---|
| 1479 | } |
---|
[17918] | 1480 | |
---|
[20591] | 1481 | if (count($collection) == 0) |
---|
| 1482 | { |
---|
| 1483 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 1484 | } |
---|
| 1485 | } |
---|
[5056] | 1486 | |
---|
| 1487 | // +-----------------------------------------------------------------------+ |
---|
| 1488 | // | delete users | |
---|
| 1489 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1490 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
---|
| 1491 | { |
---|
| 1492 | if (in_array($conf['guest_id'], $collection)) |
---|
| 1493 | { |
---|
| 1494 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
| 1495 | } |
---|
| 1496 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 1497 | in_array($conf['default_user_id'], $collection)) |
---|
| 1498 | { |
---|
| 1499 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
| 1500 | } |
---|
| 1501 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 1502 | { |
---|
| 1503 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
| 1504 | } |
---|
| 1505 | if (in_array($user['id'], $collection)) |
---|
| 1506 | { |
---|
| 1507 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
| 1508 | } |
---|
[5056] | 1509 | |
---|
[20591] | 1510 | if (count($page['errors']) == 0) |
---|
| 1511 | { |
---|
| 1512 | foreach ($collection as $user_id) |
---|
| 1513 | { |
---|
| 1514 | delete_user($user_id); |
---|
| 1515 | } |
---|
| 1516 | array_push( |
---|
| 1517 | $page['infos'], |
---|
| 1518 | l10n_dec( |
---|
| 1519 | '%d user deleted', '%d users deleted', |
---|
[17918] | 1520 | count($collection) |
---|
[20591] | 1521 | ) |
---|
| 1522 | ); |
---|
[5056] | 1523 | |
---|
[20591] | 1524 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
| 1525 | { |
---|
| 1526 | if (in_array($filter_user['id'], $collection)) |
---|
| 1527 | { |
---|
| 1528 | unset($page['filtered_users'][$filter_key]); |
---|
| 1529 | } |
---|
| 1530 | } |
---|
| 1531 | } |
---|
| 1532 | } |
---|
[5056] | 1533 | |
---|
| 1534 | // +-----------------------------------------------------------------------+ |
---|
| 1535 | // | Send ghost reminder | |
---|
| 1536 | // +-----------------------------------------------------------------------+ |
---|
| 1537 | // +-----------------------------------------------------------------------+ |
---|
| 1538 | // | selected users | |
---|
| 1539 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1540 | if (isset($_POST['Reminder_Email'])) |
---|
| 1541 | { |
---|
| 1542 | $collection = array(); |
---|
[5056] | 1543 | |
---|
[20591] | 1544 | switch ($_POST['target']) |
---|
| 1545 | { |
---|
| 1546 | case 'all' : |
---|
| 1547 | { |
---|
| 1548 | foreach($page['filtered_users'] as $local_user) |
---|
| 1549 | { |
---|
| 1550 | array_push($collection, $local_user['id']); |
---|
| 1551 | } |
---|
| 1552 | break; |
---|
| 1553 | } |
---|
| 1554 | case 'selection' : |
---|
| 1555 | { |
---|
| 1556 | if (isset($_POST['selection'])) |
---|
| 1557 | { |
---|
| 1558 | $collection = $_POST['selection']; |
---|
| 1559 | } |
---|
[17918] | 1560 | break; |
---|
[20591] | 1561 | } |
---|
| 1562 | } |
---|
[17918] | 1563 | |
---|
[20591] | 1564 | if (count($collection) == 0) |
---|
| 1565 | { |
---|
| 1566 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 1567 | } |
---|
| 1568 | } |
---|
[5056] | 1569 | // +-----------------------------------------------------------------------+ |
---|
| 1570 | // | Send ghost reminder | |
---|
| 1571 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1572 | if (isset($_POST['Reminder_Email']) and count($collection) > 0) |
---|
| 1573 | { |
---|
| 1574 | if (in_array($conf['guest_id'], $collection)) |
---|
| 1575 | { |
---|
| 1576 | array_push($page['errors'], l10n('UAM_No_reminder_for_Guest')); |
---|
| 1577 | } |
---|
| 1578 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 1579 | in_array($conf['default_user_id'], $collection)) |
---|
| 1580 | { |
---|
| 1581 | array_push($page['errors'], l10n('UAM_No_reminder_for_default_user')); |
---|
| 1582 | } |
---|
| 1583 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 1584 | { |
---|
| 1585 | array_push($page['errors'], l10n('UAM_No_reminder_for_Webmaster')); |
---|
| 1586 | } |
---|
| 1587 | if (in_array($user['id'], $collection)) |
---|
| 1588 | { |
---|
| 1589 | array_push($page['errors'], l10n('UAM_No_reminder_for_your_account')); |
---|
| 1590 | } |
---|
[5056] | 1591 | |
---|
[20591] | 1592 | if (count($page['errors']) == 0) |
---|
| 1593 | { |
---|
| 1594 | foreach ($collection as $user_id) |
---|
| 1595 | { |
---|
| 1596 | $query = ' |
---|
[5056] | 1597 | SELECT id, username, mail_address |
---|
[20591] | 1598 | FROM '.USERS_TABLE.' |
---|
[17918] | 1599 | WHERE id = '.$user_id.' |
---|
| 1600 | ;'; |
---|
[5056] | 1601 | |
---|
[20591] | 1602 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[17918] | 1603 | |
---|
[20591] | 1604 | ghostreminder($user_id,stripslashes($data['username']),$data['mail_address']); |
---|
| 1605 | } |
---|
| 1606 | |
---|
| 1607 | array_push( |
---|
| 1608 | $page['infos'], |
---|
| 1609 | l10n_dec( |
---|
| 1610 | 'UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent', |
---|
| 1611 | count($collection) |
---|
| 1612 | ) |
---|
| 1613 | ); |
---|
| 1614 | |
---|
| 1615 | $page['filtered_users'] = get_ghost_user_list(); |
---|
| 1616 | } |
---|
| 1617 | } |
---|
| 1618 | |
---|
[9253] | 1619 | if (isset($_POST['GhostTracker_Init']) and is_admin()) //Reset is only allowed for admins ! |
---|
[5056] | 1620 | { |
---|
[20591] | 1621 | $query1 = ' |
---|
[5056] | 1622 | SELECT * |
---|
[20591] | 1623 | FROM '.USER_LASTVISIT_TABLE.';'; |
---|
[5056] | 1624 | |
---|
[9253] | 1625 | $count = pwg_db_num_rows(pwg_query($query1)); |
---|
[5056] | 1626 | |
---|
[9253] | 1627 | if ($count <> 0) |
---|
| 1628 | { |
---|
[20591] | 1629 | $query = ' |
---|
[5056] | 1630 | SELECT DISTINCT u.id, |
---|
| 1631 | ui.status AS status |
---|
| 1632 | FROM '.USERS_TABLE.' AS u |
---|
| 1633 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 1634 | ON u.id = ui.user_id |
---|
| 1635 | WHERE u.id NOT IN (SELECT user_id FROM '.USER_LASTVISIT_TABLE.') |
---|
| 1636 | AND status != "webmaster" |
---|
| 1637 | AND status != "guest" |
---|
| 1638 | AND status != "admin" |
---|
| 1639 | ORDER BY u.id ASC |
---|
| 1640 | ;'; |
---|
| 1641 | |
---|
[9253] | 1642 | $result = pwg_query($query); |
---|
[20591] | 1643 | |
---|
[9253] | 1644 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 1645 | { |
---|
[19234] | 1646 | $dbnow = date("Y-m-d H:i:s"); |
---|
[5056] | 1647 | |
---|
[17918] | 1648 | $query = ' |
---|
| 1649 | INSERT INTO '.USER_LASTVISIT_TABLE.' |
---|
| 1650 | (user_id, lastvisit, reminder) |
---|
| 1651 | VALUES ('.$row['id'].',"'.$dbnow.'","false") |
---|
| 1652 | ;'; |
---|
[9253] | 1653 | pwg_query($query); |
---|
[5056] | 1654 | } |
---|
[9253] | 1655 | } |
---|
| 1656 | else if ($count == 0) |
---|
| 1657 | { |
---|
| 1658 | $query = ' |
---|
[5056] | 1659 | SELECT DISTINCT u.id, |
---|
| 1660 | ui.status AS status |
---|
| 1661 | FROM '.USERS_TABLE.' AS u |
---|
| 1662 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 1663 | ON u.id = ui.user_id |
---|
| 1664 | WHERE status != "webmaster" |
---|
| 1665 | AND status != "guest" |
---|
| 1666 | AND status != "admin" |
---|
| 1667 | ORDER BY u.id ASC |
---|
| 1668 | ;'; |
---|
| 1669 | |
---|
[9253] | 1670 | $result = pwg_query($query); |
---|
[20591] | 1671 | |
---|
[9253] | 1672 | while($row = pwg_db_fetch_assoc($result)) |
---|
| 1673 | { |
---|
[19234] | 1674 | $dbnow = date("Y-m-d H:i:s"); |
---|
[20591] | 1675 | |
---|
[17918] | 1676 | $query = ' |
---|
| 1677 | INSERT INTO '.USER_LASTVISIT_TABLE.' |
---|
| 1678 | (user_id, lastvisit, reminder) |
---|
| 1679 | VALUES ('.$row['id'].',"'.$dbnow.'","false") |
---|
| 1680 | ;'; |
---|
[9253] | 1681 | pwg_query($query); |
---|
[5056] | 1682 | } |
---|
[9253] | 1683 | } |
---|
[20591] | 1684 | |
---|
[9253] | 1685 | array_push($page['infos'], l10n('UAM_GhostTracker_Init_OK')); |
---|
[5056] | 1686 | } |
---|
| 1687 | |
---|
| 1688 | // +-----------------------------------------------------------------------+ |
---|
| 1689 | // | user list | |
---|
| 1690 | // +-----------------------------------------------------------------------+ |
---|
| 1691 | |
---|
| 1692 | $visible_user_list = array(); |
---|
| 1693 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
| 1694 | { |
---|
| 1695 | $visible_user_list[] = $local_user; |
---|
[20591] | 1696 | } |
---|
| 1697 | |
---|
| 1698 | foreach ($visible_user_list as $local_user) |
---|
[17918] | 1699 | { |
---|
[20591] | 1700 | $reminder = ''; |
---|
| 1701 | |
---|
[5056] | 1702 | if (isset($local_user['reminder']) and $local_user['reminder'] == 'true') |
---|
| 1703 | { |
---|
[9177] | 1704 | $reminder = l10n('UAM_Reminder_Sent_OK'); |
---|
[5056] | 1705 | } |
---|
| 1706 | else if (isset($local_user['reminder']) and $local_user['reminder'] == 'false') |
---|
| 1707 | { |
---|
[9177] | 1708 | $reminder = l10n('UAM_Reminder_Sent_NOK'); |
---|
[5056] | 1709 | } |
---|
[20591] | 1710 | |
---|
[5056] | 1711 | if (isset($_POST['pref_submit']) and isset($_POST['selection']) and in_array($local_user['id'], $_POST['selection'])) |
---|
[20591] | 1712 | { |
---|
| 1713 | $checked = 'checked="checked"'; |
---|
| 1714 | } |
---|
| 1715 | else |
---|
| 1716 | { |
---|
| 1717 | $checked = ''; |
---|
| 1718 | } |
---|
[5056] | 1719 | |
---|
[12271] | 1720 | // Template initialization |
---|
| 1721 | // ----------------------- |
---|
[5056] | 1722 | $template->append( |
---|
| 1723 | 'users', |
---|
| 1724 | array( |
---|
[20591] | 1725 | 'ID' => $local_user['id'], |
---|
[5056] | 1726 | 'CHECKED' => $checked, |
---|
| 1727 | 'USERNAME' => stripslashes($local_user['username']), |
---|
[20591] | 1728 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
[5056] | 1729 | 'LASTVISIT' => $local_user['lastvisit'], |
---|
| 1730 | 'REMINDER' => $reminder, |
---|
[20591] | 1731 | ) |
---|
| 1732 | ); |
---|
| 1733 | } |
---|
[5056] | 1734 | |
---|
[12271] | 1735 | // Plugin version inserted |
---|
| 1736 | // ----------------------- |
---|
[9153] | 1737 | $template->assign( |
---|
| 1738 | array( |
---|
| 1739 | 'UAM_VERSION' => $version, |
---|
| 1740 | 'UAM_PATH' => UAM_PATH, |
---|
| 1741 | ) |
---|
| 1742 | ); |
---|
| 1743 | |
---|
[5056] | 1744 | // +-----------------------------------------------------------------------+ |
---|
| 1745 | // | errors display | |
---|
| 1746 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1747 | if ( isset ($errors) and count($errors) != 0) |
---|
| 1748 | { |
---|
| 1749 | $template->assign('errors',array()); |
---|
| 1750 | foreach ($errors as $error) |
---|
| 1751 | { |
---|
| 1752 | array_push($page['errors'], $error); |
---|
| 1753 | } |
---|
| 1754 | } |
---|
[5056] | 1755 | |
---|
| 1756 | // +-----------------------------------------------------------------------+ |
---|
| 1757 | // | templates display | |
---|
| 1758 | // +-----------------------------------------------------------------------+ |
---|
[20591] | 1759 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/ghosttracker.tpl'); |
---|
[5056] | 1760 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
[20591] | 1761 | } |
---|
[5056] | 1762 | else |
---|
| 1763 | { |
---|
[20591] | 1764 | array_push($page['errors'], l10n('UAM_Err_GhostTracker_Settings')); |
---|
[5056] | 1765 | } |
---|
| 1766 | |
---|
| 1767 | break; |
---|
| 1768 | } |
---|
| 1769 | ?> |
---|