Thẩm mỹ viện Uy Tín | Web Chăm sóc Gia Đình

Tiêu đề: Tạo thống kê số người truy cập và số người trực tuyến [In trang]

Tác giả: admin    Thời gian: 27-8-2016 18:57
Tiêu đề: Tạo thống kê số người truy cập và số người trực tuyến
Down 2 file đính kèm, cái thong_ke.zip giải nén được thư mục thong_ke các bác up
ngang hàng thư mục includes (root)
Giải nén file thong_ke.lbi.zip được file thong_ke.lbi các bác mở ra xem cách chèn rồi
làm lại theo tùy style nhé. Cái đó làm theo bản phukienmaytinh.vn. Còn em đã làm cho
bản default, bác nào có nhu cầu PM Yahoo fanhuynet, em online thì send cho các bác.
Rồi đến code:
1. Mở file lib_main.php trong includes ra. Ctrl+F gõ vào
get_os()  tìm tới đoạn
  1. elseif (strpos($agent, 'nt 6.0') !== false)
  2. {
  3. $os = 'Windows Vista';
  4. }
  5. và chèn ngay sau nó đoạn mã:
  6. elseif (strpos($agent, 'nt 6.1') !== false)
  7. {
  8. $os = 'Windows 7';
  9. }  
Sao chép mã

2. tiếp, cũng là file lib_main luôn:
Chèn
  1. function quoc_gia ($ip)
  2. {
  3. $numbers = preg_split( "/\./", $ip );
  4. $ranges = $countries = array();
  5. $ma_quoc_gia = $three_letter_country_code = $quoc_gia= "";
  6. include ( ROOT_PATH . "/thong_ke/ip_files/" . $numbers[0] . ".php" );
  7. $code = ( $numbers[0] * 16777216 ) + ( $numbers[1] * 65536 ) + ( $numbers[2] * 256 ) + (
  8. $numbers[3] );
  9. if ( ! empty( $ranges ) )
  10. {
  11. foreach ( $ranges as $key => $value )
  12. {
  13. if ( $key <= $code )
  14. {
  15. if ( $ranges[$key][0] >= $code )
  16. {
  17. $ma_quoc_gia = $ranges[$key][1];
  18. break;
  19. }
  20. }
  21. }
  22. }
  23. include ( ROOT_PATH . "/thong_ke/ip_files/countries.php" );
  24. $three_letter_country_code = $countries[$ma_quoc_gia][0];
  25. $quoc_gia= $countries[$ma_quoc_gia][1];
  26. $ma_quoc_gia = ($ma_quoc_gia!='') ? strtolower($ma_quoc_gia) : 'xx';
  27. $ket_qua=array(
  28. 'quoc_gia' => $quoc_gia,
  29. 'co' => 'http://api.hostip.info/images/flags/' .$ma_quoc_gia. '.gif',
  30. );
  31. return $ket_qua;
  32. }
Sao chép mã

chèn chỗ nào cũng được, miễn sao đừng nhè giữa các function khác mà phang là được ^^
3. Tiếp nè, Trong hàm visit_star()
tìm
  1. $area = ecs_geoip($ip);
Sao chép mã

xong xóa nó luôn, rồi thay cái này vào:
  1. $kv = quoc_gia($ip);
  2. $area = $kv['quoc_gia'];
Sao chép mã

