gusl: (Default)
[personal profile] gusl
< ? 
#header("Content-Type: text/html");

$handleStr = "/home/username/public_html/log.txt";

$handle = fopen($handleStr, "a");

  $ip = $_SERVER['REMOTE_ADDR'];
  $fullhost = @gethostbyaddr($ip); 

#IP address: $_SERVER['REMOTE_ADDR']
#see http://nl3.php.net/reserved.variables

if ($_SERVER['REMOTE_ADDR'] != "121.11.1.11" && $_SERVER['REMOTE_ADDR'] != "212.22.22.212") #ignore my own home hits
{                
  fwrite($handle, strftime("%d/%b/%Y %I:%M'%S %p") . " ");
  fwrite($handle, "page " . $_SERVER['PHP_SELF']);
  fwrite($handle, "     referrer: " . $_SERVER['HTTP_REFERER']);
  fwrite($handle, "\n");
  fwrite($handle, "browser=[" . $_SERVER['HTTP_USER_AGENT'] . "]");
  fwrite($handle, "\n");
  fwrite($handle, "remote_host= \"" . $_SERVER['REMOTE_HOST'] . "\"");
  fwrite($handle, "  fullhost=" . $fullhost . " (" . $ip . ")\n");
  fwrite($handle, "\n");
  fwrite($handle, "\n");
}

fclose($handle);
? >

(no subject)

Date: 2005-09-12 10:12 pm (UTC)
From: [identity profile] breyten.livejournal.com
Heh :-)

you can write the if line also as:
if (in_array($_SERVER['REMOTE_ADDR'], array(
"121.11.1.11", "other ip addy"
)) {

which makes it easier to add other ip addresses.

Also, web proxies change REMOTE_ADDR, so you might get skewed results.

(no subject)

Date: 2005-09-13 07:47 am (UTC)
From: [identity profile] peamasii.livejournal.com
If you find/enable your apache common logs and process them with a free tool like awstats or webalizer, then you'd get a better idea where your users are coming from.

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags