D:\my docs\My Received Files\Yabb\Yabb\YaBB_2.5_AEB\cgi-bin\yabb2_old\Sources\Printpage.pl D:\WEBSITES\testbed\cgi-bin\yabb252\Sources\Printpage.pl
############################################################################### ###############################################################################
# Printpage.pl                                                                # # Printpage.pl                                                                #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5 Anniversary Edition                                # # Version:        YaBB 2.5.2                                                  #
# Packaged:       July 04, 2010                                               # # Packaged:       September 30, 2012                                          #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               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.         #    
############################################################################### ###############################################################################
   
$printpageplver = 'YaBB 2.5 AE $Revision: 1.8 $'; $printpageplver = 'YaBB 2.5.2 $Revision: 1.0 $';
if ($action eq 'detailedversion') { return 1; } if ($action eq 'detailedversion') { return 1; }
   
sub Print_IM { sub Print_IM {
   if    ($INFO{'caller'} == 1) { fopen(THREADS, "$memberdir/$username.msg")    || &donoopen; $boxtitle = "$maintxt{'316'}"; $type = "$maintxt{'318'}" }    if    ($INFO{'caller'} == 1) { fopen(THREADS, "$memberdir/$username.msg")    || &donoopen; $boxtitle = "$maintxt{'316'}"; $type = "$maintxt{'318'}" }
   elsif ($INFO{'caller'} == 2) { fopen(THREADS, "$memberdir/$username.outbox") || &donoopen; $boxtitle = "$maintxt{'320'}"; $type = "$maintxt{'324'}"; }    elsif ($INFO{'caller'} == 2) { fopen(THREADS, "$memberdir/$username.outbox") || &donoopen; $boxtitle = "$maintxt{'320'}"; $type = "$maintxt{'324'}"; }
   else { fopen(THREADS, "$memberdir/$username.imstore") || &donoopen; $boxtitle = "$load_imtxt{'46'}"; $type = "$maintxt{'318'}/$maintxt{'324'}"; }    else { fopen(THREADS, "$memberdir/$username.imstore") || &donoopen; $boxtitle = "$load_imtxt{'46'}"; $type = "$maintxt{'318'}/$maintxt{'324'}"; }
   @threads = <THREADS>;    @threads = <THREADS>;
   fclose(THREADS);    fclose(THREADS);
   
   ### Lets output all that info. ###    ### Lets output all that info. ###
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>$mbname - $maintxt{'668'}</title> <title>$mbname - $maintxt{'668'}</title>
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" /> <meta http-equiv="Content-Type" content="text/html; charset=$yycharset" />
   
<script language="JavaScript1.2" type="text/javascript" src="$yyhtml_root/YaBB.js"></script> <script language="JavaScript1.2" type="text/javascript" src="$yyhtml_root/YaBB.js"></script>
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
<!-- <!--
function printPage() { function printPage() {
   if (window.print) {    if (window.print) {
       agree = confirm('$maintxt{773}');        agree = confirm('$maintxt{773}');
       if (agree) window.print();          if (agree) window.print();  
   }    }
} }
   
var imgdisplay = 'none'; var imgdisplay = 'none';
function do_images() { function do_images() {
   for (var i = 0; i < document.images.length; i++) {    for (var i = 0; i < document.images.length; i++) {
       document.images[i].style.display = imgdisplay;        document.images[i].style.display = imgdisplay;
   }    }
   if (imgdisplay == 'none') {    if (imgdisplay == 'none') {
       imgdisplay = 'inline';        imgdisplay = 'inline';
       document.getElementById("Hide_Image").value = "$maintxt{'669b'}";        document.getElementById("Hide_Image").value = "$maintxt{'669b'}";
   } else {    } else {
       imgdisplay = 'none';        imgdisplay = 'none';
       document.getElementById("Hide_Image").value = "$maintxt{'669a'}";        document.getElementById("Hide_Image").value = "$maintxt{'669a'}";
   }    }
} }
// --> // -->
</script> </script>
</head> </head>
   
<body onload="printPage()"> <body onload="printPage()">
   
<table width="96%" align="center"> <table width="96%" align="center">
   <tr>    <tr>
       <td align="left" valign="top">        <td align="left" valign="top">
           <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span>            <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span>
       </td>        </td>
       <td align="right" valign="top">        <td align="right" valign="top">
           <input type="button" id="Hide_Image" value="$maintxt{'669a'}" onclick="do_images();" />            <input type="button" id="Hide_Image" value="$maintxt{'669a'}" onclick="do_images();" />
       </td>        </td>
   </tr>    </tr>
   <tr>    <tr>
       <td align="left" valign="top" colspan="2">        <td align="left" valign="top" colspan="2">
           <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl</span>            <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl</span>
           <br />            <br />
           <span style="font-family: arial, sans-serif; font-size: 14px; font-weight: bold;">$load_imtxt{'71'} $boxtitle $maintxt{'30'} $date</span>            <span style="font-family: arial, sans-serif; font-size: 14px; font-weight: bold;">$load_imtxt{'71'} $boxtitle $maintxt{'30'} $date</span>
       </td>        </td>
   </tr>    </tr>
</table> </table>
   
<br /> <br />
~; ~;
   
   # Split the threads up so we can print them.    # Split the threads up so we can print them.
   foreach $thread (@threads) {    foreach $thread (@threads) {
       ($threadposter, $threadtitle, $threaddate, $threadpost, undef) = split(/\|/, $thread);        ($threadposter, $threadtitle, $threaddate, $threadpost, undef) = split(/\|/, $thread);
   
       &do_print;        &do_print;
       $output .= qq~        $output .= qq~
<table width="96%" align="center" cellpadding="10" style="border: 1px solid #000000;"> <table width="96%" align="center" cellpadding="10" style="border: 1px solid #000000;">
   <tr>    <tr>
       <td style="font-family: arial, sans-serif; font-size: 12px;">        <td style="font-family: arial, sans-serif; font-size: 12px;">
           $maintxt{'70'}: <b>$threadtitle</b><br />            $maintxt{'70'}: <b>$threadtitle</b><br />
           $type <b>$threadposter</b> $maintxt{'30'} <b>$threaddate</b>            $type <b>$threadposter</b> $maintxt{'30'} <b>$threaddate</b>
           <hr width="100%" size="1" />            <hr width="100%" size="1" />
           <span style="font-family: arial, sans-serif; font-size: 12px;">            <span style="font-family: arial, sans-serif; font-size: 12px;">
           $threadpost            $threadpost
           </span>            </span>
       </td>        </td>
   </tr>    </tr>
</table> </table>
   
<br /> <br />
~; ~;
   }    }
   
   $output .= qq~    $output .= qq~
<table width="96%" align="center"> <table width="96%" align="center">
   <tr>    <tr>
       <td align="center">        <td align="center">
           <span style="font-family: arial, sans-serif; font-size: 10px;">            <span style="font-family: arial, sans-serif; font-size: 10px;">
           $yycopyright            $yycopyright
           </span>            </span>
       </td>        </td>
   </tr>    </tr>
</table> </table>
   
</body> </body>
</html>~; </html>~;
   
   &image_resize;    &image_resize;
   
   &print_output_header;    &print_output_header;
   &print_HTML_output_and_finish;    &print_HTML_output_and_finish;
} }
   
