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

ASP
论坛树状记录表的堆栈展开
Oracle大文本在ASP中存取问题的解决
ASP创建SQL Server数据库的两种方法
浅谈session_onend的调试
用ASP访问数据库的几种常见方式
教你一次下载网页中的所有资源
20种看asp源码的方法及工具
在ASP中使用智岛网格控件全过程
解决使用ASP无法连接ORACLE 9i数据库的问题
用Js判断输入的时间是否有效
ADO数据与XML数据间的转换的类
使用命名管道访问SQL Server
网页加速之网页结构篇
在红蜻蜓中实现多房间
在ASP中使用Oracle数据库技巧
关于分页办法
在VB中使用API函数(Any)
网站ASP漏洞小总结
网页之定时器详解
实用函数- 判断输入的是否是电话号码

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 19 ::
收藏到网摘: 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