473,378 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

restrict page access to one referring page

I'm looking for a way to prevent access to a web page except from a
particular referring page.

What I am trying to do is prevent access to a download page for anyone
who has not successfully completed an online quiz.

Any ideas on how to this in php (using Drupal) would be most
appreciated.

Thanks.

Tom
Jun 30 '08 #1
9 2644
Message-ID:
<71**********************************@d45g2000hsc. googlegroups.comfrom
tomrue contained the following:
>What I am trying to do is prevent access to a download page for anyone
who has not successfully completed an online quiz.

Any ideas on how to this in php (using Drupal) would be most
appreciated.
Sessions or cookies.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Jun 30 '08 #2
Using Drupal 6.x, I believe either sessions or cookies would work, but
I am not sure.


On Jun 30, 3:46 pm, Geoff Berrow <blthe...@ckdog.co.ukwrote:
Message-ID:
<71c7012d-449e-4344-9a85-8ba035064...@d45g2000hsc.googlegroups.comfrom
tomrue contained the following:
What I am trying to do is prevent access to a download page for anyone
who has not successfully completed an online quiz.
Any ideas on how to this in php (using Drupal) would be most
appreciated.

Sessions or cookies.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011


Jun 30 '08 #3
Message-ID:
<b2**********************************@y38g2000hsy. googlegroups.comfrom
tomrue contained the following:
>Using Drupal 6.x, I believe either sessions or cookies would work, but
I am not sure.
So..ummm..try it?
--
Regards,

Geoff Berrow
Jun 30 '08 #4
That's a very helpful suggestion. The problem, for me, unfortunately,
is that I don't know how to do it. Hence my question.

Thanks.

Tom


On Jun 30, 6:33 pm, Geoff Berrow <blthe...@ckdog.co.ukwrote:
Message-ID:
<b2a9b6d4-c8f1-4174-b1f0-2ce886a90...@y38g2000hsy.googlegroups.comfrom
tomrue contained the following:
Using Drupal 6.x, I believe either sessions or cookies would work, but
I am not sure.

So..ummm..try it?
--
Regards,

Geoff Berrow
Jul 1 '08 #5
On Jun 30, 6:33*pm, Geoff Berrow <blthe...@ckdog.co.ukwrote:
Message-ID:
<b2a9b6d4-c8f1-4174-b1f0-2ce886a90...@y38g2000hsy.googlegroups.comfrom
tomrue contained the following:
Using Drupal 6.x, I believe either sessions or cookies would work, but
I am not sure.

So..ummm..try it?
--
Regards,

Geoff Berrow
You could definitely use a session variable to keep track of where
you're coming from. The other way of doing this is to use hidden html
fields with known values, one per page. Have a function which checks
what the value of the hidden field is and knocks you out of the page
if you didn't come from the correct previous page.

Jul 1 '08 #6
tomrue wrote:
On Jun 30, 6:33 pm, Geoff Berrow <blthe...@ckdog.co.ukwrote:
>Message-ID:
<b2a9b6d4-c8f1-4174-b1f0-2ce886a90...@y38g2000hsy.googlegroups.comfrom
tomrue contained the following:
>>Using Drupal 6.x, I believe either sessions or cookies would work, but
I am not sure.
So..ummm..try it?
--
Regards,

Geoff Berrow


That's a very helpful suggestion. The problem, for me, unfortunately,
is that I don't know how to do it. Hence my question.

Thanks.

Tom

(Top posting fixed)

Yes, a session variable is the way to go. A cookie would be second, IMHO.

Both ways can be implemented in Drupal. For more help on how to do it
in Drupal, check the Drupal user forums. I've found them to be very helpful

And please don't top post.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jul 1 '08 #7
tomrue wrote:
I'm looking for a way to prevent access to a web page except from a
particular referring page.

What I am trying to do is prevent access to a download page for anyone
who has not successfully completed an online quiz.

Any ideas on how to this in php (using Drupal) would be most
appreciated.

Thanks.

Tom
I am not familiar at all with Dupral or what it even is but here is the
basic for PHP.

1. On the Quiz page start a session

<?php
session_start();

(This had to be the first thing sent on the page before ANY output, even
a space or header)

2. On the Quiz page set your session variable

$_SESSION['authenticated'] = 'yes';

