本文整理匯總了PHP中zmf::badWordsReplace方法的典型用法代碼示例。如果您正苦於以下問題:PHP zmf::badWordsReplace方法的具體用法?PHP zmf::badWordsReplace怎麽用?PHP zmf::badWordsReplace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zmf
的用法示例。
在下文中一共展示了zmf::badWordsReplace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handleContent
/**
* 處理內容
* @param type $content
* @return type
*/
public static function handleContent($content)
{
$pattern = "/<[img|IMG].*?data=[\\'|\"](.*?)[\\'|\"].*?[\\/]?>/i";
preg_match_all($pattern, $content, $match);
$arr_attachids = array();
if (!empty($match[0])) {
$arr = array();
foreach ($match[0] as $key => $val) {
$_key = $match[1][$key];
$arr[$_key] = $val;
$arr_attachids[] = $match[1][$key];
}
if (!empty($arr)) {
foreach ($arr as $thekey => $imgsrc) {
$content = str_ireplace("{$imgsrc}", '[attach]' . $thekey . '[/attach]', $content);
}
}
}
$content = strip_tags($content, '<b><strong><em><span><a><p><u><i><img><br><br/>');
$replace = array('/<a.*?href="(.*?)".*?>(.+?)<\\/a>/ie', '/(((http|https):\\/\\/)[a-z0-9;&#@=_~%\\?\\/\\.\\,\\+\\-\\!\\:]+)/ie', "/style=\"[^\"]*?\"/i");
$to = array("self::autoUrl('\\1','\\2')", "self::textUrl('\\1')", '');
$content = preg_replace($replace, $to, $content);
if (zmf::config('checkBadWords')) {
$h_style = zmf::config("badwordsHandleStyle");
//僅過濾
if ($h_style === 'filter') {
$content = zmf::badWordsReplace($content);
//僅通知 過濾通知
} elseif ($h_style === 'notice' or $h_style === 'filterNotice') {
$status = Yii::app()->session['checkHasBadword'];
if ($status != 'yes') {
$keywords = zmf::getBadwords();
foreach ($keywords as $word) {
if (mb_strpos($content, $word) !== false) {
Yii::app()->session['checkHasBadword'] = 'yes';
}
}
}
if ($h_style === 'filterNotice') {
$content = zmf::badWordsReplace($content);
}
}
}
$data = array('content' => $content, 'attachids' => $arr_attachids);
return $data;
}