<?php
require_once '../../Config.php';
if (count ( BLL_Admin::getAdminNow () ) <= 0) {
	header ( 'Location:../index.html' );
	die ();
}
if (! array_key_exists ( 'action', $_REQUEST )) {
	header ( 'Location:../index.html' );
}
header ( "Content-Type: text/html; charset=utf-8" );

switch ($_REQUEST ['action']) {
	// ======================表结构设置==================================
	// 添加字段
	case 'dataStructure_Add' :
		dataStructureAdd ();
		break;
	// 删除字段
	case 'dataStructureDel' :
		dataStructureDel ();
		break;
	// ======================表单设置==================================
	// 添加表单项
	case 'formSet_Add' :
		formSetAdd ();
		break;
	// 编辑表单项
	case 'formSet_Edit' :
		formSetEdit ();
		break;
	// 删除表单项
	case 'formSet_Del' :
		formSet_Del ();
		break;
	// 代码生成
	case 'makeCode' :
		switch ($_GET ['tableName']) {
			case 'tb_onepage' :
				MakeEditOnePage ();
				break;
			case 'tb_newssort' :
				MakeNewsSort ();
				break;
			case 'tb_news' :
				MakeNews ();
				break;
			case 'tb_linksort' :
				MakeLinkSort ();
				break;
			case 'tb_link' :
				MakeLink ();
				break;
			case 'tb_member' :
				MakeMember ();
				break;
			default :
				break;
		}
		break;
	default :
		break;
}

