Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Konwersja tekstu na encje i odwrotnie i textarea
tosiek
post
Post #1





Grupa: Zarejestrowani
Postów: 142
Pomógł: 0
Dołączył: 7.07.2008

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


Witam. Mam pytanie, jak prze konwertować tekst na encje i odwrotnie ? (zarówno tekstowe jak i liczbowe, jest jakas funkcja w php ?)

Oraz mam pytanie jak pobrać dane z text area oraz wczytać plik tak aby nie dało się wykonać kodu 9php, html etc) ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
marcio
post
Post #2





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Ad 2:
  1. <?php
  2. if(!empty($_POST['file']) && isset($_POST['edytuj'])) {
  3.  
  4.  
  5. if(is_readable($_POST['file'])) {
  6. $zawartosc = fread(fopen($_POST['file'], 'r'), filesize($_POST['file']));
  7.  //$zawartosc = stripslashes($zawartosc);
  8.                    
  9. <form method="post" action="'.$_SERVER['PHP_SELF'].'">
  10. <table align="center" width="75%" style="border: 1px dotted white;">
  11. <tr><td align="center">Plik: '.$_POST['file'].'</td></tr>
  12. <tr><td align="center">
  13. <textarea name="msg" rows="20" cols="125" style="background-color:#000000; color:#CCCCCC;">'
  14. .strtr($zawartosc, array('</textarea>' => '<CLOSE_TA>')).'</textarea></td></tr>
  15. <input type="hidden" name="file" value="'.$_POST['file'].'">
  16. <tr>
  17. <td align="center"><input type="submit" name="akt" value="Aktualizuj" style="font-style:italic; background-color:#000000; color:#00A54E;"/></td></tr>
  18. </form>');
  19.  }
  20. }
  21.  
  22. if(!empty($_POST['msg']) && isset($_POST['akt'])) {
  23. if(is_writable($_POST['file'])) {
  24.  $fp = fopen($_POST['file'], 'w');
  25.   $data = strtr($_POST['msg'], array('<CLOSE_TA>' => '</textarea>'));
  26.    fwrite($fp, $data);
  27.     @fclose($_POST['file']);
  28.      echo('<script>alert("Dodano");</script>');
  29.  }
  30.  
  31. if(!is_writable($_POST['file']))
  32. echo('<tr><td align="center"><b style="color:#f00">Plik '.$_POST['file'].' nie ma praw zapisu</b></td></tr></table>');
  33.  }
  34. }
  35. ?>

Zobacz zamykanie tagow.

Ad 1 chodzi ci o htmlspecialchars() lub htmlentities()?

Ten post edytował marcio 13.03.2009, 20:10:54
Go to the top of the page
+Quote Post
tosiek
post
Post #3





Grupa: Zarejestrowani
Postów: 142
Pomógł: 0
Dołączył: 7.07.2008

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


a czy mogę również korzystać z file_get_contents(bezpiecznie) ?

chbya to będą te dwa, potestuje to sie dowiem, dzięki
http://us3.php.net/manual/pl/function.html-entity-decode.php
http://us3.php.net/manual/pl/function.htmlentities.php

Ten post edytował tosiek 13.03.2009, 20:25:26
Go to the top of the page
+Quote Post
marcio
post
Post #4





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Cytat
a czy mogę również korzystać z file_get_contents(bezpiecznie) ?

Nie wiem nigdy tej funckji nie uzywam ale mysle ze na to samo wyjdzie (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
Go to the top of the page
+Quote Post
tosiek
post
Post #5





Grupa: Zarejestrowani
Postów: 142
Pomógł: 0
Dołączył: 7.07.2008

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


hmm... a jak przerobić za pomocą htmlentities na liczbowe encje (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) ?
Go to the top of the page
+Quote Post
marcio
post
Post #6





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Cytat(tosiek @ 13.03.2009, 20:38:19 ) *
hmm... a jak przerobić za pomocą htmlentities na liczbowe encje (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) ?

A co masz na mysli mowiac liczbowe encje??
Go to the top of the page
+Quote Post
tosiek
post
Post #7





Grupa: Zarejestrowani
Postów: 142
Pomógł: 0
Dołączył: 7.07.2008

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


Liczowa: &
Tekstowa &amp;
Wynik: &



Znalazłem opcję ale... nie wiem jak zainstalować: ICU

http://pl.php.net/unicode_decode

Ten post edytował tosiek 14.03.2009, 14:20:41
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 27.09.2025 - 20:10