Gazelle/sections/userhistory/email_history.php

151 lines
3.8 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/************************************************************************
||------------|| 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'];
2013-04-19 08:00:55 +00:00
if (!is_number($UserID)) {
error(404);
}
2011-03-28 14:21:28 +00:00
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT ui.JoinDate, p.Level AS Class
FROM users_main AS um
2013-07-04 08:00:56 +00:00
JOIN users_info AS ui ON um.ID = ui.UserID
JOIN permissions AS p ON p.ID = um.PermissionID
2013-05-27 08:00:58 +00:00
WHERE um.ID = $UserID");
2012-03-28 08:00:20 +00:00
list($Joined, $Class) = $DB->next_record();
2013-04-19 08:00:55 +00:00
if (!check_perms('users_view_email', $Class)) {
error(403);
}
$UsersOnly = $_GET['usersonly'];
2011-03-28 14:21:28 +00:00
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT Username
FROM users_main
WHERE ID = $UserID");
2012-03-29 08:00:19 +00:00
list($Username)= $DB->next_record();
2012-10-11 08:00:15 +00:00
View::show_header("Email history for $Username");
2011-03-28 14:21:28 +00:00
if ($UsersOnly == 1) {
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT
u.Email,
'".sqltime()."' AS Time,
u.IP,
c.Code
FROM users_main AS u
LEFT JOIN users_main AS u2 ON u2.Email = u.Email AND u2.ID != '$UserID'
LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
2013-07-04 08:00:56 +00:00
WHERE u.ID = '$UserID'
AND u2.ID > 0
2013-05-27 08:00:58 +00:00
UNION
SELECT
h.Email,
h.Time,
h.IP,
c.Code
FROM users_history_emails AS h
2013-07-04 08:00:56 +00:00
LEFT JOIN users_history_emails AS h2 ON h2.email = h.email and h2.UserID != '$UserID'
2013-05-27 08:00:58 +00:00
LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
2013-07-04 08:00:56 +00:00
WHERE h.UserID = '$UserID'
AND h2.UserID > 0"
/*AND Time != '0000-00-00 00:00:00'*/."
2013-05-27 08:00:58 +00:00
ORDER BY Time DESC");
2011-03-28 14:21:28 +00:00
} else {
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT
u.Email,
'".sqltime()."' AS Time,
u.IP,
c.Code
FROM users_main AS u
LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
2013-07-04 08:00:56 +00:00
WHERE u.ID = '$UserID'
2013-05-27 08:00:58 +00:00
UNION
SELECT
h.Email,
h.Time,
h.IP,
c.Code
FROM users_history_emails AS h
LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
2013-07-04 08:00:56 +00:00
WHERE UserID = '$UserID' "
/*AND Time != '0000-00-00 00:00:00'*/."
2013-05-27 08:00:58 +00:00
ORDER BY Time DESC");
2011-03-28 14:21:28 +00:00
}
$History = $DB->to_array();
?>
2012-08-19 08:00:19 +00:00
<div class="header">
<h2>Email history for <a href="user.php?id=<?=$UserID ?>"><?=$Username ?></a></h2>
</div>
2011-03-28 14:21:28 +00:00
<table width="100%">
<tr class="colhead">
<td>Email</td>
<td>Set</td>
2013-02-09 08:01:01 +00:00
<td>IP <a href="userhistory.php?action=ips&amp;userid=<?=$UserID ?>" class="brackets">H</a></td>
2011-03-28 14:21:28 +00:00
<? if ($UsersOnly == 1) {
?>
<td>User</td>
<?
}
?>
</tr>
<?
2013-04-20 08:01:01 +00:00
foreach ($History as $Key => $Values) {
if (isset($History[$Key + 1])) {
$Values['Time'] = $History[$Key + 1]['Time'];
2011-03-28 14:21:28 +00:00
} else {
$Values['Time'] = $Joined;
}
?>
<tr class="rowa">
<td><?=display_str($Values['Email'])?></td>
<td><?=time_diff($Values['Time'])?></td>
2013-11-05 08:01:12 +00:00
<td><?=display_str($Values['IP'])?> (<?=display_str($Values['Code'])?>) <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Values['IP'])?>" class="brackets tooltip" title="Search">S</a></td>
2011-03-28 14:21:28 +00:00
<?
if ($UsersOnly == 1) {
2013-04-20 08:01:01 +00:00
$ueQuery = $DB->query("
2013-11-05 08:01:12 +00:00
SELECT
ue.UserID,
2013-11-17 08:00:47 +00:00
um.Username,
2013-11-05 08:01:12 +00:00
ue.Time,
ue.IP
2013-11-17 08:00:47 +00:00
FROM users_history_emails AS ue, users_main AS um
2013-11-05 08:01:12 +00:00
WHERE ue.Email = '".db_string($Values['Email'])."'
2013-11-17 08:00:47 +00:00
AND ue.UserID != $UserID
AND um.ID = ue.UserID");
2012-03-28 08:00:20 +00:00
while (list($UserID2, $Time, $IP) = $DB->next_record()) { ?>
2011-03-28 14:21:28 +00:00
</tr>
<tr>
2013-08-28 23:08:41 +00:00
<td></td>
2011-03-28 14:21:28 +00:00
<td><?=time_diff($Time)?></td>
<td><?=display_str($IP)?></td>
2013-07-04 08:00:56 +00:00
<?
2014-02-27 08:00:30 +00:00
$UserURL = site_url()."user.php?id=$UserID2";
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT Enabled
FROM users_main
WHERE ID = $UserID2");
2013-05-16 16:15:57 +00:00
list($Enabled) = $DB->next_record();
2011-03-28 14:21:28 +00:00
$DB->set_query_id($ueQuery);
?>
2012-10-11 08:00:15 +00:00
<td><a href="<?=display_str($UserURL)?>"><?=Users::format_username($UserID2, false, false, true)?></a></td>
2013-02-22 08:00:24 +00:00
</tr>
2011-03-28 14:21:28 +00:00
<?
}
}
2013-04-20 08:01:01 +00:00
} ?>
2011-03-28 14:21:28 +00:00
</table>
2012-10-11 08:00:15 +00:00
<? View::show_footer(); ?>