Guest User

Untitled

a guest
Nov 8th, 2017
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. <?php
  2. /*
  3. * @ Code web bán nick LMHT được viết bởi Hậu Nguyễn
  4. *
  5. * @ Liên hệ: https://www.facebook.com/profile.php?id=100004684695399
  6. *
  7. */
  8.  
  9. session_start();
  10.  
  11. $ketnoi['host'] = '127.0.0.1'; //Tên server, nếu dùng hosting free thì cần thay đổi
  12. $ketnoi['dbname'] = 'root'; //Đây là tên của Database
  13. $ketnoi['username'] = 'shop'; //Tên sử dụng Database
  14. $ketnoi['password'] = '';//Mật khẩu của tên sử dụng Database
  15. @mysql_connect("{$ketnoi['host']}","{$ketnoi['username']}","{$ketnoi['password']}") or die("Không thể kết nối database");
  16. @mysql_select_db( "{$ketnoi['dbname']}") or die("Không thể chọn database");
  17. // lấy dữ liệu user trong csdl thông qua sesion
  18. if (isset($_SESSION['username']) && $_SESSION['username']){
  19. $uid = $_SESSION['username'];
  20. $data = mysql_fetch_array(mysql_query("SELECT * FROM `nguoidung` WHERE `uid` = '".$uid."' LIMIT 1"));// get dữ liệu từ trong data theo user id
  21. }
  22. $home = 'http://'.$_SERVER['HTTP_HOST'].'';// lấy tên miền
  23. $lienminh = mysql_result(mysql_query("SELECT COUNT(*) FROM `baidang` WHERE `loainick` = 'LMHT' AND `trangthai` !='off' LIMIT 1"), 0);
  24. $user = mysql_result(mysql_query("SELECT COUNT(*) FROM `nguoidung` LIMIT 1"), 0);
  25. $giaodich = mysql_result(mysql_query("SELECT COUNT(*) FROM `lichsumua` LIMIT 1"), 0);
  26. $now = getdate();
  27. // func đếmn ngược thời gian (dạng giống facebook)
  28. function time_stamp($time)
  29. {
  30.  
  31. $periods = array("giây", "phút", "giờ", "ngày", "tuần", "tháng", "năm", "thập kỉ");
  32. $lengths = array("60","60","24","7","4.35","12","10");
  33.  
  34. $now = time();
  35.  
  36. $difference = $now - $time;
  37. $tense = "trước";
  38.  
  39. for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
  40. $difference /= $lengths[$j];
  41. }
  42.  
  43. $difference = round($difference);
  44.  
  45.  
  46.  
  47. return "Cách đây $difference $periods[$j]";
  48. }
  49.  
  50. // Func thống kê online
  51. function getAmungStats($amung) {
  52. if(!isset($amung)) return false;
  53.  
  54. $url = 'http://whos.amung.us/sitecount/' . $amung . '/';
  55. $result = '';
  56. if (function_exists('curl_init')) {
  57. $http_headers = array();
  58. $http_headers[] = 'Expect:';
  59. $http_headers[] = 'Content-Type: text/plain';
  60. $http_headers[] = 'Host: whos.amung.us';
  61. $opts = array();
  62. $opts[CURLOPT_URL] = $url;
  63. $opts[CURLOPT_HTTPHEADER] = $http_headers;
  64. $opts[CURLOPT_CONNECTTIMEOUT] = 5;
  65. $opts[CURLOPT_TIMEOUT] = 10;
  66. $opts[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17';
  67. $opts[CURLOPT_HEADER] = FALSE;
  68. $opts[CURLOPT_RETURNTRANSFER] = TRUE;
  69.  
  70. # Initialize PHP/CURL handle
  71. $ch = curl_init();
  72. curl_setopt_array($ch, $opts);
  73. # Create return array
  74. $result = curl_exec($ch);
  75. curl_close($ch);
  76. } elseif (ini_get('allow_url_fopen')) {
  77. $result = file_get_contents($url);
  78. }
  79.  
  80. return intval($result);
  81. }
  82.  
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment