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

最近迷恋上作网站了,使用asp开发,发现asp有好多的漏洞,而且在一个网站中有好多的代码是重复使用的,所以就查询了一些资料发现在asp中可以使用类的思想,所以就写了这个类,写的不好,但是比较实用。

1<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
1   
2Const Btn_First="

<font face="webdings">9</font>

1" '定义第一页按钮显示样式   
2Const Btn_Prev="

<font face="webdings">3</font>

1" '定义前一页按钮显示样式   
2Const Btn_Next="

<font face="webdings">4</font>

1" '定义下一页按钮显示样式   
2Const Btn_Last="

<font face="webdings">:</font>

  1" '定义最后一页按钮显示样式 
  2
  3Class clsDSJ   
  4Private p_Error,p_IpAdd,p_Debug,Errs   
  5Private p_InvaildWords   
  6Private tmpStr   
  7Private objConnDivPage,rsDivPage,p_GetSQL,p_nPage   
  8Private p_rsPageSize,p_intCurPage,p_strURL,p_intTotalPage,p_intTotalRecords   
  9Private p_dbType,p_dbFolder,p_DataBase,dbPath,p_dbUserID,p_dbPassword,p_sqlDataSource   
 10Private param_DataBase,param_dbUserID,param_dbPassword,param_dbType   
 11'Property   
 12Public objConn,ConnStr,SQLQueryNum   
 13Public logDB,WebURL   
 14Public SaveLog   
 15Public ErrCodes,ErrCode,ErrMsg   
 16Public ScriptFolder,ScriptName   
 17  
 18Private Sub Class_Initialize   
 19p_Debug=True   
 20ClientConnected   
 21SaveLog=True   
 22ErrMsg=""   
 23p_Error=0   
 24SQLQueryNum=0   
 25Rem 数据库连接初始化   
 26dbType=12 '取1x——Access,2x——SQL;x1——OLEDB,x2——ODBC   
 27dbFolder="Data"   
 28DataBase="zhubizidatabase.MDB"   
 29dbUserID=""   
 30dbPassword=""   
 31sqlDataSource=""   
 32p_rsPageSize=10   
 33'p_nPage=2   
 34If request("page")="" Then   
 35p_intCurPage=1   
 36ElseIf NOT IsNumeric(request("page")) Then   
 37p_intCurPage=1   
 38ElseIf CInt(Trim(request("page")))<1 Then   
 39p_intCurPage=1   
 40Else   
 41p_intCurPage=CInt(Trim(request("page")))   
 42End If   
 43WebURL=" http://blog.csdn.net/alonesword/ "   
 44tmpStr=Request.ServerVariables("PATH_INFO")   
 45tmpStr=Split(tmpStr,"/",-1)   
 46ScriptName=Lcase(tmpStr(UBound(tmpStr)))   
 47ScriptFolder=LCase(tmpStr(UBound(tmpStr)-1)) & "/"   
 48p_InvaildWords=" select|update|delete|insert|@|--|;|'|#|%|xp|cmd|shell "   
 49End Sub   
 50  
 51Private Sub Class_terminate()   
 52If IsObject(rsDivPage) Then rsDivPage.Close:Set rsDivPage=Nothing   
 53If IsObject(objConn) Then objConn.Close:Set objConn=Nothing   
 54End Sub 
 55
 56Public Property Get Version   
 57Version="DSJ 1.1.0 Beta"   
 58End Property   
 59  
 60Public Property Get Error   
 61Error=p_Error   
 62End Property   
 63  
 64Public Property Get Debug   
 65Debug=p_Debug   
 66End Property   
 67Public Property Let Debug(BoolDebug)   
 68If BoolDebug Then   
 69p_Debug=True   
 70Else   
 71p_Debug=False   
 72End If   
 73End Property   
 74  
 75Public Property Get dbType   
 76dbType=p_dbType   
 77End Property   
 78Public Property Let dbType(lngdbType)   
 79If IsNumeric(lngdbType) Then   
 80p_dbType=lngdbType   
 81Else   
 82p_dbType=12   
 83End If   
 84End Property   
 85  
 86Public Property Get dbFolder   
 87dbFolder=p_dbFolder   
 88End Property   
 89Public Property Let dbFolder(strFolder)   
 90If Right(strFolder,1)="\" OR Right(strFolder,1)="/" Then   
 91p_dbFolder=strFolder   
 92Else   
 93If (NOT IsNull(strFolder)) OR (strFolder<>"") Then   
 94p_dbFolder=strFolder & "\"   
 95Else   
 96p_dbFoler=""   
 97End If   
 98End If   
 99End Property   
