From a98681b49db302d4ed6e1b027c02aa7e3426c91a Mon Sep 17 00:00:00 2001 From: in2 Date: Fri, 30 May 2003 10:17:34 +0000 Subject: outputfilter git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@911 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- blog/blog.pl | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'blog') diff --git a/blog/blog.pl b/blog/blog.pl index 69e039b1..af2112fa 100755 --- a/blog/blog.pl +++ b/blog/blog.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: blog.pl,v 1.8 2003/05/26 04:01:40 in2 Exp $ +# $Id: blog.pl,v 1.9 2003/05/30 10:17:34 in2 Exp $ use CGI qw/:standard/; use LocalVars; use DB_File; @@ -214,21 +214,11 @@ sub AddArticle($$$) { my($cl, $fields, $s) = @_; my($content, $short) = (); - if( $fields =~ /content/i ){ - $content = $article{"$s.content"}; - if( $config{outputfilter} == 1 ){ - $content =~ s/\/>/gs; - $content =~ s/\"/"/gs; - $content =~ s/\n/
\n/gs; - } - } - if( $fields =~ /short/i ){ - $short = $article{"$s.short"}; - if( $config{outputfilter} == 1 ){ - $short =~ s/\n/
\n/gs; - } - } + $content = applyfilter($article{"$s.content"}, $config{outputfilter}) + if( $fields =~ /content/i ); + + $short = applyfilter($article{"$s.short"}, $config{outputfilter}) + if( $fields =~ /short/i ); my($y, $m, $d) = unpackdate($s); push @{$th{$cl}}, {year => $y, @@ -247,6 +237,28 @@ sub AddArticle($$$) if( $article{"$s.title"} ); } +sub applyfilter($$) +{ + my($c, $filter) = @_; + foreach( split(',', $filter) ){ + if( /^generic$/i ){ + $c =~ s/\/>/gs; + $c =~ s/\"/"/gs; + $c =~ s/\n/
\n/gs; + } + elsif( /^ubb$/i ){ + $c =~ s|\[url\](.*?)\[/url\]|\1|gsi; + $c =~ s|\[url=(.*?)\](.*?)\[/url\]|\2|gsi; + $c =~ s|\[email\](.*?)\[/email\]|\1|gsi; + $c =~ s|\[b\](.*?)\[/b\]|\1|gsi; + $c =~ s|\[i\](.*?)\[/i\]|\1|gsi; + $c =~ s|\[img\](.*?)\[/img\]||gsi; + } + } + return $c; +} + sub parsefn($) { my($fs) = @_; -- cgit v1.2.3