View Full Version : IP Log
06-09-2007, 02:47 PM
Ive made ip logger for my site. Is there anyway to make it so that it only logs the same ip once a day e.g. 188.8.131.52 so that it doesnt apper in the log more than once? Also i was looking to make it so it only displays 25 ip's on a page and when 25 ip's are logged it automaticly creates a new page.
06-09-2007, 03:11 PM
I'm assuming you're using a database?
If so, to only log one IP per day
//assumes you're already connected to the database
$ip = $_SERVER['REMOTE_ADDR'];
//This assumes you have a variable with todays date named $date
$query = "SELECT * FROM `table` WHERE `date_inserted` = $date AND `ip` = $ip";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
//There is already an IP from today in the database
$addip = false;
$addip = true;
$query = "INSERT INTO `table`(columns here) VALUES (values here)";
Using a database, you only need one page to display all the IPs. You can limit the number shown by only withdrawing 25 IPs at a time. Using a $_GET var, the page can figure out which set of results to pull from the database:
http://www.mysite.com/showips.php -- shows IPs 1-25
http://www.mysite.com/showips.php?page=2 -- shows IPs 26-50
http://www.mysite.com/showips.php?page=3 -- shows IPs 51-75
06-09-2007, 03:16 PM
thanks ill give it a try :D
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.