100  
101Public Property Get Database   
102Database=p_dataBase   
103End Property   
104Public Property Let Database(strDataBase)   
105p_dataBase=strDatabase   
106End Property   
107  
108Public Property Get dbUserID   
109dbUserID=p_dbUserID   
110End Property   
111Public Property Let dbUserID(strDataBaseUserID)   
112p_dbUserID=strDataBaseUserID   
113End Property   
114  
115Public Property Get dbPassword   
116dbPassword=p_dbPassword   
117End Property   
118Public Property Let dbPassword(strDataBasePassword)   
119p_dbPassword=strDataBasePassword   
120End Property   
121  
122Public Property Get SQLDataSource   
123SQLDataSource=p_sqlDataSource   
124End Property   
125Public Property Let SQLDataSource(strSQLDataSource)   
126If strsqlDataSource<>"" Then   
127If Left(p_dbType,1)=2 Then   
128p_sqlDataSource=strSQLDataSource   
129Else   
130AddErrorCode(110)   
131p_sqlDataSource=""   
132End If   
133End If   
134End Property   
135  
136Public Property Let PageSize(int_PageSize)   
137If IsNumeric(Int_Pagesize) Then   
138p_rsPageSize=CLng(int_PageSize)   
139End If   
140End Property   
141Public Property Get PageSize   
142If p_rsPageSize="" or NOT IsNumeric(p_rsPageSize) Then   
143PageSize=8   
144Else   
145PageSize=p_rsPageSize   
146End If   
147End Property 
148
149Public Property Get GetRs()   
150If NOT Debug Then On Error Resume Next   
151If NOT IsObject(objConn) Then ConnectionDataBase dbDataBase,dbUserID,dbPassword,dbType   
152If NOT IsObject(rsDivPage) Then   
153Set rsDivPage=Server.createobject("adodb.recordset")   
154rsDivPage.Open GetSQL,objConn,1,1   
155rsDivPage.PageSize=PageSize   
156If not(rsDivPage.eof and rsDivPage.BOF) Then   
157If p_intCurPage>rsDivPage.PageCount Then   
158p_intCurPage=rsDivPage.PageCount   
159End If   
160rsDivPage.AbsolutePage=p_intCurPage   
161End If   
162If Err Then   
163Err.Clear   
164rsDivPage.Close   
165Set rsDivPage=Nothing   
166If SaveLog Then   
167tmpMsg="连接数据库错误,请检查您的查询代码是否正确。

