Location: PHPKode > scripts > Style-7 > counter/counter_graphic.php
<?php

#global $filter = array( "BOT", "SPIDER", "CRAWLER"); #roBOT

function IsRobot(){
	$filter = array( "BOT", "SPIDER", "CRAWLER", "SCOUT"); #roBOT	#include your own key words
	$agent007 = StrToUpper( $_SERVER['HTTP_USER_AGENT'] );
        $countValues = Count( $filter );
        for( $i = 0; $i < $countValues; $i++ ){
        	if( strpos( $agent007, $filter[$i] ) != false){
                	return true;
                }
        }
        return false;
}

function Counter( $filename, $zeroPadding){

	$file = fopen( $filename, "r+" );
	if( $file ){
		if( flock( $file, LOCK_EX ) ){
			$counter = fread( $file, 10 );
			$counter++;
			ftruncate( $file, 0 );
	                rewind( $file );
			fwrite( $file, $counter );
	                fflush( $file );
			flock( $file, LOCK_UN );
			fclose( $file );
			if( $zeroPadding ){
		        	$counter = sprintf( "%0".$zeroPadding."s", $counter);
		        }
	                return $counter;
	        }
	}
        return 0;
}

function CounterText( $counter){
	echo $counter;
}

function CounterImage( $counter, $pathToImages, $extensionImage){
    $len = StrLen( $counter );
    $pathLocal = "0.".$extensionImage;
    $size = GetImageSize( $pathLocal );		#all images are equal
    for( $i = 0; $i < $len; $i++ ){
    	$num = SubStr( $counter, $i, 1);
	echo "<IMG SRC = '".$pathToImages.$num.".".$extensionImage."' WIDTH='".$size[0]."' HEIGHT='".$size[1]."' BORDER = '0' ALT = '".$num."'>";
    }
}

if( IsRobot() == true){	# !
	return;
}

# common parameters
$filename = "../../counter/counter.txt";
$zeroPadding = 7;	# zero for off

#only for image counter
$pathToImages = "/counter/";
$extensionImage = "png";

$counter = Counter( $filename, $zeroPadding);

CounterImage( $counter, $pathToImages, $extensionImage );
?>

Return current item: Style-7