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.

(no subject)

Date: 2005-09-13 09:12 am (UTC)
From: [identity profile] gustavolacerda.livejournal.com
Yeah... it seems the web server should do this for me automatically. Thanks for the tips. I'm going to look up these two.

One difference, though, is that I'm interested in individual visitors. I'd like to change my signature on every email, in order to see who saw what.
http://www.optimizelife.com/index.php#peamasii130905

Then I can associate the IP with the person, and if they visit again spontaneously, that's probably a sign that they liked my site.

(no subject)

Date: 2005-09-13 09:23 am (UTC)
From: [identity profile] gustavolacerda.livejournal.com
And for those IPs that find my site without such an identifying link, and visit a lot, I want to make a message like:

hey, you seem to visit my site quite a lot. I'm now curious about who you are. What's your name?

-Gustavo


The message is easy to make with PHP, but I think I would need to create a form for them to POST, and that would kinda suck.
A JavaScript pop-up might be nicer, but that doesn't simplify anything.

(no subject)

Date: 2005-09-13 09:29 am (UTC)
From: [identity profile] peamasii.livejournal.com
It might be better to do all this with a site registration mechanism. That way you can identify visitors with a cookie, regardless what their IP is.

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