Files:
image file: 0.gif - 9.gif. 0.gif for 0.
create folder ani, for image file 0.gif - 9.gif. but, but every value added 1, 0.gif to for 1. then 9.gif for 0.
acount.txt: visitor counter record. default: 0.
config.xml: module configuration file.
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>count</name>
<displayName>Counter Visitor</displayName>
<version>1</version>
<description>Counter Visitor.</description>
<author>Mr. Lent</author>
<tab>front_office_features</tab>
<is_configurable>0</is_configurable>
<need_instance>1</need_instance>
</module>
count.php: coding for module.
<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
define('COUNT_MAX_LEVEL', 3);
class Count extends Module
{
function __construct()
{
$this->name = 'count';
$this->tab = 'front_office_features';
$this->version = 1.0;
$this->author = 'Mr. Lent';
parent::__construct();
$this->displayName = $this->l('Counter Visitor');
$this->description = $this->l('Counter Visitor.');
}
function hookLeftColumn($params)
{
$img = "modules/count/";
$animated_img = "modules/count/ani/";
$padding = 6;
$width = 16;
$height = 22;
$fpt = "modules/count/acount.txt";
$lock_ip =0;
$ip_lock_timeout =30;
$fpt_ip = "modules/count/ip.txt";
$this->_html .='<div id="count_block_left" class="block count_block">';
$this->_html .= '<h4>'.$this->displayName.'</h4>
<p class="block_content" align="center">
';
if (!file_exists($fpt))
{
$count_dat = fopen($fpt,"w+");
$digits = 0;
fwrite($count_dat,$digits);
fclose($count_dat);
}
else
{
$line = file($fpt);
$digits = $line[0];
if ($lock_ip==0 || ($lock_ip==1 && checkIP($REMOTE_ADDR)==0))
{
$count_dat = fopen($fpt,"r+");
$digits++;
fwrite($count_dat,$digits);
fclose($count_dat);
}
}
$digits = sprintf ("%0".$padding."d",$digits);
$ani_digits = sprintf ("%0".$padding."d",$digits+1);
$this->_html .= 'Visitor Counter: <br>';
$length_digits = strlen($digits);
for ($i=0; $i < $length_digits; $i++) {
if (substr("$digits",$i,1) == substr("$ani_digits",$i,1)) {
$digit_pos = substr("$digits",$i,1);
$this->_html .= ('<img src=modules/count/'.$digit_pos.'.gif width=$width height=$height>');
}
else {
$digit_pos = substr("$ani_digits",$i,1);
$this->_html .= ('<img src=modules/count/ani/'.$digit_pos.'.gif width=$width height=$height>');
}
}
$this->_html .= '';
$this->_html .='<br>
Since September 1, 2011
</p>
</div>
';
return $this->_html;
}
function checkIP($rem_addr)
{
global $fpt_ip,$ip_lock_timeout;
$ip_array = file($fpt_ip);
$reload_dat = fopen($fpt_ip,"w");
$this_time = time();
for ($i=0; $i<sizeof($ip_array); $i++)
{
list($ip_addr,$time_stamp) = split("|",$ip_array[$i]);
if ($this_time < ($time_stamp+60*$ip_lock_timeout))
{
if ($ip_addr == $rem_addr)
{
$found=1;
}
else
{
fwrite($reload_dat,"$ip_addr|$time_stamp");
}
}
}
fwrite($reload_dat,"$rem_addr|$this_timen");
fclose($reload_dat);
return ($found==1) ? 1 : 0;
}
function hookRightColumn($params)
{
return $this->hookLeftColumn($params);
}
}
?>
ip.txt: IP Address record. default: Zero file