/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] deny acess to page unless

putfile used to have something like this, but its gone now so i cant look at their code ?

so could someone help me out with a code that denies acess to a page or send you to a different page unless that page is acessed via a certain page?

like…. you have to click the link on page a to get to page b, and if you type in the url for page b into the webbrowser it send you back to page a.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@cs3mwJun 05.2007 — are you using a server side script ie.e. php its easily done in that.

Regards
Copy linkTweet thisAlerts:
@Gerald_BocciJun 05.2007 — Using JavaScript isn't the best way, this can always be spoofed (or even just turned off). A better idea would be to use server-side code to check that the referring page came from the proper URL.

However, since this is the JavaScript forum, you can try this:

[CODE]
<script language="javascript">
if(document.referrer != "http://myUrl/myPage.html")
window.location.href=top.document.referrer;
</script>
[/CODE]


This will redirect the browser back to the referring page if it does not match your specified URL.

To test, create these three pages:

[B]a.html[/B] ("proper" page with a link to c.html)
[CODE]
<HTML>
<HEAD></HEAD>
<BODY>
<a href="c.html">c.html</a>
</BODY>
</HTML>
[/CODE]


[B]b.html[/B] ("improper" page with a link to c.html)
[CODE]
<HTML>
<HEAD></HEAD>
<BODY>
<a href="c.html">c.html</a>
</BODY>
</HTML>
[/CODE]


[B]c.html[/B]
[CODE]
<HTML>
<HEAD>
<script language="javascript">
if(document.referrer != "http://localhost/a.html")
window.location.href=top.document.referrer;
</script>
</HEAD>
<BODY onload="checkReferrer();">
Yay!
</BODY>
</HTML>
[/CODE]


(This assumes that the three pages are in the root folder of your web server, and that you're running this locally. Change the "localhost" to a proper URL to test the code on your site.)
Copy linkTweet thisAlerts:
@LowallynauthorJun 05.2007 — hmm it sending me back to the page i was on no matter what.... might be due to restrictions in zendurl though...

EDIT: nvm i got it to work.... its just that i have a subdomain so i was trying to visit c from http://www.zendurl.com/1/1erik1/a.html instead of http://1erik1.zendurl.com/a.html even though theyre the same page.

Thanks ?
Copy linkTweet thisAlerts:
@LowallynauthorJun 15.2007 — okay thanks one thing can you edit the above script to fit my needs?

site: http://1erik1.zendurl.com

I changed my mind on how I was going to use the script and decided to use it to hide the source code of a certain page (the YOUTUBE url link, third one down) by putting it in an iFrame. Only problem, is that you can getaround that easily by opening that link in a new tab in firefox.

any help?
Copy linkTweet thisAlerts:
@LowallynauthorJun 17.2007 — someone please help
Copy linkTweet thisAlerts:
@felgallJun 17.2007 — The referrer is a user enterable field and so can be set to whatever you want. You will actually need to use a session server side if you want to control which pages a given page can be accessed from. Any other approach will not work.
×

Success!

Help @Lowallyn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...