<%
'**************************************
'* 最后更新 2013-04-24 by 56770.kingdge
'* Copyright www.56770.com
'**************************************
Showpath = "<a href='"& Eshop_url & LangPath &"'>"& Lebi_word(0) &"</a> → <a href='"& Eshop_url & url_book &"'>"& Lebi_word(20) &"</a> → "& Lebi_book(1)
Dim GuestBookMain
Select Case Request("action")
	   Case "add"
            GuestBookMain = GuestBookAdd()
	   Case "save"
            GuestBookMain = GuestBookPost()
	   Case Else
            GuestBookMain = GuestBookAdd()
End Select

Function GuestBookAdd()	' 添加验证码判断 2008-3-8 b 56770.WangLei
        Dim strFile,RLoadStyle(2),verifycode
		strFile = Eshop_url& Style_Folder &"Lebi.GuestBookAdd."
		RLoadStyle(0) = splits(LoadStyle(strFile&"0.style"))
		RLoadStyle(1) = splits(LoadStyle(strFile&"1.style"))
		If CInt(Config_Lebi_Eshop(13)) = 1 Then
				verifycode = RLoadStyle(1)
		Else
				verifycode = ""
		End If
        GuestBookAdd = RLoadStyle(0)
		ReplaceStyle "verifycode",verifycode,GuestBookAdd
		ReplaceStyle "post",LangPath &"book/post.asp",GuestBookAdd
End Function

rem 2008-3-8 添加敏感文字过滤，验证码判断  b 56770.WangLei
Function GuestBookPost()
        Dim strFile,RLoadStyle(1)
		strFile = Eshop_url& Style_Folder &"Lebi.GuestBookPost."
		RLoadStyle(0) = splits(LoadStyle(strFile&"0.style"))
		RLoadStyle(1) = splits(LoadStyle(strFile&"1.style"))
        Dim iname,iqq,iemail,iselect,iface,show,isadmin,strisadmin,ititle,icontent,verifycode,server_v1,server_v2,mes,book_error,tl,itel
        iname=Trim(Safereplace(request.form("name")))
        iqq=Trim(Safereplace(request.form("qq")))
        iemail=Trim(Safereplace(request.form("email")))
		itel=Trim(Safereplace(request.form("tel")))
        iselect=Safereplace(request.form("select"))
        iface=Safereplace(request.form("face"))
        show=Safereplace(request.form("show"))
        isadmin=checknum(request.form("isadmin"),0)
        ititle=Trim(Safereplace(request.form("title")))
        icontent=safereplace(request.form("content"))
        server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
        server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))

		If CInt(Config_Lebi_Eshop(13)) = 1 Then '2008-3-8 验证码 判断
				verifycode = request("verifycode")
				if verifycode <> cstr(Session("verifycode")) Then
						mes=mes&"·"&Lebi_book(18)&"<br>"
						book_error=True
				End If
		End If

        If iname="" Then
                mes=mes&"·"&Lebi_book(19)&"<br>"
		        book_error=True
        End If
        If iname<>"" And Len(iname)>10 Then
                mes=mes&"·"&Lebi_book(20)&"<br>"
		        book_error=True
        End If
        If ititle="" Then
                mes=mes&"·"&Lebi_book(21)&"<br>"
		        book_error=True
        End If
        If ititle<>"" And Len(ititle)>50 Then
                mes=mes&"·"&Lebi_book(22)&"<br>"
		        book_error=True
        End If
        'If IsValidEmail(iemail)=False Then
        '        mes=mes&"·"&Lebi_book(23)&"<br>"
	'	book_error=True
        'End If
        if icontent="" Then
                mes=mes&"·"&Lebi_book(24)&"<br>"
                book_error=True
        End If
        if icontent<>"" And Len(icontent)>255 Then
                mes=mes&"·"&Lebi_book(25)&"<br>"
                book_error=True
        End If
        if mid(server_v1,8,len(server_v2))<>server_v2 Then
                mes=mes&"·"&Lebi_word(39)&"<br>"
                book_error=True
        End If
        If book_error=True Then
		        book_error=True
                tl=Lebi_word(20)
				GuestBookPost = RLoadStyle(0)
		        ReplaceStyle "mes",mes,GuestBookPost
        Else
				ititle = reBadWord(ititle)	'敏感文字过滤 2008-3-8 b 56770.WangLei
				iname = reBadWord(iname)
				icontent = reBadWord(icontent)
				If SMS_State = "1" Then
						If InStr(","& SMS_SendMode &",",",15,") > 0 Then
								If CheckMobile(sms_receiveno) Then
										Dim LoadSMSInfo,SMSMsg
										LoadSMSInfo = LoadStyle(Eshop_url&"include/lebi_data/SMS"& LangTxt &".data")
										SMSMsg = splits(Split(LoadSMSInfo,"@@@")(14))
										ReplaceStyle "user",iname,SMSMsg
										ReplaceStyle "qq",iqq,SMSMsg
										ReplaceStyle "tel",itel,SMSMsg
										ReplaceStyle "email",iemail,SMSMsg
										ReplaceStyle "time",Now(),SMSMsg
										ReplaceStyle "title",ititle,SMSMsg
										ReplaceStyle "content",icontent,SMSMsg
										Call RedirectSendSMS(sms_receiveno,SMSMsg,"book","",sms_sendtype)
								End If
						End If
				End If
                set rs=server.createobject("adodb.recordset")
                rs.open "select * from guestbook where (id is null)",conn,1,3
                rs.addnew
                rs("face")=iface
                rs("select")=iselect
                rs("name")=iname
                rs("qq")=iqq
                rs("email")=iemail
                rs("title")=ititle
				rs("tel")=itel
                rs("content")=icontent
                rs("time")=now()
                rs("ip")=GetIP()
                rs("show")=0
                rs("isadmin")=isadmin
                rs.update
                rs.close:set rs=Nothing
                mes = ""
		        GuestBookPost = RLoadStyle(1)
				ReplaceStyle "mes","",GuestBookPost
        End If
End Function
%>