“Rivals can easily copy your improvements in quality and efficiency.
But they shouldn’t be able to copy your strategic positioning –
what distiguishes your company from all the rest.”

Michael A. Porter, 1996.

Jumat, Februari 06, 2009

PHP Counter kunjungan

nah ini ilmu dari php yang berguna banget untuk di pelajari.... couse untuk tau seberapa banyak yang datang ke web kita... nich source code nya...
ini juga diajarin di hari ke 3...


$filename = "filecounter.txt";

// untuk membuat counter bertambah setiap page di klik
$count_my_page = ($filename);
$count = file($count_my_page);
$count[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$count[0]");
fclose($fp);
echo $count[0];

// end conter

// melihat IP yang sama melihat page kita, perhitungan mengunakan IP
$filename2 = "ipcounter.txt";
// file harus dibedakan dengan diatas diakrenakan untuk menuliskan log ipyang read

//memaasukkan no IP komputer yang browse ke dalam file ipcounter.txt
$count_my_address = ($_SERVER['REMOTE_ADDR']);

$f=fopen($filename2,"a");
fwrite($f," \r\n\n ".$count_my_address);
fclose($f);
// end -- membuka file dan menuliskan ke file ipcounter

// menghitung jumlah ip yang telah di simpan pada ipcounter.txt
$count = file($filename2);
$counter = 0;
while (list($line_num, $line) = each($count))
{
if(trim($line)== $count_my_address) {
++$counter;
}

}
echo "Anda telah mengunjungi kami sebanyak ", $counter. "kali";

?>

Tidak ada komentar:

Posting Komentar