Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]$name w skrypcie generowane na podstawie godziny oraz adresu witryny.
Forum PHP.pl > Forum > Przedszkole
kedzier11
Witam mam taki skrypt:
  1. <?
  2. /*
  3.  
  4. PHPSOFT.ORG 5-STARS RATING SCRIPT !
  5. Script developed by SqrtBoy (sqrtboy@phpsoft.org)
  6. */
  7.  
  8. function rate($name)
  9. {
  10.  
  11. if (file_exists("votes/$name.txt")) {
  12.  
  13. $fp = fopen("votes/$name.txt", "r");
  14. $ligne = fgets($fp,4096);
  15.  
  16. //we retrieve variables
  17.  
  18. $tt_votes = strrchr($ligne, "|");
  19. $tt_votes = str_replace("|", "", $tt_votes);
  20. $tt_votes = trim($tt_votes);
  21.  
  22. $ligne = strrev($ligne);
  23. $nb_votes = strrchr($ligne, "|");
  24. $nb_votes = strrev($nb_votes);
  25. $nb_votes = str_replace("|", "", $nb_votes);
  26. $nb_votes = trim($nb_votes);
  27.  
  28. fclose($fp);
  29.  
  30. // Calculs :
  31.  
  32. if (($tt_votes == 0) AND ($nb_votes == 0))
  33. {
  34. // Si fichier vide
  35. $etoiles_oui = 0;
  36. $note = "0.00";
  37. }
  38. else
  39. {
  40. $moy_en = $tt_votes/$nb_votes;
  41. $etoiles = round($moy_en);
  42. $note = round($moy_en, 2);
  43. }
  44.  
  45. $Result = "<table border='0' width='100%' ><tr><td width='70%'>";
  46.  
  47. if ($nb_votes > 0)
  48. {
  49. $Result .="<img src=\"rating/".$etoiles."stars.gif\" border=\"0\" alt=\"Rate\">";
  50. $Result .=" <font size=1><strong>ocena: ".$note." / 5</strong>";
  51. $Result.=" - <strong>ilosc glosow: ".$nb_votes."</strong></font>";
  52. }
  53. else $Result .="<font size=1><strong>Zagłosuj</strong></font> ";
  54.  
  55. if (!isset($_COOKIE[$name]))
  56. {
  57. $Result.="</td>";
  58. $Result.="<td width=\"30%\" align=left>
  59. <form action=\"takerate.php?name=$name\" method=\"post\" onSubmit=\"alert('Dziekuje za twoj glos');\" ><select name=\"note\">";
  60. $Result.="<option value =\"5\">5</option>";
  61. $Result.="<option value =\"4\">4</option>";
  62. $Result.="<option value =\"3\">3</option>";
  63. $Result.="<option value =\"2\">2</option>";
  64. $Result.="<option value =\"1\">1</option>";
  65. $Result.="<option value =\"0\">0</option>";
  66. $Result.="</select>";
  67. $Result.=" <input type=\"submit\" value=\"ocen\"></form>";
  68. }
  69. else $Result.="<font size=1><strong> - juz to oceniles</strong></font>";
  70.  
  71. $Result.="</td></tr></table>";
  72. }
  73. else
  74. {
  75. $Result = "<table border='0' width='100%'><tr><td width=\"20%\">";
  76. $Result.="<strong><font size=1>Brak glosow, badz pierwszy</font></strong></td>";
  77. $Result.="<td width=\"80%\" align=left><form name=\"rate\" action=\"takerate.php?name=$name\" method=\"post\" onSubmit=\"alert('Dziekujemy za Twoj glos!');\" > <select name=\"note\" style=\"margin: 0; font-size: 2 pt; font-family: Verdana; border: 0\">";
  78. $Result.="<option value =\"5\">5</option>";
  79. $Result.="<option value =\"4\">4</option>";
  80. $Result.="<option value =\"3\">3</option>";
  81. $Result.="<option value =\"2\">2</option>";
  82. $Result.="<option value =\"1\">1</option>";
  83. $Result.="<option value =\"0\">0</option>";
  84. $Result.="</select>";
  85. $Result.=" <input type=\"submit\" value=\"ocen\">";
  86. $Result.="</form></td></tr></table>";
  87. }
  88.  
  89. return $Result;
  90. }
  91. ?>
chciałbym aby przy wywołaniu nie było potrzeby podawania ręcznie parametru $name tylko aby generował się on automatycznie na podstawie adresu witryny oraz godziny. Czy da się? Czy ktoś ma pomysły?
Turson
  1. $name = $_SERVER['REQUEST_URI'].date("Y-m-d");
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.