艺术品综合搜索: |
<%
'--------定义部份------------------
'自定义需要过滤的字串,用 "|" 分隔
XH_In = "'|;|and|exec|insert|select|delete%20from|update|count|*|%|chr|mid|master|truncate|char|declare|drop%20table|from|net%20user|xp_cmdshell|/add|net%20localgroup%20administrators|Asc|char"
'----------------------------------
%>
<%
XH_Inf = split(XH_In,"|")
'--------GET部份-------------------
If Request.QueryString<>"" Then
For Each XH_Get In Request.QueryString
For XH_Xh=0 To Ubound(XH_Inf)
If Instr(LCase(Request.QueryString(XH_Get)),XH_Inf(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓ "
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&" "
Response.Write "操作时间:"&Now&" "
Response.Write "操作页面:"&Request.ServerVariables("URL")&" "
Response.Write "提交方式:GET "
Response.Write "提交参数:"&XH_Get&" "
Response.Write "提交数据:"&Request.QueryString(XH_Get)
Response.End
End If
Next
Next
End If
'----------------------------------
'--------COOKIE部份-------------------
If Request.Cookies<>"" Then
For Each XH_Cookie In Request.Cookies
For XH_Xh=0 To Ubound(XH_Inf)
If Instr(LCase(Request.Cookies(XH_Cookie)),XH_Inf(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓ "
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&" "
Response.Write "操作时间:"&Now&" "
Response.Write "操作页面:"&Request.ServerVariables("URL")&" "
Response.Write "提交方式:Cookie "
Response.Write "提交参数:"&XH_Cookie&" "
Response.Write "提交数据:"&Request.Cookies(XH_Cookie)
Response.End
End If
Next
Next
End If
'----------------------------------
%>
<%
sss=LCase(request.servervariables("QUERY_STRING"))
if instr(sss,"select")<>0 or instr(sss,"(")<>0 or instr(sss,"'or")<>0 then
response.write " 你的网址不合法"
response.end
end if
xuasmdb="../db/#le88king2A.asp"
set conn=server.CreateObject("adodb.connection")
DBPath = Server.MapPath(xuasmdb)
'connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &DBPath
'===低版本========================================================================================
'connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
'=============================================================================================
connstr="Provider=MSDASQL; Driver={SQL Server}; Server=(local); Database=le111; UID=dfi3242sdgf32; PWD=Lrg#&280@*487AS"
'connstr2="Provider=MSDASQL; Driver={SQL Server}; Server=(local); Database=db_le111; UID=db_le111_f; PWD=#b007e0d;"
conn.Open connstr
'conn.Open connstr2
'ON ERROR RESUME NEXT
%>
<%
'================================================================
'获取拼音首字母
'=====================================================================
function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) or left(char,1)="a" or left(char,1)="A" then getpychar= "A"
if(tmp>=45253 and tmp<=45760) or left(char,1)="b" or left(char,1)="B" then getpychar= "B"
if(tmp>=45761 and tmp<=46317) or left(char,1)="c" or left(char,1)="C" then getpychar= "C"
if(tmp>=46318 and tmp<=46825) or left(char,1)="d" or left(char,1)="D" then getpychar= "D"
if(tmp>=46826 and tmp<=47009) or left(char,1)="e" or left(char,1)="E" then getpychar= "E"
if(tmp>=47010 and tmp<=47296) or left(char,1)="f" or left(char,1)="F" then getpychar= "F"
if(tmp>=47297 and tmp<=47613) or left(char,1)="g" or left(char,1)="G" then getpychar= "G"
if(tmp>=47614 and tmp<=48118) or left(char,1)="h" or left(char,1)="H" then getpychar= "H"
if left(char,1)="I" or left(char,1)="i" then getpychar= "I"
if(tmp>=48119 and tmp<=49061) or left(char,1)="j" or left(char,1)="J" then getpychar= "J"
if(tmp>=49062 and tmp<=49323) or left(char,1)="k" or left(char,1)="K" then getpychar= "K"
if(tmp>=49324 and tmp<=49895) or left(char,1)="l" or left(char,1)="L" then getpychar= "L"
if(tmp>=49896 and tmp<=50370) or left(char,1)="m" or left(char,1)="M" then getpychar= "M"
if(tmp>=50371 and tmp<=50613) or left(char,1)="n" or left(char,1)="N" then getpychar= "N"
if(tmp>=50614 and tmp<=50621) or left(char,1)="o" or left(char,1)="O" then getpychar= "O"
if(tmp>=50622 and tmp<=50905) or left(char,1)="p" or left(char,1)="P" then getpychar= "P"
if(tmp>=50906 and tmp<=51386) or left(char,1)="q" or left(char,1)="Q" then getpychar= "Q"
if(tmp>=51387 and tmp<=51445) or left(char,1)="r" or left(char,1)="R" then getpychar= "R"
if(tmp>=51446 and tmp<=52217) or left(char,1)="s" or left(char,1)="S" then getpychar= "S"
if(tmp>=52218 and tmp<=52697) or left(char,1)="t" or left(char,1)="T" then getpychar= "T"
if left(char,1)="u" or left(char,1)="U" then getpychar= "U"
if left(char,1)="V" or left(char,1)="v" then getpychar= "V"
if(tmp>=52698 and tmp<=52979) or left(char,1)="w" or left(char,1)="W" then getpychar= "W"
if(tmp>=52980 and tmp<=53640) or left(char,1)="x" or left(char,1)="X" then getpychar= "X"
if(tmp>=53689 and tmp<=54480) or left(char,1)="y" or left(char,1)="Y" then getpychar= "Y"
if(tmp>=54481 and tmp<=55289) or left(char,1)="z" or left(char,1)="Z" then getpychar= "Z"
end function
function getpy(str)
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
end function
'**************************************************************
'下载文件,文件类型可以是txt,asp,html等
'**************************************************************
function downloadFile(strFile)
strFilename = server.MapPath(strFile)
Response.Buffer = True
Response.Clear
Set fso=Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
goexit("错误:\n\n该文件不存在。\n\n能留言告诉我一下吗?")
Response.End
end if
Set fl=fso.getfile(strFilename)
flsize=fl.size
flName=fl.name
Set fl=Nothing
Set fso=Nothing
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile strFilename
Select Case lcase(Right(flName, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case ".rar"
ContentType = "application/rar"
Case Else
ContentType = "application/octet-stream"
end Select
Response.AddHeader "Content-Disposition", "attachment; filename=" & flName
Response.AddHeader "Content-Length", flsize
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
response.Clear()
objStream.Close
Set objStream = Nothing
End Function
'*******************************************************************
'函数名:img_new
'作 用:新闻列表中显示NEW图标
'参 数:times 新闻发表的时间
' nums 间隔日期
'返 回:当前日期前nums天发表的新闻都显示NEW图标
'*******************************************************************
Function img_new(times,nums)
img_new=""
if IsNumeric(nums) then
if fix(nums)<0 then
nums=1
end if
else
exit function
end if
times_now=getdate()
if datediff(day,times,times_now)<=nums then
img_new=" "
else
img_new=""
end if
end Function
'*******************************************************************
'函数名:shuzi_img
'作 用:把字符数字转化成图片数字
'参 数:tp_str 数字
' img 图片数字的路径
' m "m"黑色的数字图片,"f"红色的数字图片
'返 回:转变好后的图片数字
'*******************************************************************
Function shuzi_img( tp_str,img,m)
Dim S, i, G
S = CStr( tp_str )
For i = 1 to Len(S)
G = G & " "
Next
shuzi_img=G
End Function
'******************************************************************
'过程名:CreateFile
'作 用:以UTF-8格式创建一个文件
'参 数:str ----要创建的文件内容
' files ----要创建的文件名,带路径。 例:../test.txt
'****************************************************************
Sub CreateFile(str,files)
Dim st
Set st=Server.CreateObject("ADODB.Stream")
st.Type=2
st.Mode=3
st.Charset="utf-8"
st.Open()
st.WriteText str
st.SaveToFile Server.MapPath(files),2
st.Close()
Set st=Nothing
End Sub
'asp动态include文件
Function include(filename)
Dim re,content,fso,f,aspStart,aspEnd
set fso=CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
set f=nothing
set fso=nothing
set re=new RegExp
re.pattern="^\s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
do while aspStart>aspEnd+1
Response.write Mid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%\>")+2
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.write Mid(content,aspEnd)
set re=nothing
End Function
'删除指定表的指定ID数据
function action_del(tb,id)
dim qq,ss
qq="delete from "&tb&" where id="&id&""
set ss=conn.execute(qq)
end function
Function CheckInput(str,strType)
'函数功能:过滤字符参数中的单引号,对于数字参数进行判断,如果不是数值类型,则赋值0
'参数意义: str ---- 要过滤的参数
' strType ---- 参数类型,分为字符型和数字型,字符型为"s",数字型为"i"
Dim strTmp
strTmp = ""
If strType ="s" Then
strTmp = Replace(Replace(Replace(Trim(str), "'", ""), Chr(34), ""), ";", "")
ElseIf strType="i" Then
If isNumeric(str)=False Then str="0"
strTmp = str
Else
strTmp = str
End If
CheckInput = strTmp
End Function
'
'----------定义SafeRequest()函数,用来判断页面传递的参数是否合法
'----------对于数字型 SafeRequest(ParaName,0)
'----------对于字符型 SafeRequest(ParaName,1)主要应用于一般提交 一般性过滤
'----------对于字符型 SafeRequest(ParaName,2)主要应用于后台管理的登陆口 严格性过滤
Function SafeRequest(ParaName,ParaType)
If ParaType=0 Then
If Not isNumeric(ParaName) or isNull(ParaName) or isNull(Trim(ParaName)) Then
Response.write "Url中有非法字符,请确定数据类型是否正确且不为空!!"
Response.End
Else
ParaName=Cint(ParaName)
SafeRequest=ParaName
End If
End If
If ParaType=1 then
If isNull(ParaName) Then
SafeRequest=""
Exit Function
Else
ParaName=Replace(Trim(ParaName),"'","''")
SafeRequest=ParaName
End If
End If
If ParaType=2 then
If isNull(ParaName) Then
SafeRequest=""
Exit Function
Else
dim K
K=0
If Instr(1,ParaName,"%20",1)<>0 Then K=1
If Instr(1,ParaName,"select%20",1)<>0 Then K=1
If Instr(1,ParaName,"insert%20",1)<>0 Then K=1
If Instr(1,ParaName,"delete%20from",1)<>0 Then K=1
If Instr(1,ParaName,"count(",1)<>0 Then K=1
If Instr(1,ParaName,"drop%20table",1)<>0 Then K=1
If Instr(1,ParaName,"update%20",1)<>0 Then K=1
If Instr(1,ParaName,"truncate%20",1)<>0 Then K=1
If Instr(1,ParaName,"asc(",1)<>0 Then K=1
If Instr(1,ParaName,"mid(",1)<>0 Then K=1
If Instr(1,ParaName,"char(",1)<>0 Then K=1
If Instr(1,ParaName,"xp_cmdshell",1)<>0 Then K=1
If Instr(1,ParaName,"exec%20master",1)<>0 Then K=1
If Instr(1,ParaName,"net%20localgroup%20administrators",1)<>0 Then K=1
If Instr(1,ParaName,":",1)<>0 Then K=1
If Instr(1,ParaName,";",1)<>0 Then K=1
If Instr(1,ParaName,"net%20user",1)<>0 Then K=1
If Instr(1,ParaName,"%20or%20",1)<>0 Then K=1
If Instr(1,ParaName,"&",1)<>0 Then K=1
If Instr(1,ParaName,"--",1)<>0 Then K=1
If Instr(1,ParaName,"==",1)<>0 Then K=1
If K=1 Then
response.write "提交内容里含有非法字符!!"
Response.Write ""
Response.End
Else
ParaName=Replace(Trim(ParaName),"'","''")
SafeRequest=ParaName
End If
End If
End If
End Function
'
'----------另外一个普通的页面字符型过滤
Function SafeStr(Str)
If isNull(Str) Then
SafeStr=""
Exit Function
else
Str=Replace(Str,"'","''")
SafeStr=Str
end If
End Function
'
'----------Html转换为文本:编辑时拿来做转换,如修改
Function Html2Text(Str)
If isNull(Str) Then
Html2Text=""
Exit Function
End If
Str=Replace(Str,"<","<")
Str=Replace(Str,">",">")
Str=Replace(Str," ",VBcrlf)
Str=Replace(Str,""",chr(34))
Str=Replace(Str," "," ")
Str=Replace(Str,"&","&")
Html2Text=Str
End Function
'
'----------文本转换为Html:写入数据库时使用,Add或Update
Function Text2Html(Str)
If isNull(Str) Then
Text2Html=""
Exit Function
End If
Str=Replace(Str,"&","&")
Str=Replace(Str,"<","<")
Str=Replace(Str,">",">")
Str=Replace(Str,VBcrlf," ")
Str=Replace(Str,chr(34),""")
Str=Replace(Str,chr(9)," ")
Str=Replace(Str," "," ")
Text2Html=Str
End Function
'判断文件名是否合法
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 filter(str)
filter=replace(str,"'","´")
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
'**************************************************
'过滤掉HTML代码的函数
'**************************************************
Function ReSetHTML(Str,Get_Type)
Dim obj, StrOutPut, pStr
pStr=Str
Set obj = New Regexp
obj.IgnoreCase = True
obj.Global = True
if Get_Type="cn" then
obj.Pattern = ".+?< /script>"
pStr = obj.Replace(Str, "")
obj.Pattern = ".+?< /style>"
pStr = obj.Replace(pStr, "")
obj.Pattern = "<.+?>"
pStr = obj.Replace(pStr, "")
obj.Pattern = "\b(www|http|\S+@)\S+\b"
pStr = obj.Replace(pStr, "")
else
pStr = Replace(pStr, "><", "> <")
obj.Pattern = ">.+?<"
pStr = obj.Replace(pStr, "><")
end if
pStr = Replace(pStr, "<", "<")
pStr = Replace(pStr, ">", ">")
ReSetHTML = pStr
Set obj = Nothing
End Function
'**************************************************
'把一长串数字分位显示
'
'**************************************************
Function Comma(str)
If Not(IsNumeric(str)) Or str = 0 Then
Result = 0
ElseIf Len(Fix(str)) < 4 Then
Result = str
Else
Pos = Instr(1,str,".")
If Pos > 0 Then
Dec = Mid(str,Pos)
End if
Res = StrReverse(Fix(str))
LoopCount = 1
While LoopCount <= Len(Res)
TempResult = TempResult + Mid(Res,LoopCount,3)
LoopCount = LoopCount + 3
If LoopCount <= Len(Res) Then
TempResult = TempResult + ","
End If
Wend
Result = StrReverse(TempResult) + Dec
End If
Comma = Result
End Function
'**************************************************
'函数格式 root()
'功能描述 返回一个路径串变量
'**************************************************
Function root()
root = Request.ServerVariables("Appl_Physical_Path")
End Function
'**************************************************
'函数格式 url()
'功能描述 返回一个URL串变量
'应用代码 'sample string = http://www.intels.net/filesys.asp'
'**************************************************
Function url()
url ="http://"&Request.ServerVariables("Server_Name") &Request.ServerVariables("Script_Name")
End Function
function MapURL(path)
dim rootPath, url
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
end function
'**************************************************
'函数名:gotTopic
'作 用:截字符串,汉字一个算两个字符,英文算一个字符
'参 数:str ----原字符串
' strlen ----截取长度
'返回值:截取后的字符串
'**************************************************
function gotTopic(ByVal str,ByVal strlen)
if str="" then
gotTopic=""
exit function
end if
dim l,t,c, i,strTemp
l=len(str)
t=0
strTemp=str
strlen=Clng(strLen)
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
strTemp=left(str,i)
exit for
end if
next
if strTemp<>str then
strTemp=strTemp & "…"
end if
gotTopic=strTemp
end function
function gotTopic1(ByVal str,ByVal strlen)
if str="" then
gotTopic=""
exit function
end if
dim l,t,c, i,strTemp
str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
l=len(str)
t=0
strTemp=str
strlen=Clng(strLen)
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
strTemp=left(str,i)
exit for
end if
next
if strTemp<>str then
strTemp=strTemp
end if
gotTopic1=replace(replace(replace(replace(strTemp," "," "),chr(34),"""),">",">"),"<","<")
end function
'======================================================
'删除图片
'tb 数据库表名
'id 数据ID
'IMG 图片文件夹路径
'=======================================================
function del_pic3(tb,id,img)
dim qq,ss
qq="select * from "&tb&" where id="&id
set ss=server.createobject("adodb.recordset")
ss.open qq,conn,1,1
if not(ss.eof and ss.bof) then
Dim fso,f1,f2,url,burl,surl
surl=img&ss("pic")
all_urs=Server.mappath(surl)
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(all_urs) then
Set f1 = fso.GetFile(all_urs)
f1.Delete
end if
end if
end function
'======================================================
'删除图片
'tb 数据库表名
'id 数据ID
'=======================================================
function del_pic(tb,id,path)
dim qq,ss
qq="select * from "&tb&" where id="&id
set ss=server.createobject("adodb.recordset")
ss.open qq,conn,1,1
if not(ss.eof and ss.bof) then
Dim fso,f1,f2,url,burl,surl,all_urs,all_urb
surl="../images/"&path&ss("s_pic")
all_urs=Server.mappath(surl)
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(all_urs) then
Set f1 = fso.GetFile(all_urs)
f1.Delete
end if
set fso=nothing
end if
ss.close
end function
'========打开数据库===================================================
'TD 数据库字段名,可以为空
'TB 数据库表名
'WHERE 查询条件
'BY 以哪个字段排序
'PX 排序方式,1 为正序 ,2为倒序
'SS 数据集名
'
'=====================================================================
function openDB(tu,tb,where,by,px,ss)
dim qq,where2,by2,px2
if tu="" then
tu="*"
end if
if where="" then
where2=""
else
where2=" where "&where
end if
if by="" then
by2=""
else
if px=2 then
px2=" desc"
else
px2=" asc"
end if
by2=" order by "&by&px2
end if
qq="select "&tu&" from "&tb&where2&by2
set ss=server.createobject("adodb.recordset")
ss.open qq,conn,3,3
end function
'============================================================
'关闭数据集
'RS 数据集名
'============================================================
function closeDB(rs)
rs.close
Set rs = Nothing
End function
'============================================================
'结束程序的执行
'============================================================
function dead()
response.end
end function
'==========================================================
'关闭数据库连接
'===========================================================
function closeconn()
conn.close
Set conn = Nothing
End function
'=========删除记录=========================================
'TB 数据表名
'ID 数据ID
'==========================================================
function del(tb,id)
dim qq,ss
qq="delete from "&tb&" where id="&id&""
set ss=conn.execute(qq)
end function
'=========================================================
'以一个表格显示指定字符串
'STR 指定的字符串
'=========================================================
function cc(str)
response.write " "
response.write " "
response.write " "
response.write " "
response.write " "&str&" "
response.write " Back"
response.write " | "
response.write " "
end function
function echo(str)
Response.write str
End function
function red(str)
red=""&str&""
End function
function gotourl(str)
response.redirect str
response.end
end function
function check_err(str)
if Err.Number>0 then
response.clear
response.write "出错:[" & Err.Number & "]" & Err.description &"!"
'response.write str
response.end
end if
end function
'========================================================================
'检测EMAIL是否合法
'返回值 false:不合法 / true:合法
'========================================================================
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
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 = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", 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
'========================================================
'弹出对话框,并后退一步
'
'========================================================
Function goexit(lang)
response.Write ""
response.end
End Function
'========================================================
'弹出对话框,并跳转到指定页面
'
'========================================================
Function gogo(lang,to_url)
response.Write ""
response.end
End Function
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
Function HtmlEncode(str)
If Trim(Str)="" Or IsNull(str) Then Exit Function
str=Replace(str,">",">")
str=Replace(str,"<","<")
str=Replace(str,Chr(32)," ")
str=Replace(str,Chr(9)," ")
str=Replace(str,Chr(34),""")
str=Replace(str,Chr(39),"'")
str=Replace(str,Chr(13),"")
str=Replace(str,Chr(10) & Chr(10), "")
str=Replace(str,Chr(10)," ")
str=Replace(str," "," ")
HtmlEncode=str
End Function
'========================================================
'随机生成文件名的函数
'========================================================
Function Generator(Length)
dim i, tempS, v
dim c(39)
tempS = ""
c(1) = "a": c(2) = "b": c(3) = "c": c(4) = "d": c(5) = "e": c(6) = "f": c(7) = "g"
c(8) = "h": c(9) = "i": c(10) = "j": c(11) = "k": c(12) = "l": c(13) = "m": c(14) = "n"
c(15) = "o": c(16) = "p": c(17) = "q": c(18) = "r": c(19) = "s": c(20) = "t": c(21) = "u"
c(22) = "v": c(23) = "w": c(24) = "x": c(25) = "y": c(26) = "z": c(27) = "1": c(28) = "2"
c(29) = "3": c(30) = "4": c(31) = "5": c(32) = "6": c(33) = "7": c(34) = "8": c(35) = "9"
'c(36) = "-": c(37) = "_": c(38) = "@": c(39) = "!"
If isNumeric(Length) = False Then
Response.Write "没有指定文件名长度"
Exit Function
End If
For i = 1 to Length
Randomize
v = Int((35 * Rnd) + 1)
tempS = tempS & c(v)
Next
Generator = tempS
'应用实例
'For i = 1 to 20
'Randomize
'x = Int((20 * Rnd) + 1) + 10
'Response.Write Generator(x) & " " & vbnewline
'Next
End Function
'========取得带端口的URL,推荐使用================
Function Get_ScriptNameUrl()
If request.servervariables("SERVER_PORT")="80" Then
Get_ScriptNameUrl="http://" & request.servervariables("server_name")&lcase(request.servervariables("script_name"))
Else
Get_ScriptNameUrl="http://" & request.servervariables("server_name")&":"&request.servervariables("SERVER_PORT")&lcase(request.servervariables("script_name"))
End If
End Function
'=================用正则表达式突出显示字符串中查询到的单词的函数======================
Function BoldWord(strContent,word)
If word="" Then
BoldWord = strContent
Exit Function
End IF
dim objRegExp
Set objRegExp=new RegExp
objRegExp.IgnoreCase =true
objRegExp.Global=True
objRegExp.Pattern="(" & word & ")"
strContent=objRegExp.Replace(strContent,"$1" )
Set objRegExp=Nothing
BoldWord=strContent
End Function
'===============取得用户当前IP地址===================
Function GetIP()
uIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If uIP = "" Then uIP = Request.ServerVariables("REMOTE_ADDR")
GetIp = uIP
End Function
'===============取得当前程序脚本路径==================
Function GetScriptName()
ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME"))'取得当前地址
If (Request.QueryString <> "") Then
ScriptAddress = ScriptAddress & "?" & Server.HTMLEncode(Request.QueryString)'取得带参数地址
End If
If Len(ScriptAddress)>250 Then ScriptAddress = Left(ScirptAddress,250)&"..." '进行路径截取,最大为250个字符
GetScriptName = ScriptAddress
End Function
'===========返回带参数的Url,多关键字排序时使用==============
' RemoveList 参数:需要从Url中去除的参数,可以是多个,中间请用逗号隔开
Function KeepUrlStr(RemoveList)
ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME"))&"?"'取得当前地址,并加入“?”符号
M_ItemUrl = ""
For Each M_item In Request.QueryString
If InStr(RemoveList,M_Item)=0 Then
M_ItemUrl = M_ItemUrl & M_Item &"="& Server.URLEncode(Request.QueryString(""&M_Item&"")) & "&"
End If
Next
KeepUrlStr = ScriptAddress & M_ItemUrl
End Function
'----日期转化函数-----
function wf_DateToChar(datetime,l)
'---------说明------------
'datetime是你要转化的日期值
'l是你要转化到的层次,可设为"d"、"n"和"s"
'"d"是指转化为yyyy-mm-dd形式
'"n"是指转化为yyyy-mm-dd hh:mm形式
'"s"是指转化为yyyy-mm-dd hh:mm:ss形式
'"long"是指转化为yyyy年mm月dd日的形式
'"no"是指转化为yyyymmdd的形式
'"short"是指转化为yymmdd的形式
'"t"是指转化为yymmdd hh:mm的形式
'-------------------------
dim ls_date,ls_getstr
if isnull(l) or trim(l)="" then l="s"
if isdate(datetime) then
ls_date=cstr(datetime)
'writeln ls_date
ls_getstr=DatePart("yyyy",cdate(ls_date))
ls_getstr=ls_getstr & "-" & wf_ctonstr(DatePart("m",cdate(ls_date)),2)
ls_getstr=ls_getstr & "-" & wf_ctonstr(DatePart("d",cdate(ls_date)),2)
if l="d" then wf_DateToChar=ls_getstr
ls_getstr=ls_getstr & " " & wf_ctonstr(DatePart("h",cdate(ls_date)),2)
ls_getstr=ls_getstr & ":" & wf_ctonstr(DatePart("n",cdate(ls_date)),2)
if l="n" then wf_DateToChar=ls_getstr
ls_getstr=ls_getstr & ":" & wf_ctonstr(DatePart("s",cdate(ls_date)),2)
if l="s" then wf_DateToChar=ls_getstr
if l="long" then wf_DateToChar=DatePart("yyyy",cdate(ls_date))&"年"&wf_ctonstr(DatePart("m",cdate(ls_date)),2)&"月"&wf_ctonstr(DatePart("d",cdate(ls_date)),2)&"日"
if l="no" then wf_DateToChar=DatePart("yyyy",cdate(ls_date))&wf_ctonstr(DatePart("m",cdate(ls_date)),2)&wf_ctonstr(DatePart("d",cdate(ls_date)),2)
if l="short" then wf_DateToChar=right(DatePart("yyyy",cdate(ls_date)),2)&wf_ctonstr(DatePart("m",cdate(ls_date)),2)&wf_ctonstr(DatePart("d",cdate(ls_date)),2)
if l="t" then wf_DateToChar=wf_ctonstr(DatePart("m",cdate(ls_date)),2)&wf_ctonstr(DatePart("d",cdate(ls_date)),2)&" "& wf_ctonstr(DatePart("h",cdate(ls_date)),2)& ":" & wf_ctonstr(DatePart("n",cdate(ls_date)),2)
else
wf_DateToChar=Null
end if
end function
'----把一位整数转化为两位整数----"1" to "01"
function wf_ctonstr(num,n)
if not IsNumeric(num) then
wf_ctonstr=num
else
if len(cstr(cint(num)))>=n then
wf_ctonstr=cstr(cint(num))
else
wf_ctonstr="0"&cstr(cint(num))
while len(wf_ctonstr)全角
'* 参数说明:
'* str:要转换的字符串
'* flag:标记,为0时半转全,为非0时全转半
'* 返回值类型:字符串
'****************************
function DBC2SBC(str,flag)
dim i
if len(str)<=0 then
msgbox "字符串参数出错"
exit function
end if
for i=1 to len(str)
str1=asc(mid(str,i,1))
if str1>0 and str1<=125 and not flag then
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))-23680)
else
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))+23680)
end if
next
end function
'示例:
'alert(dbc2sbc("AB",1))
'=================================================
'函数名:JmailSend
'作 用:用Jmail发送邮件
'参 数:Subject 邮件标题
' Body 邮件内容
' isHtml 是否发送Html格式邮件 (true 是)
' HtmlBody Html格式邮件内容
' MailTo 收件人Email
' From 发件人Email
' FromName 发件人姓名
' Smtp smtp服务器
' Username 邮箱用户名
' Password 邮箱密码
'返回值:JmailSend="N" 发送失败 JmailSend="Y" 发送成功
'=================================================
function JmailSend(Subject,Body,isHtml,HtmlBody,MailTo,From,FromName,Smtp,Username,Password)
dim JmailMsg
set JmailMsg=server.createobject("jmail.message")
JmailMsg.mailserverusername=Username
JmailMsg.mailserverpassword=Password
JmailMsg.addrecipient MailTo
JmailMsg.from=From
JmailMsg.fromname=FromName
JmailMsg.charset="gb2312"
JmailMsg.logging=true
JmailMsg.silent=true
JmailMsg.subject=Subject
JmailMsg.body=Body
if isHtml=true then JmailMsg.htmlbody=HtmlBody
if not JmailMsg.send(Smtp) then
JmailSend="N"
else
JmailSend="Y"
end if
JmailMsg.close
set JmailMsg=nothing
end function
'**************************************************
'函数格式 mkdir( DIrName )
'功能描述 创建一个目录并返回信息
'**************************************************
Function mkdir( xVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FolderExists( xVar ) Then
msg ="抱歉,该目录已存在! "
Else Sys.CreateFolder( xVar )
msg ="恭喜,目录创建成功! "
End If
Set Sys = Nothing
mkdir = msg
End Function
'**************************************************
'函数格式 rmdir( DirName )
'功能描述 删除一个目录并返回信息
'**************************************************
Function rmdir( xVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FolderExists( xVar ) Then
Sys.DeleteFolder( xVar )
msg ="恭喜,目录删除成功!"
Else
msg ="抱歉,该目录还未被创建! "
End If
Set Sys = Nothing
rmdir = msg
End Function
'**************************************************
'函数格式 isdir( DirName )
'功能描述 检查一个目录是否存在并返回信息
'**************************************************
Function isdir( xVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FolderExists( xVar ) Then
msg = True
Else msg = False
End If
Set Sys = Nothing
isdir = msg
End Function
'**************************************************
'函数格式 cpdir( DirName, Destination, OverWrite )
'功能描述 复制文件夹并返回信息
'**************************************************
Function cpdir( xVar, yVar, zVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FolderExists( xVar ) Then
Sys.CopyFolder xVar, root&yVar, zVar
msg ="恭喜,目录复制成功!"
Else
msg ="抱歉,没有找到您想要的目录!"
End If
Set Sys = Nothing
cpdir = msg
End Function
'**************************************************
'函数格式 mvdir( DirName, Destination )
'功能描述 移动一个文件夹并返回信息
'**************************************************
Function mvdir( xVar, yVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FolderExists( xVar ) Then
Sys.MoveFolder xVar, root&yVar
msg ="恭喜,目录夹已移动!"
Else
msg ="抱歉,没有找到您想要的目录!"
End If
Set Sys = Nothing
mvdir = msg
End Function
'**************************************************
'函数格式 isfile( FileName )
'功能描述 检查文件是否存在并返回信息
'**************************************************
Function isfile( xVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FileExists( xVar ) Then
msg = True
Else
msg = False
End If
Set Sys = Nothing
isfile = msg
End Function
'**************************************************
'函数格式 wfile( FileName, OverWrite, String )
'功能描述 写入串到一个文件并返回信息
'**************************************************
Function wfile( xVar, yVar, zVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If yVar Then
Set Txt = Sys.OpenTextFile( xVar, 2 )
Txt.Write( zVar )
Txt.Close
msg ="恭喜,文件创建成功并保存!"
Else
If Sys.FileExists( xVar ) Then
msg ="抱歉,文件已经存在!"
End If
end if
Set Sys = Nothing
wfile = msg
End Function
'**************************************************
'函数格式 rfile( FileName )
'功能描述 读取一个文件并返回信息
'**************************************************
Function rfile( xVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FileExists( xVar ) Then
Set Txt = Sys.OpenTextFile( xVar, 1 )
msg = Txt.ReadAll
Txt.Close
Else
msg ="抱歉,文件不存在!"
End If
Set Sys = Nothing
rfile = msg
End Function
'**************************************************
'函数格式 afile( FileName, String )
'功能描述 添加串到一个文件并返回信息
'**************************************************
Function afile( xVar, zVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FileExists( xVar ) Then
Set Txt = Sys.OpenTextFile( xVar, 8 )
Txt.Write( zVar )
Txt.Close
msg ="恭喜,文件添加成功并保存!"
Else
msg ="抱歉,文件不存在!"
End If
Set Sys = Nothing
afile = msg
End Function
'**************************************************
'函数格式 cpfile( FileName, Destination, OverWrite )
'功能描述 复制一个文件并返回信息
'**************************************************
Function cpfile( xVar, yVar, zVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FileExists( xVar ) Then
Sys.CopyFile xVar, root&yVar, zVar
msg ="恭喜,文件复制成功!"
Else
msg ="抱歉,文件复制失败!"
End If
Set Sys = Nothing
cpfile = msg
End Function
'**************************************************
'函数格式 mvfile( FileName, Destination )
'功能描述 移动一个文件并返回信息
'**************************************************
Function mvfile( xVar, yVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FileExists( xVar ) Then
Sys.MoveFile xVar, root&yVar
msg ="恭喜,文件移动成功!"
Else
msg ="抱歉,文件移动失败!"
End If
Set Sys = Nothing
mvfile = msg
End Function
'**************************************************
'函数格式 rmfile( FileName )
'功能描述 删除一个文件并返回信息
'**************************************************
Function rmfile( xVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FileExists( xVar ) Then
Sys.DeleteFile( xVar )
msg ="恭喜,文件删除成功!"
Else
msg ="抱歉,文件删除失败!"
End If
Set Sys = Nothing
rmfile = msg
End Function
%>
|
|
|
|