Просмотр файла gallery/count24.php

Размер файла: 3.55Kb
  1. <?php
  2. #-----------------------------------------------------#
  3. # ********* ROTORCMS ********* #
  4. # Made by : VANTUZ #
  5. # E-mail : visavi.net@mail.ru #
  6. # Site : http://pizdec.ru #
  7. # WAP-Site : http://visavi.net #
  8. # ICQ : 36-44-66 #
  9. # Вы не имеете право вносить изменения в код скрипта #
  10. # для его дальнейшего распространения #
  11. #-----------------------------------------------------#
  12. require_once "../includes/start.php";
  13. require_once "../includes/functions.php";
  14.  
  15. $hours = floor((gmmktime(date("H"), 0, 0, date("m"), date("d"), date("Y")) - gmmktime(4, 0, 0, 1, 1, 1970)) / 3600);
  16.  
  17. $querycount = DB :: $dbh -> query("SELECT * FROM `counter24` ORDER BY `count_hour` DESC;");
  18. $counts = $querycount -> fetchAll();
  19.  
  20. $arrhits = array();
  21. $arrhosts = array();
  22. $hits_data = array();
  23. $host_data = array();
  24.  
  25. foreach ($counts as $val) {
  26. $arrhits[$val['count_hour']] = $val['count_hits'];
  27. $arrhosts[$val['count_hour']] = $val['count_hosts'];
  28. }
  29.  
  30. for ($i = 0, $tekhours = $hours; $i < 24; $tekhours -= 1, $i++) {
  31. if (isset($arrhits[$tekhours])) {
  32. $hits_data[] = $arrhits[$tekhours];
  33. } else {
  34. $hits_data[] = 0;
  35. }
  36.  
  37. if (isset($arrhosts[$tekhours])) {
  38. $host_data[] = $arrhosts[$tekhours];
  39. } else {
  40. $host_data[] = 0;
  41. }
  42. }
  43.  
  44. $hits_data = array_reverse($hits_data);
  45. $host_data = array_reverse($host_data);
  46. // --------------------------------------------------//
  47. $max = 0;
  48. $max_index = 0;
  49. foreach ($hits_data as $index => $value) {
  50. if ($value > $max) {
  51. $max = $value;
  52. $max_index = $index;
  53. }
  54. }
  55.  
  56. if ($max == 0) {
  57. $max = 1;
  58. }
  59. // процентное соотношение хитов
  60. $per_hit = array();
  61. foreach ($hits_data as $value) {
  62. $per_hit[] = $value * 0.90 / $max;
  63. }
  64. // процентное соотношение хостов
  65. $per_host = array();
  66. foreach ($host_data as $value) {
  67. $per_host[] = $value * 1.90 / $max;
  68. }
  69. $img = @imageCreateFromGIF(BASEDIR . 'images/img/counter24.gif');
  70. // линейный
  71. $color1 = imageColorAllocate($img, 44, 191, 228);
  72. $color2 = imageColorAllocate($img, 0, 0, 120);
  73. $color_red = imageColorAllocate($img, 200, 0, 0);
  74.  
  75. $image = 47;
  76. $coll = 4;
  77. $x1 = 114;
  78. $x2 = $x1 - 3;
  79. $y1_hits = (int)($image - $image * $per_hit[0] + 7);
  80. $y1_host = (int)($image - $image * $per_host[0] + 7);
  81.  
  82. $counth = count($hits_data);
  83. if ($counth > 24) {
  84. $counth = 24;
  85. }
  86.  
  87. for($i = 1;$i < $counth;$i++) {
  88. // хиты
  89. $y2_hits = (int)($image - $image * $per_hit[$i] + 7);
  90. imageLine($img, $x1, $y1_hits, $x2, $y2_hits, $color1);
  91. // хосты
  92. $y2_host = (int)($image - $image * $per_host[$i] + 7);
  93. imageLine($img, $x1, $y1_host, $x2, $y2_host, $color2);
  94.  
  95. if ($hits_data[$i] != 0 && $i == $max_index) {
  96. imageTTFtext($img, 6, 0, $x2-17, $y2_hits-3, $color_red, BASEDIR . "gallery/fonts/font.ttf", "max");
  97. imageTTFtext($img, 6, 0, $x2 + 2, $y2_hits-3, $color2, BASEDIR . "gallery/fonts/font.ttf", $hits_data[$i]);
  98. /**
  99. * ImageString($img, 1, $x2-17, $y2_hits-10, "max", $color_red);
  100. * ImageString($img, 1, $x2+2, $y2_hits-10, $hits_data[$i], $color2);
  101. */
  102.  
  103. imageLine($img, $x2-1, $y2_hits-7, $x2-1, $y2_hits + 42, $color_red);
  104. }
  105. $y1_hits = $y2_hits;
  106. $y1_host = $y2_host;
  107. $x1 -= $coll;
  108. $x2 -= $coll;
  109. }
  110. Header("Content-type: image/gif");
  111. ImageGIF($img);
  112. ImageDestroy($img);
  113.  
  114. ?>