www.gusucode.com > 08CMS空白站群系统 3.3 繁体 UTF-8 > upload/include/parse/odeal.php

    <?php
!defined('M_COM') && exit('No Permission');
function odealtxt(&$tag,&$sarr,$mode='u'){
	if($mode == 'u'){
		if(empty($tag['tname']) || !($content = @$sarr[$tag['tname']])) return '';
	}else{
		if(!($content = @$sarr['body'])) return '';
	}
	if(!empty($tag['dealhtml'])){
		if($tag['dealhtml'] == 'clearhtml'){
			$content = strip_tags($content);
		}elseif($tag['dealhtml'] == 'disablehtml'){
			$content = mhtmlspecialchars($content);
		}elseif($tag['dealhtml'] == 'safehtml'){
			$content = safestr($content);
		}
	}
	!empty($tag['trim']) && $content = cutstr($content,$tag['trim'],'');
	!empty($tag['badword']) && mbadword($content);
	!empty($tag['wordlink']) && mwordlink($content);
	!empty($tag['nl2br']) && $content = mnl2br($content);
	!empty($tag['randstr']) && $content = preg_replace("/\<br \/\>/e", "randstr()", $content);
	return $content;
}
function mbadword(&$source){
	global $badwords;
	load_cache('badwords');
	if(!empty($badwords['wsearch'])){
		$source = preg_replace($badwords['wsearch'],$badwords['wreplace'],$source);
	}
}
function mwordlink(&$source){
	$source = preg_replace("/(^|>)([^<]+)(<|$)/ies","outwordlink('\\2','\\1','\\3')",$source);
}
function outwordlink($str,$start='',$end=''){
	global $wordlinks;
	load_cache('wordlinks');
	if(!empty($wordlinks['swords'])){
		$str = str_replace($wordlinks['swords'],$wordlinks['rwords'],$str);
	}
	return $start.$str.$end;
}
function randstr(){
	$str = '';
	for($i = 0;$i < mt_rand(5,15);$i++)  $str .= chr(mt_rand(0,59)).chr(mt_rand(63,126));
	return mt_rand(0, 1) ? '<br /><span style="display:none">'.$str.'</span>' : '<br /><font style="display:none">'.$str.'</font>';
}
?>