Просмотр файла rating/count.php

Размер файла: 4.01Kb
  1. <?php
  2. include "config.php";
  3. $qu = @mysql_query("SELECT `id`,`date`,`countdays` FROM `rate` WHERE id='".$id."';");
  4. $sqlar = @mysql_fetch_array($qu);
  5. $date=date("Y-m-d",time());
  6. //////////////////////////////////////////////
  7. if(!empty($id) && $id==$sqlar['id'])
  8. {
  9. if($date!=$sqlar['date'])
  10. {
  11. $countdays = $sqlar['countdays'] + 1;
  12. @mysql_query("update `rate` set `date`='$date',`today`=0,`countdays`='$countdays' where 1;");
  13. $count=0;
  14. }
  15. //////////////////////////////////////////////
  16. $q = @mysql_query("SELECT `today`,`allday` FROM `rate` WHERE id='".$id."';");
  17. $sqlid = @mysql_fetch_array($q);
  18. //////////////////////////////////////////////
  19. $count = $sqlid['today'];
  20. $count_all = $sqlid['allday'];
  21. /*$host = $sqlid['host'];
  22. ///////////////////////
  23. $cagent = getenv("HTTP_USER_AGENT");
  24. if (getenv("HTTP_X_FORWARDED_FOR"))
  25. $ip = getenv("HTTP_X_FORWARDED_FOR");
  26. else
  27. $ip = getenv("REMOTE_ADDR");
  28. $nhost = "[".$ip."]~".$cagent;
  29. $hosts = @explode("([[x]])",$host);
  30. if(!@in_array($nhost,$hosts)) $host .= "([[x]])".$nhost;
  31. $hosts = @explode("([[x]])",$host);
  32. $chost = count($hosts)-1;*/
  33. $count++;
  34. $count_all++;
  35. @mysql_query("UPDATE `rate` SET `today`=$count,`allday`=$count_all,`host`='$host',`counthost`='$chost' WHERE id=$id;");
  36. /////////////////////////////////////////////////
  37. /*if ($chost >= 0 && $chost < 10)
  38. $hpos = 59;
  39. if ($chost >= 10 && $chost < 100)
  40. $hpos = 54;
  41. if ($chost >= 100 && $chost < 1000)
  42. $hpos = 49;
  43. if ($chost >= 1000 && $chost < 10000)
  44. $hpos = 44;
  45. if ($chost >= 10000 && $chost < 100000)
  46. $hpos = 39;
  47. if ($chost >= 100000 && $chost < 1000000)
  48. $hpos = 34;
  49. if ($chost >= 1000000 && $chost < 10000000)
  50. $hpos = 29;
  51. if ($chost >= 10000000 && $chost < 100000000)
  52. $hpos = 24;
  53. if ($chost >= 100000000 && $chost < 1000000000)
  54. $hpos = 19;
  55. if ($chost >= 1000000000 && $chost < 10000000000)
  56. $hpos = 14;
  57. if ($chost >= 10000000000 && $chost < 100000000000)
  58. $hpos = 9;*/
  59. /////////////////////////////////////////////////
  60. if ($count >= 0 && $count < 10)
  61. $pos = 64;
  62. if ($count >= 10 && $count < 100)
  63. $pos = 59;
  64. if ($count >= 100 && $count < 1000)
  65. $pos = 54;
  66. if ($count >= 1000 && $count < 10000)
  67. $pos = 49;
  68. if ($count >= 10000 && $count < 100000)
  69. $pos = 44;
  70. if ($count >= 100000 && $count < 1000000)
  71. $pos = 39;
  72. if ($count >= 1000000 && $count < 10000000)
  73. $pos = 34;
  74. if ($count >= 10000000 && $count < 100000000)
  75. $pos = 29;
  76. if ($count >= 100000000 && $count < 1000000000)
  77. $pos = 24;
  78. if ($count >= 1000000000 && $count < 10000000000)
  79. $pos = 19;
  80. if ($count >= 10000000000 && $count < 100000000000)
  81. $pos = 14;
  82. /////////////////////////////////////////////////
  83. if ($count_all >= 0 && $count_all < 10)
  84. $pos_all = 64;
  85. if ($count_all >= 10 && $count_all < 100)
  86. $pos_all = 59;
  87. if ($count_all >= 100 && $count_all < 1000)
  88. $pos_all = 54;
  89. if ($count_all >= 1000 && $count_all < 10000)
  90. $pos_all = 49;
  91. if ($count_all >= 10000 && $count_all < 100000)
  92. $pos_all = 44;
  93. if ($count_all >= 100000 && $count_all < 1000000)
  94. $pos_all = 39;
  95. if ($count_all >= 1000000 && $count_all < 10000000)
  96. $pos_all = 34;
  97. if ($count_all >= 10000000 && $count_all < 100000000)
  98. $pos_all = 29;
  99. if ($count_all >= 100000000 && $count_all < 1000000000)
  100. $pos_all = 24;
  101. if ($count_all >= 1000000000 && $count_all < 10000000000)
  102. $pos_all = 19;
  103. if ($count_all >= 10000000000 && $count_all < 100000000000)
  104. $pos_all = 14;
  105. ///////////////////////////////////////////////
  106. switch($img) {
  107. case 'mini':
  108. $im = @imagecreate(70, 14);
  109. $background_color = imagecolorallocate($im, 0, 0, 0);
  110. $text_color = imagecolorallocate($im, 255, 255, 255);
  111. ImageString($im, 1, 3, 3, "+$count", $text_color);
  112. ImageString($im, 1, 49, 3, "Mobilka.Us", $text_color);
  113. header("Content-type: image/png");
  114. ImagePNG($im);
  115. break;
  116. default:
  117. $im = ImageCreateFromGIF('counter.gif');
  118. $black = ImageColorAllocate($im,100,50,170);
  119. /*ImageString($im,1,$hpos,9,$chost,$black);*/
  120. ImageString($im,1,$pos,14,$count,$black);
  121. ImageString($im,1,$pos_all,21,$count_all,$black);
  122. header("Content-type: image/png");
  123. ImagePNG($im);
  124. break;
  125. }
  126. }
  127. else
  128. {
  129. print "ID = ???";
  130. }
  131. ?>