summaryrefslogtreecommitdiffstats
path: root/blog
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-05-30 18:17:34 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-05-30 18:17:34 +0800
commita98681b49db302d4ed6e1b027c02aa7e3426c91a (patch)
treeea47a9f22763ec72305c1c5ec33661bc67e23357 /blog
parentb379ddf207772646081016cb0580c1168e4d68a7 (diff)
downloadpttbbs-a98681b49db302d4ed6e1b027c02aa7e3426c91a.tar
pttbbs-a98681b49db302d4ed6e1b027c02aa7e3426c91a.tar.gz
pttbbs-a98681b49db302d4ed6e1b027c02aa7e3426c91a.tar.bz2
pttbbs-a98681b49db302d4ed6e1b027c02aa7e3426c91a.tar.lz
pttbbs-a98681b49db302d4ed6e1b027c02aa7e3426c91a.tar.xz
pttbbs-a98681b49db302d4ed6e1b027c02aa7e3426c91a.tar.zst
pttbbs-a98681b49db302d4ed6e1b027c02aa7e3426c91a.zip
outputfilter
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@911 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'blog')
-rwxr-xr-xblog/blog.pl44
1 files changed, 28 insertions, 16 deletions
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/\</&lt;/gs;
- $content =~ s/\>/&gt;/gs;
- $content =~ s/\"/&quot;/gs;
- $content =~ s/\n/<br \/>\n/gs;
- }
- }
- if( $fields =~ /short/i ){
- $short = $article{"$s.short"};
- if( $config{outputfilter} == 1 ){
- $short =~ s/\n/<br \/>\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/\</&lt;/gs;
+ $c =~ s/\>/&gt;/gs;
+ $c =~ s/\"/&quot;/gs;
+ $c =~ s/\n/<br \/>\n/gs;
+ }
+ elsif( /^ubb$/i ){
+ $c =~ s|\[url\](.*?)\[/url\]|<a href='http://\1'>\1</a>|gsi;
+ $c =~ s|\[url=(.*?)\](.*?)\[/url\]|<a href='http://\1'>\2</a>|gsi;
+ $c =~ s|\[email\](.*?)\[/email\]|<a href='mailto:\1'>\1</a>|gsi;
+ $c =~ s|\[b\](.*?)\[/b\]|<b>\1</b>|gsi;
+ $c =~ s|\[i\](.*?)\[/i\]|<i>\1</i>|gsi;
+ $c =~ s|\[img\](.*?)\[/img\]|<img src='\1'>|gsi;
+ }
+ }
+ return $c;
+}
+
sub parsefn($)
{
my($fs) = @_;