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

📄 lib.asp

📁 增添网站节日气氛
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<%
Private Function FilterSQL(strValue)
'函数名称: FilterSQL
'功能描述: 过滤字符串中的单引号

'使用方法:FilterSQL(strValue)
	FilterSQL=Replace(strValue,"'","''")
End Function

Private Function IsSubmit()
'函数名称: IsSubmit
'功能描述: 判断页面是否提交
'使用方法:如果是提交则返回 True 否则返回 False
'		 If IsSubmit Then
'  		 ...
'		 else
'		 ...
'		 End if
	IsSubmit=Request.ServerVariables("request_method")="POST"
End Function

Function HTMLcode(fString)
'函数名称: HTMLcode
'功能描述: 转换字符为HTML格式
'使用方法:HTMLcode(fString)
	If Not isnull(fString) then
		fString = replace(fString, ">", "&gt;")
		fString = replace(fString, "<", "&lt;")
		fString = Replace(fString, CHR(32), "&nbsp;")
		fString = Replace(fString, CHR(9), "&nbsp;")
		fString = Replace(fString, CHR(34), "&quot;")
		fString = Replace(fString, CHR(39), "&#39;")
		fString = Replace(fString, CHR(13), "")
		fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
		fString = Replace(fString, CHR(10), "<BR> ")
		HTMLcode = fString
	End if
End function

Function gotTopic(str,strlen)
'函数名称: gotTopic
'功能描述: 控制字符串显示的长度
'使用方法:gotTopic(str,strlen)
Dim l,t,c
	l=len(str)
	t=0
	If IsNull(str) Then Exit Function
	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
			gotTopic=left(str,i)&"..."
			exit for
		Else
			gotTopic=str&""
		End if
	Next
End function

function cutStr(str,strlen)
'函数名称: cutStr
'功能描述: 限制标题长度
'传入参数:str 字符串;strlen 长度
'传出参数:cutStr
'使用方法:cutStr(str,strlen)
	dim l,t,c
	l=len(str)
    If l>strlen Then
	   cutStr=left(str,strlen-2)&"..."
	Else
	   cutStr=str
	End IF
end function

Private Function GetLongDate(Value)
'函数名称: GetLongDate
'功能描述: '把时间转换为长日期格式格式 与 FormatDateTime函数相似
'使用方法:GetLongDate(Value)
    Dim strYear, strMonth, strDate
    strYear = Year(Value)
    strMonth = Month(Value)
    strDate = Day(Value)
    GetLongDate = strYear & " 年 " & strMonth & " 月 " & strDate & "日"
End Function

Private Function GetFields(Value)
'函数名称: GetFields
'功能描述: 当数据库中字段为空时,返回空
'使用方法:GetFields(Value)
	If IsNull(Value) Then
		GetFields=""
	Else
		GetFields= Value 
	End If
End Function




private function OnlyWord(strng)
'函数名程:OnlyWord
'功能描述:只替换字符串中的图片
'传入参数:strng
'使用方法:OnlyWord(strng)
Set re=new RegExp 
re.IgnoreCase =True 
re.Global=True 

re.Pattern = "(<)(.[^<]*)(src=)('|"&CHR(34)&"| )?(.[^'|\s|"&CHR(34)&"]*)(\.)(jpg|gif|png|bmp|jpeg|swf)('|"&CHR(34)&"|\s|>)(.[^>]*)(>)" '设置模式。 
OnlyWord=re.Replace(strng,"") 
Set re= nothing 
end function 
 
Function RemoveHTML(strHTML)
'函数名程:RemoveHTML
'功能描述:去除字符串中的html代码,包括图片
'传入参数:strHTML
'使用方法:RemoveHTML(strHTML)
Dim objRegExp, Match, Matches 
Set objRegExp = New Regexp 

objRegExp.IgnoreCase = True 
objRegExp.Global = True 
'取闭合的<> 
objRegExp.Pattern = "<.+?>" 
'进行匹配 函数的建立

Set Matches = objRegExp.Execute(strHTML) 

' 遍历匹配集合,并替换掉匹配的项目 
For Each Match in Matches 
strHtml=Replace(strHTML,Match.Value,"") 
Next 
RemoveHTML=strHTML 
Set objRegExp = Nothing 
End Function 


