473,837 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2663
Message-ID:
<71************ *************** *******@d45g200 0hsc.googlegrou ps.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 011000100110110 0010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011
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...@d4 5g2000hsc.googl egroups.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 011000100110110 0010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011


Jun 30 '08 #3
Message-ID:
<b2************ *************** *******@y38g200 0hsy.googlegrou ps.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...@y3 8g2000hsy.googl egroups.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...@y3 8g2000hsy.googl egroups.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...@y3 8g2000hsy.googl egroups.comfrom
tomrue contained the following:
>>Using Drupal 6.x, I believe either sessions or cookies would work, but
I am not sure.
So..ummm..tr y 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*******@attgl obal.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************ *************** *******@i76g200 0hsf.googlegrou ps.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...@i7 6g2000hsf.googl egroups.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.phpsht tp://www.ckdog..co.u k/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.ph p) 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("downlo ad.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.ph p",$HTTP_SERVER _VARS['PHP_SELF']) ||
eregi(".inc.php ",$_SERVER['PHP_SELF'])) {
echo "<html>\r\n<hea d>\r\n<title>Fo rbidden 403</title>\r\n</head>\r
\n<body><h3>For bidden 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
3142
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 in "log in" and "user authentication, restrict access to page" features. But I find the after login I constantly get redirected from the restricted pages.
1
4509
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 by checking to see if the "user" cookie has been previously set (i.e. they have logged in before and are authorized to enter the site.) Currently using session variables to restrict access to page, but if anyone can provide code to check for...
28
6432
by: gc | last post by:
Hi, What is the purpose of the restrict keyword? gc
7
2681
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 location(s) pointed to, so that only one declared pointer can store that address and access the data in those memory blocks, where I the data in those location(s) can be changed. Is that a correct understanding?
6
4909
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
21
6542
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 definition found in K&R 2nd.
7
5325
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 restricted range, specified in web.config. Any thoughts? Thanks, Chris
3
3605
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" MM_authFailedURL="index.asp" MM_grantAccess=false If Session("MM_Username") <"" Then If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
4
11588
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 have to access the manage_products.php page then i can access it just typing like the link below http://localhost/vineet/admin/manage_products.php without entering login user and pasword.
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10280
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7012
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5862
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4481
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.