Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 24th, 2001, 01:45 PM
atarbaer atarbaer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 17 atarbaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Restrict access based on referring URL

What is the simplest way to restrict access to a page within a site based on the referring URL? I'd like the user to receive the following message if they try to access the page via the "back door": "To access this site, you must link to it from a pre-approved URL." Please give detailed instructions if possible, as I am just a beginner.

Thanks in advance!

Reply With Quote
  #2  
Old September 24th, 2001, 10:24 PM
pieux pieux is offline
Seņor Member
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2000
Posts: 1,156 pieux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 59 sec
Reputation Power: 9
It would be best to accomplish this using server-side code (such as PHP). The reason for this, is that 1) JavaScript can be disabled and 2) if the processing occurs on the server, the "protected" content is never displayed/sent to the browser.

The actual code would be pretty straightforward. In PHP, you would use the variable $HTTP_REFERER and compare it to pre-determined URLs. Basically, if $HTTP_REFERER = "xyz" then do abc, for example:
PHP Code:
<?
  
if  $HTTP_REFERER "http://www.devshed.com/" {
     print 
"Thanks for visiting from DevShed";
  }
?>
The tricky part is figuring out logic that encompasses all the possible permutations you wish to cover. Also, if you have many possibilities, it would be more efficient to use the switch() statement, over multiple if statements.
__________________
Michael

Reply With Quote
  #3  
Old September 25th, 2001, 12:57 PM
atarbaer atarbaer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 17 atarbaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the reply. I don't know anything about PHP.
Any suggestions for restricting access using Javascript? The site is actually set up for Javascript-enabled browsers only, so disabled Javascript shouldn't be a problem.

Reply With Quote
  #4  
Old September 25th, 2001, 01:15 PM
pieux pieux is offline
Seņor Member
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2000
Posts: 1,156 pieux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 59 sec
Reputation Power: 9
It would basically be the same thing, but instead of $HTTP_REFERER, you would use document.referer. Also, your page would need to be one really big JavaScript, such that the actual content is really output from the JavaScript (using document.write()).

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Restrict access based on referring URL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway