Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[ADDON] IP History
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2008-07-13 11:29:39
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 = "&nbsp;";
$ipshow = "";
$ip = $arr["ip"];
$dom = @gethostbyaddr($arr["ip"]);
if ($dom == $arr["ip"] || @gethostbyname($dom) != $arr["ip"])
$addr = "&nbsp;";
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]
iplog.PNG
iplog.PNG
iphistory.php
Download
Unknown User
2008-10-27 14:19:26
i need help to delete in ip history table, all ip more old of 15 days..

i would insert in cleanup.php a similar code:

mysql_query("DELETE FROM iplog WHERE lastused >= 1296000");


can you help me to find a correct syntax to indicate "lastused >= 15 days" ?

thanx
Unknown User
2008-10-29 17:54:25
mysql_query("DELETE FROM iplog WHERE lastused <= FROM_UNIXTIME(".(gmtime() - 1209600).")");
Unknown User
2008-11-08 11:39:53
Just a small tweak to TSes mod that I find useful.

Adds a list of other users using the same IP address.

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><td class='ttable_head'>Other Users</td></tr>";

$x = 1;

while($row=mysql_fetch_assoc($res)) {

//Find tother users with the same IP

$res2 = mysql_query("SELECT users.id AS id,users.username as username FROM users INNER JOIN iplog ON (iplog.ip = '$row[ip]' AND users.id=iplog.userid AND users.id<>$id)");

$usersSame="";

while($userrow=mysql_fetch_assoc($res2)) {

$usersSame .= "<a href='account-details.php?id=$userrow[id]'>$userrow[username]</a>,&nbsp;";

}

//display table

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><td>$usersSame</td></tr>";

if ($x == 1)

$x = 2;

else

$x = 1;

}

unset($x);



echo "</table>";

end_frame();
Unknown User
2008-11-12 21:55:00
"TheUnknown, post: 48909":
Hello,
I'm having a problem.

I can't go directly into iphistory.php, it comes up blank and in account-details no IPs are being added or shown.
if you go directly to iphistory.php it requires a user id e.g.

iphistory.php?id=1

As for none shown in account details. Maybe they haven't logged in since you created the table.

TSes mod works wonderfully for me.
Unknown User
2009-04-06 14:22:13
Brilliant Mod- Lovely-   ;)   Works a treat in tt2.05

Thanks again

Kardklub
Unknown User
2009-04-09 22:24:56
Thanks, works fine ;)
Unknown User
2009-04-28 16:15:53
Works fine

Thank you all :)
Unknown User
2009-09-11 23:14:01
Is it possible to make a webpage with a COUNT to know how many differents IP are on same account, and order them by number descend ?

So it would be nice to know how many people use the same account and to find them fastly.

thanks ;)
Unknown User
2010-04-22 15:41:52
Thanks working fine .. for v2.6
Unknown User
2010-10-28 12:01:08
Thanks for this!
Unknown User
2011-01-13 17:52:33
it's possible to add hostname column in this mod?

thx
Unknown User
2011-09-23 13:43:08
Bonjour a tous

Possible d'avoir un scripts un historique tk quand un membres clik sur un film ou une page suur le site et le staff le vois svp merci a tous

Hello all

Possible to have a history tk scripts when a member clik on a film or a page suur the site and the staff see it please thank you to all
Unknown User
2012-04-09 19:05:14
Nice, works in 2.08 as well :)
Unknown User
2013-03-06 01:08:02
Is this php have banned ip b/c I got banned from my own site lmfao can we make the php only show ip history on account-details nothing else to need it for v2.8
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728