Gazelle/sections/tools/managers/whitelist_alter.php

55 lines
1.4 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
2013-05-02 08:00:23 +00:00
if (!check_perms('admin_whitelist')) {
2011-03-28 14:21:28 +00:00
error(403);
}
2013-05-02 08:00:23 +00:00
if ($_POST['submit'] == 'Delete') {
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error('1');
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$DB->query("SELECT peer_id FROM xbt_client_whitelist WHERE id = ".$_POST['id']);
list($PeerID) = $DB->next_record();
$DB->query('DELETE FROM xbt_client_whitelist WHERE id='.$_POST['id']);
2012-10-11 08:00:15 +00:00
Tracker::update_tracker('remove_whitelist', array('peer_id' => $PeerID));
2011-03-28 14:21:28 +00:00
} else { //Edit & Create, Shared Validation
2013-02-22 08:00:24 +00:00
2013-05-02 08:00:23 +00:00
if (empty($_POST['client']) || empty($_POST['peer_id'])) {
2011-03-28 14:21:28 +00:00
print_r($_POST);
die();
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$Client = db_string($_POST['client']);
$PeerID = db_string($_POST['peer_id']);
2013-05-04 08:00:48 +00:00
if ($_POST['submit'] == 'Edit') { //Edit
2013-05-02 08:00:23 +00:00
if (empty($_POST['id']) || !is_number($_POST['id'])) {
error('3');
2011-03-28 14:21:28 +00:00
} else {
$DB->query("SELECT peer_id FROM xbt_client_whitelist WHERE id = ".$_POST['id']);
list($OldPeerID) = $DB->next_record();
2013-05-02 08:00:23 +00:00
$DB->query("
UPDATE xbt_client_whitelist
SET
vstring='".$Client."',
peer_id='".$PeerID."'
2011-03-28 14:21:28 +00:00
WHERE ID=".$_POST['id']);
2012-10-11 08:00:15 +00:00
Tracker::update_tracker('edit_whitelist', array('old_peer_id' => $OldPeerID, 'new_peer_id' => $PeerID));
2011-03-28 14:21:28 +00:00
}
} else { //Create
2013-05-02 08:00:23 +00:00
$DB->query("
INSERT INTO xbt_client_whitelist (vstring, peer_id)
VALUES
('$Client','$PeerID')");
2012-10-11 08:00:15 +00:00
Tracker::update_tracker('add_whitelist', array('peer_id' => $PeerID));
2011-03-28 14:21:28 +00:00
}
}
2013-06-27 08:01:06 +00:00
$Cache->delete_value('whitelisted_clients');
2011-03-28 14:21:28 +00:00
// Go back
header('Location: tools.php?action=whitelist')
?>