############################################################################### # YaBBC.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 2.4 # # Packaged: April 12, 2009 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2009 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.4 $Revision$'; if ($GLOBAL::ACTION eq 'detailedversion') { return 1; } &LoadLanguage('Post'); $yyYaBBCloaded = 1; sub MakeSmileys { my $message = join "", @_; my $i = 0; my @HTMLtags; while ($message =~ s/(<.+?>)/[HTML$i]/s) { push(@HTMLtags, $1); $i++; } $message =~ s/(\W|^)\[smil(ie|ey)=(\S+?\.(gif|jpg|png|bmp))\]/$1$post_txt{'287'}/ig; $message =~ s/(\W|^);-?\)/$1$post_txt{'292'}/g; $message =~ s/(\W|^);D/$1$post_txt{'293'}/g; $message =~ s/(\W|^):'\(/$1$post_txt{'530'}/g; $message =~ s/(\W|^):-\//$1$post_txt{'528'}/g; $message =~ s/(\W|^):-X/$1$post_txt{'527'}/g; $message =~ s/(\W|^):-\[/$1$post_txt{'526'}/g; $message =~ s/(\W|^):-\*/$1$post_txt{'529'}/g; $message =~ s/(\W|^)>:\(/$1$post_txt{'288'}/g; $message =~ s/(\W|^)::\)/$1$post_txt{'450'}/g; $message =~ s/(\W|^):P/$1$post_txt{'451'}/g; $message =~ s/(\W|^):-?\)/$1$post_txt{'287'}/g; $message =~ s/(\W|^):D/$1$post_txt{'289'}/g; $message =~ s/(\W|^):-?\(/$1$post_txt{'291'}/g; $message =~ s/(\W|^):o/$1$post_txt{'294'}/gi; $message =~ s/(\W|^)8-\)/$1$post_txt{'295'}/g; $message =~ s/(\W|^):-\?/$1$post_txt{'296'}/g; $message =~ s/(\W|^)\^_\^/$1$post_txt{'801'}/g; $message =~ s/(\W|^):thumb:/$1$post_txt{'282'}/g; $message =~ s/(\W|^)>:-D/$1$post_txt{'802'}/g; my $count = 0; while ($SmilieURL[$count]) { if ($SmilieURL[$count] =~ /\//i) { $tmpurl = $SmilieURL[$count]; } else { $tmpurl = qq~$imagesdir/$SmilieURL[$count]~; } $tmpcode = $SmilieCode[$count]; $tmpcode =~ s/$/\$/g; $tmpcode =~ s/@/\@/g; $message =~ s~\Q$tmpcode\E~$SmilieDescription[$count]~g; $count++; } $i = 0; while ($message =~ s/\[HTML$i\]/$HTMLtags[$i]/s) { $i++; } return $message; } sub quotemsg { my ($qauthor, $qlink, $qdate, $qmessage) = @_; my ($testauthor,$fqauthor); if ($qauthor) { $usernames_life_quote{'temp_quote_autor'} = $qauthor; # for display names in Quotes in LivePreview &ToChars($qauthor); if (!&checkfor_DBorFILE("$memberdir/$qauthor.vars")) { # if the file is there it is an unencrypted user ID $qauthor = &decloak($qauthor); # if not, decrypt it and see if it is a regged user if (!&checkfor_DBorFILE("$memberdir/$qauthor.vars")) { # if still not found probably the author is a screen name $testauthor = &MemberIndex("who_is", "$qauthor"); # check if this name exists in the memberlist if ($testauthor ne ""){ # if it is, load the user id returned $qauthor = $testauthor; &LoadUser($qauthor); $fqauthor = ${$uid.$qauthor}{'realname'}; # set final author var to the current users screen name } else { $fqauthor = &decloak($qauthor); # if all fails it is a non existing real name so decode and asign as screenname } } else { &LoadUser($qauthor); # after encoding the user ID was found and loaded, setting the current real name $fqauthor = ${$uid.$qauthor}{'realname'}; } } else { &LoadUser($qauthor); # it was an old style user id which could be loaded and screen name set to final author $fqauthor = ${$uid.$qauthor}{'realname'}; } $qmessage =~ s~\/me\s+(.*?)(\n|\Z)(.*?)~* $fqauthor $1$2$3~ig; } # next 2 lines: for display names in Quotes in LivePreview $usernames_life_quote{$usernames_life_quote{'temp_quote_autor'}} = $fqauthor; delete $usernames_life_quote{'temp_quote_autor'}; $qmessage = &parseimgflash($qmessage); $qdate = &timeformat($qdate); # generates also the global variable $daytxt if ($fqauthor eq '' || $qlink eq '' || $qdate eq '') { $_ = $post_txt{'601'}; } elsif ($qlink eq 'impost') { $_ = $daytxt ? $post_txt{'600a_d'} : $post_txt{'600a'}; $_ =~ s~AUTHOR2~$scripturl?action=viewprofile;username=$useraccount{$qauthor}~g; } elsif ($GLOBAL::ACTION ne 'imshow' && $GLOBAL::ACTION ne 'imsend' && $GLOBAL::ACTION ne 'imsend2') { $_ = $daytxt ? $post_txt{'600_d'} : $post_txt{'600'}; } else { $_ = $daytxt ? $post_txt{'599_d'} : $post_txt{'599'}; } $_ =~ s~AUTHOR~$fqauthor~g; $_ =~ s~QUOTELINK~$scripturl?num=$qlink~g; $_ =~ s~DATE~$qdate~g; $_ =~ s~QUOTE~$qmessage~g; $_; } sub parseimgflash { my $tmp_message = $_[0]; $tmp_message =~ s~\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]~$display_txt{'769'} ($1 x $2): >$3~g; my $char_160 = chr(160); my $hardspace = qq~ ~; if (!$showimageinquote) { $tmp_message =~ s~\[img(.+?)\]~[img\]~isg; $tmp_message =~ s~\[img\](?:\s|\t|\n|$hardspace|$char_160)*(http\:\/\/)*(.+?)(?:\s|\t|\n|$hardspace|$char_160)*\[/img\]~\[url\]$1$2\[\/url\]~isg; } $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; } return qq~
$ttext
~; } { my %killhash = ( ';' => ';', '!' => '!', '(' => '(', ')' => ')', '-' => '-', '.' => '.', '/' => '/', ':' => ':', '?' => '?', '[' => '[', '\\' => '\', ']' => ']', '^' => '^', 'D' => 'D' ); sub codemsg { my $code = $_[0]; my $class = $_[1]; my $prclass = ""; if(lc $class eq "c++") { $insclass = "sh_cpp"; $prclass = " (C++)"; } elsif(lc $class eq "css") { $insclass = "sh_css"; $prclass = " (CSS)"; } elsif(lc $class eq "html") { $insclass = "sh_html"; $prclass = " (HTML)"; } elsif(lc $class eq "java") { $insclass = "sh_java"; $prclass = " (Java)"; } elsif(lc $class eq "javascript") { $insclass = "sh_javascript"; $prclass = " (Javascript)"; } elsif(lc $class eq "pascal") { $insclass = "sh_pascal"; $prclass = " (Pascal)"; } elsif(lc $class eq "perl") { $insclass = "sh_perl"; $prclass = " (Perl)"; } elsif(lc $class eq "php") { $insclass = "sh_php"; $prclass = " (PHP)"; } elsif(lc $class eq "sql") { $insclass = "sh_sql"; $prclass = " (SQL)"; } else { $insclass = "code"; } &ToChars($code); if ($code !~ /&\S*;/) { $code =~ s/;/;/g; } $code =~ s~([\(\)\-\:\\\/\?\!\]\[\.\^\.D])~$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~\s*?\n\s*?~\[code_br\]~ig; # we need to keep normal linebreaks inside
 tag
		$code = qq~
$code\[code_br][code_br]
~; $_ =~ s~XLANGX~$prclass~g; $_ =~ s~CODE~$code~g; $_; } sub noparse { my $noubbc = $_[0]; $noubbc =~ s~([\/\]\[\.])~$killhash{$1}~g; $noubbc; } } sub imagemsg { my ($rest,$attribut,$url,$type) = @_; # use or kill urls $url =~ s~\[url\](.*?)\[/url\]~$1~ig; $url =~ s~\[link\](.*?)\[/link\]~$1~ig; $url =~ s~\[url\s*=\s*(.*?)\s*.*?\].*?\[/url\]~$1~ig; $url =~ s~\[link\s*=\s*(.*?)\s*.*?\].*?\[/link\]~$1~ig; $url =~ s~\[url.*?/url\]~~ig; $url =~ s~\[link.*?/link\]~~ig; my $char_160 = chr(160); $url =~ s/\s|\?| |$char_160//g; if ($url !~ /^http.+\.(gif|jpg|jpeg|png|bmp)$/i) {return $rest . $url;} my %parameter; &FromHTML($attribut); $attribut =~ s/(\s|$char_160)+/ /g; foreach (split(/ +/, $attribut)) { my ($key, $value) = split(/=/, $_); $value =~ s/["']//g; $parameter{$key} = $value; } $parameter{'name'} = $type ? 'signat_img_resize' : 'post_img_resize'; $parameter{'alt'} =~ s/[<>"]/*/g; $parameter{'alt'} ||= "..."; $parameter{'align'} =~ s~[^a-z]~~ig; $parameter{'width'} =~ s~\D~~g; $parameter{'height'} =~ s~\D~~g; if ($parameter{'align'}) { $parameter{'align'} = qq~ align="$parameter{'align'}"~; } if ($parameter{'width'}) { $parameter{'width'} = qq~ width="$parameter{'width'}"~; } if ($parameter{'height'}) { $parameter{'height'} = qq~ height="$parameter{'height'}"~; } my $linkedimg = $rest =~ /\[url[^\[]*\]\s*$/i ? 1 : 0; $rest . ((!$linkedimg && $img_greybox) ? qq~~ : '') . qq~$parameter{'alt'}~ . ((!$linkedimg && $img_greybox) ? '' : ''); } sub DoUBBC { my $msg = _do_ubbc($message); $message = $msg; } sub _do_ubbc { my $message = join "", @_; return $message if $ns eq "NS" || $message =~ s/#nosmileys//isg; my $image_type = $_[0]; if($message =~ m{(.*?)\[noparse\](.*)}) { my ($beginning, $temp, $middle, $end) = (undef, undef, undef, undef); ($beginning, $temp) = ($1, $2); if($temp =~ m{(.*?)\[/noparse\](.*)}) { my ($middle, $end) = ($1, $2); return _do_ubbc($beginning).noparse($middle)._do_ubbc($end); } else { return _do_ubbc($beginning).noparse($temp); } } $message =~ s~\[code\]~ \[code\]~ig; $message =~ s~\[/code\]~ \[/code\]~ig; $message =~ s~\[quote\]~ \[quote\]~ig; $message =~ s~\[/quote\]~ \[/quote\]~ig; $message =~ s~\[glow\]~ \[glow\]~ig; $message =~ s~\[/glow\]~ \[/glow\]~ig; $message =~ s~
|
~\n~ig; $message =~ s~\[code\s*(.*?)\]\n*(.+?)\n*\[/code\]~&codemsg($2,$1)~eisg; # [code] must come at first! At least before image transformation! $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\]~$2~isg; # Quote message while ($message =~ s~\[quote(\s+author=(.*?)\s+link=(.*?)\s+date=(.*?)\s*)?\]\n*(.*?)\n*\[/quote\]~ "emsg($2,$3,$4,$5) ~eisg) { } # Images in message. Must come behind "Quote message" due to $showimageinquote in "emsg -> &parseimgflash while ($message =~ s~(\[url[^\[]*\]\s*)?\[img(.*?)\](.*?)\[/img\]~ &imagemsg($1,$2,$3,$image_type) ~eisg) { } $message =~ s~\[color=([A-Za-z0-9# ]+)\](.+?)\[/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~\[timestamp\=([\d]{9,10})\]~&timeformat($1)~eisg; $message =~ s~\[font=([A-Za-z0-9# -]+)\](.+?)\[/font\]~
$2
~isg; while ($message =~ s~\[size=([A-Za-z0-9# ]+)\](.+?)\[/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; $message =~ s~\[highlight\](.*?)\[/highlight\]~$1~isg; sub format_url { my ($txtfirst, $txturl) = @_; my $lasttxt = ""; if ($txturl =~ m~(.*?)(\.|\.\)|\)\.|\!|\!\)|\)\!|\,|\)\,|\)|\;|\"\;|\"\;\.|\.\"\;|\"\;\,|\,\"\;|\"\;\;|\<\/)\Z~) { $txturl = $1; $lasttxt = $2; } my $realurl = $txturl; $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig; $txturl =~ s~\[~[~g; $txturl =~ s~\]~]~g; $txturl =~ s~\<.+?\>~~ig; qq~$txtfirst\[url\=$txturl\]$realurl\[\/url\]$lasttxt~; } sub format_url2 { my ($txturl, $txtlink) = @_; $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig; $txturl =~ s~\<.+?\>~~ig; qq~[url=$txturl]$txtlink\[/url]~; } sub format_url3 { my $txturl = $_[0]; my $txtlink = $txturl; $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig; $txturl =~ s~\[~[~g; $txturl =~ s~\]~]~g; $txturl =~ s~\<.+?\>~~ig; qq~[url=$txturl]$txtlink\[/url]~; } $message =~ s~\[url=\s*(.+?)\s*\]\s*(.+?)\s*\[/url\]~&format_url2($1, $2)~eisg; $message =~ s~\[url\]\s*(\S+?)\s*\[/url\]~&format_url3($1)~eisg; if ($autolinkurls) { $message =~ s~\[url\]\s*([^\[]+)\s*\[/url\]~[url]$1\[/url]~g; $message =~ s~\[link\]\s*([^\[]+)\s*\[/link\]~[link]$1\[/link]~g; $message =~ s~\[news\](\S+?)\[/news\]~$1~isg; $message =~ s~\[gopher\](\S+?)\[/gopher\]~$1~isg; $message =~ s~">~">~g; #" $message =~ s~(\[\*\])~ $1~g; $message =~ s~(\[\/list\])~ $1~g; $message =~ s~(\[\/td\])~ $1~g; $message =~ s~(\[\/td\])~ $1~g; $message =~ s~\\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg; $message =~ s~([^\"\=\[\]/\:\.\-(\://\w+)]|[\n\b]|\"\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg; $message =~ s~\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\]\s*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~\[edit\](.*?)\[/edit\]~$post_txt{'603'}:
$1
~isg; $message =~ s~/me ~$displayname ~ig; if($message =~ /\[media/ || $message =~ /\[flash/) { require "$sourcedir/MediaCenter.pl"; $message =~ s~\[flash\](.*?)\[/flash\]~\[media\]$1\[/media\]~isg; # convert old flash tags to media tags while ($message =~ s~\[flash\s*(.*?)\]\n*(.*?)\n*\[/flash\]~&flashconvert($2,$1)~eisg){ } # convert old flash tags to media tags while ($message =~ s~\[media\]\n*(.*?)\n*\[/media\]~&embed($1)~eisg){ } while ($message =~ s~\[media\s*(.*?)\]\n*(.*?)\n*\[/media\]~&embed($2,$1)~eisg){ } $message =~ s~media:~http:~ig; } if ($guest_media_disallowed && $iamguest) { my $oops = qq~$maintxt{'40'}  $maintxt{'41'} $img{'login'}~; if ($regtype) { $oops .= qq~ $maintxt{'42'} $img{'register'}~; } $showattach = ''; $showattachhr = ''; $attachment =~ s~~[oops]~g; $attachment =~ s~\[oops\]~$oops~g; $message =~ s~~[oops]~g; $message =~ s~\[oops\]~$oops~g; } $message = MakeSmileys($message); $message =~ s~\s*\[\*\]~
  • ~isg; $message =~ s~\[olist\]~
      ~isg; $message =~ s~\s*\[/olist\]~
    ~isg; $message =~ s~
    1. ~
        ~isg; $message =~ s~
          ~
            ~isg; $message =~ s~\[list\]~