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! Link to comment https://forums.phpfreaks.com/topic/44957-solved-img-bbcode-tags-only-allow-images-from-local-server/ 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! Link to comment https://forums.phpfreaks.com/topic/44957-solved-img-bbcode-tags-only-allow-images-from-local-server/#findComment-218321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.