Not Solved Nofollow external plugin BUG Fix
#1
Not Solved
Guys this plugin is awesome but for some reason it doesn't add nofollow to urls that are posted this way

My websites are http://google.com , http://google.com , http://google.com , http://google.com , http://google.com

<?php
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("parse_message_end", "nofollowexternal_changelink");

function nofollowexternal_info() {
    return array(
        "name" => "Nofollow external",
        "description" => "A simple plugin that puts rel=\"nofollow\" in external links",
        "website" => "",
        "author" => "Matthew DeSantis",
        "authorsite" => "http://www.anarchy46.net/",
        "version" => "1.0",
        "guid"  => "2b874bd1e9ee6153673957629d68ef12",
        "compatibility" => "*"
        );
}
function nofollowexternal_changelink($message) {
    global $mybb;
    $message = preg_replace_callback("/<a href=\"(.+)\" (.+)>(.+)<\\/a>/",  "replace_external", $message);
    return $message;
}
function replace_external($groups) {
    global $mybb;
    $url = str_replace(array(".", "/"), array("\\.", "\\/"), $mybb->settings['bburl']);
    $urls = preg_replace("/^http/","https", $url, 1);
    if (preg_match("/$url/", $groups[1]) || preg_match("/$urls/", $groups[1])) {
        return $groups[0];
    }
    else {
        return "<a href=\"".$groups[1]."\" target=\"_blank\" rel=\"nofollow\">".$groups[3]."</a>";
    }
}
?>
Reply


Messages In This Thread
Nofollow external plugin BUG Fix - by marcus123 - 2013-12-03, 06:22 PM
RE: Nofollow external plugin BUG Fix - by .m. - 2013-12-03, 06:34 PM
RE: Nofollow external plugin BUG Fix - by Dave H - 2013-12-07, 06:03 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)