User Log Viewer head<= <=head body<= " unless $remote; my $err = sub { return ""; }; return $err->("You do not have the necessary privilege to view this page.") unless LJ::check_priv($remote, 'canview', 'userlog') || LJ::check_priv($remote, 'canview', '*'); my $user = LJ::canonical_username($POST{user}); my $ret = < Username: FORM return $ret unless $user; my $u = LJ::load_user($user); return $err->("User does not exist.") unless $u; my $dbcr = LJ::get_cluster_reader($u); return $err->("Unable to get user cluster reader.") unless $dbcr; my $sth = $dbcr->prepare('SELECT * FROM userlog WHERE userid = ? ORDER BY logtime DESC LIMIT 1000'); $sth->execute($u->{userid}); return $err->("Database error: " . $sth->errstr) if $sth->err; $ret .= ""; $ret .= "\n"; $ret .= ""; $ret .= join('', map { "" } ("Date and Time", "Action", "Initiator", "IP Address", "Uniq Cookie")); $ret .= "\n"; while (my $row = $sth->fetchrow_hashref) { my $extra = {}; LJ::decode_url_string($row->{extra}, $extra); my $action = "Action undefined for: $row->{action}"; if ($row->{action} eq 'delete_entry') { $action = "Deleted entry $row->{actiontarget} via $extra->{method}"; } elsif ($row->{action} eq 'account_create') { $action = "Account created"; } elsif ($row->{action} eq 'ban_set') { my $u = LJ::load_userid($row->{actiontarget}); $action = "Banned " . LJ::ljuser($u) if $u; } elsif ($row->{action} eq 'ban_unset') { my $u = LJ::load_userid($row->{actiontarget}); $action = "Unbanned " . LJ::ljuser($u) if $u; } elsif ($row->{action} eq 'maintainer_add') { my $u = LJ::load_userid($row->{actiontarget}); $action = "Added maintainer " . LJ::ljuser($u) if $u; } elsif ($row->{action} eq 'maintainer_remove') { my $u = LJ::load_userid($row->{actiontarget}); $action = "Removed maintainer " . LJ::ljuser($u) if $u; } else { $action = "Unknown action ($row->{action})"; } my $time = LJ::mysql_time($row->{logtime}); my $actor; if ($row->{remoteid}) { my $u = LJ::load_userid($row->{remoteid}); $actor = LJ::ljuser($u); } else { $actor = "not recorded"; } my $ip = $row->{ip} || "not recorded"; my $uniq = $row->{uniq} || "not recorded"; $ret .= "" . join('', map { "" } ($time, $action, $actor, $ip, $uniq)) . "\n"; } $ret .= "
$_
$_
"; return $ret; } _code?> <=body page?>