IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Classic ASP: Check Referrer
DEADmike
post May 18 2008, 16:33
Post #1


Advanced Member
***

Group: Members
Posts: 3,005
Joined: 11-September 07
Member No.: 2



QUOTE
There comes a time in every young ASP programmers life when he must write code for checking the referrer. Be it for security reasons or just preventing the dreaded BACK button double-execution! After writing too many if...then functions in my pages I wrapped it into a reusable function. Just pass a comma delimited string of page names that are allowed and it returns true or false. Simple and easy. This is a beginner function, if you use it and like it then vote and/or leave some comments. Thanks


CODE
Code
If CheckReferrer("page1,page3,index") = False Then
Response.Write "Denied Access!"
Response.End
End If
Function CheckReferrer(sPages)
'CShellVB http://www.cshellvb.com
Dim sRef, aRef
Dim lcv
CheckReferrer = False  
    aRef = Split(sPages, ",")
    sRef = Request.ServerVariables("HTTP_REFERER")
    
    For lcv = 0 To UBound(aRef) - 1
    
        If InStr(1, sRef, aRef(lcv)) = 0 Then
            CheckReferrer = True
            Exit Function
        End If
        
    Next
    
    
End Function
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 20th April 2024 - 11:05