<?php

//if(!defined('ISDVBBS')) exit('Access denied.Sorry, you can not access this file directly.');
if( !defined('ISDVBBS') ){
	//header('HTTP/1.0 401 Unauthorized');
	header('HTTP/1.0 400 Bad Request');
	exit;
}
class HtmlFilter
{
	var $_roottag = 'Dv_Root_Tag';
	var $_htmldata = '';
	var $_stag = ',br,img,hr,base,input,';
	var $_disabletags = ',link,iframe,meta,script,frameset,layer,style,xss,base,html,xhtml,xml,';
	function &xml_encode(&$data)
	{
		$returnval = preg_replace(array('/\s*^|^\s*|\s*$/m'), array(''), str_replace('&', '&amp;', $data));
		for ($i = 0; $i <= 31; $i++) {
			$returnval = str_replace(chr($i), "&amp;#{$i};", $returnval);
		}
		for ($i = 96; $i <= 96; $i++) {
			$returnval = str_replace(chr($i), "&amp;#{$i};", $returnval);
		}
		$returnval = utf8_encode($returnval);
		return $returnval;
	}
	function &xml_decode(&$data)
	{
		$returnval =& $data;
		$returnval = utf8_decode($returnval);
		for ($i = 0; $i <= 31; $i++) {
			$returnval = str_replace("&amp;#{$i};", chr($i), $returnval);
		}
		for ($i = 95; $i <= 96; $i++) {
			$returnval = str_replace(array("&amp;#{$i};", "&#{$i};"), chr($i), $returnval);
		}
		return $returnval;
	}
	function error_string($errorcode)
	{
		return xml_error_string($errorcode);
	}
	function _tag_open(&$parser, $tagname, &$attributes)
	{
		if ($tagname === $this->_roottag) {
			return;
		}
		$lowertag = strtolower($tagname);
		$lttag = '<';
		$gttag = '>';
		if (false !== ($isdisabletag = strpos($this->_disabletags, ",{$lowertag},"))) {
			$lttag = '&lt;';
			$gttag = '&gt;';
		} elseif (false !== strpos($this->_stag, ",{$lowertag},")) {
			$gttag = ' />';
		}
		$this->_htmldata .= "{$lttag}{$tagname}";
		if (!empty($attributes) AND is_array($attributes)) {
			foreach ($attributes AS $attrname => $attrval) {
				if (false === $isdisabletag) {
					$attrname = preg_replace('/(^on)/ie', 'str_replace(array("o", "O"), array("&#111;", "&#79;"), "$1")', $attrname);
					$attrval = preg_replace(array('/&(?!amp|amp;)/i', '#(javascript:)#ie', '#(file:(?:/{0,3}))#ie'), array('&amp;', 'str_replace(array("j", "J"), array("&amp;#106;", "&amp;#74;"), "$1")', 'str_replace(array("f", "F"), array("&amp;#102;", "&amp;#70;"), "$1")'), $attrval);
				} else {
					$attrval = preg_replace(array('/&(?!amp|amp;)/i', '#(file:(?:/{0,3}))#ie'), array('&amp;', 'str_replace(array("f", "F"), array("&amp;#102;", "&amp;#70;"), "$1")'), $attrval);
				}
				$lowerattrname = strtolower($attrname);
				if ($lowertag === 'a' AND $lowerattrname === 'target') { // 强制链接在新窗口中打开
					$attrval = '_blank';
				} elseif ($lowerattrname === 'style') { // 过滤掉 style属性中的 position top left 等几个样式属性
					$newattrval = '';
					$styleprops = explode(';', $attrval);
					if (!empty($styleprops) AND is_array($styleprops)) {
						$semicolon = '';
						foreach ($styleprops AS $keyval) {
							$keyval = strtolower(trim($keyval));
							if ($keyval === '') {
								continue;
							}
							list($stylepropname, $stylepropval) = explode(':', $keyval);
							$stylepropname = trim($stylepropname);
							$stylepropval = trim($stylepropval);
							if ($stylepropname === '' AND $stylepropval === '') {
								continue;
							}
							if ($stylepropname === 'position' AND $stylepropval === 'absolute') {
								$stylepropval = 'static';
							} elseif (false !== strpos(',top,left,bottom,right,height,width,font-size,line-height,', ",{$stylepropname},")) {
								if (1 == preg_match('#([0-9]+)(.*)#i', $stylepropval, $matchs)) {
									$matchs[2] = strtolower($matchs[2]);
									if ($matchs[2] === '%' AND $matchs[1] > 100) {
										$stylepropval = '100%';
									} elseif ($matchs[2] === 'px' AND $matchs[1] > 200) {
										$stylepropval = '200px';
									} elseif ($matchs[2] === 'pt' AND $matchs[1] > 10) {
										$stylepropval = '10pt';
									} elseif ($matchs[1] > 24) {
										$stylepropval = '24';
									}
								}
							}
							$newattrval .= "{$semicolon}{$stylepropname}:{$stylepropval}";
							$semicolon = ';';
						}//end foreach
					}
					if ($newattrval !== '') {
						$attrval = $newattrval;
					}
					$attrval = preg_replace(array('/disabled_by_dv__/i', '/(expression|behavior)/i'), array('', 'disabled_by_dv__$1'), $attrval);
				}
				$this->_htmldata .= " {$attrname}=\"{$attrval}\"";
			}
		}
		$this->_htmldata .= $gttag;
	}
	function _cdata(&$parser, &$cdata)
	{
		$this->_htmldata .= $cdata;
	}
	function _tag_close(&$parser, $tagname)
	{
		if ($tagname === $this->_roottag) {
			return;
		}
		$lowertag = strtolower($tagname);
		if (false !== strpos($this->_stag, ",{$lowertag},")) {
			return;
		}
		$lttag = '<';
		$gttag = '>';
		if (false !== strpos($this->_disabletags, ",{$lowertag},")) {
			$lttag = '&lt;';
			$gttag = '&gt;';
		}
		$this->_htmldata .= "{$lttag}/{$tagname}{$gttag}";
	}
	function &do_filter(&$data, &$errorcode)
	{
		$this->_htmldata = '';
		$parser = xml_parser_create('utf-8');
		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
		xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
		xml_set_element_handler($parser, array(&$this, '_tag_open'), array(&$this, '_tag_close'));
		xml_set_character_data_handler($parser, array(&$this, '_cdata'));
		xml_parse($parser, "<{$this->_roottag}>".$this->xml_encode($data)."</{$this->_roottag}>", true);
		$errorcode = xml_get_error_code($parser);
		xml_parser_free($parser);
		unset($parser);
		return $this->xml_decode($this->_htmldata);
	}
	function &_getEncoding($charset = '')
	{
		static $objenc = array();
		if (empty($charset) AND isset($GLOBALS['charset'])) {
			$charset = $GLOBALS['charset'];
		} else {
			$charset = 'utf-8';
		}
		if (!isset($objenc[$charset])) {
			require_once INC_PATH.'DV_Encoding.class.php';
			$objenc[$charset] = DV_Encoding::GetEncoding($charset);
		}
		return $objenc[$charset];
	}//end function _getEncoding
	function _cdata_substr(&$parser, &$cdata)
	{
		if ($this->_substr_length <= 0) {
			$cachestart = 0;
			return;
		}
		$objenc =& $this->_getEncoding();
		if ($this->_substr_start > 0) {
			$strlen = $objenc->StrLength($cdata);
			if ($this->_substr_start >= $strlen) {
				$this->_substr_start -= $strlen;
				return;
			}
		}
		$cdata = utf8_decode($cdata);
		$tmpsubstr =& $objenc->SubString($cdata, $this->_substr_start, $this->_substr_length);
		$tmplen = $objenc->StrLength($tmpsubstr);
		$tmpsubstr = utf8_encode($tmpsubstr);
		$this->_substr_length -= $tmplen;
		$this->_substr_start = 0;
		$this->_htmldata .= $tmpsubstr;
	}//end function _cdata_substr
	function &SubString(&$str,$start,$length=null)
	{
		if (!is_numeric($start)) {
			return '';
		}
		$objenc =& $this->_getEncoding();
		$strlen = $objenc->StrLength($str);
		if ($start < 0) {
			$this->_substr_start = $strlen + $start;
		} else {
			$this->_substr_start = $start;
		}
		if (!is_numeric($length)) {
			$this->_substr_length = $strlen;
		} elseif ($length < 0) {
			$this->_substr_length = $strlen - $this->_substr_start + $length;
		} else {
			$this->_substr_length = $length;
		}
		$this->_htmldata = '';
		if (-1 == version_compare(PHP_VERSION, '5.0.0')) {
			$xmlencoding = 'utf-8';
		} else {
			$xmlencoding = '';
		}
		$parser = xml_parser_create($xmlencoding);
		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
		xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
		xml_set_element_handler($parser, array(&$this, '_tag_open'), array(&$this, '_tag_close'));
		xml_set_character_data_handler($parser, array(&$this, '_cdata_substr'));
		xml_parse($parser, "<{$this->_roottag}>".$this->xml_encode($str)."</{$this->_roottag}>", true);
		$errorcode = xml_get_error_code($parser);
		xml_parser_free($parser);
		unset($parser);
		return $this->xml_decode($this->_htmldata);
	}//end function SubString
}

