Friday, September 23, 2011

Counter Module Prestashop




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

Reaksi:

13 komentar:

Anonymous said...

can you share this modules for everyone ?

muis arghiansyach gp said...

ok.....
i upload that file in:

http://www.ziddu.com/download/17451399/count.zip.html

Anonymous said...

The module did not show any output in the front end...

Anonymous said...

It's not working in my version

muis arghiansyach gp said...

Sorry, this module for Presta ver. 4.0.1x

muis arghiansyach gp said...

The module did not show any output in the front end...

-->

In administrator, tab modules, Front Office Features, click Enable.

Anonymous said...

I was enable but didn't show on front end

Anonymous said...

everything i did perfectly, please post ASAP

Anonymous said...

it's not show in position tab (modules-> Position)

muis arghiansyach gp said...

In my Presta ver. 1.4.0.17, This module name: Counter Visitor v.01

Anonymous said...

mas mau tanyak gimana supaya counternya angka dari awal maksudnya dari 000000

muis arghiansyach gp said...

di file acount.txt ganti dengan 0

stif meister said...

Prestashop 1.5 is now out I hope you can made this module work on the latest version so that I can add this to my currently installed Prestashop Themes

Post a Comment

Thanks a lot for your attention...

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Web Hosting