I downed a "counter.php" file and a "counter.dat" file.
when I open the it works fine. I don't know how to embed/print the counted result (number) into my mage index.htm.
following is the php file codes:
<?php
$counterFile="counter.dat";
$counterData=file($counterFile);
$sign=False;
for($i=0;$i<=count($counterData)-1;$i++)
{
$varArray=explode("|",$counterData[$i]);
if ($varArray[0]==$PATH_INFO)
{
$varArray[1]++;
print($varArray[1]);
$counterData[$i]=implode("|", $varArray);
$sign=True;
break;
}
}
$data=implode("",$counterData);
$fp=fopen($counterFile,"w");
fputs($fp,$data);
if (!$sign)
{fputs($fp,"\n$PATH_INFO"."|"."1"."|");
print("1");}
fclose($fp);
?>
I copied the codes above to the index.htm page code between <body>... </body> but it does not work.
Could anyone tell me how to make it works? I already spend 6 hours on this tiny function. I appreciate for your help.
Thanks.
when I open the it works fine. I don't know how to embed/print the counted result (number) into my mage index.htm.
following is the php file codes:
<?php
$counterFile="counter.dat";
$counterData=file($counterFile);
$sign=False;
for($i=0;$i<=count($counterData)-1;$i++)
{
$varArray=explode("|",$counterData[$i]);
if ($varArray[0]==$PATH_INFO)
{
$varArray[1]++;
print($varArray[1]);
$counterData[$i]=implode("|", $varArray);
$sign=True;
break;
}
}
$data=implode("",$counterData);
$fp=fopen($counterFile,"w");
fputs($fp,$data);
if (!$sign)
{fputs($fp,"\n$PATH_INFO"."|"."1"."|");
print("1");}
fclose($fp);
?>
I copied the codes above to the index.htm page code between <body>... </body> but it does not work.
Could anyone tell me how to make it works? I already spend 6 hours on this tiny function. I appreciate for your help.
Thanks.