F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\Printpage.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\Printpage.pm
############################################################################### ###############################################################################
# Printpage.pl                                                                # # Printpage.pm                                                                #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# 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.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 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.                      #
############################################################################### ###############################################################################
  use CGI::Carp qw(fatalsToBrowser);
  our $VERSION = '2.6.12';
   
$printpageplver = 'YaBB 2.5.2 $Revision: 1.0 $'; $printpagepmver = 'YaBB 2.6.12 $Revision: 1651 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
  get_micon();
   
sub Print_IM { sub Print_IM {
   if    ($INFO{'caller'} == 1) { fopen(THREADS, "$memberdir/$username.msg")    || &donoopen; $boxtitle = "$maintxt{'316'}"; $type = "$maintxt{'318'}" }    if ($iamguest) { fatal_error('not_allowed'); }
   elsif ($INFO{'caller'} == 2) { fopen(THREADS, "$memberdir/$username.outbox") || &donoopen; $boxtitle = "$maintxt{'320'}"; $type = "$maintxt{'324'}"; }     LoadLanguage('InstantMessage'); 
   else { fopen(THREADS, "$memberdir/$username.imstore") || &donoopen; $boxtitle = "$load_imtxt{'46'}"; $type = "$maintxt{'318'}/$maintxt{'324'}"; }  
   @threads = <THREADS>;     my ( 
   fclose(THREADS);         $fromTitle,    $toTitle,      $toTitleCC,     $toTitleBCC, 
         $usernameFrom, $usernameTo,   $usernameCC,    $usernameBCC,
   ### Lets output all that info. ###         $pmAttachment, $pmShowAttach, $pmAttachments, %attach_gif 
   $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">  
     if ( $INFO{'caller'} == 1 ) {
         fopen( THREADS, "$memberdir/$username.msg" ) || donoopen();
         $boxtitle = qq~$inmes_txt{'inbox'}~;
     }
     elsif ( $INFO{'caller'} == 2 ) {
         fopen( THREADS, "$memberdir/$username.outbox" ) || donoopen();
         $boxtitle = qq~$inmes_txt{'outbox'}~;
     }
     elsif ( $INFO{'caller'} == 3 ) {
         fopen( THREADS, "$memberdir/$username.imstore" ) || donoopen();
         $boxtitle   = qq~$inmes_txt{'storage'}~;
         $storetitle = qq~$INFO{'viewfolder'}~;
     }
     elsif ( $INFO{'caller'} == 5 ) {
         fopen( THREADS, "$memberdir/broadcast.messages" ) || donoopen();
         $boxtitle = qq~$inmes_txt{'broadcast'}~;
     }
     @threads = <THREADS>;
     fclose(THREADS);
   
     $threadid = $INFO{'id'};
     foreach my $thread (@threads) {
         chomp $thread;
         if ( $thread =~ /$threadid/xsm ) {
             (
                 undef,          $threadposter,   $threadtousers,
                 $threadccusers, $threadbccusers, $threadtitle,
                 $threaddate,    $threadpost,     undef,
                 undef,          undef,           $threadstatus,
                 undef,          $fold,           $threadAttach
             ) = split /\|/xsm, $thread;
             if ( $INFO{'caller'} == 3 ) {
                 $folder = ucfirst $fold;
                 $boxtitle .= qq~ &gt;&gt; $folder~;
             }
         }
     }
   
     $printDate = timeformat( $date, 1 );
   
     # Lets output all that info.
     if ($yycharset) {$yymycharset = $yycharset;}
     $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="$abbr_lang" lang="$abbr_lang">
<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=$yymycharset" />
  <meta name="robots" content="noindex,noarchive" />
<script language="JavaScript1.2" type="text/javascript" src="$yyhtml_root/YaBB.js"></script>  <link rel="stylesheet" href="$yyhtml_root/Templates/Forum/$usestyle.css" type="text/css" /> 
<script language="JavaScript" type="text/javascript">  <style type="text/css"> 
<!--    body { background-color:#fff;background-image:none; } 
function printPage() {  </style> 
   if (window.print) {  <style type="text/css" media="print"> 
       agree = confirm('$maintxt{773}');     .no-print { display: none; } 
       if (agree) window.print();  </style> 
   }  <script type="text/javascript" src="$yyhtml_root/YaBB.js"></script> 
}  <script type="text/javascript"> 
   
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>
   
<body onload="printPage()">  <table style="width:96%; margin-top:10px"> 
     <tr>
<table width="96%" align="center">         <td class="vtop"> 
   <tr>             <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span> 
       <td align="left" valign="top">         </td> 
           <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span>         <td class="right vtop"> 
       </td>             <input type="button" id="Hide_Image" value="$maintxt{'669a'}" class="no-print" onclick="do_images();" /> 
       <td align="right" valign="top">         </td> 
           <input type="button" id="Hide_Image" value="$maintxt{'669a'}" onclick="do_images();" />     </tr><tr> 
       </td>         <td class="vtop" colspan="2"> 
   </tr>         <!-- Uncomment the following line if you want the Forum URL to appear--> 
   <tr>             <!--<span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl</span><br />--> 
       <td align="left" valign="top" colspan="2">             <!--<span style="font-family: arial, sans-serif; font-size: 16px; font-weight: bold;">$load_imtxt{'71'} $boxtitle $inmes_txt{'30'} $printDate</span>--> 
           <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl</span>             <!--<span style="font-family: arial, sans-serif; font-size: 16px; font-weight: bold;">$mbname &gt;&gt; $inmes_txt{'usercp'} &gt;&gt; $boxtitle $storetitle</span>--> 
           <br />             <span style="font-family: arial, sans-serif; font-size: 16px; font-weight: bold;">$load_imtxt{'71'} $inmes_txt{'usercp'} &gt;&gt; $boxtitle  $storetitle $inmes_txt{'30'} $printDate</span> 
           <span style="font-family: arial, sans-serif; font-size: 14px; font-weight: bold;">$load_imtxt{'71'} $boxtitle $maintxt{'30'} $date</span>             <br /> 
       </td>             <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl?action=imshow;caller=$INFO{'caller'};id=$INFO{'id'}</span> 
   </tr>         </td> 
     </tr>
</table> </table>
   
<br /> <br />
~; ~;
   
   # Split the threads up so we can print them.     $threadDate = timeformat( $threaddate, 1 ); 
   foreach $thread (@threads) {  
       ($threadposter, $threadtitle, $threaddate, $threadpost, undef) = split(/\|/, $thread);  
   
       &do_print;  
       $output .= qq~  
<table width="96%" align="center" cellpadding="10" style="border: 1px solid #000000;">  
   <tr>  
       <td style="font-family: arial, sans-serif; font-size: 12px;">  
           $maintxt{'70'}: <b>$threadtitle</b><br />  
           $type <b>$threadposter</b> $maintxt{'30'} <b>$threaddate</b>  
           <hr width="100%" size="1" />  
           <span style="font-family: arial, sans-serif; font-size: 12px;">  
           $threadpost  
           </span>  
       </td>  
   </tr>  
</table>  
   
<br />     if ( $INFO{'caller'} == 1 ) { 
         if ($threadtousers) {
             foreach my $uname ( split /,/xsm, $threadtousers ) {
                 LoadUser($uname);
                 $usernameTo .= (
                       ${ $uid . $uname }{'realname'}
                     ? ${ $uid . $uname }{'realname'}
                     : (
                           $uname ? qq~$uname ($maintxt{'470a'})~
                         : $maintxt{'470a'}
                     )
                 ) . q{, };    # 470a == Ex-Member
             }
             $usernameTo =~ s/, $//sm;
             $usernameTo = qq~<b>$usernameTo</b><br />~;
             $toTitle    = qq~$inmes_txt{'324'}:~;
         }
         if ($threadccusers) {
             foreach my $uname ( split /,/xsm, $threadccusers ) {
                 LoadUser($uname);
                 $usernameCC .= (
                       ${ $uid . $uname }{'realname'}
                     ? ${ $uid . $uname }{'realname'}
                     : (
                           $uname ? qq~$uname ($maintxt{'470a'})~
                         : $maintxt{'470a'}
                     )
                 ) . q{, };
             }
             $usernameCC =~ s/, $//sm;
             $usernameCC = qq~<b>$usernameCC</b><br />~;
             $toTitleCC  = qq~$inmes_txt{'325'}:~;
         }
         if ($threadbccusers) {
             foreach my $uname ( split /,/xsm, $threadbccusers ) {
                 if ( $uname eq $username ) {
                     LoadUser($uname);
                     $usernameBCC =
                         ${ $uid . $uname }{'realname'}
                       ? ${ $uid . $uname }{'realname'}
                       : (
                           $uname ? qq~$uname ($maintxt{'470a'})~
                         : $maintxt{'470a'}
                       );
                 }
             }
             if ($usernameBCC) {
                 $usernameBCC = qq~<b>$usernameBCC</b>~;
                 $toTitleBCC  = qq~$inmes_txt{'326'}:~;
             }
         }
   
         if ( $threadstatus eq 'g' || $threadstatus eq 'ga' ) {
             my ( $guestName, $guestEmail ) = split / /sm, $threadposter;
             $guestName =~ s/%20/ /gsm;
             $usernameFrom = qq~<b>$guestName ($guestEmail)</b><br />~;
         }
         else {
             LoadUser($threadposter);
             $usernameFrom =
                 ${ $uid . $threadposter }{'realname'}
               ? ${ $uid . $threadposter }{'realname'}
               : (
                   $threadposter ? qq~$threadposter ($maintxt{'470a'})~
                 : $maintxt{'470a'}
               );    # 470a == Ex-Member
             $usernameFrom = qq~<b>$usernameFrom</b><br />~;
         }
         $fromTitle = qq~$inmes_txt{'318'}:~;
     }
     chomp $threadAttach;
     if ( $threadAttach ne q{} ) {
         LoadLanguage('FA');
         foreach ( split /,/xsm, $threadAttach ) {
             my ( $pmAttachFile, undef ) = split /~/xsm, $_;
             if ( $pmAttachFile =~ /\.(.+?)$/sm ) {
                 $ext = lc $1;
             }
             if ( !exists $attach_gif{$ext} ) {
                 $attach_gif{$ext} =
                   ( $ext
                       && -e "$htmldir/Templates/Forum/$useimages/$att_img{$ext}" 
                   ) ? "$imagesdir/$att_img{$ext}" : "$micon_bg{'paperclip'}";
             }
             my $filesize = -s "$pmuploaddir/$pmAttachFile";
             if ($filesize) {
                 if (   $pmAttachFile =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/ism
                     && $pmDisplayPics == 1 )
                 {
                     $imagecount++;
                     $pmShowAttach .=
  qq~<div class="small" style="float:left; margin:8px;"><img src="$attach_gif{$ext}" class="bottom" alt="" /> $pmAttachFile ( ~
                       . int( $filesize / 1024 )
                       . qq~ KB)<br /><img src="$pmuploadurl/$pmAttachFile" name="attach_img_resize" alt="$pmAttachFile" title="$pmAttachFile" style="display:none;" /></div>\n~;
                 }
                 else {
                     $pmAttachment .=
  qq~<div class="small"><img src="$attach_gif{$ext}" class="bottom" alt="" /> $pmAttachFile ( ~
                       . int( $filesize / 1024 )
                       . q~ KB)</div>~;
                 }
             }
             else {
                 $pmAttachment .=
  qq~<div class="small"><img src="$attach_gif{$ext}" class="bottom" alt="" />  $pmAttachFile ($fatxt{'1'})</div>~;
             }
         }
         if ( $pmShowAttach && $pmAttachment ) {
             $pmAttachment =~
               s/<div class="small">/<div class="small" style="margin:8px;">/gsm;
         }
         $pmAttachments .= qq~
             <hr />
             $pmAttachment
             $pmShowAttach~;
     }
     elsif ( $INFO{'caller'} == 2 ) {
         LoadUser($threadposter);
         $usernameFrom =
             ${ $uid . $threadposter }{'realname'}
           ? ${ $uid . $threadposter }{'realname'}
           : (
               $threadposter ? qq~$threadposter ($maintxt{'470a'})~
             : $maintxt{'470a'}
           );    # 470a == Ex-Member
         $usernameFrom = qq~<b>$usernameFrom</b><br />~;
         $fromTitle    = qq~$inmes_txt{'318'}:~;
   
         if ( $threadstatus !~ /b/sm ) {
             if ( $threadstatus !~ /gr/sm ) {
                 foreach my $uname ( split /,/xsm, $threadtousers ) {
                     LoadUser($uname);
                     $usernameTo .= (
                           ${ $uid . $uname }{'realname'}
                         ? ${ $uid . $uname }{'realname'}
                         : (
                               $uname ? qq~$uname ($maintxt{'470a'})~
                             : $maintxt{'470a'}
                         )
                     ) . q{, };    # 470a == Ex-Member
                 }
             }
             else {
                 my ( $guestName, $guestEmail ) = split / /sm, $threadtousers;
                 $guestName =~ s/%20/ /gxsm;
                 $usernameTo = qq~$guestName ($guestEmail)~;
             }
             $toTitle = qq~$inmes_txt{'324'}:~;
         }
         else {
             require Sources::InstantMessage;
             foreach my $uname ( split /,/xsm, $threadtousers ) {
                 $usernameTo .= links_to($uname);
             }
             $toTitle = qq~$inmes_txt{'324'} $inmes_txt{'327'}:~;
         }
         $usernameTo =~ s/, $//sm;
         $usernameTo = qq~<b>$usernameTo</b><br />~;
         if ($threadccusers) {
             foreach my $uname ( split /,/xsm, $threadccusers ) {
                 LoadUser($uname);
                 $usernameCC .= (
                       ${ $uid . $uname }{'realname'}
                     ? ${ $uid . $uname }{'realname'}
                     : (
                           $uname ? qq~$uname ($maintxt{'470a'})~
                         : $maintxt{'470a'}
                     )
                 ) . q{, };    # 470a == Ex-Member
             }
             $usernameCC =~ s/, $//sm;
             $usernameCC = qq~<b>$usernameCC</b><br />~;
             $toTitleCC  = qq~$inmes_txt{'325'}:~;
         }
         if ($threadbccusers) {
             foreach my $uname ( split /,/xsm, $threadbccusers ) {
                 LoadUser($uname);
                 $usernameBCC .= (
                       ${ $uid . $uname }{'realname'}
                     ? ${ $uid . $uname }{'realname'}
                     : (
                           $uname ? qq~$uname ($maintxt{'470a'})~
                         : $maintxt{'470a'}
                     )
                 ) . q{, };    # 470a == Ex-Member
             }
             $usernameBCC =~ s/, $//sm;
             $usernameBCC = qq~<b>$usernameBCC</b>~;
             $toTitleBCC  = qq~$inmes_txt{'326'}:~;
         }
     }
     elsif ( $INFO{'caller'} == 3 ) {
         if ( $threadstatus !~ /b/sm ) {
             if ( $threadstatus !~ /gr/sm ) {
                 foreach my $uname ( split /,/xsm, $threadtousers ) {
                     LoadUser($uname);
                     $usernameTo .= (
                           ${ $uid . $uname }{'realname'}
                         ? ${ $uid . $uname }{'realname'}
                         : (
                               $uname ? qq~$uname ($maintxt{'470a'})~
                             : $maintxt{'470a'}
                         )
                     ) . q{, };    # 470a == Ex-Member
                 }
             }
             else {
                 my ( $guestName, $guestEmail ) = split / /sm, $threadtousers;
                 $guestName =~ s/%20/ /gsm;
                 $usernameTo = qq~$guestName ($guestEmail)~;
             }
             $toTitle = qq~$inmes_txt{'324'}:~;
             if ( $threadccusers && $threadposter eq $username ) {
                 foreach my $uname ( split /,/xsm, $threadccusers ) {
                     LoadUser($uname);
                     $usernameCC .= (
                           ${ $uid . $uname }{'realname'}
                         ? ${ $uid . $uname }{'realname'}
                         : (
                               $uname ? qq~$uname ($maintxt{'470a'})~
                             : $maintxt{'470a'}
                         )
                     ) . q{, };    # 470a == Ex-Member
                 }
                 $usernameCC =~ s/, $//sm;
                 $usernameCC = qq~<b>$usernameCC</b><br />~;
                 $toTitleCC  = qq~$inmes_txt{'325'}:~;
             }
             if ( $threadbccusers && $threadposter eq $username ) {
                 foreach my $uname ( split /,/xsm, $threadbccusers ) {
                     LoadUser($uname);
                     $usernameBCC .= (
                           ${ $uid . $uname }{'realname'}
                         ? ${ $uid . $uname }{'realname'}
                         : (
                               $uname ? qq~$uname ($maintxt{'470a'})~
                             : $maintxt{'470a'}
                         )
                     ) . q{, };    # 470a == Ex-Member
                 }
                 $usernameBCC =~ s/, $//sm;
                 $usernameBCC = qq~<b>$usernameBCC</b>~;
                 $toTitleBCC  = qq~$inmes_txt{'326'}:~;
             }
         }
         else {
             foreach my $uname ( split /,/xsm, $threadtousers ) {
                 require Sources::InstantMessage;
                 $usernameTo .= links_to($uname);
             }
             $toTitle = qq~$inmes_txt{'324'} $inmes_txt{'327'}:~;
         }
         $usernameTo =~ s/, $//sm;
         $usernameTo = qq~<b>$usernameTo</b><br />~;
   
         if ( $threadstatus eq 'g' || $threadstatus eq 'ga' ) {
             my ( $guestName, $guestEmail ) = split / /sm, $threadposter;
             $guestName =~ s/%20/ /gsm;
             $usernameFrom = qq~$guestName ($guestEmail)~;
         }
         else {
             LoadUser($threadposter);
             $usernameFrom =
                 ${ $uid . $threadposter }{'realname'}
               ? ${ $uid . $threadposter }{'realname'}
               : (
                   $threadposter ? qq~$threadposter ($maintxt{'470a'})~
                 : $maintxt{'470a'}
               );    # 470a == Ex-Member
         }
         $usernameFrom = qq~<b>$usernameFrom</b><br />~;
         $fromTitle    = qq~$inmes_txt{'318'}:~;
   
     }
     elsif ( $INFO{'caller'} == 5
         && ( $threadstatus eq 'g' || $threadstatus eq 'ga' ) )
     {
         my ( $guestName, $guestEmail ) = split / /sm, $threadposter;
         $guestName =~ s/%20/ /gsm;
         $usernameFrom = qq~<b>$guestName ($guestEmail)</b><br />~;
         $fromTitle    = qq~$inmes_txt{'318'}:~;
   
     }
     elsif ( $INFO{'caller'} == 5 && $threadstatus =~ /b/sm ) {
         if ($threadtousers) {
             require Sources::InstantMessage;    # Needed for To Member Groups
             foreach my $uname ( split /,/xsm, $threadtousers ) {
                 $usernameTo .= links_to($uname);
             }
             $usernameTo =~ s/, $//sm;
             $usernameTo .= q~<br />~;
             $toTitle = qq~$inmes_txt{'324'} $inmes_txt{'327'}:~;
         }
   
         LoadUser($threadposter);
         $usernameFrom =
             ${ $uid . $threadposter }{'realname'}
           ? ${ $uid . $threadposter }{'realname'}
           : (
               $threadposter ? qq~$threadposter ($maintxt{'470a'})~
             : $maintxt{'470a'}
           );    # 470a == Ex-Member
   
         $usernameFrom = qq~<b>$usernameFrom</b><br />~;
         $fromTitle    = qq~$inmes_txt{'318'}:~;
     }
   
     do_print();
     $output .= qq~
  <table class="cs_10px" style="border: 1px solid #000000; width:96%">
     <tr>
         <td style="font-family: arial, sans-serif; font-size: 12px;">
             <div>$inmes_txt{'70'}: <b>$threadtitle</b></div>
             <div>$inmes_txt{'317'}: <b>$threadDate</b></div>
             $toTitle $usernameTo
             $fromTitle $usernameFrom
             $toTitleCC $usernameCC
             $toTitleBCC $usernameBCC
             <hr />
             <span style="font-family: arial, sans-serif; font-size: 12px;">
             $threadpost
             </span>
             $pmAttachments
         </td>
     </tr>
  </table>
  <form><p class="no-print" style="text-align:center"><input class="no-print" type="button" value=" $maintxt{'printpage'} " onclick="window.print();" /></p></form>
~; ~;
   }  
   
   $output .= qq~    $output .= qq~
<table width="96%" align="center">  <table class="pad_10px" style="width:96%"> 
   <tr>    <tr>
       <td align="center">         <td class="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(); 
     return;
} }
   
sub Print { sub Print {
   $num = $INFO{'num'};    $num  = $INFO{'num'};
     $post = $INFO{'post'};
   # Determine category  
   $curcat = ${$uid.$currentboard}{'cat'};  
   &MessageTotals("load", $num);  
   
   my $ishidden;  
   if (${$num}{'threadstatus'} =~ /h/i) {  
       $ishidden = 1;  
   }  
   
   if ($ishidden && !$iammod && !$iamadmin && !$iamgmod) { &fatal_error("no_access"); }  
   
   # Figure out the name of the category  
   unless ($mloaded == 1) { require "$boardsdir/forum.master"; }  
   ($cat, $catperms) = split(/\|/, $catinfo{"$curcat"});  
   
   ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$currentboard"});  
   
   &LoadCensorList;  
   
   # Lets open up the thread file itself  
   unless (ref($thread_arrayref{$num})) {  
       fopen(THREADS, "$datadir/$num.txt") || &donoopen;  
       @{$thread_arrayref{$num}} = <THREADS>;  
       fclose(THREADS);  
   }  
   $cat =~ s/\n//g;  
   
   ($messagetitle, $poster, undef, $date, undef) = split(/\|/, ${$thread_arrayref{$num}}[0]);  
   
   $startedby = $poster;     # Determine category 
   $startedon = timeformat($date, 1);     $curcat = ${ $uid . $currentboard }{'cat'}; 
   &ToChars($messagetitle);     MessageTotals( 'load', $num ); 
   ($messagetitle, undef) = &Split_Splice_Move($messagetitle,0);  
     my $ishidden;
   ### Lets output all that info. ###     if ( ${$num}{'threadstatus'} =~ /h/ism ) { 
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">         $ishidden = 1; 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">     } 
   
     if ( $ishidden && !$staff ) {
         fatal_error('no_access');
     }
   
     # Figure out the name of the category
     get_forum_master();
     ( $cat, $catperms ) = split /\|/xsm, $catinfo{"$curcat"};
   
     ( $boardname, $boardperms, $boardview ) =
       split /\|/xsm, $board{"$currentboard"};
   
     LoadCensorList();
   
     # Lets open up the thread file itself
     if ( !ref $thread_arrayref{$num} ) {
         fopen( THREADS, "$datadir/$num.txt" ) || donoopen();
         @{ $thread_arrayref{$num} } = <THREADS>;
         fclose(THREADS);
     }
     $cat =~ s/\n//gxsm;
   
     ( $messagetitle, $poster, undef, $date, undef ) =
       split /\|/xsm, ${ $thread_arrayref{$num} }[0];
   
     $startedby = $poster;
     $startedon = timeformat( $date, 1 );
     ToChars($messagetitle);
     ( $messagetitle, undef ) = Split_Splice_Move( $messagetitle, 0 );
     my $pageTitle = $post ? $maintxt{'668a'} : $maintxt{'668'};
   
     ### Lets output all that info. ###
     if ($yycharset) {$yymycharset = $yycharset;}
     $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="$abbr_lang" lang="$abbr_lang">
<head> <head>
<title>$mbname - $maintxt{'668'}</title>  <title>$mbname - $pageTitle</title> 
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" /> <meta http-equiv="Content-Type" content="text/html; charset=$yymycharset" />
  <meta name="robots" content="noindex,noarchive" />
<script language="JavaScript1.2" type="text/javascript" src="$yyhtml_root/YaBB.js"></script>  <link rel="canonical" href="$scripturl?num=$num" /> 
<script language="JavaScript" type="text/javascript">  <link rel="stylesheet" href="$yyhtml_root/Templates/Forum/$usestyle.css" type="text/css" /> 
<!--  <style type="text/css"> 
function printPage() {     body { background-color:#fff;background-image:none; } 
   if (window.print) {  </style> 
       agree = confirm('$maintxt{773}');  <style type="text/css" media="print"> 
       if (agree) window.print();     .no-print { display: none; } 
   }  </style> 
}  <script type="text/javascript" src="$yyhtml_root/YaBB.js"></script> 
  <script type="text/javascript">
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>
   
<body onload="printPage()">  <table style="width:96%; margin-top:10px"> 
     <tr>
<table width="96%" align="center">         <td class="vtop"> 
   <tr>             <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span> 
       <td align="left" valign="top">         </td> 
           <span style="font-family: arial, sans-serif; font-size: 18px; font-weight: bold;">$mbname</span>         <td class="right vtop"> 
       </td>             <input type="button" id="Hide_Image" value="$maintxt{'669a'}" class="no-print" onclick="do_images();" /> 
       <td align="right" valign="top">         </td> 
           <input type="button" id="Hide_Image" value="$maintxt{'669a'}" onclick="do_images();" />     </tr><tr> 
       </td>         <td class="vtop" colspan="2"> 
   </tr>             <!-- Uncomment the following line if you want the Forum URL to appear --> 
   <tr>             <!--<span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl</span><br />--> 
       <td align="left" valign="top" colspan="2">             <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: 10px;">$scripturl</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: 16px; font-weight: bold;">$cat &gt;&gt; $boardname &gt;&gt; $messagetitle</span>             <br /> 
           <br />            <hr  />
           <span style="font-family: arial, sans-serif; font-size: 10px;">$scripturl?num=$num</span>             <span style="font-family: arial, sans-serif; font-size: 14px; font-weight: bold;">$maintxt{'195'} $startedby $maintxt{'30'} $startedon</span> 
           <br />         </td> 
           <hr size="1" width="100%" />     </tr> 
           <span style="font-family: arial, sans-serif; font-size: 14px; font-weight: bold;">$maintxt{'195'} $startedby $maintxt{'30'} $startedon</span>  
       </td>  
   </tr>  
</table> </table>
   
<br />~; <br />~;
   
   &LoadLanguage('FA');     LoadLanguage('FA'); 
   # Split the threads up so we can print them.  
   foreach $thread (@{$thread_arrayref{$num}}) {  
       ($threadtitle, $threadposter, undef, $threaddate, undef, undef, undef, undef, $threadpost, undef, undef, undef, $attachments) = split(/\|/, $thread);  
   
       ($threadtitle, undef) = &Split_Splice_Move($threadtitle,0);  
       ($threadpost, undef) = &Split_Splice_Move($threadpost,$num);  
       &do_print;  
   
       $output .= qq~  
<table width="96%" align="center" cellpadding="10" style="border: 1px solid #000000;">  
   <tr>  
       <td style="font-family: arial, sans-serif; font-size: 12px;">  
           $maintxt{'196'}: <b>$threadtitle</b><br />  
           $maintxt{'197'} <b>$threadposter</b> $maintxt{'30'} <b>$threaddate</b>  
           <hr width="100%" size="1" />  
           <div style="font-family: arial, sans-serif; font-size: 12px;">  
           $threadpost~;  
   
       chomp $attachments;  
       if ($attachments) {  
           # store all downloadcounts in variable  
           if (!%attach_count) {  
               my ($atfile,$atcount);  
               fopen(ATM, "$vardir/attachments.txt");  
               while (<ATM>) {  
                   (undef, undef, undef, undef, undef, undef, undef, $atfile, $atcount) =split(/\|/, $_);  
                   $attach_count{$atfile} = $atcount;  
               }  
               fclose(ATM);  
               $attach_count{'no_attachments'} = 1 if !%attach_count;  
           }  
   
           my $attachment = '';  
           my $showattach = '';  
   
           foreach (split(/,/, $attachments)) {  
               $_ =~ /\.(.+?)$/;  
               my $ext = lc($1);  
               unless (exists $attach_gif{$ext}) {  
                   $attach_gif{$ext} = ($ext && -e "$forumstylesdir/$useimages/$ext.gif") ? "$ext.gif" : "paperclip.gif";  
               }  
               my $filesize = -s "$uploaddir/$_";  
               if ($filesize) {  
                   if ($_ =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/i && $amdisplaypics == 1) {  
                       $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~;  
                   } 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>~;  
                   }  
               } 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>~;  
               }  
           }  
           if ($showattach && $attachment) {  
               $attachment =~ s/<div class="small">/<div class="small" style="margin:8px;">/g;  
           }  
           $output .= qq~  
           <hr width="100%" size="1" />  
           $attachment  
           $showattach~;  
       }  
   
       $output .= qq~  
           </div>  
       </td>  
   </tr>  
</table>  
   
<br />~;     # Split the threads up so we can print them. 
   }     $postnum = 0; 
     foreach my $thread ( @{ $thread_arrayref{$num} } ) {
   $output .= qq~         $postnum++; 
<table width="96%" align="center">         ( 
   <tr>             $threadtitle, $threadposter, undef, $threaddate, 
       <td align="center" style="font-family: arial, sans-serif; font-size: 10px;">             undef,        undef,         undef, undef, 
           $yycopyright             $threadpost,  undef,         undef, undef, 
       </td>             $attachments 
   </tr>         ) = split /\|/xsm, $thread; 
         if ( $post && ( $post ne $postnum ) ) {
             next;
             (
                 $threadtitle, $threadposter, undef, $threaddate,
                 undef,        undef,         undef, undef,
                 $threadpost,  undef,         undef, undef,
                 $attachments
             ) = split /\|/xsm, @{ $thread_arrayref{$num} }[$post];
             last;
         }
         ( $threadtitle, undef ) = Split_Splice_Move( $threadtitle, 0 );
         ( $threadpost,  undef ) = Split_Splice_Move( $threadpost,  $num );
   
         do_print();
   
         $output .= qq~
  <table class="pad_10px" style="border: 1px solid #000000; width:96%">
     <tr>
         <td style="font-family: arial, sans-serif; font-size: 12px;">
             $maintxt{'196'}: <b>$threadtitle</b><br />
             $maintxt{'197'} <b>$threadposter</b> $maintxt{'30'} <b>$threaddate</b>
             <hr />
             <div style="font-family: arial, sans-serif; font-size: 12px;">
             $threadpost~;
   
         chomp $attachments;
         if ($attachments) {
   
             # store all downloadcounts in variable
             if ( !%attach_count ) {
                 my ( $atfile, $atcount );
                 fopen( ATM, "$vardir/attachments.txt" );
                 while (<ATM>) {
                     (
                         undef, undef, undef,   undef, undef,
                         undef, undef, $atfile, $atcount
                     ) = split /\|/xsm, $_;
                     $attach_count{$atfile} = $atcount;
                 }
                 fclose(ATM);
                 if ( !%attach_count ) { $attach_count{'no_attachments'} = 1; }
             }
   
             my $attachment = q{};
             my $showattach = q{};
   
             foreach ( split /,/xsm, $attachments ) {
                 if ( $_ =~ /\.(.+?)$/xsm ) {
                     $ext = lc $1;
                 }
                 if ( !exists $attach_gif{$ext} ) {
                     $attach_gif{$ext} =
                       ( $ext
                           && -e "$htmldir/Templates/Forum/$useimages/$att_img{$ext}" 
                       )
                       ? "$imagesdir/$att_img{$ext}" 
                       : "$micon_bg{'paperclip'}";
                 }
                 my $filesize = -s "$uploaddir/$_";
                 $download_txt = ( $attach_count{$_} == 1 ) ? $fatxt{'41b'} : isempty( $fatxt{'41c'}, $fatxt{'41a'} );
                 if ($filesize) {
                     if (   $_ =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/ixsm
                         && $amdisplaypics == 1 )
                     {
                         $imagecount++;
                         $showattach .=
  qq~<div class="small" style="float:left; margin:8px;"><img src="$attach_gif{$ext}" class="bottom" alt="" /> <span id="urlimagecount$imagecount" style="display:none">$scripturl?action=downloadfile;file=</span>$_ ( ~
                           . int( $filesize / 1024 )
                           . qq~ KB | $attach_count{$_} $download_txt )<br /><img src="$uploadurl/$_" name="attach_img_resize" alt="$_" id="imagecount$imagecount" title="$_" style="display:none" /></div>\n~;
                     }
                     else {
                         $attachment .=
  qq~<div class="small"><img src="$attach_gif{$ext}" class="bottom" alt="" /> $scripturl?action=downloadfile;file=$_ ( ~
                           . int( $filesize / 1024 )
                           . qq~ KB | $attach_count{$_} $download_txt )</div>~;
                     }
                 }
                 else {
                     $attachment .=
  qq~<div class="small"><img src="$attach_gif{$ext}" class="bottom" alt="" />  $_ ($fatxt{'1'}~
                       . (
                         exists $attach_count{$_}
                         ? qq~ | $attach_count{$_} $download_txt ~
                         : q{}
                       ) . q~)</div>~;
                 }
             }
             if ( $showattach && $attachment ) {
                 $attachment =~
  s/<div class="small">/<div class="small" style="margin:8px;">/gsm;
             }
             $output .= qq~
             <hr />
             $attachment
             $showattach~;
         }
   
         $output .= q~
             </div>
         </td>
     </tr>
</table> </table>
  <br />
  ~;
     }
   
     $output .= qq~
  <form><p class="no-print" style="text-align:center"><input class="no-print" type="button" value=" $maintxt{'printpage'} " onclick="window.print();" /></p></form>
  <table class="pad_10px" style="width:96%">
     <tr>
         <td class="center" style="font-family: arial, sans-serif; font-size: 10px;">
             $yycopyright
         </td>
     </tr>
  </table>
</body> </body>
</html>~; </html>~;
   
   &image_resize;     image_resize(); 
   
   &print_output_header;  
   &print_HTML_output_and_finish;  
}  
   
sub sizefont {     print_output_header(); 
   # limit minimum and maximum font pitch as CSS does not restrict it at all.     print_HTML_output_and_finish(); 
   my ($tsize, $ttext) = @_;     return; 
   if    (!$fontsizemax)         { $fontsizemax = 72; }  
   if    (!$fontsizemin)         { $fontsizemin = 6; }  
   if    ($tsize < $fontsizemin) { $tsize       = $fontsizemin; }  
   elsif ($tsize > $fontsizemax) { $tsize       = $fontsizemax; }  
   my $resized = qq~<span style="font-size:$tsize\px;">$ttext</span>~;  
   return $resized;  
} }
   
