Jump to content

[SOLVED] [img] bbcode tags: only allow images from local server


sbourdon

Recommended Posts

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!  ;)

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.