2011-03-28 14:21:28 +00:00
|
|
|
<?
|
2013-05-02 08:00:23 +00:00
|
|
|
if (!check_perms('users_view_email')) {
|
|
|
|
error(403);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
authorize();
|
|
|
|
|
2014-03-23 08:00:50 +00:00
|
|
|
if ($_POST['submit'] === 'Delete') { // Delete
|
|
|
|
if (!is_number($_POST['id']) || $_POST['id'] === '') {
|
2013-05-02 08:00:23 +00:00
|
|
|
error(0);
|
|
|
|
}
|
2014-03-23 08:00:50 +00:00
|
|
|
$DB->query("
|
|
|
|
DELETE FROM email_blacklist
|
|
|
|
WHERE ID = $_POST[id]");
|
2013-05-16 08:00:10 +00:00
|
|
|
} else { // Edit & Create, Shared Validation
|
2014-03-23 08:00:50 +00:00
|
|
|
$Val->SetFields('email', '1', 'string', 'The email must be set', array('minlength'=>1));
|
|
|
|
$Val->SetFields('comment', '0', 'string', 'The description has a max length of 255 characters', array('maxlength'=>255));
|
|
|
|
$Err = $Val->ValidateForm($_POST);
|
2013-05-02 08:00:23 +00:00
|
|
|
if ($Err) {
|
|
|
|
error($Err);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-05-02 08:00:23 +00:00
|
|
|
$P = array();
|
|
|
|
$P = db_array($_POST); // Sanitize the form
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2014-03-23 08:00:50 +00:00
|
|
|
if ($_POST['submit'] === 'Edit') { // Edit
|
|
|
|
if (!is_number($_POST['id']) || $_POST['id'] === '') {
|
2013-05-02 08:00:23 +00:00
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
$DB->query("
|
|
|
|
UPDATE email_blacklist
|
|
|
|
SET
|
2014-03-23 08:00:50 +00:00
|
|
|
Email = '$P[email]',
|
|
|
|
Comment = '$P[comment]',
|
|
|
|
UserID = '$LoggedUser[ID]',
|
|
|
|
Time = '".sqltime()."'
|
|
|
|
WHERE ID = '$P[id]'");
|
2013-05-16 08:00:10 +00:00
|
|
|
} else { // Create
|
2013-05-02 08:00:23 +00:00
|
|
|
$DB->query("
|
|
|
|
INSERT INTO email_blacklist (Email, Comment, UserID, Time)
|
2014-03-23 08:00:50 +00:00
|
|
|
VALUES ('$P[email]', '$P[comment]', '$LoggedUser[ID]', '".sqltime()."')");
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go back
|
|
|
|
header('Location: tools.php?action=email_blacklist')
|
|
|
|
?>
|