ok HER KOMMER MIT COUNTER SCRIPT
#!/usr/bin/php
<?
#Simple Hit Counter, Copyright 2000 s@shat.net
http://shat.net/php/#This script may be FREELY DISTRIBUTED as long as all headers are kept
#intact, and no fee is charged.
#This text-based counter script will keep track of the number of hits
#to a web page. You can use it on multiple pages. For each page, this
#script will create a unique log file to track the number of visitors.
#Don\'t worry, each log file is very tiny, between 1 and 10 bytes.
#How to use the hit counter:
#Call the script as you would call a normal SSI,
#<!--#exec cgi=\"/path/to/count.php\"-->
#This won\'t work if your server doesn\'t recognize .php as executable.
#Or, you can call it from within a PHP document, using the PHP command
#include(\'/path/to/count.php\')
# You\'ll need to modify a couple of the variables below:
#$datadir is the directory where the counter log files will be kept.
#You should probably make this a dedicated directory, because a log
#file will be created for each page on which you\'re using this script.
#This needs to be the full system path to your data directory, including
#the trailing slash. This directory MUST EXIST with 755 permissions in
#order for the script to function.
$datadir = \"/home/shat/public_html/shaun/00/counters/\";
#If $snoop is set to 1, the counter will also keep a log of each visitor\'s
#IP address, browser type/version, and referring URL if available.
#The snoop logs are kept in the same directory as the counter logs.
#Watch out, if you have a high-traffic site, these logs grow fast.
$snoop = 1;
###################################################################
# DO NOT EDIT BELOW THIS LINE, unless you know what you\'re doing! #
###################################################################
#
#do_snoop() records the IP address, browser type, and referring
#URL of the visitor, if $snoop is set to 1.
#
function do_snoop($datadir,$REMOTE_ADDR,$HTTP_USER_AGENT,$HTTP_REFERER,$REQUEST_URI)
{
$filename = str_replace(\"/\",\"_\",$REQUEST_URI);
if ( (substr($filename, -1)) == \"_\" )
$filename .= \"index\";
$date = date(\"m/d/Y h:i:s A\");
$logfile = fopen(\"$datadir\" . \"$filename\" . \"-info.txt\", \"a+\");
fputs(\"$logfile\", $date . \"\\t\" . $REMOTE_ADDR . \"\\t\" . $HTTP_USER_AGENT . \"\\t \" . $HTTP_REFERER . \"\\n\");
fclose($logfile);
}
#MAIN PROGRAM CODE BEGINS HERE
#Get the name of the page being viewed, apache should send
#this through REQUEST_URI. The file name is then unslashed
#(the clean version is used in the name of the log file).
$filename = str_replace(\"/\",\"_\",$REQUEST_URI);
if ( (substr($filename, -1)) == \"_\" )
$filename .= \"index\";
#Check to see if a counter log already exists for this page
$filetest = file_exists( \"$datadir\" . \"$filename\");
if (!$filetest)
{
# If there\'s not a log file for this page, try to create one
$logfile = fopen( \"$datadir\" . \"$filename\", \"w\");
if (!$logfile)
exit;
else
{
$count += 1; # increment count from 0 to 1
fputs(\"$logfile\", $count); # write count to log file
fclose(\"$logfile\");
exit;
}
}
else
#If a log file is already present, read the current count
$logfile = fopen(\"$datadir\" . \"$filename\", \"r+\");
if (!$logfile)
exit;
else
{
$count = fgets(\"$logfile\", 8);
if (!$count)
exit;
else
{
$count += 1; #increment the count by 1
#This is where the script will send the count to the calling web page,
#if it\'s working properly. If you want to give the counter a consistent
#look across all your pages, you can edit the following echo statement,
#and add HTML tags before and after the variable name. For example:
#echo \"<font face=\\\"verdana\\\" size=2 color=\\\"#000000\\\"> $count </font>\";
echo \"$count\";
fseek(\"$logfile\", 0); #go to beginning of log
fputs(\"$logfile\", $count); #replace old count with new one
fclose($logfile); #close log file
}
}
#Snoop the visitor, if we want to
if ($snoop==1) do_snoop($datadir,$REMOTE_ADDR,$HTTP_USER_AGENT,$HTTP_REFERER,$REQUEST_URI);
#And we\'re done!
exit;
?>
KAN DET HJÆLP LIDT PÅ DET