witam

mam problem z liczeniem glosow w sondzie w jportalu. dodawane sa glosy ktore nie sa liczone jako jedna z odpowiedzi. mam 600 glosow w sondzie, a na wykresie pokazuje 50, reszta powoduje ze wykres pokazuje zle wartosci. chcialbym to jakos zabezpieczyc przed takim spamowaniem, ale nie wiem jak. ponizej zamieszczam kod sondy.

  1. <?php
  2.  
  3. /*****************************************************/
  4. /* jPORTAL - internetowy system portalowy  */
  5. /*****************************************************/
  6. /* autor: Pawel 'jaco' Jaczewski  */
  7. /* email: info@websys.pl  */
  8. /*****************************************************/
  9.  
  10.  
  11. function count_poll($id, $val)
  12. {
  13. global $poll_a_tbl, $poll_b_tbl, $poll_err;
  14.  
  15.  
  16. if($_COOKIE['poll_cookie_'.$id]<>10)
  17. {
  18.  
  19. setcookie('poll_cookie_'.$id, 10, time()+3600*12);
  20.  
  21. if($val<>'')
  22. {
  23. mysql_query("UPDATE $poll_a_tbl SET votes=votes+1 WHERE id='$id'");
  24. mysql_query("UPDATE $poll_b_tbl SET count=count+1 WHERE vid='$id' AND value='$val'");
  25.  
  26. $poll_err = ' - <b>Dzięki za oddanie głosu!</b>';
  27. }
  28. else
  29. {
  30. $poll_err = ' - <b>Zaznacz jakąś odpowiedź!</b>';
  31. }
  32. }
  33. else
  34. {
  35. $poll_err = ' - <b>Nie możesz głosować 2 razy!</b>';
  36. }
  37. }
  38.  
  39.  
  40.  
  41. function poll_result($id='no')
  42. {
  43. global $poll_a_tbl, $poll_b_tbl, $theme;
  44.  
  45. if($id<>'no')
  46. {
  47. $query = "SELECT * FROM $poll_a_tbl WHERE id='$id'";
  48. }
  49. else
  50. {
  51. $query = "SELECT * FROM $poll_a_tbl ORDER BY id DESC LIMIT 1 ";
  52. }
  53.  
  54. //
  55.  
  56. $res = mysql_query($query);
  57. $r  = mysql_fetch_assoc($res);
  58.  
  59. $votes = $r['votes'];
  60.  
  61.  
  62. echo '<table width="99%" border="0" align="center">
  63. <tr>
  64. <td class="uni_01" colspan="2"><center><b>'.$r['title'].'</b>
  65.  
  66. </td>
  67. </tr>';
  68.  
  69. $res = mysql_query("SELECT * FROM $poll_b_tbl WHERE vid='{$r['id']}' ORDER BY value");
  70.  
  71. $img[0] = file_exists('theme/'.$theme.'/gfx/poll_l.gif') ? '<img src="theme/'.$theme.'/gfx/poll_l.gif">' : '';
  72. $img[3] = file_exists('theme/'.$theme.'/gfx/poll_r.gif') ? '<img src="theme/'.$theme.'/gfx/poll_r.gif">' : '';
  73.  
  74. while($r = mysql_fetch_assoc($res))
  75. {
  76.  
  77. if($r['title']<>'')
  78. {
  79.  
  80.  
  81. if($votes<>0)
  82. {
  83. $a = $r['count'] / $votes;
  84. $a = $a * 100;
  85. $a = round($a);
  86. $b = $a * 2;
  87. $c = 200 - $b;
  88. }
  89. else
  90. {
  91. $a = 0;
  92. $b = 0;
  93. $c = 0;
  94. }
  95.  
  96. $img[1] = $b==0 ? '' : '<img src="theme/'.$theme.'/gfx/poll.gif" height="12" width="'.$b.'">';
  97. $img[2] = $c==0 ? '' : '<img src="theme/'.$theme.'/gfx/poll2.gif" height="12" width="'.$c.'">';
  98.  
  99. ksort($img);
  100.  
  101. echo '<tr>
  102. <td class="uni_01" width="30%">- '.$r['title'].'</td>
  103. <td class="uni_01">'.join('', $img).' '.$a.'% ('.$r['count'].')</td>
  104. </tr>';
  105.  
  106. }
  107. }
  108.  
  109. echo '
  110. <table width="90%" border="0" align="center">
  111. <tr>
  112. <td class="uni_01" colspan="2">
  113.  
  114. <center>łącznie głosów: <b>'.$votes.'</b></td>
  115. </tr>
  116. </table>';
  117.  
  118. }
  119.  
  120.  
  121. function old_poll()
  122. {
  123. global $poll_a_tbl, $poll_b_tbl, $theme;
  124.  
  125. $res = mysql_query("SELECT * FROM $poll_a_tbl ORDER BY id DESC");
  126.  
  127. if(mysql_num_rows($res)>1)
  128. {
  129. echo '<hr size="1" noshade><center><b>Stare sondy</b></center><hr size="1" noshade>
  130. ';
  131.  
  132. while($r = mysql_fetch_assoc($res))
  133.  
  134. {
  135. poll_result($r['id']);
  136. echo '<hr size="1" noshade>
  137. ';
  138. }
  139.  
  140.  
  141. }
  142. }
  143.  
  144.  
  145. ?>