From 1880cc2f73e5094ee203416552493f783ed24258 Mon Sep 17 00:00:00 2001 From: in2 Date: Sat, 5 Jul 2003 05:19:18 +0000 Subject: gb support git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1022 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- staticweb/man.pl | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'staticweb/man.pl') diff --git a/staticweb/man.pl b/staticweb/man.pl index 28d21ae0..0baa69be 100755 --- a/staticweb/man.pl +++ b/staticweb/man.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: man.pl,v 1.4 2003/07/04 05:58:45 in2 Exp $ +# $Id: man.pl,v 1.5 2003/07/05 05:19:18 in2 Exp $ use CGI qw/:standard/; use lib qw/./; use LocalVars; @@ -11,7 +11,8 @@ use Template; use HTML::Calendar::Simple; use OurNet::FuzzyIndex; use Data::Serializer; -use vars qw/%db $brdname $fpath/; +use Encode; +use vars qw/%db $brdname $fpath $isgb/; sub main { @@ -26,6 +27,7 @@ sub main return; } + $isgb = (param('gb') ? 1 : 0); charset(''); print header(); @@ -41,21 +43,34 @@ sub main RELATIVE => 0, RECURSION => 0, EVAL_PERL => 0, - COMPILE_EXT => '.tmpl', - COMPILE_DIR => $MANCACHE}); +# COMPILE_EXT => '.tmpl', +# COMPILE_DIR => $MANCACHE, + }); + if( $rh->{gb} = $isgb ){ + $rh->{encoding} = 'gb2312'; + $rh->{lang} = 'zh_CN'; + $rh->{charset} = 'gb2312'; + } + else{ + $rh->{encoding} = 'Big5'; + $rh->{lang} = 'zh_TW'; + $rh->{charset} = 'big5'; + } $tmpl->process($rh->{tmpl}, $rh); } sub dirmode { - my(%th); + my(%th, $isdir); my $serial = Data::Serializer->new(serializer => 'Storable', digester => 'MD5', compress => 0, ); foreach( @{$serial->deserialize($db{$fpath})} ){ - push @{$th{dat}}, {isdir => (($_->[0] =~ m|/$|) ? 1 : 0), - fn => "/man.pl/$brdname$_->[0]", + Encode::from_to($_->[1], 'big5', 'gb2312') if( $isgb ); + $isdir = (($_->[0] =~ m|/$|) ? 1 : 0); + push @{$th{dat}}, {isdir => $isdir, + fn => "man.pl/$brdname$_->[0]", title => $_->[1]}; } @@ -71,7 +86,7 @@ sub articlemode $th{content} = $db{$fpath}; $th{content} =~ s/\033\[.*?m//g; - $th{content} =~ s|(http://[\w\-\.\:\/\,@]+)|$1|gs; + $th{content} =~ s|(http://[\w\-\.\:\/\,@\?=]+)|$1|gs; $th{content} =~ s|(ftp://[\w\-\.\:\/\,@]+)|$1|gs; $th{content} =~ s|§å½ð½ð¨ß|§å½ð½ð¨ß|gs; @@ -81,6 +96,8 @@ sub articlemode s|ptt\.csie\.ntu\.edu\.tw|ptt.csie.ntu.edu.tw|gs; $th{content} =~ s|ptt\.twbbs\.org|ptt.twbbs.org|gs; + + Encode::from_to($th{content}, 'big5', 'gb2312') if( $isgb ); return \%th; } -- cgit v1.2.3