<?php
require("../../class/connect.php");
include("../../class/db_sql.php");
include("../../class/config.php");
include("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
$editor=1;
is_login($logininid,$loginin,$loginrnd);
//验证权限
CheckLevel($logininid,$loginin,$classid,"f");
$tid=(int)$_GET['tid'];
$tbname=RepPostVar($_GET['tbname']);
if(empty($tid)||empty($tbname))
{
	printerror("ErrorUrl","history.go(-1)");
}
$enews=$_GET['enews'];
$iscj1=" checked";
$r[tobr]=1;
$r[dohtml]=1;
$r[myorder]=0;
$url="数据表:[".$dbtbpre."ecms_".$tbname."]&nbsp;->&nbsp;<a href=ListF.php?tid=$tid&tbname=$tbname>字段管理</a>&nbsp;->&nbsp;新建字段";
//修改字段
if($enews=="EditF")
{
	$fid=(int)$_GET['fid'];
	$url="数据表:[".$dbtbpre."ecms_".$tbname."]&nbsp;->&nbsp;<a href=ListF.php?tid=$tid&tbname=$tbname>字段管理</a>&nbsp;->&nbsp;修改字段";
	$r=$empire->fetch1("select * from {$dbtbpre}enewsf where fid='$fid' and tid='$tid'");
	if(!$r[fid])
	{
		printerror("ErrorUrl","history.go(-1)");
	}
	$oftype="type".$r[ftype];
	$$oftype=" selected";
	$ofform="form".$r[fform];
	$$ofform=" selected";
	if($r[iscj])
	{
		$iscj1=" checked";
		$iscj0="";
	}
	else
	{
		$iscj1="";
		$iscj0=" checked";
	}
}
db_close();
$empire=null;
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建字段</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td>位置：<?=$url?></td>
  </tr>
</table>
<form name="form1" method="post" action="../enews.php">
  <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr> 
      <td height="25" colspan="2" class="header">增加数据表(<?=$dbtbpre?>ecms_ 
        <?=$tbname?>
        )字段 
        <input name="add[fid]" type="hidden" id="add[fid]" value="<?=$fid?>"> 
        <input name="enews" type="hidden" id="enews" value="<?=$enews?>"> <input name="add[oldfform]" type="hidden" id="add[oldfform]" value="<?=$r[fform]?>"> 
        <input name="add[oldf]" type="hidden" id="add[oldf]" value="<?=$r[f]?>"> 
        <input name="add[tbname]" type="hidden" id="add[tbname]" value="<?=$tbname?>"> 
        <input name="add[tid]" type="hidden" id="add[tid]" value="<?=$tid?>"> 
        <input name="add[oldfvalue]" type="hidden" id="add[oldfvalue]" value="<?=$r[fvalue]?>"> 
        <input name="add[oldiskey]" type="hidden" id="add[oldiskey]" value="<?=$r[iskey]?>"> 
        <input name="add[oldsavetxt]" type="hidden" id="add[oldsavetxt]" value="<?=$r[savetxt]?>"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">字段名</td>
      <td width="75%" height="25"><input name="add[f]" type="text" id="add[f]" value="<?=$r[f]?>">
        索引字段： 
        <input name="add[iskey]" type="checkbox" id="add[iskey]" value="1"<?=$r[iskey]==1?' checked':''?>> 
        <font color="#666666">(比如：&quot;title&quot;)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">字段标识</td>
      <td height="25"><input name="add[fname]" type="text" id="add[fname]" value="<?=$r[fname]?>"> 
        <font color="#666666">(比如：&quot;标题&quot;)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">字段类型</td>
      <td height="25"><select name="add[ftype]" id="select">
          <option value="VARCHAR"<?=$typeVARCHAR?>>字符型0-255字节(VARCHAR)</option>
          <option value="TEXT"<?=$typeTEXT?>>小型字符型(TEXT)</option>
          <option value="MEDIUMTEXT"<?=$typeMEDIUMTEXT?>>中型字符型(MEDIUMTEXT)</option>
          <option value="LONGTEXT"<?=$typeLONGTEXT?>>大型字符型(LONGTEXT)</option>
          <option value="TINYINT"<?=$typeTINYINT?>>小数值型(TINYINT)</option>
          <option value="SMALLINT"<?=$typeSMALLINT?>>中数值型(SMALLINT)</option>
          <option value="INT"<?=$typeINT?>>大数值型(INT)</option>
          <option value="BIGINT"<?=$typeBIGINT?>>超大数值型(BIGINT)</option>
          <option value="FLOAT"<?=$typeFLOAT?>>数值浮点型(FLOAT)</option>
          <option value="DOUBLE"<?=$typeDOUBLE?>>数值双精度型(DOUBLE)</option>
        </select>
        字段长度 
        <input name="add[flen]" type="text" id="add[flen]" value="<?=$r[flen]?>" size="6"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">数据存放文本文件</td>
      <td height="25"><input name="add[savetxt]" type="checkbox" id="add[savetxt]" value="1"<?=$r[savetxt]==1?' checked':''?>>
        是 <font color="#666666">(对“newstext”字段有效)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">输入表单显示元素</td>
      <td height="25"><select name="add[fform]" id="add[fform]">
          <option value="text"<?=$formtext?>>单行文本框(text)</option>
          <option value="password"<?=$formpassword?>>密码框(password)</option>
          <option value="select"<?=$formselect?>>下拉框(select)</option>
          <option value="radio"<?=$formradio?>>单选框(radio)</option>
          <option value="textarea"<?=$formtextarea?>>多行文本框(textarea)</option>
          <option value="img"<?=$formimg?>>图片(img)</option>
          <option value="flash"<?=$formflash?>>FLASH文件(flash)</option>
          <option value="file"<?=$formfile?>>文件(file)</option>
        </select> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td rowspan="2" valign="top">初使化值：</td>
      <td height="25"> <textarea name="add[fvalue]" cols="65" rows="8" id="add[fvalue]"><?=str_replace("|","\r\n",$r[fvalue])?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25"><font color="#666666">(多个值用&quot;回车&quot;格开,对radio,select元素有效)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">前台显示设定</td>
      <td height="25"><input name="add[tobr]" type="checkbox" id="add[tobr]" value="1"<?=$r[tobr]==1?' checked':''?>>
        将回车替换成换行符, 
        <input name="add[dohtml]" type="checkbox" id="add[dohtml]" value="1"<?=$r[dohtml]==1?' checked':''?>>
        支持html代码</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">显示顺序</td>
      <td height="25"><input name="add[myorder]" type="text" id="add[myorder]" value="<?=$r[myorder]?>" size="6"> 
        <font color="#666666">(数字越小越前面)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" valign="top">输入表单替换html代码<br>
        (增加字段时请留空)</td>
      <td height="25"><textarea name="add[fhtml]" cols="65" rows="10" id="add[fhtml]"><?=htmlspecialchars(stripSlashes($r[fhtml]))?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">是否采集项</td>
      <td height="25">是 
        <input name="add[iscj]" type="radio" value="1"<?=$iscj1?>>
        否 
        <input name="add[iscj]" type="radio" value="0"<?=$iscj0?>></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25" valign="top">投稿表单替换html代码<br>
        (增加字段时请留空)</td>
      <td height="25"><textarea name="add[qfhtml]" cols="65" rows="10" id="add[qfhtml]"><?=htmlspecialchars(stripSlashes($r[qfhtml]))?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" valign="top">注释：</td>
      <td height="25"><textarea name="add[fzs]" cols="65" rows="10" id="add[fzs]"><?=stripSlashes($r[fzs])?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">&nbsp;</td>
      <td height="25"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
</body>
</html>