sub Print { sub Print {
   $num = $INFO{'num'};    $num = $INFO{'num'};
   
   # Determine category    # Determine category
   $curcat = ${$uid.$currentboard}{'cat'};    $curcat = ${$uid.$currentboard}{'cat'};
   &MessageTotals("load", $num);    &MessageTotals("load", $num);
   
   my $ishidden;    my $ishidden;
   if (${$num}{'threadstatus'} =~ /h/i) {    if (${$num}{'threadstatus'} =~ /h/i) {
       $ishidden = 1;        $ishidden = 1;
   }    }
   
   if ($ishidden && !$iammod && !$iamadmin && !$iamgmod) { &fatal_error("no_access"); }    if ($ishidden && !$iammod && !$iamadmin && !$iamgmod) { &fatal_error("no_access"); }
   
   # Figure out the name of the category    # Figure out the name of the category
   unless ($mloaded == 1) { require "$boardsdir/forum.master"; }    unless ($mloaded == 1) { require "$boardsdir/forum.master"; }
   ($cat, $catperms) = split(/\|/, $catinfo{"$curcat"});    ($cat, $catperms) = split(/\|/, $catinfo{"$curcat"});
   
   ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$currentboard"});    ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$currentboard"});
   
   &LoadCensorList;    &LoadCensorList;
   
   # Lets open up the thread file itself    # Lets open up the thread file itself
   unless (ref($thread_arrayref{$num})) {    unless (ref($thread_arrayref{$num})) {
       fopen(THREADS, "$datadir/$num.txt") || &donoopen;        fopen(THREADS, "$datadir/$num.txt") || &donoopen;
       @{$thread_arrayref{$num}} = <THREADS>;        @{$thread_arrayref{$num}} = <THREADS>;
       fclose(THREADS);        fclose(THREADS);
   }    }
   $cat =~ s/\n//g;    $cat =~ s/\n//g;
   
   ($messagetitle, $poster, undef, $date, undef) = split(/\|/, ${$thread_arrayref{$num}}[0]);    ($messagetitle, $poster, undef, $date, undef) = split(/\|/, ${$thread_arrayref{$num}}[0]);
   
   $startedby = $poster;    $startedby = $poster;
   $startedon = timeformat($date, 1);    $startedon = timeformat($date, 1);
   &ToChars($messagetitle);    &ToChars($messagetitle);
   ($messagetitle, undef) = &Split_Splice_Move($messagetitle,0);    ($messagetitle, undef) = &Split_Splice_Move($messagetitle,0);
   
   ### Lets output all that info. ###    ### Lets output all that info. ###
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>$mbname - $maintxt{'668'}</title> <title>$mbname - $maintxt{'668'}</title>
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" /> <meta http-equiv="Content-Type" content="text/html; charset=$yycharset" />
   
<script language="JavaScript1.2" type="text/javascript" src="$yyhtml_root/YaBB.js"></script> <script language="JavaScript1.2" type="text/javascript" src="$yyhtml_root/YaBB.js"></script>
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
<!-- <!--
function printPage() { function printPage() {
   if (window.print) {    if (window.print) {
       agree = confirm('$maintxt{773}');        agree = confirm('$maintxt{773}');
       if (agree) window.print();          if (agree) window.print();  
   }    }
} }
   
var imgdisplay = 'none'; var imgdisplay = 'none';
var urldisplay = 'inline'; var urldisplay = 'inline';
function do_images() { function do_images() {
   for (var i = 0; i < document.images.length; i++) {    for (var i = 0; i < document.images.length; i++) {
       if (document.images[i].align != 'bottom') {        if (document.images[i].align != 'bottom') {
           document.images[i].style.display = imgdisplay;            document.images[i].style.display = imgdisplay;
           imageid = document.images[i].id;            imageid = document.images[i].id;
           if (imageid) document.getElementById('url' + imageid).style.display = urldisplay;            if (imageid) document.getElementById('url' + imageid).style.display = urldisplay;
       }        }
   }    }
   if (imgdisplay == 'none') {    if (imgdisplay == 'none') {
       imgdisplay = 'inline';        imgdisplay = 'inline';
       urldisplay = 'none';        urldisplay = 'none';
       document.getElementById("Hide_Image").value = "$maintxt{'669b'}";        document.getElementById("Hide_Image").value = "$maintxt{'669b'}";
   } else {    } else {
       imgdisplay = 'none';        imgdisplay = 'none';
       urldisplay = 'inline';        urldisplay = 'inline';
       document.getElementById("Hide_Image").value = "$maintxt{'669a'}";        document.getElementById("Hide_Image").value = "$maintxt{'669a'}";
   }    }
} }
// --> // -->
</script> </script>
</head> </head>
   
<body onload="printPage()"> <body onload="printPage()">
   
<table width="96%" align="center"> <table width="96%" align="center">
   <tr>    <tr>
       <td align="left" valign="top">        <td align="left" valign="top">
           <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span>            <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span>
       </td>        </td>
       <td align="right" valign="top">        <td align="right" valign="top">
           <input type="button" id="Hide_Image" value="$maintxt{'669a'}" onclick="do_images();" />            <input type="button" id="Hide_Image" value="$maintxt{'669a'}" onclick="do_images();" />
       </td>        </td>
   </tr>    </tr>
   <tr>    <tr>
       <td align="left" valign="top" colspan="2">        <td align="left" valign="top" colspan="2">
           <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl</span>            <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl</span>
           <br />            <br />
           <span style="font-family: arial, sans-serif; font-size: 16px; font-weight: bold;">$cat &gt;&gt; $boardname &gt;&gt; $messagetitle</span>            <span style="font-family: arial, sans-serif; font-size: 16px; font-weight: bold;">$cat &gt;&gt; $boardname &gt;&gt; $messagetitle</span>
           <br />            <br />
           <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl?num=$num</span>            <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl?num=$num</span>
           <br />            <br />
           <hr size="1" width="100%" />            <hr size="1" width="100%" />
           <span style="font-family: arial, sans-serif; font-size: 14px; font-weight: bold;">$maintxt{'195'} $startedby $maintxt{'30'} $startedon</span>            <span style="font-family: arial, sans-serif; font-size: 14px; font-weight: bold;">$maintxt{'195'} $startedby $maintxt{'30'} $startedon</span>
       </td>        </td>
   </tr>    </tr>
</table> </table>
   
