print "
<?
#========================================================================================================
# Session based counter v.0.2 by banmiklos
# Copyright ( c ) Date 2003. okt. 21., Thu, 18.20.06 CEST
# Author Banmiklos,,, <banm@kornel.zool.klte.hu>
#
# Unspecified copying policy, please contact the author
# Banmiklos,,, <banm@kornel.zool.klte.hu>
#========================================================================================================
session_start();
\$file_name = split ( \"/\", \$PHP_SELF );
\$h = count( \$file_name )-1;
\$hitfile = \"../sb_counter/\".\$file_name[\$h].\".txt\"; ## txt where the hits are stored
if ( !file_exists( \$hitfile ) ) {
print \"The file \$hitfile does not exists ...\";
if ( touch ( \$hitfile ) ) {
print \"The \$hitfile was be created!\";
}
else {
print \"Can't be create \$hitfile! ... exitting now --\";
exit;
}
}
\$fp = fopen( \$hitfile,\"r+\" ); ## file pointer
\$hits=fread( \$fp,filesize( \$hitfile ) );
## If you use more then one page with this counter, change the session variable to unique name in every one.
if( !session_is_registered( \"counter\" ) ) { ## if the session variable don't be yet
fseek( \$fp,0 );
ftruncate( \$fp,0 ); ## clear the file out
\$hits++;
fwrite( \$fp,\$hits );
session_register( \"counter\" );
}
fclose( \$fp );
## The graphical counter -------------
\$ghtis = \$hits;
\$garray = array();
while ( \$ghtis ){
\$flt = \$ghtis%10;
\$int = sprintf( \"%d\", \$ghtis/10 );
array_push( \$garray,\"\$flt\" );
\$ghtis = \$int;
}
if ( count( \$garray ) < 5 ) {
\$c = 5-count( \$garray );
for( \$i=0;\$i<\$c;\$i++ ) {
array_push( \$garray,\"0\" );
}
}
## End of graphical counter part ----
?>
<HTML>
<HEAD>
<TITLE> ..:: Session Alapú Látogatottság Számláló ::.. </TITLE>
<STYLE>
td.counter {
background: #858585;
border-right: solid thin black;
border-bottom: solid thin black;
border-top: solid thin #c0c0c0;
border-left: solid thin #c0c0c0;
}
</STYLE>
</HEAD>
<BODY>
<H1> Példa php látogatottság számláló </H1>
.
<P>
<HR> ";
if( $lang == 'en' ) {
print "
<HTML>
<HEAD>
<TITLE> ..:: Session Based Visiting counter ::.. </TITLE>
<STYLE>
td.counter {
background: #858585;
border-right: solid thin black;
border-bottom: solid thin black;
border-top: solid thin #c0c0c0;
border-left: solid thin #c0c0c0;
}
</STYLE>
</HEAD>
<BODY>
<H1> Example HTML embended php visiting counter</H1>
.
<P>
<HR>";
}
print"
<?
\$date = \"2003. mar. 42.\"; ## start time
print \"
The text version: <br>
This page was visited \$hits times since \$date <p>
Graphical version:<br>
<TABLE cellpadding=1 cellspacing=0>
<TR>
<TD>This page was visited </TD>
<TD class='counter'>
<TABLE cellpadding=0 cellspacing=1>
<TR> \";
while( \$garray ) {
\$hits = array_pop( \$garray );
print \"<TD class='counter'><img src='./counter_images/\$hits.png'></TD>\";
}
print \" </TR></TABLE></TD>
<TD> times since \$date</TD>
</TR>
</TABLE>\";
?>
<P> <BR>
</BODY>
</HTML>
";
?>