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

Code php bộ đếm truy cập trong ngày, tuần, tháng

Admin

Well-Known Member
Staff member
Administrator
Dán code sau vào nơi bạn muốn hiển thị bộ đếm
PHP:
<?php
// --[Config]--------------
date_default_timezone_set ("Asia/Ho_Chi_Minh");
$jam=date("H:i:s",time());
$file = 'stats.dat';
// File to store all data.
$onlineTime = 360;
// Max user online time (in seconds)
$perPage = 10;
// Entry per page
// --[End Config]------
if(!file_exists($file)) {
$fs = fopen($file, 'w') or die('<b>Error:</b> Unable to create stats file.<br/>');
fclose($fs);
}
$ip = (getenv('HTTP_X_FORWARDED_FOR') != '') ? getenv('HTTP_X_FORWARDED_FOR') : $_SERVER['REMOTE_ADDR'];
$ua = $_SERVER['HTTP_USER_AGENT'];
$user = $_SERVER['REMOTE_ADDR'];
$hp = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$ua = str_replace('|~~|', '', htmlspecialchars($ua));
$hp = str_replace('|~~|', '', htmlspecialchars($hp));
$hp = explode(' ', $hp);
$hp = $hp[0];
$ua = explode(' ', $ua);
$ua = $ua[0];

$ip = str_replace('|~~|', '', htmlspecialchars($ip));
$waktu=7*3600+time();
$data = file($file);
foreach($data as $i => $line) {
$line = explode('|~~|', $line);
if(($line[1] == $ip && $line[2] == $hp && $line[3] == $ua && $line[4] == $user) || $line[0] < ($waktu - $onlineTime)) unset($data[$i]);
}
$data[] = implode('|~~|', array_pad(array($waktu, $ip, $hp, $ua, $user, $pageName), 5, ''));
$online = count($data);
$fs = fopen($file, 'w');
foreach($data as $line) fputs($fs, rtrim($line) . "\n");
fclose($fs);
unset($data, $line, $ip, $hp, $ua, $user, $fs);

$counter = "<?php include'config.php' ?>";
$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));
echo("<div class=\"gmenu\" align=\"center\"><small>Online: ".$online." | Today: ".$daily_hits_size." | Total: ".$total_hits."</small></div>");
echo "</div>";
?>
Tạo 1 file tên là config.php nằm cùng thư mục với bộ đếm rồi dán code này vào
PHP:
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|14June2012
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
|22January2013
Nguồn: http://tuoitreit.vn
 

Facebook Comments

Similar threads
Thread starter Title Forum Replies Date
Admin Yilmaz - Hide [code,php,html] content from guests (vb5.6.x) Add-ons 0
Vtkun Xin giải mã code php Thảo luận chung 0
Admin Share code php check rank Việt Nam và thế giới từ Alexa PHP 0
T Share Code PHP HảiCMS giao diện BĐS Mã nguồn web 0
C Hỏi Cách tạo hosting trên winserver 2008R2 chạy code php và worpress Hỏi đáp về domain & hosting 0
thanhchiit Share Code PHP Hiển Thị Ping MS cho Web/Wap Mã nguồn wap 5
K Share Code PHP hạn chế tấn công DDOS PHP 4
D Xin code php Mã nguồn web 0
blog4me Share Code web đọc truyện online PHP Mã nguồn web 22
H Share code tạo ảnh chữ lồng php và html All Shared Scripts 3
H Share code php lấy ảnh avatar teamobi All Shared Scripts 1
K Help Ai giúp mình sửa code php này PHP 0
T Share code wap chat PHP v1.3 PHP 0
Tuzoro Share code online php cho wap web Mã nguồn wap 0
T xin code auto wap/wed php mong admin, mod giúp Thảo luận wap việt 2
N Hỏi xin code web quản lí tour du lịch bằng php Mã nguồn web 0
Tuzoro Share Code PHP đóng dấu ảnh logo vào Java All Shared Scripts 0
Admin Share code php mã hóa và giải mã cơ số 64 - encode and decode base64 PHP 1
Admin Share code php chuyển đổi các hệ cơ số PHP 0
Admin Share code php tạo album ảnh online Mã nguồn web 0
Admin Share code php thêm header, footer vào zip html online Mã nguồn wap 1
Admin Share code php đổi .jar thành _jar Mã nguồn wap 0
tubotocdo Share Code Php Mod Style Soft Java Khi Truy Cập Tập Tin Mã nguồn wap 1
Admin Xenplaza – Select ALL & Clipboard: CODE, PHP, HTML Xenforo 0
Admin Share code web bán sách bằng php Mã nguồn web 1
Admin Share code php hiện quảng cáo ngẫu nhiên Mã nguồn wap 0
Admin Share code php crack sms kichhoat.net Mã nguồn wap 0
Admin Share code php leech fshare.vn, 4share.vn, mediafire.com Mã nguồn web 7
Admin Share code php tạo file index cho thư mục chưa có Mã nguồn wap 2
Admin Share code php đóng dấu văn bản cho ảnh PHP 0
Admin Share code php đăng nhập facebook PHP 2
Admin Share code tạo album ảnh đẹp (jquery + css3 + php) Mã nguồn web 0
Admin Share code php show bài viết chuyên mục có chia trang PHP 0
A Share Code PHP Tạo Logo "Angry Birds" By Nguyên Ary Mã nguồn wap 1
D Share Code tra từ điển nhỏ gọn php All Shared Scripts 0
Admin Ebook hướng dẫn làm forum bằng php và mysql kèm theo source code full PHP 0
Admin Share code gửi mail bằng php và java Mã nguồn web 1
Admin Share code php extract email từ wordpress, joomla, opencart, whmcs Hacking 0
Admin Share code php bạn đến từ đâu Mã nguồn wap 0
Admin Improved templates for [code], [html] and [php] bbcodes Vbulletin 0
Admin Share code php giải nén .rar Mã nguồn wap 0
Admin Share code quản lí file php không cần đăng nhập ftp Mã nguồn wap 1
Admin Share code crack sms game, ứng dụng bằng php Mã nguồn wap 0
Admin Share code quản lý sinh viên bằng php cho người mới học Mã nguồn web 1
Admin Short.Url.Script.v2.1.PHP.NULL-DGT - Code rút gọn link Mã nguồn web 0
E Ai cho mình xin code php import files PHP 3
Admin Change CODE and PHP tags design Add-ons 0
Myshare Share Code php đóng dấu ảnh đơn giản All Shared Scripts 1
Admin Share code php đơn giản leech file dung lượng lớn PHP 3
T Share Code php zip file online All Shared Scripts 5

Similar threads

New posts New threads New resources

Back
Top