forked from LimeSurvey/LimeSurvey
-
Notifications
You must be signed in to change notification settings - Fork 3
/
optout.php
92 lines (80 loc) · 2.8 KB
/
optout.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: optout.php 11664 2011-12-16 05:19:42Z tmswhite $
*/
// Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB
require_once(dirname(__FILE__).'/classes/core/startup.php'); // Since this file can be directly run
require_once(dirname(__FILE__).'/config-defaults.php');
require_once(dirname(__FILE__).'/common.php');
require_once($rootdir.'/classes/core/language.php');
$surveyid=returnglobal('sid');
$postlang=returnglobal('lang');
$token=returnglobal('token');
//Check that there is a SID
if (!isset($surveyid))
{
//You must have an SID to use this
include "index.php";
exit;
}
// Get passed language from form, so that we dont loose this!
if (!isset($postlang) || $postlang == "")
{
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$clang = new limesurvey_lang($baselang);
} else {
$clang = new limesurvey_lang($postlang);
$baselang = $postlang;
}
$thissurvey=getSurveyInfo($surveyid,$baselang);
$html='<div id="wrapper"><p id="optoutmessage">';
if ($thissurvey==false || !tableExists("tokens_{$surveyid}")){
$html .= $clang->gT('This survey does not seem to exist.');
}
else
{
$usquery = "SELECT emailstatus from ".db_table_name("tokens_{$surveyid}")." where token=".db_quoteall($token,true);
$usresult = $connect->GetOne($usquery);
if ($usresult==false)
{
$html .= $clang->gT('You are not a participant in this survey.');
}
elseif ($usresult=='OK')
{
$usquery = "Update ".db_table_name("tokens_{$surveyid}")." set emailstatus='OptOut', usesleft=0 where token=".db_quoteall($token,true);
$usresult = $connect->Execute($usquery);
$html .= $clang->gT('You have been successfully removed from this survey.');
}
else
{
$html .= $clang->gT('You have been already removed from this survey.');
}
}
$html .= '</p></div>';
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir'])
{
$thistpl=sGetTemplatePath($defaulttemplate);
}
else
{
$thistpl=sGetTemplatePath($thissurvey['templatedir']);
}
sendcacheheaders();
doHeader();
echo templatereplace(file_get_contents("$thistpl/startpage.pstpl"));
echo templatereplace(file_get_contents("$thistpl/survey.pstpl"));
echo $html;
echo templatereplace(file_get_contents("$thistpl/endpage.pstpl"));
doFooter();
// Closing PHP tag is intentially left out (yes, it's fine!)