2014-08-02 15:53:52 +04:00
|
|
|
|
<?php
|
2017-01-13 01:20:43 +03:00
|
|
|
|
/**
|
2018-06-23 21:50:13 +03:00
|
|
|
|
* TorrentPier – Bull-powered BitTorrent tracker engine
|
2017-01-13 01:20:43 +03:00
|
|
|
|
*
|
2023-12-12 22:14:01 +07:00
|
|
|
|
* @copyright Copyright (c) 2005-2024 TorrentPier (https://torrentpier.com)
|
2018-06-23 21:50:13 +03:00
|
|
|
|
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
|
|
|
|
|
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
2017-01-13 01:20:43 +03:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!empty($setmodules)) {
|
|
|
|
|
$module['USERS']['DISALLOW'] = basename(__FILE__);
|
|
|
|
|
return;
|
2014-08-02 15:53:52 +04:00
|
|
|
|
}
|
2023-06-10 15:55:53 +07:00
|
|
|
|
|
2017-02-05 22:28:55 +03:00
|
|
|
|
require __DIR__ . '/pagestart.php';
|
2014-08-02 15:53:52 +04:00
|
|
|
|
|
|
|
|
|
$message = '';
|
|
|
|
|
|
2017-01-13 01:20:43 +03:00
|
|
|
|
if (isset($_POST['add_name'])) {
|
2017-06-11 18:56:28 +03:00
|
|
|
|
$disallowed_user = isset($_POST['disallowed_user']) ? trim($_POST['disallowed_user']) : trim($_GET['disallowed_user']);
|
2014-08-02 15:53:52 +04:00
|
|
|
|
|
2017-01-13 01:20:43 +03:00
|
|
|
|
if ($disallowed_user == '') {
|
|
|
|
|
bb_die($lang['FIELDS_EMPTY']);
|
|
|
|
|
}
|
2023-03-20 17:08:34 +07:00
|
|
|
|
if (\TorrentPier\Validate::username($disallowed_user)) {
|
2017-01-13 01:20:43 +03:00
|
|
|
|
$message = $lang['DISALLOWED_ALREADY'];
|
|
|
|
|
} else {
|
2017-06-11 18:56:28 +03:00
|
|
|
|
$sql = 'INSERT INTO ' . BB_DISALLOW . " (disallow_username) VALUES('" . DB()->escape($disallowed_user) . "')";
|
2017-01-13 01:20:43 +03:00
|
|
|
|
$result = DB()->sql_query($sql);
|
|
|
|
|
if (!$result) {
|
|
|
|
|
bb_die('Could not add disallowed user');
|
|
|
|
|
}
|
|
|
|
|
$message = $lang['DISALLOW_SUCCESSFUL'];
|
|
|
|
|
}
|
2014-08-02 15:53:52 +04:00
|
|
|
|
|
2017-01-13 01:20:43 +03:00
|
|
|
|
$message .= '<br /><br />' . sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
|
2014-08-02 15:53:52 +04:00
|
|
|
|
|
2017-01-13 01:20:43 +03:00
|
|
|
|
bb_die($message);
|
|
|
|
|
} elseif (isset($_POST['delete_name'])) {
|
2017-06-11 18:56:28 +03:00
|
|
|
|
$disallowed_id = isset($_POST['disallowed_id']) ? (int)$_POST['disallowed_id'] : (int)$_GET['disallowed_id'];
|
2014-08-02 15:53:52 +04:00
|
|
|
|
|
2023-05-17 16:48:13 +07:00
|
|
|
|
if (!empty($disallowed_id)) {
|
|
|
|
|
$sql = 'DELETE FROM ' . BB_DISALLOW . " WHERE disallow_id = $disallowed_id";
|
|
|
|
|
$result = DB()->sql_query($sql);
|
|
|
|
|
if (!$result) {
|
|
|
|
|
bb_die('Could not removed disallowed user');
|
|
|
|
|
}
|
2017-01-13 01:20:43 +03:00
|
|
|
|
|
2023-05-17 16:48:13 +07:00
|
|
|
|
$message .= $lang['DISALLOWED_DELETED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
|
2017-01-13 01:20:43 +03:00
|
|
|
|
|
2023-05-17 16:48:13 +07:00
|
|
|
|
bb_die($message);
|
|
|
|
|
}
|
2014-08-02 15:53:52 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-11 16:09:27 +03:00
|
|
|
|
/**
|
|
|
|
|
* Grab the current list of disallowed usernames
|
|
|
|
|
*/
|
2017-06-11 18:56:28 +03:00
|
|
|
|
$sql = 'SELECT * FROM ' . BB_DISALLOW;
|
2014-08-02 15:53:52 +04:00
|
|
|
|
$result = DB()->sql_query($sql);
|
2017-01-13 01:20:43 +03:00
|
|
|
|
if (!$result) {
|
|
|
|
|
bb_die('Could not get disallowed users');
|
2014-08-02 15:53:52 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$disallowed = DB()->sql_fetchrowset($result);
|
|
|
|
|
|
2017-06-11 16:09:27 +03:00
|
|
|
|
/**
|
|
|
|
|
* Now generate the info for the template, which will be put out no matter what mode we are in
|
|
|
|
|
*/
|
2014-08-02 15:53:52 +04:00
|
|
|
|
$disallow_select = '<select name="disallowed_id">';
|
|
|
|
|
|
2017-01-13 01:20:43 +03:00
|
|
|
|
if (count($disallowed) <= 0) {
|
|
|
|
|
$disallow_select .= '<option value="">' . $lang['NO_DISALLOWED'] . '</option>';
|
|
|
|
|
} else {
|
2017-05-07 20:59:35 +03:00
|
|
|
|
for ($i = 0, $iMax = count($disallowed); $i < $iMax; $i++) {
|
2017-01-13 01:20:43 +03:00
|
|
|
|
$disallow_select .= '<option value="' . $disallowed[$i]['disallow_id'] . '">' . $disallowed[$i]['disallow_username'] . '</option>';
|
|
|
|
|
}
|
2014-08-02 15:53:52 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$disallow_select .= '</select>';
|
|
|
|
|
|
2023-09-04 16:42:15 +07:00
|
|
|
|
$template->assign_vars([
|
2017-01-13 01:20:43 +03:00
|
|
|
|
'S_DISALLOW_SELECT' => $disallow_select,
|
|
|
|
|
'S_FORM_ACTION' => 'admin_disallow.php',
|
2023-09-04 16:42:15 +07:00
|
|
|
|
]);
|
2014-08-02 15:53:52 +04:00
|
|
|
|
|
2017-01-13 01:20:43 +03:00
|
|
|
|
print_page('admin_disallow.tpl', 'admin');
|