{ sub codemsg {
   my %killhash = (     my ($code) = @_; 
       ';' => '&#059;',     my %killhash = ( 
       '!' => '&#33;',         q{;}  => '&#059;', 
       '(' => '&#40;',         q{!}  => '&#33;', 
       ')' => '&#41;',         q{(}  => '&#40;', 
       '-' => '&#45;',         q{)}  => '&#41;', 
       '.' => '&#46;',         q{-}  => '&#45;', 
       '/' => '&#47;',         q{.}  => '&#46;', 
       ':' => '&#58;',         q{/}  => '&#47;', 
       '?' => '&#63;',         q{:}  => '&#58;', 
       '[' => '&#91;',         q{?}  => '&#63;', 
       '\\' => '&#92;',         q{[}  => '&#91;', 
       ']' => '&#93;',         q{\\} => '&#92;', 
       '^' => '&#94;');         q{]}  => '&#93;', 
         q{^}  => '&#94;',
   sub codemsg {     ); 
       my $code = $_[0];     if ( $code !~ /&\S*;/xsm ) { $code =~ s/;/&\x23059;/gxsm; } 
       if ($code !~ /&\S*;/) { $code =~ s/;/&#059;/g; }     $code =~ s/([\(\)\-\:\\\/\?\!\]\[\.\^])/$killhash{$1}/gxsm; 
       $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>~;  q~<br /><b>Code:</b><br /><table class="cs_thin" style="width:90%"><tr><td><table class="padd_2px"><tr><td><span style="font-family:courier; font-size:80%">CODE</span></td></tr></table></td></tr></table>~; 
       $_ =~ s~CODE~$code~g;     $_ =~ s/CODE/$code/gxsm; 
       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>  <p style="font-size:small; font-family:Arial,Helvetica; text-align:center">$maintxt{'199'}</p> 
</body> </body>
</html>~;  </html>~ or croak "$croak{'print'}"; 
   exit;    exit;
} }
   
sub do_print { sub do_print {
   $threadpost =~ s~<br />~\n~ig;     $threadpost =~ s/\[reason\](.+?)\[\/reason\]//isgxm; 
   $threadpost =~ s~\[highlight(.*?)\](.*?)\[/highlight\]~$2~isg;     $threadpost =~ s/<br \/>/\n/igxsm; 
   $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/\[highlight(.*?)\](.*?)\[\/highlight\]/$2/isgxm; 
   $threadpost =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g;     $threadpost =~ 
   $threadpost =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g;  s/\[code\s*(.+?)\]\n*(.+?)\n*\[\/code\]/<br \/><b>Code ($1):<\/b><br \/><table class=\"cs_thin\"><tr><td><table class=\"pad_2px\"><tr><td><span style=\"font-family:courier; font-size:80%\">$2<\/span><\/td><\/tr><\/table><\/td><\/tr><\/table>/isgm; 
   $threadpost =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g;     $threadpost =~ s/\[([^\]]{0,30})\n([^\]]{0,30})\]/\[$1$2\]/gxsm; 
     $threadpost =~ s/\[\/([^\]]{0,30})\n([^\]]{0,30})\]/\[\/$1$2\]/gxsm;
   $threadpost =~ s~\[b\](.*?)\[/b\]~<b>$1</b>~isg;     $threadpost =~ s/(\w+:\/\/[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)/$1\n$2/gxsm; 
   $threadpost =~ s~\[i\](.*?)\[/i\]~<i>$1</i>~isg;  
   $threadpost =~ s~\[u\](.*?)\[/u\]~<u>$1</u>~isg;     $threadpost =~ s/\[b\](.*?)\[\/b\]/<b>$1<\/b>/isgxm; 
   $threadpost =~ s~\[s\](.*?)\[/s\]~<s>$1</s>~isg;     $threadpost =~ s/\[i\](.*?)\[\/i\]/<i>$1<\/i>/isgxm; 
   $threadpost =~ s~\[move\](.*?)\[/move\]~$1~isg;     $threadpost =~ 
  s/\[u\](.*?)\[\/u\]/<span style="text-decoration:underline">$1<\/span>/isgm;
   $threadpost =~ s~\[glow(.*?)\](.*?)\[/glow\]~&elimnests($2)~eisg;     $threadpost =~ s/\[s\](.*?)\[\/s\]/<s>$1<\/s>/isgxm; 
   $threadpost =~ s~\[shadow(.*?)\](.*?)\[/shadow\]~&elimnests($2)~eisg;     $threadpost =~ s/\[move\](.*?)\[\/move\]/$1/isgxm; 
   
   $threadpost =~ s~\[shadow=(\S+?),(.+?),(.+?)\](.+?)\[/shadow\]~$4~eisg;     $threadpost =~ s/\[glow(.*?)\](.*?)\[\/glow\]/&elimnests($2)/eisgxm; 
   $threadpost =~ s~\[glow=(\S+?),(.+?),(.+?)\](.+?)\[/glow\]~$4~eisg;     $threadpost =~ s/\[shadow(.*?)\](.*?)\[\/shadow\]/&elimnests($2)/eisgxm; 
   
   $threadpost =~ s~\[color=([\w#]+)\](.*?)\[/color\]~$2~isg;     $threadpost =~ s/\[shadow=(\S+?),(.+?),(.+?)\](.+?)\[\/shadow\]/$4/eisgxm; 
   $threadpost =~ s~\[black\](.*?)\[/black\]~$1~isg;     $threadpost =~ s/\[glow=(\S+?),(.+?),(.+?)\](.+?)\[\/glow\]/$4/eisgxm; 
   $threadpost =~ s~\[white\](.*?)\[/white\]~$1~isg;  
   $threadpost =~ s~\[red\](.*?)\[/red\]~$1~isg;     $threadpost =~ s/\[color=([\w#]+)\](.*?)\[\/color\]/$2/isgxm; 
   $threadpost =~ s~\[green\](.*?)\[/green\]~$1~isg;     $threadpost =~ s/\[black\](.*?)\[\/black\]/$1/isgxm; 
   $threadpost =~ s~\[blue\](.*?)\[/blue\]~$1~isg;     $threadpost =~ s/\[white\](.*?)\[\/white\]/$1/isgxm; 
   $threadpost =~ s~\[font=(.+?)\](.+?)\[/font\]~<span style="font-family:$1;">$2</span>~isg;     $threadpost =~ s/\[red\](.*?)\[\/red\]/$1/isgxm; 
   while ($threadpost =~ s~\[size=(.+?)\](.+?)\[/size\]~&sizefont($1,$2)~eisg) { }     $threadpost =~ s/\[green\](.*?)\[\/green\]/$1/isgxm; 
     $threadpost =~ s/\[blue\](.*?)\[\/blue\]/$1/isgxm;
   $threadpost =~ s~\[quote\s+author=(.*?)\s+link=(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote author=$1 link=$2\]<i>* $1 $3</i>\[/quote\]~isg;     $threadpost =~ 
   $threadpost =~ s~\[quote(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote$1\]<i>* Me $2</i>\[/quote\]~isg;  s/\[font=(.+?)\](.+?)\[\/font\]/<span style="font-family:$1;">$2<\/span>/isgm; 
   $threadpost =~ s~\/me\s+(.*)~* $displayname $1~ig;  
     while (
   # Images in message         $threadpost =~ s/\[size=(.+?)\](.+?)\[\/size\]/sizefont($1,$2)/eisgxm ) 
   $threadpost =~ s~\[img(.*?)\](.*?)\[/img\]~ &imagemsg($1,$2) ~eisg;     { 
   sub imagemsg { # out of YaBBC.pl -> sub imagemsg {     } 
       my($attribut,$url) = @_;  
       # use or kill urls     $threadpost =~ 
       $url =~ s~\[url\](.*?)\[/url\]~$1~ig;  s/\[quote\s+author=(.*?)\s+link=(.*?)\].*\/me\s+(.*?)\[\/quote\]/\[quote author=$1 link=$2\]<i>* $1 $3<\/i>\[\/quote\]/isgm; 
       $url =~ s~\[link\](.*?)\[/link\]~$1~ig;     $threadpost =~ 
       $url =~ s~\[url\s*=\s*(.*?)\s*.*?\].*?\[/url\]~$1~ig;  s/\[quote(.*?)\].*\/me\s+(.*?)\[\/quote\]/\[quote$1\]<i>* Me $2<\/i>\[\/quote\]/isgm; 
       $url =~ s~\[link\s*=\s*(.*?)\s*.*?\].*?\[/link\]~$1~ig;     $threadpost =~ 
       $url =~ s~\[url.*?/url\]~~ig;       s/\/me\s+(.*)/* $displayname $1/igsm;    #*/ make my syntax checker happy 
       $url =~ s~\[link.*?/link\]~~ig;  
     # Images in message
       my $char_160 = chr(160);     $threadpost =~ s/\[img(.*?)\](.*?)\[\/img\]/ imagemsg($1,$2) /eisgm; 
       $url =~ s/(\s|&nbsp;|$char_160)+//g;  
     $threadpost =~ s/\[tt\](.*?)\[\/tt\]/<tt>$1<\/tt>/isgxm;
       if ($url !~ /^http.+?\.(gif|jpg|jpeg|png|bmp)$/i) {return ' ' . $url;}     $threadpost =~ 
       s/\[left\](.*?)\[\/left\]/<div style="text-align: left;">$1<\/div>/isgm;
       my %parameter;     $threadpost =~ 
       &FromHTML($attribut);  s/\[center\](.*?)\[\/center\]/<div style="text-align: center;">$1<\/div>/isgm; 
       $attribut =~ s/(\s|$char_160)+/ /g;     $threadpost =~ 
       foreach (split(/ +/, $attribut)) {  s/\[right\](.*?)\[\/right\]/<div style="text-align: right;">$1<\/div>/isgm; 
           my ($key, $value) = split(/=/, $_);     $threadpost =~ 
           $value =~ s/["']//g;  s/\[justify\](.*?)\[\/justify\]/<div style="text-align: justify">$1<\/div>/isgm; 
           $parameter{$key} = $value;     $threadpost =~ s/\[sub\](.*?)\[\/sub\]/<sub>$1<\/sub>/isxgm; 
       }     $threadpost =~ s/\[sup\](.*?)\[\/sup\]/<sup>$1<\/sup>/isgxm; 
     $threadpost =~
       $parameter{'name'} = 'post_img_resize' if $parameter{'name'} ne 'signat_img_resize';  s/\[fixed\](.*?)\[\/fixed\]/<span style="font-family: Courier New;">$1<\/span>/isgm; 
       &ToHTML($parameter{'alt'});  
       $parameter{'align'}  =~ s~[^a-z]~~ig;     $threadpost =~ s/\[\[/\{\{/gxsm; 
       $parameter{'width'}  =~ s~\D~~g;     $threadpost =~ s/\]\]/\}\}/gxsm; 
       $parameter{'height'} =~ s~\D~~g;     $threadpost =~ s/\|/\&verbar;/gxsm; 
       if ($parameter{'align'})  { $parameter{'align'}  = qq~ align="$parameter{'align'}"~; }     $threadpost =~ 
       if ($parameter{'width'})  { $parameter{'width'}  = qq~ width="$parameter{'width'}"~; }       s/\[hr\]\n/<hr style="width:40%; text-align:left" class="hr" \/>/gsm; 
       if ($parameter{'height'}) { $parameter{'height'} = qq~ height="$parameter{'height'}"~; }     $threadpost =~ 
       s/\[hr\]/<hr style="width:40%; text-align:left" class="hr" \/>/gsm;
       $imagecount++;     $threadpost =~ s/\[br\]/\n/igxsm; 
       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/\[flash\](.*?)\[\/flash\]/\[media\]$1\[\/media\]/isgxm; 
   
   $threadpost =~ s~\[tt\](.*?)\[/tt\]~<tt>$1</tt>~isg;     $threadpost =~ 
   $threadpost =~ s~\[left\](.*?)\[/left\]~<div style="text-align: left;">$1</div>~isg;       s/\[url=\s*(.+?)\s*\]\s*(.+?)\s*\[\/url\]/format_url2($1, $2)/eisgxm; 
   $threadpost =~ s~\[center\](.*?)\[/center\]~<center>$1</center>~isg;     $threadpost =~ s/\[url\]\s*(\S+?)\s*\[\/url\]/format_url3($1)/eisgxm; 
   $threadpost =~ s~\[right\](.*?)\[/right\]~<div style="text-align: right;">$1</div>~isg;  
   $threadpost =~ s~\[justify\](.*?)\[/justify\]~<div style="text-align: justify">$1</div>~isg;     if ($autolinkurls) { 
   $threadpost =~ s~\[sub\](.*?)\[/sub\]~<sub>$1</sub>~isg;         $threadpost =~ s/\[url\]\s*([^\[]+)\s*\[\/url\]/[url]$1\[\/url]/gxsm; 
   $threadpost =~ s~\[sup\](.*?)\[/sup\]~<sup>$1</sup>~isg;         $threadpost =~ 
   $threadpost =~ s~\[fixed\](.*?)\[/fixed\]~<span style="font-family: Courier New;">$1</span>~isg;           s/\[link\]\s*([^\[]+)\s*\[\/link\]/[link]$1\[\/link]/gxsm; 
         $threadpost =~ s/\[news\](\S+?)\[\/news\]/<a href="$1">$1<\/a>/isgm;
   $threadpost =~ s~\[\[~\{\{~g;         $threadpost =~ s/\[gopher\](\S+?)\[\/gopher\]/<a href="$1">$1<\/a>/isgm; 
   $threadpost =~ s~\]\]~\}\}~g;         $threadpost =~ s/&quot;&gt;/\x22>/gxsm; 
   $threadpost =~ s~\|~\&#124;~g;         $threadpost =~ s/(\[\*\])/ $1/gsm; 
   $threadpost =~ s~\[hr\]\n~<hr width="40%" align="left" size="1" class="hr" />~g;         $threadpost =~ s/(\[\/list\])/ $1/gsm; 
   $threadpost =~ s~\[hr\]~<hr width="40%" align="left" size="1" class="hr" />~g;         $threadpost =~ s/(\[\/tr\])/ $1/gsm; 
   $threadpost =~ s~\[br\]~\n~ig;         $threadpost =~ s/(\[\/td\])/ $1/gsm; 
         $threadpost =~ s/\<span style\=/\<span_style\=/gsm;
   $threadpost =~ s~\[flash\](.*?)\[/flash\]~\[media\]$1\[/media\]~isg;         $threadpost =~ s/\<div style\=/\<div_style\=/gsm; 
         $threadpost =~
   sub format_url {  s/([^\w\"\=\[\]]|[\n\b]|\&quot\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A)\\*(\w+?\:\/\/(?:[\w\~\;\:\,\$\-\+\!\*\?\/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?\/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)/format_url($1,$2)/eisgm; 
       my ($txtfirst, $txturl) = @_;         $threadpost =~ 
       my $lasttxt = "";  s/([^\"\=\[\]\/\:\.\-(\:\/\/\w+)]|[\n\b]|\&quot\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?\/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?\/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)/format_url($1,$2)/eisgm; 
       if ($txturl =~ m~(.*?)(\.|\.\)|\)\.|\!|\!\)|\)\!|\,|\)\,|\)|\;|\&quot\;|\&quot\;\.|\.\&quot\;|\&quot\;\,|\,\&quot\;|\&quot\;\;|\<\/)\Z~) {         $threadpost =~ s/\<span_style\=/\<span style\=/gsm; 
           $txturl = $1;         $threadpost =~ s/\<div_style\=/\<div style\=/gsm; 
           $lasttxt = $2;     } 
       }  
       my $realurl = $txturl;     if ($stealthurl) { 
       $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;         $threadpost =~ 
       $txturl =~ s~\[~&#91;~g;  s/\[url=\s*(\w+\:\/\/.+?)\](.+?)\s*\[\/url\]/<a href="$boardurl\/$yyexec.$yyext?action=dereferer;url=$1" target="_blank">$2<\/a>/isgm; 
       $txturl =~ s~\]~&#93;~g;         $threadpost =~ 
       $txturl =~ s~\<.+?\>~~ig;  s/\[url=\s*(.+?)\]\s*(.+?)\s*\[\/url\]/<a href="$boardurl\/$yyexec.$yyext?action=dereferer;url=http:\/\/$1" target="_blank">$2<\/a>/isgm; 
       my $formaturl = qq~$txtfirst\[url\=$txturl\]$realurl\[\/url\]$lasttxt~;  
       return $formaturl;         $threadpost =~ 
   }  s/\[link\]\s*www\.\s*(.+?)\s*\[\/link\]/<a href="$boardurl\/$yyexec.$yyext?action=dereferer;url=http:\/\/www.$1">www.$1<\/a>/isgm; 
   sub format_url2 {         $threadpost =~ 
       my ($txturl, $txtlink) = @_;  s/\[link=\s*(\w+\:\/\/.+?)\](.+?)\s*\[\/link\]/<a href="$boardurl\/$yyexec.$yyext?action=dereferer;url=$1">$2<\/a>/isgm; 
       $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;         $threadpost =~ 
       $txturl =~ s~\<.+?\>~~ig;  s/\[link=\s*(.+?)\]\s*(.+?)\s*\[\/link\]/<a href="$boardurl\/$yyexec.$yyext?action=dereferer;url=http:\/\/$1">$2<\/a>/isgm; 
       my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~;         $threadpost =~ 
       return $formaturl;  s/\[link\]\s*(.+?)\s*\[\/link\]/<a href="$boardurl\/$yyexec.$yyext?action=dereferer;url=$1">$1<\/a>/isgm; 
   }         $threadpost =~ 
   sub format_url3 {  s/\[ftp\]\s*(.+?)\s*\[\/ftp\]/<a href="$boardurl\/$yyexec.$yyext?action=dereferer;url=$1" target="_blank">$1<\/a>/isgm; 
       my $txturl = $_[0];     } 
       my $txtlink = $txturl;     else { 
       $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig;         $threadpost =~ 
       $txturl =~ s~\[~&#91;~g;  s/\[url=\s*(\S\w+\:\/\/\S+?)\s*\](.+?)\[\/url\]/<a href="$1" target="_blank">$2<\/a>/isgm; 
       $txturl =~ s~\]~&#93;~g;         $threadpost =~ 
       $txturl =~ s~\<.+?\>~~ig;  s/\[url=\s*(\S+?)\](.+?)\s*\[\/url\]/<a href="http:\/\/$1" target="_blank">$2<\/a>/isgm; 
       my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~;         $threadpost =~ 
       return $formaturl;  s/\[link\]\s*www\.(\S+?)\s*\[\/link\]/<a href="http:\/\/www.$1">www.$1<\/a>/isgm; 
   }         $threadpost =~ 
  s/\[link=\s*(\S\w+\:\/\/\S+?)\s*\](.+?)\[\/link\]/<a href="$1">$2<\/a>/isgm;
   $threadpost =~ s~\[url=\s*(.+?)\s*\]\s*(.+?)\s*\[/url\]~&format_url2($1, $2)~eisg;         $threadpost =~ 
   $threadpost =~ s~\[url\]\s*(\S+?)\s*\[/url\]~&format_url3($1)~eisg;  s/\[link=\s*(\S+?)\](.+?)\s*\[\/link\]/<a href="http:\/\/$1">$2<\/a>/isgm; 
         $threadpost =~
   if ($autolinkurls) {           s/\[link\]\s*(\S+?)\s*\[\/link\]/<a href="$1">$1<\/a>/isgm; 
       $threadpost =~ s~\[url\]\s*([^\[]+)\s*\[/url\]~[url]$1\[/url]~g;         $threadpost =~ 
       $threadpost =~ s~\[link\]\s*([^\[]+)\s*\[/link\]~[link]$1\[/link]~g;  s/\[ftp\]\s*(ftp:\/\/)?(.+?)\s*\[\/ftp\]/<a href="ftp:\/\/$2">$1$2<\/a>/isgm; 
       $threadpost =~ s~\[news\](\S+?)\[/news\]~<a href="$1">$1</a>~isg;     } 
       $threadpost =~ s~\[gopher\](\S+?)\[/gopher\]~<a href="$1">$1</a>~isg;  
       $threadpost =~ s~&quot;&gt;~">~g; #"     $threadpost =~ s/(dereferer\;url\=http\:\/\/.*?)#(\S+?\")/$1;anch=$2/isgm; 
       $threadpost =~ s~(\[\*\])~ $1~g;  
       $threadpost =~ s~(\[\/list\])~ $1~g;     if ( $guest_media_disallowed && $iamguest ) { 
       $threadpost =~ s~(\[\/td\])~ $1~g;         my $oops = 
       $threadpost =~ s~(\[\/td\])~ $1~g;  qq~ <i>$maintxt{'40'}&nbsp;&nbsp;$maintxt{'41'} <a href="$scripturl?action=login"><b>$maintxt{'34'}</b></a></i>~; 
       $threadpost =~ s~\<span style\=~\<span_style\=~g;         if ($regtype) { 
       $threadpost =~ s~\<div style\=~\<div_style\=~g;             $oops .= 
       $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;  qq~<i> $maintxt{'42'} <a href="$scripturl?action=register"><b>$maintxt{'97'}</b></a></i>~; 
       $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~\<div_style\=~\<div style\=~g;         $threadpost =~ s/<a href=".+?<\/a>/[oops]/gsm; 
   }         $threadpost =~ s/<img src=".+?>/[oops]/gsm; 
         $threadpost =~ s/\[media\].*?\[\/media\]/[oops]/isgxm;
   if ($stealthurl) {         $threadpost =~ s/\[oops\]/$oops/gxsm; 
       $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~\[link\]\s*www\.\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=http://www.$1">www.$1</a>~isg;     $threadpost =~ s/\[media\](.*?)\[\/media\]/$1/isgxm; 
       $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/\[email\]\s*(\S+?\@\S+?)\s*\[\/email\]/$1/isgxm; 
       $threadpost =~ s~\[link\]\s*(.+?)\s*\[/link\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1">$1</a>~isg;     $threadpost =~ 
       $threadpost =~ s~\[ftp\]\s*(.+?)\s*\[/ftp\]~<a href="$boardurl/$yyexec.$yyext?action=dereferer;url=$1" target="_blank">$1</a>~isg;       s/\[email=\s*(\S+?\@\S+?)\]\s*(.*?)\s*\[\/email\]/$2 ($1)/isgm; 
   } else {  
       $threadpost =~ s~\[url=\s*(\S\w+\://\S+?)\s*\](.+?)\[/url\]~<a href="$1" target="_blank">$2</a>~isg;     $threadpost =~ s/\[news\](.+?)\[\/news\]/$1/isgxm; 
       $threadpost =~ s~\[url=\s*(\S+?)\](.+?)\s*\[/url\]~<a href="http://$1" target="_blank">$2</a>~isg;     $threadpost =~ s/\[gopher\](.+?)\[\/gopher\]/$1/isgxm; 
       $threadpost =~ s~\[link\]\s*www\.(\S+?)\s*\[/link\]~<a href="http://www.$1">www.$1</a>~isg;     $threadpost =~ s/\[ftp\](.+?)\[\/ftp\]/$1/isgxm; 
       $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;     while ( $threadpost =~ 
       $threadpost =~ s~\[link\]\s*(\S+?)\s*\[/link\]~<a href="$1">$1</a>~isg;  /\[quote\s+author=(.*?)\slink=.*?\s+date=(.*?)\s*\]\n*.*?\n*\[\/quote\]/ism 
       $threadpost =~ s~\[ftp\]\s*(ftp://)?(.+?)\s*\[/ftp\]~<a href="ftp://$2">$1$2</a>~isg;       ) 
   }     { 
         my $author = $1;
   $threadpost =~ s~(dereferer\;url\=http\:\/\/.*?)#(\S+?\")~$1;anch=$2~isg;         my $date = timeformat( $2, 1 ); 
   
    if ($guest_media_disallowed && $iamguest) {         if ($author) {    # out of YaBBC.pm -> sub quotemsg { 
       my $oops = qq~$maintxt{'40'}&nbsp;&nbsp;$maintxt{'41'} <a href="$scripturl?action=login">$img{'login'}</a>~;             ToChars($author); 
       if ($regtype) { $oops .= qq~ $maintxt{'42'} <a href="$scripturl?action=register">$img{'register'}</a>~; }             if ( !-e "$memberdir/$author.vars" ) 
             {             # if the file is there it is an unencrypted user ID
       $threadpost =~ s~<a href=".+?</a>~[oops]~g;                 $author = decloak($author); 
       $threadpost =~ s~<img src=".+?>~[oops]~g;  
       $threadpost =~ s~\[media\].*?\[/media\]~[oops]~isg;                 # if not, decrypt it and see if it is a regged user 
       $threadpost =~ s~\[oops\]~$oops~g;                 if ( !-e "$memberdir/$author.vars" ) 
   }                 {    # if still not found probably the author is a screen name 
                     $testauthor = MemberIndex( 'check_exist', "$author" );
   $threadpost =~ s~\[media\](.*?)\[/media\]~$1~isg;  
                     # check if this name exists in the memberlist
   $threadpost =~ s~\[email\]\s*(\S+?\@\S+?)\s*\[/email\]~$1~isg;                     if ( $testauthor ne q{} ) 
   $threadpost =~ s~\[email=\s*(\S+?\@\S+?)\]\s*(.*?)\s*\[/email\]~$2 ($1)~isg;                     {    # if it is, load the user id returned 
                         $author = $testauthor;
   $threadpost =~ s~\[news\](.+?)\[/news\]~$1~isg;                         LoadUser($author); 
   $threadpost =~ s~\[gopher\](.+?)\[/gopher\]~$1~isg;                         $author = ${ $uid . $author }{'realname'}; 
   $threadpost =~ s~\[ftp\](.+?)\[/ftp\]~$1~isg;  
                         # set final author var to the current users screen name
   while ($threadpost =~ /\[quote\s+author=(.*?)\slink=.*?\s+date=(.*?)\s*\]\n*.*?\n*\[\/quote\]/is) {                     } 
       my $author = $1;                     else { 
       my $date   = &timeformat($2, 1);                         $author = decloak($author); 
   
       if ($author) { # out of YaBBC.pl -> sub quotemsg {  # if all fails it is a non existing real name so decode and asign as screenname 
           &ToChars($author);                     } 
           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                 else { 
               if (!-e "$memberdir/$author.vars"){ # if still not found probably the author is a screen name                     LoadUser($author); 
                   $testauthor = &MemberIndex("who_is", "$author"); # check if this name exists in the memberlist  
                   if ($testauthor ne ""){ # if it is, load the user id returned  # after encoding the user ID was found and loaded, setting the current real name 
                       $author = $testauthor;                     $author = ${ $uid . $author }{'realname'}; 
                       &LoadUser($author);                 } 
                       $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                 LoadUser($author); 
                   }  
               } else {  # it was an old style user id which could be loaded and screen name set to final author 
                   &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 {  
               &LoadUser($author); # it was an old style user id which could be loaded and screen name set to final author         $threadpost =~ 
               $author = ${$uid.$author}{'realname'};  s/\[quote\s+author=.*?link=.*?\s+date=.*?\s*\]\n*(.*?)\n*\[\/quote\]/<br \/><i>$author $maintxt{'30a'} $date:<\/i><table style="padding:1px; width:90%; border:thin solid #000"><tr><td style="width:100%;font-size:10px">$1<\/td><\/tr><\/table>/ism; 
           }    }
       }     $threadpost =~ 
  s/\[quote\]\n*(.+?)\n*\[\/quote\]/<br \/><i>$maintxt{'31'}:<\/i><table style="padding:1px; width:90%; border:thin solid #000"><tr><td style="width:100%;font-size:10px; font-family:Arial,Helvetica">$1<\/td><\/tr><\/table>/isgm;
       $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;  
   }  ## list code from YaBBC.pm - DAR ## 
   $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/\s*\[\*\]/<\/li><li>/isgm; 
     $threadpost =~ s/\[olist\]/<ol>/isgm;
   $threadpost =~ s~\[list\]~<ul>~isg;     $threadpost =~ s/\s*\[\/olist\]/<\/li><\/ol>/isgm; 
   $threadpost =~ s~\[\*\]~<li>~isg;     $threadpost =~ s/<\/li><ol>/<ol>/isgm; 
   $threadpost =~ s~\[/list\]~</ul>~isg;     $threadpost =~ s/<ol><\/li>/<ol>/isgm; 
     $threadpost =~ s/\[list\]/<ul>/isgm;
   $threadpost =~ s~\[pre\](.+?)\[/pre\]~'<pre>' . dopre($1) . '</pre>'~iseg;     $threadpost =~ 
  s/\[list (.+?)\]/<ul style="list-style-image\: url($defaultimagesdir\/$1\.gif)">/isgm;
   $threadpost =~ s~\[flash=(\S+?),(\S+?)\](\S+?)\[/flash\]~$3~isg;     $threadpost =~ s/\s*\[\/list\]/<\/li><\/ul>/isgm; 
     $threadpost =~ s/<\/li><ul>/<ul>/isgm;
   $threadpost =~ s~\{\{~\[~g;     $threadpost =~ s/<ul><\/li>/<ul>/isgm; 
   $threadpost =~ s~\}\}~\]~g;     $threadpost =~ s/<\/li><ul (.+?)>/<ul $1>/isgm; 
     $threadpost =~ s/<ul (.+?)><\/li>/<ul $1>/isgm;
   if ($threadpost =~ m~\[table\]~i) {  
       $threadpost =~ s~\n{0,1}\[table\]\n*(.+?)\n*\[/table\]\n{0,1}~<table>$1</table>~isg;     $threadpost =~ 
       while ($threadpost =~ s~\<table\>(.*?)\n*\[tr\]\n*(.*?)\n*\[/tr\]\n*(.*?)\</table\>~<table>$1<tr>$2</tr>$3</table>~is) { }       s/\[pre\](.+?)\[\/pre\]/'<pre>' . dopre($1) . '<\/pre>'/isegm; 
       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/\[flash=(\S+?),(\S+?)\](\S+?)\[\/flash\]/$3/isxgm; 
   
   $threadpost =~ s~\[\&table(.*?)\]~<table$1>~g;     $threadpost =~ s/\{\{/\[/gxsm; 
   $threadpost =~ s~\[/\&table\]~</table>~g;     $threadpost =~ s/\}\}/\]/gxsm; 
   $threadpost =~ s~\n~<br />~ig;  
     if ( $threadpost =~ m{\[table\]}ixsm ) {
   ### Censor it ###         $threadpost =~ 
   $threadtitle = &Censor($threadtitle);  s/\n{0,1}\[table\]\n*(.+?)\n*\[\/table\]\n{0,1}/<table>$1<\/table>/isgxm; 
   $threadpost  = &Censor($threadpost);         while ( $threadpost =~ 
  s/\<table\>(.*?)\n*\[tr\]\n*(.*?)\n*\[\/tr\]\n*(.*?)\<\/table\>/<table>$1<tr>$2<\/tr>$3<\/table>/isxm
           )
         {
         }
         while ( $threadpost =~
  s/\<tr\>(.*?)\n*\[td\]\n{0,1}(.*?)\n{0,1}\[\/td\]\n*(.*?)\<\/tr\>/<tr>$1<td>$2<\/td>$3<\/tr>/isxm
           )
         {
         }
     }
   
     $threadpost =~ s/\[\&table(.*?)\]/<table$1>/gxsm;
     $threadpost =~ s/\[\/\&table\]/<\/table>/gxsm;
     $threadpost =~ s/\n/<br \/>/igsm;
   
     ### Censor it ###
     $threadtitle = Censor($threadtitle);
     $threadpost  = Censor($threadpost);
   
     ToChars($threadtitle);
     ToChars($threadpost);
   
     $threaddate = timeformat( $threaddate, 1 );
     return;
  }
   
   &ToChars($threadtitle);  sub imagemsg {    # out of YaBBC.pm -> sub imagemsg { 
   &ToChars($threadpost);     my ( $attribut, $url ) = @_; 
   
   $threaddate = timeformat($threaddate, 1);     # use or kill urls 
     $url =~ s/\[url\](.*?)\[\/url\]/$1/igxsm;
     $url =~ s/\[link\](.*?)\[\/link\]/$1/igxsm;
     $url =~ s/\[url\s*=\s*(.*?)\s*.*?\].*?\[\/url\]/$1/igxsm;
     $url =~ s/\[link\s*=\s*(.*?)\s*.*?\].*?\[\/link\]/$1/igxsm;
     $url =~ s/\[url.*?\/url\]//igxsm;
     $url =~ s/\[link.*?\/link\]//igxsm;
   
     my $char_160 = chr 160;
     $url =~ s/(\s|&nbsp;|$char_160)+//gxsm;
   
     if ( $url !~ /^http.+?\.(gif|jpg|jpeg|png|bmp)$/ixsm ) {
         return q{ } . $url;
     }
   
     my %parameter;
     FromHTML($attribut);
     $attribut =~ s/(\s|$char_160)+/ /gsm;
     foreach ( split / +/sm, $attribut ) {
         my ( $key, $value ) = split /=/xsm, $_;
         $value =~ s/[\x22\x27]//gxsm;
         $parameter{$key} = $value;
     }
   
     if ( $parameter{'name'} ne 'signat_img_resize' ) {
         $parameter{'name'} = 'post_img_resize';
     }
     ToHTML( $parameter{'alt'} );
     $parameter{'align'}  =~ s/[^a-z]//igxsm;
     $parameter{'width'}  =~ s/\D//gxsm;
     $parameter{'height'} =~ s/\D//gxsm;
     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'};~;
     }
   
     $imagecount++;
     return
  qq~ <img src="$url" name="$parameter{'name'}" alt="$parameter{'alt'}" style="display:none;$parameter{'align'}$parameter{'width'}$parameter{'height'}" /><span id="urlimagecount$imagecount" style="display:none">$url</span>~;
} }
   
1; 1;