Comments Received body<= Down for Maintenance
This page used database queries that were horribly unoptimized and killed the rest of the site. This is currently being fixed on the LiveJournal development server, and when it's fixed, the main server will be updated and this page will be available again."; my $dbh = LJ::get_db_writer(); my $ret = ""; my $user = lc($FORM{'user'}); my $quser = $dbh->quote($user); my $month = $FORM{'month'}; my $year; if ($month =~ /^(\d\d\d\d)-(\d\d)$/) { $year = $1; $month = $2; } else { my @nowtime = localtime(); $year = $nowtime[5]+1900; $month = sprintf("%02d", $nowtime[4]+1); } my $qyear = $dbh->quote($year); my $qmonth = $dbh->quote($month); $sth = $dbh->prepare("SELECT * FROM user WHERE user=$quser"); $sth->execute; my $u = $sth->fetchrow_hashref; unless ($u) { return "$user. Sorry. p?>"; } # get number of posts per month $sth = $dbh->prepare("SELECT DATE_FORMAT(datepost, '%Y-%m') AS 'month', DATE_FORMAT(datepost, '%Y-%M') AS 'monthpretty', COUNT(*) AS 'count' FROM talkpost WHERE userjournal=$quser GROUP BY 1, 2 ORDER BY 1"); $sth->execute; %permonth = (); while ($_ = $sth->fetchrow_hashref) { $permonth{$_->{'month'}} = { format => $_->{'monthpretty'}, count => $_->{'count'} }; } $ret .= "$u->{'name'} which have been commented on by others, in reverse chronological order. You can also view other months this user has received comments: p?>"; $ret .= "
Month:

"; # load the comment numbers $sth = $dbh->prepare("SELECT itemid, COUNT(*) AS 'count' FROM talkpost WHERE userjournal=$quser AND YEAR(datepost)=$qyear AND MONTH(datepost)=$qmonth GROUP BY 1 ORDER BY datepost DESC"); $sth->execute; @items = (); push @items, $_ while ($_ = $sth->fetchrow_hashref); $TRUNCATE_SIZE = 100; # load the comments my $itemid_in = join(", ", 0, map { $_->{'itemid'} } @items); $sth = $dbh->prepare("SELECT l.itemid, l.subject, l.eventtime, LEFT(l.event, $TRUNCATE_SIZE) AS 'eventtrunc', LENGTH(l.event) as 'eventlength' FROM log l LEFT JOIN friends f ON l.ownerid=f.userid AND f.friendid=$qremuid WHERE l.ownerid=$u->{'userid'} AND l.itemid IN ($itemid_in) AND ((l.security='public') OR (l.security='usemask' AND l.allowmask & f.groupmask) OR (l.ownerid=$qremuid))"); $sth->execute; if ($dbh->err) { return "I'm working on this work now, I know it's an error.....: " . $dbh->errstr; } my %item = (); $item{$_->{'itemid'}} = $_ while ($_ = $sth->fetchrow_hashref); $ret .= "

\n"; $ret .= "\n"; foreach my $i (@items) { $id = $i->{'itemid'}; next unless (defined $item{$id}->{'eventtime'}); $date = $item{$id}->{'eventtime'}; $date =~ s/ /
/; $ret .= ""; $ret .= "\n"; } $ret .= "
DateComment# Comments
$date"; $event = $item{$id}->{'eventtrunc'}; $event =~ s/\<[^\>]*$//; LJ::CleanHTML::clean_event(\$event); if ($item{$id}->{'eventlength'} > $TRUNCATE_LENGTH) { $event .= "..."; } if ($item{$id}->{'subject'}) { $ret .= "$item{$id}->{'subject'}
"; } $ret .= "$event
$i->{'count'}
\n"; return $ret; _code?> <=body page?>