function &cross_site_html_proc(&$htmldata, &$errcode, &$errstr) // Cross site scripting/html code 跨站 html 代码处理
{
	static $htmlfilter = null;
	if (empty($htmlfilter)) {
		$htmlfilter = new HtmlFilter();
	}
	$result =& $htmlfilter->do_filter($htmldata, $errcode);
	$errstr = $htmlfilter->error_string($errcode);
	return $result;
}

$lang = load_lang($lang, 'dv_code' );

//论坛内容部分UBBCODE，入口：内容、用户组ID、模式(1=帖子/2=公告、短信等)、模式2(0=新版/1=旧版)
	//用户积分
	if( !isset($UserPointInfo) || empty($UserPointInfo) ){
		if( $userid > 0 ){
			$UserPointInfo = array(
								intval($userinfo['userwealth'])
								,intval($userinfo['userep'])
								,intval($userinfo['usercp'])
								,intval($userinfo['userpower'])
								,intval($userinfo['userpost'])
							 ); 
		} else{
			$UserPointInfo = array(0,0,0,0,0);;
		}
	}

function &_getUserGroupSettingsById($grpid=0)
{
	if (empty($grpid)) {
		return $returnval;
	}
	static $cacheallgrp;
	static $cachegrp = array();
	if (!isset($cachegrp[$grpid])) {
		$cachegrp[$grpid] = array();
		if (!isset($cacheallgrp)) {
			require_once CACHE_PATH.'group/group_all.php';
			$cacheallgrp = $_DCACHE['all_groups'];
		}
		$cachegrp[$grpid] =& $cacheallgrp["{$grpid}"];
	}
	return $cachegrp[$grpid];
}//end function _getUserGroupSettingsById

//---------------2007-12-28 edit----------------------

function Dv_adDownLoad($usergroupid)
{
	global $lang,$boardid;
		if (!empty($usergroupid))
		{
			$currcachefile =CACHE_PATH.'Forum_DownLoad_benefit_File.php';
			if (file_exists($currcachefile))
			{

				require $currcachefile;
				foreach ($Forum_DownLoad_benefit[DownLoad_benefit] as  $k => $vv )
				{

					if ( $vv[DB_boardid] == $boardid  and $vv[DB_close]==1)
					{
						$getDB_boardid = $vv[DB_boardid];
						$getDB_starttime = $vv[DB_starttime];
						$getDB_endtime = $vv[DB_endtime];
						$getArrdb = $Forum_DownLoad_benefit[DownLoad_benefit][$k];
						$sGroupId = $vv[DB_groupid];
						$setUserGroup = false;
						if (false!==strpos($sGroupId,',')){
							$arrGroupid = explode(',',$sGroupId);
							foreach($arrGroupid as $v){
								if (intval($usergroupid)===intval($v)) {$setUserGroup = true;break;}
							}
						}else{
							if (intval($usergroupid)===intval($sGroupId)){$setUserGroup = true;break;}
						}
						if ($setUserGroup===true)break;

					}
				}
			}
		}
		if ( $setUserGroup === true )
		{
			if (file_exists($currcachefile))
			{
				$arrdb = ARRAY();
				$today_from = strtotime(gmdate('Y-m-d H:s'));
				if ( ($getDB_starttime <= $today_from and $getDB_endtime >= $today_from))
				{
					$arrdb=$getArrdb;
				}else{
					$arrdb=NULL;
				}
				if (is_array($arrdb) and count($arrdb) > 0)
				{
					$strDB_ContentText = 'onmouseover=\'DvAjaxSend("dv_ajax.php?getDB_id='.$arrdb['DB_id'].'&setSign=DownLoad","",this.id,"showAjaxPic");\' id="DownLoad_'.$arrdb['DB_id'].'"';
				}
			}		
		}
	return str_replace("'","\'",$strDB_ContentText);

}//end Dv_adDownLoad



