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