ASP中幾個有用的函式

2021-03-31 08:56:57 字數 2869 閱讀 3144

/* 原出處:江都資訊網論壇

function deletefile(filename) '刪除檔案

if filename<>"" then

set fso = server.createobject("scripting.filesystemobject")

if fso.fileexists(filename) then

fso.deletefile filename

end if

set fso = nothing

end if

end function

function createdir(byval localpath) '建立目錄的程式,如果有多級目錄,則一級一級的建立

on error resume next

localpath = replace(localpath,"/","/")

set fileobject = server.createobject("scripting.filesystemobject")

patharr = split(localpath,"/")

path_level = ubound(patharr)

for i = 0 to path_level

if i=0 then pathtmp=patharr(0) & "/" else pathtmp = pathtmp & patharr(i) & "/"

cpath = left(pathtmp,len(pathtmp)-1)

if not fileobject.folderexists(cpath) then fileobject.createfolder cpath

next

set fileobject = nothing

if err.number<>0 then

createdir = false

err.clear

else

createdir = true

end if

end function

function generaterandomfilename(byval szfilename) '根據原檔名生成新的隨機檔名

randomize

rannum=int(90000*rnd)+10000

if month(now)<10 then c_month="0" & month(now) else c_month=month(now)

if day(now)<10 then c_day="0" & day(now) else c_day=day(now)  

if hour(now)<10 then c_hour="0" & hour(now) else c_hour=hour(now)

if minute(now)<10 then c_minute="0" & minute(now) else c_minute=minute(now)

if second(now)<10 then c_second="0" & second(now) else c_second=minute(now)

fileext_a=split(szfilename,".")

fileext=lcase(fileext_a(ubound(fileext_a)))

generaterandomfilename = year(now)&c_month&c_day&c_hour&c_minute&c_second&"_"&rannum&"."&fileext

end function

function jaron_replacer(strcontent,start_string,end_string,replace_string)

'cms替換函式:源字串,前部分,後部分,替換成的字元

'返回被替換後的字串

jaron_replacer = replace(strcontent,mid(strcontent,instr(strcontent,start_string),instr(strcontent,end_string)+len(end_string)-1),replace_string)

end function

function replaceplus(strcontent,start_string,end_string,replace_string) '文件中,將所有開始,結束之間的所有字元刪除

on error resume next

markcounts = ubound(split(strcontent,start_string))

prestring = strcontent

for i=0 to markcounts

startmark=instr(1,prestring,start_string,1)

if startmark=0 then exit for

***pmark=instr(1,prestring,end_string,1) + len(end_string)

verstring=mid(prestring,startmark,***pmark - startmark)

prestring = replace(prestring,verstring,replace_string)

next

replaceplus = prestring

if err.number<>0 then err.clear

end function

如果在一段html中,你並不知道裡面有多少個flash,想把他們全部刪除。就可以這樣用。

strcontent = replaceplus(strcontent,"","")

這個命令可以把html**中所有.... 的標記全部刪除。

mysql中幾個有用的函式

1.from unixtime 作用 將mysql中以int 11 儲存的時間以 yyyy mm dd 格式來顯示。例 作用 將str1,str2.連線為字串。如有任何乙個引數為null 則返回值為 null。例 update video set playlink concat playlink,f...

標準庫中的幾個有用的函式

好幾天沒跟大家見了,這幾天忙著總結和學習新的知識呢 一nsrange 一nspoint 一nssize 一nsrect 一nssting 和 nsmutablesting 字串 nssting bool hasprefix nsstring astring 判斷字串是否以另乙個字元 bool has...

幾個常用的ASP函式

取得帶埠的url,推薦使用 function get scriptnameurl if request.servervariables server port 80 then get scriptnameurl http request.servervariables serve程式設計客棧r na...