<!--#include file="_conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/md5.asp"-->
<%
'****************************************************************
'** QQ324707900
'****************************************************************
Call Chk_Post()
Call Chk_Time(KEEP_TIME)

Select Case request("cmd")
	Case "save"
		Call SaveLove()
	Case "find"
		Call FindLove()
	Case "del"
		Call DelLove()
	Case "edit"
		Call EditPWD()
	Case "login"
		Call chkLogin()
	Case Else
		conn.close		
		Set conn = Nothing
		response.redirect "default.asp"
End Select 

Sub SaveLove() 
	If request("send")="" Or request("info")="" Or request("key")="" Then 
  		response.write "<script type='text/javascript'>alert('含“*”项必填！');history.go(-1);</script>"
		response.End
	Else 
		Dim key,getcode
			key = Int(request("key"))	
			getcode = Int(session("getcode"))
		If key <> getcode Then 
			response.write "<script type='text/javascript'>alert('验证码错误！');history.go(-1);</script>"
			response.End
		End If 
	End If
	Dim send,pick,info
		send = Trim(request("send"))
		pick = Trim(request("pick"))
		info = Trim(request("info"))
	If BadWord(send,BAN_LIST) Or BadWord(pick,BAN_LIST) Or BadWord(info,BAN_LIST) Then
		response.write "<script type='text/javascript'>alert('请删除禁用词！');history.go(-1);</script>"
		response.End 
	End If

	Dim icon,face,ip,postdate
		icon=ReplaceBadChar(request("icon"))
		face=ReplaceBadChar(request("face"))
		send=ReplaceBadChar(send)
		pick=ReplaceBadChar(pick)
		If icon="" Then icon="0"
		If face="" Then face="0"
		If send="" Then send="匿名"	
		If pick="" Then pick="&nbsp;"	
		info=HTMLEncode(CutStr(info,150))
		ip=GetIP()
		postdate=Now()
	Dim sql,rs,id
		sql="Select * From LOVE"
	Set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,3	
	rs.addnew
	rs("Info")=info
	rs("Send")=send
	rs("Pick")=pick
	rs("IP")=IP
	rs("PostDate")=postdate 
	rs("Icon")=icon
	rs("Face")=face
	rs.update
	id=rs("ID")
	rs.close
	Set rs = Nothing
	conn.close		
	Set Conn = Nothing
	response.write "<script type='text/javascript'>alert('发表字条成功！\n你的爱墙号是："&id&"  ');location.href='default.asp';</script>"
End Sub  

Sub FindLove()
	If request("sKey")="" Then server.transfer "default.asp"
	Dim skey
		skey=Trim(request("sKey"))
	If IsIntChar(skey) Then 
		response.redirect "list.asp?id="&skey
	Else 
		response.write "<script type='text/javascript'>alert('爱墙号不正确！');history.go(-1);</script>"	
	End If
End Sub 

Sub DelLove()
	If session("_ASPK")="" Or request("id")="" Then server.transfer "default.asp"
	Dim id
		id=Trim(request("id"))
	If IsIntChar(id) Then
		id=CLng(id)
		conn.execute "Delete From LOVE Where ID ="&id
		conn.close		
		Set conn = Nothing
		response.write "<script type='text/javascript'>alert('成功删除字条！');location.href='list.asp';</script>"
	End If
End Sub

Sub EditPWD()
	If session("_ASPK")<>"ok" Or request("username")="" Or request("password")="" Then server.transfer "default.asp"
	Dim username
		username=Trim(request("username"))
		username=MD5(ReplaceBadChar(username))
	Dim password
		password=Trim(request("password"))
		password=MD5(ReplaceBadChar(password))
	conn.execute "Update ASPK Set [username]='"&username&"',[password]='"&password&"'"
	conn.close		
	Set conn = Nothing
	response.write "<script type='text/javascript'>alert('成功修改密码！');location.href='default.asp';</script>"
End Sub 

Sub chkLogin()
	If request("username")="" Or request("password")="" Or request("key") = "" Then 
		response.write "<script type='text/javascript'>alert('必须填所有项！');history.go(-1);</script>"
		response.End
	Else 
		Dim key,getcode
			key = Int(request("key"))
			getcode = Int(session("getcode"))
		If key <> getcode Then 
			response.write "<script type='text/javascript'>alert('验证码错误！');history.go(-1);</script>"
			response.End
		End If 
	End If
	Dim username
		username=Trim(request("username"))
		username=MD5(ReplaceBadChar(username))
	Dim password
		password=Trim(request("password"))
		password=MD5(ReplaceBadChar(password))
	Dim sql
		sql="Select * From ASPK Where [username]='"&username&"' And [password]='"&password&"'"
	Dim rs
	Set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,1
	If rs.eof And rs.bof Then
		rs.close
		Set rs=Nothing
		response.write ("非法登录，操作已被记录")
		response.End
	End If		
	rs.close		
    Set rs = Nothing
	conn.close		
	Set conn = Nothing
	session("_ASPK")="ok"
	session.timeout=10
	response.write "<script type='text/javascript'>alert('成功登录本系统\n退出请关浏览器');location.href='list.asp';</script>"
End Sub 
%>