function &Dv_CodeProcess(&$code,&$currUserInfo,$ubblists,$PostType=1,$sType=1)
{
	if( $code == '' ) return '';
	global $lang, $membername,$master,$UserPointInfo,$userinfo,$userid,$boardid,$fsetting,$dvCodeLang,$board_settings,$_DCACHE,$forum_ads,$groupsetting;

	$iscontain39 = (false === strpos($ubblists,',39,'));
	$isOld = (empty($ubblists) ? false : $iscontain39);
	if( $isOld !== false && ( strpos($code,',table,') !== false || strpos($code,',tr,') !== false || strpos($code,',th,') !== false || strpos($code,',td,') !== false ) ){
		$code = htmlspecialchars($code);
		print str_replace('{$code}',$code,str_replace('{$replyid}',$GLOBALS['replyid'],$lang['Error.strings3']));
		exit;
	}
	$PostUserGroup = intval($currUserInfo['usergroupid']);
	static $crtusergrpsettings = array();
	if (!isset($crtusergrpsettings[$PostUserGroup])) {
		if (empty($currUserInfo['UserGroupSettings'])) {
			$crtusergrpsettings[$PostUserGroup] =& _getUserGroupSettingsById($PostUserGroup);
		} elseif (is_string($currUserInfo['UserGroupSettings'])) {
			$crtusergrpsettings[$PostUserGroup] = explode(',', $currUserInfo['UserGroupSettings']);
		}
	}
	$currGrpSetting =& $crtusergrpsettings[$PostUserGroup];
	if( !empty($currGrpSetting) ){
		$mt = $currGrpSetting[72];
	} else {
		$mt = 7;
	}
	$PostType = intval($PostType);
	$sType = intval($sType);

	//正则表达式模式数组
	$arrPattern = array( '/\[(.+?)][\r\n]*\[\/\1]/i' ,'/(?:([\r\n])\1)+/i' ,'/<\!-- CETagParser -->/i' ,'/<\!-- CETagParser (.[^>]*) -->/i' );

	//对应正则表达式的替换数组
	$arrRepl = array( '' ,'' ,'' ,'' );

	$isxhtml = false;	
	$board_setting68 = intval($board_settings[68]);
	static $filterspechtml;
	if (!isset($filterspechtml)) {
		$filterspechtml = trim($fsetting['filterspechtml']);
		('' !== $filterspechtml) AND ($filterspechtml = preg_quote($filterspechtml));
	}
	if ('' === $filterspechtml) {
		$arrPattern[] = '/(?:(?:<)|(?:<\/))(?:iframe|frameset)(.*?)>/ies';
	} else {
		$arrPattern[] = '/(?:(?:<)|(?:<\/))(?:'.$filterspechtml.')(.*?)>/ies';
	}
	$arrRepl[] = 'str_replace("<","&lt;","$0")';//'htmlspecialchars("$0")';
	if (false === $iscontain39 && ( strpos($code,',table,') !== false || strpos($code,',tr,') !== false || strpos($code,',th,') !== false || strpos($code,',td,') !== false ) ) {
		$code = str_replace('<','&lt;',$code);
	} else{
		$arrPattern[] = '/>(?:\r|\n|(?:\r\n))</i';
		$arrRepl[] = '><';
	}
	$arrPattern[] = '/(<\!--)/i';
	$arrRepl[] = '&lt;!--';
	$arrPattern[] = '/-->/i';
	$arrRepl[] = '--&gt';

	if( $board_settings[66] == 0 ){
		//Start 过滤连续的或大片的空片符
			$arrPattern[] = '/>[\s\r\n]+</i';
			$arrRepl[] = '><';
			$arrPattern[] = '/[\r\n]+>/i';
			$arrRepl[] = '>';
			$arrPattern[] = '/(?:(\s)\1)+/i';
			$arrRepl[] = '$1';
		//End 过滤连续的或大片的空片符
	}
//Start JavaScript过滤
	//*
	if (true) {	//	如果需要为特殊用户组或其它条件启用 JavaScript 代码，则修改此处
		$arrPattern[] = '#(<\s*s\s*c\s*r\s*i\s*p\s*t\s*|<\s*\/\s*s\s*c\s*r\s*i\s*p\s*t\s*)#ei';
		$arrRepl[] = 'htmlspecialchars("$1")';
	}
	if (true) {	//	如果需要为特殊用户组或其它条件启用 JavaScript 代码，则修改此处
		$arrPattern[] = '/\s+(on(?:\w+?)=)/i';
		$arrRepl[] = 'disabled_by_dv__$1';
	}
	//*/
//End JavaScript过滤
//Start URL 和 IMG 标签混合的情况
		$arrPattern[] = '#\[url\s*=\s*([^\]]+)](.*?)\[img](.+?)\[\/img](.*?)\[/url]#iesm';
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank">$2<img src="\'.str_filter_xss("$3").\'" border="0"/ >$4</a>\'';
//End URL 和 IMG 标签混合的情况
//Start img标签处理
	if( $sType === 1 || strpos($ubblists,',1,') !== false ){
		$arrPattern[] = '/\[img]((?:\w+:\/\/)?(?:[^\/:]+?)(?::\d*?)?(?:[^]\n])*?)\[\/img]/iesm';
		if ($board_setting68 == 1) {
			$arrRepl[] = '\'<a onfocus="this.blur()" href="\'.str_filter_xss("$1").\'" target="_blank" title="'.$lang['template.strings22'].'"><img src="\'.str_filter_xss("$1").\'" border="0" /></a>\'';
		} else {
			$arrRepl[] = '\'<img src="images/filetype/gif.gif" border="0\ /"> <a onfocus="this.blur()" href="\'.str_filter_xss("$1").\'" target="_blank">\'.str_filter_xss("$1").\'</a>\'';
		}
	}
//End img标签处理
//Start url 标签处理
	if( $sType === 1 || strpos($ubblists,',16,') !== false ){
		$arrPattern[] = '#\[url\s*=\s*([^\]]+)](.+?)\[/url]#iesm';
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank">\'.str_filter_xss("$2").\'</a>\'';
		$arrPattern[] = '#\[url](.+?)\[/url]#iesm';
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank">$1</a>\'';
	}
//End url 标签处理


//Start upload 标签处理
	if( $sType === 1 || strpos($ubblists,',2,') !== false ){
		if( empty($fsetting['forumuploadname']) ){
			$fsetting['forumuploadname'] = 'uploadfile/';
		}
		static $_forumuploadname;
		if (!isset($_forumuploadname)) {
			$_forumuploadname = $fsetting['forumuploadname'];
			$len = strlen($_forumuploadname);
			($len > 0) AND ('/' !== $_forumuploadname{$len - 1}) AND ($_forumuploadname .= '/');
		}

		if (!is_numeric($fsetting['file_pic_guardchain'])) {
			$fsetting['file_pic_guardchain'] = 0;
		}

		$arrPattern[] = '/\[upload=(gif|jpg|jpeg|bmp|png)[^\]]*]([^\[\n]*)\[\/upload]/ei';
		$arrRepl[] = '"[upload=$1]".str_filter_xss("$2")."[/upload]"';
		$arrPattern[] = '/\[upload=(gif|jpg|jpeg|bmp|png)]([^\[\n]*)\[\/upload]/i';	

		$groupsetting[93]=(empty($groupsetting[93]))?0:intval($groupsetting[93]);
		if (true === $master OR $currUserInfo['userid'] == $userid  OR $groupsetting[93]===1) {
		if( $fsetting['file_pic_guardchain'] == 0 ){
			if( $board_setting68 === 1 || $PostUserGroup < 4 ){
				$arrRepl[] = '<br /><img src="images/filetype/$1.gif" border="0" >'.$lang['template.strings2'].'<br /><a href="'.$_forumuploadname.'$2" target="_blank" id="ImgSpan"><img src="'.$_forumuploadname.'$2" border="0" alt="'.$lang['template.strings3'].'" ></a>';
			} else{
				$arrRepl[] = '<br /><img src="images/filetype/$1.gif" border="0" ><a href="'.$_forumuploadname.'$2" target="_blank">'.$_forumuploadname.'$2</a>';
			}
		} else{
			if( $board_setting68 === 1 || $PostUserGroup < 4 ){
				$arrRepl[] = '<br /><img src="images/filetype/$1.gif" border="0" >'.$lang['template.strings2'].'<br /><a href="showimg.php?boardid='.$boardid.'&filename=$2" target="_blank" id="ImgSpan" ><img src="showimg.php?boardid='.$boardid.'&filename=$2" border="0" alt="'.$lang['template.strings2'].'" ></a>';
			} else{
				$arrRepl[] = '<br /><img src="images/filetype/$1.gif" border="0" ><a href="showimg.php?boardid='.$boardid.'&filename=$2" target="_blank">showimg.php?boardid='.$boardid.'&filename=$2</a>';
			}
		}
		}else{
				$arrRepl[] = '<br /><img src="images/filetype/$1.gif" border="0" > '.$lang['dispbbs_code_pic'].'';		
		}
		$arrPattern[] = '#\[upload\s*=\s*(swf|swi)]([^\[\n]*)\[\/upload]#ei';
		$arrRepl[] = '"[upload=$1]".str_filter_xss("$2")."[/upload]"';
		$arrPattern[] = '#\[upload\s*=\s*(swf|swi)]([^\[\n]*)\[\/upload]#i';
		if( $fsetting['file_pic_guardchain'] == 0 ){
			if( $PostUserGroup < 4 || $board_settings[70] == 1 ){
				$arrRepl[] = '<br /><img src="images/filetype/swf.gif" border="0" ><a href="'.$_forumuploadname.'$2" target="_blank">'.$lang['template.strings4'].'</a>:<br /><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="500" height="300" ID="Shockwaveflash1"><param name="movie" value="'.$_forumuploadname.'$2"><param name="quality" value="high"><param name="menu" value="false"><embed src="'.$_forumuploadname.'$2" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="500" height="300"></embed></object>';
			} else{
				$arrRepl[] = '<br /><img src="images/filetype/swf.gif" border="0" ><a href="'.$_forumuploadname.'$2" target="_blank">'.$_forumuploadname.'$2</a>';
			}
		} else{
			$arrRepl[] = '<br /><img src="images/filetype/swf.gif" border="0"><a href="'.$_forumuploadname.'$2" target="_blank">'.$lang['template.strings5'].'</a>';
		}

		//wma|mp3在线播放处理
		$arrPattern[] = '#\[upload\s*=\s*(wma|mp3|rm|wav)]([^\[\n]*)\[\/upload]#ei';
		$arrRepl[] = '"[upload=$1]".str_filter_xss("$2")."[/upload]"';
		$arrPattern[] = '#\[upload\s*=\s*(wma|mp3|rm|wav)]([^\[\n]*)\[\/upload]#i';
		if( $fsetting['file_pic_guardchain'] == 0 ){
			if( $board_settings[71] * $mt == 1 ){
				
				$arrRepl[] = '<object align="middle" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" class="object" id="MediaPlayer" width="500" height="300" ><param name="ShowStatusBar" value="-1" /><param name="AUTOSTART" value="true" /><param name="Filename" value="'.$_forumuploadname.'$2" /><embed type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" flename="mp" src="'.$_forumuploadname.'$2" width="500" height="300"></embed></object>';
			} else{
				$arrRepl[] = '<br /><img src="images/filetype/mp3.gif" border="0" ><a href="'.$_forumuploadname.'$2" target="_blank">'.$_forumuploadname.'$2</a>';
			}
		} else{
			$arrRepl[] = '<br /><img src="images/filetype/mp3.gif" border="0"><a href="'.$_forumuploadname.'$2" target="_blank">'.$lang['template.strings5_1'].'</a>';
		}
		

		$arrPattern[] = '/\[upload=([^\]\n]+)]viewfile\.(?:php|asp)\?id=([0-9]*)\[\/upload]/ei';
		$arrRepl[] = '\'<img src="images/filetype/\'.str_filter_xss("$1").\'.gif" border="0"><a href="viewfile.php?boardid='.$boardid.'&id=\'.intval("$2").\'" target="_blank" '.Dv_adDownLoad($currUserInfo[usergroupid]).'>'.$lang['template.strings6'].'</a>\'';
		$arrPattern[] = '/\[upload=([^\]\n]+)]([^\[]*)\[\/upload]/ei';
		$arrRepl[] = '\'<img src="images/filetype/\'.str_filter_xss("$1").\'.gif" border="0"><a href="\'.str_filter_xss("$2").\'" target="_blank">'.$lang['template.strings6'].'</a>\'';

	}
//End upload 标签处理

//Start lastedittime 标签处理
	if (1 === $sType OR false !== strpos($ubblists,',43,')) {
		$arrPattern[] = '#\[lastedittime]\s*([0-9]+)\s*\[/lastedittime]#ei';
		$arrRepl[] = 'gmdate("Y-m-d H:i:s", "$1"+getUserTimeZoneOffset())';
	}
//End lastedittime 标签处理

//Start dir 标签处理
	if( $sType === 1 || strpos($ubblists,',3,') !== false ){
		$arrPattern[] = '/\[dir=([0-9]+),([0-9]+)]([^\s\[]*)\[\/dir]/ei';
		if( $board_settings[71] * $mt == 1 ){
			$arrRepl[] = '\'<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,2,0" width="$1" height="$2"><param name="src" value="\'.str_filter_xss("$3").\'" /><embed src="\'.str_filter_xss("$3").\'" pluginspage="http://www.macromedia.com/shockwave/download/" width="$1" height="$2"></embed></object>\'';
		} else{
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$3").\'" target="_blank">\'.str_filter_xss("$3").\'</a>\'';
		}
	}
//End dir 标签处理

//Start QT 标签处理
	if( $sType === 1 || strpos($ubblists,',4,') !== false ){
		$arrPattern[] = '/\[qt=([0-9]+),([0-9]+)]([^\s\[]*)\[\/qt]/ei';
		if( $board_settings[71] * $mt == 1 ){
			$arrRepl[] = '\'<embed src="\'.str_filter_xss("$3").\'" width="$1" height="$2" autoplay="true" loop="false" controller="true" playeveryframe="false" cache="false" scale="TOFIT" bgcolor="#000000" kioskmode="false" targetcache="false" pluginspage="http://www.apple.com/quicktime/">\'';
		} else{
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$3").\'" target="_blank">\'.str_filter_xss("$3").\'</a>\'';
		}
	}
//End QT 标签处理

//Start mp 标签处理
	if( $sType === 1 || strpos($ubblists,',5,') !== false ){
		$arrPattern[] = '/\[mp=([0-9]+),([0-9]+),(.*?)]([^\s\[]*)\[\/mp]/ei';
		if( $board_settings[71] * $mt == 1 ){
			$arrRepl[] = '\'<object align="middle" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" class="object" id="MediaPlayer" width="$1" height="$2" ><param name="ShowStatusBar" value="-1" /><param name="AUTOSTART" value="\'.str_filter_xss("$3").\'" /><param name="Filename" value="\'.str_filter_xss("$4").\'" /><embed type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" flename="mp" src="\'.str_filter_xss("$4").\'" width="$1" height="$2"></embed></object>\'';
		} else{
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$4").\'" target="_blank">\'.str_filter_xss("$4").\'</a>\'';
		}
	}
//End mp 标签处理

//Start rm 标签处理
	if( $sType === 1 || strpos($ubblists,',6,') !== false ){
		$arrPattern[] = '/\[rm=([0-9]+),([0-9]+),(.*?)]([^\s\[]*)\[\/rm]/ei';
		if( $board_settings[71] * $mt == 1 ){
			$arrRepl[] = '\'<br><object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" class="object" id="RAOCX" width="$1" height="$2"><param name="SRC" value="\'.str_filter_xss("$4").\'" /><param name="CONSOLE" value="Clip1" /><param name="CONtrOLS" value="imagewindow" /><param name="AUTOSTART" value="\'.str_filter_xss("$3").\'" /></object><br /><object classid="CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" height="32" id="video2" width="$1"><param name="SRC" value="\'.str_filter_xss("$4").\'" /><param name="AUTOSTART" value="\'.str_filter_xss("$3").\'" /><param name="CONtrOLS" value="controlpanel" /><param name="CONSOLE" value="Clip1" /></object>\'';
		} else{
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$4").\'" target="_blank">\'.str_filter_xss("$4").\'</a>\'';
		}
	}
//End rm 标签处理

//Start sound 标签处理
	if( $sType === 1 || strpos($ubblists,',7,') !== false ){
		$arrPattern[] = '/\[sound](.*)\[\/sound]/ei';
		if( $board_settings[71] * $mt == 1 ){
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank"><img src="images/filetype/mid.gif" border="0" alt="'.$lang['code.str1'].'" /></a><bgsound src="\'.str_filter_xss("$1").\'" loop="-1">\'';
		} else{
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank">$1</a>\'';
		}
	}
//End sound 标签处理

//Start flash 标签处理
	if( $sType === 1 || strpos($ubblists,',8,') !== false ){
		$arrPattern[] = '/\[flash(?:\=([0-9]+),([0-9]+))?]([^\s\[]*)\[\/flash]/ei';
		if( $board_settings[70] == 1 ){
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$3").\'" target="_blank"><img src="images/filetype/swf.gif" border="0" alt="'.$lang['template.strings7'].'" height="16" width="16" />'.$lang['template.strings'].'</a><br /><object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="\'.(is_numeric("$1") ? "$1" : 500).\'" height="\'.(is_numeric("$2") ? "$2" : 400).\'"><param name="movie" value="\'.str_filter_xss("$3").\'" /><param name="quality" value="high" /><embed src="\'.str_filter_xss("$3").\'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="$1" height="$2"></embed></object>\'';
		} else{
			$arrRepl[] = '\'<a href="\'.str_filter_xss("$3").\'" target="_blank">\'.str_filter_xss("$3").\'</a>\'';
		}
	}
//End flash 标签处理
//Start money 标签处理
	if( $sType === 1 || strpos($ubblists,',9,') !== false ){
		$arrPattern[] = '/\[money *= *([0-9]+)]\s*([^\[\n\r]*)\s*\[\/money]/iem';
		$arrRepl[] = '("$userid">0 AND ("$master"||"$userid"=="$currUserInfo[userid]"||"$UserPointInfo[0]">=intval("$1")))?"<hr size=\"1\" /><font color=\"gray\">'.$lang['template.strings10'].'<b>$1</b>'.$lang['template.strings9'].'</font><br />$2<hr size=\"1\"/>":"<hr size=\"1\" /><font color=\"'.$_DCACHE['stylecss'][19].'\">'.$lang['template.strings10'].'<b>$1</b>'.$lang['template.strings9'].'</font><hr size=\"1\" />"';
	}
//End money 标签处理
//Start point 标签处理
	if( $sType === 1 || strpos($ubblists,',10,') !== false ){
		$arrPattern[] = '/\[point *= *([0-9]+)]\s*([^\[\n\r]*)\s*\[\/point]/iem';
		$arrRepl[] = '("$userid">0 AND ("$master"||"$userid"=="$currUserInfo[userid]"||"$UserPointInfo[1]">=intval("$1")))?"<hr size=\"1\" /><font color=\"gray\">'.$lang['template.strings11'].'<b>$1</b>'.$lang['template.strings9'].'</font><br />$2<hr size=\"1\"/>":"<hr size=\"1\" /><font color=\"'.$_DCACHE['stylecss'][19].'\">'.$lang['template.strings11'].'<b>$1</b>'.$lang['template.strings9'].'</font><hr size=\"1\" />"';
	}
//End point 标签处理
//Start UserCP 标签处理
	if( $sType === 1 || strpos($ubblists,',11,') !== false ){
		$arrPattern[] = '/\[UserCP *= *([0-9]+)]\s*([^\[\n\r]*)\s*\[\/UserCP]/iem';
		$arrRepl[] = '("$userid">0 AND ("$master"||"$userid"=="$currUserInfo[userid]"||"$UserPointInfo[2]">=intval("$1")))?"<hr size=\"1\" /><font color=\"gray\">'.$lang['template.strings12'].'<b>$1</b>'.$lang['template.strings9'].'</font><br />$2<hr size=\"1\"/>":"<hr size=\"1\" /><font color=\"'.$_DCACHE['stylecss'][19].'\">'.$lang['template.strings12'].'<b>$1</b>'.$lang['template.strings9'].'</font><hr size=\"1\" />"';
	}
//End UserCP 标签处理
//Start Power 标签处理
	if( $sType === 1 || strpos($ubblists,',12,') !== false ){
		$arrPattern[] = '/\[Power *= *([0-9]+)]\s*([^\[\n\r]*)\s*\[\/Power]/eim';
		$arrRepl[] = '("$userid">0 AND ("$master"||"$userid"=="$currUserInfo[userid]"||"$UserPointInfo[3]">=intval("$1")))?"<hr size=\"1\" /><font color=\"gray\">'.$lang['template.strings13'].'<b>$1</b>'.$lang['template.strings9'].'</font><br />$2<hr size=\"1\"/>":"<hr size=\"1\" /><font color=\"'.$_DCACHE['stylecss'][19].'\">'.$lang['template.strings13'].'<b>$1</b>'.$lang['template.strings9'].'</font><hr size=\"1\" />"';
	}
//End Power 标签处理
//Start Post 标签处理
	if( $sType === 1 || strpos($ubblists,',13,') !== false ){
		$arrPattern[] = '/\[Post *= *([0-9]+)]\s*([^\[\n\r]*)\s*\[\/Post]/iem';
		$arrRepl[] = '("$userid">0 AND ("$master"||"$userid"=="$currUserInfo[userid]"||"$UserPointInfo[4]">=intval("$1")))?"<hr size=\"1\" /><font color=\"gray\">'.$lang['template.strings14'].'<b>$1</b>'.$lang['template.strings9'].'</font><br />$2<hr size=\"1\"/>":"<hr size=\"1\" /><font color=\"'.$_DCACHE['stylecss'][19].'\">'.$lang['template.strings14'].'<b>$1</b>'.$lang['template.strings9'].'</font><hr size=\"1\" />"';
	}
//End Post 标签处理
	static $isgetreed = 0;
	static $reed = 0;
//Start replyview 标签处理
	if( $sType === 1 || strpos($ubblists,',14,') !== false ){
		$arrPattern[] = '/\[replyview]([^\[]*)\[\/replyview]/i';
		if (1 == $PostType AND ($PostUserGroup < 4 OR 1 == $board_settings[77])) {
			$reed = 0;
			if ($isgetreed !== 1) {
				global $dv,$db,$TotalUseTable,$AnnounceID;
				$isgetreed = 1;
				$posttable = trim($GLOBALS['TotalUseTable']);
				if ('' === $posttable) {
					global $fsetting;
					$posttable = $fsetting['nowtablename'];
				}
				$posttable = addslashes($posttable);
				if ($db->scalar("SELECT COUNT(1) FROM {$posttable} WHERE rootid='".$AnnounceID."' AND postuserid='{$userid}'") > 0) {
					$reed = 1;
				} else{
					$reed = 0;
				}
			}
			if ($userid > 0 AND (1 == $reed OR true === $master)) {
				$arrRepl[] = '<hr noshade size=1><font color="gray">'.$lang['template.strings15'].'</font><br />$1<hr noshade size=1>';
			} else {
				$arrRepl[] = '<hr noshade size=1><font color="'.$_DCACHE['stylecss'][19].'">'.$lang['template.strings15'].'</font><hr noshade size=1>';
			}
		} else{
			$arrRepl[] = '$1';
		}
	}
//End replyview 标签处理
//Start USEMONEY 标签处理
	if( $sType === 1 || strpos($ubblists,',15,') !== false ){
		global $T_GetMoneyType;
		if( $T_GetMoneyType ){
			$arrPattern[] = '/\[USEMONEY\s*=\s*([0-9]+)](.*)\[\/USEMONEY]/is';
			$arrRepl[] =& $lang['template.strings16'];
		} else{
			if (1 === $PostType AND ($PostUserGroup < 4 OR 1 == $board_settings[78])) {
				$arrPattern[] = $tmpPattern = '/\[USEMONEY=*([0-9]+)]((.|\n)*)\[\/USEMONEY]/i';
				if ($userid > 0 AND (true === $master OR $currUserInfo['userid'] == $userid)) {
					if( !empty($currUserInfo['postbuyuser']) ){
						$arrBuyUser = explode('|', $currUserInfo['postbuyuser']);
						$strPostBuyUser = '<option value="0">'.$lang['code.str2'].'</option>';
						if( !empty($arrBuyUser) ){
							$key = 0;
							foreach( $arrBuyUser as $val ){
								$val = trim($val);
								if ('' === $val) {
									continue;
								}
								$strPostBuyUser .= '<option value="'.(++$key).'">'.$val.'</option>';
							}
						}
					} else{
						$strPostBuyUser = '<option value="0">'.$lang['code.str3'].'</option>';
					}
					$arrRepl[] = '<hr noshade="noshade" size="1" /><font color="gray">'.$lang['code.str4'].'</font>&nbsp;&nbsp;<select size=1 name=buyuser>'.$strPostBuyUser.'</select><br />$2<hr noshade size=1>';
				} else {
					$buied = 0;
					if( !empty($currUserInfo['postbuyuser']) ){
						if ($userid > 0 AND false !== strpos('|'.$currUserInfo['postbuyuser'].'|','|'.$membername.'|')) {
							$buied = 1;
						}
					}
					if( $buied === 1 ){
						$arrRepl[] = '<hr noshade="noshade" size="1" /><font color="gray">'.$lang['code.str5'].'<hr noshade size=1>';
					} else{
						if( preg_match($tmpPattern,$code,$matches) === 1 ){
							if( is_array($matches) ){
								$ii = intval($matches[1]);
							} else{
								$ii = 0;
							}
						}
						if( $UserPointInfo[0] >= $ii ){
							$arrRepl[] = '<form action="buypost.php" method="post"><font color="'.$_DCACHE['stylecss'][19].'">'.$lang['code.str6'].$UserPointInfo[0].'</b>'.$lang['template.strings23'].'<br /><br /><input type="hidden" name="boardid" value="'.$boardid.'"><input type="hidden" name="replyid" value="'.$currUserInfo['current_replyid'].'"><input type="hidden" name="id" value="'.$currUserInfo['current_announceid'].'"><input type="hidden" name="rootid" value="'.$currUserInfo['current_rootid'].'"><input type="hidden" name="posttable" value="'.$currUserInfo['posttable'].'"><input type="submit" name="submit" value="'.$lang['code.str7'].'">&nbsp;&nbsp;</font></form>';
						} else{
							$lang['code.str8'] = str_replace('$UserPointInfo[0]', $UserPointInfo[0], $lang['code.str8']);
							$arrRepl[] = '<hr noshade="noshade" size="1" /><font color="'.$_DCACHE['stylecss'][19].'">'.$lang['code.str8'].'</font><hr noshade size=1>';
						}
					}
				}
			} else{
				$arrPattern[] = '/\[\/?USEMONEY=*[0-9]*]/i';
				$arrRepl[] = '';
			}
		}
	}
//End USEMONEY 标签处理
//Start email 标签处理
	if( $sType === 1 || strpos($ubblists,',17,') !== false ){
		$arrPattern[] = '/\[email](.*?)\[\/email]/eis';
		$arrRepl[] = '\'<a href="mailto:\'.str_filter_xss("$1").\'">\'.str_filter_xss("$1").\'</a>\'';
		$arrPattern[] = '/\[email=(.*?)](.*?)\[\/email]/is';
		$arrRepl[] = '\'<a href="mailto:\'.str_filter_xss("$1").\'">\'.str_filter_xss("$2").\'</a>\'';
	}
//End email 标签处理
//Start html 标签处理
	if( $sType === 1 || strpos($ubblists,',23,') !== false ){
		$arrPattern[] = '/\[html](.*?)\[\/html]/eis';
		$Floor = 1;
		$arrRepl[] = '_InnerUbbCodeProcess_Html("$1",$Floor++);';
	}
//End html 标签处理
//Start code 标签处理
	if( $sType === 1 || strpos($ubblists,',24,') !== false ){
		$arrPattern[] = '/\[code](.*?)\[\/code]/is';
		$arrRepl[] = '<div class="htmlcode"><b>'.$lang['code.str9'].'</b><br />$1</div>';
	}
//End code 标签处理
//Start color 标签处理
	if( $sType === 1 || strpos($ubblists,',25,') !== false ){
		$arrPattern[] = '/\[color\s*=\s*(\#[a-zA-Z0-9]{6}|[a-zA-z]+)]\s*(.*?)\s*\[\/color]/im';
		$arrRepl[] = '<font color="$1">$2</font>';
	}
//End color 标签处理
//Start face 标签处理
	if( $sType === 1 || strpos($ubblists,',26,') !== false ){
		$arrPattern[] = '/\[face *= *(.+?)]\s*(.+?)\s*\[\/face]/im';
		$arrRepl[] = '<font face="$1">$2</font>';
	}
//End face 标签处理
//Start align 标签处理
	if( $sType === 1 || strpos($ubblists,',27,') !== false ){
		$arrPattern[] = '/\[align *?= *?(left|center|right)](.*?)\[\/align]/i';
		$arrRepl[] = '<div align="$1">$2</div>';
	}
//End align 标签处理
//Start quote 标签处理
	if( $sType === 1 || strpos($ubblists,',28,') !== false ){
		$arrPattern[] = '/\[quote]/i';
		$arrRepl[] = '<div class="quote">';
		$arrPattern[] = '/\[\/quote]/i';
		$arrRepl[] = '</div>';
	}
//End quote 标签处理
//Start fly 标签处理
	if( $sType === 1 || strpos($ubblists,',29,') !== false ){
		$arrPattern[] = '/\[fly](.*?)\[\/fly]/i';
		$arrRepl[] = '<marquee width="90%" behavior="alternate" scrollamount="3">$1</marquee>';
	}
//End fly 标签处理
//Start move 标签处理
	if( $sType === 1 || strpos($ubblists,',30,') !== false ){
		$arrPattern[] = '/\[move](.*?)\[\/move]/i';
		$arrRepl[] = '<marquee scrollamount="3">$1</marquee>';
	}
//End move 标签处理
//Start shadow 标签处理
	if( $sType === 1 || strpos($ubblists,',31,') !== false ){
		$arrPattern[] = '/\[shadow=([0-9]+),((?:\#[0-9]{6})|(?:[a-zA-Z]+)),([0-9]+)](.+?)\[\/shadow]/i';
		$arrRepl[] = '<div style="width:$1px;filter:shadow(color=$2, strength=$3)">$4</div>';
	}
//End shadow 标签处理
//Start glow 标签处理
	if( $sType === 1 || strpos($ubblists,',32,') !== false ){
		$arrPattern[] = '/\[glow=([0-9]+),((?:\#[0-9]{6})|(?:[a-zA-Z]+)),([0-9]+)](.+?)\[\/glow]/i';
		$arrRepl[] = '<div style="width:$1px;filter:glow(color=$2, strength=$3)">$4</div>';
	}
//End glow 标签处理
//Start size 标签处理
	if( $sType === 1 || strpos($ubblists,',33,') !== false ){
		$arrPattern[] = '/\[size *= *([0-9]+)]\s*(.+?)\s*\[\/size]/im';
		$arrRepl[] = '<font size="$1">$2</font>';
	}
//End size 标签处理
//Start i 标签处理
	if( $sType === 1 || strpos($ubblists,',34,') !== false ){
		$arrPattern[] = '/\[i](.*?)\[\/i]/i';
		$arrRepl[] = '<i>$1</i>';
	}
//End i 标签处理
//Start b 标签处理
	if( $sType === 1 || strpos($ubblists,',35,') !== false ){
		$arrPattern[] = '/\[b](.*?)\[\/b]/i';
		$arrRepl[] = '<b>$1</b>';
	}
//End b 标签处理
//Start u 标签处理
	if( $sType === 1 || strpos($ubblists,',36,') !== false ){
		$arrPattern[] = '/\[u](.*?)\[\/u]/i';
		$arrRepl[] = '<u>$1</u>';
	}
//End u 标签处理
//Start em 标签处理
	if( $sType === 1 || strpos($ubblists,',37,') !== false ){
		if( ( $PostUserGroup < 4 || $board_settings[69] == 1 ) && preg_match('/\[em/i',$code) === 1 ){
			$arrPattern[] = '/\[em([0-9]+?)\]/is';
			global $empath;
			$arrRepl[] = '<img src="'.str_filter_xss($empath).'em$1.gif" border="0" align="absmiddle">';
		}
	}
//End em 标签处理
	if( strpos($code,'payto:') === false ){
		$code = str_replace("https://www.alipay.com/payt","https://www.alipay.com/payto:",$code);
	}
//Start 支付宝相关 标签处理
	if( strpos($ubblists,',40,') !== false ){
		$arrPattern[] = '/\[payto](.+?)\[\/payto]/eis';
		$arrRepl[] = '__InnerPaytoCodeProcess("$1","$0")';
	}
//End 支付宝相关 标签处理
//Start username 标签处理
	if( $sType === 1 || strpos($ubblists,',41,') !== false ){
		$arrPattern[] = '/\[username *= *(.+?)]\s*(.*?)\s*\[\/username]/ie';
		$arrRepl[] = '_InnerUbbCodeProcess_username("$1","$2","$0","$currUserInfo[username]")';
	}
//End username 标签处理

//Start cc 标签处理
//	if( $sType === 1 || strpos($ubblists,',8,') !== false ){
		$arrPattern[] = '/\[cc(?:\=([0-9]+),([0-9]+))?]([^\s\[]*)\[\/cc]/ei';
		if( $board_settings[70] == 1 ){
			$arrRepl[] = '\'<a href="http://union.bokecc.com/\'.str_filter_xss("$3").\'" target="_blank"><img src="images/filetype/swf.gif" border="0" alt="'.$lang['template.strings7'].'" height="16" width="16" />'.$lang['template.strings'].'</a><br /><object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="\'.(is_numeric("$1") ? "$1" : 500).\'" height="\'.(is_numeric("$2") ? "$2" : 400).\'"><param name="movie" value="http://union.bokecc.com/\'.str_filter_xss("$3").\'" /><param name="quality" value="high" /><embed src="http://union.bokecc.com/\'.str_filter_xss("$3").\'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="$1" height="$2"></embed></object>\'';
		} else{
			$arrRepl[] = '\'<a href="http://union.bokecc.com/\'.str_filter_xss("$3").\'" target="_blank">http://union.bokecc.com/\'.str_filter_xss("$3").\'</a>\'';
		}
//	}
//End cc 标签处理

//Start qihoo组图处理
	$arrPattern[] = '/\[mergepic,[\d]?]([_0-9a-z]*)\[\/mergepic]/ei';
	$arrRepl[]= '\'<object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="750" height="500"><param name="movie" value="\'.getqihoomerge("$1").\'" /><param name="quality" value="high" /><embed src="\'.getqihoomerge("$1").\'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="750" height="500"></embed></object><p>\'';
//End qihoo组图处理
	
//Start center 标签处理
	if( $sType === 1 || strpos($ubblists,',42,') !== false ){
		$arrPattern[] = '/\[center](.*?)\[\/center]/i';
		$arrRepl[] = '<div align="center">$1</div>';
	}
//End center 标签处理
	if( $isxhtml !== true ){
		//自动识别网址
		if( preg_match('/(?:,18,)|(?:,19,)|(?:,20,)|(?:,21,)|(?:,22,)/i',$ubblists) === 1 ){
		}
		//自动识别www等开头的网址
		if( $sType === 1 || strpos($ubblists,',38,') !== false ){
		}
	}
	$arrPattern[] = '/<img([^>]+)>/ims';
	$arrRepl[] = '<img onload="return imgzoom(this,700)" $1>';
	$arrPattern[] = '/\t/i';
	$arrRepl[] = '&nbsp;&nbsp;&nbsp;&nbsp;';

	$returnval = preg_replace( $arrPattern ,$arrRepl ,$code );

	//添加帖子内容右侧广告代码
	if($forum_ads[18]){
		if((THIS_SCRIPT == 'dispbbs') || (THIS_SCRIPT == 'savvy_dispbbs') || (THIS_SCRIPT == 'indivgroup_dispbbs')){
			if($currGrpSetting[91]){
				//用户组广告设置打开
				if($currGrpSetting[92] == '0' || $currGrpSetting[92] == ''){
					$dispbbs_ads_content= explode("\r\n", $forum_ads[19]);
					$ads_content_valign= $forum_ads[18];
				}
				else{
					$dispbbs_ads_content= explode("\r\n", $currGrpSetting[92]);
					$ads_content_valign= $currGrpSetting[91];
				}
			}
			else{
				//用户组广告设置关闭
				$dispbbs_ads_content = explode("\r\n", $forum_ads[19]);
				$ads_content_valign= $forum_ads[18];
			}

			if(isset($dispbbs_ads_content)){
			$num = count($dispbbs_ads_content) - 1;
			$num = rand(0, $num);
			$ads_content = $dispbbs_ads_content[$num];
			if($ads_content_valign=='1')
				$ads_content_valign= 'top';
			else if($ads_content_valign=='2')
				$ads_content_valign= 'middle';
			else
				$ads_content_valign= 'bottom';

			$returnval= "<table cellpadding='0' cellspacing='0' width='100%'><tr><td><div class=\"bodys\" onload=\"this.style.overflowX='auto';\">\r\n".$returnval."</div></td><td width='80px' valign='{$ads_content_valign}'>{$ads_content}</td></tr></table>";
			}
		}
	}
	return $returnval;
}//end function Dv_CodeProcess

