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

View File

@ -174,8 +174,7 @@ class CommentListTheme extends Themelet {
$avatar = "<img src=\"http://www.gravatar.com/avatar/$hash.jpg\"><br>";
}
$h_reply = " - <a href='javascript: replyTo($i_image_id, $i_comment_id)'>Reply</a>";
$ban = $user->can("ban_ip") ? ", <a href='".make_link("ip_ban/list", "ip={$h_poster_ip}&reason=Comment%20posted%20{$comment->posted}#add")."'>Ban</a>" : "";
$h_ip = $user->can("view_ip") ? "<br>$h_poster_ip, $ban" : "";
$h_ip = $user->can("view_ip") ? "<br>".show_ip($image->owner_ip, "Comment posted {$comment->posted}") : "";
$h_del = $user->can("delete_comment") ?
' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '.
'href="'.make_link('comment/delete/'.$i_comment_id.'/'.$i_image_id).'">Del</a>' : '';

View File

@ -37,8 +37,7 @@ class TagEditTheme extends Themelet {
$h_owner = html_escape($image->get_owner()->name);
$h_av = $image->get_owner()->get_avatar_html();
$h_date = autodate($image->posted);
$ban = $user->can("ban_ip") ? ", <a href='".make_link("ip_ban/list", "ip={$image->owner_ip}&reason=Image%20posted%20{$image->posted}#add")."'>Ban</a>" : "";
$ip = $user->can("view_ip") ? " ({$image->owner_ip}$ban)" : "";
$ip = $user->can("view_ip") ? " (".show_ip($image->owner_ip, "Image posted {$image->posted}").")" : "";
return "
<tr>
<td>User</td>