This is pretty easy to do. Case in point? I just did it. This will stop people from URL spamming in their profile, and via BBCode URL tags, which is about 99% of the problem.
I can even install this for cash, but I'll put this one out there for free. Save as 'file.diff' and use GNU's patch against your original source tree - or find the files (listed at the top with --- / +++, and remove the lines that have - at the beginning, then replace with the lines starting with +.
Code:
diff -urN phpBB2/includes/bbcode.php phpBB2-nofollow/includes/bbcode.php
--- phpBB2/includes/bbcode.php 2006-12-19 11:29:15.000000000 -0600
+++ phpBB2-nofollow/includes/bbcode.php 2007-10-12 19:42:54.000000000 -0600
@@ -624,13 +624,13 @@
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
- $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
+ $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
- $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
+ $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
diff -urN phpBB2/viewtopic.php phpBB2-nofollow/viewtopic.php
--- phpBB2/viewtopic.php 2006-12-19 11:29:16.000000000 -0600
+++ phpBB2-nofollow/viewtopic.php 2007-10-12 19:45:29.000000000 -0600
@@ -939,8 +939,8 @@
$email = '';
}
- $www_img = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
- $www = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';
+ $www_img = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww" rel="nofollow"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
+ $www = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww" rel="nofollow">' . $lang['Visit_website'] . '</a>' : '';
if ( !empty($postrow[$i]['user_icq']) )
{