CREATE TABLE `iplog` (
`id` int(10) unsigned NOT NULL auto_increment,
`ip` varchar(15) collate utf8_bin NOT NULL default '',
`userid` int(10) unsigned NOT NULL default '0',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`lastused` datetime NOT NULL default '0000-00-00 00:00:00',
`timesused` int(10) NOT NULL default '1',
PRIMARY KEY (`id`),
UNIQUE KEY `ip_userid` (`ip`,`userid`),
KEY `userid` (`userid`),
KEY `ip` (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
account-login.php, find:
logincookie($row["id"], $row["password"], hash_pad($row["secret"], 20));
add after:
$now = get_date_time();
mysql_query("INSERT INTO iplog (ip, userid, added, lastused) VALUES('".getip()."', $row[id], '$now', '$now') ON DUPLICATE KEY UPDATE timesused=timesused+1, lastused='$now'");
account-details.php, find:
begin_frame("Staff Only Information");
add after:
begin_frame("IP History");
echo "<table align=center cellpadding=0 cellspacing=0 class='ttable_headinner' width='99%'>";
$res = mysql_query("SELECT * FROM iplog WHERE userid=$id ORDER BY lastused DESC, timesused ASC");
echo "<tr><td class='ttable_head'>IP</td><td class='ttable_head'>".DATE_ADDED."</td><td class='ttable_head'>".LAST_ACCESS."</td><td class='ttable_head'>Times Used</td></tr>";
$x = 1;
while($row=mysql_fetch_assoc($res)) {
echo "<tr align='center' class='ttable_col$x'><td>$row[ip]</td><td>".date("d/m/Y H:i:s", utc_to_tz_time($row['added']))."</td><td>".date("d/m/Y H:i:s", utc_to_tz_time($row['lastused']))."</td><td>".number_format($row['timesused'])."</td></tr>";
if ($x == 1)
$x = 2;
else
$x = 1;
}
unset($x);
echo "</table>";
end_frame();
functions.php, find:
$GLOBALS["CURUSER"] = $row;
add before:
$r = get_row_count("iplog", "WHERE userid=$row[id] AND ip='$ip'");
if ($r == 0) {
$now = get_date_time();
mysql_query("INSERT INTO iplog (ip, userid, added, lastused) VALUES('".getip()."', $row[id], '$now', '$now') ON DUPLICATE KEY UPDATE timesused=timesused+1, lastused='$now'");
}

i'll update iphistory.php when i have some more time, unless someone else does it first.
iphistory.php:
<?php
require "backend/functions.php";
$userid = (int) $_GET["id"];
if (!is_valid_id($userid))
die;
dbconn(false);
loggedinonly();
if ($CURUSER["control_panel"] != "yes")
show_error_msg(_ERROR_, ACCESS_DENIED, 1);
$res = mysql_query("SELECT username FROM users WHERE id = $userid");
$arr = mysql_fetch_array($res) or show_error_msg(_ERROR_, "User not found.");
$username = $arr["username"];
$page = 0 + $_GET["page"];
$perpage = 20;
$countrows = number_format(get_row_count("iplog", "WHERE userid = $userid"));
$order = $_GET['order'];
list($pagertop, $pagerbottom, $limit) = pager($perpage, $countrows, "iphistory.php?id=$userid&order=$order&");
switch ($order) {
case 'ip':
$orderby = "iplog.ip DESC, iplog.lastused";
break;
case 'added':
$orderby = "iplog.added DESC, iplog.ip DESC, iplog.lastused DESC";
break;
default:
$orderby = "iplog.lastused";
}
$res = mysql_query("SELECT users.id, iplog.ip, iplog.added, iplog.lastused FROM users RIGHT JOIN iplog ON users.id = iplog.userid WHERE users.id=$userid ORDER BY $orderby $limit") or die(mysql_error());
stdhead("IP History Log for $username");
begin_frame("Historical IP addresses used by <a href=account-details.php?id=$userid><b>$username</b></a>");
echo $pagertop;
begin_table();
print("<tr>n
<td class=colhead><a class=colhead href="" . $_SERVER['PHP_SELF'] . "?id=$userid&order=lastused">Last used</a></td>n
<td class=colhead><a class=colhead href="" . $_SERVER['PHP_SELF'] . "?id=$userid&order=added">Added</a></td>n
<td class=colhead><a class=colhead href="" . $_SERVER['PHP_SELF'] . "?id=$userid&order=ip">IP</a></td>n
<td class=colhead>Hostname</td>n
</tr>n");
while ($arr = mysql_fetch_array($res)) {
$addr = " ";
$ipshow = "";
$ip = $arr["ip"];
$dom = @gethostbyaddr($arr["ip"]);
if ($dom == $arr["ip"] || @gethostbyname($dom) != $arr["ip"])
$addr = " ";
else
$addr = $dom;
$ipcount = get_row_count("users", "WHERE ip='$ip'");
$nip = ip2long($ip);
$bancount = get_row_count("bans", "WHERE $nip >= first AND $nip <= last");
if ($bancount == 0) {
if ($ipcount > 1)
$ipshow = "<b><a href=admin-search.php?ip=". $arr['ip'] .">" . $arr['ip'] ."</a></b>";
else
$ipshow = "<a href=admin-search.php?ip=". $arr['ip'] .">" . $arr['ip'] ."</a>";
} else
$ipshow = "<a href='/testip.php?ip=" . $arr['ip'] . "'><font color='#FF0000'><b>" . $arr['ip'] . "</b></font></a>";
print("<tr><td>".date("d/m/Y at H:i:s", sql_timestamp_to_unix_timestamp($arr["lastused"]))."</td>n");
print("<td>".date("d/m/Y at H:i:s", sql_timestamp_to_unix_timestamp($arr["added"]))."</td>n");
print("<td>$ipshow</td>n");
print("<td>$addr</td>n");
}
end_table();
echo $pagerbottom;
end_frame();
stdfoot();
?>
[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=7181"]iphistory.php[/url]
`id` int(10) unsigned NOT NULL auto_increment,
`ip` varchar(15) collate utf8_bin NOT NULL default '',
`userid` int(10) unsigned NOT NULL default '0',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`lastused` datetime NOT NULL default '0000-00-00 00:00:00',
`timesused` int(10) NOT NULL default '1',
PRIMARY KEY (`id`),
UNIQUE KEY `ip_userid` (`ip`,`userid`),
KEY `userid` (`userid`),
KEY `ip` (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
account-login.php, find:
logincookie($row["id"], $row["password"], hash_pad($row["secret"], 20));
add after:
$now = get_date_time();
mysql_query("INSERT INTO iplog (ip, userid, added, lastused) VALUES('".getip()."', $row[id], '$now', '$now') ON DUPLICATE KEY UPDATE timesused=timesused+1, lastused='$now'");
account-details.php, find:
begin_frame("Staff Only Information");
add after:
begin_frame("IP History");
echo "<table align=center cellpadding=0 cellspacing=0 class='ttable_headinner' width='99%'>";
$res = mysql_query("SELECT * FROM iplog WHERE userid=$id ORDER BY lastused DESC, timesused ASC");
echo "<tr><td class='ttable_head'>IP</td><td class='ttable_head'>".DATE_ADDED."</td><td class='ttable_head'>".LAST_ACCESS."</td><td class='ttable_head'>Times Used</td></tr>";
$x = 1;
while($row=mysql_fetch_assoc($res)) {
echo "<tr align='center' class='ttable_col$x'><td>$row[ip]</td><td>".date("d/m/Y H:i:s", utc_to_tz_time($row['added']))."</td><td>".date("d/m/Y H:i:s", utc_to_tz_time($row['lastused']))."</td><td>".number_format($row['timesused'])."</td></tr>";
if ($x == 1)
$x = 2;
else
$x = 1;
}
unset($x);
echo "</table>";
end_frame();
functions.php, find:
$GLOBALS["CURUSER"] = $row;
add before:
$r = get_row_count("iplog", "WHERE userid=$row[id] AND ip='$ip'");
if ($r == 0) {
$now = get_date_time();
mysql_query("INSERT INTO iplog (ip, userid, added, lastused) VALUES('".getip()."', $row[id], '$now', '$now') ON DUPLICATE KEY UPDATE timesused=timesused+1, lastused='$now'");
}

i'll update iphistory.php when i have some more time, unless someone else does it first.
iphistory.php:
<?php
require "backend/functions.php";
$userid = (int) $_GET["id"];
if (!is_valid_id($userid))
die;
dbconn(false);
loggedinonly();
if ($CURUSER["control_panel"] != "yes")
show_error_msg(_ERROR_, ACCESS_DENIED, 1);
$res = mysql_query("SELECT username FROM users WHERE id = $userid");
$arr = mysql_fetch_array($res) or show_error_msg(_ERROR_, "User not found.");
$username = $arr["username"];
$page = 0 + $_GET["page"];
$perpage = 20;
$countrows = number_format(get_row_count("iplog", "WHERE userid = $userid"));
$order = $_GET['order'];
list($pagertop, $pagerbottom, $limit) = pager($perpage, $countrows, "iphistory.php?id=$userid&order=$order&");
switch ($order) {
case 'ip':
$orderby = "iplog.ip DESC, iplog.lastused";
break;
case 'added':
$orderby = "iplog.added DESC, iplog.ip DESC, iplog.lastused DESC";
break;
default:
$orderby = "iplog.lastused";
}
$res = mysql_query("SELECT users.id, iplog.ip, iplog.added, iplog.lastused FROM users RIGHT JOIN iplog ON users.id = iplog.userid WHERE users.id=$userid ORDER BY $orderby $limit") or die(mysql_error());
stdhead("IP History Log for $username");
begin_frame("Historical IP addresses used by <a href=account-details.php?id=$userid><b>$username</b></a>");
echo $pagertop;
begin_table();
print("<tr>n
<td class=colhead><a class=colhead href="" . $_SERVER['PHP_SELF'] . "?id=$userid&order=lastused">Last used</a></td>n
<td class=colhead><a class=colhead href="" . $_SERVER['PHP_SELF'] . "?id=$userid&order=added">Added</a></td>n
<td class=colhead><a class=colhead href="" . $_SERVER['PHP_SELF'] . "?id=$userid&order=ip">IP</a></td>n
<td class=colhead>Hostname</td>n
</tr>n");
while ($arr = mysql_fetch_array($res)) {
$addr = " ";
$ipshow = "";
$ip = $arr["ip"];
$dom = @gethostbyaddr($arr["ip"]);
if ($dom == $arr["ip"] || @gethostbyname($dom) != $arr["ip"])
$addr = " ";
else
$addr = $dom;
$ipcount = get_row_count("users", "WHERE ip='$ip'");
$nip = ip2long($ip);
$bancount = get_row_count("bans", "WHERE $nip >= first AND $nip <= last");
if ($bancount == 0) {
if ($ipcount > 1)
$ipshow = "<b><a href=admin-search.php?ip=". $arr['ip'] .">" . $arr['ip'] ."</a></b>";
else
$ipshow = "<a href=admin-search.php?ip=". $arr['ip'] .">" . $arr['ip'] ."</a>";
} else
$ipshow = "<a href='/testip.php?ip=" . $arr['ip'] . "'><font color='#FF0000'><b>" . $arr['ip'] . "</b></font></a>";
print("<tr><td>".date("d/m/Y at H:i:s", sql_timestamp_to_unix_timestamp($arr["lastused"]))."</td>n");
print("<td>".date("d/m/Y at H:i:s", sql_timestamp_to_unix_timestamp($arr["added"]))."</td>n");
print("<td>$ipshow</td>n");
print("<td>$addr</td>n");
}
end_table();
echo $pagerbottom;
end_frame();
stdfoot();
?>
[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=7181"]iphistory.php[/url]