AndzX8-842 Posted September 4, 2005 Report Share Posted September 4, 2005 (edited) Šādi parasti pārveido no BBcode uz html. $teksts = preg_replace('/[([biu])]/i', '<1>', $teksts); $teksts = preg_replace('/[/([biu])]/i', '</1>', $teksts); Ideja tāda, ka < un > varētu aizvietot ar < un >. $teksts = preg_replace("<", "<", $teksts); $teksts = preg_replace(">", ">", $teksts); $teksts = preg_replace('/[([biu])]/i', '<1>', $teksts); $teksts = preg_replace('/[/([biu])]/i', '</1>', $teksts); Principā vispirms visi < un > tiktu pārveidoti par < un >. Pēctam tiktu filtrētu BBcode. Gribēju pajautāt ko citi izmanto, lai veiktu to pašu uzdevumu un vai šis vispār droši? Edited September 4, 2005 by AndzX8-842 Link to comment Share on other sites More sharing options...
bubu Posted September 4, 2005 Report Share Posted September 4, 2005 izmantoju htmlspecialchars() Link to comment Share on other sites More sharing options...
AndzX8-842 Posted September 4, 2005 Author Report Share Posted September 4, 2005 (edited) Teiksim, ja kāds kaut ko iebleiztu datu bāzē ar <?php ?> tad arī tie tiktu aizvietoti ar < un > un nestrādātu, javascript laikam arī pazūd jēga, ja < un > tiek aizstāti. Tas htmlspecialchars() ir saprotams, ka visi < un > tiktu aizstāti vai tikai filtrē html tagus? Edited September 4, 2005 by AndzX8-842 Link to comment Share on other sites More sharing options...
Paulinjsh Posted September 4, 2005 Report Share Posted September 4, 2005 http://lv.php.net/htmlspecialchars Link to comment Share on other sites More sharing options...
bubu Posted September 4, 2005 Report Share Posted September 4, 2005 Ko nozīmē "filtrēt html tegus"? htmlspecialchars() iz manuāļa dara: The translations performed are: * '&' (ampersand) becomes '&' * '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. * ''' (single quote) becomes ''' only when ENT_QUOTES is set. * '<' (less than) becomes '<' * '>' (greater than) becomes '>' Link to comment Share on other sites More sharing options...
Kavacky Posted September 4, 2005 Report Share Posted September 4, 2005 Tagus filtrē strip_tags, šitais tikai pārveido simbolus. Link to comment Share on other sites More sharing options...
Recommended Posts