/**
* 过滤提交的内容
* @param $content
* @return bool
*/
public function filterContent($content){
$content=strtolower($content);
$content=preg_replace("/<a[^>]*>(.*?)<\/a>/is", "$1", $content);
$content=preg_replace("/<[img|IMG].*?src=[\'|\"](http[s]?:\/\/)(.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/", "", $content);
$strRegex = '/(http[s]?:\/\/)?'.
'((([0-9]{1,3}\.){3}[0-9]{1,3}'. // IP形式的URL- 199.194.52.184
'|'. // 允许IP和DOMAIN(域名)
'([0-9a-z_!~*\'()-]+\.)*'. // 域名- www.
'([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.'. // 二级域名
'(com|net|gov|edu|cn|org|biz|cc|info|uk|tv|top|int|hk|xyz|me|co)+)'. // first level domain- .com or .museum,"[a-z]{2,6})"
'(:[0-9]{1,4})?)+'. // 端口- :80
'((\/\?)?)/' // a slash isn't required if there is no file name
;
return preg_replace($strRegex,'',$content);
}删除文章内所有的a标签链接,域名 ,带外链的图片,内链的图片不会删的方法
与本文相关的文章
网友最新评论 (0)
暂无评论