Hide Links by MSSTI

Modifications for phpBB3.
Try the Mods here and share Your own Mods
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support

Hide Links by MSSTI

Post by Stoker »

Forgot and found this code.
Reposting it to make sure i dont forget again :D
Stoker 4.0 wrote:I would go for Prime Links, but I used to use this code by MSSTI:

This topic is a reminder of a mod that is written by MSSTI and not released fully anywhere.


Open viewtopic.php
Find:

Code: Select all

        $user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
Add before:

Code: Select all

// MOD : MSSTI Hide links (V1.0.2) - Start
        if ($user->data['user_id'] == ANONYMOUS)
        {
            $user_cache[$poster_id]['sig'] = hide_link($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], 'sig');
        }
// MOD : MSSTI Hide links (V1.0.2) - End
Find:

Code: Select all

   // Second parse bbcode here
Add before:

Code: Select all

// MOD : MSSTI Hide links (V1.0.2) - Start
   if ($user->data['user_id'] == ANONYMOUS)
   {
      $message = hide_link($message, $row['bbcode_uid']);
   }
// MOD : MSSTI Hide links (V1.0.2) - End
Open includes/function.php
Find:

Code: Select all

?>
Add before:

Code: Select all

// MOD : MSSTI Hide links (V1.0.2) - Start
function hide_link($text, $uid = '', $mode = 'post')
{
   if (!defined('IN_HIDE'))
   {
      define('IN_HIDE', true);

      define('IN_SIGNATURE',      false);   // Hide links on signatures ?            default false
      define('IN_LINE_URL',      true);   // Hide in-line links ?                  default true
      define('IN_BBCODE_URL',      true);   // Hide links into the bbcode [url][/url]   default true   
      define('IN_BBCODE_IMG',      false);   // Hide links into the bbcode [img][/img]   default false
      define('IN_BBCODE_CODE',   true);   // Hide links into the bbcode [code]
default true
}

if ($mode == 'sig' && !IN_SIGNATURE)
{
return $text;
}

global $user, $phpbb_root_path, $phpEx;
global $forum_id, $topic_id, $post_id;

$redirect = array();
if ($forum_id)
{
$redirect['f'] = $forum_id;
}
if ($topic_id)
{
$redirect['t'] = $topic_id;
}
if ($post_id)
{
$redirect['p'] = $post_id;
}

$hidelink_redirect = append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=login&redirect=" . urlencode(str_replace('&', '&', append_sid("{$phpbb_root_path}viewtopic.$phpEx", $redirect))));
$hidelink_search = array();
$hidelink_replace = '<span class="hidelink"><a href="' . $hidelink_redirect . '">'. $user->lang['LOGIN_EXPLAIN_VIEW'] . '</a></span>';

if (IN_BBCODE_CODE)
{
if (IN_LINE_URL)
{
// we need to turn the entities back into their original form
$entities = array("[code:$uid]", '&#46;', '&#58;', '&#058;');
$characters = array("[code:$uid]\n", '.', ':', ':');
$text = str_replace($entities, $characters, $text);
$text = make_clickable($text, generate_board_url());
}

if (IN_BBCODE_URL)
{
$hidelink_search[] = "#\&\#91;url\&\#93;(.*?)\&\#91;\/url\&\#93;#is";
$hidelink_search[] = "#\&\#91;url(=(.*?))\&\#91;\/url\&\#93;#si";
$hidelink_search[] = "#\[url(=(.*))?\]([\]].*)\[/url\]#si";
}

if (IN_BBCODE_IMG)
{
$hidelink_search[] = "#\&\#91;img\&\#93;(.*?)\&\#91;\/img\&\#93;#is";
$hidelink_search[] = "#\[img\]([\]].*)\[/img\]#si";
}
}

// OK
if (IN_LINE_URL)
{
$hidelink_search[] = '#<!-- ([lmwe]) --><a class=\"(postlink|postlink-local)\" href=\"(.*?)\">(.*?)</a><!-- ([lmwe]) -->#si';
}

// OK
if (IN_BBCODE_URL)
{
$hidelink_search[] = "/\[url:$uid\](.*?)\[\/url:$uid\]/is";
$hidelink_search[] = "/\[url\=(.*?):$uid\](.*?)\[\/url:$uid\]/is";
}

// OK
if (IN_BBCODE_IMG)
{
$hidelink_search[] = "#\[img:$uid\](.*?)\[/img:$uid\]#s";
$hidelink_search[] = "#\[img\=(.*?):$uid\](.*?)\[/img:$uid\]#s";
}

$text = preg_replace ($hidelink_search, $hidelink_replace, $text);

return $text;
}
// MOD : MSSTI Hide links (V1.0.2) - End[/code]

Open language/en/common.php
Find:

Code: Select all

	'IMAGE'						=> 'Image',
Add after:

Code: Select all

// MOD : MSSTI Hide links (V1.0.1) - Start
	'LOGIN_EXPLAIN_VIEW'		=> 'The board requires you to be registered and logged in to view links.',
// MOD : MSSTI Hide links (V1.0.1) - End
Open styles/prosilver/theme/colours.css
Add at the bottom:

Code: Select all

/* MOD : MSSTI Hide links (V1.0.2) - Start */
code .hidelink { line-height: 2em; }
.hidelink a { border: 1px solid #cccccc; border-collapse: collapse; padding: 1px 2px; color:#ff0000; background-color: #ffffff; font-weight: normal; text-decoration: none; font-size: 1em; line-height: 1.2em;}
/* MOD : MSSTI Hide links (V1.0.2) - End */ 

Hide Links by MSSTI

Post by martin123456 »

Seen this one before somewhere but not sure where.

edit found it https://www.phpbb.com/community/viewtop ... #p13002190