<br />~; <br />~;
   
   &LoadLanguage('FA');    &LoadLanguage('FA');
   # Split the threads up so we can print them.    # Split the threads up so we can print them.
   foreach $thread (@{$thread_arrayref{$num}}) {    foreach $thread (@{$thread_arrayref{$num}}) {
       ($threadtitle, $threadposter, undef, $threaddate, undef, undef, undef, undef, $threadpost, undef, undef, undef, $attachments) = split(/\|/, $thread);        ($threadtitle, $threadposter, undef, $threaddate, undef, undef, undef, undef, $threadpost, undef, undef, undef, $attachments) = split(/\|/, $thread);
   
       ($threadtitle, undef) = &Split_Splice_Move($threadtitle,0);        ($threadtitle, undef) = &Split_Splice_Move($threadtitle,0);
       ($threadpost, undef) = &Split_Splice_Move($threadpost,$num);        ($threadpost, undef) = &Split_Splice_Move($threadpost,$num);
       &do_print;        &do_print;
   
       $output .= qq~        $output .= qq~
<table width="96%" align="center" cellpadding="10" style="border: 1px solid #000000;"> <table width="96%" align="center" cellpadding="10" style="border: 1px solid #000000;">
   <tr>    <tr>
       <td style="font-family: arial, sans-serif; font-size: 12px;">        <td style="font-family: arial, sans-serif; font-size: 12px;">
           $maintxt{'196'}: <b>$threadtitle</b><br />            $maintxt{'196'}: <b>$threadtitle</b><br />
           $maintxt{'197'} <b>$threadposter</b> $maintxt{'30'} <b>$threaddate</b>            $maintxt{'197'} <b>$threadposter</b> $maintxt{'30'} <b>$threaddate</b>
           <hr width="100%" size="1" />            <hr width="100%" size="1" />
           <div style="font-family: arial, sans-serif; font-size: 12px;">            <div style="font-family: arial, sans-serif; font-size: 12px;">
           $threadpost~;            $threadpost~;
   
       chomp $attachments;        chomp $attachments;
       if ($attachments) {        if ($attachments) {
           # store all downloadcounts in variable            # store all downloadcounts in variable
           if (!%attach_count) {            if (!%attach_count) {
               my ($atfile,$atcount);                my ($atfile,$atcount);
               fopen(ATM, "$vardir/attachments.txt");                fopen(ATM, "$vardir/attachments.txt");
               while (<ATM>) {                while (<ATM>) {
                   (undef, undef, undef, undef, undef, undef, undef, $atfile, $atcount) =split(/\|/, $_);                    (undef, undef, undef, undef, undef, undef, undef, $atfile, $atcount) =split(/\|/, $_);
                   $attach_count{$atfile} = $atcount;                    $attach_count{$atfile} = $atcount;
               }                }
               fclose(ATM);                fclose(ATM);
               $attach_count{'no_attachments'} = 1 if !%attach_count;                $attach_count{'no_attachments'} = 1 if !%attach_count;
           }            }
   
           my $attachment = '';            my $attachment = '';
           my $showattach = '';            my $showattach = '';
   
           foreach (split(/,/, $attachments)) {            foreach (split(/,/, $attachments)) {
               $_ =~ /\.(.+?)$/;                $_ =~ /\.(.+?)$/;
               my $ext = lc($1);                my $ext = lc($1);
               unless (exists $attach_gif{$ext}) {                unless (exists $attach_gif{$ext}) {
                   $attach_gif{$ext} = ($ext && -e "$forumstylesdir/$useimages/$ext.gif") ? "$ext.gif" : "paperclip.gif";                    $attach_gif{$ext} = ($ext && -e "$forumstylesdir/$useimages/$ext.gif") ? "$ext.gif" : "paperclip.gif";
               }                }
               my $filesize = -s "$uploaddir/$_";                my $filesize = -s "$uploaddir/$_";
               if ($filesize) {                if ($filesize) {
                   if ($_ =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/i && $amdisplaypics == 1) {                    if ($_ =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/i && $amdisplaypics == 1) {
                       $imagecount++;                        $imagecount++;
                       $showattach .= qq~<div class="small" style="float:left; margin:8px;"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> <span id="urlimagecount$imagecount" style="display:none">$scripturl?action=downloadfile;file=</span>$_ (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )<br /><img src="$uploadurl/$_" name="attach_img_resize" alt="$_" id="imagecount$imagecount" title="$_" border="0" style="display:none" /></div>\n~;                        $showattach .= qq~<div class="small" style="float:left; margin:8px;"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> <span id="urlimagecount$imagecount" style="display:none">$scripturl?action=downloadfile;file=</span>$_ (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )<br /><img src="$uploadurl/$_" name="attach_img_resize" alt="$_" id="imagecount$imagecount" title="$_" border="0" style="display:none" /></div>\n~;
                   } else {                    } else {
                       $attachment .= qq~<div class="small"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> $scripturl?action=downloadfile;file=$_ (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )</div>~;                        $attachment .= qq~<div class="small"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> $scripturl?action=downloadfile;file=$_ (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )</div>~;
                   }                    }
               } else {                } else {
                   $attachment .= qq~<div class="small"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" />  $_ ($fatxt{'1'}~ . (exists $attach_count{$_} ? qq~ | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> ~ : '') . qq~)</div>~;                    $attachment .= qq~<div class="small"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" />  $_ ($fatxt{'1'}~ . (exists $attach_count{$_} ? qq~ | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> ~ : '') . qq~)</div>~;
               }                }
           }            }
           if ($showattach && $attachment) {            if ($showattach && $attachment) {
               $attachment =~ s/<div class="small">/<div class="small" style="margin:8px;">/g;                $attachment =~ s/<div class="small">/<div class="small" style="margin:8px;">/g;
           }            }
           $output .= qq~            $output .= qq~
           <hr width="100%" size="1" />            <hr width="100%" size="1" />
           $attachment            $attachment
           $showattach~;            $showattach~;
       }        }
   
       $output .= qq~        $output .= qq~
           </div>            </div>
       </td>        </td>
   </tr>    </tr>
</table> </table>
   
<br />~; <br />~;
   }    }
   
   $output .= qq~    $output .= qq~
<table width="96%" align="center"> <table width="96%" align="center">
   <tr>    <tr>
       <td align="center" style="font-family: arial, sans-serif; font-size: 10px;">        <td align="center" style="font-family: arial, sans-serif; font-size: 10px;">
           $yycopyright            $yycopyright
       </td>        </td>
   </tr>    </tr>
</table> </table>
   
</body> </body>
</html>~; </html>~;
   
   &image_resize;    &image_resize;
   
   &print_output_header;    &print_output_header;
   &print_HTML_output_and_finish;    &print_HTML_output_and_finish;
} }
   
sub sizefont { sub sizefont {
   # limit minimum and maximum font pitch as CSS does not restrict it at all.    # limit minimum and maximum font pitch as CSS does not restrict it at all.
   my ($tsize, $ttext) = @_;    my ($tsize, $ttext) = @_;
   if    (!$fontsizemax)         { $fontsizemax = 72; }    if    (!$fontsizemax)         { $fontsizemax = 72; }
   if    (!$fontsizemin)         { $fontsizemin = 6; }    if    (!$fontsizemin)         { $fontsizemin = 6; }
   if    ($tsize < $fontsizemin) { $tsize       = $fontsizemin; }    if    ($tsize < $fontsizemin) { $tsize       = $fontsizemin; }
   elsif ($tsize > $fontsizemax) { $tsize       = $fontsizemax; }    elsif ($tsize > $fontsizemax) { $tsize       = $fontsizemax; }
   my $resized = qq~<span style="font-size:$tsize\px;">$ttext</span>~;    my $resized = qq~<span style="font-size:$tsize\px;">$ttext</span>~;
   return $resized;    return $resized;
} }
   