<br/>

  1基于安全的理由,只显示本信息,要查看详细的错误信息,请设置dsj.Debug=True"   
  2Response.Write SaveSQLLog(cmd,tmpMsg)   
  3Else   
  4Response.Write "连接数据库错误,请检查您的查询代码是否正确。"   
  5End If   
  6Response.End()   
  7End If   
  8SQLQueryNum=SQLQueryNum+1   
  9Set GetRs=rsDivPage   
 10End If   
 11End Property   
 12  
 13Public Property Let GetSQL(str_sql)   
 14If str_sql<>"" Then   
 15p_GetSQL=str_sql   
 16Else   
 17AddErrorCode(111)   
 18If Debug Then ShowErrMsg()   
 19p_GetSQL="The Property of GetSQL is NULL."   
 20End If   
 21End Property   
 22Public Property Get GetSQl()   
 23GetSQL=p_GetSQL   
 24End Property 
 25
 26  
 27'******************************   
 28'名称: gotTopic   
 29'参数:str,strlen   
 30'返回值:被限制后的字符串   
 31'创建时间:2005年3月3日   
 32'作用:限制被限制的字符串   
 33'******************************   
 34Public Function GotToPic(str,strlen)   
 35Rem 限制字符串显示长度在一定的范围内   
 36Dim i,StringLen,CharSize,EchoCharType   
 37StringLen=len(str)   
 38CharSize=0   
 39For i=1 to StringLen   
 40EchoCharType=Abs(Asc(Mid(str,i,1)))   
 41If EchoCharType>255 Then   
 42CharSize=CharSize+2   
 43Else   
 44CharSize=CharSize+1   
 45End If   
 46If CharSize>strlen Then   
 47gotTopic=Left(str,i) & "..."   
 48Exit For   
 49Else   
 50gotTopic=str & ""   
 51End If   
 52Next   
 53End Function   
 54  
 55'******************************   
 56'名称: ChkInvStr   
 57'参数:Str   
 58'返回值:True/False   
 59'创建时间:2005年5月2日   
 60'作用:检查参数是否有非法字符   
 61'******************************   
 62Public Function ChkInvStr(Str)   
 63Rem 定义需要过滤得非法字符   
 64Dim InvaildWord,inWords,i   
 65Str=CStr(Str)   
 66ChkInvStr=False   
 67If Len(Replace(p_InvaildWords,Chr(0),""))<1 Then   
 68AddErrorCode(103) 'invaildwords is null   
 69Exit Function   
 70Else   
 71If Instr(1,p_Invaildwords,"|")>0 Then   
 72InvaildWord=Split(p_InvaildWords,"|")   
 73inWords=LCase(Trim(Str))   
 74For i=LBound(InvaildWord) To UBound(InvaildWord)   
 75If Instr(inWords,InvaildWord(i))>0 Then   
 76p_Error=1982   
 77AddErrorCode(105)   
 78ChkInvStr=True   
 79Exit Function   
 80End If   
 81Next   
 82Else   
 83AddErrorCode(104) '"|" is requried.   
 84Exit Function   
 85End If   
 86End If   
 87End Function   
 88  
 89'******************************   
 90'名称: GetIP   
 91'参数:NULL   
 92'返回值:NULL   
 93'创建时间:2005年5月3日   
 94'作用:得到用户的ip地址   
 95'******************************   
 96Public Function GetIP()   
 97p_IpAdd=Request.ServerVariables("HTTP_X_FORWARDED_FOR")   
 98If IsNull(p_IpAdd) OR p_IpAdd="" Then   
 99p_IpAdd=Request.ServerVariables("REMOTE_ADDR")   
