7月28

如何给BO-BLOG加上"no follow" link

| |
16:31    ukidhulei 本站原创   From: 本站原创 不指定
    先看下我做的效果,黑熊工作室,网页源代码如
<A href="http://blbear.com/" target="_blank" rel="nofollow">黑熊工作室</A>


     需要这样来添加这个功能:
    
           1. \inc下的 ubb.php
                              
$regubb_search = array(
        "/\[size=([^\[\<]+?)\](.+?)\[\/size\]/ie",
        "/\[tbl( width=[0-9]+)?(%)?( bgcolor=[^ ]*)?( border=[^ ]*)?\](.+?)\[\/tbl\]/ise",
        "/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is",
        "/\s*\[quote=(.+?)\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is",
        "/\s*\[code\][\n\r]*(.+?)[\n\r]*\[\/code\]\s*/ie",
        "/\[url\]([^\[]*)\[\/url\]/ie",
        "/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/is",
        "/\[url=([^\[]*)\](.+?)\[\/url\]/is",
  
                     后面添加

        "/\[url_nofollow\]([^\[]*)\[\/url\]/ie",
        "/\[url_nofollow=www.([^\[\"']+?)\](.+?)\[\/url\]/is",
        "/\[url_nofollow=([^\[]*)\](.+?)\[\/url\]/is",


$regubb_replace =  array(
        "makefontsize('\\1', '\\2')",
        "maketable('\\5','\\1','\\2','\\3','\\4')",
        "<div class=\"quote\"><div class=\"quote-title\">{$lnc[265]}</div><div class=\"quote-content\">\\1</div></div>",
        "<div class=\"quote\"><div class=\"quote-title\">{$lnc[266]} \\1</div><div class=\"quote-content\">\\2</div></div>",
        "makecode('\\1')",
        "makeurl('\\1')",
        "<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",
        "<a href=\"\\1\" target=\"_blank\">\\2</a>",
          
                     后面添加

        "makeurl_nofollow('\\1')",
        "<a href=\"http://www.\\1\" target=\"_blank\" rel=\"nofollow\">\\2</a>",
        "<a href=\"\\1\" target=\"_blank\" rel=\"nofollow\">\\2</a>",

                     再添加function

function makeurl_nofollow($url) {
  global $mbcon;
  $urllink="<a href=\"".(substr(strtolower($url), 0, 4) == 'www.' ? "http://$url" : $url).'" target="_blank" rel="nofollow">';
  if($mbcon['shortenurl']=='1' && strlen($url) > $mbcon['urlmaxlen']) {
    $url = substr($url, 0, $mbcon['urlmaxlen']).'...';
  }
  $urllink .= $url.'</a>';
  return $urllink;
}



           2. \editor\ubb下的 editordef.php
                            
                                <a href="JavaScript: void(0); "><IMG border=0 onclick=hyperlink() title="{$lna[688]}" src="editor/ubb/images/url.gif" ></a>

                     后面添加

<a href="JavaScript: void(0); "><IMG border=0 onclick=hyperlink_nofollow() title="Nofollow Link" src="editor/ubb/images/url_nofollow.gif" ></a>


           3. \editor\ubb下的 ubbeditor.js
                      添加function

function hyperlink_nofollow() {
if (document.selection && document.selection.type == "Text") {
    var range = document.selection.createRange();
    txt=prompt(jslang[53],"http://");
    range.text = "[url_nofollow=" + txt + "]" + range.text + "[/url]";
} else if (is_firefox && noweditorid.selectionEnd) {
  txt=prompt(jslang[53],"http://");
  txt=FxGetTxt ("[url_nofollow=" + txt + "]", "[/url]");
  return;
} else {
  txt2=prompt(jslang[54],"");
  if (txt2!=null) {
    txt=prompt(jslang[55],"http://");
    if (txt!=null) {
      if (txt2=="") {
        AddTxt="[url_nofollow]"+txt;
        AddText(AddTxt);
        AddTxt="[/url]";
        AddText(AddTxt);
      } else {
        AddTxt="[url_nofollow="+txt+"]"+txt2;
        AddText(AddTxt);
        AddTxt="[/url]";
        AddText(AddTxt);
      }
    }
  }
}
}


           4. \editor\ubb下的 ubbeditor_tiny.js
                     添加function

function hyperlink_nofollow() {
if (document.selection && document.selection.type == "Text") {
    var range = document.selection.createRange();
    txt=prompt(jslang[29],"http://");
    range.text = "[url_nofollow=" + txt + "]" + range.text + "[/url]";
} else if (is_firefox && document.getElementById('v_content').selectionEnd) {
  txt=prompt(jslang[29],"http://");
  txt=FxGetTxt ("[url_nofollow=" + txt + "]", "[/url]");
  return;
} else {
  txt2=prompt(jslang[30]+"\n"+jslang[31],"");
  if (txt2!=null) {
    txt=prompt(jslang[32],"http://");
    if (txt!=null) {
      if (txt2=="") {
        AddTxt="[url_nofollow]"+txt;
        AddText(AddTxt);
        AddTxt="[/url]";
        AddText(AddTxt);
      } else {
        AddTxt="[url_nofollow="+txt+"]"+txt2;
        AddText(AddTxt);
        AddTxt="[/url]";
        AddText(AddTxt);
      }
    }
  }
}
}


           5.为了美观,再做张图片到 editor/ubb/images/url_nofollow.gif下面,就O了~

怕麻烦的到这里下我做好的,直接覆盖就可以了~


Tags: , ,
阅读(1371) | 评论(1) | 引用(0)
Ax Homepage
07/29/2008 16:17
收藏了!~

http://kvcd8.cn
ukidhulei 回复于 08/07/2008 12:25
dog收藏了好啊!
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]