Bravo List
Register
Go Back   > Bravo List > Source Code > Active Trackers > Torrent Trader > Mods & Themes
Reply
  #1  
Old 3rd September 2008, 02:27
Grom's Avatar
Grom Grom is offline
Senior Member
 
Join Date: Aug 2008
Posts: 73
Smile IP History
IP History
Add in msql
PHP Code:
CREATE TABLE `iplog` (
`
idint(10unsigned NOT NULL auto_increment,
`
ipvarchar(15collate latin1_bin NOT NULL default '',
`
useridint(10unsigned NOT NULL default '0',
`
addeddatetime NOT NULL default '0000-00-00 00:00:00',
`
lastuseddatetime NOT NULL default '0000-00-00 00:00:00',
`
timesusedint(10NOT NULL default '1',
PRIMARY KEY (`id`),
UNIQUE KEY `ip_userid` (`ip`,`userid`),
KEY `userid` (`userid`),
KEY `ip` (`ip`)
ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
account-login.php, find:
PHP Code:
logincookie($row["id"], $row["password"], hash_pad($row["secret"], 20)); 
add after:
PHP Code:
$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:
PHP Code:
begin_frame("Staff Only Information"); 
Add after
PHP Code:
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:
PHP Code:
$GLOBALS["CURUSER"] = $row
Add before
PHP Code:
$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'");

find code in account-details.php
PHP Code:
print("<tr><td>IP Adress</td><td align=left><input type=text size=20 name=ip value=\"$user[ip]\"></tr>\n"); 
Add after code
PHP Code:
if (get_user_class() >= 5) {
$resip mysql_query("SELECT ip FROM iplog WHERE userid =$id GROUP BY ip") or sqlerr(__FILE____LINE__);
$iphistory mysql_num_rows($resip);

if (
$iphistory 0)
print(
"<tr><td class=rowhead>IP History</td><td align=left>This user has earlier used <b><br><a href=iphistory.php?id=" $user['id'] . ">" $iphistory" different IP addresses</a></b></td></tr>\n");

And add iphistory.php in your root site
iphistory.php
[PHP]IP History
Add in msql
PHP Code:
CREATE TABLE `iplog` (
`
idint(10unsigned NOT NULL auto_increment,
`
ipvarchar(15collate latin1_bin NOT NULL default '',
`
useridint(10unsigned NOT NULL default '0',
`
addeddatetime NOT NULL default '0000-00-00 00:00:00',
`
lastuseddatetime NOT NULL default '0000-00-00 00:00:00',
`
timesusedint(10NOT NULL default '1',
PRIMARY KEY (`id`),
UNIQUE KEY `ip_userid` (`ip`,`userid`),
KEY `userid` (`userid`),
KEY `ip` (`ip`)
ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
account-login.php, find:
PHP Code:
logincookie($row["id"], $row["password"], hash_pad($row["secret"], 20)); 
add after:
PHP Code:
$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:
PHP Code:
begin_frame("Staff Only Information"); 
Add after
PHP Code:
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:
PHP Code:
$GLOBALS["CURUSER"] = $row
Add before
PHP Code:
$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'");

find code in account-details.php
PHP Code:
print("<tr><td>IP Adress</td><td align=left><input type=text size=20 name=ip value=\"$user[ip]\"></tr>\n"); 
Add after code
PHP Code:
if (get_user_class() >= 5) {
$resip mysql_query("SELECT ip FROM iplog WHERE userid =$id GROUP BY ip") or sqlerr(__FILE____LINE__);
$iphistory mysql_num_rows($resip);

if (
$iphistory 0)
print(
"<tr><td class=rowhead>IP History</td><td align=left>This user has earlier used <b><br><a href=iphistory.php?id=" $user['id'] . ">" $iphistory" different IP addresses</a></b></td></tr>\n");

And add iphistory.php in your root site
iphistory.php
PHP Code:
<?
require "backend/functions.php";
dbconn(false);
loggedinonly();

if (
get_user_class() < 5)
show_error_msg("Error""No Access");


$userid $_GET["id"];
if (!
is_valid_id($userid)) show_error_msg("Error""Invalid ID");

$res mysql_query("SELECT username FROM users WHERE id = $userid") or sqlerr(__FILE____LINE__);
if (
mysql_num_rows($res) == 0)
show_error_msg("Error""User not found");

$arr mysql_fetch_array($res);
$username $arr["username"];

$page $_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&");


if (
$order == "ip")
$orderby "ip DESC, access";
else
$orderby "access";

$query "SELECT u.id, u.ip AS ip, last_access AS access FROM users as u WHERE u.id = $userid
UNION SELECT u.id, iplog.ip as ip, iplog.access as access FROM users AS u
RIGHT JOIN iplog on u.id = iplog.userid WHERE u.id = 
$userid ORDER BY $orderby $limit";

$res mysql_query($query) or sqlerr(__FILE____LINE__);

stdhead("IP History Log for $username");

begin_frame("Historical IP addresses used by <a href=account-details.php?id=$userid><b>$username</b></a>"True);

echo 
$pagertop;

begin_table();
print(
"<tr>\n
<td class=colhead><a class=colhead href=\"" 
$_SERVER['PHP_SELF'] . "?id=$userid&order=access\">Last access</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 "";
if (
$arr["ip"])
{
$ip $arr["ip"];
$dom = @gethostbyaddr($arr["ip"]);
if (
$dom == $arr["ip"] || @gethostbyname($dom) != $arr["ip"])
$addr "";
else
$addr $dom;
$resip mysql_query("SELECT count(ip) as count FROM users WHERE ip = " sqlesc($ip) ."");
$arrip mysql_fetch_row($resip);
$ipcount $arrip[0];

$nip ip2long($ip);
$banres mysql_query("SELECT COUNT(*) FROM bans WHERE $nip >= first AND $nip <= last") or sqlerr(__FILE____LINE__);
$banarr mysql_fetch_row($banres);
if (
$banarr[0] == 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>";
}
$date get_date_time(sql_timestamp_to_unix_timestamp($arr["access"]) , $CURUSER[tzoffset] );
print(
"<tr><td>$date</td>\n");
print(
"<td>$ipshow</td>\n");
print(
"<td>$addr</td>\n");
}

end_table();

echo 
$pagerbottom;



end_frame();
stdfoot();
?>
Reply With Quote
The Following 2 Users Say Thank You to Grom For This Useful Post:
BamBam0077 (19th January 2022), Legend2000 (30th May 2012)
Reply

Tags
history , ip

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
History Shoutbox xxx2008 Free Torrent Source 0 18th January 2010 13:06
Shoutbox history marirds TBDev 1 6th June 2009 00:06



All times are GMT +2. The time now is 04:13. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.