[Looking for a script.] -



Looking for a script.

Discuss Looking for a script.



Posted by: U.n.c.u.T.!

Hello all,

I'm looking for a PHP script that can detect IP, host, and name, if possible, and write it to a .txt or .log file. If you know of something, please tell.

Uncut



Posted by: shan

Here's something simple
make sure to create a data.log file on your webserver and chmod it to something like 666 to give sufficient privlages to write to the file....
[PHP]
<?php
$this = $HTTP_USER_AGENT;
$that = $REMOTE_ADDR;
$host = gethostbyaddr($that);

$file = "data.log";
$open = fopen($file, a);
fwrite($open, "$this\n$that\n$host\n\n");
fclose($open);
?>[/PHP]
hope this works for you



Posted by: shan

The data.log file will look something like this....

[code]

Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U; ) Gecko/20030131
11.111.11.11 <-- Ip address
11-111-11-11.client.attbi.com <-- Hostname

Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U; ) Gecko/20030131
11.111.11.11
11-111-11-11.client.attbi.com[/code]

on a side note, this log will go everytime the page is loaded, it doesn't check unique visitors. If you wanted something like that you could dump most of that into a SQL database...that would be a more involved script though ;) Good luck...

~Shan



Posted by: shan

you might know this already but just for the **** of it...don't forget to

[PHP]
<? include 'filename.php' ?>
[/php]



Posted by:

[QUOTE][i]Originally posted by shan [/i]
[B]Here's something simple
make sure to create a data.log file on your webserver and chmod it to something like 666 to give sufficient privlages to write to the file....
[/B][/QUOTE]

You might want to chmod it to 777 for writing permissions ;)