/
unsubscriber.php
50 lines (43 loc) · 1.48 KB
/
unsubscriber.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
<?php
include 'db/opendb.php';
include 'db/utils.php';
include 'config.php';
/**
* php unsubscriber. Takes a uuid as a parameter in the url for unsubscription,
* or a maintenance parameter for executing logged failed updates to the database.
* (Connectivity issues, personal use-favor feature, the home mysql database of a
* friend does not run 24/7)
*/
$uid = htmlspecialchars($_GET["uuid"]);
$maintenance = htmlspecialchars($_GET["maintenance"]);
if ($maintenance == 1) {
updateLogged($unQuery, $log);
}
if ($dbError == false) {
sqlUnsubscribe($unQuery, $uid);
$res = sqliQuery($selQuery . "'" . $uid . "'");
while ($mailR = mysqli_fetch_object($res)) {
$mail = $mailR->$emailC;
}
}
$file = fopen($log, 'a') or die("cannot write log. UUID: " . $uid);
if ($maintenance != 1) {
if ($file != false && $dbError == true) {
//checking if uuid already logged.
if (checkUid($log, $uid) == false) {
fwrite($file, $uid . ":0\n");
}
echo $dataFail;
} else if ($mail == null && $uid != null) {
echo "Wrong UUID. Your email address is possibly not registered in this database.";
} else {
if (checkUid($log, $uid) == false) {
fwrite($file, $uid . ":1\n");
}
echo $mesIntro . $mail . $mesEnding;
sendMail('', $dbname, $mesIntro . $mail . $mesEnding,
$mailAddress, 'unsubscriber');
}
}
$mysqli->close();
?>