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