forked from jwnisbet/melodiesforus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redirector.php
executable file
·72 lines (58 loc) · 1.4 KB
/
redirector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
//This file ensures that participants view the right pages at the right times
$override = false;
if(array_key_exists('override', $_COOKIE)) {
$override = true;
}
if(array_key_exists('override', $_REQUEST)) {
setcookie("override", 'true', time()+3600); //1 hour
$override = true;
}
include('config.php');
if(!EXPERIMENT_OPEN && !$override) {
die('OLD. This experiment is now closed. Thank you for your participation.');
}
include_once('functions.php');
// Check for the user asking to reset the environment
if(isset($_POST['phase']) && $_POST['phase'] == 'resetEnv')
{
// Clear cookie and redirect to start
unset($_COOKIE['sid']);
setcookie('sid', null, -1, '/');
header('Location: /');
exit();
}
if(has_finished(-1)) {
redir("thankYouPage.php");
}
else {
if(!array_key_exists('sid', $_COOKIE)) {
redir("consent.php", true);
}
else {
$sid = intval($_COOKIE['sid']);
if(!has_consented($sid)) {
redir("consent.php", true);
}
else {
if(!has_done_presurvey($sid)) {
if("intro.php" != basename($_SERVER["SCRIPT_FILENAME"]))
redir("shopping.php");
}
else {
if(!has_seen_negative_option($sid)) { //pre survey done
redir('purchase.php', true);
//go to negative options page
}
else {
if(has_finished($sid)) {
redir("thankYouPage.php");
}
else {
redir('endSurvey.php');
}
}
}
}
}
}