function _InnerUbbCodeProcess_Html($matchStr,$Floor = 1){
	global $lang;
	$CodeStr = '';
	if( !empty($matchStr) ){
		$CodeStr = preg_replace(
				    array( "/&nbsp;/i" ,"/<p>/i" ,"/</p>/i" ,"/(?:\[br]|<br\/>|\r\n|\n)/i" )
				   ,array( " " ,"" ,"&#13;&#10;" ,"&#13;&#10;" )
				   ,$matchStr);
		$tmpInt = (( ($Floor+1) % 2 ) + 1 );
		$replyid = intval($GLOBALS['replyid']);
		$CodeStr = '<form name="scode'.$replyid.'_'.$Floor.'" method="post" action=""><table class="tableborder1" cellspacing="1" cellpadding="3" style="width: 98%;" align="center"><tr><th height="22">'.$lang['code.str10'].'</th></tr><tr><td class="tablebody'.$tmpInt.' align="middle" width="98%"><textarea id="CodeText" style="width: 100%;" rows="10">'.$CodeStr.'</textarea></td></tr><tr><td class="tablebody'.$tmpInt.' align="middle" width="98%">'.$lang['code.str11'].'</td></tr><tr><td class="tablebody'.$tmpInt.'" align="middle" width="98%"><input type="button" name="run" value="'.$lang['code.str12'].'" onclick="Dvbbs_ViewCode(\''.$replyid.'_'.$Floor.'\');">&nbsp;<input type="button" name="copy" value="'.$lang['code.str13'].'" onclick="Dvbbs_CopyCode(\''.$replyid.'_'.$Floor.'\');" disabled="disabled">&nbsp;<input type="button" name="save" value="'.$lang['code.str14'].'" onclick="Dvbbs_SaveCode(\''.$replyid.'_'.$Floor.'\');" disabled="disabled"></td></tr></table></form>';
	}
	return $CodeStr;
}//end function _InnerUbbCodeProcess_Html

