function for showing IPs with ban button

This commit is contained in:
Shish
2012-02-09 22:51:22 +00:00
parent f8af5c0e07
commit 01b89c2a1b
3 changed files with 19 additions and 4 deletions

View File

@@ -180,6 +180,23 @@ function plural($num, $single_form="", $plural_form="s") {
return ($num == 1) ? $single_form : $plural_form;
}
/**
* Give a HTML string which shows an IP (if the user is allowed to see IPs),
* and a link to ban that IP (if the user is allowed to ban IPs)
*
* FIXME: also check that IP ban ext is installed
*
* @retval string
*/
function show_ip($ip, $ban_reason) {
global $user;
$u_reason = url_escape($ban_reason);
$u_end = url_escape("+1 week");
$ban = $user->can("ban_ip") ? ", <a href='".make_link("ip_ban/list", "ip=$ip&reason=$u_reason&end=$u_end#add")."'>Ban</a>" : "";
$ip = $user->can("view_ip") ? $ip.$ban : "";
return $ip;
}
/**
* Different databases have different ways to represent booleans; this