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/contrib/ipban/theme.php

68 lines
1.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
* 'date' => when the ban started
* 'end' => when the ban will end
* )
*/
2009-01-04 19:54:16 +00:00
public function display_bans(Page $page, $bans) {
2009-07-17 01:43:57 +00:00
global $database, $user;
$h_bans = "";
2009-01-17 04:24:43 +00:00
$n = 0;
2009-07-17 01:43:57 +00:00
$prefix = ($database->engine->name == "sqlite" ? "bans." : "");
$prefix2 = ($database->engine->name == "sqlite" ? "users." : "");
foreach($bans as $ban) {
2009-07-17 01:43:57 +00:00
$end_human = date('Y-m-d', $ban[$prefix.'end_timestamp']);
2009-01-17 04:24:43 +00:00
$oe = ($n++ % 2 == 0) ? "even" : "odd";
$h_bans .= "
2009-01-17 04:24:43 +00:00
<tr class='$oe'>
2009-07-17 01:43:57 +00:00
<td width='10%'>{$ban[$prefix.'ip']}</td>
<td>{$ban[$prefix.'reason']}</td>
2009-01-17 04:24:43 +00:00
<td width='10%'>{$ban['banner_name']}</td>
<td width='15%'>{$end_human}</td>
<td width='10%'>
<form action='".make_link("ip_ban/remove")."' method='POST'>
2010-05-28 13:26:46 +00:00
".$user->get_auth_html()."
2009-07-17 01:43:57 +00:00
<input type='hidden' name='id' value='{$ban[$prefix.'id']}'>
<input type='submit' value='Remove'>
</form>
</td>
</tr>
";
}
$html = "
2009-07-07 12:42:34 +00:00
<script>
$(document).ready(function() {
$(\"#bans\").tablesorter();
});
</script>
<a href='".make_link("ip_ban/list", "all=on")."'>Show All</a>
2009-07-07 12:42:34 +00:00
<p><table id='bans' class='zebra'>
<thead><tr><th>IP</th><th>Reason</th><th>By</th><th>Until</th><th>Action</th></tr></thead>
$h_bans
2009-01-17 04:24:43 +00:00
<tfoot><tr>
<form action='".make_link("ip_ban/add")."' method='POST'>
2010-05-28 13:26:46 +00:00
".$user->get_auth_html()."
<td><input type='text' name='ip'></td>
<td><input type='text' name='reason'></td>
<td>{$user->name}</td>
<td><input type='text' name='end'></td>
<td><input type='submit' value='Ban'></td>
</form>
2009-01-17 04:24:43 +00:00
</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));
}
}
?>