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

2008-02-23 05:31:30来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

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

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
Const Btn_First="<font face='webdings'>9</font>" '定义第一页按钮显示样式
Const Btn_Prev="<font face='webdings'>3</font>" '定义前一页按钮显示样式
Const Btn_Next="<font face='webdings'>4</font>" '定义下一页按钮显示样式
Const Btn_Last="<font face='webdings'>:</font>" '定义最后一页按钮显示样式

Class clsDSJ
Private p_Error,p_IpAdd,p_Debug,Errs
Private p_InvaildWords
Private tmpStr
Private objConnDivPage,rsDivPage,p_GetSQL,p_nPage
Private p_rsPageSize,p_intCurPage,p_strURL,p_intTotalPage,p_intTotalRecords
Private p_dbType,p_dbFolder,p_DataBase,dbPath,p_dbUserID,p_dbPassword,p_sqlDataSource
Private param_DataBase,param_dbUserID,param_dbPassword,param_dbType
'Property
Public objConn,ConnStr,SQLQueryNum
Public logDB,WebURL
Public SaveLog
Public ErrCodes,ErrCode,ErrMsg
Public ScriptFolder,ScriptName

Private Sub Class_Initialize
p_Debug=True
ClientConnected
SaveLog=True
ErrMsg=""
p_Error=0
SQLQueryNum=0
Rem 数据库连接初始化
dbType=12 '取1x——Access,2x——SQL;x1——OLEDB,x2——ODBC
dbFolder="Data"
DataBase="zhubizidatabase.MDB"
dbUserID=""
dbPassword=""
sqlDataSource=""
p_rsPageSize=10
'p_nPage=2
If request("page")="" Then
p_intCurPage=1
ElseIf NOT IsNumeric(request("page")) Then
p_intCurPage=1
ElseIf CInt(Trim(request("page")))<1 Then
p_intCurPage=1
Else
p_intCurPage=CInt(Trim(request("page")))
End If
WebURL="http://blog.csdn.net/alonesword/"
tmpStr=Request.ServerVariables("PATH_INFO")
tmpStr=Split(tmpStr,"/",-1)
ScriptName=Lcase(tmpStr(UBound(tmpStr)))
ScriptFolder=LCase(tmpStr(UBound(tmpStr)-1)) & "/"
p_InvaildWords="select|update|delete|insert|@|--|;|'|#|%|xp|cmd|shell"
End Sub

Private Sub Class_terminate()
If IsObject(rsDivPage) Then rsDivPage.Close:Set rsDivPage=Nothing
If IsObject(objConn) Then objConn.Close:Set objConn=Nothing
End Sub

Public Property Get Version
Version="DSJ 1.1.0 Beta"
End Property

Public Property Get Error
Error=p_Error
End Property

Public Property Get Debug
Debug=p_Debug
End Property
Public Property Let Debug(BoolDebug)
If BoolDebug Then
p_Debug=True
Else
p_Debug=False
End If
End Property

Public Property Get dbType
dbType=p_dbType
End Property
Public Property Let dbType(lngdbType)
If IsNumeric(lngdbType) Then
p_dbType=lngdbType
Else
p_dbType=12
End If
End Property

Public Property Get dbFolder
dbFolder=p_dbFolder
End Property
Public Property Let dbFolder(strFolder)
If Right(strFolder,1)="\" OR Right(strFolder,1)="/" Then
p_dbFolder=strFolder
Else
If (NOT IsNull(strFolder)) OR (strFolder<>"") Then
p_dbFolder=strFolder & "\"
Else
p_dbFoler=""
End If
End If
End Property

Public Property Get Database
Database=p_dataBase
End Property
Public Property Let Database(strDataBase)
p_dataBase=strDatabase
End Property

Public Property Get dbUserID
dbUserID=p_dbUserID
End Property
Public Property Let dbUserID(strDataBaseUserID)
p_dbUserID=strDataBaseUserID
End Property

Public Property Get dbPassword
dbPassword=p_dbPassword
End Property
Public Property Let dbPassword(strDataBasePassword)
p_dbPassword=strDataBasePassword
End Property

Public Property Get SQLDataSource
SQLDataSource=p_sqlDataSource
End Property
Public Property Let SQLDataSource(strSQLDataSource)
If strsqlDataSource<>"" Then
If Left(p_dbType,1)=2 Then
p_sqlDataSource=strSQLDataSource
Else
AddErrorCode(110)
p_sqlDataSource=""
End If
End If
End Property

Public Property Let PageSize(int_PageSize)
If IsNumeric(Int_Pagesize) Then
p_rsPageSize=CLng(int_PageSize)
End If
End Property
Public Property Get PageSize
If p_rsPageSize="" or NOT IsNumeric(p_rsPageSize) Then
PageSize=8
Else
PageSize=p_rsPageSize
End If
End Property

Public Property Get GetRs()
If NOT Debug Then On Error Resume Next
If NOT IsObject(objConn) Then ConnectionDataBase dbDataBase,dbUserID,dbPassword,dbType
If NOT IsObject(rsDivPage) Then
Set rsDivPage=Server.createobject("adodb.recordset")
rsDivPage.Open GetSQL,objConn,1,1
rsDivPage.PageSize=PageSize
If not(rsDivPage.eof and rsDivPage.BOF) Then
If p_intCurPage>rsDivPage.PageCount Then
p_intCurPage=rsDivPage.PageCount

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Windows 2003上传文件不能超过200k解决方法

下一篇:ASP判断文件地址是否有效!