<?
$pagecount=0;
// read from existing file in php-bin/counters/ named filename.ext.count
$counterfile=$DOCUMENT_ROOT . "/php-bin/counters" . $PHP_SELF . ".count";
if(!$fp=fopen($counterfile,"r+")):
echo "Unable to open $counterfilen";
else:
$pagecount=intval(fgets($fp,10));
$pagecount++;
rewind($fp);
fputs($fp,strval($pagecount));
fclose($fp);
endif; $time=time();
// connect to postgresql if(!$linkid = pg_pconnect("", "", "", "", "my.postgresql.db")):
echo "PGSQL ERROR: ".pg_errormessage();
endif;
// stuff data in table if(!pg_exec($linkid,"insert into mylog (stamp,doc,hostname,browser,referer) values ($time,'$REQUEST_URI','$REMOTE_HOST','$HTTP_USER_AGENT','$HTTP_REFERER')")):
echo "PGSQL ERROR: ".pg_errormessage();
endif;
// output the count anywhere on the page if($pagecount): echo $pagecount; endif; ?>
|
|