function __InnerPaytoCodeProcess($match_1,$match_0){
	global $lang;
	$match_1 = str_replace(array('&#95;', '&#95'), array('_'), $match_1);
	if( preg_match('/\(seller\)([^\n]+?)\(\/seller\)/i',$match_1,$sellerMatches) === 1 ){
		unset($sellerMatches[0]);
		if( preg_match('/\(subject\)([^\n]+?)\(\/subject\)/i',$match_1,$subjectMatches) === 1 ){
			unset($subjectMatches[0]);
			if( preg_match('/\(body\)(.*?)\(\/body\)/is',$match_1,$bodyMatches) === 1 ){
				unset($bodyMatches[0]);
				if( preg_match('/\(price\)([\d\.]+?)\(\/price\)/i',$match_1,$priceMatches) === 1 ){
					unset($priceMatches[0]);
					if( preg_match('/\(transport\)([1-3])\(\/transport\)/i',$match_1,$transportMatches) === 1 ){
						unset($transportMatches[0]);
						$isChecked = true;
						$arrTmp = array( $lang['code.str15'] ,$lang['code.str16'] ,$lang['code.str17'] );
						$strUrlTmp = '';
						$strMsgTmp = '';
						$iTmp = intval($transportMatches[1]);
						if( $iTmp === 2 ){
							if (1 === preg_match('#\(express_fee\)(\d+?)\(/express_fee\)#i',$match_1,$express_feeMatches)) {
								unset($express_feeMatches[0]);
								$strUrlTmp .= '&transport='.$iTmp.'&express_fee='.doubleval($express_feeMatches[1]);
								$strMsgTmp .= '<b>'.$lang['code.str18'].'</b>'.$lang['template.strings24'].$arrTmp[$iTmp-1].$lang['code.str19'].doubleval($express_feeMatches[1]).$lang['code.str20'].'<br /><br />';
							} elseif( preg_match('#\(ordinary_fee\)(\d+?)\(/ordinary_fee\)#i',$match_1,$ordinary_feeMatches) === 1 ){
								unset($ordinary_feeMatches[0]);
								$strUrlTmp .= '&transport='.$iTmp.'&ordinary_fee='.doubleval($ordinary_feeMatches[1]);
								$strMsgTmp .= '<b>'.$lang['code.str18'].'</b>'.$lang['template.strings24'].$arrTmp[$iTmp-1].$lang['code.str21'].doubleval($ordinary_feeMatches[1]).$lang['code.str20'].'<br /><br />';
							} else{
								return $match_0;
							}
						} else{
							$strUrlTmp .= '&transport='.$iTmp;
							$strMsgTmp .= '<b>'.$lang['code.str18'].'</b>'.$lang['template.strings24'].$arrTmp[$iTmp-1].'<br /><br />';
						}
						$isChecked = false;
						if( preg_match('/\(ww\)([^\n]+?)\(\/ww\)/i',$match_1,$wwMatches) === 1 ){
							unset($wwMatches[0]);
							$strUtf8Tmp = EncodeUtf8($wwMatches[1]);
							$strMsgTmp .= '<b>'.$lang['code.str22'].'</b>'.$lang['template.strings24'].'<a target="_blank" href="http://amos1.taobao.com/msg.ww?v=2&uid='.$strUtf8Tmp.'&s=1"><img border="0" src="http://amos1.taobao.com/online.ww?v=2&uid='.$strUtf8Tmp.'"&s=1"/></a>';
							$isChecked = true;
						}
						if( preg_match('/\(qq\)(\d+?)\(\/qq\)/i',$match_1,$qqMatches) === 1 ){
							unset($qqMatches[0]);
							if( $isChecked === true ){
								$strMsgTmp .= '&nbsp;&nbsp;<a target="_blank" href="http://wpa.qq.com/msgrd?V=1&Uin='.$qqMatches[1].'&Site=Dvbbs.Net&Menu=yes"><img border="0" SRC="http://wpa.qq.com/pa?p=1:'.$qqMatches[1].':10" alt="'.$lang['code.str23'].'"></a><br /><br />';
							} else{
								$strMsgTmp .= '<b>'.$lang['code.str22'].'</b>'.$lang['template.strings24'].'<a target="_blank" href="http://wpa.qq.com/msgrd?V=1&Uin='.$qqMatches[1].'&Site=Dvbbs.Net&Menu=yes"><img border="0" SRC="http://wpa.qq.com/pa?p=1:'.$qqMatches[1].':10" alt="'.$lang['code.str23'].'"></a><br /><br />';
							}
						} elseif( $isChecked === true ){
							$strMsgTmp .= '<br /><br />';
						}
						if( preg_match('/\(demo\)([^\n]+?)\(\/demo\)/i',$match_1,$demoMatches) === 1 ){
							unset($demoMatches[0]);
							$strUrlTmp .= '&url='.urlencode($demoMatches[1]);
							$strMsgTmp .= '<b>'.$lang['code.str24'].'</b>'.$lang['template.strings24'].$demoMatches[1].'<br /><br />';
						}
						return '<br /><b>'.$lang['code.str25'].'</b>'.$lang['template.strings24'].$subjectMatches[1].'<br /><br /><b>'.$lang['code.str26'].'</b>'.$lang['template.strings24'].$bodyMatches[1].'<br /><br /><b>'.$lang['code.str27'].'</b>'.$lang['template.strings24'].$priceMatches[1].$lang['code.str20'].'<br /><br />'.$strMsgTmp.'<a href="http://pay.dvbbs.net/payto.asp?seller='.urlencode($sellerMatches[1]).'&subject='.urlencode($subjectMatches[1]).'&body='.urlencode($bodyMatches[1]).'&price='.urlencode($priceMatches[1]).$strUrlTmp.'&partner=2088002048522272&type=1&readonly=true" target="_blank"><img src="images/alipay/alipay_7.gif" border="0" alt="'.$lang['code.str28'].'"></a>&nbsp;&nbsp;<a href="http://server.dvbbs.net/dvbbs/alipay/b.htm" target="_blank"><font color="blue">'.$lang['code.str29'].'</font></a><br />';
					}
				}
			}
		}
	}
	return $match_0;
}//end funciton __InnerPaytoCodeProcess

