<%
'判断文件名是否合法
function isfilename(afilename)
dim serrorstr,inamelength,i
isfilename=true
serrorstr=array("/","\",":","*","?","""","<",">","")
inamelength=len(afilename)
if inamelength<1 or inamelength=null then
isfilename=false
else
for i=0 to 8
if instr(afilename,serrorstr(i)) then
isfilename=false
end if
next
end if
end function
'去掉字符串头尾的连续的回车和空格
function trimvbcrlf(str)
trimvbcrlf=rtrimvbcrlf(ltrimvbcrlf(str))
end function
'去掉字符串开头的连续的回车和空格
function ltrimvbcrlf(str)
dim pos,isblankchar
pos=1
isblankchar=true
while isblankchar
if mid(str,pos,1)=" " then
pos=pos+1
elseif mid(str,pos,2)=vbcrlf then
pos=pos+2
else
isblankchar=false
end if
wend
ltrimvbcrlf=right(str,len(str)-pos+1)
end function
'去掉字符串末尾的连续的回车和空格
function rtrimvbcrlf(str)
dim pos,isblankchar
pos=len(str)
isblankchar=true
while isblankchar and pos>=2
if mid(str,pos,1)=" " then
pos=pos-1
elseif mid(str,pos-1,2)=vbcrlf then
pos=pos-2
else
isblankchar=false
end if
wend
rtrimvbcrlf=rtrim(left(str,pos))
end function
'判断email是否有效,返回1表示正确
function isemail(aemail)
dim ilocat,v,ilength,i,checkletter
if instr(aemail,"@") = 0 or instr(aemail,".") = 0 then
isemail=0
exit function
end if
ilocat=instr(aemail,"@")
if instr(ilocat,aemail,".")=0 or instr(ilocat+1,aemail,"@")>0 then
isemail=0
exit function
end if
if left(aemail,1)="." or right(aemail,1)="." or left(aemail,1)="@" or right(aemail,1)="@" then
isemail=0
exit function
end if
v="1234567890abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz_-.@"
ilength=len(aemail)
for i=1 to ilength
checkletter=mid(aemail,i,1)
if instr(v,checkletter)=0 then
isemail=0
exit function
end if
next
isemail=1
end function
'测试用:显示服务器信息
sub showserver
dim name
response.write "<table border=1 bordercolor=lightblue cellspacing=0>"
for each name in request.servervariables
response.write "<tr>"
response.write "<td>"&name&"</td>"
response.write "<td>"&request.servervariables(name)&"<br></td>"
response.write "</tr>"
next
response.write "</table>"
end sub
'测试用:显示rs结果集以及字段名称
sub showrs(rs)
dim strtable,whatever
response.write "<center><table><tr>"
for each whatever in rs.fields
response.write "<td><b>" & whatever.name & "</b></td>"
next
strtable = "</tr><tr><td>"&rs.getstring(,,"</td><td>","</tr><tr><td>"," ") &"</td></tr></table></center>"
response.write(strtable)
end sub
'用html格式显示文本
function htmlencode(fstring)
if not isnull(fstring) then
fstring = replace(fstring, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, chr(32), " ")
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(39), "'")
fstring = replace(fstring, chr(13), "")
fstring = replace(fstring, chr(10) & chr(10), "</p><p> ")
fstring = replace(fstring, chr(10), "<br> ")
htmlencode = fstring
end if
end function
'测试用:显示调试错误信息
sub showerror
dim serrmsg
serrmsg=err.source&" "&err.description
response.write "<center>"&serrmsg&"</center>"
err.clear
end sub
'显示文字计数器
sub showcounter
dim fs,outfile,filename,count
filename=server.mappath("count.txt")
set fs = createobject("scripting.filesystemobject")
if fs.fileexists(filename) then
set outfile=fs.opentextfile(filename,1)
count=outfile.readline
count=count+1
response.write "<center>浏览人次:"&count&"<center>"
outfile.close
set outfile=fs.createtextfile(filename)
outfile.writeline(count)
else
set outfile=fs.opentextfile(filename,8,true)
count=0
outfile.writeline(count)
end if
outfile.close
set fs=nothing
end sub
%>
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 注册表 操作系统 服务器 应用服务器