100End If   
101GetIp=p_IpAdd   
102End Function   
103  
104'******************************   
105'名称: IPAddress   
106'参数:sip   
107'返回值:County,City   
108'作用:对数据内容进行排版转换   
109'创建时间:2005年5月6日   
110'来源: www.knowsky.com   
111'******************************   
112Public Function IPAddress(sip)   
113Dim IPConnStr,IPConn,IPAddressDB   
114Dim str1,str2,str3,str4   
115Dim num   
116Dim country,city,address   
117Dim IPRs,SQL   
118address="未知"   
119If IsNumeric(Left(sip,2)) Then   
120If sip="127.0.0.1" Then sip="192.168.0.1"   
121str1=Left(sip,InStr(sip,".")-1)   
122sip=mid(sip,instr(sip,".")+1)   
123str2=Left(sip,instr(sip,".")-1)   
124sip=Mid(sip,InStr(sip,".")+1)   
125str3=Left(sip,instr(sip,".")-1)   
126str4=Mid(sip,instr(sip,".")+1)   
127If isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0 Then   
128Else   
129num=CLng(str1)*16777216+CLng(str2)*65536+CLng(str3)*256+CLng(str4)-1   
130IPAddressDB = "DSJ_Ipaddress.mdb"   
131IPConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(p_dbFolder & IPAddressDB)   
132Set IPConn = Server.CreateObject("ADODB.Connection")   
133IPConn.Open IpConnStr   
134country="亚洲"   
135city=""   
136sql="select top 1 country,city from DSJ_IPAddress where ip1 <="#&" and ip2 >="#&""   
137Set IPRs=IPConn.execute(sql)   
138If Not(IPRs.EOF And IPRs.bof) Then   
139country=IPRs(0)   
140city=IPRs(1)   
141End If   
142IpRs.Close:Set IPRs=Nothing   
143IPConn.CLose:Set IPConn = Nothing   
144SqlQueryNum = SqlQueryNum+1   
145End If   
146IPAddress=country&city   
147End If   
148End Function   
149  
150'******************************   
151'名称: ClientConnected   
152'参数:NULL   
153'返回值:NULL   
154'创建时间:2005年5月5日   
155'作用:得到用户是否与服务器连接   
156'******************************   
157Public Sub ClientConnected()   
158If Response.IsClientConnected then   
159Response.Flush()   
160Else   
161Response.End()   
162End If   
163End Sub   
164  
165'******************************   
166'名称: ChkPost   
167'参数:NULL   
168'返回值:True/False   
169'创建时间:2005年5月5日   
170'作用:检查被提交的数据来源   
171'******************************   
172Public Function ChkPost()   
173Dim Server_v1,Server_v2   
174ChkPost=False   
175Server_v1=CStr(Request.ServerVariables("HTTP_REFERER"))   
176Server_v2=CStr(Request.ServerVariables("SERVER_NAME"))   
177If Mid(Server_v1,8,Len(Server_v2))=Server_v2 Then ChkPost=True   
178End Function   
179  
180'******************************   
181'名称: AddErrorCode   
182'参数:ErrCode   
183'返回值:ErrCodes   
184'创建时间:2005年5月3日   
185'作用:添加错误代码到ErrCodes中   
186'******************************   
187Public Sub AddErrorCode(ErrCode)   
188If ErrCodes="" Then   
189ErrCodes=ErrCode   
190Else   
191ErrCodes=ErrCodes & "," & ErrCode   
192End If   
193End Sub   
194  
195'******************************   
196'名称: ShowErrMsg   
197'参数:NULL   
198'返回值:NULL   
199'创建时间:2005年5月3日   
200'作用:显示详细的错误信息   
201'******************************   
202Public Function ShowErrMsg()   
203If NOT p_Debug Then On Error Resume Next   
204If ErrCodes<>"" Then   
205iErrCodes=Split(ErrCodes,",",-1,Binary)   
206For i=LBound(iErrCodes) To UBound(iErrCodes)   
207tmpErrCode=CLng(iErrCodes(i))   
208If IsNumeric(tmpErrCode) Then   
209ErrMsg=ErrMsg & ErrDetails(tmpErrCode)   
210End If   
211Next   
212End If   
213ShowErrMsg=ErrMsg   
214End Function   
215  
216'******************************   
217'名称: ConnectionDataBase   
218'参数:DataBase,p_dbUserID,p_dbPassword,p_dbType   
219'返回值:NULL   
220'作用:连接到数据库   
221'创建时间:2005年5月6日   
222'******************************   
223Public Function ConnectionDataBase(param_DataBase,param_dbUserID,param_dbPassword,param_dbType)   
224If Not p_Debug Then On Error Resume Next   
225ClientConnected   
226If IsNumeric(param_dbType) Then   
227Set objConn=Server.CreateObject("ADODB.Connection")   
228objConn.ConnectionTimeOut=10 '设置连接超时为10秒   
229dbPath=Server.MapPath(p_dbFolder&param_DataBase)   
230'Response.Write dbPath   
231Select Case param_dbType   
232Case 11: 'Access Data Base(OLEDB)   
233ConnStr="Provider=Microsoft.Jet.Oledb.4.0;Data Source="&dbPath&";User ID="&param_dbUserID&";Password="&param_dbPassword&""   
234Case 21: 'SQL Server (OLEDB)   
235ConnStr="Provider=SQLOLEDB;Initial Catalog="&param_DataBase&";Data Source="&p_sqlDataSource&";User ID="&param_dbUserID&";Password="&param_dbPassword&""   
236Case 12: 'Access Data Base(ODBC)   
237ConnStr="Driver={Microsoft Access Driver (*.mdb)};DBQ="&dbPath&";User ID="&param_dbUserID&";Password="&param_dbPassword   
238Case 22: 'SQL Server (ODBC)   
239ConnStr="Driver={SQL Server};DataBase="&param_DataBase&";Server="&p_sqlDataSource&";User ID="&param_dbUserID&";Password="&param_dbPassword&""   
240Case Else:   
241AddErrorCode(100)   
242If p_Debug Then Response.Write ShowErrMsg()   
243'Exit Function   
244End Select   
245objConn.ConnectionString=ConnStr   
246objConn.Open   
247Set ConnectionDataBase=objConn   
248If Err Then   
249Err.Clear   
250  
251If SaveLog Then   
252tmpMsg="数据库连接时出现错误,请检查您的查询代码是否正确。