function _InnerUbbCodeProcess_username($match_1,$match_2,$match_0,$currUserName){
	global $board_settings,$membername,$lang;
	if( $board_settings[79] == 1 ){
		if( $membername != '' && ( $membername == $currUserName || strpos(",{$match_1},",",{$membername},") !== false ) ){
			return '<hr /><font color="red">'.$lang['code.str30'].'<b>'.$match_1.'</b>'.$lang['code.str31'].'</font><br />'.$match_2.'<hr />';
		} else{
			return '<hr /><font color="gray">'.$lang['code.str30'].'<b>'.$match_1.'</b>'.$lang['code.str31'].'</font><br /><hr />';
		}
	} else{
		return $match_2;
	}
}//end function _InnerUbbCodeProcess_username

//帖子内容,发帖人组别,发帖类型,,,,,,用户积分,是否开放ubb标签
//正则表达式数组、发帖人组别，发帖类型、用户积分、是否开发UBB标签
function Dv_UbbCode_Get($arrPattern,$PostUserGroup,$PostType,$UsePoint,$flag){
	global $board_settings;
}//end function Dv_UbbCode_Get

//判断是否存在JavaScript代码
function Dv_HasJSCode(&$code){
	return ( preg_match('/((\<script(?:.*?)\>)|(\<\/script(?:.*?)\>))|((javascript(.*?):))|((vbscript(.*?):))|((on(?:\w+?)=))/i',preg_quote($code)) === 0 ? false : true );
}//end function Dv_HasJSCode

