Comments Posted 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 talk WHERE posterid=$u->{'userid'} GROUP BY 1, 2 ORDER BY 1"); $sth->execute; %permonth = (); while ($_ = $sth->fetchrow_hashref) { $permonth{$_->{'month'}} = { format => $_->{'monthpretty'}, count => $_->{'count'} }; } $ret .= "$u->{'name'}. You can also view other months this user has posted comments: p?>"; $ret .= "
Month:

"; # load the comment numbers $sth = $dbh->prepare("SELECT t.datepost, uj.user as 'userjournal', t.nodeid AS 'itemid', t.parenttalkid, tt.subject FROM talk t, talktext tt, user uj WHERE t.talkid=tt.talkid AND t.journalid=uj.userid AND t.posterid=$u->{'userid'} AND t.state<>'D' AND t.nodetype='L' AND YEAR(t.datepost)=$qyear AND MONTH(t.datepost)=$qmonth ORDER BY t.datepost"); $sth->execute; if ($dbh->err) { return $dbh->errstr; } @posts = (); push @posts, $_ while ($_ = $sth->fetchrow_hashref); $TRUNCATE_SIZE = 50; # load the comments my $itemid_in = join(", ", 0, map { $_->{'itemid'} } @posts); $sth = $dbh->prepare("SELECT l.itemid, l.eventtime, LEFT(lt.event, $TRUNCATE_SIZE) AS 'eventtrunc', LENGTH(lt.event) as 'eventlength' FROM log l, logtext lt WHERE l.itemid IN ($itemid_in) AND l.itemid=lt.itemid"); $sth->execute; if ($dbh->err) { return $dbh->errstr; } my %item = (); $item{$_->{'itemid'}} = $_ while ($_ = $sth->fetchrow_hashref); $ret .= "

\n"; $ret .= "\n"; foreach my $p (@posts) { $id = $p->{'itemid'}; $date = $p->{'datepost'}; $date =~ s/ /
/; $ret .= ""; if ($p->{'parenttalkid'} == 0) { $event = $item{$id}->{'eventtrunc'}; $event =~ s/\<[^\>]*$//; LJ::CleanHTML::clean_event(\$event); if ($item{$id}->{'eventlength'} > $TRUNCATE_LENGTH) { $event .= "..."; } $ret .= ""; } else { $ret .= ""; } $p->{'subject'} ||= "(no subject)"; $ret .= "\n"; } $ret .= "
DateEntrySubject
$date{'userjournal'}\">$p->{'userjournal'}: $event(reply to other comment)$p->{'subject'}
\n"; return $ret; _code?> <=body page?>