Error: You don't have access to viewing recent comments." unless LJ::check_priv($remote, "siteadmin", "commentview"); my $user = $GET{'user'}; my $u; if ($user =~ /^\#(\d+)/) { $u = LJ::load_userid($1); } elsif ($user) { $u = LJ::load_user($user); } unless ($u) { return "
Username or (#userid) to view comments of: ". "
"; } $user = $u->{'user'}; $ret .= "<< Recent comments of " . LJ::ljuser($u) . " (\#$u->{userid})
\n"; my $dbcr = LJ::get_cluster_reader($u); return "Error: can't get DB for user" unless $dbcr; my $now = time(); my $sth = $dbcr->prepare("SELECT posttime, journalid, nodetype, nodeid, jtalkid, publicitem ". "FROM talkleft ". "WHERE userid=? ORDER BY posttime DESC LIMIT 250"); $sth->execute($u->{'userid'}); my %jcount; # jid -> ct while (my $r = $sth->fetchrow_hashref) { $jcount{$r->{'journalid'}}++; next unless $r->{'nodetype'} eq "L"; # log2 comment my $ju = LJ::load_userid($r->{'journalid'}); my $lrow = LJ::get_log2_row($ju, $r->{'nodeid'}); my $hr_ago = sprintf("%.1f", ($now - $r->{'posttime'}) / 3600); if ($lrow) { my $talkid = ($r->{'jtalkid'} << 8) + $lrow->{'anum'}; my $url = "$LJ::SITEROOT/users/$ju->{user}/$lrow->{ditemid}.html?thread=$talkid\#t$talkid"; $ret .= "$hr_ago hr ago in " . LJ::ljuser($ju) . ": $url
\n"; } else { $ret .= "$hr_ago hr ago in " . LJ::ljuser($ju) . ": link unavailable
"; } } return $ret; } _code?>