<?php

//替换字段html代码
function upChangeFieldRepHtml($fhtml,$ecms=0){
	$fhtml=str_replace('htmlspecialchars(','ehtmlspecialchars(',$fhtml);
	if($ecms==0)
	{
		$fhtml=str_replace('FileMain.php?','FileMain.php?infoid=<?=$id?>&sinfo=1&',$fhtml);
	}
	return $fhtml;
}

//获取特殊属性字段html代码
function upChangeFieldGetSpecialHtml(){
	$sysfdata=ReadFiletext('../data/html/sysfhtml.txt');
	$sysf_specialr=explode('[!--sys.special.field--]',$sysfdata);
	$sysf_specialtr=explode('[!--sys.qf.exp--]',$sysf_specialr[1]);
	return $sysf_specialtr;
}

//处理信息字段
function upChangeFieldInfo(){
	global $empire,$dbtbpre,$ecms_config;
	//特殊属性字段
	$sr=upChangeFieldGetSpecialHtml();
	$sql=$empire->query("select * from {$dbtbpre}enewsf");
	while($r=$empire->fetch($sql))
	{
		//评分字段
		if($r['f']=='infopfen'||$r['f']=='infopfennum')
		{
			continue;
		}
		if($r['f']=='special.field')//特殊属性
		{
			$fhtml=$sr[0];
			$cjhtml=$sr[2];
			$qfhtml=$sr[1];
		}
		else
		{
			$fhtml=upChangeFieldRepHtml($r['fhtml'],0);
			$cjhtml=upChangeFieldRepHtml($r['cjhtml'],1);
			$qfhtml=upChangeFieldRepHtml($r['qfhtml'],1);
		}
		$empire->query("update {$dbtbpre}enewsf set fhtml='".addslashes($fhtml)."',cjhtml='".addslashes($cjhtml)."',qfhtml='".addslashes($qfhtml)."' where fid='$r[fid]'");
	}
}

//处理会员字段
function upChangeFieldMember(){
	global $empire,$dbtbpre,$ecms_config;
	$sql=$empire->query("select * from {$dbtbpre}enewsmemberf");
	while($r=$empire->fetch($sql))
	{
		$fhtml=upChangeFieldRepHtml($r['fhtml'],1);
		$empire->query("update {$dbtbpre}enewsmemberf set fhtml='".addslashes($fhtml)."' where fid='$r[fid]'");
	}
}

//处理栏目字段
function upChangeFieldClass(){
	global $empire,$dbtbpre,$ecms_config;
	$sql=$empire->query("select * from {$dbtbpre}enewsclassf");
	while($r=$empire->fetch($sql))
	{
		$fhtml=upChangeFieldRepHtml($r['fhtml'],1);
		$empire->query("update {$dbtbpre}enewsclassf set fhtml='".addslashes($fhtml)."' where fid='$r[fid]'");
	}
}

//处理专题字段
function upChangeFieldZt(){
	global $empire,$dbtbpre,$ecms_config;
	$sql=$empire->query("select * from {$dbtbpre}enewsztf");
	while($r=$empire->fetch($sql))
	{
		$fhtml=upChangeFieldRepHtml($r['fhtml'],1);
		if($r['fform']=='editor')
		{
			$fhtml=str_replace(',\"Default\",\"\"',',\"Default\",\"../ecmseditor/infoeditor/\"',$fhtml);
		}
		$empire->query("update {$dbtbpre}enewsztf set fhtml='".addslashes($fhtml)."' where fid='$r[fid]'");
	}
}
?>