forked from davidmelhart/PAGAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
end.php
76 lines (67 loc) · 2.31 KB
/
end.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
73
74
75
76
<?php
require_once "config.php";
// Initialize the session
session_start();
// Generate User if User does not exists
if(!isset($_COOKIE['user'])){
$id = getGUID();
setcookie('user', $id, time()+315400000,"/");
$_COOKIE['user'] = $id;
}
$current_page = explode(".", $_SERVER['REQUEST_URI'])[0];
// Generates GUID for username
function getGUID(){
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);
$uuid = substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
return $uuid;
}
$title = 'Platform for Affective Game ANnotation';
$css = ['forms.css'];
$message = $survey = $autofill_id = "";
$project_id = htmlspecialchars($_GET['id'], ENT_QUOTES, "UTF-8");
$participant_id = $_COOKIE['user'];
if($_SERVER["REQUEST_METHOD"] == "GET"){
$sql = "SELECT end_message, survey_link, autofill_id FROM projects WHERE project_id = :project_id LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(":project_id", $project_id, PDO::PARAM_STR);
$stmt->execute();
$project = $stmt->fetch(PDO::FETCH_ASSOC);
$message = $project['end_message'];
$survey = $project['survey_link'];
$autofill_id = $project['autofill_id'];
// Close statement
unset($stmt);
// Close connection
unset($pdo);
}
include("header.php");
echo '<div class="participant_id">ID: '.$_COOKIE['user'].'</div>';
?>
<div id="end-messages">
<div>
<p>Thank you for participating in this experiment!</p>
<?php
if (!empty($message)){
echo '<p>'.$message.'</p>';
}
if (!empty($survey)){
if (!empty($autofill_id)){
echo '<a class="button" href="'.$survey.'&entry.'.$autofill_id.'='.$participant_id.'">go to survey</a>';
} else {
echo '<a class="button" href="'.$survey.'">go to survey</a>';
}
}
?>
<div>
</div>
<?php
include("scripts.php");
$tooltip = '';
include("footer.php");
?>