Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Pomoc z rating system.
Forum PHP.pl > Forum > PHP
Mieczu
Witam, niedawno znalazłem skrypt php pozwalający na oddawanie swojej oceny. Wszystko działa w porządku, ale w skrypcie tym można oddawać ocenę tylko dla jednej rzeczy/strony. Czy mógłby mi ktoś pomóc w stowrzeniu czegoś typu tego, że wpisując rate.php?id=x (rate.php to przykładowy plik ze skryptem) oddaje się inną niezależną ocenę?

Tu daję link do całego skryptu z obrazkami: http://www.scriptsez.net/download/download...em.zip&ns=1, a poniżej kod skryptu oceny:
  1. <? 
  2. extract($HTTP_GET_VARS);
  3. extract($HTTP_POST_VARS);
  4. /********* PHP RATING SYSTEM v1.5 ************ 
  5. Copyright Scriptsez.net 
  6. You have to leave the copyright. 
  7. If you have any problem just let us know.
  8. E-mail: support@scriptsez.net
  9. Website: <a href=\"http://www.scriptsez.net\" target=\"_blank\">http://www.scriptsez.net</a>
  10. **********************************************/ 
  11. $ficdest=explode(".",basename($PHP_SELF)); 
  12. $ficdest=$ficdest[0].".dat"; 
  13. $ip = getenv(REMOTE_ADDR); 
  14. if(file_exists($ficdest)) { 
  15.  $compteur=fopen($ficdest, "r"); 
  16.  $old_stats=file($ficdest); 
  17.  $stats=explode("|", $old_stats[0]); 
  18.  fclose($compteur); 
  19.  $new_count=$stats[0]; 
  20.  if ($stats[3] != $ip) { 
  21.  $new_count +=1; 
  22.  } 
  23.  $ip_hit=$ip; 
  24.  $compteur=fopen($ficdest, "w"); 
  25.  fputs($compteur, "$new_count|$stats[1]|$stats[2]|$ip_hit|$stats[4]"); 
  26.  fclose($compteur); 
  27. } 
  28. else { 
  29.  $nouveau_compteur=fopen($ficdest, "w"); 
  30.  fputs($nouveau_compteur, "1|||$ip|"); 
  31.  fclose($nouveau_compteur); 
  32. } 
  33.  
  34. if (!empty($envoi)) { 
  35.  $vote=fopen($ficdest, "r"); 
  36.  $old_stats=file($ficdest); 
  37.  $stats=explode("|", $old_stats[0]); 
  38.  fclose($vote); 
  39.  $nbr_votes=$stats[1]; 
  40.  $moy_votes=$stats[2]; 
  41.  if ($stats[4] != $ip) { 
  42.  $nbr_votes +=1; 
  43.  $moy_votes=((($stats[1]*$stats[2])+$note)/$nbr_votes); 
  44.  } 
  45. else { echo "<font face=Verdana size=2 color=red>You have already voted</font>"; } 
  46.  $ip_vote=$ip; 
  47.  $vote=fopen($ficdest, "w"); 
  48.  $new_stats=fputs($vote, "$new_count|$nbr_votes|$moy_votes|$stats[3]|$ip_vote"); 
  49.  fclose($vote); 
  50. } 
  51.  
  52. print ("<form method=post>"); 
  53. $old_stats=file($ficdest); 
  54. $stats=explode("|", $old_stats[0]); 
  55. if ($stats[2] == 5)
  56. {
  57. $star = "images/5star.gif" ;
  58. }
  59. if ($stats[2]>=1)
  60. {
  61. $star = "images/1star.gif" ;
  62. }
  63. if ($stats[2]>=1.5)
  64. {
  65. $star = "images/15star.gif" ;
  66. }
  67. if ($stats[2]>=2)
  68. {
  69. $star = "images/2star.gif" ;
  70. }
  71. if ($stats[2]>=2.5)
  72. {
  73. $star = "images/25star.gif" ;
  74. }
  75. if ($stats[2]>=3)
  76. {
  77. $star = "images/3star.gif" ;
  78. }
  79. if ($stats[2]>=3.5)
  80. {
  81. $star = "images/35star.gif" ;
  82. }
  83. if ($stats[2] >= 4)
  84. {
  85. $star = "images/4star.gif" ;
  86. }
  87. if ($stats[2] >= 4.5)
  88. {
  89. $star = "images/45star.gif" ;
  90. }
  91. if ($stats[2] >= 5)
  92. {
  93. $star = "images/5star.gif" ;
  94. }
  95. if ($stats[2]<=0)
  96. {
  97. $star = "images/00star.gif" ;
  98. }
  99. print ("<table bordercolor=#99999 cellspacing=0 border=0><td width=50% cellspacing=none cellpadding=none align=middle valign=middle border=1><font size=1 face=Verdana color=#999999>Rating: <img src=\"$star\" alt=\"Average rating: $stats[2]\"> $stats[1] Ratings</td><tr></font>");
  100. echo"<td align=middle valign=middle><input type=radio name=note value=5><font face=arial size=2 color=#99999>Excellent";
  101. echo"<input type=radio name=note value=4>Very Good";
  102. echo"<input type=radio name=note value=3>Good";
  103. echo"<input type=radio name=note value=2>Fine";
  104. echo"<input type=radio name=note value=1>Bad";
  105. print ("<input type=hidden name=envoi value=1> <input type=submit value=Rate style=background:#ffcc00;border-width:1;Border-color:#ffcc00;></table></form></font></td>");
  106.  
  107. ?>
Mieczu
Dzięki za pomoc, już to rozwiązałem w inny sposób.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.