summaryrefslogtreecommitdiffstats
path: root/blog/blog.pl
diff options
context:
space:
mode:
Diffstat (limited to 'blog/blog.pl')
-rwxr-xr-xblog/blog.pl33
1 files changed, 19 insertions, 14 deletions
diff --git a/blog/blog.pl b/blog/blog.pl
index 07b72011..e3ba2744 100755
--- a/blog/blog.pl
+++ b/blog/blog.pl
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $Id: blog.pl,v 1.20 2003/06/14 03:55:10 in2 Exp $
+# $Id: blog.pl,v 1.21 2003/06/18 09:06:21 in2 Exp $
use CGI qw/:standard/;
use lib qw/./;
use LocalVars;
@@ -113,19 +113,24 @@ sub main
}
# topBlogs
- if( $attr{"$fn.loadTopBlogs"} ){
- dodbi(sub {
- my($dbh) = @_;
- my($sth);
- $sth = $dbh->prepare("select k, v from counter order by v desc ".
- ($attr{"$fn.loadTopBlogs"} eq 'all' ? '' :
- 'limit 0,'. $attr{"$fn.loadTopBlogs"}));
- $sth->execute();
- while( $_ = $sth->fetchrow_hashref() ){
- push @{$th{topBlogs}}, {brdname => $_->{k},
- counter => $_->{v}};
- }
- });
+ my($t);
+ foreach $t ( ['loadTopBlogs', 'v', 'topBlogs'],
+ ['loadRandomBlogs', 'RAND()', 'randomBlogs'] ){
+ if( $attr{"$fn.$t->[0]"} ){
+ dodbi(sub {
+ my($dbh) = @_;
+ my($sth);
+ $sth = $dbh->prepare("select k, v from counter ".
+ "order by $t->[1] desc ".
+ ($attr{"$fn.$t->[0]"} eq 'all' ? '' :
+ 'limit 0,'. $attr{"$fn.$t->[0]"}));
+ $sth->execute();
+ while( $_ = $sth->fetchrow_hashref() ){
+ push @{$th{$t->[2]}}, {brdname => $_->{k},
+ counter => $_->{v}};
+ }
+ });
+ }
}
# Counter ----------------------------------------------------------------