diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-11-12 10:30:48 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-11-12 10:30:48 +0800 |
commit | 177b143355538ee8485e87bcc09d87e56fac751e (patch) | |
tree | 5de021879dab35716a9559e558df49bad9ce8eb1 /blog | |
parent | f4ae410856e994617aecff81edcfc811902dc97c (diff) | |
download | pttbbs-177b143355538ee8485e87bcc09d87e56fac751e.tar pttbbs-177b143355538ee8485e87bcc09d87e56fac751e.tar.gz pttbbs-177b143355538ee8485e87bcc09d87e56fac751e.tar.bz2 pttbbs-177b143355538ee8485e87bcc09d87e56fac751e.tar.lz pttbbs-177b143355538ee8485e87bcc09d87e56fac751e.tar.xz pttbbs-177b143355538ee8485e87bcc09d87e56fac751e.tar.zst pttbbs-177b143355538ee8485e87bcc09d87e56fac751e.zip |
add week counter
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1323 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'blog')
-rwxr-xr-x | blog/blog.pl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/blog/blog.pl b/blog/blog.pl index dcb272c7..49b30fd8 100755 --- a/blog/blog.pl +++ b/blog/blog.pl @@ -142,13 +142,15 @@ sub main # topBlogs my($t); - foreach $t ( ['loadTopBlogs', 'v', 'topBlogs'], - ['loadRandomBlogs', 'RAND()', 'randomBlogs'] ){ + foreach $t ( ['loadTopBlogs', 'v', 'topBlogs', 'counter'], + ['loadTopWeekBlogs', 'v', 'topWeekBlogs', 'wcounter'], + ['loadRandomBlogs', 'RAND()', 'randomBlogs', 'counter'], + ){ if( $attr{"$fn.$t->[0]"} ){ dodbi(sub { my($dbh) = @_; my($sth); - $sth = $dbh->prepare("select k, v from counter ". + $sth = $dbh->prepare("select k, v from $t->[3] ". "order by $t->[1] desc ". ($attr{"$fn.$t->[0]"} eq 'all' ? '' : 'limit 0,'. $attr{"$fn.$t->[0]"})); @@ -169,13 +171,15 @@ sub main $time = time(); $dbh->do("update counter set v = v + 1, mtime = $time ". "where k = '$brdname' && mtime < ". ($time - 2)); + $dbh->do("update wcounter set v = v + 1, mtime = $time ". + "where k = '$brdname' && mtime < ". ($time - 2)); $sth = $dbh->prepare("select v from counter where k='$brdname'"); $sth->execute(); $t = $sth->fetchrow_hashref(); return $t->{v} if( $t->{v} ); - $dbh->do("insert into counter (k, v) ". - "values ('$brdname', 1)"); + $dbh->do("insert into counter (k, v) values ('$brdname', 1)"); + $dbh->do("insert into wcounter (k, v) values ('$brdname', 1)"); return 1; }); } |