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
commit0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac (patch)
tree059bccef93565c06801f9cf27485281d034699f7
parentba7c6e238e724e6d5ee2215a7d4666b548acbabf (diff)
downloadpttbbs-0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac.tar
pttbbs-0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac.tar.gz
pttbbs-0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac.tar.bz2
pttbbs-0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac.tar.lz
pttbbs-0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac.tar.xz
pttbbs-0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac.tar.zst
pttbbs-0d75a368cb85cbfe7a4d0cdd000cc38bab5816ac.zip
randomBlog
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@942 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rwxr-xr-xpttbbs/blog/blog.pl33
1 files changed, 19 insertions, 14 deletions
diff --git a/pttbbs/blog/blog.pl b/pttbbs/blog/blog.pl
index 07b72011..e3ba2744 100755
--- a/pttbbs/blog/blog.pl
+++ b/pttbbs/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 ----------------------------------------------------------------