当前位置: 首页 > 图文教程 > 网络编程 > ASP > 一个比较实用的asp函数集合类(2)

ASP
在ASP文件中调用DLL
ASP服务器组件的编程
在ASP.NET访问Excel文件
ADO.NET:通向未来之桥
ASP.Net的几大热点问题
DataList控件也玩分页
ASP.NET高级应用(1)
ASP.NET高级应用(2)
ASP.NET高级应用(3)
关于ASP.Net中的时间处理
ASP编写完整的一个IP所在地搜索类
ASP发送E-MAIL
建立MSXML 测试环境
怎样创建.NET Web Service
怎样创建.NET Web Service(2)
怎样创建.NET Web Service(3)
怎样创建.NET Web Service(4)
ASP.NET中的HTMLControl和WebControl
比尔·盖茨在微软开发者成功之路大会上的主题演讲
运用.NET读写Windows注册编辑表

ASP 中的 一个比较实用的asp函数集合类(2)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 32 ::
收藏到网摘: n/a

       '******************************
   '名称: ChkInvStr
   '参数:Str
   '返回值:True/False
   '创建时间:2005年5月2日
   '作用:检查参数是否有非法字符
   '******************************
   Public Function ChkInvStr(Str)
   Rem 定义需要过滤得非法字符
   Dim InvaildWord,inWords,i
   Str=CStr(Str)
   ChkInvStr=False
   If Len(Replace(p_InvaildWords,Chr(0),""))<1 Then
   AddErrorCode(103) 'invaildwords is null
   Exit Function
   Else
   If Instr(1,p_Invaildwords,"")>0 Then
   InvaildWord=Split(p_InvaildWords,"")
   inWords=LCase(Trim(Str))
   For i=LBound(InvaildWord) To UBound(InvaildWord)
   If Instr(inWords,InvaildWord(i))>0 Then
   p_Error=1982
   AddErrorCode(105)
   ChkInvStr=True
   Exit Function
   End If
   Next
   Else
   AddErrorCode(104) '"" is requried.
   Exit Function
   End If
   End If
   End Function
  
   '******************************
   '名称: GetIP
   '参数:NULL
   '返回值:NULL
   '创建时间:2005年5月3日
   '作用:得到用户的ip地址
   '******************************
   Public Function GetIP()
   p_IpAdd=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
   If IsNull(p_IpAdd) OR p_IpAdd="" Then
   p_IpAdd=Request.ServerVariables("REMOTE_ADDR")
   End If
   GetIp=p_IpAdd
   End Function
  
   '******************************
   '名称: IPAddress
   '参数:sip
   '返回值:County,City
   '作用:对数据内容进行排版转换
   '创建时间:2005年5月6日
   '来源:www.knowsky.com
   '******************************
   Public Function IPAddress(sip)
   Dim IPConnStr,IPConn,IPAddressDB
   Dim str1,str2,str3,str4
   Dim num
   Dim country,city,address
   Dim IPRs,SQL
   address="未知"
   If IsNumeric(Left(sip,2)) Then
   If sip="127.0.0.1" Then sip="192.168.0.1"
   str1=Left(sip,InStr(sip,".")-1)
   sip=mid(sip,instr(sip,".")+1)
   str2=Left(sip,instr(sip,".")-1)
   sip=Mid(sip,InStr(sip,".")+1)
   str3=Left(sip,instr(sip,".")-1)
   str4=Mid(sip,instr(sip,".")+1)
   If isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0 Then
   Else
   num=CLng(str1)*16777216+CLng(str2)*65536+CLng(str3)*256+CLng(str4)-1
   IPAddressDB = "DSJ_Ipaddress.mdb"
   IPConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(p_dbFolder & IPAddressDB)
   Set IPConn = Server.CreateObject("ADODB.Connection")
   IPConn.Open IpConnStr
   country="亚洲"
   city=""
   sql="select top 1 country,city from DSJ_IPAddress where ip1 <="&num&" and ip2 >="&num&""
   Set IPRs=IPConn.execute(sql)
   If Not(IPRs.EOF And IPRs.bof) Then
   country=IPRs(0)
   city=IPRs(1)
   End If
   IpRs.Close:Set IPRs=Nothing
   IPConn.CLose:Set IPConn = Nothing
   SqlQueryNum = SqlQueryNum+1
   End If
   IPAddress=country&city
   End If
   End Function