I've made an IP Logger:
Heres the page that logs it:
http://dframe.t35.com/iplogger/test.php
Then click the ADMIN SECTION link, then click VIEW IPS in the menu. IT will display them with the date aswell. Now what i wanna know is how would i get it to display the numbers to the left of it?
[EXAMPLE]
1 November 2nd 2003 123.456.7.8
2 November 2nd 2003 123.456.7.8
3 November 2nd 2003 123.456.7.8
4 November 3rd 2003 123.456.7.8
5 November 3rd 2003 123.456.7.8
6 November 3rd 2003 123.456.7.8
7 November 4th 2003 123.456.7.8
[/EXAMPLE]
IP Logger
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Woops forgot, sorry 
Code thats loggin and sending to logs.txt
Code thats loggin and sending to logs.txt
Code: Select all
<?
$iplog="ips.txt";
$TestLog=fopen($iplog,"r");
fclose($TestLog);
$Date=date("F j, Y");
$IP=$HTTP_SERVER_VARS["REMOTE_ADDR"];
$Logging="<tr valign="top">
<td width="50%"><font face="Verdana" size="1">$Date</font></td>
<td width="50%"><font face="Verdana" size="1">$IP</font></td>
</tr>";
$Post = fopen("$iplog","a");
fputs($Post,$Logging);
fclose($Post);
?>- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Give it a try:
See more info on [php_man]file[/php_man] and count
Tis may cause your server to speed dow due to the possibility of the ips.txt file becomes very very large. So keep cleaning it from time to time... Or implement a counter in a separate file to keep track of the access number.
Hope that helps. Tchau,
Scorphus.
Code: Select all
<?php
$iplog="ips.txt";
$TestLog=fopen($iplog,"r");
fclose($TestLog);
$nextLine = count(file($iplog)) + 1;
$Date=date("F j, Y");
$IP=$HTTP_SERVER_VARS["REMOTE_ADDR"];
$Logging="<tr valign="top"><td width="10%"><font face="Verdana" size="1">$nextLine</font></td><td width="40%"><font face="Verdana" size="1">$Date</font></td><td width="50%"><font face="Verdana" size="1">$IP</font></td></tr>\n";
$Post = fopen("$iplog","a");
fputs($Post,$Logging);
fclose($Post);
?>Tis may cause your server to speed dow due to the possibility of the ips.txt file becomes very very large. So keep cleaning it from time to time... Or implement a counter in a separate file to keep track of the access number.
Hope that helps. Tchau,
Scorphus.
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
You could write a dellogs.php:
and make your delete button (<a href="dellogs.php"><img src="button.jpg"></a>) to do the job.
Hope that helps your understanding!
Cheers,
Scorphus.
Code: Select all
<?php
/* This script creates a backup copy of ips.txt and creates a new empty ips.txt
* It deletes a backup file ips.txt.bak if it exists
* It copy the current ips.txt to a new ips.txt.bak
* And then creates a new ips.txt
*/
$iplog="ips.txt";
// Checks if ips.txt.bak exists and attempts to delete it
if (file_exists($iplog.'.bak') && !unlink($iplog.'.bak')) {
print ("failed to delete $iplog.bak...<br>\n");
}
// Attempts to copy ips.txt to ips.txt.bak
if (!copy($iplog, $iplog.'.bak')) {
print ("failed to copy $iplog to $iplog.bak...<br>\n");
}
// Attempts to create a new ips.txt
$TestLog = @fopen($iplog, "w");
if (!$TestLog) {
print ("failed to create new $iplog...<br>\n");
}
fclose($TestLog);
?>Hope that helps your understanding!
Cheers,
Scorphus.