<!--#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=chkhtm(trim(request("lyyzmm")))
lyyzm=chkhtm(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="VBScript" Type="text/vbscript"><!--
function FrontPage_Form1_onsubmit()
  Set theForm = document.FrontPage_Form1

  If (theForm.username.value = "") Then
    MsgBox "请在 你的姓名 域中输入值。", 0, "有效性验证错误"
    theForm.username.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.username.value) < 2) Then
    MsgBox "在 你的姓名 域中，请至少输入 2 个字符。", 0, "有效性验证错误"
    theForm.username.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.username.value) > 10) Then
    MsgBox "在 你的姓名 域中，请最多输入 10 个字符。", 0, "有效性验证错误"
    theForm.username.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.Email.value = "") Then
    MsgBox "请在 电子邮件 域中输入值。", 0, "有效性验证错误"
    theForm.Email.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.Email.value) < 5) Then
    MsgBox "在 电子邮件 域中，请至少输入 5 个字符。", 0, "有效性验证错误"
    theForm.Email.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.Email.value) > 50) Then
    MsgBox "在 电子邮件 域中，请最多输入 50 个字符。", 0, "有效性验证错误"
    theForm.Email.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.sex.selectedIndex < 0) Then
    MsgBox "请选择“性别”选项中的一项。", 0, "有效性验证错误"
    theForm.sex.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.sex.selectedIndex = 0) Then
    MsgBox "第一个“性别”选项无效。 请选择其他选项中的一项。", 0, "有效性验证错误"
    theForm.sex.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.lb.selectedIndex < 0) Then
    MsgBox "请选择“留言类型”选项中的一项。", 0, "有效性验证错误"
    theForm.lb.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.lb.selectedIndex = 0) Then
    MsgBox "第一个“留言类型”选项无效。 请选择其他选项中的一项。", 0, "有效性验证错误"
    theForm.lb.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.lyyzm.value = "") Then
    MsgBox "请在 验证码 域中输入值。", 0, "有效性验证错误"
    theForm.lyyzm.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.lyyzm.value) < 5) Then
    MsgBox "在 验证码 域中，请至少输入 5 个字符。", 0, "有效性验证错误"
    theForm.lyyzm.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.lyyzm.value) > 5) Then
    MsgBox "在 验证码 域中，请最多输入 5 个字符。", 0, "有效性验证错误"
    theForm.lyyzm.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  checkOK = "0123456789-" 
  checkStr = theForm.lyyzm.value
  allValid = True
  validGroups = True
  decPoints = 0
  allNum = ""
  For i = 1 to len(checkStr)
    ch = Mid(checkStr, i, 1)
    If (InStr(checkOK, ch) = 0) Then
        allValid = False
        Exit For
    End If
    allNum = allNum & ch
  Next
  If (Not allValid) Then
    MsgBox "在 验证码 域中，只能输入 数字 字符。", 0, "有效性验证错误"
    theForm.lyyzm.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If ((checkstr <> "" And Not IsNumeric(allNum)) Or (decPoints > 1) Or Not validGroups) Then
    MsgBox "请在 lyyzm 域中输入一个有效数字。", 0, "有效性验证错误"
    theForm.lyyzm.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.title.value = "") Then
    MsgBox "请在 留言标题 域中输入值。", 0, "有效性验证错误"
    theForm.title.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.title.value) < 2) Then
    MsgBox "在 留言标题 域中，请至少输入 2 个字符。", 0, "有效性验证错误"
    theForm.title.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.title.value) > 50) Then
    MsgBox "在 留言标题 域中，请最多输入 50 个字符。", 0, "有效性验证错误"
    theForm.title.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (theForm.content.value = "") Then
    MsgBox "请在 留言内容 域中输入值。", 0, "有效性验证错误"
    theForm.content.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If

  If (Len(theForm.content.value) < 1) Then
    MsgBox "在 留言内容 域中，请至少输入 1 个字符。", 0, "有效性验证错误"
    theForm.content.focus()
    FrontPage_Form1_onsubmit = False
    Exit Function
  End If
  FrontPage_Form1_onsubmit = True 
End Function
--></script><!--webbot BOT="GeneratedScript" endspan --><form method="POST" action="ly-write.asp" 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" name="bm">保密　<input type="radio" value="0" checked  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()

content=replace(content,chr(13),"<BR>")

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
%>