mam pytanie odnośnie kody php znajdującego się w systemie newsów PS News
jest problem, gdy dodaje w newsie za długi link, wtedy po kliknięciu w link otwiera sie w nowym oknie pusta strona bo w adresie jest dodatkowa spacja, która wszystko komplikuje.
znalazłem w pliku "functions.php" takie coś:

  1. <?php
  2. function pscode($string){
  3. //formatowanie
  4. $string = preg_replace("'(.*)'si","<b>1</b>", $string);
  5. $string = preg_replace("'(.*)'si","<i>1</i>", $string);
  6. $string = preg_replace("'(.*)'si","<u>1</u>", $string);
  7. $string = preg_replace("'
    (.*)
    'si"
    ,"<center>1</center>", $string);
  8. $string = preg_replace("'*)](.*)'si", "<font color="1">2</font>",$string);
  9. //obrazek 
  10. $string = preg_replace("'[img]([0-9a-zA-Z~`!@#$%^&-_=+|/:;]*)[/img]'si","<img src="1" border=0>", $string);
  11. //url'e
  12. $string = preg_replace("'([a-zA-Z0-9-_.]*)'si","<a href="http://1" target="_blank">1</a>", $string);
  13. 'si","<a href="1" target="_blank">1</a>", $string);
  14. 'si","<a href="mailto:1">1</a>", $string);
  15. 'si", "<a href="mailto:1">2</a>", $string);
  16. .'si", "<a href="http://1" target="_blank">2</a>", $string);
  17. 'si", "<a href="1" target="_blank">2</a>", $string);
  18.  
  19. //na wypadek, gdyby za wcześnie ucięło string'a
  20. $string = preg_replace("'[b](.*)'si","<b>1</b>", $string);
  21. $string = preg_replace("'[i](.*)'si","<i>1</i>", $string);
  22. $string = preg_replace("'[u](.*)'si","<u>1</u>", $string);
  23. $string = preg_replace("'[center](.*)'si","<center>1</center>", $string);
  24. $string = preg_replace("'[img]([0-9a-zA-Z~`!@#$%^&-_=+|/:;]*)'si","<img src="1" border=0>", $string);
  25. $string = preg_replace("'[color=([a-zA-Z1-9#(),]*)](.*)'si", "<font color="1">2</font>",$string);
  26. ?>


nie znam sie na php, ale moim zdaniem pod komentarzem "na wypadek, gdyby za wcześnie ucięło string'a" powinien być jeszcze kod dotyczący URL-a... niestety nie mam pojęcia jak on powinien wyglądać.

to samo dotyczy linków w komentarzach, jak ktoś wklei http-jakis-link-do-strony.html to ten tekst nie jest linkiem, a w środku jest spacja, której nie powinno być, mi już nie zależy na tych komentarzach, ale żeby w newsach można było dać normalnie działającego linka...


Proszę o pomoc.