| 1 |
# web board for hns / Board.pm |
| 2 |
# Copyright (C) 2001 Yoichi Imai <yoichi@silver-forest.com> |
| 3 |
# |
| 4 |
# This program is free software; you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation; either version 2 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program; if not, write to the Free Software |
| 16 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 |
|
| 18 |
|
| 19 |
package Board; |
| 20 |
use vars qw($Use_BBS, $BBSReadCGI, $BBSData, $ReadStr, $WriteStr, $LinkStr); |
| 21 |
$Use_BBS = 0; |
| 22 |
$BBSReadCGI = 'hnsbbs/read.cgi'; |
| 23 |
$BBSWriteCGI = 'hnsbbs/write.cgi'; |
| 24 |
$BBSData = 'hnsbbs/data/bbsdata.txt'; |
| 25 |
$ReadStr = 'Read more... (%num)'; |
| 26 |
$WriteStr = 'Post message...'; |
| 27 |
$LinkStr = '<div align="right">( %readstr | %writestr )</div>'; |
| 28 |
|
| 29 |
my %ArtcileNum; |
| 30 |
|
| 31 |
sub read_bbsdata() |
| 32 |
{ |
| 33 |
return unless $Use_BBS; |
| 34 |
|
| 35 |
open(FH, $BBSData) || die "Can't open bbsdata file."; |
| 36 |
foreach (<FH>) { |
| 37 |
my @list = split(/\t/, $_); |
| 38 |
if($list[0] ne '' && $list[3] ne '' && $list[2] ne 'root') { |
| 39 |
$ArticleNum{$list[3]}++; |
| 40 |
} |
| 41 |
} |
| 42 |
close(FH); |
| 43 |
} |
| 44 |
|
| 45 |
sub get_linkstr($) |
| 46 |
{ |
| 47 |
return "" unless $Use_BBS; |
| 48 |
|
| 49 |
my ($daydata) = shift; |
| 50 |
my $num = $ArticleNum{$daydata}; |
| 51 |
my $readstr = $ReadStr; |
| 52 |
my $writestr = $WriteStr; |
| 53 |
my $linkstr = $LinkStr; |
| 54 |
|
| 55 |
# readstr |
| 56 |
$num = 0 if ($num eq ''); |
| 57 |
$readstr =~ s/%num/$num/g; |
| 58 |
if ($num != 0) { |
| 59 |
$readstr = qq(<a href="${BBSReadCGI}?diary=${daydata}">) . $readstr . '</a>'; |
| 60 |
} |
| 61 |
# writestr |
| 62 |
$writestr = qq(<a href="${BBSWriteCGI}?diary=${daydata}">) . $writestr . '</a>'; |
| 63 |
|
| 64 |
# linkstr |
| 65 |
$linkstr =~ s/%readstr/$readstr/g; |
| 66 |
$linkstr =~ s/%writestr/$writestr/g; |
| 67 |
|
| 68 |
return $linkstr; |
| 69 |
} |
| 70 |
|
| 71 |
1; |