]+/', 'callback', $content); } function callback($matches) { $link = $matches[0]; $site_link = 'http://' . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; if (strpos($link, 'rel') === false) { $link = preg_replace("%(href=\S(?!$site_link))%i", 'rel="nofollow" $1', $link); } elseif (preg_match("%href=\S(?!$site_link)%i", $link)) { $link = preg_replace('/rel=\S(?!nofollow)\S*/i', 'rel="nofollow"', $link); } return $link; } ?>