(Now where you set this variable is up to you. Set it at the top and you
will just know if the person has been to the page, if you want to make
sure they have done something particular on the page you will have to
add it to that process when they are done)

3. On the second page check for the session variable
<?php
session_start(); (before any output remember)
if($_SESSION['authenticated'] != 'yes') {
*** redirect code ***
}

This is super simplicated but will work is the basic of ways.

This will also work with cookies, but if the cookie you are comparing it
to is the same for anyone, it would be easy to spoof the cookie process
and get in anyhow.

Good luck.

Scotty
Jul 1 '08 #8
Message-ID:
<d1**********************************@i76g2000hsf. googlegroups.comfrom
tomrue contained the following:
>That's a very helpful suggestion. The problem, for me, unfortunately,
is that I don't know how to do it. Hence my question.
I wasn't being deliberately unhelpful. There are plenty of PHP tutorials
around which will show you how to use sessions or cookies. Se my own
examples for cookies below.

I suggested cookies because I thought it would be simpler for you to
decide when they expire.

For cookies
http://www.ckdog.co.uk/phpcourse/Lesson6/remember.php

Code
http://www.ckdog.co.uk/phpcourse/Lesson6/remember.phps
http://www.ckdog.co.uk/phpcourse/Lesson6/remember2.phps

--
Regards,

Geoff Berrow
Jul 1 '08 #9
On Jul 1, 8:11*am, Geoff Berrow <blthe...@ckdog.co.ukwrote:
Message-ID:
<d13ffd7f-9315-46ee-97dc-96067c246...@i76g2000hsf.googlegroups.comfrom
tomrue contained the following:
That's a very helpful suggestion. The problem, for me, unfortunately,
is that I don't know how to do it. Hence my question.

I wasn't being deliberately unhelpful. There are plenty of PHP tutorials
around which will show you how to use sessions or cookies. Se my own
examples for cookies below.

I suggested cookies because I thought it would be simpler for you to
decide when they expire.

For cookieshttp://www.ckdog.co.uk/phpcourse/Lesson6/remember.php

Codehttp://www.ckdog.co.uk/phpcourse/Lesson6/remember.phpshttp://www.ckdog..co.uk/phpcourse/Lesson6/remember2.phps

--
Regards,

Geoff Berrow
My suggestion as an alternative would be to have a regular expression
at the top of your download page that checks the page refferal. I'd
call the page .inc.php and include it when it should be displayed. The
regular expression would test for the .inc.php in the request for the
page and reject it if its found. That would mean someone is trying to
view it directly by opening the page (eg download.inc.php) rather than
from the point you want to view it.

It does mean that you would need another place from which to use an
include() on the download page. So on the submission of the last page
of the quiz, the php handler for the form (i'm assuming there is a
form involved in your quiz pages) would simply have
include("download.inc.php"); as the only action to perform.

Sorry if this isn't clear, a session/cookie variable to track the quiz
status is far simpler if your quiz isn't setup in a compatible way.

Regular expression (Not very PHP5 way of doing it I know you could use
a different server array)

if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) ||
eregi(".inc.php",$_SERVER['PHP_SELF'])) {
echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r
\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is
forbidden.\r\n</body>\r\n</html>";
exit;
}

This will only allow the file to be included and not directly viewed.
Clear as mud :-)

Regards,
John
Jul 2 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul | last post by:
Hi all, at present I I've built a website which can be updated by admin and users. My problem, I've combined "log in" and "access levels" to restrict access to certain pages, using the built...
1
by: sonik son | last post by:
Have a family website which requires username and password to access. I have the code to set a cookie ("user") upon successfull login. However, I cannot figure out how to allow access to the site...
28
by: gc | last post by:
Hi, What is the purpose of the restrict keyword? gc
7
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
21
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no...
7
by: Chris Fulstow | last post by:
Hi, I need to restirict access at the page level to a range of IP addresses. What's the best approach? I thought of building an HTTP module that could compare the requesting IP with a...
3
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi there, I've got the standard Dreamweaver restrict access to page behaviour below – <% ' *** Restrict Access To Page: Grant or deny access to this page MM_authorizedUsers="1,2,3"...
4
by: vinpkl | last post by:
hi i am working on admin section which has a login page with login id and pasword form. in my admin section i have many pages say like manage_products.php, description.php, user.php etc. if i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.