bob_the _builder Posted September 26, 2006 Share Posted September 26, 2006 Hi,When converting [url=http://tags whats the correct format:[code=php:0]"[url]" => "<a href='","] tags whats the correct format:[code=php:0]"[url]" => "<a href='","[/url]" => "'></a>",[/code]how can you allow words between '> </a>and is there security risk, should the url some how be cleaned before inserting into the database?so far user input is been cleaned via:[code=php:0]function ValidateInput($value) { $value = mysql_real_escape_string(trim(strip_tags($value))); return $value;[/code]Thanks Link to comment https://forums.phpfreaks.com/topic/22069-bbcode-url/ Share on other sites More sharing options...
Daniel0 Posted September 26, 2006 Share Posted September 26, 2006 [code]<?phpfunction parse_url_bbcode($string){ $string = preg_replace("/\[url\](.*)\[\/url\]/","<a href='\\1'>\\1</a>",$string); $string = preg_replace("/\[url=(.*)\](.*)\[\/url\]/","<a href='\\1'>\\2</a>",$string); return $string;}echo parse_url_bbcode("[url=http://phpfreaks.com/forums]PHP Freaks[/url]")."<br />\n";echo parse_url_bbcode("[url]http://phpfreaks.com[/url]");?>[/code]The output would be: [code]<a href='http://phpfreaks.com/forums'>PHP Freaks</a><br /><a href='http://phpfreaks.com'>http://phpfreaks.com</a>[/code] Link to comment https://forums.phpfreaks.com/topic/22069-bbcode-url/#findComment-98738 Share on other sites More sharing options...
bob_the _builder Posted September 26, 2006 Author Share Posted September 26, 2006 Hi,I got:[code=php:0]$value = preg_replace("/\[url=http://(.*)\](.*)\[\/url\]/","<a href='\\1'>\\2</a>",$value);[/code]and wrap url with:[nobbc][url=http://www.phpfreaks.com/forums/index.php?action=post;topic=109508.0;num_replies=1]phpfreaks[/url][/nobbc]Does the trick thanks Link to comment https://forums.phpfreaks.com/topic/22069-bbcode-url/#findComment-98768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.