all is well so far, just little hicups... one being..
i have a .pl script that logs ip/host time and date etc...

i have changed the includes and it is functioning (ie, no 500 errors)
but it is logging the server i am being hosted on

[ Time: Tuesday May 04, 2010, 09:09:19 PM ] - [ With: PHP/5.2.12 ]
[ Host: 74.81.xx.xxx/server3r.xxxxxx.net ] [ From: ]
[ Pages: ]

when normally it will be (with the index.shtml page)

[ Time: Monday May 03, 2010, 09:30:46 PM ] - [ With: Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; Trident/4.0; GTB) ]
[ Host: 64.12.xxx.xx/cache-mtc.xxx.xxx.com ] [ From: http://search.aol.com/aol/search?s_it=wscreen-searchboxhtml&q=xxxxxxxx]
[ Pages: ]

$_SERVER['REMOTE_ADDR'];
$ENV{'REMOTE_HOST'};

i see that PHP uses the $_server var, whereas pl uses the $env

i have tried changing them around.. but to no avail...

i have:

if (!$ENV{'REMOTE_HOST'}) {my @subnet_numbers = split (/\./, $_SERVER['REMOTE_ADDR']);
$ENV{'REMOTE_HOST'} = gethostbyaddr(pack("C4", @subnet_numbers), 2) || $_SERVER['REMOTE_ADDR'];
	}

$ippjrey = $_SERVER['REMOTE_ADDR'];
$hostpjrey = $ENV{'REMOTE_HOST'};

thanks for taking time to read this!
pj

Recommended Answers

All 6 Replies

<?php
 /* stats.php 
 creates csv text file that can be 
 imported into excell or other spreadsheet
text file format can be made to match whatever in the fput() line
 requires file 'log.csv' or whatever,, chmod writable in subfolder 'logfiles' 
filenames can be altered in the line defining $file. 
 can be an include() or just a paragraph in a php file
 none of the notes are necessary for function
 A lot more information is available, 
 see php.net $_server[] documentation */
$getdate = date( 'd-m-Y H:i:s' ); //Get the datetime.
$user_ip = $_SERVER['REMOTE_ADDR']; //Get the IP
$userhost=gethostbyaddr( $user_ip ); //get host
$user_browser = $_SERVER['HTTP_USER_AGENT']; //Get the browser type.
$referer = $_server["HTTP_REFERER"]; //Get the refering page.
$file = "logfiles/log.csv"; //define the text file.
$fp = fopen($file, "a+"); //define open the text file for writing.
fputs ($fp, "$user_ip,$userhost,$getdate,$referer,$user_browser\n"); //Write the user stats into the text file.
fclose($fp); // Close the text file. */
?>

something similar?
if ran as an include [pages] is an iteration of $_SERVER

looks perfect, thanks again! man you're helpful!
how should i call it?

<?php include("logger_script.php"); ?>

thanks
pj

ok, got that going... just curious how i go about formatting the LOG file (creating links for the referrals, different colors for the host/IP (i did this with cgi just fine... with a

print "Content-type: text/html\n\n";
   open (LOG, ">$log");
    print LOG " [ <a class=smtxt><B>Time:</B> $getdate  etc....

this PHP is a whole new world..
i like it!

pj

the default as described creates a comma separated file
php has csv handling functions fget(csv) http://ca2.php.net/manual/en/function.fgetcsv.php to let you read and handle the log file
I cheat somewhat, open the csv file in excell

Before you waste too much time, look at bbclone demo page
it seems exactly what you want, page hits, all sorts of different views
resolves hostname, country flags, selectable columns for justabout everything,, the demo page does not show all the columns available

I dont make a kickback from them, its free

thanks again, got bbclone up and running.. very nice, thanks for the link.
im still curious how to write custom css etc to the php log script you posted earlier in this thread... i dont know what is allowed and what isnt.. (i got that working as well, but it is just plain text, each log gets its own line (perfect, just want to change size, color, and create links for referrals.. thanks again!
pj

when reading the file with fgetcsv() an array is created of each line
$arrayline=fgetcsv(blabla);
given that there are 9 columns in the csv

$arrayline =array fgetcsv ( fopen('logfile.csv','r'));  
while($arrayline !==FALSE) { echo "anyhtmlcodeformatting"
.$arrayline[0]
."anyhtmlcodeformatting"
.$arrayline[1]
."anyhtmlcodeformatting"
.$arrayline[2]
."anyhtmlcodeformatting"
.$arrayline[3]
."anyhtmlcodeformatting"
.$arrayline[4]
."anyhtmlcodeformatting"
.$arrayline[5]
."anyhtmlcodeformatting"
.$arrayline[6]
."anyhtmlcodeformatting"
.$arrayline[7]
."anyhtmlcodeformatting"
.$arrayline[8]."</endofhtml><br>"; }

where anyhtmlformatting can be quite literally any html code,

not proper code, not checked at all, a thought process

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.