Page 1 of 2
(How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Fri Jul 23, 2010 11:06 pm
by bebaspromo
Saat saia bongkar2 file lawas tadi siang, nemu satu "statistik pengunjung" favorit waktu jaman OC masih versi 140 dulu.
berhubung (lagi-lagi) masih belum kompeten membuat real module-nya maka tutorial sederhana ini berkolaborasi
dengan MyModule-nya Bro Saccarep.
"Statistik Pengunjung" yang saia maksud seperti ini (Statistik Web) :
Persiapan awal,
pilih module MyModule yang sesuai dengan versi OC Anda
di situs Bro Saccarep. Install & aktifkan seperti biasa.
Jika memungkinkan & waktu Anda cukup, modif MyModule menjadi module Visitor (umpamanya). Kalau tidak,
biarkan begitu apa adanya.
saia lanjutkan sebentar lagi, buat kopi dulu ...

Re: (How To) Menampilkan Jumlah Pengunjung Situs ...
Posted: Fri Jul 23, 2010 11:26 pm
by bebaspromo
woke ... lanjut lageee ....
Persiapan berikutnya adalah :
satu,
tuliskan kode berikut & simpan dengan nama
counter.php di
folder utama OC Anda
Code: Select all
<?
$expire = 600;
$filename = "counter.txt";
if (file_exists($filename))
{
$ignore = false;
$current_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? addslashes(trim($_SERVER['HTTP_USER_AGENT'])) : "no agent";
$current_time = time();
$current_ip = $_SERVER['REMOTE_ADDR'];
$c_file = array();
$handle = fopen($filename, "r");
if ($handle)
{
while (!feof($handle))
{
$line = trim(fgets($handle, 4096));
if ($line != "")
$c_file[] = $line;
}
fclose ($handle);
}
else
$ignore = true;
if (substr_count($current_agent, "bot") > 0)
$ignore = true;
for ($i = 1; $i < sizeof($c_file); $i++)
{
list($counter_ip, $counter_time) = explode("||", $c_file[$i]);
$counter_time = trim($counter_time);
if ($counter_ip == $current_ip && $current_time-$expire < $counter_time)
{
// besucher wurde bereits gezählt, daher hier abbruch
$ignore = true;
break;
}
}
if ($ignore == false)
{
if (sizeof($c_file) == 0)
{
$add_line1 = date("z") . ":1||" . date("W") . ":1||" . date("n") . ":1||" . date("Y") . ":1||1||1||" . $current_time . "\n";
$add_line2 = $current_ip . "||" . $current_time . "\n";
$fp = fopen($filename,"w+");
if ($fp)
{
flock($fp, LOCK_EX);
fwrite($fp, $add_line1);
fwrite($fp, $add_line2);
flock($fp, LOCK_UN);
fclose($fp);
}
$day = $week = $month = $year = $all = $record = 1;
$record_time = $current_time;
$online = 1;
}
else
{
// counter
list($day_arr, $week_arr, $month_arr, $year_arr, $all, $record, $record_time) = explode("||", $c_file[0]);
// day
$day_data = explode(":", $day_arr);
$day = $day_data[1];
if ($day_data[0] == date("z")) $day++; else $day = 1;
// week
$week_data = explode(":", $week_arr);
$week = $week_data[1];
if ($week_data[0] == date("W")) $week++; else $week = 1;
// month
$month_data = explode(":", $month_arr);
$month = $month_data[1];
if ($month_data[0] == date("n")) $month++; else $month = 1;
// year
$year_data = explode(":", $year_arr);
$year = $year_data[1];
if ($year_data[0] == date("Y")) $year++; else $year = 1;
// all
$all++;
$record_time = trim($record_time);
if ($day > $record)
{
$record = $day;
$record_time = $current_time;
}
$online = 1;
$fp = fopen($filename,"w+");
if ($fp)
{
flock($fp, LOCK_EX);
$add_line1 = date("z") . ":" . $day . "||" . date("W") . ":" . $week . "||" . date("n") . ":" . $month . "||" . date("Y") . ":" . $year . "||" . $all . "||" . $record . "||" . $record_time . "\n";
fwrite($fp, $add_line1);
for ($i = 1; $i < sizeof($c_file); $i++)
{
list($counter_ip, $counter_time) = explode("||", $c_file[$i]);
if ($current_time-$expire < $counter_time)
{
$counter_time = trim($counter_time);
$add_line = $counter_ip . "||" . $counter_time . "\n";
fwrite($fp, $add_line);
$online++;
}
}
$add_line = $current_ip . "||" . $current_time . "\n";
fwrite($fp, $add_line);
flock($fp, LOCK_UN);
fclose($fp);
}
}
}
else
{
if (sizeof($c_file) > 0)
list($day_arr, $week_arr, $month_arr, $year_arr, $all, $record, $record_time) = explode("||", $c_file[0]);
else
list($day_arr, $week_arr, $month_arr, $year_arr, $all, $record, $record_time) = explode("||", date("z") . ":1||" . date("W") . ":1||" . date("n") . ":1||" . date("Y") . ":1||1||1||" . $current_time);
// day
$day_data = explode(":", $day_arr);
$day = $day_data[1];
// week
$week_data = explode(":", $week_arr);
$week = $week_data[1];
// month
$month_data = explode(":", $month_arr);
$month = $month_data[1];
// year
$year_data = explode(":", $year_arr);
$year = $year_data[1];
$record_time = trim($record_time);
$online = sizeof($c_file) - 1;
}
?>
<table cellpadding="0" cellspacing="0" style="border:0px solid #">
<tr>
</tr>
<tr>
<center>
<td>
<font face="Arial, Helvetica, sans-serif" size="2">
<img src="image/counter/online.png" width="16" height="16" border="0" /> Sedang Online : <? echo $online; ?><br>
<img src="image/counter/today.png" width="16" height="16" border="0" /> Hari ini : <? echo $day; ?> <br>
<img src="image/counter/week.png" width="16" height="16" border="0" /> Minggu Ini : <? echo $week; ?><br>
<img src="image/counter/all.png" width="16" height="16" border="0" /> Keseluruhan : <? echo $all; ?>
</font>
<center/>
<div align="center">
</div>
</div></td>
</tr>
</table>
<?
}
?>
dua,
buat 1 file kosong, simpan dengan nama
counter.txt di
folder utama OC Anda
tiga,
buat folder
counter di folder image (
folder utama OC Anda) dan isi dengan images berikut ini :
klik kanan, Save Image As ...
-
-
-
-
atau gunakan images yg Anda punya, asal nama & ekstensinya disamakan atau atur ulang di file
counter.phpnya
Tahap kolaborasi ...
Posted: Fri Jul 23, 2010 11:37 pm
by bebaspromo
sekarang, saatnya mengkolaborasikan MyModule dengan counter kita...
Buka file
mymodule.tpl, yang awalnya berisi kode sbb :
Code: Select all
<div class="box">
<div class="top">
<?php
if($title) { ?>
<img src="catalog/view/theme/default/image/brands.png" alt="" /><?php echo $title; ?>
<?php
} ?>
</div>
<div class="middle" style="text-align: left;">
<?php echo $code; ?>
</div>
<div class="bottom"> </div>
</div>
ubah menjadi :
Code: Select all
<div class="box">
<div class="top">
<?php
if($title) { ?>
<img src="catalog/view/theme/default/image/brands.png" alt="" /><?php echo $title; ?>
<?php
} ?>
</div>
<div class="middle" style="text-align: left;">
<? include "counter.php"; ?>
</div>
<div class="bottom"> </div>
</div>
Perubahan (penggantian) terletak pada baris 10, dari
<?php echo $code; ?> menjadi
<? include "counter.php"; ?>
Berikutnya ...
Posted: Fri Jul 23, 2010 11:42 pm
by bebaspromo
Login ke Admin Panel Anda,
akses MyModule (Extensions > Modules > My Module > Edit)
Title : Statistik Web (atau apapun, terserah Anda)
Header : Yes
HTML Code : biarkan kosong
Position : biasanya kalau ndak Right ya Left ... aneh aja kalau pilih Home
Status : pasti sudah Enable dong?
Sort Order : atur ...
jangan lupa hajar tombol "Save"
selamat mencoba, tutorial sederhana usai ...

Re: Berikutnya ...
Posted: Sat Jul 24, 2010 10:19 am
by cevarief
bebaspromo wrote:Login ke Admin Panel Anda,
jangan lupa hajar tombol "Save"
Wah kacau nih tutorialnya, kalau tombol save dihajar bisa ganti monitor sering2 nih
B, attach aja file jadinya biar gampang

Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Sat Jul 24, 2010 11:02 am
by qahar
tutorial sederhana berdampak "besar"

Re: Berikutnya ...
Posted: Sat Jul 24, 2010 12:23 pm
by bebaspromo
cevarief wrote:
Wah kacau nih tutorialnya, kalau tombol save dihajar bisa ganti monitor sering2 nih
"hajar"nya penuh kasih sayang ... romantisme ... dan kelembutan duniawi ...
cevarief wrote:
B, attach aja file jadinya biar gampang

biar sambil belajar bareng, C ...

Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Sat Jul 24, 2010 12:24 pm
by bebaspromo
qahar wrote:tutorial sederhana berdampak "besar"

monggo disempurnakan, Q ...

Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Sat Jul 24, 2010 12:50 pm
by mulunix
saya sudah mencobanya dan berjalan dengan sempurna
makasih banyak atas tutorialnya
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Sat Jul 24, 2010 12:52 pm
by mulunix
qahar wrote:tutorial sederhana berdampak "besar"

kecil barannya besar khasiatnya

Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Sat Jul 24, 2010 11:38 pm
by budi99
sy copy ya om TS.. belom sempet nyoba..
thanks
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Sun Jul 25, 2010 2:14 am
by bebaspromo
budi99 wrote:sy copy ya om TS.. belom sempet nyoba..
thanks
sama2, Sob ... copas dan kapan2 dicobi, nggih??
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Mon Jul 26, 2010 4:28 am
by bebaspromo
Ternyata sudah ada modulenya
hajar
Brooo .....
Lantjar djaja di 148b, versi lain monggo di test2 ...
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Thu Jul 29, 2010 11:15 am
by PreSiDent
bebaspromo wrote:Ternyata sudah ada modulenya
hajar
Brooo .....
Lantjar djaja di 148b, versi lain monggo di test2 ...
Thanks Om .. Its work
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Wed Nov 03, 2010 11:24 am
by Sinarweb
Sedekar mempermudah tutorialnya tidak perlu setting dan editing tinggal download dan upload saja.
Lebih mudahnya coba di sini :
http://www.blog.sinarweb.com/counter-pe ... r-counter/
Terima kasih
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Tue Feb 22, 2011 11:53 pm
by gozzilionare
makasih tutorialnya suhu....
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Wed Feb 23, 2011 10:02 pm
by ndroe
Baru gabung nehhh .. udah nemu totor ini mantap ....
makin maju open cart ...

Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Thu May 12, 2011 9:51 am
by klopshop
ane gagal terus neh pake OC 1.4.9.4 gimana donk caranya http://www.klopshop.com
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Fri May 13, 2011 9:47 pm
by zetri
ko reset ke 0 pengunjung lagi visitor counter setelah awal bulan, mhn pencerahannya
Re: (How To) Jumlah Pengunjung Situs (visitor counter) ...
Posted: Fri May 20, 2011 3:20 pm
by AgenJaket
zetri wrote:ko reset ke 0 pengunjung lagi visitor counter setelah awal bulan, mhn pencerahannya
Coba baca disini
http://forum.opencart.com/viewtopic.php ... nter+reset
Warm Regards,
