This repository has been archived on 2024-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
mybb-digest/unsubscribe.php

25 lines
676 B
PHP

<?php
require_once "config.php";
$pdo = new PDO(DSN, MYSQL_USER, MYSQL_PASSWORD);
$key = $pdo->prepare("SELECT loginkey FROM ".MYBB_PREFIX."users WHERE email = :email");
$loginkey = $_GET['key'];
$email = $_GET['email'];
if (empty($loginkey) || empty($email)) {
echo "Not enough parameters.";
var_dump($_GET);
return;
}
$key->execute([
'email' => $email
]);
$key = $key->fetch()['loginkey'];
if ($key === $loginkey) {
$key = $pdo->prepare('UPDATE '.MYBB_PREFIX."users SET isSubscribed = 0 WHERE email = :email");
$key->execute([
'email' => $email
]);
echo "You were unsubscribed. Close this window.";
} else {
echo "Key is incorrect. No action made.";
}