函数名:chk_email()
'返回值:布尔值(true为通过,false为未通过)
'参数:email(需要判断的email,类型:字符串) type_1(是否需要判断@之后的domain,类型:布尔值)
'type_2(是否只能是特定域的e-mail注册,类型:布尔值) type_3(一个e-mail是否只能注册一次,类型:布尔值)
const c_maildomain=".com,.com.cn,.net,.net.cn,.org,.org.cn,.gov,.gov.cn,.edu,.edu.cn,.cn,.cc,.biz,.info" '电子邮件可接受的domain
const c_lockdomain="bit.edu.cn,loster.org" '特定的域
function chk_email(email,type_1,type_2,type_3)
dim i,k
dim at
dim email_1,temp
if email="" then
chk_email=false
exit function
end if
email_1=cstr(trim(email))
if len(email_1)<5 then
chk_email=false
exit function
end if
at=false
for i=1 to len(email_1)
temp=mid(email_1,i,1)
if temp="@" then
at=true
exit for
end if
next
if at=false then
chk_email=false
exit function
end if
k=0
for i=1 to len(email_1)
temp=mid(email_1,i,1)
if temp="." then
k=k+1
end if
next
if k=0 or k>2 then
chk_email=false
exit function
end if
if type_1=true then
for i=1 to len(email_1)
temp=mid(email_1,i,1)
if temp="@" then
k=i
exit for
end if
next
for i=k to len(email_1)
temp=mid(email_1,i,1)
if temp="." then
k=i
exit for
end if
next
temp=""
for i=k to len(email_1)
temp=temp+mid(email_1,i,1)
next
temp=cstr(trim(temp))
at=false
for i=0 to r_reader(c_maildomain,",")
if temp=reader(i) then
at=true
exit for
end if
next
erase reader
if at=false then
chk_email=false
exit function
end if
end if
if type_2=true then
for i=1 to len(email_1)
temp=mid(email_1,i,1)
if temp="@" then
k=i
exit for
end if
next
temp=""
for i=k+1 to len(email_1)
temp=temp+mid(email_1,i,1)
next
temp=cstr(trim(temp))
at=false
for i=0 to r_reader(c_lockdomain,",")
if temp=reader(i) then
at=true
exit for
end if
next
erase reader
if at=false then
chk_email=false
exit function
end if
end if
if type_3=true then
dim j
call greate_userdb()
call create_rs("select * from user_basic_info where user_email='"&email_1&"'",1,1,"user")
if rs.bof=false then
chk_email=false
call close_rs()
call close_userdb()
exit function
end if
call close_rs()
call close_userdb()
end if
chk_email=true
end function
dim user_db,user_driver
dim user_conn
user_db="data/userdata.mdb"
'建立user_conn的过程
sub greate_userdb()
user_driver="driver={microsoft access driver (*.mdb)}"
user_driver=user_driver&";dbq="&server.mappath(user_db)
'response.write (user_driver)
set user_conn = server.createobject("adodb.connection")
user_conn.open(user_driver)
end sub
'关闭user_conn的过程
sub close_userdb()
user_conn.close
set user_conn=nothing
end sub
dim reader
dim rs
'读取常数,并将每个常数保存在reader数组中,参数:r_str(常数串),f_str(分隔符),返回值:reader数组的下标
function r_reader(r_str,f_str)
dim i
if r_str="" or f_str="" then
exit function
end if
reader=split(r_str,f_str)
for i=0 to ubound(reader,1)
reader(i)=cstr(trim(reader(i)))
next
r_reader=ubound(reader,1)
end function
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器