From 0de2f23ece2e0cf6c7220c880b141d617a87a13d Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 24 Nov 2019 13:24:42 +0000 Subject: [PATCH] be more CRUD --- ext/ipban/main.php | 30 +++++++++++++++--------------- ext/ipban/theme.php | 36 ++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ext/ipban/main.php b/ext/ipban/main.php index 55daa494..72040316 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -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")); } } diff --git a/ext/ipban/theme.php b/ext/ipban/theme.php index 2b200c80..3eb8f4df 100644 --- a/ext/ipban/theme.php +++ b/ext/ipban/theme.php @@ -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 {$ban[$prefix.'ip']} {$ban[$prefix.'reason']} - {$ban['banner_name']} + {$ban['banner']} ".substr($ban[$prefix.'added'], 0, 10)." ".substr($ban[$prefix.'expires'], 0, 10)." {$ban['mode']} - ".make_form(make_link("ip_ban/remove"))." + ".make_form(make_link("ip_ban/delete"))." - + @@ -37,19 +37,19 @@ class IPBanTheme extends Themelet } $today = date('Y-m-d'); $html = " - Show All Active / - Show EVERYTHING + Show All Active / + Show EVERYTHING

- ".make_form(make_link("ip_ban/list/1"), "GET")." - - - - - - + ".make_form(make_link("ip_ban/list"), "GET")." + + + + + + @@ -57,12 +57,12 @@ class IPBanTheme extends Themelet $h_bans - ".make_form(make_link("ip_ban/add"))." - - + ".make_form(make_link("ip_ban/create"))." + + - +
IPReasonByFromUntilTypeAction
{$user->name} {$today} block