Recommended: Asp class A tag engine class tagEngine.Class A asp class used to implement tag function, you can understand the specific functions if you can understand them. Modification record: 1, add extension function, 2006-12-3 % '*************************** 'Class name: tagEngine 'Name: Tag Engine' Date: 2006-11-29 'Author: Xilou Lengyue' Website: www.xilou.net | www.
The author is so meticulous that he encapsulates all these things into classes. It's a bit over. These things can be encapsulated as processes or functions. Sub and function are also encapsulated, and it doesn't have to be a class. Your file library is not necessarily all class, some sub and function are necessary.
The functions implemented include
1. showInfo(e_title,c_url,e_num,e_des,e_time,opera,ip,reurl): display error message
2. getIP(): Obtain the client IP
3. CheckPost(): Verify whether it is an off-site submission
4. getReferer(): the origin record
5. getCurURL(): Get the current page path
6, isRefresh(s1,s2,maxtimes): Anti-refresh
Complete code:
<%
'*********************************
'Name: eventProvider(event class)
'Date: 2006/11/24
'Author: Leng Yue, Xilou
'Website: www.CuoXIn.com
'Description: None
'Copyright: Please refer to the source for reprinting, author
'*********************************
'Last modified: 2006/11/24
'Number of modifications: 0
'Modification instructions: None
'Current version: v1.0.0
'*********************************
Class eventProvider
Private logDBName' log table name
'www.CuoXIn.com Design Home
'initialization
Private Sub Class_Initialize()
logDBName=LogInfo
End Sub
'
Private Sub Class_Terminate()
End Sub
'The title of the predefined event, or a type
Public Function eventTitles(typepenum)
Dim arrType(9)
arrType(0)=Unknown event
arrType(1)=Illegal user login
arrType(2)=URL passes illegal parameters
arrType(3)=Login and pass in illegal characters
arrType(4)=Login frequently, the number of logins exceeds the specified time
arrType(5)=Query incoming illegal characters
arrType(6)=Frequent query, the number of query times exceeds the specified time
arrType(7)=The page is refreshed frequently, and the number of refreshes exceeds the specified time
arrType(8)=Off-site submission data
arrType(9)=backend login
If Not IsNumeric(typepenum) Then eventTitles=Unknown Event:Exit Function
If CLng(Abs(typenum))>UBound(arrType) Then
eventTitles=Unknown event:Exit Function
End If
eventTitles=arrType(typepenum)
End Function
'The pre-order array display error
Public Sub showArrayInfo(infoitems,infovalues)
Dim str
str=<div style='border:2px solid #4E4E9C;font-family:arial ;color:#800040;width:50%;font-size:9pt'>
str=str&<ul style='margin:20px;'><b>Asp Event Information:</b>&vbcrlf
If IsArray(infoitems) And IsArray(infovalues) Then
For I=LBound(infoitems) To UBound(infoitems)
str=str&<li><b style='color:#4E4E9C'>&infoitems(I)&:</b>&infovalues(I)&vbcrlf
Next
Else
str=str&<li><b>&infoitems&</b>:&infovalues&vbcrlf
End If
str=str&</ul></div>&vbcrlf
Response.Write str
End Sub
'Show error
Public Sub showInfo(e_title,c_url,e_num,e_des,e_time,opera,ip,reurl)
Dim infoitems,infovalues
infoitems=Array(Event Title,Event Url,EventNumber,EventDescription,_
EventTime,Operator,IP,Referer Url_
)
infovalues=Array(e_title,c_url,e_num,e_des,e_time,opera,ip,reurl)
showArrayInfo infoitems,infovalues
End Sub
'Show information about the original file
Public Sub showOriInfo(oriclass,orifunction,oripage)
Dim infoitems,infovalues
infoitems=Array(Original class,Original function,Original page)
infovalues=Array(oriclass,orifunction,oripage)
showArrayInfo infoitems,infovalues
End Sub
'Get ip
Public Function getIP()
Dim IP
'If the client uses a proxy server, it should use the ServerVariables(HTTP_X_FORWARDED_FOR) method
IP = Request.ServerVariables(HTTP_X_FORWARDED_FOR)
If IP = or isnull(IP) or isempty(IP) Then
'If the client does not use a proxy, the Request.ServerVariables(REMOTE_ADDR) method should be used
IP = Request.ServerVariables(REMOTE_ADDR)
end if
getIP = IP
End Function
'Off-site submission verification
Public Function checkPost()
Dim server_v1,server_v2
checkPost=False
server_v1=Cstr(Request.ServerVariables(HTTP_REFERER))
server_v2=Cstr(Request.ServerVariables(SERVER_NAME))
If Mid(server_v1,8,len(server_v2))=server_v2 Then checkPost=True
End Function
'Get the way
Public Function getReferer()
getReferer=Request.ServerVariables(HTTP_REFERER)
End Function
'Get the current URL of the browser
Public Function getCurURL()
If Request.ServerVariables(HTTPS) = on Then
GetCurrentURL = https://
Else
GetCurrentURL = http://
End If
GetCurURL = GetCurURL & Request.ServerVariables(SERVER_NAME)
If (Request.ServerVariables(SERVER_PORT) <> 80) Then GetCurURL = GetCurURL & : & Request.ServerVariables(SERVER_PORT)
GetCurURL = GetCurURL & Request.ServerVariables(URL)
If (Request.QueryString <> ) Then GetCurURL = GetCurURL & ? & Request.QueryString
End Function
'Get the source or get the current URL of the browser, and combine the first two
Public Function getUrl(t)
If t=1 Then
getUrl=getCurURL()
Else
getUrl=getReferer()
End If
End Function
'Anti-refresh
's1: Access is allowed after more than s1 seconds
's2: If the current time and the last access time are different from s2 seconds, it will be considered to be refreshed frequently
'maxtimes: If the number of frequent refreshes is equal to or greater than maxtimes, record
'If refreshing frequently, isRefresh=true, otherwise it is false
Public Function isRefresh(s1,s2,maxtimes)
Dim CacheName
CacheName=eventProvider_2006
If IsDate(Session(CacheName&IsRefreshTime)) Then'Access is allowed after s1 seconds
If DateDiff(s,Session(CacheName&IsRefreshTime),Now())>s1 Then
Session(CacheName&IsRefreshTime)=Now()
Session(CacheName&IsRefresh)=False
End If
End If
If Session(CacheName&IsRefresh)=True Then
isRefresh=True
Else
isRefresh=False
End If
If IsDate(Session(CacheName&RefreshStart)) Then
If DateDiff(s,Session(CacheName&RefreshStart),Now())<s2 Then'//If the current time and the last access time are different from s2 seconds, it will be considered to be refreshed frequently
Session(CacheName&RefreshT)=Session(CacheName&RefreshT)+1'//Statistics the number of frequent refreshes
If Session(CacheName&RefreshT)>=maxtimes Then'//If the frequency refresh times are equal to or greater than maxtimes, record
Session(CacheName&IsRefresh)=True
Session(CacheName&IsRefreshTime)=Now()
End If
Else
Session(CacheName&RefreshT)=0'//If not, change the number of frequent records to 0
End If
End If
Session(CacheName&RefreshStart)=Now()'//Reserve the time for this visit until the next visit
End Function
'Write to database log
Public Sub writeToDB(e_title,c_url,e_num,e_des,e_time,opera,ip,reurl,conn)
Dim sql
sql=Insert INTO &logDBName&(eTitle,eUrl,eNum,eDes,eTime,Operator,IP,RefererUrl) VALUES(
sql=sql&'&e_title&','&c_url&','&e_num&','&e_des&','&e_time&','&opera&','&ip&','&reurl&')
conn.Execute(sql)
End Sub
End Class
%>
Share: Asp+Ajax achieves no refresh to add friends Due to work relationships, one of the functions is to increase the other party as a friend. As shown in the figure: The method used is ajax, and the appropriate code is less expensive: a href=javascript: void(0); onClick =add_username('%= rs(username) %'); Add as friend/a, the js verification used: script language = JavaScript src=ajax.