searching for image hash bans

This commit is contained in:
Shish 2012-01-17 15:33:42 +00:00
parent c3aa7f14dd
commit 940b95c9e6
2 changed files with 31 additions and 3 deletions

View file

@ -128,11 +128,30 @@ class ImageBan extends SimpleExtension {
// DB funness // DB funness
public function get_image_hash_bans($page, $size=100) { public function get_image_hash_bans($page, $size=100) {
global $database;
// FIXME: many // FIXME: many
$size_i = int_escape($size); $size_i = int_escape($size);
$offset_i = int_escape($page-1)*$size_i; $offset_i = int_escape($page-1)*$size_i;
global $database; $where = array("(1=1)");
$bans = $database->get_all("SELECT * FROM image_bans ORDER BY id DESC LIMIT $size_i OFFSET $offset_i"); $args = array();
if(!empty($_GET['hash'])) {
$where[] = 'hash = ?';
$args[] = $_GET['hash'];
}
if(!empty($_GET['reason'])) {
$where[] = 'reason SCORE_ILIKE ?';
$args[] = "%".$_GET['reason']."%";
}
$where = implode(" AND ", $where);
$bans = $database->get_all($database->engine->scoreql_to_sql("
SELECT *
FROM image_bans
WHERE $where
ORDER BY id DESC
LIMIT $size_i
OFFSET $offset_i
"), $args);
if($bans) {return $bans;} if($bans) {return $bans;}
else {return array();} else {return array();}
} }

View file

@ -45,7 +45,16 @@ class ImageBanTheme extends Themelet {
}); });
</script> </script>
<table id='image_bans' class='zebra'> <table id='image_bans' class='zebra'>
<thead><th>Hash</th><th>Reason</th><th>Action</th></thead> <thead>
<th>Hash</th><th>Reason</th><th>Action</th>
<tr>
<form action='".make_link("image_hash_ban/list/1")."' method='GET'>
<td><input type='text' name='hash'></td>
<td><input type='text' name='reason'></td>
<td><input type='submit' value='Search'></td>
</form>
</tr>
</thead>
$h_bans $h_bans
<tfoot><tr> <tfoot><tr>
".make_form(make_link("image_hash_ban/add"))." ".make_form(make_link("image_hash_ban/add"))."