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

ASP
ASP编程中20个非常有用的例子
省名与城名下拉选择框联动
ASP有函数可以把某个网页通过STREAM下载吗?
用Regular Expression来改变HTML代码
控制输出字符串的长度,可以区别中英文
教你做小偷程序 容易学
小偷程序原理和简单示例
好漂亮的钟[代码]
实现WEB中的@虚拟域名系统 原理篇
ASP对excel的操作
将服务器端文件夹下的文件,按文件建立的时间先后排序
存储过程编写经验和优化措施
存储过程入门
在ASP中怎樣用Excel寫報表
在ASP中使用Oracle数据库技巧(1)
在ASP中使用Oracle数据库技巧(2)
在ASP中使用断开的记录集
披著羊皮的大野狼 Session
两级联动的select XML版
判断checkbox是否至少有选择一项

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


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