<?php


//$array['form_type'] , $array['title'] , $array['field_id'] , $array['form_set'] , $array['form_value'] , $array['form_word'] , $array['add_field_id'] , $array['add_field_id_more'] , $array['mustfill']



function formMoudlePost( $array ){
global $webdb,$str_ieedit_js;

$array['form_word'] = stripslashes ( $array['form_word'] );

switch ( $array['form_type'] ) {
    case "text"://单行文本框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}

			if( $array['mustfill'] == 0 ){
			
				if( empty( $array['form_word'] ) )$array['form_word'] = "";
				$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."："."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><input name=\"".$array['field_id']."\" type=\"text\" id=\"".$array['field_id']."\" size=\"50\" value=\"".$array['form_value']."\" ".stripslashes ( $array['form_set'] )." />". $array['form_word'] ."</td>
    </tr>";
				
			}elseif( $array['mustfill'] == 1 ){
			
				if( empty( $array['form_word'] ) )$array['form_word'] = "";
				$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."："."<font color=red>(必填)</font></td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><input name=\"".$array['field_id']."\" type=\"text\" id=\"".$array['field_id']."\" size=\"50\" value=\"".$array['form_value']."\" ".stripslashes ( $array['form_set'] )." />". $array['form_word'] ."</td>
    </tr>";
	
			}elseif( $array['mustfill'] == 2 ){
			
				$str .= "<input name=\"".$array['field_id']."\" type=\"hidden\" value=\"".$array['form_value']."\">";
				
			}
	      
        break;
		
    case "textarea"://多行文本框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		if( empty( $array['form_set'] ) ){
			$idedit_w = "80";
			$idedit_h = "8";
		}else{
			$detail=explode("*",$array['form_set']);
			$idedit_w = $detail[0];
			$idedit_h = $detail[1];
		}
		
		//if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><textarea name=\"".$array['field_id']."\" id=\"".$array['field_id']."\"  cols=\"".$idedit_w."\" rows=\"".$idedit_h."\">".$array['form_value']."</textarea>". $array['form_word'] ."</td>
    </tr>";
		/*
		if( $array['mustfill'] == 0 ){
			
		
			if( empty( $array['form_set'] ) ){
				$idedit_w = "80";
				$idedit_h = "8";
			}else{
				$detail=explode("*",$array['form_set']);
				$idedit_w = $detail[0];
				$idedit_h = $detail[1];
			}

			
				if( empty( $array['form_word'] ) )$array['form_word'] = "";
				$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."："."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><textarea name=\"".$array['field_id']."\" cols=\"".$idedit_w."\" rows=\"".$idedit_h."\">".$array['form_value']."</textarea>". $array['form_word'] ."</td>
    </tr>";
				
			}elseif( $array['mustfill'] == 1 ){
			
				if( empty( $array['form_word'] ) )$array['form_word'] = "";
				$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."："."<font color=red>(必填)</font></td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><textarea name=\"".$array['field_id']."\" cols=\"".$idedit_w."\" rows=\"".$idedit_h."\">".$array['form_value']."</textarea>". $array['form_word'] ."</td>
    </tr>";
	
			}
			*/
		break;
	
	case "select"://下拉菜单
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		$detail=explode("\r\n",$array['form_set']);
		
		$array['form_value'] =explode("/",$array['form_value']);
		$array['form_value'] =array_flip($array['form_value']);
		
		if( $array['auto_select'] == "1" ){//随机选择
			$_show = "<!--\nEOT;\nunset(\$str);\n";
			$select_num = count($detail);//取总数
			$_show .= "\$select_num = $select_num;\n";//随机取 selected
			$_show .= "\$selected_num = make_1_rand(1,\$select_num,1);\n";//随机取 selected
			for($i=0;$i<count($detail);$i++){
				
				list($a1,$a2)=explode("|",$detail[$i]); 
				
				$s = 0;
				$_show .= "if(\$selected_num==".$a1.") { \$str = '";
				foreach( $detail AS $key=>$value){ 
				
					if($value===''){ continue; } 
					list($v1,$v2)=explode("|",$value); 
					$v2 ||$v2=$v1; 
					$_show.="<option value=\"".$v1."\"";
					if($i == $s){$_show.=" selected";} 
					$_show.=">".$v2."</option>\n";
				
				$s++;
				} 
				$_show .= "'; }\n";
			}
			$_show .= "print <<<EOT\n-->\n\$str\n";
			//随机选择 -》 end
		}else{
			$i = 0;
			foreach( $detail AS $key=>$value){
				if($value===''){
					continue;
				}
				list($v1,$v2)=explode("|",$value);
				$v2 || $v2=$v1;
				$_show.="<option value=\"$v1\"";
				
				//if(array_key_exists($v1, $array['form_value'])){$_show.=" selected";}
				if(array_key_exists($v1, $array['form_value'])){//array_key_exists 检查给定的键名或索引是否存在于数组中
					$_show.=" selected";
				}
				elseif( $auto_select == "1" ){
					if($i == $selected_num)$_show.=" selected";
				}
	
				$_show.=">".$v2."</option>\n	  	";
			$i++;
			}
		}

		//插入函数
		$add_fun_1 = '';
		$add_fun_2 = '';
		if($array['add_field_id']){
			$add_fun_1 = ' onChange="MM_AddTxt(this)"';
			if($array['add_field_id_more'] == "1"){
				$add_fun_2 = '<script language="JavaScript">
<!--
function MM_AddTxt(selObj){ //v3.0
  va=selObj.options[selObj.selectedIndex].value
  if (va!=\'\'){
  	if(get_obj(\''.$array['add_field_id'].'\').value==\'\'){
		get_obj(\''.$array['add_field_id'].'\').value=va;
	}else{
		vb=get_obj(\''.$array['add_field_id'].'\').value;
		arr = vb.split(\' \');
		for(var i=0;i<arr.length;i++){
			if(arr[i]==va){
				alert(va+",已经存在了,不能雷同");
				return ;
			}
		}
		//va = va.replace(" ", " "); 
		//va = va.replace(" ", " "); 
		get_obj(\''.$array['add_field_id'].'\').value+="|"+va;
	}
  } 
}
//-->
</script>';
			}else{
				$add_fun_2 = '<script language="JavaScript">
<!--
function MM_AddTxt(selObj){ //v3.0
  va=selObj.options[selObj.selectedIndex].value
  if (va!=\'\'){
  	get_obj(\''.$array['add_field_id'].'\').value=va;
  } 
}
//-->
</script>';
			}			
		}
		//插入函数
		$show="    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><select name=\"".$array['field_id']."\" id=\"".$array['field_id']."\" ".$add_fun_1.">
	  	$_show</select> ". $array['form_word'] ."</td>
    </tr>
	".$add_fun_2;
		$str .=  $show;
	
		break;
		
	case "radio"://单选框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		$detail=explode("\r\n",$array['form_set']);
		
		$array['form_value'] =explode("/",$array['form_value']);
		$array['form_value'] =array_flip($array['form_value']);
			
		foreach( $detail AS $key=>$value){
			if($value===''){
				continue;
			}
			list($v1,$v2)=explode("|",$value);
			$v2 || $v2=$v1;
			$_show.="<label><input type=\"radio\" name=\"".$array['field_id']."\" value=\"".$v1."\"";
			
			if(array_key_exists($v1, $array['form_value'])){$_show.=" checked";}
		
			$_show.=">".$v2."</label>\n	  	";
		}
		$show="    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">$_show ". $array['form_word'] ."</td>
    </tr>";
		$str .=  $show;

	
		break;
		
	case "checkbox"://复选框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		$detail=explode("\r\n",$array['form_set']);
		
		$array['form_value'] =explode("/",$array['form_value']);
		$array['form_value'] =array_flip($array['form_value']);
			
		foreach( $detail AS $key=>$value){
			if($value===''){
				continue;
			}
			list($v1,$v2)=explode("|",$value);
			$v2 || $v2=$v1;
			$_show.="<label><input type=\"checkbox\" name=\"".$array['field_id']."[]\" value=\"".$v1."\"";
			
			if(array_key_exists($v1, $array['form_value'])){$_show.=" checked=\"checked\"";}
		
			$_show.=">".$v2."</label>\n	  	";
		}
		$show="    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">$_show ". $array['form_word'] ."</td>
    </tr>";
		$str .=  $show;
	
		break;
		
	case "ieedit"://可视化编辑器
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		if( empty( $array['form_set'] ) ){
			$idedit_w = "84";
			$idedit_h = "16";
		}else{
			$detail=explode("*",$array['form_set']);
			$idedit_w = $detail[0];
			$idedit_h = $detail[1];
		}

		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><textarea id=\"".$array['field_id']."\" name=\"".$array['field_id']."\" cols=\"".$idedit_w."\" rows=\"".$idedit_h."\">".$array['form_value']."</textarea>
	  ". $array['form_word'] ."</td>
    </tr>";
	
		$str_ieedit_js .= "\$('#".$array['field_id']."').xheditor({upImgUrl:\"$webdb[www_url]/webeditor/xheditor/upload.php?immediate=1\",upImgExt:\"jpg,jpeg,gif,png\"});\n";

		break;
		
	case "upfile"://文件上传
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= '    <tr>
          <td height="14" bgcolor="'.$array['td_color'].'">'.$array['title'].'：'.$str_mustfill.'</td>
          <td bgcolor="'.$array['td_color'].'"><input name="'.$array['field_id'].'" id="'.$array['field_id'].'" value="" size="38" />
            <a onclick="window.open(\'upfile.php?dir=upfile1&amp;label='.$array['field_id'].'\',\'\',\'width=350,height=50,top=200,left=400\')" href="javascript:"><font color="#0000FF">点击上传图片</font></a>
			
			'.$array['form_word'].'
			
			<SCRIPT LANGUAGE="JavaScript">
<!--
function upfile(url,name,size,p){
	document.getElementById(p).value=url;
}
//-->
</SCRIPT>            </td>
        </tr>';

		break;

	case "upfile_big"://大的文件上传
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">
	  <input name='".$array['field_id']."' type='text' id='".$array['field_id']."' size='42' />
<input name='button' type='button' onClick='filelist.value=uploadid.selectfile();' value='选择一个文件' />
<input name='button2' type='button' onClick=\"".$array['field_id'].".value=uploadid.uploadfile();filelist.value='';\" value='上 传' />
<input name='filelist' type='text' id='filelist' size='20' />
<br />
上传文件方法：1、点“<font color='#FF0000'>选择一个文件</font>”，在弹出框中选择一个文件，2、然后点击“<font color='#FF0000'>上传</font>”按钮即可". $array['form_word'] ."</td>
    </tr>";

		break;
		
	case "upphoto"://上传图片
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= '    <tr>
          <td height="14" bgcolor="'.$array['td_color'].'">'.$array['title'].'：'.$str_mustfill.'<br />
(您只需上传一张大图片，即可生成一张 '.$array['form_set'].' 像素的小图片)</td>
      <td bgcolor="'.$array['td_color'].'">小图片地址(字段s_'.$array['field_id'].')：<input name="s_'.$array['field_id'].'" id="s_'.$array['field_id'].'" value="" size="38" /><br />
大图片地址(字段b_'.$array['field_id'].')：<input name="b_'.$array['field_id'].'" id="b_'.$array['field_id'].'" value="" size="38" />
            <a onclick="window.open(\'upphoto.php?dir=upphoto&label='.$array['field_id'].'&photo_w_h='.$array['form_set'].'\',\'\',\'width=350,height=50,top=200,left=400\')" href="javascript:"><font color="#0000FF">点击上传图片</font></a>
			
'.$array['form_word'].'
			
			<SCRIPT LANGUAGE="JavaScript">
<!--
function upfile(url,name,size,p){
	document.getElementById(p).value=url;
}
//-->
</SCRIPT>            </td>
        </tr>';

		break;
		
}

	return $str;

}

	





//$array['form_type'] , $array['title'] , $array['field_id'] , $array['form_set'] , $array['form_value'] , $array['form_word'] , $array['add_field_id']  , $array['add_field_id_more'] , $array['mustfill'] 
function formMoudleModify( $array ){
global $webdb,$aid,$mid,$tpbdh_imgUrl,$tpbdh_imgUrl2,$web126_imgUrl,$str_ieedit_js;


$array['form_word'] = stripslashes ( $array['form_word'] );


$job = 'modify';

switch ( $array['form_type'] ) {
    case "text"://单行文本框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
			if( $array['mustfill'] == 0 ){
			
				if( empty( $array['form_word'] ) )$array['form_word'] = "";
				$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."："."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><input name=\"postdb[".$array['field_id']."]\" type=\"text\" id=\"".$array['field_id']."\" size=\"50\" value=\"\$show_db[".$array['field_id']."]\" ".stripslashes ( $array['form_set'] )." />". $array['form_word'] ."</td>
    </tr>";
				
			}elseif( $array['mustfill'] == 1 ){
			
				if( empty( $array['form_word'] ) )$array['form_word'] = "";
				$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."："."<font color=red>(必填)</font></td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><input name=\"postdb[".$array['field_id']."]\" type=\"text\" id=\"".$array['field_id']."\" size=\"50\" value=\"\$show_db[".$array['field_id']."]\" ".stripslashes ( $array['form_set'] )." />". $array['form_word'] ."</td>
    </tr>";
	
			}elseif( $array['mustfill'] == 2 ){
			
				$str .= "<input name=\"postdb[".$array['field_id']."]\" type=\"hidden\" value=\"\$show_db[".$array['field_id']."]\">";
				
			}
	      
        break;
		
    case "textarea"://多行文本框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}

		if( empty( $array['form_set'] ) ){
			$idedit_w = "80";
			$idedit_h = "8";
		}else{
			$detail=explode("*",$array['form_set']);
			$idedit_w = $detail[0];
			$idedit_h = $detail[1];
		}
		
		//if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><textarea name=\"postdb[".$array['field_id']."]\" id=\"".$array['field_id']."\" cols=\"".$idedit_w."\" rows=\"".$idedit_h."\">\$show_db[".$array['field_id']."]</textarea>". $array['form_word'] ."</td>
    </tr>";
		
		/*
		if( $array['mustfill'] == 0 ){
			
		
			if( empty( $array['form_set'] ) ){
				$idedit_w = "80";
				$idedit_h = "8";
			}else{
				$detail=explode("*",$array['form_set']);
				$idedit_w = $detail[0];
				$idedit_h = $detail[1];
			}

			
				if( empty( $array['form_word'] ) )$array['form_word'] = "";
				$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."："."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><textarea name=\"postdb[".$array['field_id']."]\" cols=\"".$idedit_w."\" rows=\"".$idedit_h."\">\$show_db[".$array['field_id']."]</textarea>". $array['form_word'] ."</td>
    </tr>";
				
			}elseif( $array['mustfill'] == 1 ){
			

	
			}
			*/
		break;
	
	case "select"://下拉菜单
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		$detail=explode("\r\n",$array['form_set']);
		$array['form_value'] = filtrate ( $array['form_value'] );
		
		$_show = "<!--\nEOT;\nunset(\$str);\n";
		for($i=0;$i<count($detail);$i++){
			
			list($a1,$a2)=explode("|",$detail[$i]); 
			
			$s = 0;
			$_show .= "if(\$show_db['".$array['field_id']."']=='".$a1."') { \$str = '";
			foreach( $detail AS $key=>$value){ 
			
				if($value===''){ continue; } 
				list($v1,$v2)=explode("|",$value); 
				$v2 ||$v2=$v1; 
				$_show.="<option value=\"".$v1."\"";
				if($i == $s){$_show.=" selected";} 
				//$_show.=">".$s." ".$v2."</option>\n	  	";
				$_show.=">".$v2."</option>\n";
			
			$s++;
			} 
			$_show .= "'; }\n";
		}
		$_show .= "print <<<EOT\n-->\n\$str\n";
		
		//$array['form_value'] =explode("/",$array['form_value']);
		//$array['form_value'] =explode("|",$array['form_value']);
		//$array['form_value'] =array_flip($array['form_value']);
		/*
		if($job == 'insert'){
			$select_num = count($detail);//取总数
			$selected_num = make_1_rand(0,$select_num,1);//得到要加selected的那个数
		}
			
		if($array['add_field_id']) $_show='<option value="">请选择以下内容</option>';
		
		
		$i = 0;
		foreach( $detail AS $key=>$value){
			if($value===''){
				continue;
			}
			list($v1,$v2)=explode("|",$value);
			$v2 || $v2=$v1;
			$_show.="<option value=\"$v1\"";
			
				if($job == 'insert'){
					if($i == $selected_num)$_show.=" selected";
				}elseif($job == 'modify'){
					//if(array_key_exists($v1, $array['form_value']))$_show.=" selected";//array_key_exists 检查给定的键名或索引是否存在于数组中
					if($v1 == $array['form_value'])$_show.=" selected";//array_key_exists 检查给定的键名或索引是否存在于数组中
				}

			$_show.=">".$i." ".$v2."</option>\n	  	";

		$i++;
		}*/
		
		//插入函数
		$add_fun_1 = '';
		$add_fun_2 = '';
		if($array['add_field_id']){
			$add_fun_1 = ' onChange="MM_AddTxt(this)"';
			$add_fun_1 = ' onChange="MM_AddTxt(this)"';
			if($array['add_field_id_more'] == "1"){
				$add_fun_2 = '<script language="JavaScript">
<!--
function MM_AddTxt(selObj){ //v3.0
  va=selObj.options[selObj.selectedIndex].value
  if (va!=\'\'){
  	if(get_obj(\''.$array['add_field_id'].'\').value==\'\'){
		get_obj(\''.$array['add_field_id'].'\').value=va;
	}else{
		vb=get_obj(\''.$array['add_field_id'].'\').value;
		arr = vb.split(\' \');
		for(var i=0;i<arr.length;i++){
			if(arr[i]==va){
				alert(va+",已经存在了,不能雷同");
				return ;
			}
		}
		//va = va.replace(" ", " "); 
		//va = va.replace(" ", " "); 
		get_obj(\''.$array['add_field_id'].'\').value+="|"+va;
	}
  } 
}
//-->
</script>';
			}else{
				$add_fun_2 = '<script language="JavaScript">
<!--
function MM_AddTxt(selObj){ //v3.0
  va=selObj.options[selObj.selectedIndex].value
  if (va!=\'\'){
  	get_obj(\''.$array['add_field_id'].'\').value=va;
  } 
}
//-->
</script>';
			}			
		}
		//插入函数
		$show="    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><select name=\"postdb[".$array['field_id']."]\" id=\"postdb[".$array['field_id']."]\" ".$add_fun_1.">
	  ".$_show."</select> ". $array['form_word'] ."</td>
    </tr>
	".$add_fun_2;
		$str .= $show;
	
		break;
		
	case "radio"://单选框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		$detail=explode("\r\n",$array['form_set']);
		
		
		$_show = "<!--\nEOT;\nunset(\$str);\n";
		for($i=0;$i<count($detail);$i++){
			$array['form_value'] =explode("/",$array['form_value']);
			$array['form_value'] =array_flip($array['form_value']);
			
			list($a1,$a2)=explode("|",$detail[$i]); 
			
			$s = 0;
			$_show .= "if(\$show_db['".$array['field_id']."']=='".$a1."') { \$str = '";
			foreach( $detail AS $key=>$value){ 
			
				if($value===''){ continue; } 
				list($v1,$v2)=explode("|",$value); 
				$v2 ||$v2=$v1; 
				$_show.="<label><input type=\"radio\" name=\"postdb[".$array['field_id']."]\" value=\"".$v1."\""; 
				if($i == $s){$_show.=" checked";} 
				$_show.=">".$v2."</label>\n	  	"; 
			$s++;
			} 
			$_show .= "'; }\n";
		}
		$_show .= "print <<<EOT\n-->\n\$str\n";
		
		$show="    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">$_show ". $array['form_word'] ."</td>
    </tr>";
		$str .= $show;
/*

		$array['form_value'] =explode("/",$array['form_value']);
		$array['form_value'] =array_flip($array['form_value']);
			
		foreach( $detail AS $key=>$value){
			if($value===''){
				continue;
			}
			list($v1,$v2)=explode("|",$value);
			$v2 || $v2=$v1;
			$_show.="<input type=\"radio\" name=\"postdb[".$array['field_id']."]\" value=\"".$v1."\"";
			
			if(array_key_exists($v1, $array['form_value'])){$_show.=" checked";}
		
			$_show.=">".$v2."\n	  	";
		}
		$show="    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">$_show ". $array['form_word'] ."</td>
    </tr>";
		$str .= $show;



######################################有待改善 
foreach( $detail AS $key=>$value){ 
if($value===''){ 
continue; 
} 
list($v1,$v2)=explode("|",$value); 
$v2 ||$v2=$v1; 
$_show.="<input type=\"radio\" name=\"postdb[".$array['field_id']."]\" value=\"".$v1."\""; 
if(array_key_exists($v1,$array['form_value'])){$_show.=" checked";} 
$_show.=">".$v2." "; 
} 
$_show_1 = "<!--\nEOT;\nif(\$show_db['".$array['field_id']."']==1) { \$str = '".$_show."';"; 
unset($_show); 
foreach( $detail AS $key=>$value){ 
if($value===''){ 
continue; 
} 
list($v1,$v2)=explode("|",$value); 
$v2 ||$v2=$v1; 
$_show.="<input type=\"radio\" name=\"postdb[".$array['field_id']."]\" value=\"".$v1."\""; 
if(!array_key_exists($v1,$array['form_value'])){$_show.=" checked";} 
$_show.=">".$v2." "; 
} 
$_show_2 = " } else { \$str = '".$_show."'; }\nprint <<<EOT\n-->\n"; 
unset($_show); 
$_show = $_show_1.$_show_2; 
######################################有待改善 
$show="    <tr> 
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td> 
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">$_show\$str ".$array['form_word']."</td> 
    </tr>"; 
$str .= $show; 


*/






	
		break;
		
	case "checkbox"://复选框
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		$detail=explode("\r\n",$array['form_set']);
		
		$array['form_value'] =explode("/",$array['form_value']);
		$array['form_value'] =array_flip($array['form_value']);
		
		$_show = "<!--\nEOT;\nunset(\$str);\n\$show_db['".$array['field_id']."'] = array_flip ( explode('|',\$show_db['".$array['field_id']."']) );\n";
		for($i=0;$i<count($detail);$i++){
			//$array['form_value'] =explode("/",$array['form_value']);
			//$array['form_value'] =array_flip($array['form_value']);
			
			list($v1,$v2)=explode("|",$detail[$i]); 
			$v2 ||$v2=$v1; 
			
			$s = 0;//array_key_exists('1',$show_db['car_qclx'])
			$_show .= "if(array_key_exists('".$v1."',\$show_db['".$array['field_id']."'])) { \$str .= '";
			$_show .= "<label><input type=\"checkbox\" name=\"postdb[".$array['field_id']."][]\" value=\"".$v1."\" checked=\"checked\">".$v2."</label> "; 
			$_show .= "';}else{";
			$_show .= " \$str .= '<label><input type=\"checkbox\" name=\"postdb[".$array['field_id']."][]\" value=\"".$v1."\" >".$v2."</label> ';"; 
			$_show .= "}\n"; 
			
			/*
			foreach( $detail AS $key=>$value){ 
			
				if($value===''){ continue; } 
				list($v1,$v2)=explode("|",$value); 
				$v2 ||$v2=$v1; 
				$_show.="<input type=\"checkbox\" name=\"postdb[".$array['field_id']."][]\" value=\"".$v1."\""; 
				if($i == $s){$_show.=" checked=\"checked\"";} 
				$_show.=">".$v2." "; 
			
			$s++;
			} 
			$_show .= "'; }\n";
			*/
		}
		$_show .= "print <<<EOT\n-->\n\$str\n";
		
		$show="    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">$_show ". $array['form_word'] ."</td>
    </tr>";
		$str .= $show;
		break;
		
	case "ieedit"://可视化编辑器
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		
		if( empty( $array['form_set'] ) ){
			$idedit_w = "84";
			$idedit_h = "16";
		}else{
			$detail=explode("*",$array['form_set']);
			$idedit_w = $detail[0];
			$idedit_h = $detail[1];
		}

		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		
		//对地址进行还原
		//$array['form_value'] = str_replace($tpbdh_imgUrl,$tpbdh_imgUrl2,$array['form_value']);
		//$array['form_value'] = str_replace($web126_imgUrl,$webdb['www_url'],$array['form_value']);
		
		//对地址进行还原
		$str .= "\n<!--\nEOT;\n";
		$str .= "\$show_db['". $array['field_id'] . "']" ." = str_replace('$tpbdh_imgUrl',\$tpbdh_imgUrl2,". "\$show_db['" .$array['field_id'] . "']" .");\n";
		$str .= "\$show_db['". $array['field_id'] . "']" ." = str_replace('$web126_imgUrl',\$webdb['www_url'],". "\$show_db['" .$array['field_id'] . "']" .");\n";
		$str .= "print <<<EOT\n-->\n";

		$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\"><textarea id=\"".$array['field_id']."\" name=\"postdb[".$array['field_id']."]\" cols=\"".$idedit_w."\" rows=\"".$idedit_h."\">\$show_db[".$array['field_id']."]</textarea>
	  ". $array['form_word'] ."</td>
    </tr>";
	
		$str_ieedit_js .= "\$('#".$array['field_id']."').xheditor({upImgUrl:\"$webdb[www_url]/webeditor/xheditor/upload.php?immediate=1\",upImgExt:\"jpg,jpeg,gif,png\"});\n";

		break;
		
	case "upfile"://文件上传
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= '    <tr>
          <td height="14" bgcolor="'.$array['td_color'].'">'.$array['title'].'：'.$str_mustfill.'</td>
          <td bgcolor="'.$array['td_color'].'"><input name="postdb['.$array['field_id'].']" id="'.$array['field_id'].'" value="$show_db['.$array['field_id'].']" size="38" />
            <a onclick="window.open(\'upfile.php?dir=upfile1&amp;label='.$array['field_id'].'\',\'\',\'width=350,height=50,top=200,left=400\')" href="javascript:"><font color="#0000FF">点击上传图片</font></a>
			
'.$array['form_word'].'
			
			<SCRIPT LANGUAGE="JavaScript">
<!--
function upfile(url,name,size,p){
	document.getElementById(p).value=url;
}
//-->
</SCRIPT>            </td>
        </tr>';

		break;

	case "upfile_big"://大的文件上传
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		$str .= "    <tr>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">".$array['title']."：".$str_mustfill."</td>
      <td align=\"left\" bgcolor=\"".$array['td_color']."\">
	  <input name='postdb[".$array['field_id']."]' type='text' id='".$array['field_id']."' size='42' value=\"\$show_db[".$array['field_id']."]\" />
<input name='button' type='button' onClick='filelist.value=uploadid.selectfile();' value='选择一个文件' />
<input name='button2' type='button' onClick=\"".$array['field_id'].".value=uploadid.uploadfile();filelist.value='';\" value='上 传' />
<input name='filelist' type='text' id='filelist' size='20' />
<br />
上传文件方法：1、点“<font color='#FF0000'>选择一个文件</font>”，在弹出框中选择一个文件，2、然后点击“<font color='#FF0000'>上传</font>”按钮即可". $array['form_word'] ."

<br />
<a href=\"view.php?action=flash&aid=".$aid."&mid=".$mid."&field_id=".$array['field_id']."\" target=\"_blank\"><font color=\"#0000FF\">如果上传的内容为flash文件，可点击这里查看媒体显示效果，一般用于检验上传文件是否可以播放</font></a>

</td>
    </tr>";

		break;
		
	case "upphoto"://上传图片
	
		if( empty( $array['td_color'] ) ){ $array['td_color'] = "#FFFFFF";}
		
		if( $array['mustfill'] == 1 ){ $str_mustfill = "<font color=red>(必选)</font>";}
		if( empty( $array['form_word'] ) )$array['form_word'] = "";
		
		$s_b_photo_file = explode( "@@@" , $array['form_value'] );
		$s_photo_file = $s_b_photo_file['0'];
		$b_photo_file = $s_b_photo_file['1'];
		
		$str .= '    <tr>
          <td height="14" bgcolor="'.$array['td_color'].'">'.$array['title'].'：'.$str_mustfill.'<br />
(您只需上传一张大图片，即可生成一张 '.$array['form_set'].' 像素的小图片)</td>
      <td bgcolor="'.$array['td_color'].'">小图片地址(字段s_'.$array['field_id'].')：<input name="postdb[s_'.$array['field_id'].']" id="s_'.$array['field_id'].'" value="$show_db[s_'.$array['field_id'].']" size="38" /><br />
大图片地址(字段b_'.$array['field_id'].')：<input name="postdb[b_'.$array['field_id'].']" id="b_'.$array['field_id'].'" value="$show_db[b_'.$array['field_id'].']" size="38" />
            <a onclick="window.open(\'upphoto.php?dir=upphoto&label='.$array['field_id'].'&photo_w_h='.$array['form_set'].'\',\'\',\'width=350,height=50,top=200,left=400\')" href="javascript:"><font color="#0000FF">点击上传图片</font></a>
			
'.$array['form_word'].'
			
			<SCRIPT LANGUAGE="JavaScript">
<!--
function upfile(url,name,size,p){
	document.getElementById(p).value=url;
}
//-->
</SCRIPT>
<br />

<a href="view.php?action=photo&aid='.$aid.'&mid='.$mid.'&field_id='.$array['field_id'].'" target="_blank"><font color="#0000FF">媒体效果查看</font></a>
 
            </td>
        </tr>';

		break;
		
}

	return $str;
}

	
?>

