forked from vern/website
Hopefully this is the final iteration of this
Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
parent
a57558e1be
commit
576a226064
|
@ -26,24 +26,21 @@
|
|||
return $str;
|
||||
}
|
||||
$err = $email = $code_err = '';
|
||||
if (!empty($_GET['email']) && !empty($_GET['action'])) {
|
||||
if (filter_var(sanitize($_GET['email']), FILTER_VALIDATE_EMAIL)) {
|
||||
if (preg_match("/^" . preg_quote($_GET['email']) . "$/", file_get_contents("/var/spool/list")) === 1) {
|
||||
if ($_GET['action'] == "sub")
|
||||
$email = sanitize($_GET['email']);
|
||||
else $err = "E-mail not in list";
|
||||
} else {
|
||||
if ($_GET['action'] == "unsub")
|
||||
if (empty($_GET['action']))
|
||||
if (!empty($_GET['email']))
|
||||
if (filter_var(sanitize($_GET['email']), FILTER_VALIDATE_EMAIL))
|
||||
if (preg_match("/^" . preg_quote($_GET['email']) . "$/", file_get_contents("/var/spool/list")) === 1)
|
||||
if ($_GET['action'] == "sub")
|
||||
$email = sanitize($_GET['email']);
|
||||
else $err = "E-mail not in list";
|
||||
else if ($_GET['action'] == "unsub")
|
||||
$email = sanitize($_GET['email']);
|
||||
else $err = "E-mail already in list";
|
||||
}
|
||||
} else {
|
||||
$err = "Invalid E-mail";
|
||||
}
|
||||
} else {
|
||||
$err = "E-mail is required";
|
||||
}
|
||||
else $err = "Invalid E-mail";
|
||||
else $err = "E-mail is required";
|
||||
|
||||
if (empty($_GET['action']) || ($_GET['action'] != "sub" && $_GET['action'] != "unsub") || !empty($err) && empty($_GET['code'])) {
|
||||
|
||||
?>
|
||||
<div class=h><h1 id=list>Mailing List</h1> <a aria-hidden=true href=#list>#list</a></div>
|
||||
<form method="get" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]) ?>">
|
||||
|
@ -53,7 +50,7 @@
|
|||
<select id="action" name="action">
|
||||
<option value="sub">Subscribe</option>
|
||||
<option value="unsub">Unsubscribe</option>
|
||||
</select>
|
||||
</select><br>
|
||||
|
||||
<br>
|
||||
<span><input type="submit" value="Submit" style="width:100px;height:40px;font-size:20px"></span>
|
||||
|
@ -74,6 +71,14 @@
|
|||
file_put_contents("/var/spool/list", $contents);
|
||||
}
|
||||
unlink($filename);
|
||||
|
||||
$subject = $_GET['action'] == "sub" ? "S" : "Uns" . "ubscription confirmed";
|
||||
$headers = "From: announcements@vern.cc\n";
|
||||
$headers .= "MIME-Version: 1.0\n";
|
||||
$headers .= "Content-type: text/plain\n";
|
||||
$message = "You have been " . $_GET['action'] == "sub" ? "added to" : "removed from" . " the ~vern announcement mailing list";
|
||||
|
||||
mail($email, $subject, $message, $headers);
|
||||
} else {
|
||||
$code_err = 'Incorrect code';
|
||||
}
|
||||
|
@ -84,14 +89,13 @@
|
|||
fwrite($handle, $code);
|
||||
fclose($handle);
|
||||
|
||||
$to = $email;
|
||||
$subject = "Your confirmation code";
|
||||
$headers = "From: announcements@vern.cc\n";
|
||||
$headers .= "MIME-Version: 1.0\n";
|
||||
$headers .= "Content-type: text/plain\n";
|
||||
$message = "Your confirmation code is $code. Do not share it with anyone.\n\nIf you did not initiate this, you can safely ignore this message.";
|
||||
|
||||
mail($to, $subject, $message, $headers);
|
||||
mail($email, $subject, $message, $headers);
|
||||
}
|
||||
?>
|
||||
<div class=h><h1 id=confirm>Confirm Action</h1> <a aria-hidden=true href=#confirm>#confirm</a></div>
|
||||
|
|
Loading…
Reference in New Issue