sub ShowPage(Url,TotleNum,NumPerPage,page,ShowJump,pagestyle)
  '函数名:showpage(Url,TotleNum,NumPerPage,ShowJump)
    '作  用:显示分页代码
    '参  数:Url:传递查询参数
    '        TotleNum:总条数
	'        NumPerPage:每页条数
	'        ShowJump:是否显示跳转按钮 (true or false)
	'        pagestyle:  1:上一页下一页    2:多页
	if TotleNum<=NumperPage Then Exit Sub	
    Url=trim(Url)
	'arrurl=Url       '为跳转框实现GET功能
	if Url<>"" then Url=Url&"&"
	Dim strTemp
	if TotleNum mod NumPerPage=0 then
    	n= TotleNum\NumPerPage
  	else
    	n= TotleNum\NumPerPage+1
  	end if	
  	strTemp= "<script language=javascript>function chkUrl(){formx.action=""?"&Url&"page=""+formx.Page.value;return true;}</script><table align='center'  width=""100%""><form name=""formx"" method=""post"" action="""" onSubmit=""return chkUrl()""><tr><td align=""center"">"
	strTemp=strTemp & "页次:" & Page & "/" & n & "页 "
	strTemp=strTemp & NumPerPage & "条/页 "
	strTemp=strTemp & "共" & TotleNum & "条 &nbsp;&nbsp;&nbsp;&nbsp;"	
  select case pagestyle
    case 1
	if Page<2 then
    		strTemp=strTemp & "<font color=""#999999"">首页 上页</font> "
  	else
    		strTemp=strTemp & "<a href='?" & Url & "page=1'  class=""link"">首页</a> "
    		strTemp=strTemp & "<a href='?" & Url & "page=" & (Page-1) & "'  class=""link"">上页</a> "
  	end if
  	if n-Page<1 then
    		strTemp=strTemp & "<font color=""#999999"">下页 尾页</font> "
  	else
    		strTemp=strTemp & "<a href='?" & Url & "page=" & (Page+1) & "'  class=""link"">下页</a> "
    		strTemp=strTemp & "<a href='?" & Url & "page=" & n & "'  class=""link"">尾页</a>  "
  	end if 
  case 2
    if page-1 mod 10=0 then
		p=(page-1) \ 10
	else
		p=(page-1) \ 10
	end if
	if p*10>0 then strTemp=strTemp &"<a href='?" & Url & "page="&p*10&"' title=上十页 >[&lt;&lt;]</a>   "
    uming_i=1
	for ii=p*10+1 to P*10+10
		   if ii=page then  
	         strTemp=strTemp &"<strong><font color=#ff0000>["+Cstr(ii)+"]</font></strong> "
		   else
		     strTemp=strTemp &"<a href='?" & Url & "page="&ii&"'>["+Cstr(ii)+"]</a> "
		   end if
		if ii=n then exit for
		 uming_i=uming_i+1
	next
  	if ii<=n and uming_i=11 then strTemp=strTemp &"<a href='?" & Url & "page="&ii&"' title=下十页>[&gt;&gt;]</a>  "
   end select	 
  
   
	if ShowJump=True then strTemp=strTemp & "  &nbsp;跳至第&nbsp;<input type=text size=3 name=""Page"">页 <input type=""Submit"" name=""Submit"" value=""跳转""  class=""sbe_button""> "
	strTemp=strTemp & "</td></tr></form></table>"
	response.write strTemp
end sub


Function DeleteFile(delfile,filepath) 
'函数名:DeleteFile 
'作  用:删除文件。
'参  数:delfile(要删除的文件名) | filepath (删除路径)
'返回值:无
Set fso = Server.CreateObject("Scripting.FileSystemObject")
   if instr(delfile,"|")>0 then
    dim morefile
    morefile=split(delfile,"|")
    for tempnum=0 to ubound(morefile)
        delfilepath=server.MapPath(filepath&"/"&morefile(tempnum))
	if fso.FileExists(delfilepath) then
	    fso.DeleteFile(delfilepath)	
	end if 
    next
   else
        delfilepath=server.MapPath(filepath&"/"&delfile)
	if fso.FileExists(delfilepath) then
	   fso.DeleteFile(delfilepath)
        end if
   end if
 set fso=nothing
 End Function


function ReturnSel(str1,str2,seltype)
'函数名:ReturnSel
'作  用:下拉框,复选框选择
'参  数:str1 原有值;str2 数据库值;seltype:类型
'返回值:无
select case seltype
         case 1
            if str1=str2 then response.write("selected")
         case 2
            if str1=str2 then response.write("checked")
     end select
end function


Function Judgement(content) '函数的建立

'函数名:judgement 
'作  用:判断是否。
'参  数:content---判断内容
'返回值:√ or ×
if content=true then
   response.Write("<b><font color=#009900>√</font></b>")
  else 
   response.Write("<b><font color=#FF0000>×</font></b>")
  end if
end Function

Private Sub Del(Table_name,ItemID,intID)
'过程名:Del
'功能描述: 删除数据库中的记录
'Table_name数据表名
'     ItemID:字段名
'     intID:ID序号
sql="delete from "&Table_name&" where "&ItemID&" =" &clng(intID)
conn.execute(sql)

⌨️ 快捷键说明

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