<?php
$myFile = "testFile.txt";
$ip = $_SERVER['REMOTE_ADDR'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$ref = $_SERVER['HTTP_REFERER'];
$stringData = $agent . " - " . $ip . " - " . $ref . "\n";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, $stringData);
fclose($fh);
?>
Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0 - 174.125.36.177 -
This should get you started at least -
Code:<?php $myFile = "testFile.txt"; $ip = $_SERVER['REMOTE_ADDR']; $agent = $_SERVER['HTTP_USER_AGENT']; $ref = $_SERVER['HTTP_REFERER']; $stringData = $agent . " - " . $ip . " - " . $ref . "\n"; $fh = fopen($myFile, 'a') or die("can't open file"); fwrite($fh, $stringData); fclose($fh); ?>
Output will look something like this -
Code:Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0 - 174.125.36.177 -
Note that the $ref variable will be empty if you go to the page directly, so there should be some information behind the last "-".
HTH
ND
I would advise using a database (SQL) instead of a text file. Just slightly modify the code given above. Beware this file can get pretty big if your website gets a lot of traffic.
Hi guys, I basically want to upload a PHP script to my server that will give me this info for every single person/bot that lands on that page:
user agent, IP address, and referrer.
Any suggestions??
This is a horrible suggestion! Sorry, but I'm not looking for newb advice.add google analytics to your site!![]()
This is a horrible suggestion! Sorry, but I'm not looking for newb advice.
Thanks for all the other info on this thread, though, I think that script will work just fine for my needs. Yeah, db is better, but I'm just using this to check the hits I'm getting and then shutting off traffic after maybe 100 visitors. I might log more visitors later, but just wanted something simple like this.
Newb advice?
Google analytics is problaby one of the most detailed and best solutions out there to keep track of your visitors.
Why am I even wasting my time on this issue? Like I said, you're clearly a newb. First of all, I don't want google knowing shit about my site. Secondly, google analytics doesn't give you numbers on everyone who visits your site. I want to know every bot or spider that crawls my site as well as people who don't have javascript. Many people use javascript blockers so those people won't be reported on your site.Newb advice?
Google analytics is problaby one of the most detailed and best solutions out there to keep track of your visitors. There is also awstats wich could easily be installed on your server, if you have control over it ofcourse.
why reinvent the weel? Why waste time programming something thats already made and as good as it could get when it comes to stats?
It's totally upto you, but I don't think I'm the "newb" here if you actually have to ask how to make your own statistics script.. I could make that with a blindfold covering my eyes.
Good luck