Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: bbcode
Forum PHP.pl > Forum > PHP
zaba12
ehh nie wiem juz co mam robic

Cytat
Parse error: syntax error, unexpected T_STRING in H:\n\functions.php on line 78



  1. <? function bbcode($text)
  2. {
  3. $str = " " . $text;
  4. $str = preg_replace("#(.*?)#si", "<b>1</b>", $str);
  5. $str = preg_replace("#(.*?)#si", "<i>1</i>", $str);
  6. $str = preg_replace("#(.*?)#si", "<u>1</u>", $str);
  7. $str = preg_replace("#[sm](.*?)[/sm]#si", "<small>1</small>", $str);
  8. $str = preg_replace("#[big](.*?)[/big]#si", "<big>1</big>", $str);
  9. $str = preg_replace("/[p](.*?)[/p]/si", "<p>1</p>", $str);
  10. $str = preg_replace("#[p=(http://)?(.*?)](.*?)[/p]#si", "<p align="2">3</p>", $str);
  11. $str = preg_replace("/
    (.*?)
    /si"
    , "<center>1</center>", $str);
  12. $str = preg_replace("#(.*?)#si", "<span style="color:2">3</span>", $str);
  13. $str = preg_replace("#(.*?)#si", "<span style="font-size:2">3</span>", $str);
  14. $str = preg_replace("#[img](.*?)[/img]#si", "<img src="1" border="0" alt="Obrazek" />", $str);
  15. $str = preg_replace("#[ftp_img](.*?)[/ftp_img]#si", "<img src="img/1" border="0" alt="Obrazek" />", $str);
  16. $str = preg_replace("#[hr=(d{1,2}|100)]#si", "<hr class="linia" width="1%">", $str);
  17. $str=str_replace('&nbsp;','&nbsp;',$str);
  18. // znaki specjalne
  19. $str = str_replace('&amp;plusmn;', '&plusmn;', $str);
  20. $str = str_replace('&amp;trade;', '&trade;', $str);
  21. $str = str_replace('&amp;bull;', '&bull;', $str);
  22. $str = str_replace('&amp;deg;', '&deg;', $str);
  23. $str = str_replace('&amp;copy;', '&copy;', $str);
  24. $str = str_replace('&amp;reg;', '&reg;', $str);
  25. $str = str_replace('&amp;hellip;', '&hellip;', $str);
  26.  
  27. // błędne kodowanie m.in. z phpmyadmina
  28. $str = str_replace('&amp;#261;', 'ą', $str);
  29. $str = str_replace('&amp;#263;', 'ć', $str);
  30. $str = str_replace('&amp;#281;', 'ę', $str);
  31. $str = str_replace('&amp;#322;', 'ł', $str);
  32. $str = str_replace('&amp;#347;', 'ś', $str);
  33. $str = str_replace('&amp;#378;', 'ź', $str);
  34. $str = str_replace('&amp;#380;', 'ż', $str);
  35.  
  36. // znaki specjalne z m$ word
  37. $str = str_replace('&amp;#177;', 'ą', $str);
  38. $str = str_replace('&amp;#8217;', ''', $str);
  39. $str = str_replace('&amp;#8222;', '"', $str);
  40. $str = str_replace('&amp;#8221;', '"', $str);
  41. $str = str_replace('&amp;#8220;', '"', $str);
  42. $str = str_replace('&amp;#8211;', '-', $str);
  43. $str = str_replace('&amp;#8230;', '&hellip;', $str);
  44. $str = preg_replace("#[code](.*?)[/code]#si", "<p class="kod"><u><b>Kod:</b></u><br/>1</p>", $str);
  45. $str = preg_replace("#[quote](.*?)[/quote]#si", "<p class="cytat"><u><b>Cytat:</b></u><br/>1</p>", $str);
  46. $str = preg_replace("#<p class="cytat"><u><b>Cytat (http://)?(.*?):</b></u><br/>(.*?)</p>#si", "<p class="cytat"><u><b>Cytat 2:</b></u><br/>3</p>", $str);
  47. $str = preg_replace("#([a-z0-9-_.]+?)@([w-]+.([w-.]+.)?[w]+)#i", "<a href="mailto:1@2">1@2</a>", $str);
  48. $str = preg_replace("#[email=([a-z0-9-_.]+?)@([w-]+.([w-.]+.)?[w]+)?(.*?)](.*?)[/email]#i", "<a href="mailto:1@2">5</a>", $str);
  49. $str = preg_replace("#(.*?)?(.*?)#si", "<A HREF="12" TARGET="_blank">12</A>", $str);
  50. $str = preg_replace("#(.*?)#si", "<A HREF="2" TARGET="_blank">3</A>", $str);
  51. $str = preg_replace("#[url2](.*?)?(.*?)[/url2]#si", "<A HREF="12">12</A>", $str);
  52. $str = preg_replace("#[url2=(.*?)?(.*?)](.*?)[/url2]#si", "<A HREF="2">3</A>", $str);
  53. $str = preg_replace("#([n ])www.([a-z0-9-]+).([a-z0-9-.~]+)((?:/[a-z0-9-.,?!%*_#:;~&$@/=+]*)?)#i", " <a href="http://www.2.34" target="_blank">www.2.34</a>", $str);
  54. $str = preg_replace("#([n ])([a-z0-9-_.]+?)@([w-]+.([w-.]+.)?[w]+)#i", "1<a href="java_script:mailto:mail('2','3');">2_(at)_3</a>", $str);
  55. $str = preg_replace_callback("#([n ])([a-z]+?)://([a-z0-9-.,?!%*_#:;~&$@/=+]+)#si", "bbcode_autolink", $str);
  56. $str=preg_replace_callback("#[php](.*?)[/php]#si", "bbcode_phpCode", $str);
  57. }
  58. ?>
Pigula
a ktora to jest 78 linia? bo ponumnerowane mam do linii 58 a potem nie jeszcze do tego dochodzi jeszcze zawijanie linii i ciezko jest mi sie w tym polapac winksmiley.jpg
Spirit86
  1. <? function bbcode($text)
  2. {
  3. $str = " " . $text;
  4. $str = preg_replace("#(.*?)#si", "<b>1</b>", $str);
  5. $str = preg_replace("#(.*?)#si", "<i>1</i>", $str);
  6. $str = preg_replace("#(.*?)#si", "<u>1</u>", $str);
  7. $str = preg_replace("#[sm](.*?)[/sm]#si", "<small>1</small>", $str);
  8. $str = preg_replace("#[big](.*?)[/big]#si", "<big>1</big>", $str);
  9. $str = preg_replace("/[p](.*?)[/p]/si", "<p>1</p>", $str);
  10. $str = preg_replace("#[p=(http://)?(.*?)](.*?)[/p]#si", "<p align="2">3</p>", $str);
  11. $str = preg_replace("/
    (.*?)
    /si"
    , "<center>1</center>", $str);
  12. $str = preg_replace("#(.*?)#si", "<span style="color:2">3</span>", $str);
  13. $str = preg_replace("#(.*?)#si", "<span style="font-size:2">3</span>", $str);
  14. $str = preg_replace("#[img](.*?)[/img]#si", "<img src="1" border="0" alt="Obrazek" />", $str);
  15. $str = preg_replace("#[ftp_img](.*?)[/ftp_img]#si", "<img src="img/1" border="0" alt="Obrazek" />", $str);
  16. $str = preg_replace("#[hr=(d{1,2}|100)]#si", "<hr class="linia" width="1%">", $str);
  17. $str=str_replace('&nbsp;','&nbsp;',$str);
  18. // znaki specjalne
  19. $str = str_replace('&amp;plusmn;', '&plusmn;', $str);
  20. $str = str_replace('&amp;trade;', '&trade;', $str);
  21. $str = str_replace('&amp;bull;', '&bull;', $str);
  22. $str = str_replace('&amp;deg;', '&deg;', $str);
  23. $str = str_replace('&amp;copy;', '&copy;', $str);
  24. $str = str_replace('&amp;reg;', '&reg;', $str);
  25. $str = str_replace('&amp;hellip;', '&hellip;', $str);
  26.  
  27. // błędne kodowanie m.in. z phpmyadmina
  28. $str = str_replace('&amp;#261;', 'ą', $str);
  29. $str = str_replace('&amp;#263;', 'ć', $str);
  30. $str = str_replace('&amp;#281;', 'ę', $str);
  31. $str = str_replace('&amp;#322;', 'ł', $str);
  32. $str = str_replace('&amp;#347;', 'ś', $str);
  33. $str = str_replace('&amp;#378;', 'ź', $str);
  34. $str = str_replace('&amp;#380;', 'ż', $str);
  35.  
  36. // znaki specjalne z m$ word
  37. $str = str_replace('&amp;#177;', 'ą', $str);
  38. $str = str_replace('&amp;#8217;', ''', $str);
  39. $str = str_replace('&amp;#8222;', '"', $str);
  40. $str = str_replace('&amp;#8221;', '"', $str);
  41. $str = str_replace('&amp;#8220;', '"', $str);
  42. $str = str_replace('&amp;#8211;', '-', $str);
  43. $str = str_replace('&amp;#8230;', '&hellip;', $str);
  44. $str = preg_replace("#[code](.*?)[/code]#si", "<p class="kod"><u><b>Kod:</b></u><br/>1</p>", $str);
  45. $str = preg_replace("#[quote](.*?)[/quote]#si", "<p class="cytat"><u><b>Cytat:</b></u><br/>1</p>", $str);
  46. $str = preg_replace("#<p class="cytat"><u><b>Cytat (http://)?(.*?):</b></u><br/>(.*?)</p>#si", "<p class="cytat"><u><b>Cytat 2:</b></u><br/>3</p>", $str);
  47. $str = preg_replace("#([a-z0-9-_.]+?)@([w-]+.([w-.]+.)?[w]+)#i", "<a href="mailto:1@2">1@2</a>", $str);
  48. $str = preg_replace("#[email=([a-z0-9-_.]+?)@([w-]+.([w-.]+.)?[w]+)?(.*?)](.*?)[/email]#i", "<a href="mailto:1@2">5</a>", $str);
  49. $str = preg_replace("#(.*?)?(.*?)#si", "<A HREF="12" TARGET="_blank">12</A>", $str);
  50. $str = preg_replace("#(.*?)#si", "<A HREF="2" TARGET="_blank">3</A>", $str);
  51. $str = preg_replace("#[url2](.*?)?(.*?)[/url2]#si", "<A HREF="12">12</A>", $str);
  52. $str = preg_replace("#[url2=(.*?)?(.*?)](.*?)[/url2]#si", "<A HREF="2">3</A>", $str);
  53. $str = preg_replace("#([n ])www.([a-z0-9-]+).([a-z0-9-.~]+)((?:/[a-z0-9-.,?!%*_#:;~&$@/=+]*)?)#i", " <a href="http://www.2.34" target="_blank">www.2.34</a>", $str);
  54. $str = preg_replace("#([n ])([a-z0-9-_.]+?)@([w-]+.([w-.]+.)?[w]+)#i", "1<a href="java_script:mailto:mail('2','3');">2_(at)_3</a>", $str);
  55. $str = preg_replace_callback("#([n ])([a-z]+?)://([a-z0-9-.,?!%*_#:;~&$@/=+]+)#si", "bbcode_autolink", $str);
  56. $str=preg_replace_callback("#[php](.*?)[/php]#si", "bbcode_phpCode", $str);
  57. }
  58. ?>

po zabawie
zaba12
a teraz mam problem nie dzial mi bbcode nie czyta znaczynikow ;/

Cytat
Tytuł:test Dodał: zaba Data: 0000-00-00 
TEST TEST YG [sm]Dfs[/sm] [big]dfds[/big] [p]Sdf[/p] [p=http://wp.pl]fsaf[/p]
asdasdas
Kod
KOD
Cytat
hjk
zaba141@o2.pl http://gamees.info [php]
ActivePlayer
moze na koncu funkcji return $str ?
zaba12
tak mam

  1. <?
  2.  
  3. $str = preg_replace("#([n ])([a-z0-9-_.]+?)@([w-]+.([w-.]+.)?[w]+)#i", "1<a href="java_script:mailto:mail('2','3');">2_(at)_3</a>", $str);
  4. $str = preg_replace_callback("#([n ])([a-z]+?)://([a-z0-9-.,?!%*_#:;~&$@/=+]+)#si", "bbcode_autolink", $str);
  5. $str=preg_replace_callback("#[php](.*?)[/php]#si", "bbcode_phpCode", $str);
  6. return($str);
  7. }
  8.  
  9. ?>


a do index.php dalem to

  1. <? bbcode($mala_tresc,$wlasciwa_tresc); ?>
aleksander
yhy smile.gif

<? function bbcode($text)

<? bbcode($mala_tresc,$wlasciwa_tresc); ?>

Chyba jeden parametr za duzo:)
zaba12
Ja zrobilem inaczej o tak

  1. <?
  2.  
  3. function bbcode($mala_tresc,$wlasciwa_tresc)
  4. {
  5. $mala_tresc = " ".$str;
  6. $str = " " . $wlasciwa_tresc;
  7. $str = " " . $text;
  8.  
  9. ?>
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.