Announcement

Collapse
No announcement yet.

add attribute to posts body content links

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • add attribute to posts body content links

    Following google's announcemnt to block all links containing rel="nofollow" so that spammers dont get credit for spamming links, I was thinking it would be a good thing to do for my forums (This can be an issue sometimes as we have all seen)

    Now I dont want to add the attribute to signatures, or any of the thread links in my vB just to the links that are contained within the body of a post (Such as this post) Example html output

    a href="http://www.example.com/" rel="nofollow">discount pharmaceuticals</a

    or alternately url=http://www.example.com rel="nofollow]discount pharmaceuticals[url (Not sure if this is the right way to do it in BB code.

    Anyways, just need to know what template or php file to change to effect just the body links, you help is much appreciated!
    Thanks
    Real Estate Webmasters

  • #2
    You would need to edit the includes/functions_bbcodeparse.php file. It looks like this code is responsible:

    Code:
    // ###################### Start handle_bbcode_url #######################
    function handle_bbcode_url($text, $link, $type = 'url')
    {
    	global $wysiwygparse;
    
    	if (trim($text) == '')
    	{
    		return '';
    	}
    
    	$rightlink = trim($link);
    	if (empty($rightlink))
    	{
    		// no option -- use param
    		$rightlink = trim($text);
    	}
    	$rightlink = strip_smilies(str_replace('\\"', '"', $rightlink));
    	$rightlink = str_replace(array('`', '"', "'", '['), array('`', '&quot;', ''', '['), $rightlink);
    
    	if ($type == 'url' AND !preg_match('#^[a-z0-9]+://#si', $rightlink))
    	{
    		$rightlink = "http://$rightlink";
    	}
    
    	if (!trim($link) OR $text == $rightlink)
    	{
    		$tmp = unhtmlspecialchars($rightlink);
    		if (strlen($tmp) > 55 AND !$wysiwygparse)
    		{
    			$text = htmlspecialchars_uni(substr($tmp, 0, 35) . '...' . substr($tmp, -15));
    		}
    	}
    
    	// remove double spaces -- fixes issues with wordwrap
    	$rightlink = str_replace('  ', '', $rightlink);
    
    	// strip extra quotes from hyperlink
    	$text = str_replace('\"', '"', $text);
    
    	if ($type == 'url')
    	{
    		// standard URL hyperlink
    		return "<a href=\"$rightlink\" target=\"_blank\">$text</a>";
    	}
    	else
    	{
    		// email hyperlink (mailto:)
    		if (is_valid_email($rightlink))
    		{
    			return "<a href=\"mailto:$rightlink\">$text</a>";
    		}
    		else
    		{
    			return $text;
    			// not a valid email - don't link it
    			return "<span title=\"$rightlink\">$text</span>";
    		}
    	}
    }
    If you need help modifying this code, then I recommend you post on www.vbulletin.org, the official vB hacking site.

    Comment


    • #3
      I was only able to change it universally in that file, what I wanted was a solution that only applied to the body of the text, not the signatures. Should I got to .org with this or can you help here?
      Real Estate Webmasters

      Comment


      • #4
        That would require some sort of condition to check the context. This is a www.vbulletin.org question.

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X