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 .= "
";
$ret .= "
Total accounts: $total
\n";
$ret .= "
... active in some way: $active
\n" if $active;
$ret .= "
... that have ever updated: $usedever
\n";
$ret .= "
... updating in last 30 days: $used30
\n";
$ret .= "
... updating in last 7 days: $used7
\n";
$ret .= "
... updating in past 24 hours: $usedlastday
\n";
$ret .= "
\n";
$ret .= "\n";
$ret .= "
";
{
my $male = $stat{'gender'}->{'M'}+0;
my $female = $stat{'gender'}->{'F'}+0;
my $tot = $male+$female;
$tot ||= 1;
$ret .= "
\n";
$ret .= "\n"; # L.P.
$sth = $dbr->prepare("SELECT u.userid, u.user, u.name, uu.timecreate, u.statusvis FROM user u, userusage uu WHERE u.userid=uu.userid AND uu.timeupdate > DATE_SUB(NOW(), INTERVAL 5 DAY) AND uu.timecreate > DATE_SUB(NOW(), INTERVAL 5 DAY) ORDER BY uu.timecreate DESC");
$sth->execute;
my $ct;
while (my ($iuserid, $iuser, $iname, $itime, $status) = $sth->fetchrow_array) {
my $tmp = ", $itime";
$tmp = "$tmp" if $status =~ /[DXS]/;
# determine the number of posted comments
my $com_post;
my $mysth = $dbr->prepare("SELECT COUNT(*) FROM talkleft " .
"WHERE userid=?");
$mysth->execute($iuserid);
($com_post)=$mysth->fetchrow_array;
# number of posted comments is found
if ($com_post >0) { $tmp= "$tmp; $com_post comments posted.";}
$tmp = "
\n";
$ret .= "\n"; # L.P.
$sth = $dbr->prepare("SELECT u.userid, u.user, u.name, uu.timecreate, u.statusvis FROM user u, userusage uu WHERE u.userid=uu.userid AND uu.timeupdate IS NULL AND uu.timecreate > DATE_SUB(NOW(), INTERVAL 20 DAY) ORDER BY uu.timecreate DESC");
$sth->execute;
my $ct;
while (my ($iuserid, $iuser, $iname, $itime, $status) = $sth->fetchrow_array) {
if ($iuser !~ /^(imp|ext)_.*/) {
# determine the number of posted comments
my $com_post;
my $mysth = $dbr->prepare("SELECT COUNT(*) FROM talkleft " .
"WHERE userid=?");
$mysth->execute($iuserid);
($com_post)=$mysth->fetchrow_array;
# number of posted comments is found
my $tmp = ", $itime";
$tmp = "$tmp" if $status =~ /[DXS]/;
if ($com_post >0) { $tmp= "$tmp; $com_post comments posted.";}
$tmp = "
\n";
$ret .= "\n"; # L.P.
$sth = $dbr->prepare("SELECT u.userid, u.user, u.name, uu.timecreate, u.statusvis FROM user u, userusage uu WHERE u.userid=uu.userid AND uu.timeupdate IS NULL AND uu.timecreate > DATE_SUB(NOW(), INTERVAL 20 DAY) ORDER BY uu.timecreate DESC");
$sth->execute;
my $ct;
while (my ($iuserid, $iuser, $iname, $itime, $status) = $sth->fetchrow_array) {
if ($iuser =~ /^(ext)_.*/) {
## determine the number of posted comments
my $com_post;
my $mysth = $dbr->prepare("SELECT COUNT(*) FROM talkleft " .
"WHERE userid=?");
$mysth->execute($iuserid);
($com_post)=$mysth->fetchrow_array;
## number of posted comments is found
my $tmp = ", $itime";
$tmp = "$tmp" if $status =~ /[DXS]/;
if ($com_post >0) { $tmp= "$tmp; $com_post comments posted.";}
$tmp = "
$tmp
\n";
$ret .= $tmp;
$ct++;
}
}
$ret .= "
stat not available
" unless $ct;
$ret .= "\n
\n";
}
$ret .= "\n";
{
$ret .= "
\n";
my $ct;
foreach my $key (sort { $stat{'country'}->{$b} <=> $stat{'country'}->{$a} }
keys %{$stat{'country'}})
{
$ret .= "
$key - $stat{'country'}->{$key}
\n";
$ct++;
}
$ret .= "
stat not available
" unless $ct;
$ret .= "
\n";
}
# Removed by popular request - M.V.
# {
# $ret .= "The following are the 15 most popular U.S. states $LJ::SITENAMESHORT is used in: