亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 編程 > ASP > 正文

ASP開發中有用的函數(function)集合(3)_ASP教程

2024-05-04 11:04:28
字體:
來源:轉載
供稿:網友

推薦:ASP判斷數據庫值是否為空的通用函數
由于各種字段屬性不同,判斷字段是否為空的方法也各異. 下面是一個通用函數,免去了還要看字段類型之苦. 'Check a variable isn't empty Function IsBlank(ByRef TempVar) 'by default, assume it's not blank IsBlank = False 'now check by variable t

ASP開發中有用的函數(function)集合,挺有用的,請大家保留!

'*************************************
'切割內容 - 按行分割
'*************************************
Function SplitLines(byVal Content,byVal ContentNums)
Dim ts,i,l
ContentNums=int(ContentNums)
If IsNull(Content) Then Exit Function
i=1
ts = 0
For i=1 to Len(Content)
l=Lcase(Mid(Content,i,5))
If l="<br/>" Then
ts=ts+1
End If
l=Lcase(Mid(Content,i,4))
If l="<br>" Then
ts=ts+1
End If
l=Lcase(Mid(Content,i,3))
If l="<p>" Then
ts=ts+1
End If
If ts>ContentNums Then Exit For
Next
If ts>ContentNums Then
Content=Left(Content,i-1)
End If
SplitLines=Content
End Function

'*************************************
'切割內容 - 按字符分割
'*************************************
Function CutStr(byVal Str,byVal StrLen)
Dim l,t,c,i
If IsNull(Str) Then CutStr="":Exit Function
l=Len(str)
StrLen=int(StrLen)
t=0
For i=1 To l
c=Asc(Mid(str,i,1))
If c<0 Or c>255 Then t=t+2 Else t=t+1
IF t>=StrLen Then
CutStr=left(Str,i)"..."
Exit For
Else
CutStr=Str
End If
Next
End Function

'*************************************
'刪除引用標簽
'*************************************
Function DelQuote(strContent)
If IsNull(strContent) Then Exit Function
Dim re
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern="/[quote/](.[^/]]*?)/[//quote/]"
strContent= re.Replace(strContent,"")
re.Pattern="/[quote=(.[^/]]*)/](.[^/]]*?)/[//quote/]"
strContent= re.Replace(strContent,"")
Set re=Nothing
DelQuote=strContent
End Function

'*************************************
'獲取客戶端IP
'*************************************
function getIP()
dim strIP,IP_Ary,strIP_list
strIP_list=Replace(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),"'","")

If InStr(strIP_list,",")<>0 Then
IP_Ary = Split(strIP_list,",")
strIP = IP_Ary(0)
Else
strIP = strIP_list
End IF

If strIP=Empty Then strIP=Replace(Request.ServerVariables("REMOTE_ADDR"),"'","")
getIP=strIP
End Function

本文由設計家園 收集整理


'*************************************
'獲取客戶端瀏覽器信息
'*************************************
function getBrowser(strUA)
dim arrInfo,strType,temp1,temp2
strType=""
strUA=LCase(strUA)
arrInfo=Array("Unkown","Unkown")
'瀏覽器判斷
if Instr(strUA,"mozilla")>0 then arrInfo(0)="Mozilla"
if Instr(strUA,"icab")>0 then arrInfo(0)="iCab"
if Instr(strUA,"lynx")>0 then arrInfo(0)="Lynx"
if Instr(strUA,"links")>0 then arrInfo(0)="Links"
if Instr(strUA,"elinks")>0 then arrInfo(0)="ELinks"
if Instr(strUA,"jbrowser")>0 then arrInfo(0)="JBrowser"
if Instr(strUA,"konqueror")>0 then arrInfo(0)="konqueror"
if Instr(strUA,"wget")>0 then arrInfo(0)="wget"
if Instr(strUA,"ask jeeves")>0 or Instr(strUA,"teoma")>0 then arrInfo(0)="Ask Jeeves/Teoma"
if Instr(strUA,"wget")>0 then arrInfo(0)="wget"
if Instr(strUA,"opera")>0 then arrInfo(0)="opera"

