Log in

View Full Version : Inserting a counter...


Ksilebo
08-11-2003, 02:06 AM
I'm trying to insert a counter somewhere within my board, but cant figure out the best place to do it.

Basically, its a single line that calls a count.php file...

<?
### IMAGE FORMAT
$format = ".png";

#######################################
## (C) 2000 Total Eclipse Scripts
#
### This script is free for personal
### or commercial use.
#
# problems? scripts@tescripts.net
#######################################

$file = file("count.txt");
$num = ($file[0] + 1);
exec("echo $num > count.txt");
switch($type) {
case "text":
echo $num;
break;
case "gfx":
$i = 0;
$cntn = strlen($num);
while($i < $cntn) {
$tmpnum = substr($num, $i, 1);
echo("<img src=\"$dir/$tmpnum$format\">");
$i++;
}
break;
case "q":
break;
default:
echo("count.php <b>error</b> : type not specified.");
break;
}
?>

And the little line of code that should spit out an image is this...

$type = "gfx"; $dir = "counter"; include("count.php");

Where should I put this? I tried a few things, but couldnt get it right.

noppid
08-12-2003, 05:16 PM
Count.txt needs to be in a writable folder most likely.

Ksilebo
08-12-2003, 05:20 PM
Its writeable, but thats not the issue.

The issue is where/what file to put the code in. count.php is seperate, but where to put the include() for it.

noppid
08-13-2003, 12:45 PM
Assuming you want the counter to fire on hits to forum_home put it in the index.php. I'd put it just before the very last eval at the bottom of the file myself.

Ksilebo
08-13-2003, 12:48 PM
My index just becomes a blank page.

noppid
08-13-2003, 01:19 PM
Now that I look at the code, I see a few issues that seem to be show stoppers. The switch statement uses $type, but $type is not set.

The output would need to be intergrated into a template to display.

Ksilebo
08-13-2003, 05:20 PM
How exactly do I do that?