summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--staticweb/article.html2
-rw-r--r--staticweb/dir.html8
-rw-r--r--staticweb/header.html2
-rw-r--r--staticweb/index.html4
-rwxr-xr-xstaticweb/index.pl41
-rwxr-xr-xstaticweb/man.pl27
6 files changed, 44 insertions, 40 deletions
diff --git a/staticweb/article.html b/staticweb/article.html
index 1386c3d6..8c1a8260 100644
--- a/staticweb/article.html
+++ b/staticweb/article.html
@@ -10,7 +10,7 @@
</td></tr><tr><td>
<hr>
<a href="./[% IF gb %]?gb=1[% END %]"></a><br />
-<a href="telnet://ptt.cc">у金金龟穨</a> (<a href="http://ptt.cc">PttWeb</a>)
+<a href="http://ptt.cc">у金金龟穨</a>
</td></tr>
</table>
diff --git a/staticweb/dir.html b/staticweb/dir.html
index 557438cc..071cac22 100644
--- a/staticweb/dir.html
+++ b/staticweb/dir.html
@@ -5,10 +5,10 @@
</td></tr>
<tr><td>
-<a href="http://man.ptt.cc/[% IF gb %]?gb=1[% END %]">呼弘地跋</a>
-<a href="http://webbbs.ptt.cc/[% brdname %]/DIR.html">[% brdname %]狾</a>
+<a href="http://[% IF gb %]gb[% END %]www.ptt.cc">у金金龟穨</a> |
+<a href="http://man.ptt.cc/[% IF gb %]?gb=1[% END %]">呼弘地跋</a> |
+<a href="http://webbbs.ptt.cc/[% brdname %]/DIR.html">[% brdname %]狾</a> |
<a href="http://man.ptt.cc/man.pl/[% brdname %]/[% IF gb %]?gb=1[% END %]">[% brdname %]弘地跋</a>
-<a href="http://blog.ptt.cc">у金金场辅(big5 only)</a>
<br />
<font size=+1>狾嘿: <a href="/man.pl/[% brdname %]/">[% brdname %]</a></font>
<hr />
@@ -36,7 +36,7 @@
[% END %]
<hr />
<font size="-1">籹丁: [% buildtime %]</font><br>
-<a href="telnet://ptt.cc">у金金龟穨</a> (<a href="http://ptt.cc">PttWeb</a>)
+<a href="http://ptt.cc">у金金龟穨</a>
</td></tr>
</table>
</body>
diff --git a/staticweb/header.html b/staticweb/header.html
index 5dc7161b..112efd70 100644
--- a/staticweb/header.html
+++ b/staticweb/header.html
@@ -10,6 +10,6 @@
content="text/html; charset=[% charset %]">
<meta name="generator" content="pttMan" />
<meta name="robots" content="all" />
- <link rel="stylesheet" href="http://pttx.ptt.cc:4099/ptt.man/styles.css" type="text/css" />
+ <link rel="stylesheet" href="http://pttx.ptt.cc:4099/staticpage/ptt.man.styles.css" type="text/css" />
</head>
<body>
diff --git a/staticweb/index.html b/staticweb/index.html
index e13f7d2d..c0c87174 100644
--- a/staticweb/index.html
+++ b/staticweb/index.html
@@ -5,7 +5,7 @@
</td></tr>
<tr><td>
-<a href="http://man.ptt.cc/index.pl/[% IF gb %]?gb=1[% END %]">у金金龟穨ぇ弘地跋</a>
+<a href="http://www.ptt.cc">у金金龟穨</a> &raquo; <a href="http://man.ptt.cc/index.pl/[% IF gb %]?gb=1[% END %]">у金金龟穨ぇ弘地跋</a>
[% FOREACH x=class %]
&raquo;<a href="/index.pl[% x.path %]">[% x.title %]</a>
[% END %]
@@ -40,7 +40,7 @@
</td></tr>
<tr><td>
<hr />
-<a href="telnet://ptt.cc">у金金龟穨</a> (<a href="http://ptt.cc">PttWeb</a>)
+<a href="http://ptt.cc">у金金龟穨</a>
</td></tr>
</table>
</body>
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();
diff --git a/staticweb/man.pl b/staticweb/man.pl
index 661013fc..b77fcd03 100755
--- a/staticweb/man.pl
+++ b/staticweb/man.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# $Id$
-use CGI qw/:standard/;
+use CGI qw/:cgi :html2/;
use lib qw/./;
use LocalVars;
use DB_File;
@@ -14,15 +14,16 @@ use b2g;
use POSIX;
use Compress::Zlib;
-use vars qw/%db $brdname $fpath $isgb %b2g/;
+use vars qw/%db $brdname $fpath $isgb $tmpl/;
sub main
{
- my($tmpl, $rh, $key);
+ my($rh, $key) = ();
if( !(($brdname, $fpath) = $ENV{PATH_INFO} =~ m|^/([\w\-]+?)(/.*)|) ||
- !(tie %db, 'DB_File',
- "$MANDATA/$brdname.db", O_RDONLY, 0666, $DB_HASH) ){
+ (!exists $db{$brdname} &&
+ !tie %{$db{$brdname}}, 'DB_File',
+ "$MANDATA/$brdname.db", O_RDONLY, 0666, $DB_HASH) ){
return redirect("/man.pl/$1/")
if( $ENV{PATH_INFO} =~ m|^/([\w\-]+?)$| );
print header(-status => 404);
@@ -48,7 +49,9 @@ sub main
EVAL_PERL => 0,
COMPILE_EXT => '.tmpl',
COMPILE_DIR => $MANCACHE,
- });
+ })
+ if( !$tmpl );
+
if( $rh->{gb} = $isgb ){
$rh->{encoding} = 'gb2312';
$rh->{lang} = 'zh-CN';
@@ -69,8 +72,6 @@ sub main
b2g::big5togb($output);
print $output;
}
-
- untie %db;
}
sub dirmode
@@ -80,7 +81,7 @@ sub dirmode
digester => 'MD5',
compress => 0,
);
- foreach( @{$serial->deserialize($db{$fpath}) || []} ){
+ foreach( @{$serial->deserialize($db{$brdname}{$fpath}) || []} ){
$isdir = (($_->[0] =~ m|/$|) ? 1 : 0);
push @{$th{dat}}, {isdir => $isdir,
fn => "man.pl/$brdname$_->[0]",
@@ -89,7 +90,7 @@ sub dirmode
$th{tmpl} = 'dir.html';
$th{isroot} = ($fpath eq '/') ? 1 : 0;
- $th{buildtime} = POSIX::ctime($db{_buildtime} || 0);
+ $th{buildtime} = POSIX::ctime($db{$brdname}{_buildtime} || 0);
return \%th;
}
@@ -99,9 +100,9 @@ sub articlemode
$th{tmpl} = 'article.html';
# ㄓ unzip, 璶ぃ礛穦年奔 :p
- $th{content} = $db{$fpath};
+ $th{content} = $db{$brdname}{$fpath};
$th{content} = Compress::Zlib::memGunzip($th{content})
- if( $db{_gzip} );
+ if( $db{$brdname}{_gzip} );
$th{content} =~ s/\033\[.*?m//g;
@@ -128,7 +129,7 @@ sub search($)
my %result = $idx->query($th{key} = $key, MATCH_FUZZY);
foreach my $t (sort { $result{$b} <=> $result{$a} } keys(%result)) {
$k = $idx->getkey($t);
- push @{$th{search}}, {title => $db{"title-$k"},
+ push @{$th{search}}, {title => $db{$brdname}{"title-$k"},
fn => $k,
score => $result{$t} / 10};
}