<!--#include file = admin_conn.asp -->
<!--#include file = titleb.asp -->
<%
function chkhtm(stra)
  stra=replace(stra,"<","&lt;")
  stra=replace(stra,">","&gt;")
  stra=replace(stra,"'","")
  stra=replace(stra,"(","（")
  stra=replace(stra,")","）")
  stra=replace(stra,";","；")
  stra=replace(stra,",","，")
  stra=replace(stra,"%","％")
  stra=replace(stra,"+","＋")
  chkhtm=stra
end function
%>
<head>
<!--#include file = language.asp -->
<STYLE type="text/css">
<!--
a:link       {text-decoration: none; font-family: AdobeSm; color: #000000 }
a:visited    {text-decoration: none; color: #000000 }
A:hover      {COLOR: green; FONT-FAMILY: "宋体,MingLiU"; TEXT-DECORATION: underline}
body         {font-size: 9pt; font-family: 宋体,MingLiU, Arial;color: #000000}
TD           {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000;table-layout:fixed;word-break:break-all}
p            {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
input        {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
body         {margin-top: 0; margin-bottom: 0;margin-left:0;margin-right:0; color: #000000}
select       {FONT-SIZE: 9PT;}
option       {FONT-SIZE: 9pt;}
textarea     {FONT-SIZE: 9pt;}
-->
</STYLE>
</head>

<body bgcolor="#B2C5D3">

<div align="center">
	<table border="0" cellpadding="0" cellspacing="0" width="760" id="table1">
		<tr>
			<td><img border="0" src="images/lyTOPS.gif" width="760" height="89"></td>
		</tr>
	</table>
</div>
<div align="center">
	<table border="0" cellpadding="5" cellspacing="0" width="760" id="table2" bgcolor="#FFFFFF">
		<tr>
			<td>
			<p align="center">
			<a href="ly-write.asp">
			<img border="0" src="images/lywrite.gif" width="89" height="37"></a>&nbsp;
			<a href="ly.asp">
			<img border="0" src="images/lyread.gif" width="89" height="37"></a></td>
		</tr>
	</table>
</div>
<%
username=chkhtm(trim(Request("username")))
email=chkhtm(trim(Request("email")))
sex=chkhtm(trim(Request("sex")))
lb=chkhtm(trim(request("lb")))
title=chkhtm(trim(Request("title")))
content=chkhtm(trim(Request("content")))
bm=chkhtm(trim(request("bm")))
lyyzmm=trim(Request("lyyzmm"))
lyyzm=trim(Request("lyyzm"))

if lyyzmm<>"" and lyyzm<>"" then
	if int(lyyzmm)<>int(lyyzm) then
		Response.Write "<script>alert('验证码输入不正确');</script>"
		Response.Write "<META http-equiv='refresh' content='0;url=ly-write.asp'>"
		Response.end
	end if
end if

if username="" or email="" or sex="" or title="" or content="" or lb="" then
%>
<div align="center">
	<table border="1" cellpadding="10" width="760" id="table3" style="border-collapse: collapse" bordercolor="#C0C0C0" bgcolor="#FFFFFF">
		
<!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.username.value == "")
  {
    alert("请在 你的姓名 域中输入值。");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length < 2)
  {
    alert("在 你的姓名 域中，请至少输入 2 个字符。");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length > 10)
  {
    alert("在 你的姓名 域中，请最多输入 10 个字符。");
    theForm.username.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("请在 电子邮件 域中输入值。");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length < 5)
  {
    alert("在 电子邮件 域中，请至少输入 5 个字符。");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length > 50)
  {
    alert("在 电子邮件 域中，请最多输入 50 个字符。");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.sex.selectedIndex < 0)
  {
    alert("请选择“性别”选项中的一项。");
    theForm.sex.focus();
    return (false);
  }

  if (theForm.sex.selectedIndex == 0)
  {
    alert("第一个“性别”选项无效。 请选择其他选项中的一项。");
    theForm.sex.focus();
    return (false);
  }

  if (theForm.lb.selectedIndex < 0)
  {
    alert("请选择“留言类型”选项中的一项。");
    theForm.lb.focus();
    return (false);
  }

  if (theForm.lb.selectedIndex == 0)
  {
    alert("第一个“留言类型”选项无效。 请选择其他选项中的一项。");
    theForm.lb.focus();
    return (false);
  }

  if (theForm.lyyzm.value == "")
  {
    alert("请在 验证码 域中输入值。");
    theForm.lyyzm.focus();
    return (false);
  }

  if (theForm.lyyzm.value.length < 5)
  {
    alert("在 验证码 域中，请至少输入 5 个字符。");
    theForm.lyyzm.focus();
    return (false);
  }

  if (theForm.lyyzm.value.length > 5)
  {
    alert("在 验证码 域中，请最多输入 5 个字符。");
    theForm.lyyzm.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.lyyzm.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("在 验证码 域中，只能输入 数字 字符。");
    theForm.lyyzm.focus();
    return (false);
  }

  if (theForm.title.value == "")
  {
    alert("请在 留言标题 域中输入值。");
    theForm.title.focus();
    return (false);
  }

  if (theForm.title.value.length < 2)
  {
    alert("在 留言标题 域中，请至少输入 2 个字符。");
    theForm.title.focus();
    return (false);
  }

  if (theForm.title.value.length > 50)
  {
    alert("在 留言标题 域中，请最多输入 50 个字符。");
    theForm.title.focus();
    return (false);
  }

  if (theForm.content.value == "")
  {
    alert("请在 留言内容 域中输入值。");
    theForm.content.focus();
    return (false);
  }

  if (theForm.content.value.length < 1)
  {
    alert("在 留言内容 域中，请至少输入 1 个字符。");
    theForm.content.focus();
    return (false);
  }
  return (true);
}
//--></script><!--webbot BOT="GeneratedScript" endspan --><form method="POST" action="ly-write.asp" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1" webbot-action="--WEBBOT-SELF--">
		<tr>
			<td width="722" align="center">
			
				<div align="center">
					<table border="1" cellpadding="5" width="708" id="table5" style="border-collapse: collapse" bordercolor="#C0C0C0">
						<tr>
							<td width="128" align="center">你的姓名</td>
							<td width="557">
							&nbsp;<!--webbot bot="Validation" s-display-name="你的姓名" b-value-required="TRUE" i-minimum-length="2" i-maximum-length="10" --><input type="text" name="username" size="52" maxlength="10"></td>
						</tr>
						<tr>
							<td width="128" align="center">电子邮件</td>
							<td width="557">
							&nbsp;<!--webbot bot="Validation" s-display-name="电子邮件" b-value-required="TRUE" i-minimum-length="5" i-maximum-length="50" --><input type="text" name="Email" size="52" maxlength="50"></td>
						</tr>
						<tr>
							<td width="128" align="center">性　　别</td>
							<td width="557">&nbsp;<!--webbot bot="Validation" s-display-name="性别" b-value-required="TRUE" b-disallow-first-item="TRUE" --><select size="1" name="sex">
							<option>请选择...</option>
							<option>男</option>
							<option>女</option>
							</select></td>
						</tr>
						<tr>
							<td width="128" align="center">留言类型</td>
							<td width="557">
							&nbsp;<!--webbot bot="Validation" s-display-name="留言类型" b-value-required="TRUE" b-disallow-first-item="TRUE" --><select size="1" name="lb">
							<option>请选择...</option>
							<%
							set rs = Server.CreateObject("ADODB.RecordSet")
							rs.Open "select * from [lylb] order by id asc",conn,1,1
							while not rs.eof
							%>
							<option value='<%=rs("id")%>'><%=rs("lb")%></option>
							<%
							rs.movenext
							wend
							rs.close:set rs=nothing
							%>
							</select></td>
						</tr>
						<tr>
							<td width="128" align="center">验证码
							<%
							Randomize
							an=""
							an= int((99999-22222+1) * RND +22222)
							%>
							<textarea style='display:none' cols=1 name='lyyzmm'><%=an%></textarea>						
							</td>
							<td width="557">
							&nbsp;<!--webbot bot="Validation" s-display-name="验证码" s-data-type="Integer" s-number-separators="x" b-value-required="TRUE" i-minimum-length="5" i-maximum-length="5" --><input type="text" name="lyyzm" size="15" maxlength="5">
							<%
							Response.Write an
							%>
							</td>
						</tr>
						<tr>
							<td width="128" align="center">留言标题</td>
							<td width="557">
							&nbsp;<!--webbot bot="Validation" s-display-name="留言标题" b-value-required="TRUE" i-minimum-length="2" i-maximum-length="50" --><input type="text" name="title" size="52" maxlength="50"></td>
						</tr>
						<tr>
							<td width="128" align="center">留言内容</td>
							<td width="557">
							&nbsp;<!--webbot bot="Validation" s-display-name="留言内容" b-value-required="TRUE" i-minimum-length="1" --><textarea rows="9" name="content" cols="82"></textarea></td>
						</tr>
						<tr>
							<td width="128" align="center">是否保密</td>
							<td width="557">&nbsp;<input type="radio" value="1" checked name="bm">保密　<input type="radio" value="0" name="bm">不保密　　<font color="#999999">（仅工作人员可以查看）</font></td>
						</tr>
					</table>
				</div>
			
				<p align="center">
				<input type=hidden name=sh value=<%=config("lysh")%>>
				<input type="submit" value="提交" name="B1">　　　<input type="reset" value="重置" name="B2"></p>
			
			</td>
		</tr></form>

	</table>
</div>

<%
else

sh=chkhtm(trim(request("sh")))

userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")

Randomize
an= int((10-1+1) * RND +1)

if sex="男" then
   tx="images/lylan-"&an&".gif"
else
   tx="images/lynv-"&an&".gif"
end if

addtime=date()

conn.Execute "insert into [ly] ([adduser],[email],[sex],[tx],[title],[content],[ip],[addtime],[bm],[lb],[sh]) values('"&username&"','"&email&"','"&sex&"','"&tx&"','"&title&"','"&content&"','"&userip&"','"&addtime&"','"&bm&"','"&lb&"',"&sh&")"

conn.close:set conn=nothing


if sh=1 then
	er=1
end if
Response.Redirect "ly.asp?er="&sh

end if
%>
<div align="center">
	<table border="1" cellpadding="5" width="760" id="table4" bgcolor="#FFFFFF" style="border-collapse: collapse" bordercolor="#C0C0C0">
		<tr>
			<td>
</td>
		</tr>
	</table>
</div>
<div align="center">
	<table border="0" cellpadding="0" cellspacing="0" width="760" height="37" id="table5">
		<tr>
			<td background="images/lydown.gif">　</td>
		</tr>
	</table>
</div>
<%
'rs.close:set rs=nothing
conn.close:set conn=nothing
%> 
