This is a discussion on "Restrict Access" within the JavaScript Forum section. This forum, and the thread "Restrict Access are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Restrict Access
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Restrict Access
I'm assuming that if this can be resolved it will be by Javascript.
What I need to do is really quite bizarre; I want to restrict access to a website but NOT by using a login process. I'd like to use Javascript's facility to see the referrer and only allow access to the site from people coming from URL's that are pre-defined. Can anyone crack this one or point me in the right direction? Kind regards Mike |
|
|
|
#2
|
||||
|
||||
|
Re: Restrict Access
can you elaborate on predefined URLs
are you talking about a password in the url something like http://www.blabla.com/user?password=pass hard to tell what you mean
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#3
|
|||
|
|||
|
Re: Restrict Access
Hello Alex
I wasn't thinking of using a password in the URL, just the fact that the user has arrived from a specific site / URL. I will not have access to some of the sites / URL's that are allowed access so having a specific link created with an integral password would cause complications. Incidentally, the actual referring page should be discarded for the purpose of this exercise so a referring URL of abc.com/link.html should be seen as just abc.com The javascript in the web page has been told that abc.com, def.com and ghi.com are all OK so it looks at the referer and allows those to proceed but if the referrer is from abc.co.uk (for example) or there is no referrer then entry is refused and the enquiry redirected elsewhere. I hope this clarifies my query? |
|
#4
|
||||
|
||||
|
Re: Restrict Access
ah yeah.
i know what your on about and i'm sure it's possible (not very secure though). i'll have a look about, but hopefully someone else will find this for you first
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#5
|
|||
|
|||
|
Re: Restrict Access
Hi Alex
What makes you say it "not very secure"? Kind regards Mike |
|
#6
|
||||
|
||||
|
Re: Restrict Access
for starters javascript can be turned off.
and there are work around to make it seem as though you came from somewhere but really didn't
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#7
|
|||
|
|||
|
Re: Restrict Access
Hi Alex
If the user has Javascript turned off then they won't be able to access the site; they're problem, not mine. Reality is that the type of person who would want to access this site is atypical middle class who wouldn't know how to forge their location even if they had the inclination. Kind regards Mike |
|
#8
|
||||
|
||||
|
Re: Restrict Access
if they turn off JS, then the code preventing them from accessing the site will be disabled therefore they can access the site
have you considered server side scripting like PHP?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#9
|
|||
|
|||
|
Re: Restrict Access
I would still opt for a server-side solutions instead. JS is just not dependable enough for that. What is users are browsing your site with a text-browser like Lynx?
|
|
#10
|
|||
|
|||
|
Re: Restrict Access
Hi Karinne
I'm open to any and all suggestions. How do I do it? In the meanwhile I have found this script:
Can anyone tell me how to make it forward to xyz.com/page.html? Thanks and regards Mike Last edited by karinne; Sep 7th, 2007 at 11:57. Reason: Please use [ code ]...[ /code ] tags when displaying code. |
|
#11
|
||||
|
||||
|
Re: Restrict Access
Quote:
Assumption: Your server supports >= PHP 4.1
Quote:
Cheers, Luke.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#12
|
|||
|
|||
|
Re: Restrict Access
Quote:
|
|
#13
|
|||
|
|||
|
Re: Restrict Access
It would seem that neither method is foolproof but is one better than the other or is there an alternative solution?
|
|
#14
|
||||
|
||||
|
Re: Restrict Access
PHP is much better than javascript in this case.
with the JS case, all the user does is disbale javascript (all browsers have this option) with php they have to modify header information using special programs which may take a few hours to work out. I think
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#15
|
|||
|
|||
|
Re: Restrict Access
In his previous post Rakuli quotes:
"Originally Posted by PHP.net 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted." This would seem to indicate that Javascript is the best option because at least the user controls whether JS is on or not and it's easy for me to place a note on the landing page that JS needs to be enabled. However, I've been trawling through my website logs (over 30 sites) and I cannot find one that indicates JS is off. I thinks as techies we can get tied up in detail when the man in the street doesn't even know how to setup a new email account in Outlook Express or the existence of Windows Update. Regards to all Mike PS. Many thanks to Rakuli for posting the php code. Last edited by Mike Henson; Sep 8th, 2007 at 10:50. |
|
#16
|
||||
|
||||
|
Re: Restrict Access
I really don't think he should switch to php.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#17
|
|||
|
|||
|
Re: Restrict Access
Personally I'd trust php over javascript any day... there are various reasons, one of which (of course) is that the code isn't exposed to the world in the way it is with Javascript... I'd think exposing your code to the world makes it *far* more likely that somebody would succeed in hacking their way in... after all, they can see which URLs they're required to come from just by viewing the source... not with php they can't... if they don't know which URLs are accepted, how are they going to know what to put in their hack?
Sean |
|
#18
|
|||
|
|||
|
Re: Restrict Access
I think that came out wrong... unless you've had a serious change of mind ;-)
Sean |