ljr/local/htdocs/friends/pipiskomer.bml

66 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2019-02-05 21:49:12 +00:00
<?page
title=><?_ml .title _ml?>
body<=
<?_code
{
use strict;
use vars qw(%GET);
my @users; # users
my $fr = LJ::get_friends(20); # all friends of lj_fif
return "Error fetching your friends" unless $fr;
my $LIMIT = 5000;
my @ids = keys %$fr;
splice(@ids, 0, $LIMIT) if @ids > $LIMIT;
my $fus = LJ::load_userids(@ids);
@ids = grep { $fus->{$_}{journaltype} eq "P" } @ids;
my %count;
my $MAX_DELAY = 4;
my $start = time();
while (@ids && time() < $start + $MAX_DELAY) {
my $fid = shift @ids;
my $fr = LJ::get_friends($fid);
next unless $fr;
$count{$_}++ foreach (keys %$fr);
}
my @pop = sort { $count{$b} <=> $count{$a} } keys %count;
my $ret = "";
my $rows;
my $MAX_DISPLAY = 150;
my $shown;
foreach my $popid (@pop) {
last if ++$shown > $MAX_DISPLAY;
my $u = LJ::load_userid($popid);
my $count = $count{$popid};
$rows .= "<tr><td>" . LJ::ljuser($u) . " - "
. LJ::ehtml($u->{name}) .
"</td><td align='right'>$count</td></tr>\n";
}
if ($rows) {
$ret .= "<table cellpadding='3'>\n";
$ret .=
"<tr><td><b>$ML{'.user'}</b></td><td><b>$ML{'.count'}</b></td></tr>\n";
$ret .= $rows;
$ret .= "</table>\n";
$ret .= $GET{'own'} ? "<?p $ML{'.exclude_own'} p?>" : "<?p
$ML{'.include_own'} p?>";
}
return $ret;
}
_code?>
<=body
page?>