View Full Version : URL check
I really need a code that would check from which URL surfer came and, if URL isn't right, throw him away.
In other words, I don't want surfers to type URL in adress bar to get to members section.
Thanx a lot for help.
Thundor
08-27-2002, 02:10 PM
Try checking the document.referrer variable. If its null, then the user typed in the address, else it will equal the address the user came from.
Thundor.
beetle
08-27-2002, 04:52 PM
That is ALMOST correct, Thundor :D
the document.referrer property is always of type string, and if there is not referring document, then it is an empty string. However, if you perform a conditional test on the document.referrer property, the browser will return a boolean value based on the contents of the string, and not it's acutal existance (i.e. normally this type of test would always return true). This makes it easy for us!if (!document.referrer) top.location.href="error.htm"; Or something like that :D However, this can easily be circumvented by someone making their own page and linking to yours. So, we are better off by validating what is in the referrer stringif (document.referrer != "http://www.yourdomain.com/page.htm") top.location.href="error.htm";
beetle
08-27-2002, 05:00 PM
Oh, and I'd like to add this note: Although this will deter many users from your 'members' section, you are basically denying users access with javascript, which can be turned off on the client's machine. So, if I visited your page and wanted to see the members stuff, I could just turn off javascript and keep on truckin.
Two solutions to avoid this possibility:
1) write all the members stuff to the page with javascript, because then it won't be visible either (not very practical, at all, but possible)
2) Use something server-side to validate users.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.