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

2016-01-29 19:43 0 1 收藏

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

【 tulaoshi.com - ASP 】

       '******************************
   '名称: 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

来源:https://www.tulaoshi.com/n/20160129/1509984.html

延伸阅读
一个实用的 CToolBar 扩展类 CToolBarEx 作者:xiaojin 下载源代码 我们知道,程序中的工具条是在CMainFrame中生成的,采用的类是CToolBar,使用起来很复杂。为此,对CToolBar的常用功能进行封装,生成了它的一个继承类CToolBarEx,大大简化了操作。本文参考了 VCKBASE 以前发表的关于工具条的文章,在此先表...
标签: Web开发
一个Javascript 的类库,用于table内容排序。使用很方便,不用每次都去调用数据库了。 特别适合多表查询的排序。加上的style.display 切换,也可以实现分页。 效果演示 用法: 1.添加JS QUOTE: 以下是引用片段: 2.添加TABLE,注意的是:一定要有ID,class为"sortable" QUOTE: OK,可以了,简...
标签: ASP
我们继续接上期 在页面里通过调用ShowPage()的方法显示出来,ShowPage可以在GetRS以后的任意位置调用,也可以调用多次 Public Sub ShowPage() Dim str_tmp int_totalRecord=XD_RS.RecordCount If int_totalRecord<=0 Then   str_error=str_error & "总记录数为零,请输入数据"   Call ShowError() End If If int_totalRec...
  Ehlib3.0版本以上虽然支持排序功能,但不支持带有Order By的SQL语句,而且排序很慢;我写的这个排序函数,利用ADO的sort方法,排序很快,几万条数据也是很快。该函数支持Lookup字段排序,不支持计算字段排序,因为计算字段值在内存里高速运算。排序分为:升序、降序和默认三种,支持排序图标。 procedure   SortDBG...
标签: Web开发
% '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% '快速字符串连接类 '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% '名称:Class_FastString '

经验教程

75

收藏

62
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部