//签名UBB转换
function &Dv_SignUbbCode(&$code,$PostUserGroup){
	global $lang,$fsetting,$board_settings;
	//print '$code:'.$code.'<br />';
	//return $code;
	if( Dv_HasJSCode($code) === true ){
		$code = htmlspecialchars($code);
		$errorCode = <<<EOT
			<form name="scode{$GLOBALS['replyid']}" method="post" action=""><table class="tableborder2" cellspacing="1" cellpadding="3" width="100%" align="center" border="0"><tr><th height="22">{$lang['code.str32']}</th></tr><tr><td class="tablebody1" align="middle" width="98%"><textarea id="CodeText" style="BORDER-RIGHT: 1px dotted; BORDER-TOP: 1px dotted; OVERFLOW-Y: visible; OVERFLOW: visible; BORDER-LEFT: 1px dotted; WIDth: 98%; COLOR: #000000; BORDER-BOTTOM: 1px dotted" rows="20" cols="120">{$code}</textarea></td></tr><tr><td class="tablebody2" align="middle" width="98%">{$lang['code.str33']}</td></tr><tr><td class="tablebody1" align="middle" width="98%"><input type="button" name="run" value="{$lang['code.str12']}" onclick="Dvbbs_ViewCode({$GLOBALS['replyid']});"></td></tr></table></form>
EOT;
		return $errorCode;
	}
	$PostUserGroup = intval($PostUserGroup);
	$arrPattern = array('/  /i', '/\[(br)]/i');
	$arrRepl = array('&nbsp;&nbsp;', '<br />');
	if( $fsetting['signhtmlcode'] == 0 ){//用户签名是否开启HTML代码
		$code = htmlspecialchars($code);
		$arrPattern[] = '/([^\r])\n/i';
		$arrRepl[] = '$1<br />';
		$arrPattern[] = '/\r\n(.*)/i';
		$arrRepl[] = '<p>$1</p>';
	} else{
		$code = str_replace(array('&gt;', '&lt;', '&quot;', "'", '&amp;'), array('>', '<', '"', '&#039;', '&'), $code);
		$arrPattern[] = '/<((?:asp|\!|%))/i';
		$arrRepl[] = '&lt;$1';
		$arrPattern[] = '/(>)([\r\n])(<)/i';
		$arrRepl[] = '$1$3';
		$arrPattern[] = '/(>)([\r\n][\r\n])(<)/i';
		$arrRepl[] = '$1$3';
	}
	if( intval($fsetting['signubbcode']) === 0 ){//常规设置不支持UBB代码，则退出
		return preg_replace( $arrPattern ,$arrRepl ,$code );
	}
	$board_setting68 = intval($board_settings[68]);
//Start br 标签处理
	$arrPattern[] = '/\[(br)]/i';
	$arrRepl[] = '<br />';
//End br 标签处理
//Start url 标签处理
		//$arrPattern[] = '/\[url=((?:\w+:\/\/)?(?:[^\/:]+?)(?::\d*?)?(?:[^]\n])*?)](.*?)\[\/url]/ies';
		$arrPattern[] = '#\[url=(.+?)](.+?)\[/url]#ies';
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank">\'.str_filter_xss("$2").\'</a>\'';
		$arrPattern[] = '#\[url](.+?)\[/url]#ies';
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target=\"_blank\">\'.str_filter_xss("$1").\'</a>\'';
//End url 标签处理
//Start img标签处理
	$arrPattern[] = '/\[img]((?:\w+:\/\/)?(?:[^\/:]+?)(?::\d*?)?(?:[^]\n])*?)\[\/img]/ies';
	if( $board_setting68 == 1 ){
		$arrRepl[] = '\'<img src="\'.str_filter_xss("$1").\'" border="0"/ >\'';
	} else{
		//$arrRepl[] =& $lang['template.strings20'];
		$arrRepl[] = '\'<img src="skins/default/filetype/gif.gif" border="0"><a onfocus="this.blur()" href="\'.str_filter_xss("$1").\'" target="_blank">\'.str_filter_xss("$1").\'</a>\'';
	}
//End img标签处理
//Start sound 标签处理
	$arrPattern[] = '/\[sound](.*)\[\/sound]/ie';
	if( $board_settings[71] * $mt == 1 ){
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank"><img src="images/filetype/mid.gif" border="0" alt="'.$lang['code.str1'].'" /></a><bgsound src="\'.str_filter_xss("$1").\'" loop="-1">\'';
	} else{
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$1").\'" target="_blank">\'.str_filter_xss("$1").\'</a>\'';
	}
//End sound 标签处理
//Start flash 标签处理
	$arrPattern[] = '/\[flash(?:\=([0-9]+),([0-9]+))?]([^\s\[]*)\[\/flash]/ei';
	if( $board_settings[70] == 1 ){
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$3").\'" target="_blank"><img src=images/filetype/swf.gif border="0" alt="'.$lang['template.strings7'].'" height="16" width="16" />'.$lang['template.strings'].'</a><br /><object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  width="\'.(is_numeric("$1") ? "$1" : 500).\'" height="\'.(is_numeric("$2") ? "$2" : 400).\'"><param name="movie" value="\'.str_filter_xss("$3").\'" /><param name="quality" value="high" /><embed src="\'.str_filter_xss("$3").\'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="$1" height="$2">\'.str_filter_xss("$3").\'</embed></object>\'';
	} else{
		$arrRepl[] = '\'<a href="\'.str_filter_xss("$3").\'" target="_blank">$3</a>\'';
	}
//End flash 标签处理
//Start email 标签处理
	$arrPattern[] = '/\[email](.*?)\[\/email]/eis';
	$arrRepl[] = '\'<a href="mailto:$1">\'.str_filter_xss("$1").\'</a>\'';
//End email 标签处理
//Start html 标签处理
	$arrPattern[] = '/\[html](.*?)\[\/html]/eis';
	$Floor = 1;
	$arrRepl[] = '_InnerUbbCodeProcess_Html("$1",$Floor++);';
//End html 标签处理
//Start color 标签处理
	$arrPattern[] = '/\[color\s*=\s*(\#[a-zA-Z0-9]{6}|[a-zA-z]+)]\s*(.*?)\s*\[\/color]/im';
	$arrRepl[] = '<font color="$1">$2</font>';
//End color 标签处理
//Start face 标签处理
	$arrPattern[] = '/\[face *= *(.+?)]\s*(.+?)\s*\[\/face]/im';
	$arrRepl[] = '<font face="$1">$2</font>';
//End face 标签处理
//Start align 标签处理
	$arrPattern[] = '/\[align *?= *?(left|center|right)](.*?)\[\/align]/i';
	$arrRepl[] = '<div align="$1">$2</div>';
//End align 标签处理
//Start shadow 标签处理
	$arrPattern[] = '/\[shadow=([0-9]+),((?:\#[0-9]{6})|(?:[a-zA-Z]+)),([0-9]+)](.+?)\[\/shadow]/i';
	$arrRepl[] = '<div style="width:$1px;filter:shadow(color=$2, strength=$3)">$4</div>';
//End shadow 标签处理
//Start glow 标签处理
	$arrPattern[] = '/\[glow=([0-9]+),((?:\#[0-9]{6})|(?:[a-zA-Z]+)),([0-9]+)](.+?)\[\/glow]/i';
	$arrRepl[] = '<div style="width:$1px;filter:glow(color=$2, strength=$3)">$4</div>';
//End glow 标签处理
//Start fly 标签处理
	$arrPattern[] = '/\[fly](.*?)\[\/fly]/i';
	$arrRepl[] = '<marquee width="90%" behavior="alternate" scrollamount="3">$1</marquee>';
//End fly 标签处理
//Start size 标签处理
	$arrPattern[] = '/\[size *= *([0-9]+)]\s*(.+?)\s*\[\/size]/im';
	$arrRepl[] = '<font size="$1">$2</font>';
//End size 标签处理
//Start i 标签处理
	$arrPattern[] = '/\[i](.*?)\[\/i]/i';
	$arrRepl[] = '<i>$1</i>';
//End i 标签处理
//Start b 标签处理
	$arrPattern[] = '/\[b](.*?)\[\/b]/i';
	$arrRepl[] = '<b>$1</b>';
//End b 标签处理
//Start u 标签处理
	$arrPattern[] = '/\[u](.*?)\[\/u]/i';
	$arrRepl[] = '<u>$1</u>';
//End u 标签处理
	//加上签名是否开放HTML判断
	if( $board_settings[66] == 1 && $fsetting['signhtmlcode'] == 1 ){
		if( strpos(strtolower($code),'http://') !== false ){//自动识别网址
			$arrPattern[] = '/(^|[^<="])(http:(\/\/|\\\\)(([\w\/\\\+\-~`@:%])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#]|(&)|&)+)/ei';
			$arrRepl[] = '\'$1<a target="_blank" href="\'.str_filter_xss("$2").\'">\'.str_filter_xss("$2").\'</a>\'';
		}
		if( strpos(strtolower($code),'www.') !== false || strpos(strtolower($code),'bbs.') !== false ){//自动识别www等开头的网址
			$arrPattern[] = '/(^|[^\/\\\w\=])((www|bbs)\.(\w)+\.([\w\/\\\.\=\?\+\-~`@\'!%#]|(&))+)/ei';
			$arrRepl[] = '\'$1<a target="_blank" href="http://\'.str_filter_xss("$2").\'">\'.str_filter_xss("$2").\'</a>\'';
		}
	}
	$arrPattern[] = '/<img(.[^>]*)>/i';
	$arrRepl[] = '<img$1 onload="return imgzoom(this,700)" >';
	$returnval = preg_replace($arrPattern, $arrRepl, $code);
	return $returnval;
}//end function Dv_SignUbbCode

