Statistics body<= Statistics h1?> here. p?> prepare("SELECT statcat, statkey, statval FROM stats WHERE statcat IN ('userinfo', 'client', 'age', 'gender', 'account', 'size')"); $sth->execute; while ($_ = $sth->fetchrow_hashref) { $stat{$_->{'statcat'}}->{$_->{'statkey'}} = $_->{'statval'}; } unless (%stat) { return "ljmaint.pl genstats, or ideally, put it in cron to run nightly. p?>"; } $sth = $dbr->prepare("SELECT c.item, s.statval FROM stats s, codes c WHERE c.type='country' AND s.statcat='country' AND s.statkey=c.code ORDER BY s.statval DESC LIMIT 15"); $sth->execute; while ($_ = $sth->fetchrow_hashref) { $stat{'country'}->{$_->{'item'}} = $_->{'statval'}; } $sth = $dbr->prepare("SELECT c.item, s.statval FROM stats s, codes c WHERE c.type='state' AND s.statcat='stateus' AND s.statkey=c.code ORDER BY s.statval DESC LIMIT 15"); $sth->execute; while ($_ = $sth->fetchrow_hashref) { $stat{'state'}->{$_->{'item'}} = $_->{'statval'}; } my $total = $stat{'userinfo'}->{'total'}+0; my $usedever = $stat{'userinfo'}->{'updated'}+0; my $used30 = $stat{'userinfo'}->{'updated_last30'}+0; my $used7 = $stat{'userinfo'}->{'updated_last7'}+0; my $usedlastday = $stat{'userinfo'}->{'updated_last1'}+0; my $allow_getljnews = $stat{'userinfo'}->{'allow_getljnews'}+0; my $active = $stat{'size'}->{'accounts_active'}+0; my $ret = ""; $ret .= "\n"; $ret .= " \n"; $ret .= "\n"; $ret .= "\n"; LJ::run_hook('statspage', { stat => \%stat, ret => \$ret, }); unless ($LJ::DISABLED{'stats-recentupdates'}) { $ret .= "\n"; $ret .= " \n"; } unless ($LJ::DISABLED{'stats-newjournals'}) { $ret .= "\n"; $ret .= "\n"; } $ret .= "\n"; { $ret .= "\n"; } { $ret .= "The following are the 15 most popular U.S. states $LJ::SITENAMESHORT is used in: \n"; } # ages my %age = (); my $maxage = 1; foreach my $key (keys %{$stat{'age'}}) { $age{$key} = $stat{'age'}->{$key}; if ($stat{'age'}->{$key} > $maxage) { $maxage = $stat{'age'}->{$key}; } } my @ages = grep { $_ >= 13 && $_ <= 55 } sort { $a <=> $b } sort keys %age; if (@ages) { $ret .= "\n"; $ret .= "\n"; my $lastage = 0; foreach my $age (@ages) { my $width = int(400 * $age{$age}/$maxage); $ret .= "\n"; $lastage = $_; } $ret .= "
$age$age{$age}
\n"; } # clients (if enabled) unless ($LJ::DISABLED{'clientversionlog'}) { ### sum up clients over different versions foreach my $c (keys %{$stat{'client'}}) { next unless ($c =~ /^(.+?)\//); $stat{'clientname'}->{$1} += $stat{'client'}->{$c}; } my $out; foreach my $cn (sort { $stat{'clientname'}->{$b} <=> $stat{'clientname'}->{$a} } keys %{$stat{'clientname'}}) { last unless $stat{'clientname'}->{$cn} >= 50; $out .= "$stat{'clientname'}->{$cn}". "" . LJ::ehtml($cn) . "
\n"; $out .= "\n"; foreach my $c (sort grep { /^\Q$cn\E\// } keys %{$stat{'client'}}) { my $count = $stat{'client'}->{$c}; $c =~ s/^\Q$cn\E\///; $out .= LJ::ehtml($c) . " ($count), "; } chop $ret; chop $ret; # remove trailing ", " $out .= "\n"; $out .= "\n"; } if ($out) { $ret .= "\n"; $ret .= "\n"; $ret .= $out; $ret .= "
\n"; } } # return early, since the graphs below are pretty much broken now # with index changes. FIXME: make alternate means to generate stats return $ret; ### graphs! $ret .= ""; $ret .= ""; $ret .= "

"; $ret .= ""; $ret .= "

"; $ret .= ""; $ret .= "

"; return $ret; _code?> <=body page?> link: htdocs/stats/, htdocs/support/faqbrowse.bml img: htdocs/img/bluedot.gif, htdocs/stats/postsbyday.png, htdocs/stats/postsbyweek.png, htdocs/stats/newbyday.png _c?>