###############################################################################
# YaBBC.pl #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.1 #
# Released: November 8, 2005 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2005 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com #
# Your source for web hosting, web design, and domains. #
###############################################################################
$yabbcplver = 'YaBB 2.1 $Revision: 1.22 $';
if ($action eq 'detailedversion') { return 1; }
LoadLanguage("Post");
$yyYaBBCloaded = 1;
sub decode_direction {
$_ = $_[0];
$_ =~ s~left~270~ig;
$_ =~ s~right~90~ig;
$_ =~ s~top~0~ig;
$_ =~ s~bottom~180~ig;
$_ =~ s~topright~45~ig;
$_ =~ s~bottomright~135~ig;
$_ =~ s~bottomleft~225~ig;
$_ =~ s~topleft~315~ig;
return $_;
}
sub validwidth { return ($_[0] > 400 ? 400 : $_[0]); }
sub MakeSmileys {
$message =~ s/\[smilie=(\S+\.(gif|jpg|png|bmp))\]/\
/isg;
$message =~ s/\[smiley=(\S+\.(gif|jpg|png|bmp))\]/\
/isg;
$message =~ s/(\W|\A)\;\)/$1\
/g;
$message =~ s/(\W|\A)\;\-\)/$1\
/g;
$message =~ s/(\W|\A)\;D/$1\
/g;
$message =~ s/\Q:'(\E/\
/g;
$message =~ s/(\W|\A)\:\-\//$1\
/g;
$message =~ s/\Q:-X\E/\
/g;
$message =~ s/\Q:-[\E/\
/g;
$message =~ s/\Q:-*\E/\
/g;
$message =~ s/\Q>:(\E/\
/g;
$message =~ s/\Q::)\E/\
/g;
$message =~ s/\Q:P\E/\
/g;
$message =~ s/\Q:)\E/\
/g;
$message =~ s/\Q:-)\E/\
/g;
$message =~ s/\Q:D\E/\
/g;
$message =~ s/\Q:-(\E/\
/g;
$message =~ s/\Q:(\E/\
/g;
$message =~ s/\Q:o\E/\
/gi;
$message =~ s/\Q8-)\E/\
/g;
$message =~ s/\Q:-?\E/\
/g;
$message =~ s/\Q^_^\E/\
/g;
$message =~ s/\Q:thumb:\E/\
/g;
$message =~ s/\Q>:-D\E/\
/g;
$count = 0;
while ($SmilieURL[$count]) {
if ($SmilieURL[$count] =~ /\//i) { $tmpurl = $SmilieURL[$count]; }
else { $tmpurl = qq~$defaultimagesdir/$SmilieURL[$count]~; }
$tmpcode = $SmilieCode[$count];
$tmpcode =~ s/$/\$/g;
$tmpcode =~ s/@/\@/g;
$message =~ s/\Q$tmpcode\E/\
/g;
$count++;
}
}
$MAXIMGWIDTH = 400;
$MAXIMGHEIGHT = 500;
sub restrictimage {
my ($w, $h, $s) = @_;
$w = $w <= $MAXIMGWIDTH ? $w : $MAXIMGWIDTH;
$h = $h <= $MAXIMGHEIGHT ? $h : $MAXIMGHEIGHT;
return qq~
~;
}
sub quotemsg {
my ($noquot, $qauthor, $qlink, $qdate, $qmessage) = @_;
if ($qauthor) {
$qmessage =~ s~\/me\s+(.*?)(\n|\Z)(.*?)~* $qauthor $1$2$3~ig;
}
$qmessage = &parseimgflash($qmessage);
$qdate = &timeformat($qdate);
if ($action ne "imshow") { $_ = $post_txt{'600'}; }
if ($qauthor eq "" || $qlink eq "" || $qdate eq "") { $_ = $post_txt{'601'}; }
else { $_ = $post_txt{'599'}; }
$_ =~ s~AUTHOR~$qauthor~g;
$_ =~ s~QUOTELINK~$scripturl?num=$qlink~g;
$_ =~ s~DATE~$qdate~g;
$_ =~ s~QUOTE~$qmessage~g;
$cnvmessage = qq~$noquot$_~;
return $cnvmessage;
}
sub nstquotemsg {
$nstmessage = $_[0];
$nstmessage =~ s~(.*)\[quote+(\s+author=(.*?)\s*link=(.*?)\s+date=(.*?)\s*)?\]\n*(.*?)\n*\[/quote\]~"emsg($1,$3,$4,$5,$6)~eisg;
return $nstmessage;
}
sub parseimgflash {
my $tmp_message = $_[0];
my $char_160 = '';
$tmp_message =~ s~\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]~$display_txt{'769'} ($1 x $2): >$3~g;
$char_160 = chr(160);
$hardspace = qq~ ~;
$tmp_message =~ s~\ \;~~g;
$tmp_message =~ s~\[img\](?:\s|\t|\n|$hardspace|$char_160)*(http\:\/\/)*(.+?)(?:\s|\t|\n|$hardspace|$char_160)*\[/img\]~http\:\/\/$2~isg;
$tmp_message =~ s~\[img width=(\d+) height=(\d+)\](?:\s|\t|\n|$hardspace|$char_160)*(http\:\/\/)*(.+?)(?:\s|\t|\n|$hardspace|$char_160)*\[\/img\]~http:\/\/$4~ig;
return $tmp_message;
}
sub sizefont {
## limit minimum and maximum font pitch as CSS does not restrict it at all. ##
my ($tsize, $ttext) = @_;
if (!$fontsizemax) { $fontsizemax = 72; }
if (!$fontsizemin) { $fontsizemin = 6; }
if ($tsize < $fontsizemin) { $tsize = $fontsizemin; }
elsif ($tsize > $fontsizemax) { $tsize = $fontsizemax; }
my $resized = qq~$ttext~;
return $resized;
}
{
my %killhash = (
';' => ';',
'!' => '!',
'(' => '(',
')' => ')',
'-' => '-',
'.' => '.',
'/' => '/',
':' => ':',
'?' => '?',
'[' => '[',
'\\' => '\',
']' => ']',
'^' => '^');
sub codemsg {
my $code = $_[0];
&ToChars($code);
if ($code !~ /&\S*;/) { $code =~ s/;/;/g; }
$code =~ s~([\(\)\-\:\\\/\?\!\]\[\.\^])~$killhash{$1}~g;
$code =~ s~\&\#91\;highlight\&\#93\;(.*?)\&\#91\;\&\#47\;highlight\&\#93\;~$1~isg;
$_ = $post_txt{'602'};
# Thx. to Michael Prager for the improved Code boxes
# count lines in code
$linecount = () = $code =~ /\n/g;
# if more that 20 lines then limit code box height
if ($linecount > 20) {
$height = "height: 300px;";
} else {
$height = "";
}
# try to display text as it was originally intended
$code =~ s~ \ \ \ ~\t~ig;
$code =~ s~\ ~ ~ig;
$code =~ s~ ?\n ?~\[code_br\]~ig; # we need to keep normal linebreaks inside
tag
$code = qq~$code\[code_br\][code_br\]
~;
$_ =~ s~CODE~$code~g;
return $_;
}
}
sub killimgurls {
$_ = $_[0];
$_ =~ s~\[url(.*?)\](.*?)\[\/url\]~~ig;
$_ =~ s~\[link(.*?)\](.*?)\[\/link\]~~ig;
$_ =~ s~http\:\/\/~~ig;
return $_;
}
sub DoUBBC {
$message =~ s~\[code\]~ \[code\]~ig;
$message =~ s~\[/code\]~ \[/code\]~ig;
$message =~ s~\[quote\]~ \[quote\]~ig;
$message =~ s~\[/quote\]~ \[/quote\]~ig;
$message =~ s~\[img\]~ \[img\]~ig;
$message =~ s~\[img(.*?)\](.*?)\[/img\]~qq^[img$1\]^ . &killimgurls($2) . q^[/img]^~eisg;
$message =~ s~\[glow\]~ \[glow\]~ig;
$message =~ s~\[/glow\]~ \[/glow\]~ig;
$message =~ s~
~\n~ig;
$message =~ s~
~\n~ig;
$message =~ s~\[code\]\n*(.+?)\n*\[/code\]~&codemsg($1)~eisg;
if ($message =~ /\#nosmileys/isg || $ns =~ "NS") { $message =~ s/\#nosmileys//isg; }
else { &MakeSmileys; }
$message =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g;
$message =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g;
$message =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g;
$message =~ s~\[b\](.*?)\[/b\]~$1~isg;
$message =~ s~\[i\](.*?)\[/i\]~$1~isg;
$message =~ s~\[u\](.*?)\[/u\]~$1~isg;
$message =~ s~\[s\](.*?)\[/s\]~$1~isg;
$message =~ s~\[glb\](.*?)\[/glb\]~$1~isg;
$message =~ s~\[move\](.*?)\[/move\]~~isg;
while ($message =~ s~(\[quote+(\s+author=(.*?)link=(.*?)\s+date=(.*?)\s*)?\]\n*(.*?)\n*\[/quote\])~&nstquotemsg($1)~eisg) { }
$hardspace = qq~ ~;
$char_160 = chr(160);
$message =~ s~\[img\](?:\s|\t|\n|$hardspace|$char_160)*(http\:\/\/)*(.+?)(?:\s|\t|\n|$hardspace|$char_160)*\[/img\]~
~isg;
$message =~ s~\[img width=(\d+) height=(\d+)\](?:\s|\t|\n|$hardspace|$char_160)*(http\:\/\/)*(.+?)(?:\s|\t|\n|$hardspace|$char_160)*\[/img\]~restrictimage($1,$2,'http://'.$4)~eisg;
$message =~ s~\[color=(.+?)\](.+?)\[/color\]~$2~isg;
$message =~ s~\[black\](.*?)\[/black\]~$1~isg;
$message =~ s~\[white\](.*?)\[/white\]~$1~isg;
$message =~ s~\[red\](.*?)\[/red\]~$1~isg;
$message =~ s~\[green\](.*?)\[/green\]~$1~isg;
$message =~ s~\[blue\](.*?)\[/blue\]~$1~isg;
$message =~ s~\[edit\](.*?)\[/edit\]~$post_txt{'603'}:
$1
~isg;
$message =~ s~\[timestamp\=([\d]{9,10})\]~&timeformat($1)~eisg;
$message =~ s~\[moved\]~$maintxt{'160'}~;
$message =~ s~\[move by\]~$maintxt{'525'}~;
$message =~ s~\[font=(.+?)\](.+?)\[/font\]~$2~isg;
while ($message =~ s~\[size=(.+?)\](.+?)\[/size\]~&sizefont($1,$2)~eisg) { }
$message =~ s~\[tt\](.*?)\[/tt\]~$1~isg;
$message =~ s~\[left\](.*?)\[/left\]~$1
~isg;
$message =~ s~\[center\](.*?)\[/center\]~$1~isg;
$message =~ s~\[right\](.*?)\[/right\]~$1
~isg;
$message =~ s~\[justify\](.*?)\[/justify\]~$1
~isg;
$message =~ s~\[sub\](.*?)\[/sub\]~$1~isg;
$message =~ s~\[sup\](.*?)\[/sup\]~$1~isg;
$message =~ s~\[fixed\](.*?)\[/fixed\]~$1~isg;
$message =~ s~\[hr\]\n~
~g;
$message =~ s~\[hr\]~
~g;
$message =~ s~\[br\]~\n~ig;
$message =~ s~\s$YaBBversion\s~ \$YaBBversion Forum Software\<\/a\> ~g;
if ($autolinkurls) {
$message =~ s~">~">~g;
$message =~ s~\[url\](.+?)\[\/url\]~$1 ~g;
$message =~ s~([^\w\"\=\[\]]|[\n\b]|\[quote.*?\]|\[highlight\]|\[\*\]|\[td\]|\A)\\*(\w+?\:\/\/(?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\x80-\xFF]{1,})+?)(\.\)\s|\)\.\s|\"\;\)\s|\<\/|\[\/|\[\*)~$1\[url\=$2\]$2\[\/url\]$3~isg;
$message =~ s~([^\w\"\=\[\]]|[\n\b]|\[quote.*?\]|\[highlight\]|\[\*\]|\[td\]|\A)\\*(\w+?\:\/\/(?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\x80-\xFF]{1,})+?)(\.\s|\)\s|\"\;\s)~$1\[url\=$2\]$2\[\/url\]$3~isg;
$message =~ s~([^\w\"\=\[\]]|[\n\b]|\[quote.*?\]|\[highlight\]|\[\*\]|\[td\]|\A)\\*(\w+?\:\/\/(?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\x80-\xFF]{1,})+?)(\s)~$1\[url\=$2\]$2\[\/url\]$3~isg;
$message =~ s~([^\"\=\[\]/\:\.(\://\w+)]|[\n\b]|\[quote.*?\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\x80-\xFF]{1,})+?)(\.\)\s|\)\.\s|\"\;\)\s|\<\/|\[\/|\[\*)~$1\[url\=$2\]$2\[\/url\]$3~isg;
$message =~ s~([^\"\=\[\]/\:\.(\://\w+)]|[\n\b]|\[quote.*?\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\x80-\xFF]{1,})+?)(\.\s|\)\s|\"\;\s)~$1\[url\=$2\]$2\[\/url\]$3~isg;
$message =~ s~([^\"\=\[\]/\:\.(\://\w+)]|[\n\b]|\[quote.*?\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\x80-\xFF]{1,})+?)(\s)~$1\[url\=$2\]$2\[\/url\]$3~isg;
}
if ($action eq "search2") {
$message =~ s~\[(url|link|email)\](.*?)\[/\1\]~\[$1=$2\]$2\[/$1\]~ig;
$message =~ s~\[(news|gopher|ftp|flash|img)(.*?)\](.*?)\[/\1\]~\[$1$2 tmp=$3\](.*?)\[/$1\]~ig;
foreach $tmp (@search) {
if ($searchtype == 4) { $message =~ s~(\Q$tmp\E)~\[shighlight\]$1\[/shighlight\]~ig; }
else { $message =~ s~(^|\W|_)(\Q$tmp\E)(?=$|\W|_)~$1\[shighlight\]$2\[/shighlight\]$3~ig; }
}
$tmp = 1;
while ($tmp) {
$message =~ s~\[([^\]]*?)\[/?shighlight(.*?)\]~\[$1~ig;
if ($message !~ m~\[([^\]]*?)\[/?shighlight(.*?)\]~i) { $tmp = 0; }
}
$message =~ s~\[(news|gopher|ftp|flash|img)(.*?) tmp=(.*?)\](.*?)\[/\1\]~\[$1$2\]$3\[/$1\]~ig;
}
if ($stealthurl) {
$message =~ s~\[url\]www\.\s*(.+?)\s*\[/url\]~www.$1~isg;
$message =~ s~\[url=\s*(\w+\://.+?)\](.+?)\s*\[/url\]~$2~isg;
$message =~ s~\[url=\s*(.+?)\]\s*(.+?)\s*\[/url\]~$2~isg;
$message =~ s~\[url\]\s*(.+?)\s*\[/url\]~$1~isg;
$message =~ s~\[link\]www\.\s*(.+?)\s*\[/link\]~www.$1~isg;
$message =~ s~\[link=\s*(\w+\://.+?)\](.+?)\s*\[/link\]~$2~isg;
$message =~ s~\[link=\s*(.+?)\]\s*(.+?)\s*\[/link\]~$2~isg;
$message =~ s~\[link\]\s*(.+?)\s*\[/link\]~$1~isg;
$message =~ s~\[ftp\]\s*(.+?)\s*\[/ftp\]~$1~isg;
} else {
$message =~ s~\[url\]\s*www\.(\S+?)\s*\[/url\]~www.$1~isg;
$message =~ s~\[url=\s*(\S\w+\://\S+?)\s*\](.+?)\[/url\]~$2~isg;
$message =~ s~\[url=\s*(\S+?)\](.+?)\s*\[/url\]~$2~isg;
$message =~ s~\[url\]\s*(http://)?(\S+?)\s*\[/url\]~$1$2~isg;
$message =~ s~\[link\]\s*www\.(\S+?)\s*\[/link\]~www.$1~isg;
$message =~ s~\[link=\s*(\S\w+\://\S+?)\s*\](.+?)\[/link\]~$2~isg;
$message =~ s~\[link=\s*(\S+?)\](.+?)\s*\[/link\]~$2~isg;
$message =~ s~\[link\]\s*(\S+?)\s*\[/link\]~$1~isg;
$message =~ s~\[ftp\]\s*(ftp://)?(.+?)\s*\[/ftp\]~$1$2~isg;
}
$message =~ s~(dereferer\;url\=http\:\/\/.*?)#(\S+?\")~$1;anch=$2~isg;
$message =~ s~\[email\]\s*(\S+?\@\S+?)\s*\[/email\]~$1~isg;
$message =~ s~\[email=\s*(\S+?\@\S+?)\](.*?)\[/email\]~$2~isg;
$message =~ s~\[news\](\S+?)\[/news\]~$1~isg;
$message =~ s~\[gopher\](\S+?)\[/gopher\]~$1~isg;
$message =~ s~\[highlight\](.*?)\[/highlight\]~$1~isg;
$message =~ s~\[shighlight\](.*?)\[/shighlight\]~$1~isg;
$message =~ s~\/me\s+(.*)~* $displayname $1~ig;
$message =~ s~\[\*\]~
~isg;
$message =~ s~\[olist\]~~isg;
$message =~ s~\[/olist\]~
~isg;
$message =~ s~~~isg;
$message =~ s~~~isg;
$message =~ s~\[\*\]~- ~isg;
$message =~ s~\[list\]~
~isg;
$message =~ s~\[/list\]~
~isg;
$message =~ s~~~isg;
$message =~ s~~~isg;
$message =~ s~\[pre\](.+?)\[/pre\]~'
' . dopre($1) . '
'~iseg;
if ($parseflash == 1) {
if ($message =~ /\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]/) {
$width = $1;
$height = $2;
if ($3 =~ /http:\/\/(\S+?).swf/) {
if ($width > 500) { $width = 500; }
if ($height > 500) { $height = 500; }
$message =~ s~\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]~~g;
}
}
} else {
if ($message =~ /\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]/) {
if ($3 =~ /http:\/\/(\S+?).swf/) {
if ($stealthurl) {
$message =~ s~\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]~$display_txt{'769'} ($1 x $2): >$3~;
} else {
$message =~ s~\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]~$display_txt{'769'} ($1 x $2): >$3~;
}
}
}
}
if ($message =~ /\[mov\=(\S+?),(\S+?)](\S+?)\[\/mov\]/) {
if ($3 =~ /http:\/\/(\S+?).mov/) {
if ($stealthurl) { $message =~ s~\[mov\=(\S+?),(\S+?)](\S+?)\[\/mov\]/~$display_txt{'769'} ($1 x $2): >$3~;
} else {
$message =~ s~\[mov\=(\S+?),(\S+?)](\S+?)\[\/mov\]~$display_txt{'769'} ($1 x $2): >$3~;
}
}
}
}
if ($message =~ m~\[table\](?:.*?)\[/table\]~is) {
while ($message =~ s~~~s) { }
while ($message =~ s~(.*?)\[/table\]~$3\[//table\]~s) { }
while ($message =~ s~\[table\](.*?)~\[//table\]$1~s) { }
$message =~ s~\n{0,1}\[table\]\n*(.+?)\n*\[/table\]\n{0,1}~~isg;
while ($message =~ s~\(.*?)\n*\[tr\]\n*(.*?)\n*\[/tr\]\n*(.*?)\
~~is) { }
while ($message =~ s~\(.*?)\n*\[td\]\n{0,1}(.*?)\n{0,1}\[/td\]\n*(.*?)\
~$1$2 | $3
~is) { }
$message =~ s~((?:(?!|
|| | |).)*)~~isg;
$message =~ s~
((?:(?!
|
|| | |).)*)~ | ~isg;
$message =~ s~ | ((?:(?!
|
|| | |).)*)~ | ~isg;
$message =~ s~ | ((?:(?!|
|| | |).)*)~~isg;
$message =~ s~((?!|
|| | |).*?)~ | ~isg;
$message =~ s~ | ((?!|
|| | |).*?)~~isg;
$message =~ s~((?:(?!|
|| | |).)*)~
~isg;
$message =~ s~
((?:(?!|
|| | |).)*)
~
~isg;
}
while ($message =~ s~]*?)\n([^>]*)>~~) { }
while ($message =~ s~]*)>([^<]*?)\n([^<]*)~$2$3~) { }
while ($message =~ s~]*?)&([^>]*)>~~) { }
while ($message =~ s~
]*?)\n([^>]*)>~
~) { }
while ($message =~ s~
]*?)&([^>]*)>~
~) { }
$message =~ s~\[\&table(.*?)\]~~g;
$message =~ s~\[/\&table\]~
~g;
$message =~ s~\n~
~ig;
$message =~ s~\[code_br\]~\n~ig;
}
sub DoUBBCTo {
# Does UBBC to $_[0] using &DoUBBC and keeps $message the same
my($messagecopy, $returnthis);
$messagecopy = $message;
$message = $_[0];
&DoUBBC;
$returnthis = $message;
$message = $messagecopy;
return $returnthis;
}
1;