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