Đang tải dữ liệu...
Code đếm người online - SinhViênIT.Net ||Diễn Đàn Sinh Viên CNTT
 
 
Đang tải...
 
       
Trở lại   SinhViênIT.Net ||Diễn Đàn Sinh Viên CNTT > Thư Viện Mã Nguồn > PHP Script



Đang tải bộ máy tìm kiếm

Trả lời Gởi Ðề Tài Mới
Lần đọc: 354 - Trả lời: 0  
Ðiều Chỉnh
  #1  
Cũ 04-09-2008, 09:04 AM
vanquyetno1's Avatar
vanquyetno1 vanquyetno1 đã thoát
Thành Viên SVIT
Giới tính: Nam
Cấp độ: 4 [SinhVienIT.NetSinhVienIT.NetSinhVienIT.Net]
Hoạt động: 0 / 82
Điểm: 10 / 531
Kinh Nghiệm: 31%
Thành Viên Thứ: 239
Tham gia ngày: 21-05-2008
Bài gửi: 31
Đã Cám ơn: 0 bài viết
Được cám ơn: 14 Lần trong 10 Bài viết
Mặc định Code đếm người online

Code đếm người online

Nguồn bài viết: http://sinhvienit.net/@forum/showthread.php?t=2927
Đây là đoạn code đếm số người online trên site của bạn :

$log_file="online.txt";//chmod file này thành 7777
if($users=="0"){ die("1 user online"); }
$min_online="1";
if ($HTTP_X_FORWARDED_FOR == "") {
$ip = getenv(REMOTE_ADDR);
}
else {
$ip = getenv(HTTP_X_FORWARDED_FOR);
}
$day =date("d");
$month =date("m");
$year =date("Y");
$date="$day-$month-$year";
$ora = date("H");
$minuti = date("i");
$secondi = date("s");
$time="$ora:$minuti:$secondi";
$users_read = fopen("$log_file", "r");
$users = fread($users_read, filesize("$log_file"));
fclose($users_read);
$to_write="$ip|$time|$date";
if($users==0){
$user_write = fopen("$log_file", "w");
fputs($user_write , $to_write );
fclose($user_write );
}
else{
$users=explode("\n",$users);
$user_da_tenere=array();
while (list ($key, $val) = each ($users)) {
$user_sing=explode("|",$val);
if($date==$user_sing[2]){
$h=explode(":",$user_sing[1]);
if($ip!=$user_sing[0]){
if(($h[0]==$ora)and(($minuti-$h[1])<=$min_online)){
$user_da_tenere[]=$val;}
if(($h[0]==($ora-1))and((($minuti+2)-$h[1])<=$min_online)){
$user_da_tenere[]=$val;
}
}
}
}
$user_da_tenere[]=$to_write;
$user_write = fopen("$log_file", "w");
fputs($user_write , "" );
fclose($user_write );
while (list ($k, $v) = each ($user_da_tenere)) {
$new_file_log = fopen ("$log_file", "a");
fwrite($new_file_log,"$v\n");
fclose($new_file_log);
}
}
$users_online_read = fopen("$log_file", "r");
$users_online = fread($users_online_read, filesize("$log_file"));
fclose($users_online_read);
$users_online=explode("\n",$users_online);
$n_u_online=count($users_online)-1;
echo "Đang online : $n_u_online\n";
Khách hãy cùng vanquyetno1 chung sức xây dựng SinhVienIT.Net nha
Trả Lời Với Trích Dẫn
Quảng cáo
Trả lời Gởi Ðề Tài Mới

Đánh dấu

Tags
code, người, online, đếm


Ðang đọc: 1 (0 thành viên và 1 khách)
 
Ðiều Chỉnh

Quyền viết bài
Bạn không thể gửi chủ đề mới
Bạn không thể gửi trả lời
Bạn không thể gửi file đính kèm
Bạn không thể sửa bài viết của mình

BB code is Mở
Mặt cười đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến

Các chủ đề tương tự
Chủ đề Người khởi xướng chủ đề Diễn đàn Trả lời Bài mới gửi
[PHP] Share code kết bạn online + nhật ký + truyện Vũ Thanh Lai Dating - Mạng xã hội 61 03-07-2010 08:37 PM
code audition online vbb dành cho 4rum hungclub93 Mod VBB 3.8.x 20 05-03-2010 03:13 PM
Hỏi Code phim88.com/online Tự làm hay ở đâu? HCT Code Music-Video 9 23-01-2010 09:08 PM
Share Code khuchat V 3.5.2 kết hợp imuzik online thanhhaibg Src Xtre 17 23-06-2009 11:58 PM
External Online Users Page - Chuyển trang hiển thị thành viên online khi lượng online quá nhiều Vũ Thanh Lai Mod VBB 3.8.x 0 22-06-2009 12:56 AM


Múi giờ GMT. Hiện tại là 04:29 AM
Powered by: vBulletin v3.8.2 Copyright ©2000-2010, Jelsoft Enterprises Ltd.
Xây Dựng Và Phát Triển Bởi Các Thành Viên SinhViênIT.Net
Liên hệ: Email VuThanhLai@Gmail.Com | Admin@SinhVienIT.Net
Ghi rõ nguồn SinhVienIT.Net khi sao chép bài ở đây !

 

Trang chủ | Diễn đàn | Thư viện Tutorial | Tin tức CNTT | Việc làm | Công cụ | Server Upload