蚂蚁分类信息商家发布文章外链及远程图片自

蚂蚁商户发布文章、商品是可以添加外链或者直接用外部图片,但是这对分类网站运营不利。所以要对外链进行过滤。

下面就说下怎么处理自动给外链自动加上nofollow属性。

1、添加过滤外链函数

打开/include/global.php添加处理函数

functionaddNofollow($content,$domain){

preg_match_all(/href=(.*?)/,$content,$matches);

if($matches){

foreach($matches[1]as$val){

if(strpos($val,$domain)===false)$content=str_replace(href=.$val.,href=.$val.rel=externalnofollow,$content);

}

}

preg_match_all(/src=(.*?)/,$content,$matches);

if($matches){

foreach($matches[1]as$val){

if(strpos($val,$domain)===false)$content=str_replace(src=.$val.,src=.$val.rel=externalnofollow,$content);

}

}

return$content;

}

2、发布文章调用处理函数

打开/member/include/inc_document.php查找$content=isset($_POST[content])在后面添加

$content=addNofollow(stripslashes($content));

*注意必须要加stripslashes先处理文章的转义字符

这样就处理完毕了,商品也是类似处理。



转载请注明地址:http://www.mayiox.com/ggjj/13024.html
  • 上一篇文章:
  • 下一篇文章: 没有了