{ {
   my %killhash = (    my %killhash = (
       ';' => '&#059;',        ';' => '&#059;',
       '!' => '&#33;',        '!' => '&#33;',
       '(' => '&#40;',        '(' => '&#40;',
       ')' => '&#41;',        ')' => '&#41;',
       '-' => '&#45;',        '-' => '&#45;',
       '.' => '&#46;',        '.' => '&#46;',
       '/' => '&#47;',        '/' => '&#47;',
       ':' => '&#58;',        ':' => '&#58;',
       '?' => '&#63;',        '?' => '&#63;',
       '[' => '&#91;',        '[' => '&#91;',
       '\\' => '&#92;',        '\\' => '&#92;',
       ']' => '&#93;',        ']' => '&#93;',
       '^' => '&#94;');        '^' => '&#94;');
   
   sub codemsg {    sub codemsg {
       my $code = $_[0];        my $code = $_[0];
       if ($code !~ /&\S*;/) { $code =~ s/;/&#059;/g; }        if ($code !~ /&\S*;/) { $code =~ s/;/&#059;/g; }
       $code =~ s~([\(\)\-\:\\\/\?\!\]\[\.\^])~$killhash{$1}~g;        $code =~ s~([\(\)\-\:\\\/\?\!\]\[\.\^])~$killhash{$1}~g;
       $_ = qq~<br /><b>Code:</b><br /><table cellspacing="1" width="90%"><tr><td width="100%"><table width="100%" cellpadding="2" cellspacing="0"><tr><td><font face="courier" size="1">CODE</font></td></tr></table></td></tr></table>~;        $_ = qq~<br /><b>Code:</b><br /><table cellspacing="1" width="90%"><tr><td width="100%"><table width="100%" cellpadding="2" cellspacing="0"><tr><td><font face="courier" size="1">CODE</font></td></tr></table></td></tr></table>~;
       $_ =~ s~CODE~$code~g;        $_ =~ s~CODE~$code~g;
       return $_;        return $_;
   }    }
} }
   
sub donoopen { sub donoopen {
   print qq~Content-Type: text/html\r\n\r\n    print qq~Content-Type: text/html\r\n\r\n
<html> <html>
<head> <head>
<title>$maintxt{'199'}</title> <title>$maintxt{'199'}</title>
</head> </head>
<body> <body>
<font size="2" face="Arial,Helvetica"><center>$maintxt{'199'}</center></font> <font size="2" face="Arial,Helvetica"><center>$maintxt{'199'}</center></font>
</body> </body>
</html>~; </html>~;
   exit;    exit;
} }
   
sub do_print { sub do_print {
   $threadpost =~ s~<br />~\n~ig;    $threadpost =~ s~<br />~\n~ig;
   $threadpost =~ s~\[highlight(.*?)\](.*?)\[/highlight\]~$2~isg;    $threadpost =~ s~\[highlight(.*?)\](.*?)\[/highlight\]~$2~isg;
   $threadpost =~ s~\[code\]\n*(.+?)\n*\[/code\]~<br /><b>Code:</b><br /><table cellspacing="1"><tr><td><table cellpadding="2" cellspacing="0"><tr><td><font face="Courier" size="1">$1</font></td></tr></table></td></tr></table>~isg;      $threadpost =~ s~\[code\s*(.+?)\]\n*(.+?)\n*\[/code\]~<br /><b>Code ($1):</b><br /><table cellspacing="1"><tr><td><table cellpadding="2" cellspacing="0"><tr><td><font face="Courier" size="1">$2</font></td></tr></table></td></tr></table>~isg;  
   
   $threadpost =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g;    $threadpost =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g;
   $threadpost =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g;    $threadpost =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g;
   $threadpost =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g;    $threadpost =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g;
   
   $threadpost =~ s~\[b\](.*?)\[/b\]~<b>$1</b>~isg;    $threadpost =~ s~\[b\](.*?)\[/b\]~<b>$1</b>~isg;
   $threadpost =~ s~\[i\](.*?)\[/i\]~<i>$1</i>~isg;    $threadpost =~ s~\[i\](.*?)\[/i\]~<i>$1</i>~isg;
   $threadpost =~ s~\[u\](.*?)\[/u\]~<u>$1</u>~isg;    $threadpost =~ s~\[u\](.*?)\[/u\]~<u>$1</u>~isg;
   $threadpost =~ s~\[s\](.*?)\[/s\]~<s>$1</s>~isg;    $threadpost =~ s~\[s\](.*?)\[/s\]~<s>$1</s>~isg;
   $threadpost =~ s~\[move\](.*?)\[/move\]~$1~isg;    $threadpost =~ s~\[move\](.*?)\[/move\]~$1~isg;
   
   $threadpost =~ s~\[glow(.*?)\](.*?)\[/glow\]~&elimnests($2)~eisg;    $threadpost =~ s~\[glow(.*?)\](.*?)\[/glow\]~&elimnests($2)~eisg;
   $threadpost =~ s~\[shadow(.*?)\](.*?)\[/shadow\]~&elimnests($2)~eisg;    $threadpost =~ s~\[shadow(.*?)\](.*?)\[/shadow\]~&elimnests($2)~eisg;
   
   $threadpost =~ s~\[shadow=(\S+?),(.+?),(.+?)\](.+?)\[/shadow\]~$4~eisg;    $threadpost =~ s~\[shadow=(\S+?),(.+?),(.+?)\](.+?)\[/shadow\]~$4~eisg;
   $threadpost =~ s~\[glow=(\S+?),(.+?),(.+?)\](.+?)\[/glow\]~$4~eisg;    $threadpost =~ s~\[glow=(\S+?),(.+?),(.+?)\](.+?)\[/glow\]~$4~eisg;
   
   $threadpost =~ s~\[color=([\w#]+)\](.*?)\[/color\]~$2~isg;    $threadpost =~ s~\[color=([\w#]+)\](.*?)\[/color\]~$2~isg;
   $threadpost =~ s~\[black\](.*?)\[/black\]~$1~isg;    $threadpost =~ s~\[black\](.*?)\[/black\]~$1~isg;
   $threadpost =~ s~\[white\](.*?)\[/white\]~$1~isg;    $threadpost =~ s~\[white\](.*?)\[/white\]~$1~isg;
   $threadpost =~ s~\[red\](.*?)\[/red\]~$1~isg;    $threadpost =~ s~\[red\](.*?)\[/red\]~$1~isg;
   $threadpost =~ s~\[green\](.*?)\[/green\]~$1~isg;    $threadpost =~ s~\[green\](.*?)\[/green\]~$1~isg;
   $threadpost =~ s~\[blue\](.*?)\[/blue\]~$1~isg;    $threadpost =~ s~\[blue\](.*?)\[/blue\]~$1~isg;
   $threadpost =~ s~\[font=(.+?)\](.+?)\[/font\]~<span style="font-family:$1;">$2</span>~isg;    $threadpost =~ s~\[font=(.+?)\](.+?)\[/font\]~<span style="font-family:$1;">$2</span>~isg;
   while ($threadpost =~ s~\[size=(.+?)\](.+?)\[/size\]~&sizefont($1,$2)~eisg) { }    while ($threadpost =~ s~\[size=(.+?)\](.+?)\[/size\]~&sizefont($1,$2)~eisg) { }
   
   $threadpost =~ s~\[quote\s+author=(.*?)\s+link=(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote author=$1 link=$2\]<i>* $1 $3</i>\[/quote\]~isg;    $threadpost =~ s~\[quote\s+author=(.*?)\s+link=(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote author=$1 link=$2\]<i>* $1 $3</i>\[/quote\]~isg;
   $threadpost =~ s~\[quote(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote$1\]<i>* Me $2</i>\[/quote\]~isg;    $threadpost =~ s~\[quote(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote$1\]<i>* Me $2</i>\[/quote\]~isg;
   $threadpost =~ s~\/me\s+(.*)~* $displayname $1~ig;    $threadpost =~ s~\/me\s+(.*)~* $displayname $1~ig;
   
   # Images in message    # Images in message
   $threadpost =~ s~\[img(.*?)\](.*?)\[/img\]~ &imagemsg($1,$2) ~eisg;    $threadpost =~ s~\[img(.*?)\](.*?)\[/img\]~ &imagemsg($1,$2) ~eisg;
   sub imagemsg { # out of YaBBC.pl -> sub imagemsg {    sub imagemsg { # out of YaBBC.pl -> sub imagemsg {
       my($attribut,$url) = @_;        my($attribut,$url) = @_;
       # use or kill urls        # use or kill urls
       $url =~ s~\[url\](.*?)\[/url\]~$1~ig;        $url =~ s~\[url\](.*?)\[/url\]~$1~ig;
       $url =~ s~\[link\](.*?)\[/link\]~$1~ig;        $url =~ s~\[link\](.*?)\[/link\]~$1~ig;
       $url =~ s~\[url\s*=\s*(.*?)\s*.*?\].*?\[/url\]~$1~ig;        $url =~ s~\[url\s*=\s*(.*?)\s*.*?\].*?\[/url\]~$1~ig;
       $url =~ s~\[link\s*=\s*(.*?)\s*.*?\].*?\[/link\]~$1~ig;        $url =~ s~\[link\s*=\s*(.*?)\s*.*?\].*?\[/link\]~$1~ig;
       $url =~ s~\[url.*?/url\]~~ig;        $url =~ s~\[url.*?/url\]~~ig;
       $url =~ s~\[link.*?/link\]~~ig;        $url =~ s~\[link.*?/link\]~~ig;
   
       my $char_160 = chr(160);        my $char_160 = chr(160);
       $url =~ s/(\s|&nbsp;|$char_160)+//g;        $url =~ s/(\s|&nbsp;|$char_160)+//g;
   
       if ($url !~ /^http.+?\.(gif|jpg|jpeg|png|bmp)$/i) {return ' ' . $url;}        if ($url !~ /^http.+?\.(gif|jpg|jpeg|png|bmp)$/i) {return ' ' . $url;}
   
       my %parameter;        my %parameter;
       &FromHTML($attribut);        &FromHTML($attribut);
       $attribut =~ s/(\s|$char_160)+/ /g;        $attribut =~ s/(\s|$char_160)+/ /g;
       foreach (split(/ +/, $attribut)) {        foreach (split(/ +/, $attribut)) {
           my ($key, $value) = split(/=/, $_);            my ($key, $value) = split(/=/, $_);
           $value =~ s/["']//g;            $value =~ s/["']//g;
           $parameter{$key} = $value;            $parameter{$key} = $value;
       }        }
   
       $parameter{'name'} = 'post_img_resize' if $parameter{'name'} ne 'signat_img_resize';        $parameter{'name'} = 'post_img_resize' if $parameter{'name'} ne 'signat_img_resize';
       &ToHTML($parameter{'alt'});        &ToHTML($parameter{'alt'});
       $parameter{'align'}  =~ s~[^a-z]~~ig;        $parameter{'align'}  =~ s~[^a-z]~~ig;
       $parameter{'width'}  =~ s~\D~~g;        $parameter{'width'}  =~ s~\D~~g;
       $parameter{'height'} =~ s~\D~~g;        $parameter{'height'} =~ s~\D~~g;
       if ($parameter{'align'})  { $parameter{'align'}  = qq~ align="$parameter{'align'}"~; }        if ($parameter{'align'})  { $parameter{'align'}  = qq~ align="$parameter{'align'}"~; }
       if ($parameter{'width'})  { $parameter{'width'}  = qq~ width="$parameter{'width'}"~; }        if ($parameter{'width'})  { $parameter{'width'}  = qq~ width="$parameter{'width'}"~; }
       if ($parameter{'height'}) { $parameter{'height'} = qq~ height="$parameter{'height'}"~; }        if ($parameter{'height'}) { $parameter{'height'} = qq~ height="$parameter{'height'}"~; }
   
       $imagecount++;        $imagecount++;
       qq~ <img src="$url" name="$parameter{'name'}" alt="$parameter{'alt'}"$parameter{'align'}$parameter{'width'}$parameter{'height'} border="0" id="imagecount$imagecount" style="display:none" /><span id="urlimagecount$imagecount" style="display:none">$url</span>~;        qq~ <img src="$url" name="$parameter{'name'}" alt="$parameter{'alt'}"$parameter{'align'}$parameter{'width'}$parameter{'height'} border="0" id="imagecount$imagecount" style="display:none" /><span id="urlimagecount$imagecount" style="display:none">$url</span>~;
   }    }
   
   $threadpost =~ s~\[tt\](.*?)\[/tt\]~<tt>$1</tt>~isg;    $threadpost =~ s~\[tt\](.*?)\[/tt\]~<tt>$1</tt>~isg;
   $threadpost =~ s~\[left\](.*?)\[/left\]~<div style="text-align: left;">$1</div>~isg;    $threadpost =~ s~\[left\](.*?)\[/left\]~<div style="text-align: left;">$1</div>~isg;
   $threadpost =~ s~\[center\](.*?)\[/center\]~<center>$1</center>~isg;    $threadpost =~ s~\[center\](.*?)\[/center\]~<center>$1</center>~isg;
   $threadpost =~ s~\[right\](.*?)\[/right\]~<div style="text-align: right;">$1</div>~isg;    $threadpost =~ s~\[right\](.*?)\[/right\]~<div style="text-align: right;">$1</div>~isg;
   $threadpost =~ s~\[justify\](.*?)\[/justify\]~<div style="text-align: justify">$1</div>~isg;    $threadpost =~ s~\[justify\](.*?)\[/justify\]~<div style="text-align: justify">$1</div>~isg;
   $threadpost =~ s~\[sub\](.*?)\[/sub\]~<sub>$1</sub>~isg;    $threadpost =~ s~\[sub\](.*?)\[/sub\]~<sub>$1</sub>~isg;
   $threadpost =~ s~\[sup\](.*?)\[/sup\]~<sup>$1</sup>~isg;    $threadpost =~ s~\[sup\](.*?)\[/sup\]~<sup>$1</sup>~isg;
   $threadpost =~ s~\[fixed\](.*?)\[/fixed\]~<span style="font-family: Courier New;">$1</span>~isg;    $threadpost =~ s~\[fixed\](.*?)\[/fixed\]~<span style="font-family: Courier New;">$1</span>~isg;
   
   $threadpost =~ s~\[\[~\{\{~g;    $threadpost =~ s~\[\[~\{\{~g;
   $threadpost =~ s~\]\]~\}\}~g;    $threadpost =~ s~\]\]~\}\}~g;
   $threadpost =~ s~\|~\&#124;~g;    $threadpost =~ s~\|~\&#124;~g;
   $threadpost =~ s~\[hr\]\n~<hr width="40%" align="left" size="1" class="hr" />~g;    $threadpost =~ s~\[hr\]\n~<hr width="40%" align="left" size="1" class="hr" />~g;
   $threadpost =~ s~\[hr\]~<hr width="40%" align="left" size="1" class="hr" />~g;    $threadpost =~ s~\[hr\]~<hr width="40%" align="left" size="1" class="hr" />~g;
   $threadpost =~ s~\[br\]~\n~ig;    $threadpost =~ s~\[br\]~\n~ig;
   
   $threadpost =~ s~\[flash\](.*?)\[/flash\]~\[media\]$1\[/media\]~isg;    $threadpost =~ s~\[flash\](.*?)\[/flash\]~\[media\]$1\[/media\]~isg;
   
   sub format_url {    sub format_url {
       my ($txtfirst, $txturl) = @_;        my ($txtfirst, $txturl) = @_;
       my $lasttxt = "";        my $lasttxt = "";
       if ($txturl =~ m~(.*?)(\.|\.\)|\)\.|\!|\!\)|\)\!|\,|\)\,|\)|\;|\&quot\;|\&quot\;\.|\.\&quot\;|\&quot\;\,|\,\&quot\;|\&quot\;\;|\<\/)\Z~) {        if ($txturl =~ m~(.*?)(\.|\.\)|\)\.|\!|\!\)|\)\!|\,|\)\,|\)|\;|\&quot\;|\&quot\;\.|\.\&quot\;|\&quot\;\,|\,\&quot\;|\&quot\;\;|\<\/)\Z~) {
           $txturl = $1;            $txturl = $1;
           $lasttxt = $2;            $lasttxt = $2;
       }        }
       my $realurl = $txturl;        my $realurl = $txturl;
       $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;        $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;
       $txturl =~ s~\[~&#91;~g;        $txturl =~ s~\[~&#91;~g;
       $txturl =~ s~\]~&#93;~g;        $txturl =~ s~\]~&#93;~g;
       $txturl =~ s~\<.+?\>~~ig;        $txturl =~ s~\<.+?\>~~ig;
       my $formaturl = qq~$txtfirst\[url\=$txturl\]$realurl\[\/url\]$lasttxt~;        my $formaturl = qq~$txtfirst\[url\=$txturl\]$realurl\[\/url\]$lasttxt~;
       return $formaturl;        return $formaturl;
   }    }
   sub format_url2 {    sub format_url2 {
       my ($txturl, $txtlink) = @_;        my ($txturl, $txtlink) = @_;
       $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;        $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;
       $txturl =~ s~\<.+?\>~~ig;        $txturl =~ s~\<.+?\>~~ig;
       my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~;        my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~;
       return $formaturl;        return $formaturl;
   }    }
   sub format_url3 {    sub format_url3 {
       my $txturl = $_[0];        my $txturl = $_[0];
       my $txtlink = $txturl;        my $txtlink = $txturl;
       $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;        $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;
       $txturl =~ s~\[~&#91;~g;        $txturl =~ s~\[~&#91;~g;
       $txturl =~ s~\]~&#93;~g;        $txturl =~ s~\]~&#93;~g;
       $txturl =~ s~\<.+?\>~~ig;        $txturl =~ s~\<.+?\>~~ig;
       my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~;        my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~;
       return $formaturl;        return $formaturl;
   }    }
   
   $threadpost =~ s~\[url=\s*(.+?)\s*\]\s*(.+?)\s*\[/url\]~&format_url2($1, $2)~eisg;    $threadpost =~ s~\[url=\s*(.+?)\s*\]\s*(.+?)\s*\[/url\]~&format_url2($1, $2)~eisg;
   $threadpost =~ s~\[url\]\s*(\S+?)\s*\[/url\]~&format_url3($1)~eisg;    $threadpost =~ s~\[url\]\s*(\S+?)\s*\[/url\]~&format_url3($1)~eisg;
   
   if ($autolinkurls) {    if ($autolinkurls) {
       $threadpost =~ s~\[url\]\s*([^\[]+)\s*\[/url\]~[url]$1\[/url]~g;        $threadpost =~ s~\[url\]\s*([^\[]+)\s*\[/url\]~[url]$1\[/url]~g;
       $threadpost =~ s~\[link\]\s*([^\[]+)\s*\[/link\]~[link]$1\[/link]~g;        $threadpost =~ s~\[link\]\s*([^\[]+)\s*\[/link\]~[link]$1\[/link]~g;
       $threadpost =~ s~\[news\](\S+?)\[/news\]~<a href="$1">$1</a>~isg;        $threadpost =~ s~\[news\](\S+?)\[/news\]~<a href="$1">$1</a>~isg;
       $threadpost =~ s~\[gopher\](\S+?)\[/gopher\]~<a href="$1">$1</a>~isg;        $threadpost =~ s~\[gopher\](\S+?)\[/gopher\]~<a href="$1">$1</a>~isg;
       $threadpost =~ s~&quot;&gt;~">~g; #"         $threadpost =~ s~&quot;&gt;~">~g; #" 
       $threadpost =~ s~(\[\*\])~ $1~g;        $threadpost =~ s~(\[\*\])~ $1~g;
       $threadpost =~ s~(\[\/list\])~ $1~g;        $threadpost =~ s~(\[\/list\])~ $1~g;
       $threadpost =~ s~(\[\/td\])~ $1~g;        $threadpost =~ s~(\[\/td\])~ $1~g;
       $threadpost =~ s~(\[\/td\])~ $1~g;        $threadpost =~ s~(\[\/td\])~ $1~g;
       $threadpost =~ s~\<span style\=~\<span_style\=~g;        $threadpost =~ s~\<span style\=~\<span_style\=~g;
       $threadpost =~ s~\<div style\=~\<div_style\=~g;        $threadpost =~ s~\<div style\=~\<div_style\=~g;
       $threadpost =~ s~([^\w\"\=\[\]]|[\n\b]|\&quot\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A)\\*(\w+?\:\/\/(?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg;        $threadpost =~ s~([^\w\"\=\[\]]|[\n\b]|\&quot\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A)\\*(\w+?\:\/\/(?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg;
       $threadpost =~ s~([^\"\=\[\]/\:\.(\://\w+)]|[\n\b]|\&quot\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg;        $threadpost =~ s~([^\"\=\[\]/\:\.(\://\w+)]|[\n\b]|\&quot\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg;
       $threadpost =~ s~\<span_style\=~\<span style\=~g;        $threadpost =~ s~\<span_style\=~\<span style\=~g;
       $threadpost =~ s~\<div_style\=~\<div style\=~g;        $threadpost =~ s~\<div_style\=~\<div style\=~g;
   }    }
   
   if ($stealthurl) {    if ($stealthurl) {
       $threadpost =~ s~\[url=\s*(\w+\://.+?)\](.+?)\s*\[/url\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1" target="_blank">$2</a>~isg;        $threadpost =~ s~\[url=\s*(\w+\://.+?)\](.+?)\s*\[/url\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1" target="_blank">$2</a>~isg;
       $threadpost =~ s~\[url=\s*(.+?)\]\s*(.+?)\s*\[/url\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=http://$1" target="_blank">$2</a>~isg;        $threadpost =~ s~\[url=\s*(.+?)\]\s*(.+?)\s*\[/url\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=http://$1" target="_blank">$2</a>~isg;
       $threadpost =~ s~\[link\]\s*www\.\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=http://www.$1">www.$1</a>~isg;        $threadpost =~ s~\[link\]\s*www\.\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=http://www.$1">www.$1</a>~isg;
       $threadpost =~ s~\[link=\s*(\w+\://.+?)\](.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1">$2</a>~isg;        $threadpost =~ s~\[link=\s*(\w+\://.+?)\](.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1">$2</a>~isg;
       $threadpost =~ s~\[link=\s*(.+?)\]\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=http://$1">$2</a>~isg;        $threadpost =~ s~\[link=\s*(.+?)\]\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=http://$1">$2</a>~isg;
       $threadpost =~ s~\[link\]\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1">$1</a>~isg;        $threadpost =~ s~\[link\]\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1">$1</a>~isg;
       $threadpost =~ s~\[ftp\]\s*(.+?)\s*\[/ftp\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1" target="_blank">$1</a>~isg;        $threadpost =~ s~\[ftp\]\s*(.+?)\s*\[/ftp\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1" target="_blank">$1</a>~isg;
   } else {    } else {
       $threadpost =~ s~\[url=\s*(\S\w+\://\S+?)\s*\](.+?)\[/url\]~<a href="$1" target="_blank">$2</a>~isg;        $threadpost =~ s~\[url=\s*(\S\w+\://\S+?)\s*\](.+?)\[/url\]~<a href="$1" target="_blank">$2</a>~isg;
       $threadpost =~ s~\[url=\s*(\S+?)\](.+?)\s*\[/url\]~<a href="http://$1" target="_blank">$2</a>~isg;        $threadpost =~ s~\[url=\s*(\S+?)\](.+?)\s*\[/url\]~<a href="http://$1" target="_blank">$2</a>~isg;
       $threadpost =~ s~\[link\]\s*www\.(\S+?)\s*\[/link\]~<a href="http://www.$1">www.$1</a>~isg;        $threadpost =~ s~\[link\]\s*www\.(\S+?)\s*\[/link\]~<a href="http://www.$1">www.$1</a>~isg;
       $threadpost =~ s~\[link=\s*(\S\w+\://\S+?)\s*\](.+?)\[/link\]~<a href="$1">$2</a>~isg;        $threadpost =~ s~\[link=\s*(\S\w+\://\S+?)\s*\](.+?)\[/link\]~<a href="$1">$2</a>~isg;
       $threadpost =~ s~\[link=\s*(\S+?)\](.+?)\s*\[/link\]~<a href="http://$1">$2</a>~isg;        $threadpost =~ s~\[link=\s*(\S+?)\](.+?)\s*\[/link\]~<a href="http://$1">$2</a>~isg;
       $threadpost =~ s~\[link\]\s*(\S+?)\s*\[/link\]~<a href="$1">$1</a>~isg;        $threadpost =~ s~\[link\]\s*(\S+?)\s*\[/link\]~<a href="$1">$1</a>~isg;
       $threadpost =~ s~\[ftp\]\s*(ftp://)?(.+?)\s*\[/ftp\]~<a href="ftp://$2">$1$2</a>~isg;        $threadpost =~ s~\[ftp\]\s*(ftp://)?(.+?)\s*\[/ftp\]~<a href="ftp://$2">$1$2</a>~isg;
   }    }
   
   $threadpost =~ s~(dereferer\;url\=http\:\/\/.*?)#(\S+?\")~$1;anch=$2~isg;    $threadpost =~ s~(dereferer\;url\=http\:\/\/.*?)#(\S+?\")~$1;anch=$2~isg;
   
    if ($guest_media_disallowed && $iamguest) {     if ($guest_media_disallowed && $iamguest) {
       my $oops = qq~$maintxt{'40'}&nbsp;&nbsp;$maintxt{'41'} <a href="$scripturl?action=login">$img{'login'}</a>~;        my $oops = qq~$maintxt{'40'}&nbsp;&nbsp;$maintxt{'41'} <a href="$scripturl?action=login">$img{'login'}</a>~;
       if ($regtype) { $oops .= qq~ $maintxt{'42'} <a href="$scripturl?action=register">$img{'register'}</a>~; }        if ($regtype) { $oops .= qq~ $maintxt{'42'} <a href="$scripturl?action=register">$img{'register'}</a>~; }
   
       $threadpost =~ s~<a href=".+?</a>~[oops]~g;        $threadpost =~ s~<a href=".+?</a>~[oops]~g;
       $threadpost =~ s~<img src=".+?>~[oops]~g;        $threadpost =~ s~<img src=".+?>~[oops]~g;
       $threadpost =~ s~\[media\].*?\[/media\]~[oops]~isg;        $threadpost =~ s~\[media\].*?\[/media\]~[oops]~isg;
       $threadpost =~ s~\[oops\]~$oops~g;        $threadpost =~ s~\[oops\]~$oops~g;
   }    }
   
   $threadpost =~ s~\[media\](.*?)\[/media\]~$1~isg;    $threadpost =~ s~\[media\](.*?)\[/media\]~$1~isg;
   
   $threadpost =~ s~\[email\]\s*(\S+?\@\S+?)\s*\[/email\]~$1~isg;    $threadpost =~ s~\[email\]\s*(\S+?\@\S+?)\s*\[/email\]~$1~isg;
   $threadpost =~ s~\[email=\s*(\S+?\@\S+?)\]\s*(.*?)\s*\[/email\]~$2 ($1)~isg;    $threadpost =~ s~\[email=\s*(\S+?\@\S+?)\]\s*(.*?)\s*\[/email\]~$2 ($1)~isg;
   
   $threadpost =~ s~\[news\](.+?)\[/news\]~$1~isg;    $threadpost =~ s~\[news\](.+?)\[/news\]~$1~isg;
   $threadpost =~ s~\[gopher\](.+?)\[/gopher\]~$1~isg;    $threadpost =~ s~\[gopher\](.+?)\[/gopher\]~$1~isg;
   $threadpost =~ s~\[ftp\](.+?)\[/ftp\]~$1~isg;    $threadpost =~ s~\[ftp\](.+?)\[/ftp\]~$1~isg;
   
   while ($threadpost =~ /\[quote\s+author=(.*?)\slink=.*?\s+date=(.*?)\s*\]\n*.*?\n*\[\/quote\]/is) {    while ($threadpost =~ /\[quote\s+author=(.*?)\slink=.*?\s+date=(.*?)\s*\]\n*.*?\n*\[\/quote\]/is) {
       my $author = $1;        my $author = $1;
       my $date   = &timeformat($2, 1);        my $date   = &timeformat($2, 1);
   
       if ($author) { # out of YaBBC.pl -> sub quotemsg {        if ($author) { # out of YaBBC.pl -> sub quotemsg {
           &ToChars($author);            &ToChars($author);
           if (!-e "$memberdir/$author.vars"){ # if the file is there it is an unencrypted user ID            if (!-e "$memberdir/$author.vars"){ # if the file is there it is an unencrypted user ID
               $author = &decloak($author); # if not, decrypt it and see if it is a regged user                $author = &decloak($author); # if not, decrypt it and see if it is a regged user
               if (!-e "$memberdir/$author.vars"){ # if still not found probably the author is a screen name                if (!-e "$memberdir/$author.vars"){ # if still not found probably the author is a screen name
                   $testauthor = &MemberIndex("who_is", "$author"); # check if this name exists in the memberlist                    $testauthor = &MemberIndex("who_is", "$author"); # check if this name exists in the memberlist
                   if ($testauthor ne ""){ # if it is, load the user id returned                    if ($testauthor ne ""){ # if it is, load the user id returned
                       $author = $testauthor;                        $author = $testauthor;
                       &LoadUser($author);                        &LoadUser($author);
                       $author = ${$uid.$author}{'realname'}; # set final author var to the current users screen name                        $author = ${$uid.$author}{'realname'}; # set final author var to the current users screen name
                   } else {                    } else {
                       $author = &decloak($author); # if all fails it is a non existing real name so decode and asign as screenname                        $author = &decloak($author); # if all fails it is a non existing real name so decode and asign as screenname
                   }                    }
               } else {                } else {
                   &LoadUser($author); # after encoding the user ID was found and loaded, setting the current real name                    &LoadUser($author); # after encoding the user ID was found and loaded, setting the current real name
                   $author = ${$uid.$author}{'realname'};                    $author = ${$uid.$author}{'realname'};
               }                }
           } else {            } else {
               &LoadUser($author); # it was an old style user id which could be loaded and screen name set to final author                &LoadUser($author); # it was an old style user id which could be loaded and screen name set to final author
               $author = ${$uid.$author}{'realname'};                $author = ${$uid.$author}{'realname'};
           }            }
       }        }
   
       $threadpost =~ s~\[quote\s+author=.*?link=.*?\s+date=.*?\s*\]\n*(.*?)\n*\[/quote\]~<br /><i>$author $maintxt{'30a'} $date</a>:</i><table cellspacing="1" width="90%"><tr><td width="100%"><table cellpadding="2" cellspacing="0" width="100%"><tr><td width="100%"><font size="1">$1</font></td></tr></table></td></tr></table>~is;        $threadpost =~ s~\[quote\s+author=.*?link=.*?\s+date=.*?\s*\]\n*(.*?)\n*\[/quote\]~<br /><i>$author $maintxt{'30a'} $date</a>:</i><table cellspacing="1" width="90%"><tr><td width="100%"><table cellpadding="2" cellspacing="0" width="100%"><tr><td width="100%"><font size="1">$1</font></td></tr></table></td></tr></table>~is;
   }    }
   $threadpost =~ s~\[quote\]\n*(.+?)\n*\[/quote\]~<br /><i>$maintxt{'31'}:</i><table cellspacing="1" width="90%"><tr><td width="100%"><table cellpadding="2" cellspacing="0" width="100%"><tr><td width="100%"><font face="Arial,Helvetica" size="1">$1</font></td></tr></table></td></tr></table>~isg;    $threadpost =~ s~\[quote\]\n*(.+?)\n*\[/quote\]~<br /><i>$maintxt{'31'}:</i><table cellspacing="1" width="90%"><tr><td width="100%"><table cellpadding="2" cellspacing="0" width="100%"><tr><td width="100%"><font face="Arial,Helvetica" size="1">$1</font></td></tr></table></td></tr></table>~isg;
   
   $threadpost =~ s~\[list\]~<ul>~isg;    $threadpost =~ s~\[list\]~<ul>~isg;
   $threadpost =~ s~\[\*\]~<li>~isg;    $threadpost =~ s~\[\*\]~<li>~isg;
   $threadpost =~ s~\[/list\]~</ul>~isg;    $threadpost =~ s~\[/list\]~</ul>~isg;
   
   $threadpost =~ s~\[pre\](.+?)\[/pre\]~'<pre>' . dopre($1) . '</pre>'~iseg;    $threadpost =~ s~\[pre\](.+?)\[/pre\]~'<pre>' . dopre($1) . '</pre>'~iseg;
   
   $threadpost =~ s~\[flash=(\S+?),(\S+?)\](\S+?)\[/flash\]~$3~isg;    $threadpost =~ s~\[flash=(\S+?),(\S+?)\](\S+?)\[/flash\]~$3~isg;
   
   $threadpost =~ s~\{\{~\[~g;    $threadpost =~ s~\{\{~\[~g;
   $threadpost =~ s~\}\}~\]~g;    $threadpost =~ s~\}\}~\]~g;
   
   if ($threadpost =~ m~\[table\]~i) {    if ($threadpost =~ m~\[table\]~i) {
       $threadpost =~ s~\n{0,1}\[table\]\n*(.+?)\n*\[/table\]\n{0,1}~<table>$1</table>~isg;        $threadpost =~ s~\n{0,1}\[table\]\n*(.+?)\n*\[/table\]\n{0,1}~<table>$1</table>~isg;
       while ($threadpost =~ s~\<table\>(.*?)\n*\[tr\]\n*(.*?)\n*\[/tr\]\n*(.*?)\</table\>~<table>$1<tr>$2</tr>$3</table>~is) { }        while ($threadpost =~ s~\<table\>(.*?)\n*\[tr\]\n*(.*?)\n*\[/tr\]\n*(.*?)\</table\>~<table>$1<tr>$2</tr>$3</table>~is) { }
       while ($threadpost =~ s~\<tr\>(.*?)\n*\[td\]\n{0,1}(.*?)\n{0,1}\[/td\]\n*(.*?)\</tr\>~<tr>$1<td>$2</td>$3</tr>~is)     { }        while ($threadpost =~ s~\<tr\>(.*?)\n*\[td\]\n{0,1}(.*?)\n{0,1}\[/td\]\n*(.*?)\</tr\>~<tr>$1<td>$2</td>$3</tr>~is)     { }
   }    }
   
   $threadpost =~ s~\[\&table(.*?)\]~<table$1>~g;    $threadpost =~ s~\[\&table(.*?)\]~<table$1>~g;
   $threadpost =~ s~\[/\&table\]~</table>~g;    $threadpost =~ s~\[/\&table\]~</table>~g;
   $threadpost =~ s~\n~<br />~ig;    $threadpost =~ s~\n~<br />~ig;
   
   ### Censor it ###    ### Censor it ###
   $threadtitle = &Censor($threadtitle);    $threadtitle = &Censor($threadtitle);
   $threadpost  = &Censor($threadpost);    $threadpost  = &Censor($threadpost);
   
   &ToChars($threadtitle);    &ToChars($threadtitle);
   &ToChars($threadpost);    &ToChars($threadpost);
   
   $threaddate = timeformat($threaddate, 1);    $threaddate = timeformat($threaddate, 1);
} }
   
1; 1;