asp开辟中常用函数[网站编程]
本文“asp开辟中常用函数[网站编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
<%
'能否是安全拜候
function isselfrefer()
server_v1=lcase(request.servervariables("http_referer"))
server_v2=lcase(request.servervariables("server_name"))
if instr(server_v1,server_v2)<1 then
isselfrefer = false'不是
else
isselfrefer = true'是
end if
end function
'页面出错
private sub page_err(msg)
response.write(msg)
response.end()
end sub
'格局化日期
function formatdate(sdate,ssplit)
y = cstr(year(sdate))
m = cstr(month(sdate))
if len(m)=1 then m = "0" & m
d = cstr(day(sdate))
if len(d)=1 then d = "0" & d
formatdate = y & ssplit & m & ssplit & d
end function
function mycdbl(str)
if str = "" or not isnumeric(str) then
call page_err("参数错误:要求为数字型.")
else
mycdbl = cdbl(str)
end if
end function
function getnumber(str)
if str = "" or not isnumeric(str) then
call page_err("参数错误:要求为数字型.")
else
getnumber = str
end if
end function
private sub messagebox(msg,gotourl)
response.write("<script language=""网页特效"">")
response.write("alert(""" & msg & """);")
if gotourl="" then
response.write("history.back();")
else
response.write("document.url='" & gotourl & "';")
end if
response.write("</script>")
response.end()
end sub
'自定义left
function leftx(str,n)
dim i,j,ch,strtmp
j = 0
strtmp = ""
for i = 1 to len(str)
ch = mid(str,i,1)
strtmp = strtmp & ch
if asc(ch)<0 then
j = j + 2
else
j = j + 1
end if
if j >= n then exit for
next
leftx = strtmp
end function
'输出字符串
function outstr(str)
strer=str
if strer="" or isnull(strer) then
outstr="":exit function
end if
strer=replace(strer,"<","<")
strer=replace(strer,">",">")
strer=replace(strer,chr(13) & chr(10),"<br>") '换行
strer=replace(strer,chr(32)," ") '空格
strer=replace(strer,chr(9)," ") 'table
strer=replace(strer,chr(39),"'") '单引号
strer=replace(strer,chr(34),""") '双引号
outstr = strer
end function
'过滤html标签
function filterhtml(fstring)
if isnull(fstring) or trim(fstring)="" then
filterhtml=""
exit function
end if
set re = new regexp
re.ignorecase=true
re.global=true
re.pattern="<(.+?)>"
fstring = re.replace(fstring, "")
set re=nothing
filterhtml = fstring
end function
'履行sql,返一行一列的值
function execsqlreturnonevalue(sql)
set oprs = server.createobject("adodb.recordset")
oprs.open sql,conn,0,1
if oprs.eof and oprs.bof then
execsqlreturnonevalue = ""
else
execsqlreturnonevalue = oprs(0)
end if
oprs.close
set oprs = nothing
end function
'格局化日期
function format_time(s_time,n_flag)
dim y, m, d, h, mi, s
format_time = ""
if isdate(s_time) = false then exit function
y = cstr(year(s_time))
m = cstr(month(s_time))
if len(m) = 1 then m = "0" & m
d = cstr(day(s_time))
if len(d) = 1 then d = "0" & d
h = cstr(hour(s_time))
if len(h) = 1 then h = "0" & h
mi = cstr(minute(s_time))
if len(mi) = 1 then mi = "0" & mi
s = cstr(second(s_time))
if len(s) = 1 then s = "0" & s
select case n_flag
case 1
' yyyy-mm-dd hh:mm:ss
format_time = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
case 2
' yyyy-mm-dd
format_time = y & "-" & m & "-" & d
case 3
' hh:mm:ss
format_time = h & ":" & mi & ":" & s
case 4
' yyyy年mm月dd日
format_time = y & "年" & m & "月" & d & "日"
以上是“asp开辟中常用函数[网站编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |