sbourdon Posted March 30, 2007 Share Posted March 30, 2007 Hello, I want to modify the bbcode tag so that only images available on the local server are allowed. I've installed a little modification to upload images and therefore, I want to make sure that users do not try to bypass this system and include links to external images in their posts using the tags... What I would need to do is the following: 1. check if the bbcode is used in the message ($message); 2. check if the server address appears between the tags ($board_config['server_name']); 3. if YES, execute code; if NO, display an error message. Unfortunately, I'm new to this... Would someone be kind enough to help me with this? Thank you very much! Quote Link to comment Share on other sites More sharing options...
sbourdon Posted March 30, 2007 Author Share Posted March 30, 2007 Got it! In bbcode.php: replaced // [img] $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text); with // [img=image_url_here] code.. if ((strstr($text, 'servername')) == FALSE) { $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'SORRY - LINKED EXTERNAL IMAGE REMOVED'", $text); } else { $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text); } Simply replace 'servername' with your... server name! Thanks, Minc! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.