2011-10-14 14:25:00
Protecting files that link to unreleased content
Here's the situation I'm hoping to solve. Let's say I have content items called "Unit 1 Test", "Unit 2 Test", etc. In these content pages, there is a link to a .pdf of the actual test (unit_1_test.pdf).
Now, if Unit 2 Test isn't open yet, the savvy student could simply go to the Unit 1 Test content page, click the link for the .pdf and replace "unit_1_test.pdf" with "unit_2_test.pdf" to get access to the test before it's meant to be available.
So, I thought about doing something like this in the get.php file...
[php]
$referer = $_SERVER['HTTP_REFERER'];
if ($referer == 'http://ATutor.mydomain.com/go.php/' . $_SESSION['course_id'] . '/content.php/cid/***')
{
do all the rest of the stuff in get.php....
[/php]
The goal is to say that if you didn't come from a content page, then we're not going to let you in.
Of course one problem is the *** which I don't know how to deal with. I'm trying to have the *** say "any content page", but I'm not sure how to do that.
So, thoughts on my plan overall or perhaps a better way to approach this problem?
Thanks!