<!--#include file="Inc/Consts.inc"-->
<!--#include file="Inc/NoSQL.Asp" -->
<!--#include file="Inc/common.Asp"-->
<!--#include file="Inc/strfunc.Asp"-->
<!--#include file="Inc/sharefunc.Asp"-->
<%
' 文件名称:MessageSave.asp 2012
' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com
Dim rs, sql
Dim MesName, Content,   mLinkman, mSex, mCompany, mAddress, mZipCode, mTelephone, mFax, mMobile, mEmail
MesName = Trim(request.Form("MesName"))
Content = Trim(request.Form("Content"))
mLinkman = Trim(request.Form("Linkman"))
mSex = Trim(request.Form("Sex"))
mCompany = Trim(request.Form("Company"))
mAddress = Trim(request.Form("Address"))
mZipCode = Trim(request.Form("ZipCode"))
mTelephone = Trim(request.Form("Telephone"))
mFax = Trim(request.Form("Fax"))
mMobile = Trim(request.Form("Mobile"))
mEmail = Trim(request.Form("Email"))
Dim ErrMessage, ErrMsg(6), FindErr(6), i
ErrMsg(0) = "请填写留言主题。"
ErrMsg(1) = "请正确填写留言内容。"
ErrMsg(2) = "请填写您的称呼。"
ErrMsg(3) = "请正确填写单位名称、联系地址。"
ErrMsg(4) = "请正确填写邮政编码。"
ErrMsg(5) = "请正确填写联系电话、传真号码、手机号码。"
ErrMsg(6) = "电子信箱格式错误。"
If Len(MesName)>100 Or Len(MesName) = 0 Then FindErr(0) = True
If Len(Content)<10 Then FindErr(1) = True
If Len(mLinkman)>50 Or Len(mLinkman) = 0 Then FindErr(2) = True
If Len(mCompany)>100 Or Len(mAddress)>100 Or Len(mCompany) = 0 Or Len(mAddress) = 0 Then FindErr(3) = True
If Len(mZipCode)<>6 Then FindErr(4) = True
If Len(mTelephone)>50 Or Len(mFax)>50 Or Len(mMobile)>50 Or Len(mTelephone) = 0 Or Len(mFax) = 0 Or Len(mMobile) = 0 Then FindErr(5) = True
If Not IsValidEmail(mEmail) Then FindErr(6) = True
For i = 0 To UBound(FindErr)
    If FindErr(i) = True Then ErrMessage = ErrMessage+ErrMsg(i) + "\n"
Next
If Not (ErrMessage = "" Or IsNull(ErrMessage)) Then Call Alert(ErrMessage,"b-1"):response.End

sql = "select MesName,Content,Linkman,Sex,Company,Address,ZipCode,Telephone,Fax,Mobile,Email from ["&Datapre&"_Message]"
set rs=db(sql,3)
rs.addnew
rs("MesName") = StrReplace(MesName)
rs("Content") = StrReplace(Content)
rs("Linkman") = StrReplace(mLinkman)
rs("Sex") = mSex
rs("Company") = StrReplace(mCompany)
rs("Address") = StrReplace(mAddress)
rs("ZipCode") = StrReplace(mZipCode)
rs("Telephone") = StrReplace(mTelephone)
rs("Fax") = StrReplace(mFax)
rs("Mobile") = StrReplace(mMobile)
rs("Email") = mEmail
rs.update
rs.Close:Set rs = Nothing
'Call SiteInfo()
If MesViewFlag = 0 Then
    call Alert("留言成功提交，但系统已被设置为审核可见，请等待管理员审核、回复！","MessageList.Asp")
Else
    call Alert("留言成功提交，请等待管理员回复！","MessageList.Asp")
End If
' 文件名称:MessageSave.asp 2012
' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com
Function IsValidEmail(email)
    Dim names, Name, i, c
    IsValidEmail = True
    names = Split(email, "@")
    If UBound(names) <> 1 Then
        IsValidEmail = False
        Exit Function
    End If
    For Each Name in names
        If Len(Name) <= 0 Then
            IsValidEmail = False
            Exit Function
        End If
        For i = 1 To Len(Name)
            c = Mid(Name, i, 1)
            If InStr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.", c) <= 0 And Not IsNumeric(c) Then
                IsValidEmail = False
                Exit Function
            End If
        Next
        If Left(Name, 1) = "." Or Right(Name, 1) = "." Then
            IsValidEmail = False
            Exit Function
        End If
    Next
    If InStr(names(1), ".") <= 0 Then
        IsValidEmail = False
        Exit Function
    End If
    i = Len(names(1)) - InStrRev(names(1), ".")
    If i <> 2 And i <> 3 Then
        IsValidEmail = False
        Exit Function
    End If
    If InStr(email, "..") > 0 Then
        IsValidEmail = False
    End If
End Function
%>