⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.asp

📁 安全性好,适用于制作论坛和进行资源下载的个人和大型网站使用!
💻 ASP
字号:
<%
function htmlencode(reString)
dim Str
str=reString
str=replace(str, "&", "&amp;")
str=replace(str, ">", "&gt;")
str=replace(str, "<", "&lt;")
htmlencode=Str
end function

function leftshow(str,strlen)
	if str="" then
		leftshow=""
		exit function
	end if
	dim l,t,c, i
	str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
	l=len(str)
	t=0
	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
			leftshow=left(str,i) & "…"
			exit for
		else
			leftshow=str
		end if
	next
	leftshow=replace(replace(replace(replace(leftshow," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function

function ltime(ttime,ttype)
select case ttype
case 1 ltime=""&year(ttime)&"年"&month(ttime)&"月"&day(ttime)&"日"
case 2 ltime=""&year(ttime)&"/"&month(ttime)&"/"&day(ttime)&""
case 3 ltime=""&year(ttime)&"."&month(ttime)&"."&day(ttime)&""
case 4 ltime=""&year(ttime)&"-"&month(ttime)&"-"&day(ttime)&""
case else ltime=""&year(ttime)&"/"&month(ttime)&"/"&day(ttime)&""
end select
end function

Function restr(Str)
	if isnull(str) or str="" then
		exit function
	else
		restr=replace(str,"'","")
	end if
End Function

function checknum(str)
	if isnull(str) or str=""  then
		exit function
	else
		if not isnumeric(str) then
			response.write"<center>非法操作导致程序中止!</center>"
			response.end
		else
			checknum=int(str)
		end if
	end if
end function

function sart(str)
sart=str
sart=replace(sart,chr(13)&chr(10),"<br>")
sart=replace(sart,chr(9),chr(32)&chr(32)&chr(32)&chr(32)&chr(32)&chr(32)&chr(32)&chr(32))
sart=replace(sart,chr(32)&chr(32)," ")
sart=replace(sart,chr(32)," ")
end function

function checkstr(str)
	if isnull(str) or str=""  then
		exit function
	else
		checkstr=replace(str,"'","''")
	end if	
end function

function strLength(str)
	ON ERROR RESUME NEXT
	dim WINNT_CHINESE
	WINNT_CHINESE    = (len("花香")=2)
	if WINNT_CHINESE then
        dim l,t,c
        dim i
        l=len(str)
        t=l
        for i=1 to l
        	c=asc(mid(str,i,1))
            if c<0 then c=c+65536
            if c>255 then
                t=t+1
            end if
        next
        strLength=t
    else 
        strLength=len(str)
    end if
    if err.number<>0 then err.clear
end function

function isInteger(para)
       on error resume next
       dim str
       dim l,i
       if isNUll(para) then 
          isInteger=false
          exit function
       end if
       str=cstr(para)
       if trim(str)="" then
          isInteger=false
          exit function
       end if
       l=len(str)
       for i=1 to l
           if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
              isInteger=false 
              exit function
           end if
       next
       isInteger=true
       if err.number<>0 then err.clear
end function


Function MultiPage(Numbers,Perpage,Curpage,Url_Add)
	CurPage=Int(Curpage)
	Dim URL
	URL=Request.ServerVariables("Script_Name")&Url_Add
	MultiPage=""
	Dim Page,Offset,PageI
	If Int(Numbers)>Int(PerPage) Then
		Page=10
		Offset=2
		Dim Pages,FromPage,ToPage
		If Numbers Mod Cint(Perpage)=0 Then
			Pages=Int(Numbers/Perpage)
		Else
			Pages=Int(Numbers/Perpage)+1
		End If
		FromPage=Curpage-Offset
		ToPage=Curpage+Page-Offset-1
		If Page>Pages Then
			FromPage=1
			ToPage=Pages
		Else
			If FromPage<1 Then
				Topage=Curpage+1-FromPage
				FromPage=1
				If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then ToPage=Page
			ElseIF Topage>Pages Then
				FromPage =Curpage-Pages +ToPage
				ToPage=Pages
				If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then FromPage=Pages-Page+1
			End If
		End If
                MultiPage="<a href="""&Url&"page=1""><IMG src='images/lt.gif' align=""absMiddle"" border=""0"">首页</a> "
		If Curpage>1 Then 
                        MultiPage=MultiPage&"<a href="""&Url&"page="&Curpage-1&""">上一页</a> "
                Else
                        MultiPage=MultiPage&"上一页 "
                End If
		For PageI=FromPage TO ToPage
			If PageI<>CurPage Then
				MultiPage=MultiPage&"<a href="""&Url&"page="&PageI&""">["&PageI&"]</a> "
			Else
				MultiPage=MultiPage&"<font color=red><b>["&PageI&"]</b></font> "
			End If
		Next
		If Curpage<Pages Then 
                        MultiPage=MultiPage&"<a href="""&Url&"page="&Curpage+1&""">下一页</a> "
                Else
                        MultiPage=MultiPage&"下一页 "
                End If
		        MultiPage=MultiPage&"<a href="""&Url&"page="&Pages&""">尾页<IMG src='images/rt.gif' align=""absMiddle"" border=""0""></a>"
	End If
End Function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -