-
Notifications
You must be signed in to change notification settings - Fork 1
/
change.php
executable file
·203 lines (178 loc) · 8.48 KB
/
change.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
$display = "#confirm_view {display:none;}\n#delete_view {display:none;}";
$email = isset($_POST['email']) ? $_POST['email'] : '';
$bund = isset($_POST['bund']) ? $_POST['bund'] : '';
$bgld = isset($_POST['bgld']) ? $_POST['bgld'] : '';
$ktn = isset($_POST['ktn']) ? $_POST['ktn'] : '';
$noe = isset($_POST['noe']) ? $_POST['noe'] : '';
$ooe = isset($_POST['ooe']) ? $_POST['ooe'] : '';
$sbg = isset($_POST['sbg']) ? $_POST['sbg'] : '';
$stmk = isset($_POST['stmk']) ? $_POST['stmk'] : '';
$vlbg = isset($_POST['vlbg']) ? $_POST['vlbg'] : '';
$w = isset($_POST['w']) ? $_POST['w'] : '';
$tir = isset($_POST['tir']) ? $_POST['tir'] : '';
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
$s_get = isset($_GET['s']) ? $_GET['s'] : '';
$q_get = isset($_GET['q']) ? $_GET['q'] : '';
$mailqueue = true;
require_once('config.php');
require_once('db.php');
require_once('mail.php');
$db = new db($dbLang,$dbName);
if(isset($_GET['s']) && preg_match('/^-?\d+$/', $_GET['s']) == 1 && isset($_GET['q'])) {
$s = intval($_GET['s']);
$q = $_GET['q'];
} else {
$error = "Ungültige Abfrage, Error-Code: A!";
$display = "#confirm_view {display:none;}\n#change_view {display:none;}\n#delete_view {display:none;}";
goto end;
}
$q_array = explode("|", mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key . $s, base64_url_decode($q), MCRYPT_MODE_CBC));
if (count($q_array) <= 1 || preg_match('/^-?\d+$/', $q_array[0]) != 1) {
$error = "Ungültige Abfrage, Error-Code: B!";
goto end;
}
$sid = $q_array[0];
if($submit != "true"){
goto end;
}
if($_POST['delete'] == "true") {
$delete = "true";
}
$prefs = 1;
//if($bund == "bund") {$prefs += 1;}
if($bgld == "bgld") {$prefs += 2;}
if($ktn == "ktn") {$prefs += 4;}
if($noe == "noe") {$prefs += 8;}
if($ooe == "ooe") {$prefs += 16;}
if($sbg == "sbg") {$prefs += 32;}
if($stmk == "stmk") {$prefs += 64;}
if($vlbg == "vlbg") {$prefs += 128;}
if($w == "w") {$prefs += 256;}
if($tir == "tir") {$prefs += 512;}
$id = $db->query("SELECT id FROM users WHERE sid = '$sid' LIMIT 1;");
$email = $db->query("SELECT email FROM users WHERE sid = '$sid' LIMIT 1;");
$email = $email[0]['email'];
if (count($id[0]['id']) == '')
{
$error = "Ungültige Abfrage, Error-Code: C!";
goto end;
}
if ($delete == "true") {
$db->query("DELETE FROM users WHERE sid = $sid;");
$display = "#confirm_view {display:none;}\n#change_view {display:none;}";
mail_utf8($db,$email, "[Piraten-Newsletter] Newsletter abbestellt", "Ab sofort erhältst du keinen Newsletter mehr. Außerdem wurden deine Daten aus unserer Datenbank unwiderbringlich gelöscht.", from_header(1));
goto end;
}
$db->query("UPDATE users SET prefs = $prefs WHERE sid = $sid;");
mail_utf8($db,$email, "[Piraten-Newsletter] Einstellung geändert", "Deine Newslettereinstellungen wurden geändert. Mit einem Klick auf den folgenden Klick können die Einstellungen noch einmal geändert werden:\n".change_link($sid),from_header(1));
$prefs = $db->query("SELECT prefs FROM users WHERE sid = $sid;");
$prefs = $prefs[0]['prefs'];
$display = "#change_view {display:none;}\n#delete_view {display:none;}";
end:
if ($sid != null)
{
$prefs = $db->query("SELECT prefs FROM users WHERE sid = $sid;");
$prefs = $prefs[0]['prefs'];
}
$db->close();
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Piraten-Newsletter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Hier können sich Interessenten und Mitglieder für den Newsletter der Piratenpartei Österreichs anmelden.">
<meta name="author" content="Piratenpartei Österreichs">
<!-- Le styles -->
<link href="css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
background-color: #4c2582;
padding-top: 60px;
padding-bottom: 40px;
}
footer {
color: white;
}
<?php echo $display;?>
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<!-- Fav and touch icons
<link rel="shortcut icon" href="ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">-->
</head>
<body>
<div class="container">
<div class="row">
<div class="span8">
<div id="delete_view" class="well">
<h1>Abmeldung erfolgreich!</h1>
<p>Ab sofort wurde der Versand von Newslettern an dich gestoppt und deine Daten unwiderbringlich gelöscht!</p>
</div>
<div id="confirm_view" class="well">
<h1>Deine Einstellungen wurden erfolgreich geändert!</h1>
</div>
<?php
if($error != "") {
echo "<div class='alert alert-error'>".$error."</div>";
}
?>
<div id="change_view" class="well">
<h1>Newsletter-Einstellungen bearbeiten</h1>
<p>Hier kannst du deine Newsletter-Einstellungen bearbeiten:</p>
<?php echo "<form action=\"".change_link($sid)."\" method=\"post\">";?>
<div>
<h4>Für welche Teile des Newsletters willst du dich registieren?</h4>
<?php
echo ' <input type="hidden" name="bund" value="bund"/>';
echo ' <label class="checkbox"><input type="checkbox" name="" value="" checked="checked" disabled>Bundesweite Informationen</label>';
echo ' <label class="checkbox"><input type="checkbox" name="bgld" value="bgld" '.($prefs & 2 ? 'checked="checked"' : '').'>Burgenland</label>';
echo ' <label class="checkbox"><input type="checkbox" name="ktn" value="ktn" '.($prefs & 4 ? 'checked="checked"' : '').'>Kärnten</label>';
echo ' <label class="checkbox"><input type="checkbox" name="noe" value="noe" '.($prefs & 8 ? 'checked="checked"' : '').'>Niederösterreich</label>';
echo ' <label class="checkbox"><input type="checkbox" name="ooe" value="ooe" '.($prefs & 16 ? 'checked="checked"' : '').'>Oberösterreich</label>';
echo ' <label class="checkbox"><input type="checkbox" name="sbg" value="sbg" '.($prefs & 32 ? 'checked="checked"' : '').'>Salzburg</label>';
echo ' <label class="checkbox"><input type="checkbox" name="stmk" value="stmk" '.($prefs & 64 ? 'checked="checked"' : '').'>Steiermark</label>';
echo ' <label class="checkbox"><input type="checkbox" name="tir" value="tir" '.($prefs & 512 ? 'checked="checked"' : '').'>Tirol</label>';
echo ' <label class="checkbox"><input type="checkbox" name="vlbg" value="vlbg" '.($prefs & 128 ? 'checked="checked"' : '').'>Vorarlberg</label>';
echo ' <label class="checkbox"><input type="checkbox" name="w" value="w" '.($prefs & 256 ? 'checked="checked"' : '').'>Wien</label>';
?>
</div>
<input type="hidden" name="submit" value="true" />
<button type="submit" class="btn">Absenden</button>
</form>
<?php echo "<form action=\"".change_link($sid)."\" method=\"post\">";?>
<h4>Willst du den Newsletter abbestellen?</h4>
<input type="hidden" name="submit" value="true" />
<input type="hidden" name="delete" value="true" />
<button type="submit" class="btn btn-danger">Newsletter abbestellen</button>
</form>
</div>
</div><!--/span-->
</div><!--/row-->
<footer>
<p><a href="https://wiki.piratenpartei.at/wiki/Piratenwiki:Impressum">Impressum</a></p>
</footer>
</div><!--/.fluid-container-->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.js"></script>
<script src="js/bootstrap-transition.js"></script>
<script src="js/bootstrap-alert.js"></script>
<script src="js/bootstrap-modal.js"></script>
<script src="js/bootstrap-dropdown.js"></script>
<script src="js/bootstrap-scrollspy.js"></script>
<script src="js/bootstrap-tab.js"></script>
<script src="js/bootstrap-tooltip.js"></script>
<script src="js/bootstrap-popover.js"></script>
<script src="js/bootstrap-button.js"></script>
<script src="js/bootstrap-collapse.js"></script>
<script src="js/bootstrap-carousel.js"></script>
<script src="js/bootstrap-typeahead.js"></script>
</body>
</html>