天枫常用的ASP函数封装如下

2019-01-13 12:34:05王振洲

 '****************************************************
 '函数名:GetUrl
 '作  用:获取url包括参数
 '返回值:获取url包括参数
 '****************************************************
 Public Function GetUrl()   
  Dim strTemp     
  strTemp=Request.ServerVariables("Script_Name")      
  If  Trim(Request.QueryString)<> "" Then
   strTemp=strTemp&"?"
   For Each M_item In Request.QueryString
    strTemp=strTemp&M_item&"="&Server.UrlEncode(Trim(Request.QueryString(""&M_item&"")))
   next
  end if
  GetUrl=strTemp   
 End Function 

 '****************************************************
 '函数名:CUrl
 '作  用:获取当前页面URL的函数
 '返回值:当前页面URL的函数
 '****************************************************
 Function CUrl()
  Domain_Name = LCase(Request.ServerVariables("Server_Name"))
  Page_Name = LCase(Request.ServerVariables("Script_Name"))
  Quary_Name = LCase(Request.ServerVariables("Quary_String"))
  If Quary_Name ="" Then
   CUrl = "http://"&Domain_Name&Page_Name
  Else
   CUrl = "http://"&Domain_Name&Page_Name&"?"&Quary_Name
  End If
 End Function

    '****************************************************
 '函数名:GetExtend
 '作  用:取得文件扩展名
 '参  数:filename ----文件名
 '****************************************************
 Public Function GetExtend(filename)
  dim tmp
  if filename<>"" then
   tmp=mid(filename,instrrev(filename,".")+1,len(filename)-instrrev(filename,"."))
   tmp=LCase(tmp)
   if instr(1,tmp,"asp")>0 or instr(1,tmp,"php")>0 or instr(1,tmp,"php3")>0 or instr(1,tmp,"aspx")>0 then
    getextend="txt"
   else
    getextend=tmp
   end if
  else
   getextend=""
  end if
 End Function
'------------------数据库的操作-----------------------

    '****************************************************
 '函数名:CheckExist
 '作  用:检测某个表中某个字段是否存在某个内容
 '参  数:table        ----表名
 '       fieldname    ----字段名
 '       fieldcontent ----字段内容
 '       isblur       ----是否模糊匹配
 '返回值:false不存在,true存在
 '****************************************************
 Function CheckExist(table,fieldname,fieldcontent,isblur)
  CheckExist=false
  If isblur=1 Then
            set rsCheckExist=conn.execute("select * from "&table&" where "&fieldname&" like '%"&fieldcontent&"%'")
  else
   set rsCheckExist=conn.execute("select * from "&table&" where "&fieldname&"= '"&fieldcontent&"'")
  End if
  if not (rsCheckExist.eof and rsCheckExist.bof) then CheckExist=true
  rsCheckExist.close
  set rsCheckExist=nothing
 End Function