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