MyBB Community Forums

Full Version: MyBB SafeLink 1.3.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
(2013-01-30, 01:39 PM)charafweb Wrote: [ -> ]Hi,
If I copy a "safelinked" link, and past it in a new post, the link is "safelinked" an other time.

For instance:

I copy this link:
Quote:http://localhost/safelink.php?url=http:/....4.1.0.zip

I past it in a new post, I get:

Quote:http://localhost/safelink.php?url=http:/....4.1.0.zip

That link when clicked is converted in the address bar to:

Quote:http://localhost/http://www.quest-app.ap....4.1.0.zip

And gives a page with this error:

Quote:Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.
Error 403

I'll work on a patch for that, though can I ask why you're copying safelinked URLs instead of just the URL itself?
I was just testing the plugin and I discovered that small issue, and I thought if a member have done so there were be such a problem.

And I have a request: would you modify your script so it encode the url (in the showthread) and decode it after going to redirection page.

For instance:
this url: http://localhost/safelink.php?url=http:/....4.1.0.zip

will be like something like this: http://localhost/safelink.php?url=Xdfdfd...fdfFQSFdsf

The Idea is force the user to use this page for redirecting and we will use it for advertisements.

I hope you understand my idea and my poor english.

Thanks a lot
(2013-01-30, 05:57 PM)charafweb Wrote: [ -> ]I was just testing the plugin and I discovered that small issue, and I thought if a member have done so there were be such a problem.

And I have a request: would you modify your script so it encode the url (in the showthread) and decode it after going to redirection page.

For instance:
this url: http://localhost/safelink.php?url=http:/....4.1.0.zip

will be like something like this: http://localhost/safelink.php?url=Xdfdfd...fdfFQSFdsf

The Idea is force the user to use this page for redirecting and we will use it for advertisements.

I hope you understand my idea and my poor english.

Thanks a lot

Yeah I'll work on that with the patch as well, I'll have it set as an option. Should be done in a few days.
Thanks a lot.

I did some search and found a solution, here it is:

I replaced this code:
function safelink_do($message)
{
	global $mybb, $post;
	if($mybb->settings['safelink_enabled'] == 1)
	{
		if(trim($mybb->settings['safelink_forums']) != '')
		{
			$forums = explode(",", trim($mybb->settings['safelink_forums']));
			if(!in_array($post['fid'], $forums))
			{
				$message = str_ireplace('<a href="http://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=http://", $message);
				$message = str_ireplace('<a href="https://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=https://", $message);
				$message = str_ireplace('<a href="ftp://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=ftp://", $message);
				$message = str_ireplace('<a href="file://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=file://", $message);
				// add additional protocols here if you wish to add them in the same format as those above
				#$message = str_replace("&amp;", "[S[A[F[E[and]L]I]N]K]", $message);
			}
		}
		else
		{
			$message = str_ireplace('<a href="http://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=http://", $message);
			$message = str_ireplace('<a href="https://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=https://", $message);
			$message = str_ireplace('<a href="ftp://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=ftp://", $message);
			$message = str_ireplace('<a href="file://', "<a href=\"".$mybb->settings['bburl']."/safelink.php?url=file://", $message);
			// add additional protocols here if you wish to add them in the same format as those above
			#$message = str_replace("&amp;", "[S[A[F[E[and]L]I]N]K]", $message);
		}
	}
	
	return $message;
}

with this:

function safelink_do($message)
{
	global $mybb, $post;
	
	if($mybb->settings['safelink_enabled'] == 1)//this checks if safelink is enabled
	{	$pos = strpos($message, "safelink.php"); //this checks if safelink strings exist in urls so to not safelinked it again
		if(trim($mybb->settings['safelink_forums']) != '')//this checks if there is some excluded forums
		{
			$forums = explode(",", trim($mybb->settings['safelink_forums']));//this is used make list of exclude some forums
			if((!in_array($post['fid'], $forums)) && (($pos === false)))//this is used to apply safelink to non excluded (included) forums
			{   //this apllied safe to included forums
				$message = str_ireplace('href="', "href=\"".$mybb->settings['bburl']."/safelink.php?url=", $message);
			}
		}
		elseif ($pos === false)
		{ //this is used when a member is excluded on non excluded forum (if member & forum excluded, then bypass this)
				$message = str_ireplace('href="', "href=\"".$mybb->settings['bburl']."/safelink.php?url=", $message);	
		}
	}
	
	return $message;
}

Tested.
Good luck for the request
Thanks



I found an other bug: excluded links are not really excluded.
I added my site name to URLs that SafeLink doesn't modify (in settings) but internal links are handled as other links

To exclude internal pages from being safelinked, I edited the function safelink_do like this:

function safelink_do($message)
{
	global $mybb, $post;
	
	if($mybb->settings['safelink_enabled'] == 1)//this checks if safelink is enabled
	{	$pos = strpos($message, "safelink.php"); //this checks if safelink strings exist in urls so to not safelinked it again
		$pos2 = strpos($message, $mybb->settings['bburl']); //This is to check for internal links and skip them
		if(trim($mybb->settings['safelink_forums']) != '')//this checks if there is some excluded forums
		{
			$forums = explode(",", trim($mybb->settings['safelink_forums']));//this is used make list of exclude some forums
			if((!in_array($post['fid'], $forums)) && (($pos === false)) && (($pos2 === false)))//this is used to apply safelink to non excluded (included) forums
			{   //this apllied safe to included forums
				$message = str_ireplace('href="', "href=\"".$mybb->settings['bburl']."/safelink.php?url=", $message);
			}
		}
		elseif (($pos === false) && ($pos2 === false))
		{ //this is used when a member is excluded on non excluded forum (if member & forum excluded, then bypass this)
				$message = str_ireplace('href="', "href=\"".$mybb->settings['bburl']."/safelink.php?url=", $message);
		}
	}
	
	return $message;
}
I've installed safelink but I get this error when I tested it.

[Image: safelink.png]
(2013-03-17, 11:12 PM)Prosper Wrote: [ -> ]I've installed safelink but I get this error when I tested it.

[Image: safelink.png]

I need to see your plugin settings on your site, that error alone isn't helpful.
(2013-03-17, 11:23 PM)fizz Wrote: [ -> ]
(2013-03-17, 11:12 PM)Prosper Wrote: [ -> ]I've installed safelink but I get this error when I tested it.

[Image: safelink.png]

I need to see your plugin settings on your site, that error alone isn't helpful.

I did some troubleshooting. I reinstalled and left all three urls intact but if I remove the two under my site url it doesn't work and will reproduce that error every time.
(2013-01-30, 11:08 PM)charafweb Wrote: [ -> ]I found an other bug: excluded links are not really excluded.
I added my site name to URLs that SafeLink doesn't modify (in settings) but internal links are handled as other links

To exclude internal pages from being safelinked, I edited the function safelink_do like this:

function safelink_do($message)
{
	global $mybb, $post;
	
	if($mybb->settings['safelink_enabled'] == 1)//this checks if safelink is enabled
	{	$pos = strpos($message, "safelink.php"); //this checks if safelink strings exist in urls so to not safelinked it again
		$pos2 = strpos($message, $mybb->settings['bburl']); //This is to check for internal links and skip them
		if(trim($mybb->settings['safelink_forums']) != '')//this checks if there is some excluded forums
		{
			$forums = explode(",", trim($mybb->settings['safelink_forums']));//this is used make list of exclude some forums
			if((!in_array($post['fid'], $forums)) && (($pos === false)) && (($pos2 === false)))//this is used to apply safelink to non excluded (included) forums
			{   //this apllied safe to included forums
				$message = str_ireplace('href="', "href=\"".$mybb->settings['bburl']."/safelink.php?url=", $message);
			}
		}
		elseif (($pos === false) && ($pos2 === false))
		{ //this is used when a member is excluded on non excluded forum (if member & forum excluded, then bypass this)
				$message = str_ireplace('href="', "href=\"".$mybb->settings['bburl']."/safelink.php?url=", $message);
		}
	}
	
	return $message;
}

Glad it's working then, I'll mess around with it and probably add that in an update.

(2013-03-17, 11:12 PM)Prosper Wrote: [ -> ]I did some troubleshooting. I reinstalled and left all three urls intact but if I remove the two under my site url it doesn't work and will reproduce that error every time.
I can't reproduce the error, using a fresh install of my own plugin (slightly updated) doing exactly what you said you've done.
That's okay, a friend of mine had the same problem. We found that if we leave the default urls in tact it works fine. When you release an update I'll be sure to grab it. It might be a theme issue but idk for sure lol

Great plugin though Toungue
(2013-03-28, 11:24 PM)Prosper Wrote: [ -> ]That's okay, a friend of mine had the same problem. We found that if we leave the default urls in tact it works fine. When you release an update I'll be sure to grab it. It might be a theme issue but idk for sure lol

Great plugin though Toungue

I think it might be, because I really can't replicate it, removing 2 URLs like you did, removing all of them, adding more, etc. Everything google shows says it's typically a problem with themes or something else (judging by Wordpress anyway). Have you tried reverting to the default theme?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14