<?php
//2、转换 Discuz! 代码
$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}bbcodes") or die("检索数据表 '{$source_tablepre}bbcodes' 错误！<br>请将 Discuz! 代码表 '{$source_tablepre}bbcodes' 字段类型为 nText 的改为 Text 类型。");

$query1 = $xc->db['discuz']->query("SELECT tag FROM {$discuz_tablepre}forum_bbcode WHERE 1");
while ($results = $xc->db['discuz']->fetch_array($query1)) {
	$htags[] = $results['tag'];
}

while ($bbcode = $xc->db['source']->fetch_assoc($query)) {

	$bbcode		= daddslashes(array_change_key_case($bbcode));
	$id			= $bbcode['id'] + 4;		 // 保留原来的 4 个 Discuz! 代码，有重复的自行删除
	$available	= $bbcode['available'];
	$tag		= $bbcode['tag'];

	if (in_array($tag, $htags)) {
		continue;
	}

	$icon		=	 $bbcode['icon'];
	$replacement=	 $bbcode['replacement'];
	$example	=	 $bbcode['example'];
	$explanation=	 $bbcode['explanation'];
	$params		=	 $bbcode['params'];
	$prompt		=	 $bbcode['paramsdescript'];
	$nest		=	 $bbcode['nest'];
	
	$fields1 = array('id', 'available', 'tag', 'icon', 'replacement', 'example', 'explanation', 'params', 'prompt', 'nest');
	$query1 = getinsertsql("{$discuz_tablepre}forum_bbcode", $fields1);
	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("插入 Discuz! 代码基本数据出错 id = $id tag = $tag");
	}
	$totalrows ++;
}
?>