if Instr(strUA,"gecko")>0 then
strType="[Gecko]"
arrInfo(0)="Mozilla"
if Instr(strUA,"aol")>0 then arrInfo(0)="AOL"
if Instr(strUA,"netscape")>0 then arrInfo(0)="Netscape"
if Instr(strUA,"firefox")>0 then arrInfo(0)="FireFox"
if Instr(strUA,"chimera")>0 then arrInfo(0)="Chimera"
if Instr(strUA,"camino")>0 then arrInfo(0)="Camino"
if Instr(strUA,"galeon")>0 then arrInfo(0)="Galeon"
if Instr(strUA,"k-meleon")>0 then arrInfo(0)="K-Meleon"
arrInfo(0)=arrInfo(0)+strType
end if

if Instr(strUA,"bot")>0 or Instr(strUA,"crawl")>0 then
strType="[Bot/Crawler]"
arrInfo(0)=""
if Instr(strUA,"grub")>0 then arrInfo(0)="Grub"
if Instr(strUA,"googlebot")>0 then arrInfo(0)="GoogleBot"
if Instr(strUA,"msnbot")>0 then arrInfo(0)="MSN Bot"
if Instr(strUA,"slurp")>0 then arrInfo(0)="Yahoo! Slurp"
arrInfo(0)=arrInfo(0)+strType
end if

if Instr(strUA,"applewebkit")>0 then
strType="[AppleWebKit]"
arrInfo(0)=""
if Instr(strUA,"omniweb")>0 then arrInfo(0)="OmniWeb"
if Instr(strUA,"safari")>0 then arrInfo(0)="Safari"
arrInfo(0)=arrInfo(0)+strType
end if

if Instr(strUA,"msie")>0 then
strType="[MSIE"
temp1=mid(strUA,(Instr(strUA,"msie")+4),6)
temp2=Instr(temp1,";")
temp1=left(temp1,temp2-1)
strType=strType & temp1 "]"
arrInfo(0)="Internet Explorer"
if Instr(strUA,"msn")>0 then arrInfo(0)="MSN"
if Instr(strUA,"aol")>0 then arrInfo(0)="AOL"
if Instr(strUA,"webtv")>0 then arrInfo(0)="WebTV"
if Instr(strUA,"myie2")>0 then arrInfo(0)="MyIE2"
if Instr(strUA,"maxthon")>0 then arrInfo(0)="Maxthon"
if Instr(strUA,"gosurf")>0 then arrInfo(0)="GoSurf"
if Instr(strUA,"netcaptor")>0 then arrInfo(0)="NetCaptor"
if Instr(strUA,"sleipnir")>0 then arrInfo(0)="Sleipnir"
if Instr(strUA,"avant browser")>0 then arrInfo(0)="AvantBrowser"
if Instr(strUA,"greenbrowser")>0 then arrInfo(0)="GreenBrowser"
if Instr(strUA,"slimbrowser")>0 then arrInfo(0)="SlimBrowser"
arrInfo(0)=arrInfo(0)+strType
end if

'操作系統判斷
if Instr(strUA,"windows")>0 then arrInfo(1)="Windows"
if Instr(strUA,"windows ce")>0 then arrInfo(1)="Windows CE"
if Instr(strUA,"windows 95")>0 then arrInfo(1)="Windows 95"
if Instr(strUA,"win98")>0 then arrInfo(1)="Windows 98"
if Instr(strUA,"windows 98")>0 then arrInfo(1)="Windows 98"
if Instr(strUA,"windows 2000")>0 then arrInfo(1)="Windows 2000"
if Instr(strUA,"windows xp")>0 then arrInfo(1)="Windows XP"

