PDA

View Full Version : Limit Allow Dynamic URL for [IMG] Tags


dynamite
02-25-2004, 07:35 PM
Is there a way to limit users from being able to post Dynamic URLs in IMG tags unless they are in a certain group? I know I would need to edit the following in includes/functions_bbcodeparse.php:

$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"' . iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_img_match('\\1')", $bbcode);
---------------------------------------------
Could someone tell me if changing this line to the following would allow only that particular usergroup to post dynamic URLs:

$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"' . iif(!$vboptions['allowdynimg'] AND $bbuserinfo['usergroupid'] == 3, '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_img_match('\\1')", $bbcode);

dynamite
02-26-2004, 12:16 PM
Allright... my idea didn't work. I have tried about every combo possible (that I can think of) in here and it still will not limiting it to just the one particular group. Either it lets everone or no one still.

vbmechanic
02-26-2004, 12:25 PM
Your problem is that you're looking at $bbuserinfo (which is the VIEWER's info) instead of $post (which is the POSTER's info). So rather than checking the viewer's usergroupid, you should be checking the poster's usergroupid.

Above that line a few lines, add $post to the global variable line. Then try $post['usergroupid'] and see if that works.

Cheers

dynamite
02-26-2004, 04:39 PM
Thanks to vbmechanic for pointing me in the right direction. I had to make a few changes, but it is now working. If you want to allow only the administrator group (in this case group 6) to be able to post dynamic urls, just do the following:

Open includes/functions_bbcodeparse.php and find:

// ###################### Start bbcodeparseimgcode #######################
function handle_bbcode_img($bbcode, $dobbimagecode)
{
global $vboptions, $bbuserinfo;

if($dobbimagecode AND ($bbuserinfo['userid'] == 0 OR $bbuserinfo['showimages']))
{
// do https://vborg.vbsupport.ru/
$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"' . iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_img_match('\\1')", $bbcode);
}
$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_url('\\1', '', 'url')", $bbcode);

return $bbcode;
and replace with:
// ###################### Start bbcodeparseimgcode #######################
function handle_bbcode_img($bbcode, $dobbimagecode)
{
global $vboptions, $bbuserinfo, $post;

if($dobbimagecode AND ($bbuserinfo['userid'] == 0 OR $bbuserinfo['showimages']))
{
// do https://vborg.vbsupport.ru/
$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"' . iif($post['usergroupid'] !=6, '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_img_match('\\1')", $bbcode);
}
$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_url('\\1', '', 'url')", $bbcode);

return $bbcode;
}

This will allow whatever usergroup specified at $post['usergroupid'] !=6 to post dynamic URLs. With this change, it does not matter what the setting for Allow Dynamic URL for [IMG] Tag is set in the Administrators Control Panel as only the usergroup specified will be allowed. If you want a group other than the administrators to be able to post dynamic URLs, then just change the 6 to whatever group you want.