<br/>

 1基于安全的理由,只显示本信息,要查看详细的错误信息,请设置dsj.Debug=True"   
 2cmd="Execute the command of :"&param_dbtype   
 3Response.Write SaveSQLLog(cmd,tmpMsg)   
 4Else   
 5Response.Write "数据库连接时出现错误,请检查您的查询代码是否正确。"   
 6End If   
 7AddErrorCode(101)   
 8Set objConn=Nothing   
 9Response.End()   
10End If   
11End If   
12End Function   
13  
14'******************************   
15'名称: SaveSQLLog   
16'参数:sCommand,Msg   
17'返回值:msg   
18'作用:存储日志   
19'创建时间:2005年5月6日   
20'******************************   
21Public Function SaveSQLLog(sCommand,Msg)   
22If Not p_Debug Then On Error Resume Next   
23logDB="DSJ_SQLLog.mdb"   
24'ConnectionDataBase logDB,p_dbUserID,p_dbPassword,12   
25logConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(p_dbFolder & logDB)   
26Set logConn = Server.CreateObject("ADODB.Connection")   
27logConn.Open logConnStr   
28If SaveLog Then   
29Dim logCmd   
30logCmd="INSERT INTO DSJ_SQL_Log (Command,ScriptName,logUser,IP) VALUES "   
31logCmd=logCmd & "('" & Replace(Left(sCommand,255),"'","''") &"','" & (ScriptFolder & ScriptName) &"','" & Session("User") & "','"& GetIP & "')"   
32'Response.Write "Need to execute command is:

<br/>

<font color="red">" &amp; logCmd &amp; "</font>

<br/>

 1"   
 2logConn.Execute(logCmd)   
 3End If   
 4logConn.Close   
 5Set logConn=Nothing   
 6SaveSQLLog=msg   
 7SQLQueryNum=SQLQueryNum+1   
 8End Function   
 9  
10'******************************   
11'名称: ExecuteCmd   
12'参数:cmd   
13'返回值:RecordSet   
14'作用:返回由cmd创建的记录集   
15'创建时间:2005年5月6日   
16'******************************   
17Public Function ExecuteCmd(cmd)   
18If NOT IsObject(objConn) Then ConnectionDataBase p_DataBase,p_dbUserID,p_dbPassword,p_dbType   
19If NOT p_Debug Then On Error Resume Next   
20ClientConnected   
21Set ExecuteCmd=objConn.Execute(cmd)   
22If Err Then   
23Err.Clear   
24objConn.Close   
25Set objConn=Nothing   
26If SaveLog Then   
27tmpMsg="查询数据的时候发现错误,请检查您的查询代码是否正确。

