Jump to content

PHP ip logger


Blackwar

Recommended Posts

Hey,

i just wrote a small script that allows you to log access to your site ( as long as main page is php-based)

here is a screenshot of how it logs the ips : http://blackwar2.netfirms.com/iplogger.jpg

If you just want the php script:

the code is ,

<?php
$date  = date("F d , l , Y - H:i:s");
$fp = fopen("D:/localhost/log/ip.txt", "a+");
$host = gethostbyaddr("$REMOTE_ADDR");
$dns = gethostbyname ($host);
$log = "At $date , \n \n * Host: $host , \n \n * IP: $dns ,\n \n * Browser: $HTTP_USER_AGENT";
@fwrite($fp, "$log \n\n ----------------------------------------------------------------------------------- \n\n");
@fclose($fp);
?>

change the $fp = fopen("D:/localhost/log/ip.txt", "a+"); value to the exact path of your text file.

If you just want to restrict access to everyone, like i do on my local server, and tell them that their ip is logged, and to log their ip, use this code :

<?php
$date  = date("F d , l , Y - H:i:s");
$fp = fopen("D:/localhost/log/ip.txt", "a+");
$host = gethostbyaddr("$REMOTE_ADDR");
$dns = gethostbyname ($host);
$log = "At $date , \n \n * Host: $host , \n \n * IP: $dns ,\n \n * Browser: $HTTP_USER_AGENT";
@fwrite($fp, "$log \n\n ----------------------------------------------------------------------------------- \n\n");
@fclose($fp);
?>
<html>
<head>
<title>Blackwar's private server</title>
</head>
<body>
<font face="Verdana"><i>Your IP has been logged,
<br>
<br>
If you get out now, no action will be taken against you. This is a private server and you are not allowed in here.
<br>
<br>
<p align="right"> --Blackwar</p>
</i>
</font>
</body>
</html>

change the $fp = fopen("D:/localhost/log/ip.txt", "a+"); value to the exact path of your text file. Also edit the other html values as you want which are currently set as my example to show you where to put what :)

Enjoy,

Blackwar

Link to comment
Share on other sites


you are getting more into php than i blackwar, i have a few books and stuff, but im lazy as hell lol

nice tools there  :rolleyes:

Thanks man :D

I am trying to write something larger with php but i couldn't succeed so far.. I can't see how they did boards like invision from scratch with PHP :) It is just too much work

maybe my next php code will exceed 10 lines :D

Link to comment
Share on other sites

i built a few web pages using php and html. the sites now down tho as it was at F2S.

all it was is parts of the page where randomly delivered, so with about 6 or more sections on the page being random (well, i would make about 6 variants for each section) the site would look different each time you visit.

its only what CNN and similar sites do, so that you think its updated the news when really it hasnt, they cookie you though, so the page will stay the same for the next X amount of hours and/or X amount of visits.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...