if Instr(strUA,"windows nt")>0 then
arrInfo(1)="Windows NT"
if Instr(strUA,"windows nt 5.0")>0 then arrInfo(1)="Windows 2000"
if Instr(strUA,"windows nt 5.1")>0 then arrInfo(1)="Windows XP"
if Instr(strUA,"windows nt 5.2")>0 then arrInfo(1)="Windows 2003"
end if
if Instr(strUA,"x11")>0 or Instr(strUA,"unix")>0 then arrInfo(1)="Unix"
if Instr(strUA,"sunos")>0 or Instr(strUA,"sun os")>0 then arrInfo(1)="SUN OS"
if Instr(strUA,"powerpc")>0 or Instr(strUA,"ppc")>0 then arrInfo(1)="PowerPC"
if Instr(strUA,"macintosh")>0 then arrInfo(1)="Mac"
if Instr(strUA,"mac osx")>0 then arrInfo(1)="MacOSX"
if Instr(strUA,"freebsd")>0 then arrInfo(1)="FreeBSD"
if Instr(strUA,"linux")>0 then arrInfo(1)="Linux"
if Instr(strUA,"palmsource")>0 or Instr(strUA,"palmos")>0 then arrInfo(1)="PalmOS"
if Instr(strUA,"wap ")>0 then arrInfo(1)="WAP"

'arrInfo(0)=strUA
getBrowser=arrInfo
end function

'*************************************
'計算隨機數
'*************************************
function randomStr(intLength)
dim strSeed,seedLength,pos,str,i
strSeed = "abcdefghijklmnopqrstuvwxyz1234567890"
seedLength=len(strSeed)
str=""
Randomize
for i=1 to intLength
str=str+mid(strSeed,int(seedLength*rnd)+1,1)
next
randomStr=str
end function

'*************************************
'自動閉合UBB
'*************************************
function closeUBB(strContent)
dim arrTags,i,OpenPos,ClosePos,re,strMatchs,j,Match
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
arrTags=array("code","quote","list","color","align","font","size","b","i","u","html")
for i=0 to ubound(arrTags)
OpenPos=0
ClosePos=0

re.Pattern="/["+arrTags(i)+"(=[^/[/]]+|)/]"
Set strMatchs=re.Execute(strContent)
For Each Match in strMatchs
OpenPos=OpenPos+1
next
re.Pattern="/[/"+arrTags(i)+"/]"
Set strMatchs=re.Execute(strContent)
For Each Match in strMatchs
ClosePos=ClosePos+1
next
for j=1 to OpenPos-ClosePos
strContent=strContent+"[/"+arrTags(i)+"]"
next
next
closeUBB=strContent
end function

'*************************************
'自動閉合HTML
'*************************************
function closeHTML(strContent)
dim arrTags,i,OpenPos,ClosePos,re,strMatchs,j,Match
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
arrTags=array("p","div","span","table","ul","font","b","u","i","h1","h2","h3","h4","h5","h6")
for i=0 to ubound(arrTags)
OpenPos=0
ClosePos=0

re.Pattern="/<"+arrTags(i)+"( [^/</>]+|)/>"
Set strMatchs=re.Execute(strContent)
For Each Match in strMatchs
OpenPos=OpenPos+1
next
re.Pattern="/</"+arrTags(i)+"/>"
Set strMatchs=re.Execute(strContent)
For Each Match in strMatchs
ClosePos=ClosePos+1
next
for j=1 to OpenPos-ClosePos
strContent=strContent+"</"+arrTags(i)+">"
next
next
closeHTML=strContent
end function

'*************************************
'讀取文件
'*************************************
Function LoadFromFile(ByVal File)
Dim objStream
Dim RText
RText=array(0,"")
On Error Resume Next
Set objStream = Server.CreateObject("ADODB.Stream")
If Err Then
RText=array(Err.Number,Err.Description)
LoadFromFile=RText
Err.Clear
exit function
End If
With objStream
.Type = 2
.Mode = 3
.Open
.Charset = "utf-8"
.Position = objStream.Size
.LoadFromFile Server.MapPath(File)
If Err.Number<>0 Then
RText=array(Err.Number,Err.Description)
LoadFromFile=RText
Err.Clear
exit function
End If
RText=array(0,.ReadText)
.Close
End With
LoadFromFile=RText
Set objStream = Nothing
End Function

