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("&", "[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("&", "[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;
}