This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/ipban/theme.php

79 lines
2.9 KiB
PHP
Raw Normal View History

<?php
class IPBanTheme extends Themelet
{
/*
* Show all the bans
*
* $bans = an array of (
* 'ip' => the banned IP
* 'reason' => why the IP was banned
2019-11-24 13:24:42 +00:00
* 'added' => when the ban started
* 'expires' => when the ban will end
* )
*/
public function display_bans(Page $page, $bans)
{
global $database, $user;
$h_bans = "";
$prefix = ($database->get_driver_name() == DatabaseDriver::SQLITE ? "bans." : "");
foreach ($bans as $ban) {
$h_bans .= "
2012-02-22 14:27:56 +00:00
<tr>
<td width='12%'>{$ban[$prefix.'ip']}</td>
2009-07-17 01:43:57 +00:00
<td>{$ban[$prefix.'reason']}</td>
2019-11-24 13:24:42 +00:00
<td width='10%'>{$ban['banner']}</td>
2013-08-05 19:46:54 +00:00
<td width='10%'>".substr($ban[$prefix.'added'], 0, 10)."</td>
2019-11-08 18:54:32 +00:00
<td width='10%'>".substr($ban[$prefix.'expires'], 0, 10)."</td>
<td width='10%'>{$ban['mode']}</td>
2019-11-24 13:24:42 +00:00
".make_form(make_link("ip_ban/delete"))."
<td width='8%'>
2019-11-24 13:24:42 +00:00
<input type='hidden' name='d_id' value='{$ban[$prefix.'id']}'>
<input type='submit' value='Remove'>
</td>
</form>
</tr>
";
}
2019-11-11 12:52:11 +00:00
$today = date('Y-m-d');
$html = "
2019-11-24 13:24:42 +00:00
<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'>
2019-11-11 12:52:11 +00:00
<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>
2019-11-24 13:24:42 +00:00
".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>
2019-11-11 12:52:11 +00:00
<td><input type='submit' value='Search'></td>
</form>
</tr>
</thead>
$h_bans
2019-11-11 12:52:11 +00:00
<tfoot>
<tr id='add'>
2019-11-24 13:24:42 +00:00
".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>
2019-11-11 12:52:11 +00:00
<td>{$user->name}</td>
<td>{$today}</td>
2019-11-24 13:24:42 +00:00
<td><input type='text' name='c_expires' value='".html_escape(@$_GET['c_expires'])."'></td>
2019-11-11 12:52:11 +00:00
<td>block</td>
<td><input type='submit' value='Ban'></td>
</form>
</tr>
</tfoot>
</table>
";
$page->set_title("IP Bans");
$page->set_heading("IP Bans");
$page->add_block(new NavBlock());
$page->add_block(new Block("Edit IP Bans", $html));
}
}