'*************************************
'保存文件
'*************************************
Function SaveToFile(ByVal strBody,ByVal File)
Dim objStream
Dim RText
RText=array(0,"")
On Error Resume Next
Set objStream = Server.CreateObject("ADODB.Stream")
If Err Then
RText=array(Err.Number,Err.Description)
Err.Clear
exit function
End If
With objStream
.Type = 2
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText = strBody
.SaveToFile Server.MapPath(File),2
.Close
End With
RText=array(0,"保存文件成功!")
SaveToFile=RText
Set objStream = Nothing
End Function

'*************************************
'數據庫添加修改操作
'*************************************
function DBQuest(table,DBArray,Action)
dim AddCount,TempDB,i,v
if Action<>"insert" or Action<>"update" then Action="insert"
if Action="insert" then v=2 else v=3
if not IsArray(DBArray) then
DBQuest=-1
exit function
else
Set TempDB=Server.CreateObject("ADODB.RecordSet")
On Error Resume Next
TempDB.Open table,Conn,1,v
if err then
DBQuest=-2
exit function
end if
if Action="insert" then TempDB.addNew
AddCount=UBound(DBArray,1)
for i=0 to AddCount
TempDB(DBArray(i)(0))=DBArray(i)(1)
next
TempDB.update
TempDB.close
set TempDB=nothing
DBQuest=0
end if
end Function

'*************************************
'檢測系統組件是否安裝
'*************************************
Function CheckObjInstalled(strClassString)
On Error Resume Next
Dim Temp
Err = 0
Dim TmpObj
Set TmpObj = Server.CreateObject(strClassString)
Temp = Err
IF Temp = 0 OR Temp = -2147221477 Then
CheckObjInstalled=true
ElseIF Temp = 1 OR Temp = -2147221005 Then
CheckObjInstalled=false
End IF
Err.Clear
Set TmpObj = Nothing
Err = 0
End Function

'*************************************
'判斷服務器Microsoft.XMLDOM
'*************************************
Function getXMLDOM
On Error Resume Next
Dim Temp
getXMLDOM="Microsoft.XMLDOM"
Err = 0
Dim TmpObj
Set TmpObj = Server.CreateObject(getXMLDOM)
Temp = Err
IF Temp = 1 OR Temp = -2147221005 Then
getXMLDOM="Msxml2.DOMDocument.5.0"
End IF
Err.Clear
Set TmpObj = Nothing
Err = 0
end function

'*************************************
'判斷服務器MSXML2.ServerXMLHTTP
'*************************************
Function getXMLHTTP
On Error Resume Next
Dim Temp
getXMLHTTP="MSXML2.ServerXMLHTTP"
Err = 0
Dim TmpObj
Set TmpObj = Server.CreateObject(getXMLHTTP)
Temp = Err
IF Temp = 1 OR Temp = -2147221005 Then
getXMLHTTP="Msxml2.ServerXMLHTTP.5.0"
End IF
Err.Clear
Set TmpObj = Nothing
Err = 0
end function

'*************************************
'垃圾關鍵字過濾
'*************************************
function filterSpam(str,path)
on error resume next
filterSpam = false
dim spamXml,spamItem
Set spamXml = Server.CreateObject(getXMLDOM)
If Err Then
Err.clear
exit function
end if
spamXml.async = false
spamXml.load(Server.MapPath(path))
if spamXml.parseerror.errorcode=0 then
For Each spamItem in spamXml.selectNodes("//key")
if InStr(Lcase(str),Lcase(spamItem.text))<>0 then
filterSpam = true
exit function
end if
next
end if
set spamXml=nothing
end function

'*********************************************************
' 目的: 檢查正則式
' 輸入: id
' 返回: 成功為True
'*********************************************************
Function CheckRegExp(source,para)

