Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Księga gości i polskie znaki, zmiana pliku tak aby wysylal polskie zna
zjedzony_przez_p...
post 30.03.2006, 20:43:35
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 30.03.2006

Ostrzeżenie: (0%)
-----


mam tutaj taki skrypcik ksiege gosci tylko nie wiem jak zrobic tak zeby mozna bylo wpisywac polskie znaki jak śćńąęźżłó oraz znaki specjalne prosze o modyfikacje tego pliku z gory dziekuje

  1. <?
  2. ############### .::Comments are indicated by the # symbol - you can erase all of these if needed.
  3. ############### .::Author: Jeffrey F. Hill
  4. ############### .::Website: www.Flash-dB.com
  5.  
  6. ############### Begin GuestBook Script #####################################
  7.  
  8. ##The first 3 lines use a regular expression to match a pattern then replace it 
    with nothing. The only reason for this is so we only allow necessary characters to be entered 
    into the guestbook. This also takes out slashes which are sometimes added in the 
    post headers to make the string friendly. You can erase or take these lines out if you want.
  9.  
  10. $Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
  11. $Email = ereg_replace("[^A-Za-z0-9 \@\.\-\/']", "", $Email);
  12. $Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/']", "", $Comments);
  13.  
  14. $Website = eregi_replace("http://", "", $Website);
  15. $Website = ereg_replace("[^A-Za-z0-9 \@\.\-\/'\~\:]", "", $Website);
  16.  
  17. $Name = stripslashes($Name);
  18. $Email = stripslashes($Email);
  19. $Website = stripslashes($Website);
  20. $Comments = stripslashes($Comments);
  21.  
  22. ################################################################################
    ####
  23. ########### Reading and Writing the new data to the GuestBook Database #########
    ####
  24.  
  25. if ($Submit == "Yes") {
  26. #Next line tells the script which Text file to open.
  27. $filename = "GuestBook.txt";
  28.  
  29. #Opens up the file declared above for reading 
  30.  
  31. $fp = fopen( $filename,"r"); 
  32. $OldData = fread($fp, 80000); 
  33. fclose( $fp ); 
  34.  
  35. #Gets the current Date of when the entry was submitted
  36. $Today = (date ("l dS of F Y ( h:i:s A )",time()));
  37.  
  38. #Puts the recently added data into html format that can be read into the Flash M
    ovie.
  39.  
  40. $Input = "Imie: $Name<br>Email: <u><a href=\"mailto:$Email\">$Email</a></u><br>Strona: <u><a href=\"http://$Website\" target=\"_blank\">$Website</a></u><br>Komentarz: $Comments<br><i><font size=\"-1\">Data wpisu: $Today</font><br><br>.:::.";
  41.  
  42. #This Line adds the 'GuestBook=' part to the front of the data that is stored in the text file. This is important because without this the Flash movie would not be able to assi
    gn the variable 'GuestBook' to the value that is located in this text file 
  43.  
  44. $New = "$Input$OldData";
  45.  
  46. #Opens and writes the file.
  47.  
  48. $fp = fopen( $filename,"w+"); 
  49. fwrite($fp, $New, 80000); 
  50. fclose( $fp ); 
  51. }
  52. ################################################################################
    ####
  53. ########## Formatting and Printing the Data from the Guestbook to the Flash Movi
    e ##
  54.  
  55. #Next line tells the script which Text file to open.
  56. $filename = "GuestBook.txt";
  57.  
  58. #Opens up the file declared above for reading 
  59.  
  60. $fp = fopen( $filename,"r"); 
  61. $Data = fread($fp, 80000); 
  62. fclose( $fp );
  63.  
  64. #Splits the Old data into an array anytime it finds the pattern .:::.
  65. $DataArray = split (".:::.", $Data);
  66.  
  67. #Counts the Number of entries in the GuestBook
  68. $NumEntries = count($DataArray) - 1;
  69.  
  70. print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
  71. for ($n = $NumLow; $n < $NumHigh; $n++) {
  72. print $DataArray[$n];
  73. if (!$DataArray[$n]) {
  74. Print "<br><br>No More entries";
  75. }
  76. }
  77.  
  78.  
  79.  
  80. ################################################################################
    ####
  81. ############### End GuestBook Script
  82. ?>
Go to the top of the page
+Quote Post
lenczewski
post 30.03.2006, 21:02:50
Post #2





Grupa: Zarejestrowani
Postów: 159
Pomógł: 1
Dołączył: 31.08.2005

Ostrzeżenie: (0%)
-----


do wszystkich [^A-Za-z pododawaj śćńąęźżłó, czyli np. [^A-Za-zśćńąęźżłó]


--------------------
Go to the top of the page
+Quote Post
zjedzony_przez_p...
post 30.03.2006, 23:11:47
Post #3





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 30.03.2006

Ostrzeżenie: (0%)
-----


niestety to nie dziala wyskakuje blad na serwerze php Parse error: parse error, unexpected T_VAR in .....adres...styony...GuestBook.php on line 17
Go to the top of the page
+Quote Post
-Guest-
post 31.03.2006, 07:30:34
Post #4





Goście







a ja sprobowale,m rozwiazec problem i jak uruchamiam strypt to wyswietla sie tylko &TotalEntries=0&NumLow=&NumHigh=&GuestBook=

plik GuestBook.txt utworzylem w tym samym katalogu

z polskimi znakami to uzyj: eregi_replace kodowane ą na ą
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 18.07.2025 - 00:24