summaryrefslogtreecommitdiffstats
path: root/staticweb/index.pl
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-07 22:30:43 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-07 22:30:43 +0800
commit568f85f62408671db2d16a0e33e0d206effe99c4 (patch)
treecfb3d55c2dfc419fb8b7cf1ec44ee55e45c0759c /staticweb/index.pl
parent4cfc6b121bab9bb2132087c449ddec448851bdcb (diff)
downloadpttbbs-568f85f62408671db2d16a0e33e0d206effe99c4.tar
pttbbs-568f85f62408671db2d16a0e33e0d206effe99c4.tar.gz
pttbbs-568f85f62408671db2d16a0e33e0d206effe99c4.tar.bz2
pttbbs-568f85f62408671db2d16a0e33e0d206effe99c4.tar.lz
pttbbs-568f85f62408671db2d16a0e33e0d206effe99c4.tar.xz
pttbbs-568f85f62408671db2d16a0e33e0d206effe99c4.tar.zst
pttbbs-568f85f62408671db2d16a0e33e0d206effe99c4.zip
cache all tied objects
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1930 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'staticweb/index.pl')
-rwxr-xr-xstaticweb/index.pl41
1 files changed, 22 insertions, 19 deletions
diff --git a/staticweb/index.pl b/staticweb/index.pl
index e6d647ba..5bfc631f 100755
--- a/staticweb/index.pl
+++ b/staticweb/index.pl
@@ -2,27 +2,28 @@
# $Id$
use lib qw/./;
use LocalVars;
-use CGI qw/:standard/;
+use CGI qw/:cgi :html2/;
use strict;
use Template;
-#use boardlist;
use b2g;
use DB_File;
use Data::Serializer;
+use vars qw/$serializer $tmpl %brdlist/;
sub deserialize
{
my($what) = @_;
- my $obj = Data::Serializer->new(serializer => 'Storable',
- digester => 'MD5',
- compress => 0,
- );
- return $obj->deserialize($what);
+ $serializer = Data::Serializer->new(serializer => 'Storable',
+ digester => 'MD5',
+ compress => 0,
+ )
+ if( !$serializer );
+ return $serializer->deserialize($what);
}
sub main
{
- my($tmpl, %rh, $bid, %brd);
+ my(%rh, $bid) = ();
if( param('gb') ){
$rh{gb} = 1;
@@ -42,31 +43,32 @@ sub main
charset('');
print header();
- tie %brd, 'DB_File', 'boardlist.db', O_RDONLY, 0666, $DB_HASH;
+ tie %brdlist, 'DB_File', 'boardlist.db', O_RDONLY, 0666, $DB_HASH
+ if( !%brdlist );
($bid) = $ENV{PATH_INFO} =~ m|.*/(\d+)/$|;
$bid ||= 0;
$rh{isroot} = ($bid == 0);
- if( !exists $brd{"class.$bid"} ){
+ if( !exists $brdlist{"class.$bid"} ){
print "sorry, this bid $bid not found :(";
return ;
}
- foreach( @{deserialize($brd{"class.$bid"})} ){
- next if( $brd{"$_.isboard"} &&
- !-e "$MANDATA/".$brd{"tobrdname.$_"}.'.db' );
+ foreach( @{deserialize($brdlist{"class.$bid"})} ){
+ next if( $brdlist{"$_.isboard"} &&
+ !-e "$MANDATA/".$brdlist{"tobrdname.$_"}.'.db' );
- push @{$rh{dat}}, [$brd{"$_.isboard"} ? -1 : $_,
- $brd{"$_.brdname"},
- $brd{"$_.title"},
+ push @{$rh{dat}}, [$brdlist{"$_.isboard"} ? -1 : $_,
+ $brdlist{"$_.brdname"},
+ $brdlist{"$_.title"},
];
}
my $path = '';
foreach( $ENV{PATH_INFO} =~ m|(\w+)|g ){
push @{$rh{class}}, {path => "$path/$_/",
- title => $brd{"$_.title"}};
+ title => $brdlist{"$_.title"}};
$path .= "/$_";
}
$rh{exttitle} = ($rh{class} ?
@@ -79,7 +81,9 @@ sub main
EVAL_PERL => 0,
COMPILE_EXT => '.tmpl',
COMPILE_DIR => $MANCACHE,
- });
+ })
+ if( !$tmpl );
+
if( !$rh{gb} ){
$tmpl->process('index.html', \%rh);
}
@@ -89,7 +93,6 @@ sub main
b2g::big5togb($output);
print $output;
}
- untie %brd;
}
main();