// 添加字段
function dataStructureAdd() {
	global $conn;
	$theTable = $_SESSION ['dataTable'];
	$columnsType = $_POST ['columnsType'];
	$columnsCode = $_POST ['columnsCode'];
	switch ($columnsType) {
		case '1' :
			$columnsType = "varchar(255)";
			break;
		case '2' :
			$columnsType = "int(11)";
			break;
		case '3' :
			$columnsType = "longtext";
			break;
		case '4' :
			$columnsType = "datetime";
			break;
		default :
			break;
	}
	$sql = "alter table " . $theTable . " add " . $columnsCode . ' ' . $columnsType;
	if ($conn->Execute ( $sql )) {
		echo "<script type=\"text/javascript\" >\r\n";
		echo "if (navigator.appName==\"Microsoft Internet Explorer\")\r\n";
		echo "{\r\n";
		echo "window.dialogArguments.location.href=window.dialogArguments.location.href;\r\n";
		echo "}\r\n";
		echo "else\r\n";
		echo "{\r\n";
		echo "window.opener.location.href=window.opener.location.href;\r\n";
		echo "}\r\n";
		echo "window.close();\r\n";
		echo "</script>\r\n";
	}
}
// 删除字段
function dataStructureDel() {
	global $conn;
	$theTable = $_GET ['theTable'];
	$theCode = $_GET ['theCode'];
	$sql = "alter table $theTable drop column $theCode";
	if ($conn->Execute ( $sql )) {
		echo COM_OftenJavaScript::parentRefurbish ();
	}
}
// 添加表单
function formSetAdd() {
	$theTable = $_SESSION ['dataTable'];
	$code = $_POST ['code'];
	$codeType = getColType ( $theTable, $code );
	$theId = $_POST ['theId'];
	$showName = $_POST ['showName'];
	$type = $_POST ['type'];
	$showMore = $_POST ['showMore'];
	
	$doc = new DOMDocument ();
	$doc->formatOutput = true;
	if ($doc->load ( "FormData.XML" )) {
		$root = $doc->documentElement;
		$item = $doc->createElement ( 'item' );
		xmlAddSx ( $doc, $item, "id", date ( "YmdHis" ) );
		xmlAddSx ( $doc, $item, "theTable", $theTable );
		xmlAddSx ( $doc, $item, "code", $code );
		xmlAddSx ( $doc, $item, "codeType", $codeType );
		xmlAddSx ( $doc, $item, "type", $type );
		xmlAddSx ( $doc, $item, "theId", $theId );
		xmlAddSx ( $doc, $item, "showName", $showName );
		xmlAddSx ( $doc, $item, "showMore", $showMore );
		$root->appendChild ( $item );
		$doc->save ( "FormData.XML" );
	}
	
	echo "<script type=\"text/javascript\" >\r\n";
	echo "if (navigator.appName==\"Microsoft Internet Explorer\")\r\n";
	echo "{\r\n";
	echo "window.dialogArguments.location.href=window.dialogArguments.location.href;\r\n";
	echo "}\r\n";
	echo "else\r\n";
	echo "{\r\n";
	echo "window.opener.location.href=window.opener.location.href;\r\n";
	echo "}\r\n";
	echo "window.close();\r\n";
	echo "</script>\r\n";
}
// 编辑表单项
function formSetEdit() {
	$xmlId = floor ( $_POST ['xmlId'] );
	$theTable = $_SESSION ['dataTable'];
	$code = $_POST ['code'];
	$codeType = getColType ( $theTable, $code );
	$theId = $_POST ['theId'];
	$showName = $_POST ['showName'];
	$type = $_POST ['type'];
	$showMore = $_POST ['showMore'];
	$isOk = false;
	
	$doc = new DOMDocument ();
	$doc->formatOutput = true;
	if ($doc->load ( "FormData.XML" )) {
		$root = $doc->documentElement;
		$items = $root->getElementsByTagName ( 'item' );
		foreach ( $items as $item ) {
			if ($item->getAttribute ( 'id' ) == $xmlId) {
				$item->setAttribute ( 'code', $code );
				$item->setAttribute ( 'codeType', $codeType );
				$item->setAttribute ( 'theID', $theId );
				$item->setAttribute ( 'showName', $showName );
				$item->setAttribute ( 'type', $type );
				$item->setAttribute ( 'showMore', $showMore );
				$doc->save ( "FormData.XML" );
				$isOk = true;
			}
		}
	}
	if ($isOk) {
		echo "<script type=\"text/javascript\" >\r\n";
		echo "if (navigator.appName==\"Microsoft Internet Explorer\")\r\n";
		echo "{\r\n";
		echo "window.dialogArguments.location.href=window.dialogArguments.location.href;\r\n";
		echo "}\r\n";
		echo "else\r\n";
		echo "{\r\n";
		echo "window.opener.location.href=window.opener.location.href;\r\n";
		echo "}\r\n";
		echo "window.close();\r\n";
		echo "</script>\r\n";
	}
}
// 删除表单项
function formSet_Del() {
	$theTable = $_SESSION ['dataTable'];
	$theId = $_GET ['theId'];
	$isOk = false;
	$doc = new DOMDocument ();
	$doc->formatOutput = true;
	if ($doc->load ( "FormData.XML" )) {
		$root = $doc->documentElement;
		$items = $root->getElementsByTagName ( 'item' );
		foreach ( $items as $item ) {
			if ($item->getAttribute ( 'id' ) == $theId) {
				if ($root->removeChild ( $item )) {
					$doc->save ( "FormData.XML" );
					$isOk = true;
				}
			}
		}
	}
	if ($isOk) {
		echo COM_OftenJavaScript::parentRefurbish ();
	} else {
		echo COM_OftenJavaScript::parentAlertRefurbishParent ( "删除失败" );
	}
}
// 生成修改单页代码
function MakeEditOnePage() {
	$MakeStr = MakeCode ( "Edit" );
	$file_name = "OnePage_Edit.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../OnePage/OnePage_Edit.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	echo COM_OftenJavaScript::parentAlertRefurbishParent ( "生成完成" );
}
// 生成新闻类别代码
function MakeNewsSort() {
	$MakeStr = MakeCode ( "Add" );
	$file_name = "NewsSort_Add.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../News/NewsSort_Add.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	
	$MakeStr = MakeCode ( "Edit" );
	$file_name = "NewsSort_Edit.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../News/NewsSort_Edit.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	echo COM_OftenJavaScript::parentAlertRefurbishParent ( "生成完成" );
}
// 生成新闻代码
function MakeNews() {
	$MakeStr = MakeCode ( "Add" );
	$file_name = "News_Add.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../News/News_Add.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	
	$MakeStr = MakeCode ( "Edit" );
	$file_name = "News_Edit.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../News/News_Edit.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	echo COM_OftenJavaScript::parentAlertRefurbishParent ( "生成完成" );
}
// 生成链接类别代码
function MakeLinkSort() {
	$MakeStr = MakeCode ( "Add" );
	$file_name = "LinkSort_Add.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../Link/LinkSort_Add.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	
	$MakeStr = MakeCode ( "Edit" );
	$file_name = "LinkSort_Edit.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../Link/LinkSort_Edit.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	echo COM_OftenJavaScript::parentAlertRefurbishParent ( "生成完成" );
}
// 生成链接代码
function MakeLink() {
	$MakeStr = MakeCode ( "Add" );
	$file_name = "Link_Add.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../Link/Link_Add.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	
	$MakeStr = MakeCode ( "Edit" );
	$file_name = "Link_Edit.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../Link/Link_Edit.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	echo COM_OftenJavaScript::parentAlertRefurbishParent ( "生成完成" );
}
// 生成会员代码
function MakeMember() {
	$MakeStr = MakeCode ( "Add" );
	$file_name = "Member_Add.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../Member/Member_Add.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	
	$MakeStr = MakeCode ( "Edit" );
	$file_name = "Member_Edit.txt";
	$file_pointer = fopen ( $file_name, "ra" );
	$file_read = fread ( $file_pointer, filesize ( $file_name ) );
	fclose ( $file_pointer );
	$NewsCode = str_ireplace ( "<!--这里是生成位置-->", $MakeStr, $file_read );
	$file_name = "../Member/Member_Edit.php";
	$file_pointer = fopen ( $file_name, "wa" );
	fwrite ( $file_pointer, $NewsCode, strlen ( $NewsCode ) );
	fclose ( $file_pointer );
	echo COM_OftenJavaScript::parentAlertRefurbishParent ( "生成完成" );
}
// 生成代码
function MakeCode($TheType) {
	$xml = simplexml_load_file ( "FormData.XML" );
	$newArr = null;
	foreach ( $xml as $key => $value ) {
		$tempArr = $value->attributes ();
		if ($tempArr ['theTable'] != $_SESSION ['dataTable']) {
			continue;
		}
		if ($newArr == null) {
			$newArr [] = $tempArr;
		} else {
			$iszd = false;
			foreach ( $newArr as $newvalue ) {
				if (strcmp ( $newvalue ['code'], $tempArr ['code'] ) != 0) {
					continue;
				}
				if (strcmp ( $newvalue ['codeType'], $tempArr ['codeType'] ) != 0) {
					continue;
				}
				if (strcmp ( $newvalue ['type'], $tempArr ['type'] ) != 0) {
					continue;
				}
				if (strcmp ( $newvalue ['showName'], $tempArr ['showName'] ) != 0) {
					continue;
				}
				if (strcmp ( $newvalue ['showMore'], $tempArr ['showMore'] ) != 0) {
					continue;
				}
				$newvalue ['theId'] = $newvalue ['theId'] . '|' . $tempArr ['theId'];
				$iszd = true;
			}
			if (! $iszd) {
				$newArr [] = $tempArr;
			}
		}
	}
	if (! isset ( $newArr )) {
		return;
	}
	$Make_Str = "";
	if ($TheType == "Add") {
		foreach ( $newArr as $newvalue ) {
			$TheName = $newvalue ['code'] . "_";
			switch ($newvalue ['codeType']) {
				case "C" :
				case "X" :
					$TheName .= 'txt';
					break;
				case "I" :
					$TheName .= 'int';
					break;
				case "D" :
				case "T" :
					$TheName .= 'time';
					break;
			}
			$TheValue = "<?php echo \$makeData['" . $newvalue ['code'] . "']; ?>";
			switch (( string ) $newvalue ['type']) {
				case '1' : // 文本框添加
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td><input type=\"text\" name=\"$TheName\" value=\"\" size=\"40\" /></td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '2' : // 文本域添加
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td><textarea name=\"$TheName\" cols=\"60\" rows=\"6\"></textarea></td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '3' : // 选择列表添加
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n\r\n";
					$Make_Str .= "			<select name=\"$TheName\" id=\"$TheName\">\r\n";
					$optionArr = explode ( '~--~', $newvalue ['showMore'] );
					foreach ( $optionArr as $OneOption ) {
						$OneOptionArr = explode ( '%%$$', $OneOption );
						$Make_Str .= "				<option value=\"$OneOptionArr[0]\">$OneOptionArr[1]</option>\r\n";
					}
					$Make_Str .= "			</select>\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '4' : // 复选框添加
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$optionArr = explode ( '~--~', $newvalue ['showMore'] );
					foreach ( $optionArr as $OneOption ) {
						$OneOptionArr = explode ( '%%$$', $OneOption );
						$Make_Str .= "			<input type=\"checkbox\"  name=\"temp$TheName\" onclick=\"setFxk('$TheName','')\" value=\"$OneOptionArr[0]\" \>&nbsp;&nbsp;$OneOptionArr[1]\r\n";
					}
					$Make_Str .= "			<input type=\"hidden\"  name=\"$TheName\" id=\"$TheName\" value=\"\"  />\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '5' : // 单选框添加
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$optionArr = explode ( '~--~', $newvalue ['showMore'] );
					$i = 1;
					foreach ( $optionArr as $OneOption ) {
						$OneOptionArr = explode ( '%%$$', $OneOption );
						$Make_Str .= "			<input type=\"radio\"  name=\"$TheName\" value=\"$OneOptionArr[0]\"";
						if ($i <= 1) {
							$Make_Str .= " checked=\"checked\"";
						}
						$i ++;
						$Make_Str .= " \>&nbsp;&nbsp;$OneOptionArr[1]\r\n";
					}
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '6' : // 图片添加
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$Make_Str .= "			<input type=\"text\" name=\"$TheName\" value=\"\" size=\"40\" />\r\n";
					$Make_Str .= "			<input type=\"button\" onclick=\"showUploadDialog('image','theForm.$TheName')\" value=\"图片上传\" class=\"btn\" />\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '7' : // 文件添加
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$Make_Str .= "			<input type=\"text\" name=\"$TheName\" value=\"\" size=\"40\" />\r\n";
					$Make_Str .= "			<input type=\"button\" onclick=\"showUploadDialog('file','theForm.$TheName')\" value=\"文件上传\" class=\"btn\" />\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				default :
					break;
			}
		}
	}
	if ($TheType == "Edit") {
		foreach ( $newArr as $newvalue ) {
			$TheName = $newvalue ['code'] . "_";
			switch ($newvalue ['codeType']) {
				case "C" :
				case "X" :
					$TheName .= 'txt';
					break;
				case "I" :
					$TheName .= 'int';
					break;
				case "D" :
				case "T" :
					$TheName .= 'time';
					break;
			}
			$TheValue = "<?php echo \$makeData['" . $newvalue ['code'] . "']; ?>";
			switch (( string ) $newvalue ['type']) {
				case '1' : // 文本框修改
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td><input type=\"text\" name=\"$TheName\" value=\"$TheValue\" size=\"40\" /></td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '2' : // 文本域修改
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td><textarea name=\"$TheName\" cols=\"60\" rows=\"6\">$TheValue</textarea></td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '3' : // 选择列表修改
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$Make_Str .= "			<select name=\"$TheName\" id=\"$TheName\">\r\n";
					$optionArr = explode ( '~--~', $newvalue ['showMore'] );
					foreach ( $optionArr as $OneOption ) {
						$OneOptionArr = explode ( '%%$$', $OneOption );
						$Make_Str .= "				<option value=\"$OneOptionArr[0]\">$OneOptionArr[1]</option>\r\n";
					}
					$Make_Str .= "			</select>\r\n";
					$Make_Str .= "			<script type=\"text/javascript\">\r\n";
					$Make_Str .= "			document.getElementById(\"$TheName\").value=\"$TheValue\";\r\n";
					$Make_Str .= "			</script>\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '4' : // 复选框修改
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$optionArr = explode ( '~--~', $newvalue ['showMore'] );
					foreach ( $optionArr as $OneOption ) {
						$OneOptionArr = explode ( '%%$$', $OneOption );
						$Make_Str .= "			<input type=\"checkbox\"  name=\"temp$TheName\" onclick=\"setFxk('$TheName','')\" value=\"$OneOptionArr[0]\" \>&nbsp;&nbsp;$OneOptionArr[1]\r\n";
					}
					$Make_Str .= "			<input type=\"hidden\"  name=\"$TheName\" id=\"$TheName\" value=\"$TheValue\"  />\r\n";
					$Make_Str .= "			<script type=\"text/javascript\">\r\n";
					$Make_Str .= "			setFxk(\"$TheName\",\"<?php echo \$makeData['$newvalue[code]']; ?>\");\r\n";
					$Make_Str .= "			</script>\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '5' : // 单选框修改
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$optionArr = explode ( '~--~', $newvalue ['showMore'] );
					foreach ( $optionArr as $OneOption ) {
						$OneOptionArr = explode ( '%%$$', $OneOption );
						$Make_Str .= "			<input type=\"radio\"  name=\"$TheName\" value=\"$OneOptionArr[0]\" \>&nbsp;&nbsp;$OneOptionArr[1]\r\n";
					}
					$Make_Str .= "			<script type=\"text/javascript\">\r\n";
					$Make_Str .= "			setDxk(\"$TheName\",\"<?php echo \$makeData['$newvalue[code]']; ?>\");\r\n";
					$Make_Str .= "			</script>\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '6' : // 图片修改
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$Make_Str .= "			<input type=\"text\" name=\"$TheName\" value=\"$TheValue\" size=\"40\" />\r\n";
					$Make_Str .= "			<input type=\"button\" onclick=\"showUploadDialog('image','theForm.$TheName')\" value=\"图片上传\" class=\"btn\" />\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				case '7' : // 文件修改
					$Make_Str .= "	<?php if(strpos(\"|$newvalue[theId]|\",\"|\$findId|\")!==false){ ?>\r\n";
					$Make_Str .= "	<tr>\r\n";
					$Make_Str .= "		<th>$newvalue[showName]：</th>\r\n";
					$Make_Str .= "		<td>\r\n";
					$Make_Str .= "			<input type=\"text\" name=\"$TheName\" value=\"$TheValue\" size=\"40\" />\r\n";
					$Make_Str .= "			<input type=\"button\" onclick=\"showUploadDialog('file','theForm.$TheName')\" value=\"文件上传\" class=\"btn\" />\r\n";
					$Make_Str .= "		</td>\r\n";
					$Make_Str .= "	</tr>\r\n";
					$Make_Str .= "	<?php } ?>\r\n\r\n";
					break;
				default :
					break;
			}
		}
	}
	return $Make_Str;
}
// 获取字段类型
function getColType($tableName, $col) {
	global $conn;
	$sql = 'select * from ' . $tableName;
	$rs = $conn->Execute ( $sql );
	for($i = 0; $i < $rs->FieldCount (); $i ++) {
		$fld = $rs->FetchField ( $i );
		if (strtolower ( $fld->name ) == strtolower ( $col )) {
			return $rs->MetaType ( $fld->type );
		}
	}
}
// XML添加一个属性
function xmlAddSx($doc, $item, $name, $value) {
	$sxm = $doc->createAttribute ( $name );
	$sxz = $doc->createTextNode ( $value );
	$sxm->appendChild ( $sxz );
	$item->appendChild ( $sxm );
}
?>