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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.