• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Share mod bộ đếm lượt truy cập đơn giản cho php

Admin

Well-Known Member
Staff member
Administrator
Code tạo bộ đếm lượt truy cập đơn giản cho code viết bằng php. Ai biết rồi đừng chém mình nhé!
B1: Tạo 1 file mới với tên count.php mở file count.php dán đoạn mã này vào:
PHP:
<?php
$counter = "./counter.txt";
$today = getdate();
$month = $today[month];
$mday = $today[mday];
$year = $today[year];
$current_date = $mday . $month . $year;
// Log visit;
$fp = fopen($counter, "a");
$line = $REMOTE_ADDR . "|" . $mday . $month . $year . "\n";
$size = strlen($line);
fputs($fp, $line, $size);
fclose($fp);
$contents = file($counter);
$total_hits = sizeof($contents);
$total_hosts = array();
for ($i=0;$i<sizeof($contents);$i++) {
$entry = explode("|", $contents[$i]);
array_push($total_hosts, $entry[0]);
}
$total_hosts_size = sizeof(array_unique($total_hosts));
$daily_hits = array();
for ($i=0;$i<sizeof($contents);$i++) {
$entry = explode("|", $contents[$i]);
if ($current_date == chop($entry[1])) {
array_push($daily_hits, $entry[0]);
}
}
$daily_hits_size = sizeof($daily_hits);
$daily_hosts = array();
for ($i=0;$i<sizeof($contents);$i++) {
$entry = explode("|", $contents[$i]);
if ($current_date == chop($entry[1])) {
array_push($daily_hosts, $entry[0]);
}
}
$daily_hosts_size = sizeof(array_unique($daily_hosts));
?>
B2: Mở file cần chèn bộ đếm tìm đoạn
PHP:
<?php
chèn dưới
PHP:
include("count.php");
B3: Tìm tới nơi cần đặt bộ thêm vào
PHP:
echo "Today: ".$daily_hits_size." | Total: ".$total_hits."";
Xong
 

Facebook Comments

New posts New threads New resources

Back
Top