function Ubblist(&$Str1){
	if( $Str1 == '' ){
		return '';
	}
	$arrDvUbb = array( 0=>'javascript' ,1=>'jscript:' ,2=>'js:' ,3=>'value' ,4=>'about:' ,5=>'file:' ,6=>'document.cookie' ,7=>'vbscript:' ,8=>'vbs:' ,9=>'mouse' ,10=>'exit' ,11=>'error' ,12=>'click' ,13=>'key' ,14=>'[/img]' ,15=>'[/upload]' ,16=>'[/dir]' ,17=>'[/qt]' ,18=>'[/mp]' ,19=>'[/rm]' ,20=>'[/sound]' ,21=>'[/flash]' ,22=>'[/money]' ,23=>'[/point]' ,24=>'[/usercp]' ,25=>'[/power]' ,26=>'[/post]' ,27=>'[/replyview]' ,28=>'[/usemoney]' ,29=>'[/url]' ,30=>'[/email]' ,31=>'http' ,32=>'https' ,33=>'ftp' ,34=>'rtsp' ,35=>'mms' ,36=>'[/html]' ,37=>'[/code]' ,38=>'[/color]' ,39=>'[/face]' ,40=>'[/align]' ,41=>'[/quote]' ,42=>'[/fly]' ,43=>'[/move]' ,44=>'[/shadow]' ,45=>'[/glow]' ,46=>'[/size]' ,47=>'[/i]' ,48=>'[/b]' ,49=>'[/u]' ,50=>'[em' ,51=>'www.' ,52=>'[/payto]' ,53=>'[/username]' ,54=>'[/center]' ,55=>'[/lastedittime]' );
	$returnVal = ',';
	$str = strtolower($Str1);
	for( $i = 0 ; $i <= 13 ; $i++ ){
		if( strpos($str,$arrDvUbb[$i]) !== false || strpos($str,'&#') !== false || strpos($str,'button') !== false ){
			$returnVal .= '0,';
			break;
		}
	}
	for( $i = 13 ; $i <= 55 ; $i++ ){
		if( strpos($str,$arrDvUbb[$i]) !== false ){
			if( $i >= 52 ){
				$returnVal .= ($i-12).',';
			} else{
				$returnVal .= ($i-13).',';
			}
		}
	}
	$returnVal .= '39,';
	if( isXhtml($str) === true ){
		$returnVal .= 'xhtml,';
		return $returnVal;
	}
	return preg_replace( '/ |  |\r|\n/i' ,'' ,$returnVal );
}//end function

function isXhtml(&$str){
	return false;
}
function istext(&$str){
	if( $str == '' ){
		return true;
	}
	if( $str == preg_replace( '/<(.[^>]*)>/i' ,'' ,$str ) ){
		return true;
	}
	return false;
}//end function istext


function getqihoomerge($phid){
	global $qihoo;
	$code="phid={$phid}&id={$phid}&spassword={$qihoo['spassword']}&ctime=".time();
	$code=urlencode(authcode($code,'ENCODE',$qihoo['skey']));
	$url="http://p.qihoo.com/flash/pic_view.swf?sid={$qihoo['sid']}&code={$code}";
	return $url;
}
?>