Gazelle/sections/tools/managers/email_blacklist_alter.php

46 lines
1.2 KiB
PHP
Raw Normal View History

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();
2013-05-16 08:00:10 +00:00
if ($_POST['submit'] == 'Delete') { // Delete
2013-05-02 08:00:23 +00:00
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0);
}
2011-03-28 14:21:28 +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
2011-03-28 14:21:28 +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));
2013-05-02 08:00:23 +00:00
$Err = $Val->ValidateForm($_POST); // Validate the form
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
2013-05-16 08:00:10 +00:00
if ($_POST['submit'] == 'Edit') { // Edit
2013-05-02 08:00:23 +00:00
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0);
}
$DB->query("
UPDATE email_blacklist
SET
Email='$P[email]',
Comment='$P[comment]',
UserID='$LoggedUser[ID]',
Time='".sqltime()."'
2011-03-28 14:21:28 +00:00
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)
2013-05-16 08:00:10 +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')
?>