If para="[username]" Then
para="^[.A-Za-z0-9/u4e00-/u9fa5]+"
End If
If para="[password]" Then
para="^[a-z0-9]+"
End If
If para="[email]" Then
para="^([0-9a-zA-Z]([-./w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-/w]*/.)+[a-zA-Z]*)"
End If
If para="[homepage]" Then
para="^[a-zA-Z]+://[a-zA-z0-9/-/./]+?/*"
End If
If para="[nojapan]" Then
para="[/u3040-/u30ff]+"
End If
If para="[guid]" Then
para="^/w{8}/-/w{4}/-/w{4}/-/w{4}/-/w{12}"
End If

Dim re
Set re = New RegExp
re.Global = True
re.Pattern = para
re.IgnoreCase = False
CheckRegExp = re.Test(source)

End Function

'**********************************************
'獲取在線人數
'**********************************************
function getOnline
getOnline=1
if len(Application(space_CookieName"_onlineCount"))>0 then
if DateDiff("s",Application(space_CookieName"_userOnlineCountTime"),now())>60 then
Application.Lock()
Application(space_CookieName"_online")=Application(space_CookieName"_onlineCount")
Application(space_CookieName"_onlineCount")=1
Application(space_CookieName"_onlineCountKey")=randStr(2)
Application(space_CookieName"_userOnlineCountTime")=now()
Application.Unlock()
else
if Session(space_CookieName"userOnlineKey")<>Application(space_CookieName"_onlineCountKey") then
Application.Lock()
Application(space_CookieName"_onlineCount")=Application(space_CookieName"_onlineCount")+1
Application.Unlock()
Session(space_CookieName"userOnlineKey")=Application(space_CookieName"_onlineCountKey")
end if
end if
else
Application.Lock
Application(space_CookieName"_online")=1
Application(space_CookieName"_onlineCount")=1
Application(space_CookieName"_onlineCountKey")=randStr(2)
Application(space_CookieName"_userOnlineCountTime")=now()
Application.Unlock
end if
getOnline=Application(space_CookieName"_online")
end Function

%>

本文由設計家園 收集整理

