-
Notifications
You must be signed in to change notification settings - Fork 4
/
unsubscribe.php
140 lines (119 loc) · 4.25 KB
/
unsubscribe.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
<?php
/*
Copyright 2020 FWBer.com
This file is part of FWBer.
FWBer is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FWBer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero Public License for more details.
You should have received a copy of the GNU Affero Public License
along with FWBer. If not, see <https://www.gnu.org/licenses/>.
*/
require_once("_init.php");
require_once("_secrets.php");
$db = mysqli_connect($dburl,$dbuser,$dbpass);
if(!$db)exit(mysqli_connect_error());
//make sure we've got an action.
if(!isset($_GET['email'])||empty($_GET['email']))exit('no email'); else $email= mysqli_escape_string($db,$_GET['email']);
if(!isset($_GET['verifyHash'])||empty($_GET['verifyHash']))exit('no verify'); else $verifyHash= mysqli_escape_string($db,$_GET['verifyHash']);
if(!isset($_GET['type'])||empty($_GET['type']))exit('no type'); else $type= mysqli_escape_string($db,$_GET['type']);
//types are:
//all - uncheck all email
//matches - just new match notices
//interested - matches requesting permissions
//approved - matches that approved my requests
$message = "";
if($type=="all")$message="all mail notifications.";
else if($type=="matches")$message="any new match notifications.";
else if($type=="interested")$message="any private profile request notifications.";
else if($type=="approved")$message="any notifications for approval of your private profile requests.";
else exit("unknown type");
$dbquerystring = sprintf("SELECT id, verifyHash, emailMatches, emailInterested, emailApproved FROM ".$dbname.".users WHERE email='%s'",$email);
$dbquery = mysqli_query($db,$dbquerystring);
$dbresults = mysqli_fetch_array($dbquery);
$success=false;
if($dbresults)
{
$emailMatches = $dbresults['emailMatches'];
$emailInterested = $dbresults['emailInterested'];
$emailApproved = $dbresults['emailApproved'];
if($type=="all")
{
$emailMatches=0;
$emailInterested=0;
$emailApproved=0;
}
if($type=="matches")$emailMatches=0;
if($type=="interested")$emailInterested=0;
if($type=="approved")$emailApproved=0;
if($verifyHash==$dbresults['verifyHash'])
{
$dbquerystring =
sprintf("UPDATE ".$dbname.".users SET emailMatches = '%s', emailInterested = '%s', emailApproved = '%s' WHERE email='%s'",
$emailMatches,
$emailInterested,
$emailApproved,
$email
);
if(!mysqli_query($db,$dbquerystring))exit("didn't work");
//done
mysqli_close($db);
$success=true;
}
}
?>
<!doctype html>
<html lang="en">
<head>
<title><?php require_once("_names.php"); echo getSiteName(); ?> - Unsubscribe<?php require_once("_names.php"); echo getTitleTagline(); ?></title>
<?php include("head.php");?>
</head>
<body class="d-flex flex-column h-100">
<?php include("h.php");?>
<div id="mainbody" align="center">
<br>
<br>
<table id="body_table">
<tr>
<td id="middle_column" align="center" valign="top">
<br>
<br>
<br>
<?php
if($success)
{
?>
<div style="color:#0096ff;font-size:14pt;text-shadow:#aad 1px 1px 1px;">
You have been unsubscribed from <?php echo $message; ?><br><br>
If you change your mind, you can always change it back in your <a href="/settings">Settings</a> page.
</div>
<?php
}
else
{
echo '<meta http-equiv="refresh" content="5;url='.getSiteURL().'/signin"/>';
?>
<div style="color:#000;font-size:14pt;text-shadow:#aaa 1px 1px 1px;">
<br>
<br>
<div style="color:#000;font-size:12pt;text-shadow:#aaa 1px 1px 1px;">
Something went wrong.<br>
Please set your preferences manually in your <a href="/settings">Settings</a> page.
<br>
</div>
</div>
<?php
}
?>
</td>
</tr>
</table>
<br>
</div>
<?php include("f.php");?>
</body>
</html>