2007-10-22 00:13:57 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: Image Hash Ban
|
2008-12-14 23:43:41 +00:00
|
|
|
* Author: ATravelingGeek <atg@atravelinggeek.com>
|
2007-10-22 00:13:57 +00:00
|
|
|
* Link: http://atravelinggeek.com/
|
|
|
|
* License: GPLv2
|
|
|
|
* Description: Ban images based on their hash
|
|
|
|
* Based on the ResolutionLimit and IPban extensions by Shish
|
|
|
|
* Version 0.1
|
|
|
|
* October 21, 2007
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ImageBanTheme extends Themelet {
|
|
|
|
/*
|
|
|
|
* Show all the bans
|
|
|
|
*
|
|
|
|
* $bans = an array of (
|
|
|
|
* 'hash' => the banned hash
|
|
|
|
* 'reason' => why the hash was banned
|
|
|
|
* 'date' => when the ban started
|
|
|
|
* )
|
|
|
|
*/
|
2009-01-04 19:54:16 +00:00
|
|
|
public function display_image_hash_bans(Page $page, $page_number, $bans) {
|
2007-10-22 00:13:57 +00:00
|
|
|
$h_bans = "";
|
2009-01-17 04:24:43 +00:00
|
|
|
$n = 0;
|
2007-10-22 00:13:57 +00:00
|
|
|
foreach($bans as $ban) {
|
2009-01-17 04:24:43 +00:00
|
|
|
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
2007-10-22 00:13:57 +00:00
|
|
|
$h_bans .= "
|
2009-01-17 04:24:43 +00:00
|
|
|
<tr class='$oe'>
|
|
|
|
<td width='30%'>{$ban['hash']}</td>
|
2007-10-22 00:13:57 +00:00
|
|
|
<td>{$ban['reason']}</td>
|
2009-01-17 04:24:43 +00:00
|
|
|
<td width='10%'>
|
2007-10-22 00:13:57 +00:00
|
|
|
<form action='".make_link("image_hash_ban/remove")."' method='POST'>
|
|
|
|
<input type='hidden' name='hash' value='{$ban['hash']}'>
|
|
|
|
<input type='submit' value='Remove'>
|
|
|
|
</form>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
$html = "
|
2009-07-07 12:42:34 +00:00
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
$(\"#image_bans\").tablesorter();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<table id='image_bans' class='zebra'>
|
2009-01-17 04:24:43 +00:00
|
|
|
<thead><th>Hash</th><th>Reason</th><th>Action</th></thead>
|
2007-10-22 00:13:57 +00:00
|
|
|
$h_bans
|
2009-01-17 04:24:43 +00:00
|
|
|
<tfoot><tr>
|
2007-10-22 00:13:57 +00:00
|
|
|
<form action='".make_link("image_hash_ban/add")."' method='POST'>
|
|
|
|
<td><input type='text' name='hash'></td>
|
|
|
|
<td><input type='text' name='reason'></td>
|
|
|
|
<td><input type='submit' value='Ban'></td>
|
|
|
|
</form>
|
2009-01-17 04:24:43 +00:00
|
|
|
</tr></tfoot>
|
2007-10-22 00:13:57 +00:00
|
|
|
</table>
|
|
|
|
";
|
2008-12-14 23:57:26 +00:00
|
|
|
|
|
|
|
$prev = $page_number - 1;
|
|
|
|
$next = $page_number + 1;
|
|
|
|
|
|
|
|
$h_prev = ($page_number <= 1) ? "Prev" : "<a href='".make_link("image_hash_ban/list/$prev")."'>Prev</a>";
|
|
|
|
$h_index = "<a href='".make_link()."'>Index</a>";
|
|
|
|
$h_next = "<a href='".make_link("image_hash_ban/list/$next")."'>Next</a>";
|
|
|
|
|
|
|
|
$nav = "$h_prev | $h_index | $h_next";
|
|
|
|
|
2008-12-12 19:23:42 +00:00
|
|
|
$page->set_title("Image Bans");
|
|
|
|
$page->set_heading("Image Bans");
|
|
|
|
$page->add_block(new Block("Edit Image Bans", $html));
|
2008-12-14 23:57:26 +00:00
|
|
|
$page->add_block(new Block("Navigation", $nav, "left", 0));
|
2007-10-22 00:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display a link to delete an image
|
|
|
|
*
|
|
|
|
* $image_id = the image to delete
|
|
|
|
*/
|
2009-01-04 19:54:16 +00:00
|
|
|
public function get_buttons_html(Image $image) {
|
2007-10-22 00:13:57 +00:00
|
|
|
$html = "
|
2008-07-27 15:55:45 +00:00
|
|
|
<form action='".make_link("image_hash_ban/add")."' method='POST'>
|
|
|
|
<input type='hidden' name='hash' value='{$image->hash}'>
|
|
|
|
<input type='hidden' name='image_id' value='{$image->id}'>
|
|
|
|
<input type='text' name='reason'>
|
2007-10-22 00:13:57 +00:00
|
|
|
<input type='submit' value='Ban and Delete'>
|
|
|
|
</form>
|
|
|
|
";
|
2008-07-27 15:55:45 +00:00
|
|
|
return $html;
|
2007-10-22 00:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-27 15:55:45 +00:00
|
|
|
?>
|