summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-18 17:06:21 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-18 17:06:21 +0800
commit6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d (patch)
tree17f43ddc786db48efc96f5d9e699bd3b28b52a12
parentcc20dce5dbe95d913ab9c0ff9faa4cc0c5b749ef (diff)
downloadpttbbs-6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d.tar
pttbbs-6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d.tar.gz
pttbbs-6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d.tar.bz2
pttbbs-6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d.tar.lz
pttbbs-6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d.tar.xz
pttbbs-6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d.tar.zst
pttbbs-6491311d11a8c3f9c7cecdc1cc39d5c7ef8eeb9d.zip
randomBlog
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@942 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-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 ----------------------------------------------------------------