be more CRUD
This commit is contained in:
parent
d8c4331c66
commit
0de2f23ece
@ -49,30 +49,30 @@ class IPBan extends Extension
|
||||
if ($event->page_matches("ip_ban")) {
|
||||
global $page, $user;
|
||||
if ($user->can(Permissions::BAN_IP)) {
|
||||
if ($event->get_arg(0) == "add" && $user->check_auth_token()) {
|
||||
if (isset($_POST['ip']) && isset($_POST['reason']) && isset($_POST['end'])) {
|
||||
if (empty($_POST['end'])) {
|
||||
if ($event->get_arg(0) == "create" && $user->check_auth_token()) {
|
||||
if (isset($_POST['c_ip']) && isset($_POST['c_reason']) && isset($_POST['c_expires'])) {
|
||||
if (empty($_POST['c_expires'])) {
|
||||
$end = null;
|
||||
} else {
|
||||
$end = date("Y-m-d H:i:s", strtotime(trim($_POST['end'])));
|
||||
$end = date("Y-m-d H:i:s", strtotime(trim($_POST['c_expires'])));
|
||||
}
|
||||
send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'], $end));
|
||||
send_event(new AddIPBanEvent($_POST['c_ip'], $_POST['c_reason'], $end));
|
||||
|
||||
flash_message("Ban for {$_POST['ip']} added");
|
||||
flash_message("Ban for {$_POST['c_ip']} added");
|
||||
$page->set_mode(PageMode::REDIRECT);
|
||||
$page->set_redirect(make_link("ip_ban/list/1"));
|
||||
$page->set_redirect(make_link("ip_ban/list"));
|
||||
}
|
||||
} elseif ($event->get_arg(0) == "remove" && $user->check_auth_token()) {
|
||||
if (isset($_POST['id'])) {
|
||||
send_event(new RemoveIPBanEvent($_POST['id']));
|
||||
} elseif ($event->get_arg(0) == "delete" && $user->check_auth_token()) {
|
||||
if (isset($_POST['d_id'])) {
|
||||
send_event(new RemoveIPBanEvent($_POST['d_id']));
|
||||
|
||||
flash_message("Ban removed");
|
||||
$page->set_mode(PageMode::REDIRECT);
|
||||
$page->set_redirect(make_link("ip_ban/list/1"));
|
||||
$page->set_redirect(make_link("ip_ban/list"));
|
||||
}
|
||||
} elseif ($event->get_arg(0) == "list") {
|
||||
$pageNum = $event->try_page_num(1);
|
||||
$bans = (isset($_GET["all"])) ? $this->get_bans(true, $pageNum) : $this->get_bans(false, $pageNum);
|
||||
$pageNum = isset($_GET["r__page"]) ? int_escape($_GET["r__page"]) : 1;
|
||||
$bans = $this->get_bans(isset($_GET["r_all"]), $pageNum);
|
||||
$this->theme->display_bans($page, $bans);
|
||||
}
|
||||
} else {
|
||||
@ -93,7 +93,7 @@ class IPBan extends Extension
|
||||
global $user;
|
||||
if ($event->parent==="system") {
|
||||
if ($user->can(Permissions::BAN_IP)) {
|
||||
$event->add_nav_link("ip_bans", new Link('ip_ban/list/1'), "IP Bans", NavLink::is_active(["ip_ban"]));
|
||||
$event->add_nav_link("ip_bans", new Link('ip_ban/list'), "IP Bans", NavLink::is_active(["ip_ban"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ class IPBan extends Extension
|
||||
{
|
||||
global $user;
|
||||
if ($user->can(Permissions::BAN_IP)) {
|
||||
$event->add_link("IP Bans", make_link("ip_ban/list/1"));
|
||||
$event->add_link("IP Bans", make_link("ip_ban/list"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ class IPBanTheme extends Themelet
|
||||
* $bans = an array of (
|
||||
* 'ip' => the banned IP
|
||||
* 'reason' => why the IP was banned
|
||||
* 'date' => when the ban started
|
||||
* 'end' => when the ban will end
|
||||
* 'added' => when the ban started
|
||||
* 'expires' => when the ban will end
|
||||
* )
|
||||
*/
|
||||
public function display_bans(Page $page, $bans)
|
||||
@ -22,13 +22,13 @@ class IPBanTheme extends Themelet
|
||||
<tr>
|
||||
<td width='12%'>{$ban[$prefix.'ip']}</td>
|
||||
<td>{$ban[$prefix.'reason']}</td>
|
||||
<td width='10%'>{$ban['banner_name']}</td>
|
||||
<td width='10%'>{$ban['banner']}</td>
|
||||
<td width='10%'>".substr($ban[$prefix.'added'], 0, 10)."</td>
|
||||
<td width='10%'>".substr($ban[$prefix.'expires'], 0, 10)."</td>
|
||||
<td width='10%'>{$ban['mode']}</td>
|
||||
".make_form(make_link("ip_ban/remove"))."
|
||||
".make_form(make_link("ip_ban/delete"))."
|
||||
<td width='8%'>
|
||||
<input type='hidden' name='id' value='{$ban[$prefix.'id']}'>
|
||||
<input type='hidden' name='d_id' value='{$ban[$prefix.'id']}'>
|
||||
<input type='submit' value='Remove'>
|
||||
</td>
|
||||
</form>
|
||||
@ -37,19 +37,19 @@ class IPBanTheme extends Themelet
|
||||
}
|
||||
$today = date('Y-m-d');
|
||||
$html = "
|
||||
<a href='".make_link("ip_ban/list", "limit=1000000")."'>Show All Active</a> /
|
||||
<a href='".make_link("ip_ban/list", "all=on&limit=1000000")."'>Show EVERYTHING</a>
|
||||
<a href='".make_link("ip_ban/list", "r__size=1000000")."'>Show All Active</a> /
|
||||
<a href='".make_link("ip_ban/list", "r_all=on&r__size=1000000")."'>Show EVERYTHING</a>
|
||||
<p><table id='bans' class='sortable zebra'>
|
||||
<thead>
|
||||
<tr><th>IP</th><th>Reason</th><th>By</th><th>From</th><th>Until</th><th>Type</th><th>Action</th></tr>
|
||||
<tr>
|
||||
".make_form(make_link("ip_ban/list/1"), "GET")."
|
||||
<td><input type='text' name='s_ip' value='".html_escape(@$_GET['s_ip'])."'></td>
|
||||
<td><input type='text' name='s_reason' value='".html_escape(@$_GET['s_reason'])."'></td>
|
||||
<td><input type='text' name='s_banner' value='".html_escape(@$_GET['s_banner'])."'></td>
|
||||
<td><input type='text' name='s_added' value='".html_escape(@$_GET['s_added'])."'></td>
|
||||
<td><input type='text' name='s_expires' value='".html_escape(@$_GET['s_expires'])."'></td>
|
||||
<td><input type='text' name='s_mode' value='".html_escape(@$_GET['s_mode'])."'></td>
|
||||
".make_form(make_link("ip_ban/list"), "GET")."
|
||||
<td><input type='text' name='r_ip' value='".html_escape(@$_GET['r_ip'])."'></td>
|
||||
<td><input type='text' name='r_reason' value='".html_escape(@$_GET['r_reason'])."'></td>
|
||||
<td><input type='text' name='r_banner' value='".html_escape(@$_GET['r_banner'])."'></td>
|
||||
<td><input type='text' name='r_added' value='".html_escape(@$_GET['r_added'])."'></td>
|
||||
<td><input type='text' name='r_expires' value='".html_escape(@$_GET['r_expires'])."'></td>
|
||||
<td><input type='text' name='r_mode' value='".html_escape(@$_GET['r_mode'])."'></td>
|
||||
<td><input type='submit' value='Search'></td>
|
||||
</form>
|
||||
</tr>
|
||||
@ -57,12 +57,12 @@ class IPBanTheme extends Themelet
|
||||
$h_bans
|
||||
<tfoot>
|
||||
<tr id='add'>
|
||||
".make_form(make_link("ip_ban/add"))."
|
||||
<td><input type='text' name='ip' value='".html_escape(@$_GET['ip'])."'></td>
|
||||
<td><input type='text' name='reason' value='".html_escape(@$_GET['reason'])."'></td>
|
||||
".make_form(make_link("ip_ban/create"))."
|
||||
<td><input type='text' name='c_ip' value='".html_escape(@$_GET['c_ip'])."'></td>
|
||||
<td><input type='text' name='c_reason' value='".html_escape(@$_GET['c_reason'])."'></td>
|
||||
<td>{$user->name}</td>
|
||||
<td>{$today}</td>
|
||||
<td><input type='text' name='end' value='".html_escape(@$_GET['end'])."'></td>
|
||||
<td><input type='text' name='c_expires' value='".html_escape(@$_GET['c_expires'])."'></td>
|
||||
<td>block</td>
|
||||
<td><input type='submit' value='Ban'></td>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user