<br/>

 1基于安全的理由,只显示本信息,要查看详细的错误信息,请设置dsj.Debug=True"   
 2Response.Write SaveSQLLog(cmd,tmpMsg)   
 3Else   
 4Response.Write "查询数据的时候发现错误,请检查您的查询代码是否正确。"   
 5End If   
 6Response.End()   
 7End If   
 8SQLQueryNum=SQLQueryNum+1   
 9End Function   
10  
11'******************************   
12'名称: HTMLEncode   
13'参数:fString   
14'返回值:HTMLEncode   
15'作用:对数据内容进行排版转换   
16'创建时间:2005年5月6日   
17'******************************   
18Public Function HTMLEncode(fString)   
19If Not IsNull(fString) Or fString<>"" Then   
20fString=Replace(fString,"<","<")   
21fString=Replace(fString,">",">")   
22fString=Replace(fString,Chr(9)," ") '倾斜字体   
23fString=Replace(fString,Chr(13),"")   
24fString=Replace(fString,Chr(32)," ") '转换空格   
25fString=Replace(fString,Chr(34),""") '转换双引号   
26fString=Replace(fString,Chr(39),"'") '转换单引号   
27fString=Replace(fString,Chr(10),"

<p>") '转换成段落格式
fString=Replace(fString,Chr(10),"<br/>    ") '转换为下一行
fString=Replace(fString,Chr(13),"<br/>")
fString=Replace(fSting,vbCrlf,"<br/>")
'fString=LinkFriend(fString)
'fString=ChkBadWords(fString)
HTMLEncode=fString
End If
End Function

'******************************
'名称: LinkFriend
'参数:fContent
'返回值:LinkFriend
'作用:进行友情连接替换
'创建时间:2005年5月6日
'******************************
Public Function LinkFriend(fContent)
If NOT p_Debug Then On Error Resume Next
If NOT IsObject(objConn) Then ConnectionDataBase DataBase,dbUserID,dbPassword,dbType
Set rsFriend=ExecuteCmd("Select Title,URL From dsj_FriendLink")
If rsFriend.Eof And rsFriend.Bof Then
Else
Do While NOT rsFriend.Eof
strTitle=rsFriend.Fields.Item("Title")
URl=rsFriend.Fields.Item("URL")
If LCase(Left(URL,1))&lt;&gt;"h" Then URL=Replace(URl,Left(URL,1),"")
strLink="<a href='" &amp; URL &amp; "' target="_blank" title='" &amp; strTitle &amp;"'>"
strLink=strLink&amp;strTitle&amp;"</a>"
If Instr(fContent,strTitle)&gt;0 Then fContent=Replace(fContent,strTitle,strLink)
rsFriend.MoveNext
Loop
LinkFriend=fContent
End If
rsFriend.Close
Set rsFriend=Nothing
SQLQueryNum=SQLQueryNum+1
End Function

'***************************************************************
'名称: ShowPage
'参数:NULL
'返回值:NULL
'作用:显示经过分页后的记录导航
'说明:
' 原作:zykj2000 网站: http://bbs.513soft.net
' 修改:孤剑 网站: http://blog.csdn.net/alonesword/
'时间:2005年5月7日
'******************************************************************
Public Sub ShowPage()
Dim str_tmp
p_intTotalRecords=rsDivPage.RecordCount
If p_intTotalRecords&lt;=0 Then
p_Error=p_Error &amp; "总记录数为零,请输入数据"
Call ShowError()
End If
If p_intTotalRecords &lt;=PageSize THen
p_intTotalPage=1
Else
If p_intTotalRecords mod PageSize =0 Then
p_intTotalPage = CLng(p_intTotalRecords / PageSize * -1)-1
Else
p_intTotalPage = CLng(p_intTotalRecords / PageSize * -1)
-1+1
End If
End If
If p_intCurPage&gt;p_intTotalPage Then
p_intCurPage=p_intTotalPage
End If
Response.Write ShowFirstPrv
showNumBtn
Response.Write ShowNextLast&amp;" "
Response.Write ShowPageInfo
response.write str_tmp
End Sub

Private Function ShowFirstPrv()
Dim Str_tmp,int_prvpage
int_prvpage=p_intCurPage-1
If int_prvpage&lt;1 Then int_prvpage=1
Btn_FirstLink="<a href='"&amp;AddnPageURL&amp;"1' title="第1页">"&amp;Btn_First
Btn_PrevLink="<a href='"&amp;AddnPageURL&amp;p_intCurPage-1&amp;"' title='第"&amp;int_prvpage&amp;"页'>"&amp;Btn_Prev
If p_intCurPage=1 Then
str_tmp=Btn_FirstLink&amp;"</a> "&amp;Btn_PrevLink&amp;"</a> "
Else
int_prvpage=p_intCurPage-1
str_tmp=""&amp;Btn_FirstLink&amp;" "&amp; Btn_PrevLink&amp;" "
End If
ShowFirstPrv=str_tmp
End Function

Private Function ShowNextLast()
Dim str_tmp,int_Nextpage
int_NextPage=p_intCurPage+1
If p_intCurPage+1&gt;p_intTotalPage Then int_NextPage=p_intTotalPage
Btn_NextLink="<a href='"&amp;AddnPageURL&amp;p_intCurPage+1&amp;"' title='第"&amp;int_NextPage&amp;"页'>"&amp;Btn_Next
Btn_LastLink="<a href='"&amp;AddnPageURL&amp;p_intTotalPage&amp;"' title='第"&amp;p_intTotalPage&amp;"页'>"&amp;Btn_Last
If p_intCurPage&gt;=p_intTotalPage Then
str_tmp=Btn_NextLink &amp; "</a> " &amp; Btn_LastLink&amp;"</a>"
Else
Int_NextPage=p_intCurPage+1
str_tmp=""&amp;Btn_NextLink&amp;" "&amp; Btn_LastLink&amp;""
End If
ShowNextLast=str_tmp
End Function

Private Function showNumBtn()
Dim i,str_tmp
Dim PageLink
str_tmp=""
For i=1 to p_intTotalPage Step 1
PageLink=" <a href='"&amp;AddnPageURL&amp;i&amp;"' title='第"&amp;i&amp;"页'>"&amp;i&amp;"</a> "
If i=p_intCurPage Then PageLink=" <a href='"&amp;AddnPageURL&amp;i&amp;"' title='第"&amp;i&amp;"页'><font color="red">"&amp;i&amp;"</font></a> "
Response.Write PageLink
Next
showNumBtn=str_tmp
End Function

Private Function ShowPageInfo()
Dim str_tmp
str_tmp="页次:"&amp;p_intCurPage&amp;"/"&amp;p_intTotalPage&amp;"页 共"&amp;p_intTotalRecords&amp;"条记录 "&amp;p_rsPageSize&amp;"条/每页"
ShowPageInfo=str_tmp
End Function

Private Function AddnPageURL()
Dim i,j,search_str,result_url
search_str="page="
str_params=Request.ServerVariables("QUERY_STRING")
If str_params="" Then
result_url=ScriptName &amp; "?page="
Else
If InstrRev(str_params,search_str)=0 Then
result_url=ScriptName &amp; "?" &amp; str_params &amp;"&amp;page="
Else
j=InstrRev(str_params,search_str)-2
If j=-1 Then
result_url=ScriptName &amp; "?page="
Else
str_params=Left(str_params,j)
result_url=ScriptName &amp; "?" &amp; str_params &amp;"&amp;page="
End If
End If
End If
AddnPageURL=result_url
End Function
'******************************************************************
Public Function GetName(Options)
Dim tmpName
tmpName=Request.ServerVariables("PATH_INFO")
arrTmpName=Split(tmpName,"/")
If Options=0 Then GetName=Server.Mappath(".")&amp;GetName(1)
If Options=1 Then GetName=LCase(arrTmpName(UBound(arrTmpName)))
If Options=2 Then GetName=LCase(arrTmpName(UBound(arrTmpName)-1))&amp;"/"
End Function

End Class

Published At
Categories with Web编程
Tagged with
comments powered by Disqus