MyBB Community Forums

Full Version: Attribute nofollow
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Question nofollow attribute
How to make external links on the site have attribute: nofollow

<a href="http://www.androidforum.com" rel="nofollow">forum android</a>

www.androidforum.com

<a href="http://www.jelo.com.au" rel="nofollow">Info forum</a>

www.jelo.com.au

... etc.
www.forum.pcformat.ie/tutorial/098.html
www.facebook.com/jansam.html



My links to my domain without the nofollow attribute

<a href="http://www.mysite.com" >mysite.com</a>

www.mysite.com
www.mysite.com/tutorial_one.html

Modification template, code?
Maybe a plug?
Someone knows something?

file: inc/class_parser.php

function mycode_parse_url($url, $name="")

code:

// Fix some entities in URLs
		$entities = array('$' => '%24', '$' => '%24', '^' => '%5E', '`' => '%60', '[' => '%5B', ']' => '%5D', '{' => '%7B', '}' => '%7D', '"' => '%22', '<' => '%3C', '>' => '%3E', ' ' => '%20');
		$fullurl = str_replace(array_keys($entities), array_values($entities), $fullurl);

		$name = preg_replace("#&amp;\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode

add:

		// my code
		
		// $link = "<a href=\"$fullurl\" target=\"_blank\" rel=\"nofollow\">$name</a>";
                // nie zmieniamy na nofollow linków do nas!!!
                $_host = '://'.$_SERVER["HTTP_HOST"];
                // ://forum.moja_strona.org jest w URL-u
                // i zaczyna sie nie dalej niż na 5 miejscu (https ma 5 znaków)
                if((strpos($fullurl,$_host) !== FALSE) && (strpos($fullurl,$_host) < 6))
                {
                  // Parse internal URL
                  $link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";
                } else {
                  // linki do mojej domeny!!! Chcemy miec follow!!!
                  $_host_moj = '://www.mysite.com';
                  if((strpos($fullurl,$_host_moj) !== FALSE) && (strpos($fullurl,$_host) < 6))
                  {
                    // Parse internal URL
                    $link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";
                  } else {
                    // Parse external URL deferred by anonym.to and with rel="nofollow"
                    // $link = "<a href=\"http://anonym.to/?$fullurl\" target=\"_blank\" rel=\"nofollow\">$name</a>";
                    $link = "<a href=\"$fullurl\" target=\"_blank\" rel=\"nofollow\">$name</a>";
                  }
                  unset($_host_moj);
                }
				
				unset($_host);
		
		
		// end code
		return $link;
	}