分享:ASP將數據庫中的數據導出到EXCEL表中
ASP實例代碼,直接將數據庫中的數據導出到EXCEL電子表中。 !--#include file=../conn.asp-- % dim s,sql,filename,fs,myfile,x Set fs = server.CreateObject(scripting.filesystemobject) '--假設你想讓生成的EXCEL文件做如下的存放 filename = Server.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
国产精品激情av电影在线观看| 91地址最新发布| 亚洲有声小说3d| 亚洲一区二区三区香蕉| 亚洲第一天堂av| 色婷婷综合久久久久中文字幕1| 亚洲一区999| 91国语精品自产拍在线观看性色| 亚洲精品一区二区三区不| 久久久之久亚州精品露出| 亚洲国产精品美女| 51视频国产精品一区二区| 亚洲欧美精品suv| 欧美激情一二区| 日韩中文字幕网站| 久久久免费精品视频| 国产精品嫩草影院久久久| 国产视频亚洲精品| 夜夜嗨av一区二区三区四区| 中文字幕久久亚洲| 自拍亚洲一区欧美另类| 国模精品视频一区二区三区| 一本色道久久88综合日韩精品| 欧美重口另类videos人妖| 亚洲人成欧美中文字幕| 欧美成人免费全部观看天天性色| 亚洲91精品在线观看| 久久久久久999| 一区二区欧美在线| 国产欧美日韩91| 国产精品久久电影观看| 久久精品久久精品亚洲人| 久久久精品一区二区| 久久精品久久久久久国产 免费| 尤物九九久久国产精品的分类| 国产色婷婷国产综合在线理论片a| 国产97色在线| 午夜精品理论片| 久久亚洲国产精品成人av秋霞| 91精品在线影院| 亚洲一区二区久久| 欧美疯狂性受xxxxx另类| 8x海外华人永久免费日韩内陆视频| 亚洲91av视频| www.久久草.com| 国产自产女人91一区在线观看| 欧美激情第99页| 992tv成人免费影院| 欧美日韩成人精品| 欧美成人国产va精品日本一级| 在线精品国产欧美| 亚洲激情视频网站| 色哟哟亚洲精品一区二区| 亚洲精品自拍视频| 国产精品视频免费在线| 97国产精品免费视频| 日韩久久精品成人| 日韩av一卡二卡| 国产精品一二三视频| 久久精品中文字幕免费mv| 国产97在线|日韩| 欧美丝袜第一区| 这里精品视频免费| 久久在线免费视频| 国产91精品久| 国产精品jizz在线观看麻豆| 亚洲网站视频福利| www.99久久热国产日韩欧美.com| 亚洲第一精品夜夜躁人人爽| 久久人人爽人人爽爽久久| 国产欧美精品日韩精品| 亚洲国产免费av| 7777精品久久久久久| 黄网站色欧美视频| 精品久久久免费| 国产精品av免费在线观看| 欧美重口另类videos人妖| 国产亚洲aⅴaaaaaa毛片| 国产欧美日韩精品专区| 国产精品久久久久久影视| 91中文精品字幕在线视频| www.亚洲天堂| 色偷偷噜噜噜亚洲男人的天堂| 成人h片在线播放免费网站| 亚洲国产成人精品久久久国产成人一区| 日韩免费观看网站| 青青草原成人在线视频| 日本sm极度另类视频| 欧美在线影院在线视频| 欧美激情第99页| 一本久久综合亚洲鲁鲁| 色综合伊人色综合网| 亚洲www永久成人夜色| 日韩精品www| 欧美激情a∨在线视频播放| 2020欧美日韩在线视频| 亚洲影视中文字幕| 欧美贵妇videos办公室| 久久久噜噜噜久久久| 欧美一区二区三区艳史| 中文字幕精品久久| 日韩中文理论片| 欧美在线中文字幕| 久久综合久久美利坚合众国| 2020欧美日韩在线视频| 中国china体内裑精亚洲片| 精品国产福利在线| 久久人人爽人人| 久久天天躁夜夜躁狠狠躁2022| 欧美午夜精品在线| 亚洲一区二区久久| 欧美交受高潮1| 国产精品第七十二页| 成年人精品视频| 欧美一区二区大胆人体摄影专业网站| 亚洲乱码一区av黑人高潮| 亚洲一区中文字幕| 欧美性猛交xxxx偷拍洗澡| 成人精品久久久| 亚洲在线免费视频| 国产精品电影网| 国产精品日韩欧美| 成人激情在线观看| 国产精品久久久久久久久粉嫩av| 日韩国产高清污视频在线观看| 国产在线视频一区| 欧美精品在线观看91| 欧美另类极品videosbest最新版本| 国产精品揄拍一区二区| 91精品视频观看| 亚洲国产精品成人一区二区| 最近2019中文字幕第三页视频| 亚洲欧美制服中文字幕| 国产视频亚洲视频| 国产三级精品网站| 国产欧美日韩精品专区| 亚洲国产成人久久综合| 久久久精品电影| 欧美高跟鞋交xxxxhd| 亚洲成人999| 欧美日韩精品国产| 日韩在线观看成人| 一区二区中文字幕| 91久久久亚洲精品| 精品高清美女精品国产区| 久久综合久久88| 国产精品久在线观看| 成人免费自拍视频| 亚洲国产精品va| 欧美午夜精品久久久久久久| 色午夜这里只有精品| 国产精品一区二区3区| 日韩电影免费观看中文字幕| 欧美怡春院一区二区三区| 欧美黑人又粗大| 91久久久久久久久久久久久| 成人国产精品免费视频| 亚洲91精品在线| 国产欧美日韩免费| 欧美香蕉大胸在线视频观看| 亚洲色图35p| 伊人亚洲福利一区二区三区| 成人午夜黄色影院| 欧美在线视频网站|