Post by bebaspromo » Fri Jul 23, 2010 11:06 pm

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) :
Image

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 ... :-*
Last edited by bebaspromo on Fri Jul 23, 2010 11:48 pm, edited 3 times in total.

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by bebaspromo » Fri Jul 23, 2010 11:26 pm

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 ...

- Image

- Image

- Image

- Image

atau gunakan images yg Anda punya, asal nama & ekstensinya disamakan atau atur ulang di file counter.phpnya
Last edited by bebaspromo on Fri Jul 23, 2010 11:44 pm, edited 1 time in total.

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by bebaspromo » Fri Jul 23, 2010 11:37 pm

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">&nbsp;</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">&nbsp;</div>
</div>
Perubahan (penggantian) terletak pada baris 10, dari <?php echo $code; ?> menjadi <? include "counter.php"; ?>

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by bebaspromo » Fri Jul 23, 2010 11:42 pm

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 :laugh:
Status : pasti sudah Enable dong?
Sort Order : atur ...

jangan lupa hajar tombol "Save" ;D

selamat mencoba, tutorial sederhana usai ... :joker:

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by cevarief » Sat Jul 24, 2010 10:19 am

bebaspromo wrote:Login ke Admin Panel Anda,

jangan lupa hajar tombol "Save" ;D
Wah kacau nih tutorialnya, kalau tombol save dihajar bisa ganti monitor sering2 nih :laugh: :laugh:
B, attach aja file jadinya biar gampang :P

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by qahar » Sat Jul 24, 2010 11:02 am

tutorial sederhana berdampak "besar" :laugh:

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by bebaspromo » Sat Jul 24, 2010 12:23 pm

cevarief wrote: Wah kacau nih tutorialnya, kalau tombol save dihajar bisa ganti monitor sering2 nih :laugh: :laugh:
"hajar"nya penuh kasih sayang ... romantisme ... dan kelembutan duniawi ... :crazy:
cevarief wrote: B, attach aja file jadinya biar gampang :P
biar sambil belajar bareng, C ... :P

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by bebaspromo » Sat Jul 24, 2010 12:24 pm

qahar wrote:tutorial sederhana berdampak "besar" :laugh:
monggo disempurnakan, Q ... :-*

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by mulunix » Sat Jul 24, 2010 12:50 pm

saya sudah mencobanya dan berjalan dengan sempurna :)

makasih banyak atas tutorialnya

Image


User avatar
Active Member

Posts

Joined
Mon Jun 21, 2010 4:56 am

Post by mulunix » Sat Jul 24, 2010 12:52 pm

qahar wrote:tutorial sederhana berdampak "besar" :laugh:
kecil barannya besar khasiatnya :good:

Image


User avatar
Active Member

Posts

Joined
Mon Jun 21, 2010 4:56 am

Post by budi99 » Sat Jul 24, 2010 11:38 pm

sy copy ya om TS.. belom sempet nyoba..
thanks

Newbie

Posts

Joined
Sat Jul 24, 2010 10:42 pm

Post by bebaspromo » Sun Jul 25, 2010 2:14 am

budi99 wrote:sy copy ya om TS.. belom sempet nyoba..
thanks
sama2, Sob ... copas dan kapan2 dicobi, nggih??

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by bebaspromo » Mon Jul 26, 2010 4:28 am

Ternyata sudah ada modulenya :joker:
hajar Brooo .....

Lantjar djaja di 148b, versi lain monggo di test2 ...

User avatar
Active Member

Posts

Joined
Tue Dec 22, 2009 9:14 pm

Post by PreSiDent » Thu Jul 29, 2010 11:15 am

bebaspromo wrote:Ternyata sudah ada modulenya :joker:
hajar Brooo .....

Lantjar djaja di 148b, versi lain monggo di test2 ...
Thanks Om .. Its work

User avatar
Newbie

Posts

Joined
Thu Aug 27, 2009 10:28 am
Location - Jakarta

Post by Sinarweb » Wed Nov 03, 2010 11:24 am

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

Newbie

Posts

Joined
Wed Nov 03, 2010 11:04 am

Post by gozzilionare » Tue Feb 22, 2011 11:53 pm

makasih tutorialnya suhu....

"I know that you cannot live on hope alone, but without it, life is not worth living." — Harvey Milk

Tikus Farm - Tikus Putih


User avatar
New member

Posts

Joined
Wed Jul 14, 2010 5:06 pm


Post by ndroe » Wed Feb 23, 2011 10:02 pm

Baru gabung nehhh .. udah nemu totor ini mantap ....
makin maju open cart ... :)

Newbie

Posts

Joined
Wed Feb 23, 2011 9:58 pm

Post by klopshop » Thu May 12, 2011 9:51 am

ane gagal terus neh pake OC 1.4.9.4 gimana donk caranya http://www.klopshop.com

Newbie

Posts

Joined
Thu Apr 14, 2011 5:15 pm

Post by zetri » Fri May 13, 2011 9:47 pm

ko reset ke 0 pengunjung lagi visitor counter setelah awal bulan, mhn pencerahannya

Newbie

Posts

Joined
Fri Mar 18, 2011 3:46 pm

Post by AgenJaket » Fri May 20, 2011 3:20 pm

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,
O0

http://www.AgenJaket.com
Toko Jaket Motor Online Terlengkap di Indonesia


User avatar
New member

Posts

Joined
Mon May 02, 2011 1:35 pm
Location - Denpasar
Who is online

Users browsing this forum: No registered users and 3 guests