/************************************************************************ ||------------|| User email history page ||---------------------------|| This page lists previous email addresses a user has used on the site. It gets called if $_GET['action'] == 'email'. It also requires $_GET['userid'] in order to get the data for the correct user. ************************************************************************/ $UserID = $_GET['userid']; if (!is_number($UserID)) { error(404); } $DB->query("SELECT um.Username, ui.JoinDate, p.Level AS Class FROM users_main AS um JOIN users_info AS ui ON um.ID=ui.UserID JOIN permissions AS p ON p.ID=um.PermissionID WHERE um.ID = $UserID"); list($Username, $Joined, $Class) = $DB->next_record(); if(!check_perms('users_view_email', $Class)) { error(403); } $UsersOnly = $_GET['usersonly']; show_header("Email history for $Username"); // Get current email (and matches) $DB->query(" SELECT m.Email, '".sqltime()."' AS Time, m.IP, GROUP_CONCAT(h.UserID SEPARATOR '|') AS UserIDs, GROUP_CONCAT(h.Time SEPARATOR '|') AS UserSetTimes, GROUP_CONCAT(h.IP SEPARATOR '|') AS UserIPs, GROUP_CONCAT(m2.Username SEPARATOR '|') AS Usernames, GROUP_CONCAT(m2.Enabled SEPARATOR '|') AS UsersEnabled, GROUP_CONCAT(i.Donor SEPARATOR '|') AS UsersDonor, GROUP_CONCAT(i.Warned SEPARATOR '|') AS UsersWarned FROM users_main AS m LEFT JOIN users_history_emails AS h ON h.Email=m.Email AND h.UserID<>m.ID LEFT JOIN users_main AS m2 ON m2.ID=h.UserID LEFT JOIN users_info AS i ON i.UserID=h.UserID WHERE m.ID='$UserID'" ); $CurrentEmail = array_shift($DB->to_array()); // Get historic emails (and matches) $DB->query(" SELECT h2.Email, h2.Time, h2.IP, h3.UserID AS UserIDs, h3.Time AS UserSetTimes, h3.IP AS UserIPs, m3.Username AS Usernames, m3.Enabled AS UsersEnabled, i2.Donor AS UsersDonor, i2.Warned AS UsersWarned FROM users_history_emails AS h2 LEFT JOIN users_history_emails AS h3 ON h3.Email=h2.Email AND h3.UserID<>h2.UserID LEFT JOIN users_main AS m3 ON m3.ID=h3.UserID LEFT JOIN users_info AS i2 ON i2.UserID=h3.UserID WHERE h2.UserID='$UserID' ORDER BY Time DESC" ); $History = $DB->to_array(); // Current email $Current['Email'] = $CurrentEmail['Email']; $Current['StartTime'] = $History[0]['Time']; $Current['CurrentIP'] = $CurrentEmail['IP']; $Current['IP'] = $History[(count($History) - 1)]['IP']; // Matches for current email if ($CurrentEmail['Usernames'] != '') { $UserIDs=explode('|', $CurrentEmail['UserIDs']); $Usernames=explode('|', $CurrentEmail['Usernames']); $UsersEnabled=explode('|', $CurrentEmail['UsersEnabled']); $UsersDonor=explode('|', $CurrentEmail['UsersDonor']); $UsersWarned=explode('|', $CurrentEmail['UsersWarned']); $UserSetTimes=explode('|', $CurrentEmail['UserSetTimes']); $UserIPs=explode('|', $CurrentEmail['UserIPs']); foreach($UserIDs as $Key => $Val) { $CurrentMatches[$Key]['Username'] = ' » '.format_username($Val, $Usernames[$Key], $UsersDonor[$Key], $UsersWarned[$Key], $UsersEnabled[$Key] == 2 ? false : true); $CurrentMatches[$Key]['IP'] = $UserIPs[$Key]; $CurrentMatches[$Key]['EndTime'] = $UserSetTimes[$Key]; } } // Email history records if (count($History) == 1) { $Invite['Email'] = $History[0]['Email']; $Invite['EndTime'] = $Joined; $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago' $Invite['IP'] = $History[0]['IP']; if ($Current['StartTime'] == '0000-00-00 00:00:00') { $Current['StartTime'] = $Joined; } } else { foreach ($History as $Key => $Val) { if ($History[$Key+1]['Time'] == '0000-00-00 00:00:00' && $Val['Time'] != '0000-00-00 00:00:00') { // Invited email $Invite['Email'] = $Val['Email']; $Invite['EndTime'] = $Joined; $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago' $Invite['IP'] = $Val['IP']; } elseif ($History[$Key-1]['Email'] != $Val['Email'] && $Val['Time'] != '0000-00-00 00:00:00') { // Old email $i=1; while($Val['Email'] == $History[$Key+$i]['Email']) { $i++; } $Old[$Key]['StartTime'] = (isset($History[$Key+$i]) && $History[$Key+$i]['Time'] != '0000-00-00 00:00:00') ? $History[$Key+$i]['Time'] : $Joined; $Old[$Key]['EndTime'] = $Val['Time']; $Old[$Key]['IP'] = $Val['IP']; $Old[$Key]['ElapsedTime'] = date(time() + strtotime($Old[$Key]['EndTime']) - strtotime($Old[$Key]['StartTime'])); $Old[$Key]['Email'] = $Val['Email']; } else { // Shouldn't have to be here but I'll leave it anyway $Other[$Key]['StartTime'] = (isset($History[$Key+$i])) ? $History[$Key+$i]['Time'] : $Joined; $Other[$Key]['EndTime'] = $Val['Time']; $Other[$Key]['IP'] = $Val['IP']; $Other[$Key]['ElapsedTime'] = date(time() + strtotime($Other[$Key]['EndTime']) - strtotime($Other[$Key]['StartTime'])); $Other[$Key]['Email'] = $Val['Email']; } if ($Val['Usernames'] != '') { // Match with old email $OldMatches[$Key]['Email'] = $Val['Email']; $OldMatches[$Key]['Username'] = ' » '.format_username($Val['UserIDs'], $Val['Usernames'], $Val['UsersDonor'], $Val['UsersWarned'], $Val['UsersEnabled'] == 2 ? false : true); $OldMatches[$Key]['EndTime'] = $Val['UserSetTimes']; $OldMatches[$Key]['IP'] = $Val['UserIPs']; } } } // Clean up arrays if ($Old) { $Old = array_reverse(array_reverse($Old)); $LastOld = count($Old)-1; if ($Old[$LastOld]['StartTime'] != $Invite['EndTime']) { // Make sure the timeline is intact (invite email was used as email for the account in the beginning) $Old[$LastOld+1]['Email'] = $Invite['Email']; $Old[$LastOld+1]['StartTime'] = $Invite['EndTime']; $Old[$LastOld+1]['EndTime'] = $Old[$LastOld]['StartTime']; $Old[$LastOld+1]['ElapsedTime'] = date(time()+strtotime($Old[$LastOld+1]['EndTime'] )-strtotime($Old[$LastOld+1]['StartTime'])); $Old[$LastOld+1]['IP'] = $Invite['IP']; } } // Start page with current email ?>
Current email | Start | End | Current IP [H] | Set from IP |
=display_str($Current['Email'])?> | =time_diff($Current['StartTime'])?> |
=display_str($Current['CurrentIP'])?> (=get_cc($Current['CurrentIP'])?>) [S] [WI] =get_host($Current['CurrentIP'])?> |
=display_str($Current['IP'])?> (=get_cc($Current['IP'])?>) [S] [WI] =get_host($Current['IP'])?> |
|
=$Match['Username']?> | =time_diff($Match['EndTime'])?> |
=display_str($Match['IP'])?> (=get_cc($Match['IP'])?>) [S] [WI] =get_host($Match['IP'])?> |
||
Old emails | Start | End | Elapsed | Set from IP |
=display_str($Record['Email'])?>=(($MatchCount > 0) ? ' ('.$MatchCount.')' : '')?> | =time_diff($Record['StartTime'])?> | =time_diff($Record['EndTime'])?> | =time_diff($Record['ElapsedTime'])?> |
=display_str($Record['IP'])?> (=get_cc($Record['IP'])?>) [S] [WI] =get_host($Record['IP'])?> |
Invite email | Start | End | Age of account | Signup IP |
=display_str($Invite['Email'])?>=(($MatchCount > 0) ? ' ('.$MatchCount.')' : '')?> | Never | =time_diff($Invite['EndTime'])?> | =time_diff($Invite['AccountAge'])?> |
=display_str($Invite['IP'])?> (=get_cc($Invite['IP'])?>) [S] [WI] =get_host($Invite['IP'])?> |