Vậy là xong lib_main, giờ qua lib_insert.php nè:
Các bác chèn cái này vào
  1. function insert_thong_ke()
  2. {
  3. $today = local_strtotime(local_date('Y-m-d'));
  4. $gio=date('H',$today);
  5. $ngay=local_date('d');
  6. $truc_tuyen=$GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('sessions'));
  7. $tong_truy_cap=$GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('stats'));
  8. $truy_cap_tuan=$GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('stats').
  9. "WHERE access_time >= '($today - 86400 * 7)' AND access_time <= '$today'");
  10. $truy_cap_thang=$GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('stats').
  11. "WHERE access_time >= '($today - 86400 * ($ngay-1))' AND access_time <= '$today'");
  12. $truy_cap_ngay=$GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('stats').
  13. "WHERE access_time >= '$today- 86400'");
  14. $tongcong = str_pad($tong_truy_cap, 10, "0", STR_PAD_LEFT );
  15. $truc_tuyen = str_pad($truc_tuyen, 3, "0", STR_PAD_LEFT );
  16. $truy_cap_ngay = str_pad($truy_cap_ngay, 4, "0", STR_PAD_LEFT );
  17. $truy_cap_tuan = str_pad($truy_cap_tuan, 5, "0", STR_PAD_LEFT );
  18. $truy_cap_thang = str_pad($truy_cap_tuan, 5, "0", STR_PAD_LEFT );
  19. $ngay='';
  20. $tuan='';
  21. $thang='';
  22. $tt='';
  23. $tc='';
  24. for($i=0;$i<3;$i++)
  25. {
  26. $j=intval(substr($truc_tuyen,$i,1));
  27. $tt .='<img src="thong_ke/bo_dem/'.$j.'.png" align="absmiddle" width="12">';
  28. }
  29. for($i=0;$i<4;$i++)
  30. {
  31. $j=intval(substr($truy_cap_ngay,$i,1));
  32. $ngay .='<img src="thong_ke/bo_dem/'.$j.'.png" align="absmiddle" width="12">';
  33. }
  34. for($i=0;$i<5;$i++)
  35. {
  36. $j=intval(substr($truy_cap_tuan,$i,1));
  37. $tuan .='<img src="thong_ke/bo_dem/'.$j.'.png" align="absmiddle" width="12">';
  38. $j=intval(substr($truy_cap_thang,$i,1));
  39. $thang .='<img src="thong_ke/bo_dem/'.$j.'.png" align="absmiddle" width="12">';
  40. }
  41. for($i=0;$i<10;$i++)
  42. {
  43. $j=intval(substr($tongcong,$i,1));
  44. $tc.='<img src="thong_ke/bo_dem/'.$j.'.png" width="16">';
  45. }
  46. $content ='<table width=100%>';
  47. $content.='<tr><td align="left" >Đang trực tuyến:</td><td align="right"> '.$tt.'</td></tr>';
  48. $content.='<tr><td align="left" >Truy cập trong 24h:</td><td align="right" > '. $ngay.'</td></tr>';
  49. $content.='<tr><td align="left" >Truy cập trong tuần:</td><td align="right" >'.$tuan.'</td></tr>';
  50. $content.='<tr><td align="left" >Truy cập trong tháng:</td><td align="right">'.$thang.'</td></tr>';
  51. $content.='<tr><td colspan="2" align="center"><b>Tổng số lượt truy cập:</b></td></tr>';
  52. $content.='<tr><td colspan="2" align="center">'.$tc.'</td></tr>';
  53. $content.='</table>';
  54. return $content;
  55. }
  56. function insert_thong_tin()
  57. {
  58. $hinh_trinh_duyet='thong_ke/khac.gif';
  59. $hinh_dhd='thong_ke/khac.gif';
  60. $trinh_duyet=get_user_browser();
  61. $hdh=get_os();
  62. $ips=preg_split( "/\./",real_ip());
  63. $ip='';
  64. for($i=0;$i<4;$i++)
  65. {
  66. $m=$ips[$i];
  67. for ($j=0;$j<strlen($m);$j++)
  68. {
  69. $k=intval(substr($m,$j,1));
  70. $ip.='<img src="thong_ke/bo_dem/1/'.$k.'.png" width="13px">';
  71. }
  72. if ($i<3) $ip.='.';
  73. }
  74. if (strpos($trinh_duyet, 'IE') !== false)  
  75. {
  76. $hinh_trinh_duyet='thong_ke/trinh_duyet/ie.jpg';
  77. }
  78. elseif (strpos($trinh_duyet, 'FireFox') !== false)
  79. {
  80. $hinh_trinh_duyet='thong_ke/trinh_duyet/firefox.jpg';
  81. }
  82. elseif (strpos($trinh_duyet, 'Opera') !== false)
  83. {
  84. $hinh_trinh_duyet='thong_ke/trinh_duyet/opera.jpg';
  85. }
  86. elseif (strpos($trinh_duyet, 'Netscape') !== false)
  87. {
  88. $hinh_trinh_duyet='thong_ke/trinh_duyet/netscape.jpg';
  89. }
  90. elseif (strpos($trinh_duyet, 'Chrome') !== false)
  91. {
  92. $hinh_trinh_duyet='thong_ke/trinh_duyet/chrome.jpg';
  93. }
  94. $hdh=get_os();
  95. if (strpos($hdh, 'Win') !== false)
  96. {
  97. if ($hdh=='Windows 7')
  98. {
  99. $hinh_hdh='thong_ke/hdh/win7.jpg';
  100. }
  101. else if ($hdh=='Windows 98')
  102. {
  103. $hinh_hdh='thong_ke/hdh/win98.jpg';
  104. }
  105. else
  106. {
  107. $hinh_hdh='thong_ke/hdh/winxp.jpg';
  108. }
  109. }
  110. elseif ($hdh=='Linux')
  111. {
  112. $hinh_hdh='thong_ke/hdh/linux.jpg';
  113. }
  114. $content.='<table width=100%>';
  115. $content.='<tr><td align="left" width=45%>Trình duyệt</td><td align="right" width=55%> <img
  116. src="'.$hinh_trinh_duyet.'" align="absmiddle" width="16px"> '. $trinh_duyet . '</td></tr>';
  117. $content.='<tr><td align="left" width=45%>Hệ điều hành</td><td align="right" width=55%> <img
  118. src="'.$hinh_hdh.'" align="absmiddle" width="16px"> '.$hdh. '</td></tr>';
  119. $kv=quoc_gia(real_ip());
  120. $content.='<tr><td align="left" width=45%>Quốc gia:</td><td align="right" width=55%> <img src="'.$kv['co'].'"
  121. align="absmiddle" width="16px"> '.$kv['quoc_gia'].'</td></tr>';
  122. $content.='<tr><td align="center" colspan="2"><img src="thong_ke/ip.jpg" width=20px>'.$ip.'</td></tr>';  

  123. $content .='</table>';
  124. return $content;
  125. }
Sao chép mã

LINK DOWNLOAD:
http://www.mediafire.com/?sfsj8u372m61z16
http://www.mediafire.com/?68spiaw676m71rk






Chào mừng ghé thăm Thẩm mỹ viện Uy Tín | Web Chăm sóc Gia Đình (http://www.chamsocgiadinh.com/) Powered by Discuz! X3.2