MyBB Community Forums

Full Version: Code advice help for plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello I'm hoping someone can help with some code advice on an existing plugin?

The plugin is Extra Forum Permissions but as the person who made it is no longer active here, there is no support for the plugin.

So I'm trying to work out how I can let members who don't have permission to post links, post internal links. For example if a member is disallowed posting links via the Extra Forum Permissions plugin they cant post an internal link to another thread on the forum.

I've had a little look at the code but I don't have a clue what I'm doing, Blush I think this is the part that stops a link being posted, but how can I add a code to let everyone post internal links?

if(!$forumpermissions['canpostlinks'])
	{	
		$http_links = "#([\>\s\(\)])(http|https|ftp|news){1}://([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i";
		$www_links = "#([\>\s\(\)])(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i";
		$url_tags_simple = "#\[url\]([a-z]+?://)([^\r\n\"<]+?)\[/url\]#si";
		$url_tags_simple2 = "#\[url\]([^\r\n\"<]+?)\[/url\]#i";
		$url_tags_complex = "#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si";
		$url_tags_complex2 = "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si";
		
		if(
			preg_match($http_links, $message) ||
			preg_match($www_links, $message) ||
			preg_match($url_tags_simple, $message) ||
			preg_match($url_tags_simple2, $message) ||
			preg_match($url_tags_complex, $message) ||
			preg_match($url_tags_complex2, $message)
		)
		{
			extraforumperm__lang_load();
			$datahandler->is_validated = false;
			$datahandler->set_error($lang->error_canpostlinks);
		}
	}

Thank You.
No one know?
Try replacing:
if(
	preg_match($http_links, $message) ||
	preg_match($www_links, $message) ||
	preg_match($url_tags_simple, $message) ||
	preg_match($url_tags_simple2, $message) ||
	preg_match($url_tags_complex, $message) ||
	preg_match($url_tags_complex2, $message)
)

With:
if(
	(preg_match($http_links, $message) ||
	preg_match($www_links, $message) ||
	preg_match($url_tags_simple, $message) ||
	preg_match($url_tags_simple2, $message) ||
	preg_match($url_tags_complex, $message) ||
	preg_match($url_tags_complex2, $message)) &&
	!preg_match('%^http://YOURURL\.com(/[\w.-]+){2}/$%', $message)
)

Update YOURURL with your website url. I'm not good at using regex.

http://stackoverflow.com/questions/27622...es#tab-top
Nope didn't work, but thanks for trying.
Sorry, try the new edit.
Thanks again, but no still not working.
Sorry, I se now the issue, the code check for the full message to find URLS, for something to work out the code should check individual URLS.

You can try creating a new MyCode, like this:
[internal]thread-135567-post-983144.html#pid983144[/internal]

To be replaced with:
http://community.mybb.com/thread-135567-post-983144.html#pid983144

Probably not the best solution but the easiest, considering trusted users shouldn't be bothered with the permission check, I suppose.
Sorry not with you, wouldn't that mean I have to create a MyCode for each post, thread, etc?

What would I put in Regular Expression & Replacement ?

Thanks.