F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\Post.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\Post.pm
############################################################################### ###############################################################################
# Post.pl                                                                     # # Post.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 strict;
$postplver = 'YaBB 2.5.2 $Revision: 1.2 $';  # use warnings; 
if ($action eq 'detailedversion') { return 1; }  # no warnings qw(uninitialized once redefine); 
  use CGI::Carp qw(fatalsToBrowser);
&LoadLanguage('Post');  our $VERSION = '2.6.12'; 
&LoadLanguage('Display');  
&LoadLanguage('FA');  $postpmver = 'YaBB 2.6.12 $Revision: 1714 $'; 
&LoadLanguage('UserSelect');  if ( $action eq 'detailedversion' ) { return 1; } 
   
require "$sourcedir/Notify.pl";  LoadLanguage('Post'); 
require "$sourcedir/SpamCheck.pl";  LoadLanguage('Display'); 
  LoadLanguage('FA');
if ($iamguest && $gpvalid_en && ($enable_guestposting || $PMenableGuestButton|| $PMAlertButtonGuests)) {  LoadLanguage('UserSelect'); 
   require "$sourcedir/Decoder.pl";  LoadLanguage('LivePreview'); 
   
  require Sources::Notify;
  require Sources::SpamCheck;
  require Sources::PostBox;
  get_micon();
  get_template('Post');
   
  if (   $iamguest
     && $gpvalid_en
     && ( $enable_guestposting || $PMenableGuestButton || $PMAlertButtonGuests )
   )
  {
     require Sources::Decoder;
} }
$set_subjectMaxLength ||= 50; $set_subjectMaxLength ||= 50;
   
&LoadCensorList;  LoadCensorList(); 
  if ( $action eq 'eventcal' && $MaxCalMessLen && $AdMaxCalMessLen ) {
     $MaxMessLen   = $MaxCalMessLen;
     $AdMaxMessLen = $AdMaxCalMessLen;
  }
  if (
     (
            $action eq 'guestpm' 
         || $action eq 'guestpm2' 
         || $action eq 'modalert' 
         || $action eq 'modalert2' 
     )
     && $MaxIMMessLen
     && $AdMaxIMMessLen
   )
  {
     $MaxMessLen   = $MaxIMMessLen;
     $AdMaxMessLen = $AdMaxIMMessLen;
  }
   
  if ( $iamadmin || $iamgmod ) { $MaxMessLen = $AdMaxMessLen; }
   
sub Post { sub Post {
   if ($iamguest && $enable_guestposting == 0) { &fatal_error("not_logged_in"); }     if ( $iamguest && $enable_guestposting == 0 ) { 
   if (!$iamadmin && !$iamgmod && !$iammod && $speedpostdetection && ${$uid.$username}{'spamcount'} >= $post_speed_count) {         fatal_error('not_logged_in'); 
       $detention_time = ${$uid.$username}{'spamtime'} + $spd_detention_time;     } 
       if($date <= $detention_time){     if (  !$staff 
           $detention_left = $detention_time - $date;         && $speedpostdetection 
           &fatal_error("speedpostban");         && ${ $uid . $username }{'spamcount'} >= $post_speed_count ) 
       } else {    {
           ${$uid.$username}{'spamcount'} = 0;         $detention_time = 
           &UserAccount($username,"update");           ${ $uid . $username }{'spamtime'} + $spd_detention_time; 
       }         if ( $date <= $detention_time ) { 
   }             $detention_left = $detention_time - $date; 
   if ($currentboard eq '' && !$iamguest) { &fatal_error("no_access"); }             fatal_error('speedpostban'); 
   my ($filetype_info, $filesize_info);         } 
   my ($subtitle, $x, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $msubject, $mattach, $mip, $mmessage, $mns);         else { 
   my $quotemsg = $INFO{'quote'};             ${ $uid . $username }{'spamcount'} = 0; 
   $threadid = $INFO{'num'};             UserAccount( $username, 'update' ); 
         }
   ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);     } 
     if ( $currentboard eq q{} && !$iamguest ) { fatal_error('no_access'); }
   my $icanbypass;     my ( $filetype_info, $filesize_info ); 
   ## only if bypass switched on     my ( $subtitle, $x, $msubject, $mattach, $mip, $mmessage, $mns ); 
   if ($mstate =~ /l/i && $bypass_lock_perm) { $icanbypass = &checkUserLockBypass; }     my $quotemsg = $INFO{'quote'}; 
   if ($action eq 'modalert') { $icanbypass = 1; }     $threadid = $INFO{'num'}; 
   if ($mstate =~ /l/i && !$icanbypass) { &fatal_error('topic_locked'); }  
   #if ($mstate =~ /a/i && !$iamadmin && !$iamgmod) { &fatal_error('no_access'); }     my ( 
         $mnum,     $msub,      $mname, $memail, $mdate,
   # Determine category         $mreplies, $musername, $micon, $mstate 
   $curcat = ${$uid.$currentboard}{'cat'};     ) = split /\|/xsm, $yyThreadLine; 
   &BoardTotals("load", $currentboard);  
     my $icanbypass;
   # Figure out the name of the category     ## only if bypass switched on 
   unless ($mloaded == 1) { require "$boardsdir/forum.master"; }     if ( $mstate =~ /l/ism && $bypass_lock_perm ) { 
   ($cat, $catperms) = split(/\|/, $catinfo{$curcat});         $icanbypass = checkUserLockBypass(); 
   &ToChars($cat);     } 
     if ( $action eq 'modalert' ) { $icanbypass = 1; }
   $pollthread = 0;     if ( $mstate =~ /l/ism && !$icanbypass ) { fatal_error('topic_locked'); } 
   $postthread = 0;  
   $INFO{'title'} =~ tr/+/ /;     # Determine category 
     $curcat = ${ $uid . $currentboard }{'cat'};
   if    ($INFO{'title'} eq 'CreatePoll') { $pollthread = 1; $t_title = $post_polltxt{'1a'}; }     BoardTotals( 'load', $currentboard ); 
   elsif ($INFO{'title'} eq 'AddPoll')    { $pollthread = 2; $t_title = $post_polltxt{'2a'}; }  
   elsif ($INFO{'title'} eq 'PostReply')  { $postthread = 2; $t_title = $display_txt{'116'}; }     # Figure out the name of the category 
   else { $postthread = 1; $t_title = $post_txt{'33'}; }     get_forum_master(); 
   if ($FORM{'title'} eq 'PostReply')  { $postthread = 2;}     ( $cat, $catperms ) = split /\|/xsm, $catinfo{$curcat}; 
   if ($pollthread == 2 && $useraddpoll == 0) { &fatal_error("no_access"); }     ToChars($cat); 
   
   $name_field = $iamguest ? qq~      <tr>     $pollthread = 0; 
   <td class="windowbg" align="left" width="23%"><label for="name"><b>$post_txt{'68'}:</b></label></td>     $postthread = 0; 
   <td class="windowbg" align="left" width="77%"><input type="text" name="name" id="name" size="25" value="$FORM{'name'}" maxlength="25" tabindex="2" /></td>     $INFO{'title'} =~ tr/+/ /; 
     </tr>~  
     : qq~~;     if ( $INFO{'title'} eq 'CreatePoll' ) { 
         $pollthread = 1;
   $email_field = $iamguest ? qq~      <tr>         $t_title    = $post_polltxt{'1a'}; 
   <td class="windowbg" width="23%"><label for="email"><b>$post_txt{'69'}:</b></label></td>     } 
   <td class="windowbg" width="77%"><input type="text" name="email" id="email" size="25" value="$FORM{'email'}" maxlength="40" tabindex="3" /></td>     elsif ( $INFO{'title'} eq 'AddPoll' ) { 
     </tr>~         $pollthread = 2; 
     : qq~~;         $t_title    = $post_polltxt{'2a'}; 
     }
   if ($iamguest && $gpvalid_en) {    elsif ( $INFO{'title'} eq 'PostReply' || $INFO{'num'} ) {
       &validation_code;         $postthread = 2; 
       $verification_field = $verification eq ''         $t_title    = $display_txt{'116'}; 
       ? qq~     } 
           <tr>     else { $postthread = 1; $t_title = $post_txt{'33'}; } 
               <td class="windowbg" width="23%" valign="top"><label for="verification"><b>$floodtxt{'1'}:</b></label></td>     if ( $FORM{'title'} eq 'PostReply' ) { $postthread = 2; } 
               <td class="windowbg" width="77%">$showcheck<br /><label for="verification"><span class="small">$floodtxt{'casewarning'}</span></label></td>     if ( $pollthread == 2 && $useraddpoll == 0 ) { fatal_error('no_access'); } 
           </tr>  
           <tr>     $guestpost_fields = q{}; 
               <td class="windowbg" width="23%" valign="top"><label for="verification"><b>$floodtxt{'3'}:</b></label></td>     if ( $iamguest ) { 
               <td class="windowbg" width="77%">     $guestpost_fields = $mypost_guest_fields; 
               <input type="text" maxlength="30" name="verification" id="verification" size="30" />     $guestpost_fields =~ s/{yabb name}/$FORM{'name'}/sm; 
               </td>     $guestpost_fields =~ s/{yabb email}/$FORM{'email'}/sm; 
           </tr>     } 
       ~  
       : qq~~;     if ( $iamguest && $gpvalid_en ) { 
   }         validation_code(); 
         $verification_field =
   $sub = '';             $verification eq q{} 
   $settofield = 'subject';           ? $mypost_guest_c 
   if ($threadid ne '') {           : q{}; 
       unless (ref($thread_arrayref{$threadid})) {         $verification_field =~ s/{yabb showcheck}/$showcheck/sm; 
           fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt", 1);         $verification_field =~ s/{yabb flood_text}/$flood_text/sm; 
           @{$thread_arrayref{$threadid}} = <FILE>;     } 
           fclose(FILE);     if (   $iamguest 
       }         && $spam_questions_gp 
       if ($quotemsg ne '') {         && -e "$langdir/$language/spam.questions" ) 
           ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[$quotemsg]);     { 
           $message = $mmessage;         SpamQuestion(); 
           $message =~ s~<br.*?>~\n~ig;         my $verification_question_desc; 
           $message =~ s/ \&nbsp; \&nbsp; \&nbsp;/\t/ig;         if ($spam_questions_case) { 
           if (!$nestedquotes) {             $verification_question_desc = 
               $message =~ s~\n{0,1}\[quote([^\]]*)\](.*?)\[/quote([^\]]*)\]\n{0,1}~\n~isg;               qq~<br />$post_txt{'verification_question_case'}~; 
           }        }
           $mname ||= $musername || $post_txt{'470'};         $verification_question_field = 
           my $hidename = $musername;             $verification_question eq q{} 
           $hidename = $mname if $musername eq 'Guest';           ? $mypost_guest_e 
           $hidename = &cloak($hidename) if $do_scramble_id;           : q{}; 
           $usernames_life_quote{$hidename} = $mname; # for display names in Quotes in LivePreview         $verification_question_field =~ 
           my $maxlengthofquote = $MaxMessLen - length(qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]\[/quote\]\n~) - 3;           s/{yabb spam_question}/$spam_question/gsm; 
           my $mess_len = $message;         $verification_question_field =~ 
           &ToChars($mess_len);           s/{yabb verification_question_desc}/$verification_question_desc/sm; 
           $mess_len =~ s/[\r\n ]//ig;         $verification_question_field =~ 
           $mess_len =~ s/&#\d{3,}?\;/X/ig;           s/{yabb spam_question_id}/$spam_question_id/sm; 
           if (length $mess_len >= $maxlengthofquote) {         $verification_question_field =~ s/{yabb spam_question_image}/$spam_image/sm; 
               &LoadLanguage('Error');     } 
               &alertbox($error_txt{'quote_too_long'});  
               $message = substr($message, 0, $maxlengthofquote) . '...';     $sub        = q{}; 
           }     $settofield = 'subject'; 
           undef $mess_len;     if ( $threadid ne q{} ) { 
           $message = qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]$message\[/quote\]\n~;         if ( !ref $thread_arrayref{$threadid} ) { 
           if ($mns eq 'NS') { $nscheck = qq~ checked="checked"~; }             fopen( FILE, "$datadir/$threadid.txt" ) 
       } else {               or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 ); 
           ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[0]);             @{ $thread_arrayref{$threadid} } = <FILE>; 
       }             fclose(FILE); 
       $msubject =~ s/\bre:\s+//ig;         } 
       $sub = "Re: $msubject";         if ( $quotemsg ne q{} ) { 
       $settofield = 'message';             ( 
   }                 $msubject, $mname,   $memail, $mdate,    $musername, 
                 $micon,    $mattach, $mip,    $mmessage, $mns
   if ($ENV{'HTTP_USER_AGENT'} =~ /(MSIE) (\d)/) {             ) = split /\|/xsm, ${ $thread_arrayref{$threadid} }[$quotemsg]; 
       if ($2 >= 7.0) { $iecopycheck = ''; } else { $iecopycheck = qq~ checked="checked"~; }             $message = $mmessage; 
   }             $message =~ s/<br.*?>/\n/igsm; 
   $submittxt   = "$post_txt{'105'}";             $message =~ s/ \&nbsp; \&nbsp; \&nbsp;/\t/igsm; 
   $destination = "post2";             if ( !$nestedquotes ) { 
   $icon        = "xx";                 $message =~ 
   $is_preview  = 0;  s/\n{0,1}\[quote([^\]]*)\](.*?)\[\/quote([^\]]*)\]\n{0,1}/\n/isgm; 
   $post        = "post";             } 
   $prevmain    = "";             $mname = isempty( $mname, isempty( $musername, $post_txt{'470'} ) ); 
   $preview     = "preview";             my $hidename = $musername; 
   $yytitle     = "$t_title" unless $Quick_Post;             if ( $musername eq 'Guest' ) { $hidename = $mname; } 
   &Postpage;             if ($do_scramble_id) { $hidename = cloak($hidename); } 
   &doshowthread unless $Quick_Post;             $usernames_life_quote{$hidename} = $mname; 
   if (%usernames_life_quote) { # for display names in Quotes in LivePreview  
       $yymain .= qq~             # for display names in Quotes in LivePreview 
   <script language="JavaScript" type="text/javascript">             my $maxlengthofquote = 
   <!-- //               $MaxMessLen - 
       ~ . join(';', map { qq~LivePrevDisplayNames['$_'] = "$usernames_life_quote{$_}"~ } keys %usernames_life_quote) . qq~;               length( 
   // -->  qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]\[/quote\]\n~ 
   </script>\n~;               ) - 3; 
   }             my $mess_len = $message; 
   &template;             ToChars($mess_len); 
             $mess_len =~ s/[\r\n ]//igsm;
             $mess_len =~ s/&\x23\d{3,}?\;/X/igxsm;
   
             if ( length $mess_len >= $maxlengthofquote ) {
                 LoadLanguage('Error');
                 alertbox( $error_txt{'quote_too_long'} );
                 $message = substr( $message, 0, $maxlengthofquote ) . q{...};
                 my @c = $message =~ m/\[code\]/gxsm;
                 my $countc = @c;
                 my @d = $message =~ m~\[/code\]~gxsm;
                 my $countd = @d;
                 if ($countc > $countd ) {
                     $message = $message . q~[/code]~;
                 }
             }
             undef $mess_len;
             $message =
  qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]$message\[/quote\]\n~;
             if ( $mns eq 'NS' ) { $nscheck = q~ checked="checked"~; }
         }
         else {
             (
                 $msubject, $mname,   $memail, $mdate,    $musername,
                 $micon,    $mattach, $mip,    $mmessage, $mns
             ) = split /\|/xsm, ${ $thread_arrayref{$threadid} }[0];
         }
         $msubject =~ s/\bre:\s+//igxsm;
         $sub        = "Re: $msubject";
         $settofield = 'message';
     }
   
     $submittxt   = "$post_txt{'105'}";
     $destination = 'post2';
     $icon        = 'xx';
     $post        = 'post';
     $prevmain    = q{};
     if ( !$Quick_Post ) { $yytitle = "$t_title"; }
     Postpage();
     if ( !$Quick_Post ) { doshowthread(); }
   
     template();
     return;
} }
   
##  post message page ##  post message page
sub Postpage { sub Postpage {
   my $extra;    my $extra;
   my ($filetype_info, $filesize_info, $extensions);     my ( $filetype_info, $filesize_info, $extensions ); 
   $extensions = join(" ", @ext);     $extensions = join q{ }, @ext; 
   $filetype_info = $checkext == 1 ? qq~$fatxt{'2'} $extensions~ : qq~$fatxt{'2'} $fatxt{'4'}~;     $filetype_info = 
   $filesize_info = $limit != 0    ? qq~$fatxt{'3'} $limit KB~   : qq~$fatxt{'3'} $fatxt{'5'}~;       $checkext == 1 
   $normalquot = $post_txt{'599'};       ? qq~$fatxt{'2'} $extensions~ 
   $simpelquot = $post_txt{'601'};       : qq~$fatxt{'2'} $fatxt{'4'}~; 
   $simpelcode = $post_txt{'602'};     $limit ||= 0; 
   $edittext   = $post_txt{'603'};     $filesize_info = 
   if (!$fontsizemax) { $fontsizemax = 72; }       $limit != 0 ? qq~$fatxt{'3'} $limit KB~ : qq~$fatxt{'3'} $fatxt{'5'}~; 
   if (!$fontsizemin) { $fontsizemin = 6; }     $normalquot = $post_txt{'599'}; 
     $simpelquot = $post_txt{'601'};
   if ($postid eq 'Poll')  { $sub = "$post_txt{'66a'}"; }     $simpelcode = $post_txt{'602'}; 
     $edittext   = $post_txt{'603'};
   $message =~ s~<\/~\&lt\;/~isg;     if ( !$fontsizemax ) { $fontsizemax = 72; } 
   &ToChars($message);     if ( !$fontsizemin ) { $fontsizemin = 6; } 
   $message = &Censor($message);  
   &ToChars($sub);     if ( $postid eq 'Poll' ) { $sub = "$post_txt{'66a'}"; } 
   $sub = &Censor($sub);  
     $message =~ s/<\//\&lt\;\//igxsm;
   if ($action eq "modify" || $action eq "modify2") {     ToChars($message); 
       $displayname = qq~$mename~;     $message = Censor($message); 
   } else {     ToChars($sub); 
       $displayname = ${$uid.$username}{'realname'};     $sub = Censor($sub); 
   }  
   require "$sourcedir/ContextHelp.pl";     if ( $action eq 'modify' || $action eq 'modify2' ) { 
   &ContextScript("post");         $displayname = qq~$mename~; 
   $yymain .= $ctmain;         $moddate     = $tmpmdate; 
         if (
   # this defines what the top area of the post box will look like: option 1 ) IM area             $showmodify 
   # option 2) all other post areas             && ( !$tllastmodflag 
   #  im stuff now separate                 || ( $tmpmdate + ( $tllastmodtime * 60 ) ) < $date ) 
   if ($postid ne 'Poll' && $destination ne 'modalert2' && $destination ne 'guestpm2') {           ) 
       $extra = qq~         { 
   <tr id="feature_status_1">             $tmplastmodified = 
       <td class="windowbg" width="23%"><label for="icon"><b>$post_txt{'71'}:</b></label></td>                 qq~&laquo; <i>$display_txt{'211'}: ~ 
       <td width="77%" class="windowbg">               . timeformat($date,0,0,0,1) 
           <select name="icon" id="icon" onchange="showimage(); updatTopic();">               . qq~ $display_txt{'525'} ${$uid.$username}{'realname'}</i> &raquo;~; 
           <option value="xx"$ic1>$post_txt{'281'}</option>         } 
           <option value="thumbup"$ic2>$post_txt{'282'}</option>         $tmpmusername = $thismusername; 
           <option value="thumbdown"$ic3>$post_txt{'283'}</option>     } 
           <option value="exclamation"$ic4>$post_txt{'284'}</option>     else { 
           <option value="question"$ic5>$post_txt{'285'}</option>         $displayname     = ${ $uid . $username }{'realname'}; 
           <option value="lamp"$ic6>$post_txt{'286'}</option>         $moddate         = $date; 
           <option value="smiley"$ic7>$post_txt{'287'}</option>         $tmplastmodified = q{}; 
           <option value="angry"$ic8>$post_txt{'288'}</option>         $tmpmusername    = $username; 
           <option value="cheesy"$ic9>$post_txt{'289'}</option>     } 
           <option value="grin"$ic10>$post_txt{'290'}</option>     $moddate = timeformat($moddate); 
           <option value="sad"$ic11>$post_txt{'291'}</option>     require Sources::ContextHelp; 
           <option value="wink"$ic12>$post_txt{'292'}</option>     ContextScript('post'); 
           </select>  
           <img src="$imagesdir/$icon.gif" name="icons" border="0" hspace="15" alt="" />     if (   $postid ne 'Poll' 
       </td>         && $destination ne 'modalert2' 
   </tr>         && $destination ne 'guestpm2' ) 
        ~;     { 
       if ($iamguest && $threadid ne '') { $settofield = "name"; }         $extra = $mypost_extra; 
   }         my $iconopts = q{}; 
   
   if ($pollthread && $iamguest) { $guest_vote = 1; }         @iconlist =(); 
   if ($pollthread == 2) { $settofield = "question"; }         for my $key ( sort keys %iconlist ) { 
             my ($img, $alt) = split /[|]/xsm, $iconlist{$key};
   # this defines if the notify on reply is shown or not.             my $myic = q{}; 
   if ($iamguest || $destination eq "modalert2" || $destination eq "guestpm2") {             if ( $icon eq $img ) {$myic = ' selected="selected" '; } 
       $notification = '';             $iconopts .= qq~                <option value="$img"$myic>$alt</option>\n~; 
   } else {         } 
       # check if you are already being notified and if so we check the checkbox.  
       # if the mail file exists then we have to check it otherwise we continue on         $extra =~ s/{yabb iconopts}/$iconopts/sm; 
       my $notify = "";         $extra =~ s/{yabb icon}/$icon/sm; 
       my $hasnotify = 0;         $extra =~ s/{yabb icon_img}/$micon_bg{$icon}/sm; 
       $notifytext = qq~$post_txt{'750'}~;  
       if (!$FORM{'notify'} && !exists $FORM{'hasnotify'}) {         if ( $iamguest && $threadid ne q{} ) { $settofield = 'name'; } 
           &ManageThreadNotify("load", $threadid);     } 
           if (exists $thethread{$username}) {  
               $notify    = qq~ checked="checked"~;     if ( $pollthread && $iamguest ) { $guest_vote = 1; } 
               $hasnotify = 1;     if ( $pollthread == 2 ) { $settofield = 'question'; } 
           }  
           undef %thethread;     # this defines if the notify on reply is shown or not. 
     if (   $iamguest
           &ManageBoardNotify("load", $currentboard);         || $destination eq 'modalert2' 
           if (exists $theboard{$username} && (split(/\|/, $theboard{$username}))[1] == 2) {         || $destination eq 'guestpm2' ) 
               $notify     = qq~ disabled="disabled" checked="checked"~;     { 
               $hasnotify  = 2;         $notification = q{}; 
               $notifytext = qq~$post_txt{'132'}~;     } 
           }     else { 
           undef %theboard;  
      # check if you are already being notified and if so we check the checkbox.
       } else {      # if the mail file exists then we have to check it otherwise we continue on 
           $notify = qq~ checked="checked"~ if $FORM{'notify'} eq 'x';         my $notify    = q{}; 
           $hasnotify = $FORM{'hasnotify'};         my $hasnotify = 0; 
           if ($hasnotify == 2) {         $notifytext = qq~$post_txt{'750'}~; 
               $notify     = qq~ disabled="disabled" checked="checked"~;         if ( !$FORM{'notify'} && !exists $FORM{'hasnotify'} ) { 
               $notifytext = qq~$post_txt{'132'}~;             ManageThreadNotify( 'load', $threadid ); 
           }             if ( exists $thethread{$username} ) { 
       }                 $notify    = q~ checked="checked"~; 
                 $hasnotify = 1;
             }
       if ($postid ne 'Poll') {             undef %thethread; 
           $notification = qq~  
   <tr id="feature_status_2">             ManageBoardNotify( 'load', $currentboard ); 
       <td width="23%"><label for="notify"><b>$post_txt{'131'}:</b></label></td>             if ( exists $theboard{$username} 
       <td width="77%"><input type="hidden" name="hasnotify" value="$hasnotify" /><input type="checkbox" name="notify" id="notify" value="x"$notify /> <span class="small"><label for="notify">$notifytext</label></span></td>                 && ( split /\|/xsm, $theboard{$username} )[1] == 2 ) 
   </tr>~;             { 
       }                 $notify     = q~ disabled="disabled" checked="checked"~; 
   }                 $hasnotify  = 2; 
                 $notifytext = qq~$post_txt{'132'}~;
   #add to favorites checkbox code             } 
   $favoriteadd = '';             undef %theboard; 
   if (!$iamguest && $currentboard ne $annboard && $destination ne 'modalert2') {  
       $favoritetext = $post_txt{'notfav'};         } 
       require "$sourcedir/Favorites.pl";         else { 
       $nofav = &IsFav($threadid, '', 1);             if ( $FORM{'notify'} eq 'x' ) { $notify = q~ checked="checked"~; } 
       if ($FORM{'favorite'}) {             $hasnotify = $FORM{'hasnotify'}; 
           $favorite = qq~ checked="checked"~;             if ( $hasnotify == 2 ) { 
       }                 $notify     = q~ disabled="disabled" checked="checked"~; 
       if (!$nofav) {                 $notifytext = qq~$post_txt{'132'}~; 
           $favorite = qq~ disabled="disabled" checked="checked"~;             } 
           $favoritetext = $post_txt{'alreadyfav'};         } 
           $hasfavorite = 1;  
       } elsif ($nofav == 2){         if ( $postid ne 'Poll' ) { 
           $favorite = qq~ disabled="disabled"~;             $notification = $mypost_notification; 
           $favoritetext = $post_txt{'maximumfav'};             $notification =~ s/{yabb hasnotify}/$hasnotify/sm; 
       }             $notification =~ s/{yabb notify}/$notify/sm; 
       $favoriteadd = qq~             $notification =~ s/{yabb notifytext}/$notifytext/sm; 
   <tr id="feature_status_3">         } 
       <td width="23%"><label for="favorite"><b>$post_txt{'favorite'}:</b></label></td>     } 
       <td width="77%"><input type="checkbox" name="favorite" id="favorite" value="x"$favorite /> <span class="small"><label for="favorite">$favoritetext</label></span></td>  
   </tr>~;     #add to favorites checkbox code 
   }     $favoriteadd = q{}; 
     if (  !$iamguest
   if (!$sub) { $subtitle = "<i>$post_txt{'33'}</i>"; }         && $currentboard ne $annboard 
   else { $subtitle = "<i>$sub</i>"; }         && $destination  ne 'modalert2' ) 
   # this is shown every post page except the IM area.     { 
   if ($destination ne 'modalert2' && $destination ne 'guestpm2' && !$Quick_Post) {         $favoritetext = $post_txt{'notfav'}; 
       if ($threadid) {         require Sources::Favorites; 
           $threadlink = qq~<a href="$scripturl?num=$threadid" class="nav">$subtitle</a>~;         $nofav = IsFav( $threadid, q{}, 1 ); 
       } else {        if ( $FORM{'favorite'} ) {
           $threadlink = "$subtitle";             $favorite = q~ checked="checked"~; 
       }        }
       &ToChars($boardname);         if ( !$nofav ) { 
       &ToChars($cat);             $favorite     = q~ disabled="disabled" checked="checked"~; 
       $yynavigation = qq~&rsaquo; <a href="$scripturl?catselect=$catid" class="nav">$cat</a> &rsaquo; <a href="$scripturl?board=$currentboard" class="nav">$boardname</a> &rsaquo; $t_title ( $threadlink )~;             $favoritetext = $post_txt{'alreadyfav'}; 
   } elsif (!$Quick_Post) {             $hasfavorite  = 1; 
       $yynavigation = qq~&rsaquo; $t_title~;         } 
   }         elsif ( $nofav == 2 ) { 
   #this is the end of the upper area of the post page.             $favorite     = q~ disabled="disabled"~; 
   $yymain .= qq~             $favoritetext = $post_txt{'maximumfav'}; 
         }
         $favoriteadd = $mypost_favoriteadd;
         $favoriteadd =~ s/{yabb favorite}/$favorite/sm;
         $favoriteadd =~ s/{yabb favoritetext}/$favoritetext/sm;
     }
   
     if   ( !$sub ) { $subtitle = "<i>$post_txt{'33'}</i>"; }
     else           { $subtitle = "<i>$sub</i>"; }
   
     # this is shown every post page except the IM area.
     if (   $destination ne 'modalert2' 
         && $destination ne 'guestpm2' 
         && !$Quick_Post )
     {
         if ($threadid) {
             $threadlink =
               qq~<a href="$scripturl?num=$threadid" class="nav">$subtitle</a>~;
         }
         else {
             $threadlink = "$subtitle";
         }
         ToChars($boardname);
         ToChars($cat);
         $yynavigation =
  qq~&rsaquo; <a href="$scripturl?catselect=$catid" class="nav">$cat</a> &rsaquo; <a href="$scripturl?board=$currentboard" class="nav">$boardname</a> &rsaquo; $t_title ( $threadlink )~;
     }
     elsif ( !$Quick_Post ) {
         $yynavigation = qq~&rsaquo; $t_title~;
     }
     $checkallcaps ||= 0;
   
<script language="JavaScript1.2" type="text/javascript">     #this is the end of the upper area of the post page. 
<!--    $my_q_quote = qq~ 
   
  <script type="text/javascript">
function alertqq() { function alertqq() {
   alert("$post_txt{'alertquote'}");    alert("$post_txt{'alertquote'}");
} }
function quick_quote_confirm(ahref) { function quick_quote_confirm(ahref) {
   if (document.postmodify.message.value == "") {    if (document.postmodify.message.value === "") {
       window.location.href = ahref;        window.location.href = ahref;
   } else {    } else {
       var Check = confirm('$post_txt{'quote_confirm'}');        var Check = confirm('$post_txt{'quote_confirm'}');
       if (Check == true) {        if (Check === true) {
           window.location.href = ahref;            window.location.href = ahref;
       } else {        } else {
           document.postmodify.message.focus();            document.postmodify.message.focus();
       }        }
   }    }
} }
   
var postas = '$post'; var postas = '$post';
function checkForm(theForm) { function checkForm(theForm) {
   var isError = 0;    var isError = 0;
   var msgError = "$post_txt{'751'}\\n";    var msgError = "$post_txt{'751'}\\n";
   if (navigator.appName == "Microsoft Internet Explorer" && document.getElementById('iecopy').checked == true) { theForm.message.createTextRange().execCommand("Copy"); }     ~ . ( 
   ~ . ($iamguest && $post ne "imsend" && $post ne "imsend2" ? qq~if (theForm.name.value == "" || theForm.name.value == "_" || theForm.name.value == " ") { msgError += "\\n - $post_txt{'75'}"; if (isError == 0) isError = 2; }         $iamguest && $post ne 'imsend' && $post ne 'imsend2' 
   if (theForm.name.value.length > 25)  { msgError += "\\n - $post_txt{'568'}"; if (isError == 0) isError = 2; }        ? qq~if (theForm.name.value === "" || theForm.name.value == "_" || theForm.name.value == " ") { msgError += "\\n - $post_txt{'75'}"; if (isError === 0) isError = 2; }
   if (theForm.email.value == "") { msgError += "\\n - $post_txt{'76'}"; if (isError == 0) isError = 3; }    if (theForm.name.value.length > 25)  { msgError += "\\n - $post_txt{'568'}"; if (isError === 0) isError = 2; }
   if (! checkMailaddr(theForm.email.value)) { msgError += "\\n - $post_txt{'500'}"; if (isError == 0) isError = 3; }~ : qq~if (postas == "imsend" || postas == "imsend2") {     if (theForm.email.value === "") { msgError += "\\n - $post_txt{'76'}"; if (isError === 0) isError = 3; } 
       if (theForm.toshow.options.length == 0 ) { msgError += "\\n - $post_txt{'752'}"; isError = 1; }     if (! checkMailaddr(theForm.email.value)) { msgError += "\\n - $post_txt{'500'}"; if (isError === 0) isError = 3; }~ 
       else { selectNames(); }         : qq~if (postas == "imsend" || postas == "imsend2") { 
         if (theForm.toshow.options.length === 0 ) { msgError += "\\n - $post_txt{'752'}"; isError = 1; }
   }~) . qq~         else { selectNames(); } 
   
   if (theForm.subject.value == "") { msgError += "\\n - $post_txt{'77'}"; if (isError == 0) isError = 4; }     }~ 
   else if ($checkallcaps && theForm.subject.value.search(/[A-Z]{$checkallcaps,}/g) != -1) {       ) . qq~ 
       if (isError == 0) { msgError = " - $post_txt{'79'}"; isError = 4; }    if (theForm.subject.value === "") { msgError += "\\n - $post_txt{'77'}"; if (isError === 0) isError = 4; }
       else { msgError += "\\n - $post_txt{'79'}"; }     else if ($checkallcaps && theForm.subject.value.search(/[A-Z]{$checkallcaps,}/g) != -1) { 
   }        if (isError === 0) { msgError = " - $post_txt{'79'}"; isError = 4; }
   if (theForm.message.value == "") { msgError += "\\n - $post_txt{'78'}"; if (isError == 0) isError = 5; }        else { msgError += "\\n - $post_txt{'79'}"; }
   else if ($checkallcaps && theForm.message.value.search(/[A-Z]{$checkallcaps,}/g) != -1) {     } 
       if (isError == 0) { msgError = " - $post_txt{'79'}"; isError = 5; }    if (theForm.message.value === "") { msgError += "\\n - $post_txt{'78'}"; if (isError === 0) isError = 5; }
       else { msgError += "\\n - $post_txt{'79'}"; }     else if ($checkallcaps && theForm.message.value.search(/[A-Z]{$checkallcaps,}/g) != -1) { 
   }        if (isError === 0) { msgError = " - $post_txt{'79'}"; isError = 5; }
   if (isError > 0) {         else { msgError += "\\n - $post_txt{'79'}"; } 
       alert(msgError);     } 
       if (isError == 1) imWin();     if (isError > 0) { 
       else if (isError == 2) theForm.name.focus();         alert(msgError); 
       else if (isError == 3) theForm.email.focus();         if (isError == 1) imWin(); 
       else if (isError == 4) theForm.subject.focus();         else if (isError == 2) theForm.name.focus(); 
       else if (isError == 5) theForm.message.focus();         else if (isError == 3) theForm.email.focus(); 
       return false;         else if (isError == 4) theForm.subject.focus(); 
   }         else if (isError == 5) theForm.message.focus(); 
   return true         return false; 
     }
     return true;
} }
   
//-->  
</script> </script>
   
~; ~;
   
   # if this is an IM from the admin or to groups declare where it goes.    # if this is an IM from the admin or to groups declare where it goes.
   if ($INFO{'adminim'} || $INFO{'action'} eq "imgroups") {    if ( $INFO{'adminim'} || $INFO{'action'} eq 'imgroups' ) {
       $yymain .= qq~<form action="$scripturl?action=imgroups" method="post" name="postmodify" onsubmit="return submitproc()">~;         $my_adminim = 
   } else {  qq~<form action="$scripturl?action=imgroups" method="post" name="postmodify" onsubmit="return submitproc()" accept-charset="$yymycharset">~; 
       if ($curnum) { $thecurboard = qq~num=$curnum\;action=$destination~; }    }
       elsif ($destination eq "guestpm2") { $thecurboard = qq~action=$destination~; }     else { 
       else { $thecurboard = qq~board=$currentboard\;action=$destination~; }        if ($curnum) { $thecurboard = qq~num=$curnum\;action=$destination~; }
       if (&AccessCheck($currentboard, 4) eq "granted" && $allowattach && ${$uid.$currentboard}{'attperms'} == 1) {        elsif ( $destination eq 'guestpm2' ) {
           $yymain .= qq~<form action="$scripturl?$thecurboard" method="post" name="postmodify" enctype="multipart/form-data" onsubmit="if(!checkForm(this)) {return false} else {return submitproc()}">~;             $thecurboard = qq~action=$destination~; 
       } else {         } 
           $yymain .= qq~<form action="$scripturl?$thecurboard" method="post" name="postmodify" enctype="application/x-www-form-urlencoded" onsubmit="if(!checkForm(this)) {return false} else {return submitproc()}">~;         else { $thecurboard = qq~board=$currentboard\;action=$destination~; } 
       }  
   }         $allowattach ||= 0; 
   if ($postthread == 2) { $yymain .= qq~<input type="hidden" id="title" name="PostReply" value="title" />~; }         if (   AccessCheck( $currentboard, 4 ) eq 'granted' 
   # this declares the beginning of the UBBC section             && $allowattach > 0 
   $yymain .= qq~             && ${ $uid . $currentboard }{'attperms'} == 1 ) 
         {
   <div class="bordercolor" style="padding: 1px; width: 100%; margin-left: auto; margin-right: auto;">             $my_adminim = 
   <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>  qq~<form action="$scripturl?$thecurboard" method="post" name="postmodify" enctype="multipart/form-data" onsubmit="if(!checkForm(this)) {return false} else {return submitproc()}" accept-charset="$yymycharset">~; 
   <script language="JavaScript1.2" type="text/javascript">         } 
   <!--         else { 
   ~;             $my_adminim = 
  qq~<form action="$scripturl?$thecurboard" method="post" name="postmodify" enctype="application/x-www-form-urlencoded" onsubmit="if(!checkForm(this)) {return false} else {return submitproc()}" accept-charset="$yymycharset">~;
   $moresmilieslist = '';         } 
   $more_smilie_array = '';     } 
   $i = 0;     if ( $postthread == 2 ) { 
   if ($showadded == 1) {         $my_adminim .= 
       while ($SmilieURL[$i]) {           q~<input type="hidden" id="title" name="PostReply" value="title" />~; 
           if ($SmilieURL[$i] =~ /\//i) { $tmpurl = $SmilieURL[$i]; }    }
           else { $tmpurl = qq~$imagesdir/$SmilieURL[$i]~; }  
           $moresmilieslist .= qq~                document.write('<img src="$tmpurl" align="bottom" alt="$SmilieDescription[$i]" title="$SmilieDescription[$i]" border="0" onclick="javascript: MoreSmilies($i);" style="cursor: pointer;" />$SmilieLinebreak[$i] ');\n~;     # this declares the beginning of the UBBC section 
           $tmpcode = $SmilieCode[$i];  
           $tmpcode =~ s/\&quot;/"+'"'+"/g;    #" Adding that because if not it screws up my syntax view'     $moresmilieslist   = q{}; 
           &FromHTML($tmpcode);     $more_smilie_array = q{}; 
           $tmpcode =~ s/&#36;/\$/g;     $i                 = 0; 
           $tmpcode =~ s/&#64;/\@/g;     if ( $showadded == 1 ) { 
           $more_smilie_array .= qq~" $tmpcode", ~;         while ( $SmilieURL[$i] ) { 
           $i++;             if ( $SmilieURL[$i] =~ /\//ism ) { $tmpurl = $SmilieURL[$i]; } 
       }            else { $tmpurl = qq~$imagesdir/$SmilieURL[$i]~; }
   }             $moresmilieslist .= 
  qq~             <img src="$tmpurl" class="bottom pointer" alt="$SmilieDescription[$i]" title="$SmilieDescription[$i]" onclick="javascript: MoreSmilies($i);" />$SmilieLinebreak[$i]\n~;
   if ($showsmdir == 1) {             $tmpcode = $SmilieCode[$i]; 
       opendir(DIR, "$smiliesdir");             $tmpcode =~ s/\&quot;/\x22/gxsm; 
       @contents = readdir(DIR);  
       closedir(DIR);             FromHTML($tmpcode); 
       foreach $line (sort { uc($a) cmp uc($b) } @contents) {             $tmpcode =~ s/&\x2336;/\$/gxsm; 
           ($name, $extension) = split(/\./, $line);             $tmpcode =~ s/&\x2364;/\@/gxsm; 
           if ($extension =~ /gif/i || $extension =~ /jpg/i || $extension =~ /jpeg/i || $extension =~ /png/i) {             $more_smilie_array .= qq~" $tmpcode", ~; 
               if ($line !~ /banner/i) {             $i++; 
                   $moresmilieslist .= qq~                document.write('<img src="$smiliesurl/$line" align="bottom" alt="$name" title="$name" border="0" onclick="javascript: MoreSmilies($i);" style="cursor: hand;" />$SmilieLinebreak[$i] ');\n~;         } 
                   $more_smilie_array .= qq~" [smiley=$line]", ~;     } 
                   $i++;  
               }     if ( $showsmdir == 1 ) { 
           }         opendir DIR, "$htmldir/Smilies"; 
       }         @contents = readdir DIR; 
   }         closedir DIR; 
         foreach my $line ( sort { uc($a) cmp uc $b } @contents ) {
   $more_smilie_array .= qq~""~;             ( $name, $extension ) = split /\./xsm, $line; 
             if (   $extension =~ /gif/ism
   $yymain .= qq~                 || $extension =~ /jpg/ism 
   moresmiliecode = new Array($more_smilie_array)                 || $extension =~ /jpeg/ism 
   function MoreSmilies(i) {                 || $extension =~ /png/ism ) 
       AddTxt=moresmiliecode[i];             { 
       AddText(AddTxt);                 if ( $line !~ /banner/ism ) { 
   }                     $moresmilieslist .= 
   ~;  qq~             <img src="$yyhtml_root/Smilies/$line" class="bottom cursor" alt="$name" title="$name" onclick="javascript: MoreSmilies($i);" />$SmilieLinebreak[$i]\n~; 
                     $more_smilie_array .= qq~" [smiley=$line]", ~;
   if ($smiliestyle == 1) { $smiliewinlink = qq~$scripturl?action=smilieput~; }                     $i++; 
   else { $smiliewinlink = qq~$scripturl?action=smilieindex~; }                }
             }
   $yymain .= qq~         } 
   function smiliewin() {     } 
       window.open("$smiliewinlink", 'list', 'width=$winwidth, height=$winheight, scrollbars=yes');  
   }     $more_smilie_array .= q~""~; 
   ~;  
     $my_smilie_code = qq~
   if ($destination ne 'modalert2' && $destination ne 'guestpm2') {     moresmiliecode = new Array($more_smilie_array); 
       $yymain .= qq~     function MoreSmilies(i) { 
   function showimage() {         AddTxt=moresmiliecode[i]; 
       document.images.icons.src="$imagesdir/"+document.postmodify.icon.options[document.postmodify.icon.selectedIndex].value+".gif";         AddText(AddTxt); 
   }~;     } 
   }     ~; 
   
   $yymain .= qq~     if ( $smiliestyle == 1 ) { 
//-->         $smiliewinlink = qq~$scripturl?action=smilieput~; 
     }
     else { $smiliewinlink = qq~$scripturl?action=smilieindex~; }
   
     $my_smiliewin .= qq~
     function smiliewin() {
         window.open("$smiliewinlink", 'list', 'width=$winwidth, height=$winheight, scrollbars=yes');
     }
     ~;
   
     if ( $destination ne 'modalert2' && $destination ne 'guestpm2' ) {
   
         $my_modalert = qq~
     function showimage() {
         $jsPost
         var icon_set = document.postmodify.icon.options[document.postmodify.icon.selectedIndex].value;
         var icon_show = jsPost.getItem(icon_set);
         document.images.liveicons.src = icon_show;
         document.images.icons.src = icon_show;
     }~;
     }
     ToHTML($moddate);
     $my_topper = qq~
</script> </script>
<input type="hidden" name="threadid" value="$threadid" /> <input type="hidden" name="threadid" value="$threadid" />
<input type="hidden" name="postid" value="$postid" /> <input type="hidden" name="postid" value="$postid" />
<input type="hidden" name="info" value="$idinfo" /> <input type="hidden" name="info" value="$idinfo" />
<input type="hidden" name="mename" value="$mename" /> <input type="hidden" name="mename" id="mename" value="$mename" />
  <input type="hidden" name="tmpmdate" id="tmpmdate" value="$tmpmdate" />
  <input type="hidden" name="thismusername" value="$thismusername" />
  <input type="hidden" name="tmpmusername" id="tmpmusername" value="$tmpmusername" />
  <input type="hidden" name="tmpmoddate" id="tmpmoddate" value="$moddate" />
<input type="hidden" name="post_entry_time" value="$date" /> <input type="hidden" name="post_entry_time" value="$date" />
<input type="hidden" name="virboard" value="$INFO{'virboard'}$FORM{'virboard'}" />  <input type="hidden" name="virboard" value="$INFO{'virboard'}$FORM{'virboard'}" />~; 
   
<table border="0" width="100%" cellpadding="3" cellspacing="0" style="table-layout: fixed;">  
   <tr>  
       <td class="titlebg" height="18" width="100%">  
           <img src="$imagesdir/$icon.gif" name="icons2" border="0" alt="" style="vertical-align:middle;" /> $yytitle  
       </td>  
   </tr>  
~;  
   
   $iammod = 0;  
   if (keys(%moderators) > 0) {  
       while ($_ = each(%moderators)) {  
           if ($username eq $_) { $iammod = 1; }  
       }  
   }  
   if (keys(%moderatorgroups) > 0) {  
       while ($_ = each(%moderatorgroups)) {  
           if (${$uid.$username}{'position'} eq $_) { $iammod = 1; }  
           foreach $memberaddgroups (split(/,/, ${$uid.$username}{'addgroups'})) {  
               if ($memberaddgroups eq $_) { $iammod = 1; last; }  
           }  
       }  
   }  
   
   if ($threadid && (!$Quick_Post || $is_preview) && $postthread == 2 && $username ne "Guest") {  
       my ($reptime, $repuser, $isreplying, @tmprepliers, $isrep, $template_viewers, $topviewers);  
       chomp(@repliers);  
       for (my $i = 0; $i < @repliers; $i++) {  
           ($reptime, $repuser, $isreplying) = split(/\|/, $repliers[$i]);  
           next if ($date - $reptime) > 600;  
           if ($repuser eq $username) { push(@tmprepliers, qq~$date|$repuser|1~); $isrep = 1; $isreplying = 1;}  
           else { push(@tmprepliers, $repliers[$i]); }  
           if ($isreplying) {  
               &LoadUser($repuser);  
               $template_viewers .= qq~$link{$repuser}, ~;  
               $topviewers++;  
           }  
       }  
       if (!$isrep) {  
           push(@tmprepliers, qq~$date|$username|1~);  
           $template_viewers .= qq~$link{$username}, ~;  
           $topviewers++;  
       }  
       &MessageTotals("load", $curnum);  
       @repliers = @tmprepliers;  
       &MessageTotals("update", $curnum);  
   
       if ($showtopicrepliers && $template_viewers && (($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1)) {  
           $template_viewers =~ s/\, \Z/\./;  
           $yymain .= qq~  
   <tr>  
       <td class="windowbg" valign="middle" align="left">  
           $display_txt{'646'} ($topviewers): $template_viewers  
       </td>  
   </tr>~;  
       }  
   }  
   
   $yymain .= qq~  
</table>  
   ~;  
   
   if ($pollthread) {  
       $maxpq          ||= 60;  
       $maxpo          ||= 50;  
       $maxpc          ||= 0;  
       $numpolloptions ||= 8;  
       $vote_limit     ||= 0;  
       $pie_radius     ||= 100;  
   
       if (($iamadmin || $iamgmod) && -e "$datadir/showcase.poll") {  
           fopen (FILE, "$datadir/showcase.poll");  
           $scchecked = ' checked="checked"' if $threadid == <FILE>;  
           fclose (FILE);  
       }  
       if ($guest_vote)   { $gvchecked = ' checked="checked"'; }  
       if ($hide_results) { $hrchecked = ' checked="checked"'; }  
       if ($multi_choice) { $mcchecked = ' checked="checked"'; }  
       if ($pie_legends)  { $legchecked = ' checked="checked"'; }  
   
       $yymain .= qq~  
<table border="0" width="100%" cellpadding="3" cellspacing="0" class="windowbg" style="table-layout: fixed;">  
   <tr>  
       <td width="250" class="catbg"><label for="question"><b>$post_polltxt{'6'}:</b></label></td>  
       <td width="240" class="catbg">&nbsp;</td>  
       <td width="60" class="catbg">&nbsp;</td>  
       <td width="60" class="catbg">&nbsp;</td>  
       <td class="catbg">&nbsp;</td>  
   </tr>  
   <tr>  
       <td class="windowbg2" colspan="5" style="font-size: 3px;">&nbsp;</td>  
   </tr>  
   <tr>  
   <td align="left" class="windowbg2">&nbsp;</td>  
   <td colspan="4" align="left" class="windowbg2">  
       <input type="text" size="60" name="question" id="question" value="$poll_question" maxlength="$maxpq" />  
       <input type="hidden" name="pollthread" value="$pollthread" />  
   </td>  
   </tr>  
   <tr>  
       <td class="windowbg2" colspan="5" style="font-size: 3px;">&nbsp;</td>  
   </tr>  
   <tr>  
       <td align="left" class="catbg"><b>$post_polltxt{'polloptions'}</b></td>  
       <td align="left" class="catbg"><b>$post_polltxt{'polloptionstext'}</b></td>  
       <td align="center" class="catbg"><b>$post_polltxt{'pieslicecolor'}</b></td>  
       <td align="center" class="catbg"><b>$post_polltxt{'pieslicesplit'}</b></td>  
       <td class="catbg">&nbsp;</td>  
   </tr>  
   <tr>  
       <td class="windowbg2" colspan="5" style="font-size: 3px;">&nbsp;</td>  
   </tr>~;  
   
       $piecolarray = qq~["",~;  
       for (my $i = 1; $i <= $numpolloptions; $i++) {  
           if ($split[$i]) { $splitchecked[$i] = ' checked="checked"'; }  
           if($FORM{"slicecol$i"}) { $slicecolor[$i] = $FORM{"slicecol$i"}; }  
           $yymain .= qq~  
   <tr>  
       <td align="right" class="windowbg2"><label for="option$i"> &nbsp; $post_polltxt{'7'} $i: &nbsp;</label></td>  
       <td align="left" class="windowbg2">  
           <input type="text" size="35" maxlength="$maxpo" name="option$i" id="option$i" value="$options[$i]" />  
       </td>  
       <td align="center" class="windowbg2">  
           <input type="text" size="3" name="slicecolor$i" id="slicecolor$i" value="" style="background-color: $slicecolor[$i]; border: 1px outset $slicecolor[$i]; cursor: pointer;" readonly="readonly" onclick="getSlicecolor($i)" />  
           <input type="hidden" name="slicecol$i" id="slicecol$i" value="$slicecolor[$i]" />  
       </td>  
       <td align="center" class="windowbg2">  
           <input type="checkbox" name="split$i" value="1"$splitchecked[$i] /> <span  class="small">$post_polltxt{'splitslice'}</span>  
       </td>  
       <td align="left" class="windowbg2">  
           &nbsp;  
       </td>  
   </tr>~;  
           $piecolarray .= qq~"$slicecolor[$i]", ~;  
       }  
       $piecolarray =~ s/\, $//i;  
       $piecolarray .= qq~]~;  
   
       if ($maxpc > 0) {  
           $yymain .= qq~  
   <tr>  
       <td valign=top class="windowbg2"><b>$post_polltxt{'59'}:</b></td>  
       <td class="windowbg2" colspan="4"><textarea name="poll_comment" rows="3" cols="60" wrap="soft" onkeyup="if (document.postmodify.poll_comment.value.length > $maxpc) {document.postmodify.poll_comment.value = document.postmodify.poll_comment.value.substring(0,$maxpc)}">$poll_comment</textarea></td>  
   </tr>~;  
       }  
   
       if ($poll_end) {  
           my $x = $poll_end - $date;  
           if ($x <= 0) {  
               $poll_end_min = 1;  
           } else {  
               $poll_end_days = int($x / 86400);  
               $poll_end_min = int(($x - ($poll_end_days * 86400)) / 60);  
           }  
       }  
   
       $yymain .= qq~  
   <tr>  
       <td class="windowbg2" colspan="5" style="font-size: 3px;">  
           <script language="JavaScript1.2" type="text/javascript">  
           <!--  
           var tmpslicecolor;  
           var itohex = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];  
           var slice_col = $piecolarray;  
           var defslice_col = new Array();  
           function tohex(i) {  
               a2 = ''   
               ihex = Math.floor(eval(i +'/16'));  
               idiff = eval(i + '-(' + ihex + '*16)')  
               a2 = itohex[idiff] + a2;  
               while( ihex >= 16) {  
                   itmp = Math.floor(eval(ihex +'/16'));  
                   idiff = eval(ihex + '-(' + itmp + '*16)');  
                   a2 = itohex[idiff] + a2;  
                   ihex = itmp;  
               }  
               a1 = itohex[ihex];  
               return a1 + a2;  
           }  
   
           for (var tz = 0; tz < 256; tz += 63)  
               for (var ty = 0; ty < 256; ty += 85)  
                   for (var tx = 0; tx < 256; tx += 127) defslice_col.push('#' + tohex(tx) + tohex(ty) + tohex(tz));  
   
           for(var i = 1; i <= $numpolloptions; i++) {  
               if(!slice_col[i]) slice_col[i] = defslice_col[i]  
               document.getElementById('slicecolor' + i).style.backgroundColor = slice_col[i];  
               document.getElementById('slicecolor' + i).style.borderColor = slice_col[i];  
               document.getElementById('slicecol' + i).value = slice_col[i];  
           }  
   
           function getSlicecolor(slicenum) {  
               tmpslicecolor = slicenum;  
               window.open('$scripturl?action=palette;task=templ', '', 'height=308,width=302,menubar=no,toolbar=no,scrollbars=no');  
           }  
   
           function previewColor(newsilcecolor) {  
               document.getElementById('slicecolor' + tmpslicecolor).style.backgroundColor = newsilcecolor;  
               document.getElementById('slicecolor' + tmpslicecolor).style.borderColor = newsilcecolor;  
               document.getElementById('slicecol' + tmpslicecolor).value = newsilcecolor;  
           }  
           //-->  
           </script>  
       </td>  
   </tr>~ . ($poll_locked ? '' : qq~  
   <tr>  
       <td align="left" valign="top"><label for="poll_end_days"><b>$post_polltxt{'31'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><span  class="small"><input type="text" name="poll_end_days" id="poll_end_days" value="$poll_end_days" size="4" /> $post_polltxt{'31a'} <input type="text" name="poll_end_min" value="$poll_end_min" size="4" /> $post_polltxt{'31b'} $post_polltxt{'31c'}</span></td>  
   </tr>~) . (($iamadmin || $iamgmod) ? qq~  
   <tr>  
       <td align="left" valign="top"><label for="scpoll"><b>$post_polltxt{'30'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><input type="checkbox" name="scpoll" id="scpoll" value="1"$scchecked /> <span  class="small"><label for="scpoll">$post_polltxt{'30a'}</label></span></td>  
   </tr>~ : '') . qq~  
   <tr>  
       <td align="left" valign="top"><label for="guest_vote"><b>$post_polltxt{'32'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><input type="checkbox" name="guest_vote" id="guest_vote" value="1"$gvchecked /> <span  class="small"><label for="guest_vote">$post_polltxt{'54'}</label></span></td>  
   </tr>  
   <tr>  
       <td align="left" valign="top"><label for="hide_results"><b>$post_polltxt{'26'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><input type="checkbox" name="hide_results" id="hide_results" value="1"$hrchecked /> <span  class="small"><label for="hide_results">$post_polltxt{'55'}</label></span></td>  
   </tr>  
   <tr>  
       <td align="left" valign="top"><label for="multi_choice"><b>$post_polltxt{'58'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><input type="checkbox" name="multi_choice" id="multi_choice" value="1"$mcchecked /> <span  class="small"><label for="multi_choice">$post_polltxt{'56'}</label></span></td>  
   </tr>  
   <tr>  
       <td align="left" valign="top"><label for="vote_limit"><b>$post_polltxt{'60'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><input type="text" size="6" name="vote_limit" id="vote_limit" value="$vote_limit" /> <span  class="small"><label for="vote_limit">$post_polltxt{'61'}</label></span></td>  
   </tr>  
   <tr>  
       <td align="left" valign="top"><label for="pie_legends"><b>$post_polltxt{'pielegends'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><input type="checkbox" name="pie_legends" id="pie_legends" value="1"$legchecked /> <span  class="small"><label for="pie_legends">$post_polltxt{'pielegends_descr'}</label></span></td>  
   </tr>  
   <tr>  
       <td align="left" valign="top"><label for="pie_radius"><b>$post_polltxt{'pieradius'}</b></label></td>  
       <td align="left" valign="top" colspan="4"><input type="text" size="4" name="pie_radius" id="pie_radius" value="$pie_radius" /> <span  class="small"><label for="pie_radius">$post_polltxt{'pieradius_descr'}</label></span></td>  
   </tr>  
</table>~;  
   }  
   
   
   $yymain .= qq~  
<table border="0" width="100%" cellpadding="3" cellspacing="0" class="windowbg" style="table-layout: fixed;">~;  
   
   if ($postid ne 'Poll') {  
       $yymain .= qq~  
       <tr>  
           <td width="23%" align="left" valign="top" class="windowbg"><b>$post_txt{'507'}</b></td>  
           <td width="77%" class="windowbg">$prevmain</td>  
       </tr>  
       ~ if $prevmain;  
   
       $yymain .= qq~  
   <tr>  
       <td width="23%" class="windowbg" valign="top">  
           <div id="SaveInfo" style="height:16px;">  
           <img name="prevwin" id="prevwin" src="$defaultimagesdir/cat_expand.gif" alt="$npf_txt{'01'}" title="$npf_txt{'01'}" border="0" style="cursor:pointer; cursor:hand;" onclick="enabPrev();" /> <b>$npf_txt{'04'}</b>  
           </div>  
       </td>  
       <td width="77%" class="windowbg">  
           <div id="savetable" class="bordercolor" style="padding:1px; width:100%; margin:auto; visibility:hidden;">  
           <table border="0" width="100%" cellpadding="3" cellspacing="0" style="table-layout:fixed;">  
             <tr>  
               <td class="titlebg">  
                <div id="savetopic" style="height:0px; text-align:left; vertical-align:middle; font-weight:bold; overflow:auto;">&nbsp;</div>  
               </td>  
             </tr>  
             <tr>  
               <td class="windowbg2">  
                <div id="saveframe" class="message" style="height:0px; text-align:left; vertical-align:top; overflow:auto;">&nbsp;</div>  
               </td>  
             </tr>  
           </table>  
           </div>  
       </td>  
   </tr>~;  
   
       $topicstatus_row = "";  
       $stselect        = "";  
       $lcselect        = "";  
       $hdselect        = "";  
       $threadclass     = 'thread';  
   
       ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);  
       if ($FORM{'topicstatus'}) { $thestatus = $FORM{'topicstatus'}; }  
       else { $thestatus = $mstate; }  
       if ($currentboard eq $annboard) {  
           $threadclass     = 'announcement';  
       } else {  
           if ($mreplies >= $VeryHotTopic) { $threadclass = 'veryhotthread'; }  
           elsif ($mreplies >= $HotTopic) { $threadclass = 'hotthread'; }  
       }  
       if($action ne "modalert") {  
           if ($thestatus =~ /s/) { $stselect = qq~selected="selected"~; }  
           if ($thestatus =~ /l/) { $lcselect = qq~selected="selected"~; }  
           if ($thestatus =~ /h/) { $hdselect = qq~selected="selected"~; }  
           $hidestatus = "";  
   
           if (($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {  
               $yymain .= qq~  
   <tr id="feature_status_4">  
       <td class="windowbg" align="left" valign="top" width="23%"><label for="topicstatus"><b>$post_txt{'34'}:</b></label></td>  
       <td class="windowbg" align="left" valign="middle" width="77%">  
           <select multiple="multiple" name="topicstatus" id="topicstatus" size="~ . ($currentboard ne $annboard ? 3 : 2) . qq~" style="vertical-align: middle;" onchange="showtpstatus()">  
           ~ . ($currentboard ne $annboard ? qq~<option value="s" $stselect>$post_txt{'35'}</option>~ : "") . qq~  
           <option value="l" $lcselect>$post_txt{'36'}</option>  
           <option value="h" $hdselect>$post_txt{'37'}</option>  
           </select>  
           <img src="$imagesdir/$threadclass.gif" name="thrstat" border="0" hspace="15" alt="" style="vertical-align: middle;" />  
       </td>  
   </tr>~;  
   
           } else {  
               $hidestatus = qq~<input type="hidden" value="$thestatus" name="topicstatus" />~;  
           }  
       }  
       $yymain .= qq~  
   $extra  
   $name_field  
   $email_field  
   $verification_field  
   <tr>  
       <td align="left" class="windowbg2" width="23%">  
           <label for="subject"><b>$post_txt{'70'}:</b></label>  
       </td>  
       <td align="left" class="windowbg2" width="77%">  
           <input type="text" name="subject" id="subject" value="$sub" size="50" maxlength="~ . ($set_subjectMaxLength + ($sub =~ /^Re: / ? 4 : 0)) . qq~" tabindex="1" style="width: 437px;" onkeyup="updatTopic()" />  
       </td>  
   </tr>  
   <tr>  
       <td class="windowbg2" width="23%" align="left" valign="top">  
           <label for="message"><b>$post_txt{'72'}:</b></label><br /><span class="small">$post_txt{'resizedescript'}</span>  
       </td>  
       <td rowspan="~ . ((!$removenormalsmilies || ($showadded == 3 && $showsmdir != 2) || ($showsmdir == 3 && $showadded != 2)) ? 2 : 3) . qq~" valign="middle" class="windowbg2" width="77%">  
       ~;  
       if ($enable_ubbc && $showyabbcbutt) {  
           $yymain .= qq~  
           <div style="float: left; width: 440px;">  
           <script language="JavaScript1.2" type="text/javascript">  
           <!--  
           HAND = "style='cursor: pointer;'";  
           HAND += " onmouseover='contextTip(event, this.alt)' onmouseout='contextTip(event, this.alt)' oncontextmenu='if(!showcontexthelp(this.src, this.alt)) return false;'";  
           document.write('<div style="width: 437px; float: left;">');  
           document.write("<img src='$imagesdir/url.gif' onclick='hyperlink();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'257'}' title='$post_txt{'257'}' border='0' />");  
           document.write("<img src='$imagesdir/ftp.gif' onclick='ftp();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'434'}' title='$post_txt{'434'}' border='0' />");  
           document.write("<img src='$imagesdir/img.gif' onclick='image();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'435'}' title='$post_txt{'435'}' border='0' />");  
           document.write("<img src='$imagesdir/email2.gif' onclick='emai1();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'258'}' title='$post_txt{'258'}' border='0' />");  
           document.write("<img src='$imagesdir/media.gif' onclick='flash();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'433'}' title='$post_txt{'433'}' border='0' />");  
           document.write("<img src='$imagesdir/table.gif' onclick='table();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'436'}' title='$post_txt{'436'}' border='0' />");  
           document.write("<img src='$imagesdir/tr.gif' onclick='trow();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'449'}' title='$post_txt{'449'}' border='0' />");  
           document.write("<img src='$imagesdir/td.gif' onclick='tcol();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'437'}' title='$post_txt{'437'}' border='0' />");  
           document.write("<img src='$imagesdir/hr.gif' onclick='hr();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'531'}' title='$post_txt{'531'}' border='0' />");  
           document.write("<img src='$imagesdir/tele.gif' onclick='teletype();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'440'}' title='$post_txt{'440'}' border='0' />");  
           document.write("<img src='$imagesdir/code.gif' onclick='selcodelang();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'259'}' title='$post_txt{'259'}' border='0' />");  
           document.write("<img src='$imagesdir/quote2.gif' onclick='quote();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'260'}' title='$post_txt{'260'}' border='0' />");  
           document.write("<img src='$imagesdir/edit.gif' onclick='edit();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'603'}' title='$post_txt{'603'}' border='0' />");  
           document.write("<img src='$imagesdir/sup.gif' onclick='superscript();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'447'}' title='$post_txt{'447'}' border='0' />");  
           document.write("<img src='$imagesdir/sub.gif' onclick='subscript();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'448'}' title='$post_txt{'448'}' border='0' />");  
           document.write("<img src='$imagesdir/list.gif' onclick='bulletset();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'261'}' title='$post_txt{'261'}' border='0' />");  
           document.write("<img src='$imagesdir/me.gif' onclick='me();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'604'}' title='$post_txt{'604'}' border='0' />");  
           document.write("<img src='$imagesdir/move.gif' onclick='move();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'439'}' title='$post_txt{'439'}' border='0' />");  
           document.write("<img src='$imagesdir/timestamp.gif' onclick='timestamp($date);' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'245'}' title='$post_txt{'245'}' border='0' /><br />");  
           document.write('</div>');  
           document.write('<div style="width: 115px; float: left;">');  
           document.write("<img src='$imagesdir/bold.gif' onclick='bold();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'253'}' title='$post_txt{'253'}' border='0' />");  
           document.write("<img src='$imagesdir/italicize.gif' onclick='italicize();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'254'}' title='$post_txt{'254'}' border='0' />");  
           document.write("<img src='$imagesdir/underline.gif' onclick='underline();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'255'}' title='$post_txt{'255'}' border='0' />");  
           document.write("<img src='$imagesdir/strike.gif' onclick='strike();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'441'}' title='$post_txt{'441'}' border='0' />");  
           document.write("<img src='$imagesdir/highlight.gif' onclick='highlight();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'246'}' title='$post_txt{'246'}' border='0' />");  
           document.write('</div>');  
           document.write('<div style="width: 139px; float: left; text-align: center;">');  
           document.write('<select name="fontface" id="fontface" onchange="if(this.options[this.selectedIndex].value) fontfce(this.options[this.selectedIndex].value);" style="width: 90px; margin-top: 2px; margin-left: 2px; margin-right: 1px; font-size: 9px;">');  
           document.write('<option value="">Verdana</option>');  
           document.write('<option value="">-\\-\\-\\-\\-\\-\\-\\-\\-</option>');  
           document.write('<option value="Arial" style="font-family: Arial">Arial</option>');  
           document.write('<option value="Bitstream Vera Sans Mono" style="font-family: Bitstream Vera Sans Mono">Bitstream</option>');  
           document.write('<option value="Bradley Hand ITC" style="font-family: Bradley Hand ITC">Bradley Hand ITC</option>');  
           document.write('<option value="Comic Sans MS" style="font-family: Comic Sans MS">Comic Sans MS</option>');  
           document.write('<option value="Courier" style="font-family: Courier">Courier</option>');  
           document.write('<option value="Courier New" style="font-family: Courier New">Courier New</option>');  
           document.write('<option value="Georgia" style="font-family: Georgia">Georgia</option>');  
           document.write('<option value="Impact" style="font-family: Impact">Impact</option>');  
           document.write('<option value="Lucida Sans" style="font-family: Lucida Sans">Lucida Sans</option>');  
           document.write('<option value="Microsoft Sans Serif" style="font-family: Microsoft Sans Serif">MS Sans Serif</option>');  
           document.write('<option value="Papyrus" style="font-family: Papyrus">Papyrus</option>');  
           document.write('<option value="Tahoma" style="font-family: Tahoma">Tahoma</option>');  
           document.write('<option value="Tempus Sans ITC" style="font-family: Tempus Sans ITC">Tempus Sans ITC</option>');  
           document.write('<option value="Times New Roman" style="font-family: Times New Roman">Times New Roman</option>');  
           document.write('<option value="Verdana" style="font-family: Verdana">Verdana</option>');  
           document.write('</select>');  
           var fntoptions = ["6", "7", "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "36", "48", "56", "72"]  
           document.write('<select name="fontsize" id="fontsize" onchange="if(this.options[this.selectedIndex].value) fntsize(this.options[this.selectedIndex].value);" style="width: 39px; margin-top: 2px; margin-left: 1px; margin-right: 2px; font-size: 9px;">');  
           document.write('<option value="">11</option>');  
           document.write('<option value="">-\\-</option>');  
           for(var i = 0; i < fntoptions.length; i++) {  
               if(fntoptions[i] >= $fontsizemin && fntoptions[i] <= $fontsizemax) {  
                   if(fntoptions[i] == 11) document.write('<option value="11" selected="selected">11</option>');  
                   else document.write('<option value=' + fntoptions[i] + '>' + fntoptions[i] + '</option>');  
               }  
           }  
           document.write('</select>');  
           document.write('</div>');  
   
   
           function selcodelang() {  
               if (document.getElementById("codelang").style.display == "none")  
               document.getElementById("codelang").style.display = "inline-block";  
               else  
               document.getElementById("codelang").style.display = "none";  
               document.getElementById("codelang").style.zIndex = "100";  
   
               var openbox = document.getElementsByTagName("div");  
               for (var i = 0; i < openbox.length; i++) {  
                   if (openbox[i].className == "ubboptions" && openbox[i].id != "codelang") {  
                       openbox[i].style.display = "none";  
                   }  
               }  
           }  
   
           function syntaxlang(lang, optnum) {  
               AddSelText("[code"+lang+"]","[/code]");  
               document.getElementById("codesyntax").options[optnum].selected = false;  
               document.getElementById("codelang").style.display = "none";  
           }  
   
           function bulletset() {  
               if (document.getElementById("bullets").style.display == "none")  
               document.getElementById("bullets").style.display = "block";  
               else  
               document.getElementById("bullets").style.display = "none";  
               document.getElementById("bullets").style.zIndex = "100";  
   
               var openbox = document.getElementsByTagName("div");  
               for (var i = 0; i < openbox.length; i++) {  
                   if (openbox[i].className == "ubboptions" && openbox[i].id != "bullets") {  
                       openbox[i].style.display = "none";  
                   }  
               }  
           }  
   
           function showbullets(bullet) {  
               AddSelText("[list "+bullet+"][*]", "\\n[/list]");  
           }  
   
           function olist() {  
               AddSelText("[olist][*]", "\\n[/olist]");  
           }  
   
           // Palette  
           var thistask = 'post';  
           function tohex(i) {  
               a2 = ''   
               ihex = hexQuot(i);  
               idiff = eval(i + '-(' + ihex + '*16)')  
               a2 = itohex(idiff) + a2;  
               while( ihex >= 16) {  
                   itmp = hexQuot(ihex);  
                   idiff = eval(ihex + '-(' + itmp + '*16)');  
                   a2 = itohex(idiff) + a2;  
                   ihex = itmp;  
               }  
               a1 = itohex(ihex);  
               return a1 + a2 ;  
           }  
   
           function hexQuot(i) {  
               return Math.floor(eval(i +'/16'));  
           }  
   
           function itohex(i) {  
               if( i == 0) { aa = '0' }  
               else { if( i == 1 ) { aa = '1' }  
               else { if( i == 2 ) { aa = '2' }  
               else { if( i == 3 ) { aa = '3' }  
               else { if( i == 4 ) { aa = '4' }  
               else { if( i == 5 ) { aa = '5' }  
               else { if( i == 6 ) { aa = '6' }  
               else { if( i == 7 ) { aa = '7' }  
               else { if( i == 8 ) { aa = '8' }  
               else { if( i == 9 ) { aa = '9' }  
               else { if( i == 10) { aa = 'a' }  
               else { if( i == 11) { aa = 'b' }  
               else { if( i == 12) { aa = 'c' }  
               else { if( i == 13) { aa = 'd' }  
               else { if( i == 14) { aa = 'e' }  
               else { if( i == 15) { aa = 'f' }  
               }}}}}}}}}}}}}}}  
               return aa;  
           }  
   
           function ConvShowcolor(color) {  
               if ( c=color.match(/rgb\\((\\d+?)\\, (\\d+?)\\, (\\d+?)\\)/i) ) {  
                   var rhex = tohex(c[1]);  
                   var ghex = tohex(c[2]);  
                   var bhex = tohex(c[3]);  
                   var newcolor = '#'+rhex+ghex+bhex;  
               }  
               else {  
                   var newcolor = color;  
               }  
               if(thistask == "post") showcolor(newcolor);  
               if(thistask == "templ") previewColor(newcolor);  
           }  
           //-->  
           </script>  
           <div style="float: left; height: 22px; width: 91px;">  
           <div class="bordercolor" style="height: 20px; width: 66px; padding-left: 1px; padding-top: 1px; margin-top: 1px; float: left;">  
               <span style="float: left; background-color: #000000; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#000000')">&nbsp;</span>  
               <span style="float: left; background-color: #333333; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#333333')">&nbsp;</span>  
               <span style="float: left; background-color: #666666; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#666666')">&nbsp;</span>  
               <span style="float: left; background-color: #999999; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#999999')">&nbsp;</span>  
               <span style="float: left; background-color: #cccccc; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#cccccc')">&nbsp;</span>  
               <span style="float: left; background-color: #ffffff; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor('#ffffff')">&nbsp;</span>  
               <span id="defaultpal1" style="float: left; background-color: $pallist[0]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>  
               <span id="defaultpal2" style="float: left; background-color: $pallist[1]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>  
               <span id="defaultpal3" style="float: left; background-color: $pallist[2]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>  
               <span id="defaultpal4" style="float: left; background-color: $pallist[3]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>  
               <span id="defaultpal5" style="float: left; background-color: $pallist[4]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>  
               <span id="defaultpal6" style="float: left; background-color: $pallist[5]; width: 10px; height: 9px; margin-right: 1px; margin-bottom: 1px; border: 0px; font-size: 5px; cursor: pointer; cursor: hand;" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>  
           </div>  
           <div style="height: 22px; width: 23px; padding-left: 1px; float: right;">  
               <img src="$imagesdir/palette1.gif" style="cursor: pointer" onclick="window.open('$scripturl?action=palette;task=post', '', 'height=308,width=302,menubar=no,toolbar=no,scrollbars=no')" alt="" border="0" />  
           </div>  
           </div>  
           <script language="JavaScript1.2" type="text/javascript">  
           <!--  
           HAND = "style='cursor: pointer;'";  
           HAND += " onmouseover='contextTip(event, this.alt)' onmouseout='contextTip(event, this.alt)' oncontextmenu='if(!showcontexthelp(this.src, this.alt)) return false;'";  
           document.write('<div style="width: 92px; float: left;">');  
           document.write("<img src='$imagesdir/pre.gif' onclick='pre();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'444'}' title='$post_txt{'444'}' border='0' />");  
           document.write("<img src='$imagesdir/left.gif' onclick='left();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'445'}' title='$post_txt{'445'}' border='0' />");  
           document.write("<img src='$imagesdir/center.gif' onclick='center();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'256'}' title='$post_txt{'256'}' border='0' />");  
           document.write("<img src='$imagesdir/right.gif' onclick='right();' "+HAND+" align='top' width='23' height='22' alt='$post_txt{'446'}' title='$post_txt{'446'}' border='0' />");  
           document.write('</div>');  
           //-->  
           </script>  
           <noscript>  
           <span class="small">$maintxt{'noscript'}</span>  
           </noscript>  
           </div>~;  
       }  
   
       if (!${$uid.$username}{'postlayout'}) {  
           $pheight = 130; $pwidth = 425; $textsize = 10;  
       } else {  
           ($pheight, $pwidth, $textsize, $col_row) = split(/\|/, ${$uid.$username}{'postlayout'});  
       }  
       $col_row ||= 0;  
       if(!$textsize || $textsize < 6) { $textsize = 6; }  
       if($textsize > 16) { $textsize = 16; }  
       if($pheight > 400) { $pheight = 400; }  
       if($pheight < 130) { $pheight = 130; }  
       if($pwidth > 855) { $pwidth = 855; }  
       if($pwidth < 425) { $pwidth = 425; }  
       $mtextsize = $textsize . "pt";  
       $mheight = $pheight . "px";  
       $mwidth = $pwidth . "px";  
       $dheight = ($pheight + 12) . "px";  
       $dwidth = ($pwidth + 12) . "px";  
       $jsdragwpos = $pwidth - 425;  
       $dragwpos = ($pwidth - 425) . "px";  
       $jsdraghpos = $pheight - 130;  
       $draghpos = ($pheight - 130) . "px";  
   
       $yymain .= qq~  
   
           <div id="spell_container"></div>  
           <div style="float: left; width: 99%;">  
           <input type="hidden" name="messagewidth" id="messagewidth" value="$pwidth" />  
           <input type="hidden" name="messageheight" id="messageheight" value="$pheight" />  
           <div id="dragcanvas" style="position: relative; top: 0px; left: 0px; height: $dheight; width: $dwidth; border: 0; z-index: 1;">  
           <textarea name="message" id="message" rows="8" cols="68" style="position: absolute; top: 0px; left: 0px; z-index: 2; height: $mheight; width: $mwidth; font-size: $mtextsize; padding: 5px; margin: 0px; visibility: visible;" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="4">$message</textarea>  
           <div id="dragbgw" style="position: absolute; top: 0px; left: 437px; width: 3px; height: $dheight; border: 0; z-index: 3;">  
           <img id="dragImg1" src="$defaultimagesdir/resize_wb.gif" class="drag" style="position: absolute; top: 0px; left: $dragwpos; z-index: 4; width: 3px; height: $dheight; cursor: e-resize;" alt= "" />  
           </div>  
           <div id="dragbgh" style="position: absolute; top: 142px; left: 0px; width: $dwidth; height: 3px; border: 0; z-index: 3;">  
           <img id="dragImg2" src="$defaultimagesdir/resize_hb.gif" class="drag" style="position: absolute; top: $draghpos; left: 0px; z-index: 4; width: $dwidth; height: 3px; cursor: n-resize;" alt= "" />  
           </div>  
           <div class="ubboptions" id="bullets" style="position: absolute; top: -22px; left: 345px; width: 63px; border: 1px solid #666666; padding: 2px; text-align: center; background-color: #CCCCCC; display: none;">  
           <input type="button" value="$npf_txt{'default'}" style="width: 56px; margin: 3px 0px 0px 0px; font-size: 9px; padding: 0px; text-align: center;" onclick="list(), bulletset()" /><br />  
           <input type="button" value="$npf_txt{'ordered'}" style="width: 56px; margin: 3px 0px 3px 0px; font-size: 9px; padding: 0px; text-align: center;" onclick="olist(), bulletset()" /><br />  
           <img src="$defaultimagesdir/bull-redball.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-redball'), bulletset()" /><img src="$defaultimagesdir/bull-greenball.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-greenball'), bulletset()" /><img src="$defaultimagesdir/bull-blueball.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-blueball'), bulletset()" /><img src="$defaultimagesdir/bull-blackball.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-blackball'), bulletset()" /><br />  
           <img src="$defaultimagesdir/bull-redsq.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-redsq'), bulletset()" /><img src="$defaultimagesdir/bull-greensq.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-greensq'), bulletset()" /><img src="$defaultimagesdir/bull-bluesq.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-bluesq'), bulletset()" /><img src="$defaultimagesdir/bull-blacksq.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-blacksq'), bulletset()" /><br />  
           <img src="$defaultimagesdir/bull-redpin.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-redpin'), bulletset()" /><img src="$defaultimagesdir/bull-greenpin.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-greenpin'), bulletset()" /><img src="$defaultimagesdir/bull-bluepin.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-bluepin'), bulletset()" /><img src="$defaultimagesdir/bull-blackpin.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-blackpin'), bulletset()" /><br />  
           <img src="$defaultimagesdir/bull-redcheck.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-redcheck'), bulletset()" /><img src="$defaultimagesdir/bull-greencheck.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-greencheck'), bulletset()" /><img src="$defaultimagesdir/bull-bluecheck.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-bluecheck'), bulletset()" /><img src="$defaultimagesdir/bull-blackcheck.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-blackcheck'), bulletset()" /><br />  
           <img src="$defaultimagesdir/bull-redarrow.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-redarrow'), bulletset()" /><img src="$defaultimagesdir/bull-greenarrow.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-greenarrow'), bulletset()" /><img src="$defaultimagesdir/bull-bluearrow.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-bluearrow'), bulletset()" /><img src="$defaultimagesdir/bull-blackarrow.gif" style="width: 8px; height: 8px; background-color: #CCCCCC; margin: 3px; cursor: pointer;" onclick="showbullets('bull-blackarrow'), bulletset()" /><br />  
           </div>  
           <div class="ubboptions" id="codelang" style="position: absolute; top: -22px; left: 230px; width: 92px; padding: 0px; background-color: #CCCCCC; display: none;">  
               <select size="10" name="codesyntax" id="codesyntax" onchange="syntaxlang(this.options[this.selectedIndex].value, this.selectedIndex);" style="margin:0px; font-size: 9px; width: 92px;">  
               <option value="" title="$npf_txt{'default'}">$npf_txt{'default'}</option>  
               <option value=" c++" title="C++">C++</option>  
               <option value=" css" title="CSS">CSS</option>  
               <option value=" html" title="HTML">HTML</option>  
               <option value=" java" title="Java">Java</option>  
               <option value=" javascript" title="Javascript">Javascript</option>  
               <option value=" pascal" title="Pascal">Pascal</option>  
               <option value=" perl" title="Perl">Perl</option>  
               <option value=" php" title="PHP">PHP</option>  
               <option value=" sql" title="SQL">SQL</option>  
               </select>  
           </div>  
           </div>  
           <div style="float: left; width: 315px; text-align: left;">  
           <img src="$imagesdir/green1.gif" name="chrwarn" height="8" width="8" border="0" vspace="0" hspace="0" alt="" align="middle" />  
           <span class="small">$npf_txt{'03'} <input value="$MaxMessLen" size="3" name="msgCL" class="windowbg2" style="border: 0px; font-size: 11px; width: 40px; padding: 1px" readonly="readonly" /></span>  
           </div>  
           <div style="float: left; width: 127px; text-align: right;">  
               <span class="small">$post_txt{'textsize'} <input value="$textsize" size="2" name="txtsize" id="txtsize" class="windowbg2" style="border: 0px; font-size: 11px; width: 15px; padding: 1px" readonly="readonly" />pt <img src="$imagesdir/smaller.gif" height="11" width="11" border="0" alt="" align="middle" onclick="sizetext(-1);" /><img src="$imagesdir/larger.gif" height="11" width="11" border="0" alt="" align="middle" onclick="sizetext(1);" /></span>  
           </div>  
           </div>  
       </td>  
   </tr>  
   <tr>  
       <td valign="top" class="windowbg2" width="23%">  
       ~;  
   
       # SpellChecker start  
       if ($enable_spell_check) {  
           $yyinlinestyle .= qq~<link href="$yyhtml_root/googiespell/googiespell.css" rel="stylesheet" type="text/css" />  
   
<script type="text/javascript" src="$yyhtml_root/AJS.js"></script>  
<script type="text/javascript" src="$yyhtml_root/googiespell/googiespell.js"></script>  
<script type="text/javascript" src="$yyhtml_root/googiespell/cookiesupport.js"></script>~;  
           my $userdefaultlang = (split(/-/, $abbr_lang))[0];  
           $userdefaultlang ||= 'en';  
           $yymain .= qq~  
           <script type="text/javascript">  
           <!--  
           GOOGIE_DEFAULT_LANG = '$userdefaultlang';  
           var googie1 = new GoogieSpell("$yyhtml_root/googiespell/", "$boardurl/Sources/SpellChecker.pl?lang=");  
           googie1.lang_chck_spell = '$spell_check{'chck_spell'}';  
           googie1.lang_revert = '$spell_check{'revert'}';  
           googie1.lang_close = '$spell_check{'close'}';  
           googie1.lang_rsm_edt = '$spell_check{'rsm_edt'}';  
           googie1.lang_no_error_found = '$spell_check{'no_error_found'}';  
           googie1.lang_no_suggestions = '$spell_check{'no_suggestions'}';  
           googie1.setSpellContainer("spell_container");  
           googie1.decorateTextarea("message");  
           //-->  
           </script>~;  
       }  
       # SpellChecker end  
   
       if ($showadded == 2 || $showsmdir == 2) {  
           $yymain .= qq~  
           <script language="JavaScript1.2" type="text/javascript">  
           <!--  
           function Smiliextra() {  
               AddTxt=smiliecode[document.postmodify.smiliextra_list.value];  
               AddText(AddTxt);  
           }~;  
   
           $smilieslist = '';  
           $smilie_url_array = '';  
           $smilie_code_array = '';  
           $i = 0;  
           if ($showadded eq 2) {  
               while ($SmilieURL[$i]) {  
                   $smilieslist .= qq~    document.write('<option value="$i"~ . ($SmilieDescription[$i] eq $showinbox ? ' selected="selected"' : '') . qq~>$SmilieDescription[$i]</option>');\n~;  
                   if ($SmilieURL[$i] =~ /\//i) { $tmpurl = $SmilieURL[$i]; }  
                   else { $tmpurl = qq~$defaultimagesdir/$SmilieURL[$i]~; }  
                   $smilie_url_array .= qq~"$tmpurl", ~;  
                   $tmpcode = $SmilieCode[$i];  
                   $tmpcode =~ s/\&quot;/"+'"'+"/g;    # "'   
                   &FromHTML($tmpcode);  
                   $tmpcode =~ s/&#36;/\$/g;  
                   $tmpcode =~ s/&#64;/\@/g;  
                   $smilie_code_array .= qq~" $tmpcode", ~;  
                   $i++;  
               }  
           }  
           if ($showsmdir eq 2) {  
               opendir(DIR, "$smiliesdir");  
               @contents = readdir(DIR);  
               closedir(DIR);  
               foreach $line (sort { uc($a) cmp uc($b) } @contents) {  
                   ($name, $extension) = split(/\./, $line);  
                   if ($extension =~ /gif/i || $extension =~ /jpg/i || $extension =~ /jpeg/i || $extension =~ /png/i) {  
                       if ($line !~ /banner/i) {  
                           $smilieslist .= qq~    document.write('<option value="$i"~ . ($name eq $showinbox ? ' selected="selected"' : '') . qq~>$name</option>');\n~;  
                           $smilie_url_array .= qq~"$smiliesurl/$line", ~;  
                           $smilie_code_array .= qq~" [smiley=$line]", ~;  
                           $i++;  
                       }  
                   }  
               }  
           }  
           $smilie_url_array  .= qq~""~;  
           $smilie_code_array .= qq~""~;  
   
           $yymain .= qq~  
           smilieurl = new Array($smilie_url_array)  
           smiliecode = new Array($smilie_code_array)  
           document.write('<table class="bordercolor" height="90" width="120" border="0" cellpadding="2" cellspacing="1" align="center"><tr>');  
           document.write('<td height="15" align="center" valign="middle" class="titlebg"><span class="small"><b>$post_smiltxt{'1'}</b></span></td>');  
           document.write('</tr><tr>');  
           document.write('<td height="20" align="center" valign="top" class="windowbg2"><select name="smiliextra_list" onchange="document.images.smiliextra_image.src= smilieurl[document.postmodify.smiliextra_list.value]" style="width:114px; font-size:7pt;">');  
           $smilieslist  
           document.write('</select></td>');  
           document.write('</tr><tr>');  
           document.write('<td height="70" align="center" valign="middle" class="windowbg2"><img name="smiliextra_image" src="'+smilieurl[0]+'" alt="" border="0" onclick="javascript: Smiliextra();" style="cursor: pointer;"></td>');  
           document.write('</tr><tr>');  
           document.write('<td height="15" align="center" valign="middle" class="windowbg2"><span class="small"><a href="javascript: smiliewin();">$post_smiltxt{'17'}</a></span></td>');  
           document.write('</tr></table>');  
           document.images.smiliextra_image.src = smilieurl[document.postmodify.smiliextra_list.value];  
           //-->  
           </script>  
           ~;  
       } else {  
           $yymain .= qq~  
           &nbsp;  
           ~;  
       }  
   
       $yymain .= qq~  
       </td>  
   </tr>  
   <tr>  
       <td class="windowbg2" width="23%" valign="bottom">  
           <span  class="small"><img name="feature_col" id="feature_col" src="$defaultimagesdir/cat_collapse.gif" alt="$npf_txt{'collapse_features'}" title="$npf_txt{'collapse_features'}" border="0" style="cursor:pointer;" onclick="show_features(0);" /> $npf_txt{'features_text'}</span>  
           <input type="hidden" name="col_row" id="col_row" value="$col_row" />~;  
   
       $yymain .= qq~  
       </td>  
       <td width="77%" valign="middle" class="windowbg2">  
           <script language="JavaScript1.2" type="text/javascript">  
           <!--  
           HAND = "style='cursor: pointer;'";  
           document.write("<div style='float: left; width: 440px;'>");  
           document.write("<img src='$imagesdir/smiley.gif' onclick='smiley();' "+HAND+" align='bottom' alt='$post_txt{'287'}' title='$post_txt{'287'}' border='0'> ");  
           document.write("<img src='$imagesdir/wink.gif' onclick='wink();' "+HAND+" align='bottom' alt='$post_txt{'292'}' title='$post_txt{'292'}' border='0'> ");  
           document.write("<img src='$imagesdir/cheesy.gif' onclick='cheesy();' "+HAND+" align='bottom' alt='$post_txt{'289'}' title='$post_txt{'289'}' border='0'> ");  
           document.write("<img src='$imagesdir/grin.gif' onclick='grin();' "+HAND+" align='bottom' alt='$post_txt{'293'}' title='$post_txt{'293'}' border='0'> ");  
           document.write("<img src='$imagesdir/angry.gif' onclick='angry();' "+HAND+" align='bottom' alt='$post_txt{'288'}' title='$post_txt{'288'}' border='0'> ");  
           document.write("<img src='$imagesdir/sad.gif' onclick='sad();' "+HAND+" align='bottom' alt='$post_txt{'291'}' title='$post_txt{'291'}' border='0'> ");  
           document.write("<img src='$imagesdir/shocked.gif' onclick='shocked();' "+HAND+" align='bottom' alt='$post_txt{'294'}' title='$post_txt{'294'}' border='0'> ");  
           document.write("<img src='$imagesdir/cool.gif' onclick='cool();' "+HAND+" align='bottom' alt='$post_txt{'295'}' title='$post_txt{'295'}' border='0'> ");  
           document.write("<img src='$imagesdir/huh.gif' onclick='huh();' "+HAND+" align='bottom' alt='$post_txt{'296'}' title='$post_txt{'296'}' border='0'> ");  
           document.write("<img src='$imagesdir/rolleyes.gif' onclick='rolleyes();' "+HAND+" align='bottom' alt='$post_txt{'450'}' title='$post_txt{'450'}' border='0'> ");  
           document.write("<img src='$imagesdir/tongue.gif' onclick='tongue();' "+HAND+" align='bottom' alt='$post_txt{'451'}' title='$post_txt{'451'}' border='0'> ");  
           document.write("<img src='$imagesdir/embarassed.gif' onclick='embarassed();' "+HAND+" align='bottom' alt='$post_txt{'526'}' title='$post_txt{'526'}' border='0'> ");  
           document.write("<img src='$imagesdir/lipsrsealed.gif' onclick='lipsrsealed();' "+HAND+" align='bottom' alt='$post_txt{'527'}' title='$post_txt{'527'}' border='0'> ");  
           document.write("<img src='$imagesdir/undecided.gif' onclick='undecided();' "+HAND+" align='bottom' alt='$post_txt{'528'}' title='$post_txt{'528'}' border='0'> ");  
           document.write("<img src='$imagesdir/kiss.gif' onclick='kiss();' "+HAND+" align='bottom' alt='$post_txt{'529'}' title='$post_txt{'529'}' border='0'> ");  
           document.write("<img src='$imagesdir/cry.gif' onclick='cry();' "+HAND+" align='bottom' alt='$post_txt{'530'}' title='$post_txt{'530'}' border='0'> ");$moresmilieslist  
           document.write("</div>");  
           //-->  
           </script>\n~ if !$removenormalsmilies;  
   
       if (($showadded == 3 && $showsmdir != 2) || ($showsmdir == 3 && $showadded != 2)) {  
           $yymain .= qq~  
       </td>  
       <td width="77%" valign="middle" class="windowbg2">~ if $removenormalsmilies;  
           $yymain .= qq~  
           <a href="javascript: smiliewin();">$post_smiltxt{'1'}</a>\n~;  
       }  
   
       $yymain .= qq~  
           <noscript>  
           <span class="small">$maintxt{'noscript'}</span>  
           </noscript>  
       </td>  
   </tr>~;  
   
       # File Attachment's Browse Box Code  
       if (&AccessCheck($currentboard, 4) eq 'granted' && $allowattach && ${$uid.$currentboard}{'attperms'} == 1 && -d "$uploaddir" && ($action eq 'post' || $action eq 'post2' || $action eq 'modify' || $action eq 'modify2') && (($allowguestattach == 0 && !$iamguest) || $allowguestattach == 1)) {  
           $mfn = $mfn || $FORM{'oldattach'};  
           my @files = split(/,/, $mfn);  
   
           $yymain .= qq~  
   <tr id="feature_status_5">  
       <td width="23%" align="left">  
           <b>$fatxt{'80'}</b>  
           <input type="hidden" name="oldattach" id="oldattach" value="$mfn" />~;  
   
           $yymain .= qq~  
           <img name="attform_add" id="attform_add" src="$defaultimagesdir/cat_expand.gif" alt="$fatxt{'80a'}" title="$fatxt{'80a'}" border="0" style="cursor:pointer;" onclick="enabPrev2(1);" />  
           <img name="attform_sub" id="attform_sub" src="$defaultimagesdir/cat_collapse.gif" alt="$fatxt{'80s'}" title="$fatxt{'80s'}" border="0" style="cursor:pointer; visibility:hidden;" onclick="enabPrev2(-1);" />~ if $allowattach > 1;  
   
           $yymain .= qq~  
       </td>  
       <td width="77%"><span class="small">$filetype_info<br />$filesize_info</span></td>  
   </tr>  
   <tr id="feature_status_6">  
       <td colspan="2">~;  
   
           my $startcount;  
           for (my $y = 1; $y <= $allowattach; $y++) {  
               if (($action eq 'modify' || $action eq 'modify2') && $files[$y-1] ne "" && -e "$uploaddir/$files[$y-1]") {  
                   $startcount++;  
                   $yymain .= qq~  
           <div id="attform_a_$y" style="float:left; width:23%;~ . ($y > 1 ? qq~ padding-top:5px~ : '') . qq~"><b>$fatxt{'6'} $y:</b></div>  
           <div id="attform_b_$y" style="float:left; width:76%;~ . ($y > 1 ? qq~ padding-top:5px~ : '') . qq~">  
               <input type="file" name="file$y" id="file$y" size="50" onchange="selectNewattach($y);" /><br />  
               <font size="1">  
               <input type="hidden" id="w_filename$y" name="w_filename$y" value="$files[$y-1]" />  
               <select id="w_file$y" name="w_file$y" size="1">  
               <option value="attachdel">$fatxt{'6c'}</option>  
               <option value="attachnew">$fatxt{'6b'}</option>  
               <option value="attachold" selected="selected">$fatxt{'6a'}</option>  
               </select>&nbsp;$fatxt{'40'}: <a href="$uploadurl/$files[$y-1]" target="_blank">$files[$y-1]</a>  
               </font>~;  
               } else {  
                   $yymain .= qq~  
           <div id="attform_a_$y" style="float:left; width:23%;~ . ($y > 1 ? qq~ visibility:hidden; height:0px~ : '') . qq~"><b>$fatxt{'6'} $y:</b></div>  
           <div id="attform_b_$y" style="float:left; width:76%;~ . ($y > 1 ? qq~ visibility:hidden; height:0px~ : '') . qq~">\n                <input type="file" name="file$y" id="file$y" size="50" />~;  
               }  
               $yymain .= qq~\n            </div>\n~;  
   
               $is_preview = 2 if $is_preview == 1 && $CGI_query->upload("file$y");  
           }  
           $startcount = 1 if !$startcount;  
   
           $yymain .= qq~  
           <script language="JavaScript1.2" type="text/javascript">  
           <!--  
           var countattach = $startcount;~ . ($startcount > 1 ? qq~\n            document.getElementById("attform_sub").style.visibility = "visible";~ : '') . qq~  
           function enabPrev2(add_sub) {  
               if (add_sub == 1) {  
                   countattach = countattach + add_sub;  
                   document.getElementById("attform_a_" + countattach).style.visibility = "visible";  
                   document.getElementById("attform_a_" + countattach).style.height = "auto";  
                   document.getElementById("attform_a_" + countattach).style.paddingTop = "5px";  
                   document.getElementById("attform_b_" + countattach).style.visibility = "visible";  
                   document.getElementById("attform_b_" + countattach).style.height = "auto";  
                   document.getElementById("attform_b_" + countattach).style.paddingTop = "5px";  
               } else {  
                   document.getElementById("attform_a_" + countattach).style.visibility = "hidden";  
                   document.getElementById("attform_a_" + countattach).style.height = "0px";  
                   document.getElementById("attform_a_" + countattach).style.paddingTop = "0px";  
                   document.getElementById("attform_b_" + countattach).style.visibility = "hidden";  
                   document.getElementById("attform_b_" + countattach).style.height = "0px";  
                   document.getElementById("attform_b_" + countattach).style.paddingTop = "0px";  
                   countattach = countattach + add_sub;  
               }  
               if (countattach > 1) {  
                   document.getElementById("attform_sub").style.visibility = "visible";  
               } else {  
                   document.getElementById("attform_sub").style.visibility = "hidden";  
               }  
               if ($allowattach <= countattach) {  
                   document.getElementById("attform_add").style.visibility = "hidden";  
               } else {  
                   document.getElementById("attform_add").style.visibility = "visible";  
               }  
           }  
           //-->  
           </script>~ if $allowattach > 1;  
   
           $yymain .= qq~  
       </td>  
   </tr>~;  
   
           if ($is_preview == 2) {  
               $is_preview = 1;  
               $yymain .= qq~  
   <tr>  
       <td colspan="2" style="color:red;"><br /><b>$fatxt{'7'}</b><br /><br /></td>  
   </tr>~;  
           }  
       }  
       # /File Attachment's Browse Box Code  
   
       $yymain .= qq~  
$notification  
$favoriteadd  
   <tr id="feature_status_7">  
       <td class="windowbg" width="23%">  
           <label for="ns"><b>$post_txt{'276'}:</b></label>  
       </td>  
       <td class="windowbg" width="77%">  
           <input type="checkbox" name="ns" id="ns" value="NS"$nscheck /> <span class="small"> <label for="ns">$post_txt{'277'}</label></span>  
       </td>  
   </tr>  
   
   <tr id="feature_status_8">  
       <td class="windowbg" width="23%">  
           <div id="enable_iecopytext" style="display: none;">  
               <label for="iecopy"><b>$post_txt{'iecopytext'}:</b></label><br /><br />  
           </div>  
       </td>  
       <td class="windowbg" width="77%">  
           <div id="enable_iecopy" style="display: none;">  
               <input type="checkbox" name="iecopy" id="iecopy"$iecopycheck /> <span class="small"> <label for="iecopy">$post_txt{'iecopycheck'}</label></span><br /><br />  
           </div>  
       </td>  
   </tr>  
   
$lastmod     $iammod = 0; 
     if ( keys(%moderators) > 0 ) {
         while ( $_ = each %moderators ) {
             if ( $username eq $_ ) { $iammod = 1; }
         }
     }
     if ( keys(%moderatorgroups) > 0 ) {
         while ( $_ = each %moderatorgroups ) {
             if ( ${ $uid . $username }{'position'} eq $_ ) { $iammod = 1; }
             foreach my $memberaddgroups ( split /,/xsm,
                 ${ $uid . $username }{'addgroups'} )
             {
                 if ( $memberaddgroups eq $_ ) { $iammod = 1; last; }
             }
         }
     }
   
     if (   $threadid
         && ( !$Quick_Post )
         && $postthread == 2
         && $username ne 'Guest' )
     {
         my ( $reptime, $repuser, $isreplying, @tmprepliers, $isrep,
             $template_viewers, $topviewers );
         chomp @repliers;
         for my $i ( 0 .. $#repliers ) {
             ( $reptime, $repuser, $isreplying ) = split /\|/xsm, $repliers[$i];
             next if ( $date - $reptime ) > 600;
             if ( $repuser eq $username ) {
                 push @tmprepliers, qq~$date|$repuser|1~;
                 $isrep      = 1;
                 $isreplying = 1;
             }
             else { push @tmprepliers, $repliers[$i]; }
             if ($isreplying) {
                 LoadUser($repuser);
                 $template_viewers .= qq~$link{$repuser}, ~;
                 $topviewers++;
             }
         }
         if ( !$isrep ) {
             push @tmprepliers, qq~$date|$username|1~;
             $template_viewers .= qq~$link{$username}, ~;
             $topviewers++;
         }
         MessageTotals( 'load', $curnum );
         @repliers = @tmprepliers;
         MessageTotals( 'update', $curnum );
   
         if (   $showtopicrepliers
             && $template_viewers
             && ( $staff && $sessionvalid == 1 ) )
         {
             $template_viewers =~ s/\, \Z/\./sm;
             $my_tview = $mypost_topview;
             $my_tview =~ s/{yabb topviewers}/$topviewers/sm;
             $my_tview =~ s/{yabb template_viewers}/$template_viewers/sm;
         }
     }
   
     if ($pollthread) {
         $maxpq          ||= 60;
         $maxpo          ||= 50;
         $maxpc          ||= 0;
         $numpolloptions ||= 8;
         $vote_limit     ||= 0;
         $pie_radius     ||= 100;
   
         if ( ( $iamadmin || $iamgmod ) && -e "$datadir/showcase.poll" ) {
             fopen( FILE, "$datadir/showcase.poll" );
             if ( $threadid == <FILE> ) { $scchecked = ' checked="checked"'; }
             fclose(FILE);
         }
         if ($guest_vote)   { $gvchecked  = ' checked="checked"'; }
         if ($hide_results) { $hrchecked  = ' checked="checked"'; }
         if ($multi_choice) { $mcchecked  = ' checked="checked"'; }
         if ($pie_legends)  { $legchecked = ' checked="checked"'; }
   
         $piecolarray = q~["",~;
         for my $i ( 1 .. $numpolloptions ) {
             if ( $split[$i] ) { $splitchecked[$i] = ' checked="checked"'; }
             if ( $FORM{"slicecol$i"} ) {
                 $slicecolor[$i] = $FORM{"slicecol$i"} || 'transparent';
             }
             $mypoll_opt .= $my_poll_options;
             $mypoll_opt =~ s/{yabb i}/$i/gsm;
             $mypoll_opt =~ s/{yabb maxpo}/$maxpo/gsm;
             $mypoll_opt =~ s/{yabb options_i}/$options[$i]/gsm;
             $mypoll_opt =~ s/{yabb slicecolor_i}/$slicecolor[$i]/gsm;
             $mypoll_opt =~ s/{yabb splitchecked_i}/$splitchecked[$i]/sm;
             $piecolarray .= qq~"$slicecolor[$i]", ~;
         }
         $piecolarray =~ s/\, $//ism;
         $piecolarray .= q~]~;
   
         if ( $maxpc > 0 ) {
             $my_maxpc = $my_poll_comment;
             $my_maxpc .=
  qq~            <textarea name="poll_comment" rows="3" cols="60" wrap="soft" onkeyup="if (document.postmodify.poll_comment.value.length > {yabb maxpc}) {document.postmodify.poll_comment.value = document.postmodify.poll_comment.value.substring(0,$maxpc)}">$poll_comment</textarea>
~; ~;
   }             $my_maxpc .= $my_poll_comment_b; 
         }
   
   #these are the buttons to submit         if ($poll_end) { 
   if ($is_preview) { $post_txt{'507'} = $post_txt{'771'}; }             my $x = $poll_end - $date; 
   $yymain .= qq~             if ( $x <= 0 ) { 
   <tr>                 $poll_end_min = 1; 
       <td align="center" class="titlebg" colspan="2">             } 
           $hidestatus             else { 
           <br />                 $poll_end_days = int( $x / 86400 ); 
           <input type="submit" name="$post" id="$post" value="$submittxt" accesskey="s" tabindex="5" class="button" />~ . ($postid ne 'Poll' ? qq~&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" id="$preview" name="$preview" value="$post_txt{'507'}" accesskey="p" tabindex="6" class="button" />~ : '') . qq~                 $poll_end_min = 
           <script language="JavaScript1.2" type="text/javascript">                   int( ( $x - ( $poll_end_days * 86400 ) ) / 60 ); 
           <!--             } 
           if (/Opera/.test(navigator.userAgent) == false) {         } 
               if (/mac/i.test(navigator.platform)) {  
                   document.write("<br /><span class='small'>~ . ($postid ne 'Poll' ? $post_txt{'331'} : $post_txt{'331a'}) . qq~</span>");         $my_pie = $mypost_poll_pie; 
               } else if (/MSIE [7-9]/.test(navigator.userAgent) || /\\/[3-9]\\.\\d+\\.\\d+ Safari/.test(navigator.userAgent)) {         $my_pie .= 
                   document.write("<br /><span class='small'>~ . ($postid ne 'Poll' ? $post_txt{'329'} : $post_txt{'329a'}) . qq~</span>");           $poll_locked 
               } else if (/Firefox\\/[2-9]/.test(navigator.userAgent) || /Chrome/.test(navigator.userAgent)) {           ? q{} 
                   document.write("<br /><span class='small'>~ . ($postid ne 'Poll' ? $post_txt{'330'} : $post_txt{'330a'}) . qq~</span>");           : $my_poll_end; 
               }         $my_pie .= 
           }\n~;           ( $iamadmin || $iamgmod ) 
           ? $my_poll_sc
   if ($speedpostdetection){           : q{}; 
       $yymain .= qq~         $my_pie .= $my_poll_hide; 
           var postdelay = $min_post_speed*1000;  
           document.postmodify.$post.value='$post_txt{"delay"}';         $my_pie =~ s/{yabb piecolarray}/$piecolarray/sm; 
           document.postmodify.$post.disabled=true;         $my_pie =~ s/{yabb poll_end_days}/$poll_end_days/sm; 
           document.postmodify.$post.style.cursor='default';         $my_pie =~ s/{yabb poll_end_min}/$poll_end_min/sm; 
           var delay = window.setInterval('releasepost()',postdelay );         $my_pie =~ s/{yabb scchecked}/$scchecked/sm; 
           function releasepost() {         $my_pie =~ s/{yabb gvchecked}/$gvchecked/sm; 
               document.postmodify.$post.value='$submittxt';         $my_pie =~ s/{yabb hrchecked}/$hrchecked/sm; 
               document.postmodify.$post.disabled=false;         $my_pie =~ s/{yabb mcchecked}/$mcchecked/sm; 
               document.postmodify.$post.style.cursor='pointer';         $my_pie =~ s/{yabb vote_limit}/$vote_limit/sm; 
               window.clearInterval(delay);         $my_pie =~ s/{yabb legchecked}/$legchecked/sm; 
           }\n~;         $my_pie =~ s/{yabb pie_radius}/$pie_radius/sm; 
   }  
         $my_pollsection = $mypost_poll_top;
   $yyinlinestyle .= qq~<script type="text/javascript" src="$yyhtml_root/googiespell/cookiesupport.js"></script>~ unless $yyinlinestyle =~ /cookiesupport\.js/;         $my_pollsection =~ s/{yabb poll_question}/$poll_question/sm; 
   $yymain .= qq~         $my_pollsection =~ s/{yabb maxpq}/$maxpq/sm; 
           //-->         $my_pollsection =~ s/{yabb pollthread}/$pollthread/sm; 
           </script>         $my_pollsection =~ s/{yabb mypoll_opt}/$mypoll_opt/sm; 
           <br /><br />         $my_pollsection =~ s/{yabb my_maxpc}/$my_maxpc/sm; 
       </td>         $my_pollsection =~ s/{yabb my_pie}/$my_pie/sm; 
   </tr>     } 
</table>  
</div>     if ( $postid ne 'Poll' ) { 
</form>         $css = isempty( $css, 'windowbg' ); 
         if ( $tmpmusername eq 'Guest' ) {
             $liveusernamelink      = qq~<b>$mename</b>~;
             $livememberinfo        = "$maintxt{'28'}";
             $livememberstar        = q{};
             $livetemplate_postinfo = q{};
             $tmplastmodified       = q{};
             $liveuserlocation      = q{};
         }
         else {
             if ( !${ $uid . $tmpmusername }{'password'} ) {
                 LoadUser($tmpmusername);
             }
             if ( $tmpmusername eq $username ) { LoadMiniUser($tmpmusername); }
             if ( !$yyUDLoaded{$tmpmusername}
                 && -e ("$memberdir/$tmpmusername.vars") )
             {
                 my $tmpmess = $message;
                 LoadUserDisplay($tmpmusername);
                 $message = $tmpmess;
             }
             $liveusernamelink = $format{$tmpmusername};
             $livememberinfo =
               "$memberinfo{$tmpmusername}$addmembergroup{$tmpmusername}";
             $livememberstar = $memberstar{$tmpmusername};
   
             $livepostcount =
               NumberFormat( ${ $uid . $tmpmusername }{'postcount'} );
             $livetemplate_postinfo =
               qq~$display_txt{'21'}: $livepostcount<br />~;
             if (   ${ $uid . $tmpmusername }{'bday'}
                 && $showuserage
                 && ( !$showage || !${ $uid . $tmpmusername }{'hideage'} ) )
             {
                 CalcAge( $tmpmusername, 'calc' );
                 $liveuser_age = qq~$display_txt{'age'}: $age<br />~;
             }
             if ( $showregdate && ${ $uid . $tmpmusername }{'regtime'} ) {
                 $dr_regdate =
                   timeformat( ${ $uid . $tmpmusername }{'regtime'} );
                 $dr_regdate = dtonly($dr_regdate);
                 $dr_regdate =~ s/(.*)(, 1?[0-9]):[0-9][0-9].*/$1/xsm;
                 $liveuser_regdate =
                   qq~$display_txt{'regdate'} $dr_regdate<br />~;
             }
             if ( ${ $uid . $tmpmusername }{'location'} ) {
                 $liveuserlocation =
                     qq~$display_txt{'location'}:~
                   . ${ $uid . $tmpmusername }{'location'}
                   . '<br />';
             }
             if ( $action eq 'modify' ) {
                 if (
                     $showmodify
                     && ( !$tllastmodflag
                         || ( $tmpmdate + ( $tllastmodtime * 60 ) ) < $date )
                   )
                 {
                     $tmplastmodified =
  qq~<div class="small" style="float: right; width: 100%; text-align: right; margin-top: 5px;">&laquo; <i>$display_txt{'211'}: ~
                       . timeformat($date,0,0,0,1)
                       . qq~ $display_txt{'525'} ${$uid.$username}{'realname'}</i> &raquo; &nbsp;</div>~;
                 }
             }
             else {
                 $subjdate        = timeformat($date);
                 $tmplastmodified = q{};
             }
             if ( ${ $uid . $tmpmusername }{'signature'} ) {
                 $livesignature_hr = q~<hr class="hr att_hr" />~;
             }
         }
         $liveipimg = qq~<img src="$micon_bg{'ip'}" alt="" />~;
         $livemip   = $display_txt{'511'};
   
         $livemsgimg = qq~<img src="$micon_bg{$icon}" id="liveicons" alt="" />~;
         get_template('Post');
   
         FromHTML($moddate);
         $messageblock = $mypost_liveprev;
         $messageblock =~ s/{yabb images}/$imagesdir/gsm;
         $messageblock =~ s/{yabb css}/$css/gsm;
         $messageblock =~
  s/{yabb userlink}/<span id="savename" style="font-weight: bold">$liveusernamelink<\/span>/gsm;
         $messageblock =~ s/{yabb memberinfo}/$livememberinfo/gsm;
         $messageblock =~ s/{yabb stars}/$livememberstar/gsm;
         $messageblock =~ s/{yabb location}/$liveuserlocation/gsm;
         $messageblock =~
           s/{yabb gender}/${$uid.$tmpmusername}{'gender'}/gsm;
         $messageblock =~
           s/{yabb usertext}/${$uid.$tmpmusername}{'usertext'}/gsm;
         $messageblock =~
           s/{yabb userpic}/${$uid.$tmpmusername}{'userpic'}/gsm;
         $messageblock =~ s/{yabb postinfo}/$livetemplate_postinfo/gsm;
         $messageblock =~ s/{yabb msgdate}/$moddate/gsm;
         $messageblock =~ s/{yabb msgimg}/$livemsgimg/gsm;
         $messageblock =~ s/{yabb age}/$liveuser_age/gsm;
         $messageblock =~ s/{yabb regdate}/$liveuser_regdate/gsm;
         $messageblock =~
           s/{yabb subject}/<span id="savesubj"><\/span>/gsm;
         $messageblock =~
           s/{yabb message}/<span id="savemess"><\/span>/gsm;
         $messageblock =~ s/{yabb modified}/$tmplastmodified/gsm;
         $messageblock =~ s/{yabb ipimg}/$liveipimg/gsm;
         $messageblock =~ s/{yabb ip}/$livemip/gsm;
         $messageblock =~
           s/{yabb signature}/${$uid.$tmpmusername}{'signature'}/gsm;
         $messageblock =~ s/{yabb signaturehr}/$livesignature_hr/gsm;
         $messageblock =~ s/{yabb (.+?)}//gsm;
   
         if ( !$minlinkpost ) { $minlinkpost = 0; }
   
         if ( ( $iamguest && $minlinkpost > 0 )
             || ${ $uid . $username }{'postcount'} < $minlinkpost
             && !$iamadmin
             && !$iamgmod
             && !$iammod )
         {
             $nolinkallow = 1;
         }
   
         $my_postsection_ajx = my_check_prev();
   
         $topicstatus_row = q{};
         $stselect        = q{};
         $lcselect        = q{};
         $hdselect        = q{};
         $threadclass     = 'thread';
   
         (
             $mnum,     $msub,      $mname, $memail, $mdate,
             $mreplies, $musername, $micon, $mstate
         ) = split /\|/xsm, $yyThreadLine;
         if   ( $FORM{'topicstatus'} ) { $thestatus = $FORM{'topicstatus'}; }
         else                          { $thestatus = $mstate; }
         if ( $currentboard eq $annboard ) {
             $threadclass = 'announcement';
         }
         else {
             if ( $mreplies >= $VeryHotTopic ) {
                 $threadclass = 'veryhotthread';
             }
             elsif ( $mreplies >= $HotTopic ) { $threadclass = 'hotthread'; }
         }
         if ( $action ne 'modalert' ) {
             if ( $thestatus =~ /s/sm ) { $stselect = q~selected="selected"~; }
             if ( $thestatus =~ /l/sm ) { $lcselect = q~selected="selected"~; }
             if ( $thestatus =~ /h/sm ) { $hdselect = q~selected="selected"~; }
             $hidestatus = q{};
   
             if ( $staff && $sessionvalid == 1 ) {
                 $my_curbrd = $currentboard ne $annboard ? 3 : 2;
                 $my_stselect =
                   $currentboard ne $annboard
                   ? qq~<option value="s" $stselect>$post_txt{'35'}</option>~
                   : q{};
                 $my_t_status = $mypost_topicstatus;
                 $my_t_status =~ s/{yabb my_curbrd}/$my_curbrd/sm;
                 $my_t_status =~ s/{yabb my_stselect}/$my_stselect/sm;
                 $my_t_status =~ s/{yabb lcselect}/$lcselect/sm;
                 $my_t_status =~ s/{yabb hdselect}/$hdselect/sm;
                 $my_t_status =~ s/{yabb threadclass}/$threadclass/sm;
                 $my_t_status =~
                   s/{yabb threadclass_img}/$micon_bg{$threadclass}/sm;
             }
             else {
                 $hidestatus =
  qq~<input type="hidden" value="$thestatus" name="topicstatus" />~;
             }
         }
         $my_submax = $set_subjectMaxLength + ( $sub =~ /^Re: /sm ? 4 : 0 );
   
         if (   $post ne 'imsend' 
             && $postid ne 'Poll' 
             && ( $action eq 'modify' || $action eq 'modify2' )
             && ( ( $staff && $staff_reason ) || $user_reason ) )
         {
             $my_reason = $mypost_reason;
             $my_reason =~ s/{yabb reason}/$reason/sm;
         }
   
         $my_rem_smilies =
           (      !$removenormalsmilies
               || ( $showadded == 3 && $showsmdir != 2 )
               || ( $showsmdir == 3 && $showadded != 2 ) ) ? 2 : 3;
   
         if ( $enable_ubbc && $showyabbcbutt ) {
             $my_ubbc = postbox();
         }
   
         # SpellChecker start
         if ($enable_spell_check) {
             $yyinlinestyle .= googiea();
             $userdefaultlang = ( split /-/xsm, $abbr_lang )[0];
             $userdefaultlang ||= 'en';
             $my_googie = googie($userdefaultlang);
         }
   
         # SpellChecker end
   
         if ( $showadded == 2 || $showsmdir == 2 ) {
             $mypost_smilie_array_top = q~
             <script type="text/javascript">
             function Smiliextra() {
                 AddTxt=smiliecode[document.postmodify.smiliextra_list.value];
                 AddText(AddTxt);
             }
             </script>~;
   
             $smilieslist       = q{};
             $smilie_url_array  = q{};
             $smilie_code_array = q{};
             $i                 = 0;
             if ( $showadded == 2 ) {
                 while ( $SmilieURL[$i] ) {
                     $smilieslist .= qq~ <option value="$i"~
                       . (
                         $SmilieDescription[$i] eq $showinbox
                         ? ' selected="selected"' 
                         : q{}
                       ) . qq~>$SmilieDescription[$i]</option>\n~;
                     if ( $SmilieURL[$i] =~ /\//ism ) {
                         $tmpurl = $SmilieURL[$i];
                     }
                     else { $tmpurl = qq~$defaultimagesdir/$SmilieURL[$i]~; }
                     $smilie_url_array .= qq~"$tmpurl", ~;
                     $tmpcode = $SmilieCode[$i];
                     $tmpcode =~ s/\&quot;/\x22/gxsm;
                     FromHTML($tmpcode);
                     $tmpcode =~ s/&\x2336;/\$/gxsm;
                     $tmpcode =~ s/&\x2364;/\@/gxsm;
                     $smilie_code_array .= qq~" $tmpcode", ~;
                     $i++;
                 }
             }
             if ( $showsmdir == 2 ) {
                 opendir DIR, "$htmldir/Smilies";
                 @contents = readdir DIR;
                 closedir DIR;
                 foreach my $line ( sort { uc($a) cmp uc $b } @contents ) {
                     ( $name, $extension ) = split /\./xsm, $line;
                     if (   $extension =~ /gif/ism
                         || $extension =~ /jpg/ism
                         || $extension =~ /jpeg/ism
                         || $extension =~ /png/ism )
                     {
                         if ( $line !~ /banner/ism ) {
                             $smilieslist .=
                               qq~   <option value="$i"~
                               . (
                                 $name eq $showinbox
                                 ? ' selected="selected"' 
                                 : q{}
                               ) . qq~>$name</option>\n~;
                             $smilie_url_array .=
                               qq~"$yyhtml_root/Smilies/$line", ~;
                             $smilie_code_array .= qq~" [smiley=$line]", ~;
                             $i++;
                         }
                     }
                 }
             }
             $smilie_url_array  .= q~""~;
             $smilie_code_array .= q~""~;
   
             $mypost_smilie_array = qq~
             $mypost_smilie_array_top
             <script type="text/javascript">
             smilieurl = new Array($smilie_url_array);
             smiliecode = new Array($smilie_code_array);
             </script>
             $mypost_smiley1
             ~;
             $mypost_smilie_array =~ s/{yabb smilieslist}/$smilieslist/sm;
         }
         else {
             $mypost_smilie_array .= q~
             &nbsp;
             ~;
         }
   
         $my_post_feata = $mypost_feata;
         $my_post_feata .= qq~
             <span class="small"><img src="$imagesdir/$newload{'brd_col'}" id="feature_col" alt="$npf_txt{'collapse_features'}" title="$npf_txt{'collapse_features'}" class="cursor" onclick="show_features(0);" /> $npf_txt{'features_text'}</span>~;
   
         if (
             !$removenormalsmilies
             && (   !${ $uid . $username }{'hide_smilies_row'}
                 || !$user_hide_smilies_row )
           )
         {
             $my_smilies = $mypost_smilies;
             $my_smilies .= smilies_list();
         }
         else {
             $my_smilies = qq~$mypost_smilies &nbsp; ~;
         }
   
         if (   ( $showadded == 3 && $showsmdir != 2 )
             || ( $showsmdir == 3 && $showadded != 2 ) )
         {
             if ($removenormalsmilies) {
                 $my_smilies = $mypost_smilies;
             }
             $my_smilies .=
               qq~<a href="javascript: smiliewin();">$post_smiltxt{'1'}</a>\n~;
         }
   
         $my_post_smilies .= $mypost_smilies_c;
         $my_post_smilies =~ s/{yabb my_smilies}/$my_smilies/sm;
   
         # File Attachment's Browse Box Code
         $allowattach ||= 0;
         if (
                AccessCheck( $currentboard, 4 ) eq 'granted' 
             && $allowattach > 0
             && ${ $uid . $currentboard }{'attperms'} == 1
             && -d "$uploaddir" 
             && (   $action eq 'post' 
                 || $action eq 'post2' 
                 || $action eq 'modify' 
                 || $action eq 'modify2' )
             && ( ( $allowguestattach == 0 && !$iamguest )
                 || $allowguestattach == 1 )
           )
         {
             $mfn = $mfn || $FORM{'oldattach'};
             my @files = split /,/xsm, $mfn;
   
             if ( $allowattach > 1 ) {
                 $my_att_allow = qq~
             <img src="$imagesdir/$newload{'brd_exp'}" id="attform_add" alt="$fatxt{'80a'}" title="$fatxt{'80a'}" class="cursor" onclick="enabPrev2(1);" />
             <img src="$imagesdir/$newload{'brd_col'}" id="attform_sub" alt="$fatxt{'80s'}" title="$fatxt{'80s'}" class="cursor" style="visibility:hidden;" onclick="enabPrev2(-1);" />~;
             }
   
             my $startcount;
             for my $y ( 1 .. $allowattach ) {
                 if (   ( $action eq 'modify' || $action eq 'modify2' )
                     && $files[ $y - 1 ] ne q{}
                     && -e "$uploaddir/$files[$y-1]" )
                 {
                     $startcount++;
                     $my_att_a = qq~
             <div id="attform_a_$y" class="att_lft~
                       . ( $y > 1 ? q~_b~ : q{} )
                       . qq~"><b>$fatxt{'6'} $y:</b></div>
             <div id="attform_b_$y" class="att_rgt~
                       . ( $y > 1 ? q~_b~ : q{} ) . qq~">
                 <input type="file" name="file$y" id="file$y" size="50" onchange="selectNewattach($y);" /> <span class="cursor small bold" title="$fatxt{'81'}" onclick="document.getElementById('file$y').value='';">X</span><br />
                     <span style="font-size:x-small">
                         <input type="hidden" id="w_filename$y" name="w_filename$y" value="$files[$y-1]" />
                         <select id="w_file$y" name="w_file$y" size="1">
                         <option value="attachdel">$fatxt{'6c'}</option>
                         <option value="attachnew">$fatxt{'6b'}</option>
                         <option value="attachold" selected="selected">$fatxt{'6a'}</option>
                         </select>&nbsp;$fatxt{'40'}: <a href="$uploadurl/$files[$y-1]" target="_blank">$files[$y-1]</a>
                     </span></div>~;
                 }
                 else {
                     $my_att_a = qq~
             <div id="attform_a_$y" class="att_lft"~
                       . (
                         $y > 1
                         ? q~ style="visibility:hidden; height:0px"~
                         : q{}
                       )
                       . qq~><b>$fatxt{'6'} $y:</b></div>
             <div id="attform_b_$y" class="att_rgt"~
                       . (
                         $y > 1
                         ? q~ style="visibility:hidden; height:0px"~
                         : q{}
                       )
                       . qq~>\n             <input type="file" name="file$y" id="file$y" size="50" /> <span class="cursor small bold" title="$fatxt{'81'}" onclick="document.getElementById('file$y').value='';">X</span></div>~;
                 }
                 $mypoll_att .= $my_att_a;
   
             }
             if ( !$startcount ) { $startcount = 1; }
   
             if ( $allowattach > 1 ) {
                 $my_att_b = qq~
             <script type="text/javascript">
             var countattach = $startcount;~
                   . (
                     $startcount > 1
                     ? qq~\n         document.getElementById("attform_sub").style.visibility = "visible";~
                     : q{}
                   )
                   . qq~
             function enabPrev2(add_sub) {
                 if (add_sub == 1) {
                     countattach = countattach + add_sub;
                     document.getElementById("attform_a_" + countattach).style.visibility = "visible";
                     document.getElementById("attform_a_" + countattach).style.height = "auto";
                     document.getElementById("attform_a_" + countattach).style.paddingTop = "5px";
                     document.getElementById("attform_b_" + countattach).style.visibility = "visible";
                     document.getElementById("attform_b_" + countattach).style.height = "auto";
                     document.getElementById("attform_b_" + countattach).style.paddingTop = "5px";
                 } else {
                     document.getElementById("attform_a_" + countattach).style.visibility = "hidden";
                     document.getElementById("attform_a_" + countattach).style.height = "0px";
                     document.getElementById("attform_a_" + countattach).style.paddingTop = "0px";
                     document.getElementById("attform_b_" + countattach).style.visibility = "hidden";
                     document.getElementById("attform_b_" + countattach).style.height = "0px";
                     document.getElementById("attform_b_" + countattach).style.paddingTop = "0px";
                     countattach = countattach + add_sub;
                 }
                 if (countattach > 1) {
                     document.getElementById("attform_sub").style.visibility = "visible";
                 } else {
                     document.getElementById("attform_sub").style.visibility = "hidden";
                 }
                 if ($allowattach <= countattach) {
                     document.getElementById("attform_add").style.visibility = "hidden";
                 } else {
                     document.getElementById("attform_add").style.visibility = "visible";
                 }
             }
             </script>~;
             }
             $my_feat5 = $mypost_feat5;
             $my_feat5 =~ s/{yabb mfn}/$mfn/sm;
             $my_feat5 =~ s/{yabb my_att_mfn}/$my_att_mfn/sm;
             $my_feat5 =~ s/{yabb my_att_allow}/$my_att_allow/sm;
             $my_feat5 =~ s/{yabb filetype_info}/$filetype_info/sm;
             $my_feat5 =~ s/{yabb filesize_info}/$filesize_info/sm;
             $my_feat5 =~ s/{yabb mypoll_att}/$mypoll_att/sm;
             $my_feat5 =~ s/{yabb my_att_b}/$my_att_b/sm;
   
         }
   
         # /File Attachment's Browse Box Code
   
         ### Return To start ###
         my ($return_to);
         my $rts =
             $FORM{'return_to'}
           ? $FORM{'return_to'}
           : ${ $uid . $username }{'return_to'};
         for my $rt ( 1 .. 3 ) {
             $return_to_select .=
               $rts == $rt
               ? qq~<option value="$rt" selected="selected">$return_to_txt{$rt}</option>~
               : qq~<option value="$rt">$return_to_txt{$rt}</option>~;
         }
         if ( $destination ne 'modalert2' && $destination ne 'guestpm2' ) {
             $return_to = $mypost_return_to;
             $return_to =~ s/{yabb return_to_select}/$return_to_select/sm;
         }
         ### Return To modify end ###
         $guestpost_col = $my_guestpost_col;
         if ( $iamguest ) { $guestpost_col = $my_guestpost_col + 2; }
         $my_postsec_b   = postbox2();
         $my_postsection = $mypost_postblock;
         $my_postsection =~ s/{yabb my_postsection_ajx}/$my_postsection_ajx/sm;
         $my_postsection =~ s/{yabb messageblock}/$messageblock/sm;
         $my_postsection =~ s/{yabb my_t_status}/$my_t_status/sm;
         $my_postsection =~ s/{yabb extra}/$extra/sm;
         $my_postsection =~ s/{yabb name_field}/$guestpost_fields/sm;
         $my_postsection =~ s/{yabb email_field}/$email_field/sm;
         $my_postsection =~ s/{yabb verification_field}/$verification_field/sm;
         $my_postsection =~ s/{yabb guestcol}/$guestpost_col/gsm;
         $my_postsection =~ s/{yabb verification_question_field}/$verification_question_field/sm;
         $my_postsection =~ s/{yabb sub}/$sub/sm;
         $my_postsection =~ s/{yabb my_submax}/$my_submax/sm;
         $my_postsection =~ s/{yabb myreason}/$my_reason/sm;
         $my_postsection =~ s/{yabb my_rem_smilies}/$my_rem_smilies/sm;
         $my_postsection =~ s/{yabb my_ubbc}/$my_ubbc/sm;
         $my_postsection =~ s/{yabb my_postsec_b}/$my_postsec_b/sm;
         $my_postsection =~ s/{yabb my_googie}/$my_googie/sm;
         $my_postsection =~ s/{yabb mypost_smilie_array}/$mypost_smilie_array/sm;
         $my_postsection =~ s/{yabb my_post_feata}/$my_post_feata/sm;
         $my_postsection =~ s/{yabb my_post_smilies}/$my_post_smilies/sm;
         $my_postsection =~ s/{yabb my_feat5}/$my_feat5/sm;
         $my_postsection =~ s/{yabb my_is_prev}/$my_is_prev/sm;
         $my_postsection =~ s/{yabb notification}/$notification/sm;
         $my_postsection =~ s/{yabb favoriteadd}/$favoriteadd/sm;
         $my_postsection =~ s/{yabb lastmod}/$lastmod/sm;
         $my_postsection =~ s/{yabb nscheck}/$nscheck/sm;
         $my_postsection =~ s/{yabb return_to}/$return_to/sm;
     }
   
     #    these are the buttons to submit
     $my_post_submit = qq~$mypost_submit
             $hidestatus
             <input type="submit" name="$post" id="$post" value="$submittxt" accesskey="s" tabindex="5" class="button" />
             <script type="text/javascript">
~; ~;
   
   if($postid ne 'Poll') {    if ($speedpostdetection) {
       $yymain .= qq~         $my_spdpost = speedpost(); 
<script type="text/javascript" language="JavaScript1.2">     } 
<!--  
     if ( !$yyinlinestyle =~ /cookiesupport\.js/xsm ) {
var oldwidth = parseInt(document.getElementById('message').style.width) - $jsdragwpos;         $yyinlinestyle .= 
var olddragwidth = parseInt(document.getElementById('dragbgh').style.width) - $jsdragwpos;  qq~<script type="text/javascript" src="$yyhtml_root/googiespell/cookiesupport.js"></script>~; 
var oldheight = parseInt(document.getElementById('message').style.height) - $jsdraghpos;     } 
var olddragheight = parseInt(document.getElementById('dragbgw').style.height) - $jsdraghpos;  
     if (   $postid ne 'Poll' 
var skydobject={         && $post ne 'imsend' 
x: 0, y: 0, temp2 : null, temp3 : null, targetobj : null, skydNu : 0, delEnh : 0,         && $staff 
         && $sessionvalid == 1 )
initialize:function() {    {
   document.onmousedown = this.skydeKnap         $my_tclass = qq~ 
   document.onmouseup=function(){  <script type="text/javascript"> 
       this.skydNu = 0;  
       document.getElementById('messagewidth').value = parseInt(document.getElementById('message').style.width);  
       document.getElementById('messageheight').value = parseInt(document.getElementById('message').style.height);  
   }  
},  
changeSize:function(deleEnh, knapId) {  
   if (knapId == "dragImg1") {  
       newwidth = oldwidth+parseInt(deleEnh);  
       newdragwidth = olddragwidth+parseInt(deleEnh);  
       document.getElementById('message').style.width = newwidth+'px';  
       document.getElementById('dragbgh').style.width = newdragwidth+'px';  
       document.getElementById('dragImg2').style.width = newdragwidth+'px';  
   }  
   if (knapId == "dragImg2") {  
       newheight = oldheight+parseInt(deleEnh);  
       newdragheight = olddragheight+parseInt(deleEnh);  
       document.getElementById('message').style.height = newheight+'px';  
       document.getElementById('dragbgw').style.height = newdragheight+'px';  
       document.getElementById('dragImg1').style.height = newdragheight+'px';  
       document.getElementById('dragcanvas').style.height = newdragheight+'px';  
   
   }  
},  
flytKnap:function(e) {  
   var evtobj = window.event ? window.event : e  
   if (this.skydNu == 1) {  
       sizestop = f_clientWidth()  
       maxstop = parseInt(((sizestop*66)/100)-427)  
       if(maxstop > 413) maxstop = 413  
       if(maxstop < 60) maxstop = 60  
   
       glX = parseInt(this.targetobj.style.left)  
       this.targetobj.style.left = this.temp2 + evtobj.clientX - this.x + "px"   
       nyX = parseInt(this.temp2 + evtobj.clientX - this.x)  
       if (nyX > glX) retning = "vn"; else retning = "hj";  
       if (nyX < 1 && retning == "hj") { this.targetobj.style.left = 0 + "px"; nyX = 0; retning = "vn"; }  
       if (nyX > maxstop && retning == "vn") { this.targetobj.style.left = maxstop + "px"; nyX = maxstop; retning = "hj"; }  
       delEnh = parseInt(nyX)  
       var knapObj = this.targetobj.id  
       skydobject.changeSize(delEnh, knapObj)  
       return false  
   }  
   if (this.skydNu == 2) {  
       glY = parseInt(this.targetobj.style.top)  
       this.targetobj.style.top = this.temp3 + evtobj.clientY - this.y + "px"   
       nyY = parseInt(this.temp3 + evtobj.clientY - this.y)  
       if (nyY > glY) retning = "vn"; else retning = "hj";  
       if (nyY < 1 && retning == "hj") { this.targetobj.style.top = 0 + "px"; nyY = 0; retning = "vn"; }  
       if (nyY > 270 && retning == "vn") { this.targetobj.style.top = 270 + "px"; nyY = 270; retning = "hj"; }  
       delEnh = parseInt(nyY)  
       var knapObj = this.targetobj.id  
       skydobject.changeSize(delEnh, knapObj)  
       return false  
   }  
},  
skydeKnap:function(e) {  
   var evtobj = window.event ? window.event : e  
   this.targetobj = window.event ? event.srcElement : e.target  
   if (this.targetobj.className == "drag") {  
       if(this.targetobj.id == "dragImg1") this.skydNu = 1  
       if(this.targetobj.id == "dragImg2") this.skydNu = 2  
       this.knapObj = this.targetobj  
       if (isNaN(parseInt(this.targetobj.style.left))) this.targetobj.style.left = 0  
       if (isNaN(parseInt(this.targetobj.style.top))) this.targetobj.style.top = 0  
       this.temp2 = parseInt(this.targetobj.style.left)  
       this.temp3 = parseInt(this.targetobj.style.top)  
       this.x = evtobj.clientX  
       this.y = evtobj.clientY  
       if (evtobj.preventDefault) evtobj.preventDefault()  
       document.onmousemove = skydobject.flytKnap  
   }  
}  
}  
   
function f_clientWidth() {  
   return f_filterResults (  
       window.innerWidth ? window.innerWidth : 0,  
       document.documentElement ? document.documentElement.clientWidth : 0,  
       document.body ? document.body.clientWidth : 0  
   );  
}  
   
function f_filterResults(n_win, n_docel, n_body) {  
   var n_result = n_win ? n_win : 0;  
   if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel;  
   return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;  
}  
   
var orgsize = $textsize;  
   
function sizetext(sizefact) {  
   orgsize = orgsize + sizefact;  
   if(orgsize < 6) orgsize = 6;  
   if(orgsize > 16) orgsize = 16;  
   document.getElementById('message').style.fontSize = orgsize+'pt';  
   document.getElementById('txtsize').value = orgsize;  
}  
   
skydobject.initialize()  
   
// Collapse/Expand additional features  
var col_row = $col_row;  
function show_features() {  
   document.getElementById('col_row').value = col_row;  
   if (col_row == 1) {  
       for (var i = 1; 14 > i; i++) {  
           try {  
               if (typeof(document.getElementById("feature_status_" + i).style)) throw "1";  
           } catch (e) {  
               if (e == "1") {  
                   document.getElementById("feature_status_" + i).style.display = "none";  
               }  
           }  
       }  
       document.images.feature_col.alt = "$npf_txt{'expand_features'}";  
       document.images.feature_col.title = "$npf_txt{'expand_features'}";  
       document.images.feature_col.src="$defaultimagesdir/cat_expand.gif";  
       col_row = 0;  
   } else {  
       for (var i = 1; 14 > i; i++) {  
           try {  
               if (typeof(document.getElementById("feature_status_" + i).style)) throw "1";  
           } catch (e) {  
               if (e == "1") {  
                   document.getElementById("feature_status_" + i).style.display = "";  
               }  
           }  
       }  
       document.images.feature_col.alt = "$npf_txt{'collapse_features'}";  
       document.images.feature_col.title = "$npf_txt{'collapse_features'}";  
       document.images.feature_col.src="$defaultimagesdir/cat_collapse.gif";  
       col_row = 1;  
   }  
}  
show_features();  
//-->  
</script>~;  
   }  
   
   if ($postid ne 'Poll' && $post ne 'imsend' && ($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {  
       $yymain .= qq~  
<script language="JavaScript1.2" type="text/javascript">  
<!--  
function showtpstatus() { function showtpstatus() {
   var z = 0;     $jsPstat 
   var x = 0;    var z = 0;
   var theimg = '$threadclass';     var x = 0; 
   for(var i=0; i<document.postmodify.topicstatus.length; i++) {     var theimg = '$threadclass'; 
       if (document.postmodify.topicstatus[i].selected) { z++; x += i; }     for(var i=0; i<document.postmodify.topicstatus.length; i++) { 
   }~;         if (document.postmodify.topicstatus[i].selected) { z++; x += i; } 
       if ($currentboard ne $annboard) {     }~; 
           $yymain .= qq~         if ( $currentboard ne $annboard ) { 
   if(z == 1 && x == 0)  theimg = 'sticky';             $my_tclass .= q~ 
   if(z == 1 && x == 1)  theimg = 'locked';     if(z == 1 && x === 0)  theimg = 'sticky'; 
   if(z == 2 && x == 1)  theimg = 'stickylock';     if(z == 1 && x == 1)  theimg = 'locked'; 
   if(z == 1 && x == 2)  theimg = 'hide';     if(z == 2 && x == 1)  theimg = 'stickylock'; 
   if(z == 2 && x == 2)  theimg = 'hidesticky';     if(z == 1 && x == 2)  theimg = 'hide'; 
   if(z == 2 && x == 3)  theimg = 'hidelock';     if(z == 2 && x == 2)  theimg = 'hidesticky'; 
   if(z == 3 && x == 3)  theimg = 'hidestickylock';~;     if(z == 2 && x == 3)  theimg = 'hidelock'; 
       } else {     if(z == 3 && x == 3)  theimg = 'hidestickylock';~; 
           $yymain .= qq~         } 
   if(z == 1 && x == 0)  theimg = 'announcementlock';         else { 
   if(z == 1 && x == 1)  theimg = 'hide';             $my_tclass .= q~ 
   if(z == 2 && x == 1)  theimg = 'hidelock';~;     if(z == 1 && x === 0)  theimg = 'announcementlock'; 
       }     if(z == 1 && x == 1)  theimg = 'hide'; 
       $yymain .= qq~     if(z == 2 && x == 1)  theimg = 'hidelock';~; 
   document.images.thrstat.src='$imagesdir/'+theimg+'.gif';         } 
         $my_tclass .= q~
     var picon_show = jsPstat.getItem(theimg);
     document.images.thrstat.src = picon_show;
} }
showtpstatus(); showtpstatus();
//-->  
</script>~; </script>~;
   }    }
   
   if ($action eq "modify" || $action eq "modify2") {  
       $displayname = qq~$mename~;  
   } else {  
       $displayname = ${$uid.$username}{'realname'};  
   }  
   
   require "$templatesdir/$usedisplay/Display.template";  
   
   foreach (@months) { $jsmonths .= qq~'$_',~; }  
   $jsmonths =~ s~\,\Z~~;  
   $jstimeselected = ${$uid.$username}{'timeselect'} || $timeselected;  
   
   if($postid ne 'Poll') {  
       $yymain .= qq~  
<script language="JavaScript1.2" src="$yyhtml_root/yabbc.js" type="text/javascript"></script>  
<script type="text/javascript" language="JavaScript">  
<!--  
var noalert = true, gralert = false, rdalert = false, clalert = false;  
var prevsec = 5  
var prevtxt  
var cntsec = 0  
   
function tick() {  
 cntsec++  
 calcCharLeft()  
 var timerID = setTimeout("tick()",1000)  
}  
   
var autoprev = false  
var topicfirst = true;  
   
post_txt_807 = "$post_txt{'807'}";  
   
function enabPrev() {  
   if ( autoprev == false ) {  
       autoprev = true  
       topicfirst = true  
       document.getElementById("savetable").style.visibility = "visible";  
       document.getElementById("SaveInfo").style.height = "auto";  
       document.getElementById("savetopic").style.height = "auto";  
       document.getElementById("saveframe").style.height = "0px";  
       document.images.prevwin.alt = "$npf_txt{'02'}";  
       document.images.prevwin.title = "$npf_txt{'02'}";  
       document.images.prevwin.src="$defaultimagesdir/cat_collapse.gif";  
       autoPreview();  
   }  
   else {  
       autoprev = false;  
       ubbstr = '';  
       document.getElementById("savetable").style.visibility = "hidden";  
       document.getElementById("SaveInfo").style.height = "16px";  
       document.getElementById("savetopic").style.height = "0px";  
       document.getElementById("saveframe").style.height = "0px";  
       document.postmodify.message.focus();  
       document.images.prevwin.alt = "$npf_txt{'01'}";  
       document.images.prevwin.title = "$npf_txt{'01'}";  
       document.images.prevwin.src="$defaultimagesdir/cat_expand.gif";  
   }  
   calcCharLeft();  
}  
   
function calcCharLeft() {    if ( $action eq 'modify' || $action eq 'modify2' ) {
 if (document.postmodify.message.value.length > 0) document.getElementById("saveframe").style.height = "auto";          $displayname = qq~$mename~; 
 var clipped = false         $moddate     = $tmpmdate; 
 var maxLength = $MaxMessLen         if ( 
 if (document.postmodify.message.value.length > maxLength) {             $showmodify 
   document.postmodify.message.value = document.postmodify.message.value.substring(0,maxLength)             && ( !$tllastmodflag 
   var charleft = 0                 || ( $tmpmdate + ( $tllastmodtime * 60 ) ) < $date ) 
   clipped = true           ) 
 } else {        {
   charleft = maxLength - document.postmodify.message.value.length             $tmplastmodified = 
 }                 qq~&laquo; <i>$display_txt{'211'}: ~ 
 prevsec++               . timeformat($date,0,0,0,1) 
 if(autoprev && prevsec > 5 && prevtxt != document.postmodify.message.value) {               . qq~ $display_txt{'525'} ${$uid.$username}{'realname'}</i> &raquo;~; 
   autoPreview()         } 
   prevtxt = document.postmodify.message.value         $tmpmusername = $thismusername; 
 }    }
 document.postmodify.msgCL.value = charleft     else { 
 if (charleft >= 100 && noalert) { noalert = false; gralert = true; rdalert = true; clalert = true; document.images.chrwarn.src="$defaultimagesdir/green1.gif"; }         $displayname     = ${ $uid . $username }{'realname'}; 
 if (charleft < 100 && charleft >= 50 && gralert) { noalert = true; gralert = false; rdalert = true; clalert = true; document.images.chrwarn.src="$defaultimagesdir/green0.gif"; }         $moddate         = $date; 
 if (charleft < 50 && charleft > 0 && rdalert) { noalert = true; gralert = true; rdalert = false; clalert = true; document.images.chrwarn.src="$defaultimagesdir/red0.gif" }         $tmplastmodified = q{}; 
 if (charleft == 0 && clalert) { noalert = true; gralert = true; rdalert = true; clalert = false; document.images.chrwarn.src="$defaultimagesdir/red1.gif"; }         $tmpmusername    = $username; 
 return clipped     } 
}     $moddate = timeformat($moddate); 
   
var codestr = '$simpelcode';     get_template('Display'); 
var quotstr = '$normalquot';  
var squotstr = '$simpelquot';     foreach (@months) { $jsmonths .= qq~'$_',~; } 
var fontsizemax = '$fontsizemax';     $jsmonths =~ s/\,\Z//xsm; 
var fontsizemin = '$fontsizemin';     $jstimeselected = ${ $uid . $username }{'timeselect'} || $timeselected; 
var edittxt = '$edittext';  
var dispname = '$displayname';     if ( $postid ne 'Poll' ) { 
var scrpurl = '$scripturl';         $my_ajxcall   = 'ajxmessage'; 
var imgdir = '$defaultimagesdir';         $my_postbox_3 = postbox3(); 
var ubsmilieurl = '$smiliesurl';         $my_postbox_3 .= qq~ 
var parseflash = '$parseflash';  <script src="$yyhtml_root/ajax.js" type="text/javascript"></script> 
var autolinkurl = '$autolinkurls';  <script type="text/javascript">~; 
var Month = new Array($jsmonths);         $my_postbox_3 .= my_liveprev(); 
var timeselected = '$jstimeselected';  
var splittext = "$maintxt{'107'}";         $my_postbox_3 .= 
var dontusetoday = '';           ( !$Quick_Post ? "document.postmodify.$settofield.focus();" : q{} ) 
var todaytext = "$maintxt{'769'}";           . qq~\n\n~; 
var yesterdaytext = "$maintxt{'769a'}";  
var timetext1 = "$timetxt{'1'}";  
var timetext2 = "$timetxt{'2'}";  
var timetext3 = "$timetxt{'3'}";  
var timetext4 = "$timetxt{'4'}";  
var jsmilieurl = new Array($smilie_url_array);  
var jsmiliecode = new Array($smilie_code_array);  
var showimageinquote = $showimageinquote;  
   
function autoPreview() {  
   if (topicfirst)  { updatTopic(); }  
   var scrlto = parseInt(180) + 5;  
   var vismessage = document.postmodify.message.value;  
   while ( c=vismessage.match(/date=(\\d+?)\\]/i) ) {  
       var qudate=c[1];  
       qudate=qudate * 1000;  
       qdate=new Date()  
       qdate.setTime(qudate);  
       qdate=qdate.toLocaleString();  
       vismessage=vismessage.replace(/(date=)\\d+?(\\])/i, "\$1"+qdate+"\$2");  
   }  
   if($enable_ubbc) {  
       var ubbstr = jsDoUbbc(vismessage,codestr,quotstr,squotstr,edittxt,dispname,scrpurl,imgdir,ubsmilieurl,parseflash,fontsizemax,fontsizemin,autolinkurl,Month,timeselected,splittext,dontusetoday,todaytext,yesterdaytext,timetext1,timetext2,timetext3,timetext4,jsmilieurl,jsmiliecode,showimageinquote);  
   }  
   else {  
       var ubbstr = vismessage;  
   }  
   document.getElementById("saveframe").innerHTML=ubbstr;  
   sh_highlightDocument();  
   LivePrevImgResize();  
   scrlto += parseInt(document.getElementById("saveframe").scrollTop) + parseInt(document.getElementById("saveframe").offsetHeight);  
   document.getElementById("saveframe").scrollTop = scrlto;  
   prevsec = 0  
}  
   
var visikon = '';  
   
function LivePrevImgResize() {        if ( $post eq 'imsend' ) {
   var max_w = $max_post_img_width;             $my_showCC = q~ 
   var max_h = $max_post_img_height;  
   var images = document.getElementById("saveframe").getElementsByTagName("img");  
   for (var i = 0; i < images.length; i++) {  
       if (max_w != 0 && images[i].width > max_w) {  
           images[i].height = images[i].height * max_w / images[i].width;  
           images[i].width = max_w;  
       }  
       if (max_h != 0 && images[i].height > max_h) {  
           images[i].width  = images[i].width * max_h / images[i].height;  
           images[i].height = max_h;  
       }  
   }  
}  
   
function updatTopic() {  
   var topicfirst = false;  
   ~;  
   
       if ($destination ne 'modalert2' && $destination ne 'guestpm2') {  
           $yymain .= qq~  
   var visicon = document.postmodify.icon.value;  
   visicon=visicon.replace(/http\\:\\/\\/.*\\/(.*?)\\.gif/g, "\$1");  
   visicon=visicon.replace(/[^A-Za-z]/g, "");  
   visicon=visicon.replace(/\\\\/g, "");  
   visicon=visicon.replace(/\\//g, "");  
   if (visicon != "xx" && visicon != "thumbup" && visicon != "thumbdown" && visicon != "exclamation") {  
       if (visicon != "question" && visicon != "lamp" && visicon != "smiley" && visicon != "angry") {  
           if (visicon != "cheesy" && visicon != "grin" && visicon != "sad" && visicon != "wink") {  
               visicon = "xx";  
           }  
       }  
   }  
   visikon = "<img border='0' src='$imagesdir/"+visicon+".gif' alt='"+visicon+"' /> ";~;  
       }  
   
       $yymain .= qq~  
   var vistopic = document.postmodify.subject.value;  
   var htmltopic = jsDoTohtml(vistopic);  
   document.getElementById("savetopic").innerHTML=visikon+htmltopic;  
   //document.postmodify.message.focus();  
}  
   
~ . (!$Quick_Post ? "document.postmodify.$settofield.focus();" : "") . qq~\n\n~;  
   
       if ($post eq 'imsend') {  
           $yymain .= qq~  
if(document.getElementById('toshowcc').length > 0) document.getElementById('toshowcc').style.display = 'inline'; if(document.getElementById('toshowcc').length > 0) document.getElementById('toshowcc').style.display = 'inline';
if(document.getElementById('toshowbcc').length > 0) document.getElementById('toshowbcc').style.display = 'inline'; if(document.getElementById('toshowbcc').length > 0) document.getElementById('toshowbcc').style.display = 'inline';
~; ~;
       }        }
       $yymain .= qq~         $my_postbox_3 .= q~</script> 
if (navigator.appName == "Microsoft Internet Explorer") {  
   document.getElementById('enable_iecopytext').style.display = 'inline';  
   document.getElementById('enable_iecopy').style.display = 'inline';  
}  
tick();  
//-->  
</script>  
~; ~;
   }    }
     $yymain .= $ctmain;
     $yymain .= $my_q_quote;
     $yymain .= $my_adminim;
     $yymain .= $mypost_ubbc;
     $yymain .= $my_smilie_code;
     $yymain .= $my_smiliewin;
     $yymain .= $my_modalert;
     $yymain .= $mypost_title;
   
     $yymain .= $my_pollsection;
     $yymain .= $my_postsection;
     if ( $postid eq 'Poll' && $action eq 'modify') {
         $yymain .= $mypoll_tablefix;
     }
     $yymain .= $my_post_submit;
     $yymain .= $my_spdpost;
     $yymain .= $mypost_formend;
     $yymain .= $my_tclass;
     $yymain .= $my_postbox_3;
     $yymain .= $my_showCC;
     $yymain =~ s/{yabb my_topper}/$my_topper/sm;
     $yymain =~ s/{yabb icon}/$icon/sm;
     $yymain =~ s/{yabb icon_img}/$micon_bg{$icon}/sm;
     $yymain =~ s/{yabb yytitle}/$yytitle/sm;
     $yymain =~ s/{yabb my_topview}/$my_tview/sm;
     return;
} }
   
##  preview message  ##  show Error 
sub Preview { sub Preview {
   my $error = $_[0];     my ($error) = @_; 
   &ToHTML($error);     ToHTML($error); 
   
   # allows the following HTML-tags in error messages: <br /> <b>  
   $error =~ s/&lt;br( \/)&gt;/<br \/>/ig;  
   $error =~ s/&lt;(\/?)b&gt;/<$1b>/ig;  
   
   $maxpq ||= 60;  
   $maxpo ||= 50;  
   $maxpc ||= 0;  
   $numpolloptions ||= 8;  
   $vote_limit ||= 0;  
   $pie_radius ||= 100;  
   
   for (my $i = 1; $i <= $numpolloptions; $i++) {  
       $options[$i] = $FORM{"option$i"};  
       &FromChars($options[$i]);  
       $convertstr = $options[$i];  
       $convertcut = $maxpo;  
       &CountChars;  
       $options[$i] = $convertstr;  
       &ToHTML($options[$i]);  
       &ToChars($options[$i]);  
       $slicecolor[$i] = $FORM{"slicecol$i"};  
       $split[$i] = $FORM{"split$i"};  
   }  
   
   $guest_vote    = $FORM{'guest_vote'};  
   $hide_results  = $FORM{'hide_results'};  
   $multi_choice  = $FORM{'multi_choice'};  
   $poll_comment  = $FORM{'poll_comment'};  
   $vote_limit    = $FORM{'vote_limit'};  
   $pie_legends   = $FORM{'pie_legends'};  
   $pie_radius    = $FORM{'pie_radius'};  
   $poll_end_days = $FORM{'poll_end_days'};  
   $poll_end_min  = $FORM{'poll_end_min'};  
   
   $poll_end_days = '' if !$poll_end_days || $poll_end_days =~ /\D/;  
   $poll_end_min  = '' if !$poll_end_min  || $poll_end_min =~ /\D/;  
   
   if ($pie_radius =~ /\D/) { $pie_radius = 100; }  
   if ($pie_radius < 100) { $pie_radius = 100; }  
   if ($pie_radius > 200) { $pie_radius = 200; }  
   
   $pollthread = $FORM{'pollthread'} || 0;  
   
   $poll_question = $FORM{'question'};  
   &FromChars($poll_question);  
   $convertstr = $poll_question;  
   $convertcut = $maxpq;  
   &CountChars;  
   $poll_question = $convertstr;  
   &ToHTML($poll_question);  
   &ToChars($poll_question);  
   
   &FromChars($poll_comment);  
   $convertstr = $poll_comment;  
   $convertcut = $maxpc;  
   &CountChars;  
   $poll_comment = $convertstr;  
   &ToHTML($poll_comment);  
   &ToChars($poll_comment);  
   
   $name = $FORM{'name'};  
   $email = $FORM{'email'};  
   $sub = $FORM{'subject'};  
   $FORM{'message'} =~ s~\r~~g;  
   $message = $FORM{'message'};  
   $icon = $FORM{'icon'};  
   $ns = $FORM{'ns'};  
   $threadid = $FORM{'threadid'};  
   $postid = $FORM{'postid'};  
   $thestatus = $FORM{'topicstatus'};  
   $isBMess = $FORM{'isBMess'};  
   if (!$iamguest) {  
       ${$uid.$username}{'postlayout'} = qq~$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}~;  
       &UserAccount($username, "update");  
   }  
   $postthread = 2 if $threadid;  
   
   $sub =~ s/[\r\n]//g;  
   my $testsub = $sub;  
   $testsub =~ s/ |\&nbsp;//g;  
   if ($sub && !$testsub && $pollthread != 2) { $error = $post_txt{'77'}; }  
   
   &FromChars($sub);  
   $convertstr = $sub;  
   $convertcut = $set_subjectMaxLength + ($sub =~ /^Re: / ? 4 : 0);  
   &CountChars;  
   $sub = $convertstr;  
   &ToHTML($sub);  
   
   $csubject = $sub;  
   &ToChars($csubject);  
   $csubject = &Censor($csubject);  
   
   my $testmessage = $message;  
   $testmessage =~ s/[\r\n\ ]//g;  
   $testmessage =~ s/\&nbsp;//g;  
   $testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;  
   $testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;  
   $testmessage =~ s/\[.*?\]//g;  
   if ($testmessage eq "" && $message ne "" && $pollthread != 2) { fatal_error("useless_post","$testmessage"); }  
   
   &FromChars($message);  
   &ToHTML($message);  
   my $mess = $message;  
   $message =~ s/\cM//g;  
   $message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;  
   $message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;  
   $message =~ s/\t/ \&nbsp; \&nbsp; \&nbsp;/g;  
   $message =~ s/\n/<br \/>/g;  
   $message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;  
   
   &CheckIcon;  
   
   if    ($icon eq "xx")          { $ic1  = " selected=\"selected\" "; }  
   elsif ($icon eq "thumbup")     { $ic2  = " selected=\"selected\" "; }  
   elsif ($icon eq "thumbdown")   { $ic3  = " selected=\"selected\" "; }  
   elsif ($icon eq "exclamation") { $ic4  = " selected=\"selected\" "; }  
   elsif ($icon eq "question")    { $ic5  = " selected=\"selected\" "; }  
   elsif ($icon eq "lamp")        { $ic6  = " selected=\"selected\" "; }  
   elsif ($icon eq "smiley")      { $ic7  = " selected=\"selected\" "; }  
   elsif ($icon eq "angry")       { $ic8  = " selected=\"selected\" "; }  
   elsif ($icon eq "cheesy")      { $ic9  = " selected=\"selected\" "; }  
   elsif ($icon eq "grin")        { $ic10 = " selected=\"selected\" "; }  
   elsif ($icon eq "sad")         { $ic11 = " selected=\"selected\" "; }  
   elsif ($icon eq "wink")        { $ic12 = " selected=\"selected\" "; }  
   if ($FORM{'status'} eq 'c')    { $icon = 'confidential'; }  
   elsif ($FORM{'status'} eq 'u') { $icon = 'urgent'; }  
   elsif ($FORM{'status'} eq 's') { $icon = 'standard'; }  
   
   $name_field = $iamguest ? qq~      <tr>  
   <td class="windowbg" align="left" width="23%"><label for="name"><b>$post_txt{'68'}:</b></label></td>  
   <td class="windowbg" align="left" width="77%"><input type="text" name="name" id="name" size="25" value="$FORM{'name'}" maxlength="25" tabindex="2" /></td>  
     </tr>~  
     : qq~~;  
   
   $email_field = $iamguest ? qq~      <tr>  
   <td class="windowbg" width="23%"><label for="email"><b>$post_txt{'69'}:</b></label></td>  
   <td class="windowbg" width="77%"><input type="text" name="email" id="email" size="25" value="$FORM{'email'}" maxlength="40" tabindex="3" /></td>  
     </tr>~  
     : qq~~;  
   if ($iamguest && $gpvalid_en) {  
       $usename = substr($date,1,length($date)-4);  
       $sesname = substr($date,0,length($date)-4);  
       $verification = $FORM{'verification'};  
       $sessionid = $FORM{'sessionid'};  
       $verification_field = $verification ne ''   
       ? qq~  
           <tr>  
               <td class="windowbg" width="23%" valign="top"><label for="verification"><b>$floodtxt{'3'}:</b></label></td>  
               <td class="windowbg" width="77%">$verification  
               <input type="hidden" name="verification" id="verification" value="$verification" />  
               <input type="hidden" name="sessionid" id="sessionid" value="$sessionid" />  
               </td>  
           </tr>  
       ~  
           : '';  
   }  
   if ($FORM{'ns'} eq 'NS') { $nscheck = qq~ checked="checked"~; }  
   if ($FORM{'iecopy'}) { $iecopycheck = qq~ checked="checked"~; }  
   
   if ($iamguest) {  
       $name .= "($post_txt{'772'})";  
   }  
   
   if ($action eq 'modify2') {  
       $displayname = $FORM{'mename'};  
   } else {  
       $displayname = ${$uid.$username}{'realname'};  
   }  
   
   &wrap;  
   ($message, undef) = &Split_Splice_Move($message,$threadid);  
   if ($enable_ubbc) {  
       if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }  
       &DoUBBC;  
   }  
   &wrap2;  
   
   if ($FORM{'previewmodify'} || $FORM{'postmodify'}) {  
       $submittxt = $post_txt{'10'};  
       $is_preview = 1;  
       $post = 'postmodify';  
       $preview = 'previewmodify';  
       $destination = 'modify2';  
   } elsif (!$FORM{'previewim'} && $INFO{'action'} ne 'modalert2' && $INFO{'action'} ne 'guestpm2') {  
       $destination = 'post2';  
       $submittxt = $post_txt{'105'};  
       $is_preview = 1;  
       $post = 'post';  
       $preview = 'preview';  
   }  
   
   if ($INFO{'action'} eq 'imgroups') { $destination = 'imgroups'; }  
   
   if ($INFO{'action'} eq 'modalert2') {  
       $t_title = $post_txt{'alertmod'};  
       $destination = 'modalert2';  
       $submittxt = $post_txt{'148'};  
       $is_preview = 1;  
       $post = 'modalert';  
       $preview = 'preview';  
       $yytitle = $post_txt{'alertmod'};  
   }  
   
   if ($INFO{'action'} eq 'guestpm2') {  
       $t_title = $post_txt{'sendmessguest'};  
       $destination = 'guestpm2';  
       $submittxt = $post_txt{'148'};  
       $is_preview = 1;  
       $post = 'guestpm';  
       $preview = 'preview';  
       $yytitle = $post_txt{'sendmessguest'};  
   }  
   
   require "$templatesdir/$usedisplay/Display.template";  
   
   &ToChars($message);  
   $message = &Censor($message);  
   $prevmain .= qq~  
       <script language="JavaScript1.2" type="text/javascript" src="$yyhtml_root/ubbc.js"></script>  
       <div class="bordercolor" style="padding: 1px; width: 100%; margin-left: auto; margin-right: auto;">  
       <table border="0" width="100%" cellpadding="3" cellspacing="0" class="windowbg" style="table-layout: fixed;">  
        <tr>  
         <td class="titlebg">  
          <img src="$imagesdir/$icon.gif" name="icons2" border="0" alt="" /> $csubject  
         </td>  
        </tr>  
       </table>  
       <table border="0" width="100%" cellpadding="3" cellspacing="0" class="windowbg" style="table-layout: fixed;">  
        <tr>  
         <td class="windowbg2">  
          <div class="message" style="overflow:auto;">$message</div>  
         </td>  
        </tr>  
       </table>  
       </div>\n~;  
   
   if ($error) {  
       &LoadLanguage('Error');  
       $prevmain .= qq~  
       <div class="bordercolor" style="padding: 1px; width: 100%; margin-left: auto; margin-right: auto;">  
       <table border="0" width="100%" cellpadding="3" cellspacing="0" class="windowbg" style="table-layout: fixed;">  
        <tr>  
         <td class="titlebg">  
          <img src="$imagesdir/exclamation.gif" border="0" alt="" /> $error_txt{'error_occurred'}  
         </td>  
        </tr>  
       </table>  
       <table border="0" width="100%" cellpadding="3" cellspacing="0" class="windowbg" style="table-layout: fixed;">  
        <tr>  
         <td class="windowbg2">  
          <div class="message" style="overflow:auto; color: red"><br />$error<br /><br /></div>  
         </td>  
        </tr>  
       </table>  
       </div>\n~;  
   }  
   
   $message = $mess;  
   
   if ($error) { $csubject = $error; }  
   
   if ($img_greybox) {  
       $yyinlinestyle .= qq~<link href="$yyhtml_root/greybox/gb_styles.css" rel="stylesheet" type="text/css" />\n~;  
       $yyjavascript .= qq~  
var GB_ROOT_DIR = "$yyhtml_root/greybox/";  
// -->  
</script>  
<script type="text/javascript" src="$yyhtml_root/AJS.js"></script>  
<script type="text/javascript" src="$yyhtml_root/AJS_fx.js"></script>  
<script type="text/javascript" src="$yyhtml_root/greybox/gb_scripts.js"></script>  
<script type="text/javascript">  
<!--~;  
   }  
   
   $yytitle = $error ? "$error_txt{'error_occurred'} $csubject" : "$post_txt{'507'} - $csubject";     # allows the following HTML-tags in error messages: <br /> <b> 
   $settofield = "message";     $error =~ s/&lt;br( \/)&gt;/<br \/>/igsm; 
   $postthread = 2;     $error =~ s/&lt;(\/?)b&gt;/<$1b>/igxsm; 
     if ( $action eq 'modify2' ) {
   if (!$view) {         $tmpmusername = $thismusername; 
       &Postpage;     } 
       if ($threadid ne '' && $post eq 'post') { &doshowthread; }     else { 
       if (%usernames_life_quote) { # for display names in Quotes in LivePreview         $tmpmusername = $username; 
           $yymain .= qq~     } 
       <script language="JavaScript" type="text/javascript">  
       <!-- //     if ($error) { 
           ~ . join(';', map { qq~LivePrevDisplayNames['$_'] = "$usernames_life_quote{$_}"~ } keys %usernames_life_quote) . qq~;         LoadLanguage('Error'); 
       // -->         $prevmain .= $mypost_prevmain_error; 
       </script>\n~;         $prevmain =~ s/{yabb preverror}/$error/sm; 
       }         $prevmain =~ s/{yabb error_occurred}/$error_txt{'error_occurred'}/sm; 
       &template;     } 
   }  
     $message = $mess;
   
     if ($error) { $csubject = $error; }
   
     $yytitle =
       $error
       ? "$error_txt{'error_occurred'} $csubject" 
       : "$post_txt{'507'} - $csubject";
     $settofield = 'message';
     $postthread = 2;
   
     if ( !$view ) {
         Postpage();
         if ( $threadid ne q{} && $post eq 'post' ) { doshowthread(); }
   
         template();
     }
     return;
} }
   
sub Post2 { sub Post2 {
   if ($iamguest && $enable_guestposting == 0) { &fatal_error("not_logged_in"); }     if ( $iamguest && $enable_guestposting == 0 ) { 
   #if ($currentboard eq $annboard && !$iamadmin && !$iamgmod) { &fatal_error('not_allowed'); }         fatal_error('not_logged_in'); 
   if (!$iamadmin && !$iamgmod && !$iammod && $speedpostdetection && ${$uid.$username}{'spamcount'} >= $post_speed_count) {     } 
       $detention_time = ${$uid.$username}{'spamtime'} + $spd_detention_time;  
       if($date <= $detention_time){     if (  !$staff 
           $detention_left = $detention_time - $date;         && $speedpostdetection 
           &fatal_error("speedpostban");         && ${ $uid . $username }{'spamcount'} >= $post_speed_count ) 
       } else {    {
           ${$uid.$username}{'spamcount'} = 0;         $detention_time = 
           &UserAccount($username,"update");           ${ $uid . $username }{'spamtime'} + $spd_detention_time; 
       }         if ( $date <= $detention_time ) { 
   }             $detention_left = $detention_time - $date; 
   if ($iamguest && $gpvalid_en) {             fatal_error('speedpostban'); 
       &validation_check($FORM{'verification'});         } 
   }         else { 
   my ($email, $ns, $notify, $hasnotify, @memberlist, $i, $membername, $testname, @reserve, @reservecfg, $matchword, $matchcase, $matchuser, $matchname, $namecheck, $reserved, $reservecheck, $mnum, $msub, $mname, $memail, $mdate, $musername, $micon, $mstate, $pageindex, $tempname);             ${ $uid . $username }{'spamcount'} = 0; 
             UserAccount( $username, 'update' );
   &BoardTotals("load", $currentboard);         } 
     }
   # If poster is a Guest then evaluate the legality of name and email     if ( $iamguest && $gpvalid_en ) { 
   if (!${$uid.$username}{'email'}) {         validation_check( $FORM{'verification'} ); 
       $FORM{'name'} =~ s/\A\s+//;     } 
       $FORM{'name'} =~ s/\s+\Z//;     if (   $iamguest 
       &Preview($post_txt{'75'}) unless ($FORM{'name'} ne '' && $FORM{'name'} ne '_' && $FORM{'name'} ne ' ');         && $spam_questions_gp 
       &Preview($post_txt{'568'}) if (length($FORM{'name'}) > 25);         && -e "$langdir/$language/spam.questions" ) 
       &Preview("$post_txt{'76'}") if ($FORM{'email'} eq '');     { 
       &Preview("$post_txt{'240'} $post_txt{'69'} $post_txt{'241'}") if ($FORM{'email'} !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);         SpamQuestionCheck( $FORM{'verification_question'}, 
       &Preview("$post_txt{'500'}") if (($FORM{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($FORM{'email'} !~ /^.+@\[?(\w|[-.])+\.([a-zA-Z]{2,4}|[0-9]{1,4})\]?$/));             $FORM{'verification_question_id'} ); 
   }    }
     my (
   # Get the form values         $email,     $ns,    $notify, $hasnotify, $i, 
   $name         = $FORM{'name'};         $mnum,      $msub,  $mname,  $memail,    $mdate, 
   $email        = $FORM{'email'};         $musername, $micon, $mstate, $pageindex, $tempname 
   $subject      = $FORM{'subject'};     ); 
   $message      = $FORM{'message'};  
   $icon         = $FORM{'icon'};     BoardTotals( 'load', $currentboard ); 
   $ns           = $FORM{'ns'};  
   $ann          = $FORM{'ann'};     # Get the form values 
   $threadid     = $FORM{'threadid'};     $name     = $FORM{'name'}; 
   if ($threadid =~ /\D/) { &fatal_error("only_numbers_allowed"); }     $email    = $FORM{'email'}; 
   $pollthread   = $FORM{'pollthread'} || 0;     $subject  = $FORM{'subject'}; 
   $posttime     = $FORM{'post_entry_time'};     $message  = $FORM{'message'}; 
   $notify       = $FORM{'notify'};     $icon     = $FORM{'icon'}; 
   $hasnotify    = $FORM{'hasnotify'};     $ns       = $FORM{'ns'}; 
   $favorite     = $FORM{'favorite'};     $ann      = $FORM{'ann'}; 
   $thestatus    = $FORM{'topicstatus'};     $threadid = $FORM{'threadid'}; 
   $thestatus    =~ s/\, //g;     if ( $threadid =~ /\D/xsm ) { fatal_error('only_numbers_allowed'); } 
   chomp $thestatus;     $pollthread = $FORM{'pollthread'} || 0; 
     $posttime   = $FORM{'post_entry_time'};
   # Check if poster isn't using a distilled email domain     $notify     = $FORM{'notify'}; 
   &email_domain_check($email);     $hasnotify  = $FORM{'hasnotify'}; 
   my $spamdetected = &spamcheck("$name $subject $message");     $favorite   = $FORM{'favorite'}; 
   if (!${$uid.$FORM{$username}}{'spamcount'}) { ${$uid.$FORM{$username}}{'spamcount'} = 0; }     $thestatus  = $FORM{'topicstatus'}; 
   $postspeed = $date - $posttime;     $thestatus =~ s/\, //gsm; 
   if (!$iamadmin && !$iamgmod && !$iammod){     chomp $thestatus; 
       if (($speedpostdetection && $postspeed < $min_post_speed) || $spamdetected == 1) {  
           ${$uid.$username}{'spamcount'}++;     # Check if poster isn't using a distilled email domain 
           ${$uid.$username}{'spamtime'} = $date;     email_domain_check($email); 
           &UserAccount($username,"update");     my $spamdetected = spamcheck("$name $subject $message"); 
           $spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};     if ( !${ $uid . $FORM{$username} }{'spamcount'} ) { 
           if($spamdetected == 1){ &fatal_error("tsc_alert"); } else { &fatal_error("speed_alert"); }         ${ $uid . $FORM{$username} }{'spamcount'} = 0; 
       }    }
   }     $postspeed = $date - $posttime; 
   # Permission checks for posting.     if ( !$staff ) { 
   if (!$threadid) {         if ( ( $speedpostdetection && $postspeed < $min_post_speed ) 
       # Check for ability to post new threads             || $spamdetected == 1 ) 
       unless (&AccessCheck($currentboard, 1) eq 'granted' || $pollthread) { &fatal_error('no_perm_post'); }         { 
   } else {             ${ $uid . $username }{'spamcount'}++; 
       # Check for ability to reply to threads             ${ $uid . $username }{'spamtime'} = $date; 
       unless (&AccessCheck($currentboard, 2) eq 'granted' || $pollthread) { &fatal_error('no_perm_reply'); }             UserAccount( $username, 'update' ); 
       $postthread = 2;             $spam_hits_left_count = 
   }               $post_speed_count - ${ $uid . $username }{'spamcount'}; 
   if ($pollthread) {             if   ( $spamdetected == 1 ) { fatal_error('tsc_alert'); } 
       # Check for ability to post polls             else                        { fatal_error('speed_alert'); } 
       unless (&AccessCheck($currentboard, 3) eq 'granted') { &fatal_error('no_perm_poll'); }        }
   }    }
   for (my $y = 1; $y <= $allowattach; ++$y) {  
       if ($CGI_query && $CGI_query->upload("file$y")) {     # Permission checks for posting. 
           # Check once for ability to post attachments     if ( !$threadid ) { 
           unless (&AccessCheck($currentboard, 4) eq 'granted') { &fatal_error('no_perm_att'); }  
           last;         # Check for ability to post new threads 
       }         if ( AccessCheck( $currentboard, 1 ) ne 'granted' && !$pollthread ) { 
   }             fatal_error('no_perm_post'); 
   # End Permission Checks         } 
     }
   ## clean name and email - remove | from name and turn any _ to spaces fro amil     else { 
   if ($name && $email) {  
       &ToHTML($name);         # Check for ability to reply to threads 
       $email =~ s/\|//g;         if ( AccessCheck( $currentboard, 2 ) ne 'granted' && !$pollthread ) { 
       &ToHTML($email);             fatal_error('no_perm_reply'); 
       $tempname = $name;         } 
       $name =~ s/\_/ /g;         $postthread = 2; 
   }    }
     if ($pollthread) {
   # Fixes a bug with posting hexed characters.  
   $name =~ s~amp;~~g;         # Check for ability to post polls 
         if ( AccessCheck( $currentboard, 3 ) ne 'granted' ) {
   &Preview($post_txt{'75'}) unless ($username || $name);             fatal_error('no_perm_poll'); 
   &Preview($post_txt{'76'}) unless (${$uid.$username}{'email'} || $email);         } 
   &Preview($post_txt{'77'}) unless ($subject && $subject !~ m~\A[\s_.,]+\Z~);     } 
   &Preview($post_txt{'78'}) unless ($message);     $allowattach ||= 0; 
     if ( $allowattach > 0 ) {
   # Check Message Length Precisely         for my $y ( 1 .. $allowattach ) { 
   my $mess_len = $message;             if ( $CGI_query && $CGI_query->upload("file$y") ) { 
   $mess_len =~ s/[\r\n ]//ig;  
   $mess_len =~ s/&#\d{3,}?\;/X/ig;             # Check once for ability to post attachments 
   if (length($mess_len) > $MaxMessLen) {                if ( AccessCheck( $currentboard, 4 ) ne 'granted' ) {
       &Preview($post_txt{'536'} . " " . (length($mess_len) - $MaxMessLen) . " " . $post_txt{'537'});                     fatal_error('no_perm_att'); 
   }                }
   undef $mess_len;                 last; 
             }
   if ($FORM{'preview'}) { &Preview; }        }
   &spam_protection;     } 
   
   $subject =~ s/[\r\n]//g;     # End Permission Checks 
   my $testsub = $subject;  
   $testsub =~ s/ |\&nbsp;//g;     ## clean name and email - remove | from name and turn any _ to spaces for mail 
   if ($testsub eq "" && $pollthread != 2) { fatal_error("useless_post","$testsub"); }     if ( $name && $email ) { 
         ToHTML($name);
   my $testmessage = $message;         $email =~ s/\|//gxsm; 
   $testmessage =~ s/[\r\n\ ]//g;         ToHTML($email); 
   $testmessage =~ s/\&nbsp;//g;         $tempname = $name; 
   $testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;         $name =~ s/\_/ /gsm; 
   $testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;     } 
   $testmessage =~ s/\[.*?\]//g;  
   if ($testmessage eq "" && $message ne "" && $pollthread != 2) { fatal_error("useless_post","$testmessage"); }     # Fixes a bug with posting hexed characters. 
     $name =~ s/amp;//gxsm;
   if (!$minlinkpost){ $minlinkpost = 0 ;}  
   if (${$uid.$username}{'postcount'} < $minlinkpost && !$iamadmin && !$iamgmod && !$iammod) {     spam_protection(); 
       if ($message =~ m~http:\/\/~ || $message =~ m~https:\/\/~ || $message =~ m~ftp:\/\/~ || $message =~ m~www.~ || $message =~ m~ftp.~ =~ m~\[url~ || $message=~ m~\[link~ || $message=~ m~\[img~ || $message=~ m~\[ftp~) {  
           &fatal_error("no_links_allowed");     $subject =~ s/[\r\n]//gxsm; 
       }     my $testsub = $subject; 
   }     $testsub =~ s/ |\&nbsp;//gsm; 
     if ( $testsub eq q{} && $pollthread != 2 ) {
   &FromChars($subject);         fatal_error( 'useless_post', "$testsub" ); 
   $convertstr = $subject;     } 
   $convertcut = $set_subjectMaxLength + ($subject =~ /^Re: / ? 4 : 0);  
   &CountChars;     my $testmessage = regex_1($message); 
   $subject = $convertstr;     if ( $testmessage eq q{} && $message ne q{} && $pollthread != 2 ) { 
   &ToHTML($subject);         fatal_error( 'useless_post', "$testmessage" ); 
   $doadsubject = $subject;     } 
   
   $message =~ s/\cM//g;     if ( !$minlinkpost ) { $minlinkpost = 0; } 
   $message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;     if ( ${ $uid . $username }{'postcount'} < $minlinkpost 
   $message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;         && !$staff ) 
   &FromChars($message);     { 
   &ToHTML($message);         if (   $message =~ m{http:\/\/}xsm 
   $message =~ s~\t~ \&nbsp; \&nbsp; \&nbsp;~g;             || $message =~ m{https:\/\/}xsm 
   $message =~ s~\n~<br />~g;             || $message =~ m{ftp:\/\/}xsm 
   $message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;             || $message =~ m{www.}xsm 
   &CheckIcon;             || $message =~ m{ftp.}xsm =~ m{\[url}xsm 
             || $message =~ m{\[link}xsm
   if (-e ("$datadir/.txt")) { unlink("$datadir/.txt"); }             || $message =~ m{\[img}xsm 
             || $message =~ m{\[ftp}xsm )
   if (!$iamguest) {        {
       # If not guest, get name and email.             fatal_error('no_links_allowed'); 
       $name  = ${$uid.$username}{'realname'};         } 
       $email = ${$uid.$username}{'email'};     } 
   
   } else {     FromChars($subject); 
       # If user is Guest, then make sure the chosen name and email     $convertstr = $subject; 
       # is not reserved or used by a member.     $convertcut = $set_subjectMaxLength + ( $subject =~ /^Re: /sm ? 4 : 0 ); 
       if (lc $name eq lc &MemberIndex("check_exist", $name)) { &fatal_error("guest_taken","($name)"); }     CountChars(); 
       if (lc $email eq lc &MemberIndex("check_exist", $email)) { &fatal_error("guest_taken","($email)"); }     $subject = $convertstr; 
   }     ToHTML($subject); 
     $doadsubject = $subject;
   my @poll_data;  
   if ($pollthread) {     $message = regex_2($message); 
       $maxpq          ||= 60;  
       $maxpo          ||= 50;     FromChars($message); 
       $maxpc          ||= 0;     ToHTML($message); 
       $numpolloptions ||= 8;     $message = regex_3($message); 
     CheckIcon();
       my $numcount = 0;  
       my $testspaces = $FORM{"question"};     if ( -e ("$datadir/.txt") ) { unlink "$datadir/.txt"; } 
       $testspaces =~ s/[\r\n\ ]//g;  
       $testspaces =~ s/\&nbsp;//g;     if ( !$iamguest ) { 
       $testspaces =~ s~\[table\].*?\[tr\].*?\[td\]~~g;  
       $testspaces =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;         # If not guest, get name and email. 
       $testspaces =~ s/\[.*?\]//g;         $name  = ${ $uid . $username }{'realname'}; 
       if (length($testspaces) == 0 && length($FORM{"question"}) > 0) { fatal_error("useless_post","$testspaces"); }         $email = ${ $uid . $username }{'email'}; 
   
       &FromChars($FORM{'question'});     } 
       $convertstr = $FORM{'question'};     else { 
       $convertcut = $maxpq;  
       &CountChars;         # If user is Guest, then make sure the chosen name and email 
       $FORM{'question'} = $convertstr;         # is not reserved or used by a member. 
       if ($cliped) { &Preview("$post_polltxt{'40'} $post_polltxt{'34a'} $maxpq $post_polltxt{'34b'} $post_polltxt{'36'}"); }         if ( lc $name eq lc MemberIndex( 'check_exist', $name ) ) { 
       unless ($FORM{"question"}) { &Preview("$post_polltxt{'37'}"); }             fatal_error( 'guest_taken', "($name)" ); 
       &ToHTML($FORM{'question'});         } 
         if ( lc $email eq lc MemberIndex( 'check_exist', $email ) ) {
       $guest_vote    = $FORM{'guest_vote'}   || 0;             fatal_error( 'guest_taken', "($email)" ); 
       $hide_results  = $FORM{'hide_results'} || 0;         } 
       $multi_choice  = $FORM{'multi_choice'} || 0;     } 
       $poll_comment  = $FORM{'poll_comment'} || "";  
       $vote_limit    = $FORM{'vote_limit'}   || 0;     my @poll_data; 
       $pie_legends   = $FORM{'pie_legends'}  || 0;     if ($pollthread) { 
       $pie_radius    = $FORM{'pie_radius'}   || 100;         $maxpq          ||= 60; 
       $poll_end_days = $FORM{'poll_end_days'};         $maxpo          ||= 50; 
       $poll_end_min  = $FORM{'poll_end_min'};         $maxpc          ||= 0; 
         $numpolloptions ||= 8;
       if ($pie_radius =~ /\D/) { $pie_radius = 100; }  
       if ($pie_radius < 100)   { $pie_radius = 100; }         my $numcount   = 0; 
       if ($pie_radius > 200)   { $pie_radius = 200; }         my $testspaces = regex_1( $FORM{'question'} ); 
         if ( length($testspaces) == 0 && length( $FORM{'question'} ) > 0 ) {
       if ($vote_limit =~ /\D/) { $vote_limit = 0; &Preview("$post_polltxt{'62'}"); }             fatal_error( 'useless_post', "$testspaces" ); 
         }
       &FromChars($poll_comment);  
       $convertstr = $poll_comment;         FromChars( $FORM{'question'} ); 
       $convertcut = $maxpc;         $convertstr = $FORM{'question'}; 
       &CountChars;         $convertcut = $maxpq; 
       $poll_comment = $convertstr;         CountChars(); 
       if ($cliped) { &Preview("$post_polltxt{'57'} $post_polltxt{'34a'} $maxpc $post_polltxt{'34b'} $post_polltxt{'36'}"); }         $FORM{'question'} = $convertstr; 
       &ToHTML($poll_comment);  
       $poll_comment =~ s~\n~<br />~g;         ToHTML( $FORM{'question'} ); 
       $poll_comment =~ s~\r~~g;  
         $guest_vote   = $FORM{'guest_vote'}   || 0;
       $poll_end_days = '' if !$poll_end_days || $poll_end_days =~ /\D/;         $hide_results = $FORM{'hide_results'} || 0; 
       $poll_end_min  = '' if !$poll_end_min  || $poll_end_min =~ /\D/;         $multi_choice = $FORM{'multi_choice'} || 0; 
       my $poll_end = $poll_end_days * 86400 if $poll_end_days;         $poll_comment = $FORM{'poll_comment'} || q{}; 
       $poll_end += $poll_end_min * 60 if $poll_end_min;         $vote_limit   = $FORM{'vote_limit'}   || 0; 
       $poll_end += $date if $poll_end;         $pie_legends  = $FORM{'pie_legends'}  || 0; 
         $pie_radius   = $FORM{'pie_radius'}   || 100;
       push(@poll_data, qq~$FORM{"question"}|0|$username|$name|$email|$date|$guest_vote|$hide_results|$multi_choice|||$poll_comment|$vote_limit|$pie_radius|$pie_legends|$poll_end\n~);         $poll_end_days = $FORM{'poll_end_days'}; 
         $poll_end_min  = $FORM{'poll_end_min'};
       for ($i = 1; $i <= $numpolloptions; $i++) {  
           if ($FORM{"option$i"}) {         if ( $pie_radius =~ /\D/xsm ) { $pie_radius = 100; } 
               $FORM{"option$i"} =~ s/\&nbsp;/ /g;         if ( $pie_radius < 100 ) { $pie_radius = 100; } 
               my $testspaces = $FORM{"option$i"};         if ( $pie_radius > 200 ) { $pie_radius = 200; } 
               $testspaces =~ s/[\r\n\ ]//g;  
               $testspaces =~ s/\&nbsp;//g;         FromChars($poll_comment); 
               $testspaces =~ s~\[table\].*?\[tr\].*?\[td\]~~g;         $convertstr = $poll_comment; 
               $testspaces =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;         $convertcut = $maxpc; 
               $testspaces =~ s/\[.*?\]//g;         CountChars(); 
               if (length($testspaces) == 0 && length($FORM{"option$i"}) > 0) { fatal_error("useless_post","$testspaces"); }         $poll_comment = $convertstr; 
   
               &FromChars($FORM{"option$i"});         ToHTML($poll_comment); 
               $convertstr = $FORM{"option$i"};         $poll_comment =~ s/\n/<br \/>/gsm; 
               $convertcut = $maxpo;         $poll_comment =~ s/\r//gxsm; 
               &CountChars;         if ( !$poll_end_days || $poll_end_days =~ /\D/xsm ) { 
               $FORM{"option$i"} = $convertstr;             $poll_end_days = q{}; 
               if ($cliped) { &Preview("$post_polltxt{'7'} $i  $post_polltxt{'34a'} $maxpo $post_polltxt{'34b'} $post_polltxt{'36'}"); }        }
               &ToHTML($FORM{"option$i"});         if ( !$poll_end_min || $poll_end_min =~ /\D/xsm ) { 
             $poll_end_min = q{};
               $numcount++;         } 
               $split[$i] = $FORM{"split$i"} || 0;         if ($poll_end_days) { $poll_end = $poll_end_days * 86400; } 
               push(@poll_data, qq~0|$FORM{"option$i"}|$FORM{"slicecol$i"}|$split[$i]\n~);         if ($poll_end_min) { $poll_end += $poll_end_min * 60; } 
           }        if ($poll_end)     { $poll_end += $date; }
       }  
       if ($numcount < 2) { &Preview("$post_polltxt{'38'}"); }         push @poll_data, 
   }  qq~$FORM{'question'}|0|$username|$name|$email|$date|$guest_vote|$hide_results|$multi_choice|||$poll_comment|$vote_limit|$pie_radius|$pie_legends|$poll_end\n~; 
   
   my ($file,$fixfile,@filelist,%filesizekb);         for my $i ( 1 .. $numpolloptions ) { 
   for (my $y = 1; $y <= $allowattach; ++$y) {            if ( $FORM{"option$i"} ) {
       $file = $CGI_query->upload("file$y") if $CGI_query;                 $FORM{"option$i"} =~ s/\&nbsp;/ /gsm; 
       if ($file) {                 $testspaces = regex_1( $FORM{"option$i"} ); 
           $fixfile = $file;                 if (   length($testspaces) == 0 
           $fixfile =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;                     && length( $FORM{"option$i"} ) > 0 ) 
           if ($fixfile =~ /[^0-9A-Za-z\+\-\.:_]/) { # replace all inappropriate characters                 { 
               # Transliteration                     fatal_error( 'useless_post', "$testspaces" ); 
               my @ISO_8859_1 = qw(A B V G D E JO ZH Z I J K L M N O P R S T U F H C CH SH SHH _ Y _ JE JU JA a b v g d e jo zh z i j k l m n o p r s t u f h c ch sh shh _ y _ je ju ja);                 } 
               my $x = 0;  
               foreach (qw(À Á Â Ã Ä Å ¨ Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å ¸ æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ)) {                 FromChars( $FORM{"option$i"} ); 
                    $fixfile =~ s/$_/$ISO_8859_1[$x]/ig;                 $convertstr = $FORM{"option$i"}; 
                    $x++;                 $convertcut = $maxpo; 
               }                 CountChars(); 
               # END Transliteration. Thanks to "Velocity" for this contribution.                 $FORM{"option$i"} = $convertstr; 
               $fixfile =~ s/[^0-9A-Za-z\+\-\.:_]/_/g;  
           }                 ToHTML( $FORM{"option$i"} ); 
   
           # replace . with _ in the filename except for the extension                 $numcount++; 
           my $fixname = $fixfile;                 $split[$i] = $FORM{"split$i"} || 0; 
           $fixname =~ s/(.+)(\..+?)$/$1/;                 push @poll_data, 
           my $fixext = $2;                   qq~0|$FORM{"option$i"}|$FORM{"slicecol$i"}|$split[$i]\n~; 
             }
           my $spamdetected = &spamcheck("$fixname");         } 
           if (!$iamadmin && !$iamgmod && !$iammod){     } 
               if ($spamdetected == 1) {  
                   ${$uid.$username}{'spamcount'}++;     my ( $file, $fixfile, @filelist, %filesizekb ); 
                   ${$uid.$username}{'spamtime'} = $date;     $allowattach ||= 0; 
                   &UserAccount($username,"update");     if ( $allowattach > 0 ) { 
                   $spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};         for my $y ( 1 .. $allowattach ) { 
                   foreach (@filelist) { unlink("$uploaddir/$_"); }            if ($CGI_query) { $file = $CGI_query->upload("file$y"); }
                   &fatal_error("tsc_alert");             if ($file) { 
               }                 $fixfile = $file; 
           }                 $fixfile =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/xsm; 
               if ($use_guardian && $string_on) {                 if ( $fixfile =~ /[^0-9A-Za-z\+\-\.:_]/xsm ) 
                       @bannedstrings = split(/\|/, $banned_strings);                 {    # replace all inappropriate characters 
                       foreach (@bannedstrings) {                     # Transliteration 
                           chomp $_;                 my $x = 0; 
                           if ($fixname =~ m/$_/i) { &fatal_error("attach_name_blocked","($_)"); }                 foreach ( @uploadtranlist ) 
                       }                 { 
               }                     $fixfile =~ s/$_/$ISO_8859_1[$x]/gxsm; 
           $fixext  =~ s/\.(pl|pm|cgi|php)/._$1/i;                     $x++; 
           $fixname =~ s/\.(?!tar$)/_/g;                 } 
           $fixfile = qq~$fixname$fixext~;  
               # END Transliteration. Thanks to "Velocity" for this contribution.
           if (!$overwrite) { $fixfile = &check_existence($uploaddir, $fixfile); }                 $fixfile =~ s/[^0-9A-Za-z\+\-\.:_]/_/gxsm; 
           elsif ($overwrite == 2 && -e "$uploaddir/$fixfile") {             } 
               foreach (@filelist) { unlink("$uploaddir/$_"); }             my $fixname = $fixfile; 
               &fatal_error("file_overwrite");             if ( $fixname =~ s/(.+)(\..+?)$/$1/xsm ) { 
           }                 $fixext = $2; 
             }
           my $match = 0;             $spamdetected = spamcheck("$fixname"); 
           if (!$checkext) { $match = 1; }             if ( !$staff ) { 
           else {                if ( $spamdetected == 1 ) {
               foreach $ext (@ext) {                     ${ $uid . $username }{'spamcount'}++; 
                   if (grep /$ext$/i, $fixfile) { $match = 1; last; }                     ${ $uid . $username }{'spamtime'} = $date; 
               }                     UserAccount( $username, 'update' ); 
           }                     $spam_hits_left_count = 
           if ($match) {                       $post_speed_count - ${ $uid . $username }{'spamcount'}; 
               unless ($allowattach && (($allowguestattach == 0 && $username ne 'Guest') || $allowguestattach == 1)) {                     foreach (@filelist) { unlink "$uploaddir/$_"; } 
                   foreach (@filelist) { unlink("$uploaddir/$_"); }                     fatal_error('tsc_alert'); 
                   &fatal_error("no_perm_att");                 } 
               }            }
           } else {            if ( $use_guardian && $string_on ) {
               foreach (@filelist) { unlink("$uploaddir/$_"); }                 @bannedstrings = split /\|/xsm, $banned_strings; 
               &Preview("$fixfile $fatxt{'20'} @ext");                 foreach (@bannedstrings) { 
           }                     chomp $_; 
                     if ( $fixname =~ m/$_/ism ) {
           my ($size,$buffer,$filesize,$file_buffer);                         fatal_error( 'attach_name_blocked', "($_)" ); 
           while ($size = read($file, $buffer, 512)) { $filesize += $size; $file_buffer .= $buffer; }                    }
           if ($limit && $filesize > (1024 * $limit)) {                 } 
               foreach (@filelist) { unlink("$uploaddir/$_"); }            }
               &Preview("$fatxt{'21'} $fixfile (" . int($filesize / 1024) . " KB) $fatxt{'21b'} " . $limit);             $fixext  =~ s/\.(pl|pm|cgi|php)/._$1/ixsm; 
           }             $fixname =~ s/\.(?!tar$)/_/gxsm; 
           if ($dirlimit) {             $fixfile = qq~$fixname$fixext~; 
               my $dirsize = &dirsize($uploaddir);  
               if ($filesize > ((1024 * $dirlimit) - $dirsize)) {            if ( !$overwrite ) {
                   foreach (@filelist) { unlink("$uploaddir/$_"); }                 $fixfile = check_existence( $uploaddir, $fixfile ); 
                   &Preview("$fatxt{'22'} $fixfile (" . (int($filesize / 1024) - $dirlimit + int($dirsize / 1024)) . " KB) $fatxt{'22b'}");             } 
               }             elsif ( $overwrite == 2 && -e "$uploaddir/$fixfile" ) { 
           }                foreach (@filelist) { unlink "$uploaddir/$_"; }
                 fatal_error('file_overwrite');
           # create a new file on the server using the formatted ( new instance ) filename             } 
           if (fopen(NEWFILE, ">$uploaddir/$fixfile")) {  
               binmode NEWFILE; # needed for operating systems (OS) Windows, ignored by Linux             my $match = 0; 
               print NEWFILE $file_buffer; # write new file on HD             if ( !$checkext ) { $match = 1; } 
               fclose(NEWFILE);             else { 
                 foreach my $ext (@ext) {
           } else { # return the server's error message if the new file could not be created                     if ( grep { /$ext$/ixsm } $fixfile ) { 
               foreach (@filelist) { unlink("$uploaddir/$_"); }                         $match = 1; 
               &fatal_error("file_not_open","$uploaddir");                         last; 
           }                    }
                 }
           # check if file has actually been uploaded, by checking the file has a size             } 
           $filesizekb{$fixfile} = -s "$uploaddir/$fixfile";             $allowattach ||= 0; 
           unless ($filesizekb{$fixfile}) {            if ($match) {
               foreach (qw("@filelist" $fixfile)) { unlink("$uploaddir/$_"); }                 if ( 
               &fatal_error("file_not_uploaded",$fixfile);                     $allowattach == 0 
           }                     || ( ( $allowguestattach != 0 && $username eq 'Guest' ) 
           $filesizekb{$fixfile} = int($filesizekb{$fixfile} / 1024);                         && $allowguestattach != 1 ) 
                   )
           if ($fixfile =~ /\.(jpg|gif|png|jpeg)$/i) {                {
               my $okatt = 1;                     foreach (@filelist) { unlink "$uploaddir/$_"; } 
               if ($fixfile =~ /gif$/i) {                     fatal_error('no_perm_att'); 
                   my $header;                 } 
                   fopen(ATTFILE, "$uploaddir/$fixfile");             } 
                   read(ATTFILE, $header, 10);             else { 
                   my $giftest;                 foreach (@filelist) { unlink "$uploaddir/$_"; } 
                   ($giftest, undef, undef, undef, undef, undef) = unpack("a3a3C4", $header);                 fatal_error( q{}, "$fixfile $fatxt{'20'} @ext" ); 
                   fclose(ATTFILE);             } 
                   if ($giftest ne "GIF") { $okatt = 0; }  
               }             my ( $size, $buffer, $filesize, $file_buffer ); 
               fopen(ATTFILE, "$uploaddir/$fixfile");             while ( $size = read $file, $buffer, 512 ) { 
               while ( read(ATTFILE, $buffer, 1024) ) {                 $filesize += $size; 
                   if ($buffer =~ /<(html|script|body)/ig) { $okatt = 0; last; }                 $file_buffer .= $buffer; 
               }            }
               fclose(ATTFILE);             $limit ||= 0; 
               if(!$okatt) { # delete the file as it contains illegal code             if ( $limit > 0 && $filesize > ( 1024 * $limit ) ) { 
                   foreach (qw("@filelist" $fixfile)) { unlink("$uploaddir/$_"); }                foreach (@filelist) { unlink "$uploaddir/$_"; }
                   &fatal_error("file_not_uploaded","$fixfile <= illegal code inside image file!");                 fatal_error( q{}, 
               }                         "$fatxt{'21'} $fixfile (" 
           }                       . int( $filesize / 1024 ) 
                       . " KB) $fatxt{'21b'} " 
           push(@filelist, $fixfile);                       . $limit ); 
             }
       }             $dirlimit ||= 0; 
   }             if ( $dirlimit > 0 ) { 
   #Create the list of files                 my $dirsize = dirsize($uploaddir); 
   $fixfile = join(",", @filelist);                 if ( $filesize > ( ( 1024 * $dirlimit ) - $dirsize ) ) { 
                     foreach (@filelist) { unlink "$uploaddir/$_"; }
   # If no thread specified, this is a new thread.                     fatal_error( 
   # Find a valid random ID for it.                         q{}, 
   if ($threadid eq '') {                         "$fatxt{'22'} $fixfile (" 
       $newthreadid = &getnewid;                           . ( 
   } else {                             int( $filesize / 1024 ) - 
       $newthreadid = '';                               $dirlimit + 
   }                               int( $dirsize / 1024 ) 
                           )
   # This is only for update, when comming from YaBB lower or equal version 2.2.3                           . " KB) $fatxt{'22b'}" 
   # I think it can be deleted around version 2.4.0 without causing mayor issues (deti).                     ); 
   if ($enable_notifications eq '') { $enable_notifications = $enable_notification ? 3 : 0; }                }
   # End update workaround             } 
   
   # set announcement flag according to status of current board  # create a new file on the server using the formatted ( new instance ) filename 
   if ($newthreadid) {            if ( fopen( NEWFILE, ">$uploaddir/$fixfile" ) ) {
       $mreplies = 0;                 binmode NEWFILE; 
       if ($iammod || $iamgmod || $iamadmin) { $mstate = $currentboard eq $annboard ? "0a$thestatus" : "0$thestatus"; }  
       else { $mstate = "0"; }                 # needed for operating systems (OS) Windows, ignored by Linux 
                 print {NEWFILE} $file_buffer
       # This is a new thread. Save it.                   or croak "$croak{'print'} NEWFILE";    # write new file on HD 
       fopen(FILE, "+<$boardsdir/$currentboard.txt", 1) || &fatal_error("cannot_open","$boardsdir/$currentboard.txt", 1);                 fclose(NEWFILE); 
       seek FILE, 0, 0;             } 
       my @buffer = <FILE>;             else 
       truncate FILE, 0;             { # return the server's error message if the new file could not be created 
       seek FILE, 0, 0;                 foreach (@filelist) { unlink "$uploaddir/$_"; } 
       print FILE qq~$newthreadid|$subject|$name|$email|$date|$mreplies|$username|$icon|$mstate\n~;                 fatal_error( 'file_not_open', "$uploaddir" ); 
       print FILE @buffer;             } 
       fclose(FILE);  
       fopen(FILE, ">$datadir/$newthreadid.txt") || &fatal_error("cannot_open","$datadir/$newthreadid.txt", 1);      # check if file has actually been uploaded, by checking the file has a size 
       print FILE qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$fixfile\n~;             $filesizekb{$fixfile} = -s "$uploaddir/$fixfile"; 
       fclose(FILE);             if ( !$filesizekb{$fixfile} ) { 
                 foreach (qw("@filelist" $fixfile)) {
                     unlink "$uploaddir/$_";
       if (@filelist) {                 } 
           fopen(AMP, ">>$vardir/attachments.txt") || &fatal_error("cannot_open","$vardir/attachments.txt");                 fatal_error( 'file_not_uploaded', $fixfile ); 
           foreach $fixfile (@filelist) {             } 
               print AMP qq~$newthreadid|$mreplies|$subject|$name|$currentboard|$filesizekb{$fixfile}|$date|$fixfile|0\n~;             $filesizekb{$fixfile} = int( $filesizekb{$fixfile} / 1024 ); 
           }  
           fclose(AMP);             if ( $fixfile =~ /\.(jpg|gif|png|jpeg)$/ism ) { 
       }                 my $okatt = 1; 
       if ($pollthread) { # Save Poll data for new thread                 if ( $fixfile =~ /gif$/ism ) { 
           if (($iamadmin || $iamgmod) && $FORM{'scpoll'}) { # Save ShowcasePoll                     my $header; 
                   fopen (SCFILE, ">$datadir/showcase.poll");                     fopen( ATTFILE, "$uploaddir/$fixfile" ); 
                   print SCFILE $newthreadid;                     read ATTFILE, $header, 10; 
                   fclose (SCFILE);                     my $giftest; 
           }                     ( $giftest, undef, undef, undef, undef, undef ) = 
                       unpack 'a3a3C4', $header;
           fopen(POLL, ">$datadir/$newthreadid.poll");                     fclose(ATTFILE); 
           print POLL @poll_data;                     if ( $giftest ne 'GIF' ) { $okatt = 0; } 
           fclose(POLL);                 } 
       }                 fopen( ATTFILE, "$uploaddir/$fixfile" ); 
       ## write the ctb file for the new thread                 while ( read ATTFILE, $buffer, 1024 ) { 
       ${$newthreadid}{'board'}        = $currentboard;                     if ( $buffer =~ /<(html|script|body)/igxsm ) { 
       ${$newthreadid}{'replies'}      = 0;                        $okatt = 0;
       ${$newthreadid}{'views'}        = 0;                         last; 
       ${$newthreadid}{'lastposter'}   = $iamguest ? "Guest-$name" : $username;                     } 
       ${$newthreadid}{'lastpostdate'} = $newthreadid;                 } 
       ${$newthreadid}{'threadstatus'} = $mstate;                 fclose(ATTFILE); 
       &MessageTotals("update", $newthreadid);                 if ( !$okatt ) {   # delete the file as it contains illegal code 
                     foreach (qw("@filelist" $fixfile)) {
       if (($enable_notifications == 1 || $enable_notifications == 3) && -e "$boardsdir/$currentboard.mail") {                         unlink "$uploaddir/$_"; 
           &ToChars($subject);                     } 
           $subject = &Censor($subject);                     fatal_error( 'file_not_uploaded', 
           &NewNotify($newthreadid, $subject);                         "$fixfile $fatxt{'20a'}" ); 
       }                }
             }
   } else {             push @filelist, $fixfile; 
       # This is an existing thread.         } 
       ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);     } 
     }
       if ($mstate =~ /l/i) { # locked thread  
           my $icanbypass = &checkUserLockBypass if $bypass_lock_perm; # only if bypass switched on     #Create the list of files 
           if (!$icanbypass) { &fatal_error('topic_locked');}     $fixfile = join q{,}, @filelist; 
       }  
       if ($iammod || $iamgmod || $iamadmin) { $mstate = $currentboard eq $annboard ? "0a$thestatus" : "0$thestatus"; } # Leave the status as is if the user isn't allowed to change it     # If no thread specified, this is a new thread. 
     # Find a valid random ID for it.
       # Get the right timeformat for the .ctb file     if ( $threadid eq q{} ) { 
       # First save the user time format         $newthreadid = getnewid(); 
       my $timeformat = ${$uid.$username}{'timeformat'};     } 
       my $timeselect = ${$uid.$username}{'timeselect'};     else { 
       # Override user settings         $newthreadid = q{}; 
       ${$uid.$username}{'timeformat'} = 'SDT, DD MM YYYY HH:mm:ss zzz'; # The .ctb time format     } 
       ${$uid.$username}{'timeselect'} = 7;  
       # Get the time for the .ctb     # set announcement flag according to status of current board 
       my $newtime = &timeformat($date,1,"rfc");     if ($newthreadid) { 
       # Now restore the user settings         $mreplies = 0; 
       ${$uid.$username}{'timeformat'} = $timeformat;         if ($staff) { 
       ${$uid.$username}{'timeselect'} = $timeselect;             $mstate = 
               $currentboard eq $annboard ? "0a$thestatus" : "0$thestatus";
       # First load the current .ctb info but don't close the file befor saving the changed data         } 
       # or you can get wrong .ctb files if two users save at the exact same moment.         else { $mstate = '0'; } 
       # Therfore we can't use &MessageTotals("load", $threadid); her.  
       # File locking should be enabled in AdminCenter!         # This is a new thread. Save it. 
       # Changes here on @tag must also be done in System.pl -> sub MessageTotals -> my @tag = ...         fopen( FILE, "<$boardsdir/$currentboard.txt", 1 ) 
       my @tag = qw(board replies views lastposter lastpostdate threadstatus repliers);           or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); 
       fopen(UPDATE_CTB, "+<$datadir/$threadid.ctb",1) || &fatal_error('cannot_open', "$datadir/$threadid.ctb", 1);         my @buffer = <FILE>; 
       foreach (<UPDATE_CTB>) {         fclose(FILE); 
           if ($_ =~ /^'(.*?)',"(.*?)"/) { ${$threadid}{$1} = $2; }          fopen( FILE, ">$boardsdir/$currentboard.txt", 1 ) 
       }           or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); 
       truncate UPDATE_CTB, 0;         print {FILE} 
       seek UPDATE_CTB, 0, 0;  qq~$newthreadid|$subject|$name|$email|$date|$mreplies|$username|$icon|$mstate\n~ 
       print UPDATE_CTB qq~### ThreadID: $threadid, LastModified: $newtime ###\n\n~;           or croak "$croak{'print'} FILE"; 
         print {FILE} @buffer or croak "$croak{'print'} FILE";
       # Check if thread has moved. And do necessary access check         fclose(FILE); 
       if (${$threadid}{'board'} ne $currentboard) {         fopen( FILE, ">$datadir/$newthreadid.txt" ) 
           if (&AccessCheck(${$threadid}{'board'}, 2) ne "granted") {           or fatal_error( 'cannot_open', "$datadir/$newthreadid.txt", 1 ); 
               for (my $cnt = 0; $cnt < @tag; $cnt++) {         print {FILE} 
                   print UPDATE_CTB qq~'$tag[$cnt]',"${$threadid}{$tag[$cnt]}"\n~;  qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$fixfile\n~ 
               }           or croak "$croak{'print'} FILE"; 
               fclose(UPDATE_CTB);         fclose(FILE); 
               &fatal_error("no_perm_reply");  
           }         if (@filelist) { 
             fopen( AMP, ">>$vardir/attachments.txt" )
           # Thread has moved, but we can still post               or fatal_error( 'cannot_open', "$vardir/attachments.txt" ); 
           # the current board is now the new board.             foreach my $fixfile (@filelist) { 
           $currentboard = ${$threadid}{'board'};                 print {AMP} 
       }  qq~$newthreadid|$mreplies|$subject|$name|$currentboard|$filesizekb{$fixfile}|$date|$fixfile|0\n~ 
                   or croak "$croak{'print'} AMP";
       # update the ctb file for the existing thread with number of replies and lastposter             } 
       ${$threadid}{'board'} = $currentboard;             fclose(AMP); 
       ${$threadid}{'replies'}++;         } 
       ${$threadid}{'lastposter'} = $iamguest ? "Guest-$name" : $username;         if ($pollthread) {    # Save Poll data for new thread 
       ${$threadid}{'lastpostdate'} = $date;             if ( ( $iamadmin || $iamgmod ) && $FORM{'scpoll'} ) 
       ${$threadid}{'threadstatus'} = $mstate;             {                 # Save ShowcasePoll 
                 fopen( SCFILE, ">$datadir/showcase.poll" );
       for (my $cnt = 0; $cnt < @tag; $cnt++) {                 print {SCFILE} $newthreadid or croak "$croak{'print'} SCFILE"; 
           print UPDATE_CTB qq~'$tag[$cnt]',"${$threadid}{$tag[$cnt]}"\n~;                 fclose(SCFILE); 
       }            }
       fclose(UPDATE_CTB);  
       # end of .ctb file saving             fopen( POLL, ">$datadir/$newthreadid.poll" ); 
             print {POLL} @poll_data or croak "$croak{'print'} POLL";
       $mreplies = ${$threadid}{'replies'};             fclose(POLL); 
         }
       if ($pollthread) { # Save new Poll data         ## write the ctb file for the new thread 
           if (($iamadmin || $iamgmod) && $FORM{'scpoll'}) { # Save ShowcasePoll         ${$newthreadid}{'board'}        = $currentboard; 
                   fopen (SCFILE, ">$datadir/showcase.poll");         ${$newthreadid}{'replies'}      = 0; 
                   print SCFILE $threadid;         ${$newthreadid}{'views'}        = 0; 
                   fclose (SCFILE);         ${$newthreadid}{'lastposter'}   = $iamguest ? "Guest-$name" : $username; 
           }         ${$newthreadid}{'lastpostdate'} = $newthreadid; 
           fopen(POLL, ">$datadir/$threadid.poll");         ${$newthreadid}{'threadstatus'} = $mstate; 
           print POLL @poll_data;         MessageTotals( 'update', $newthreadid ); 
           fclose(POLL);  
       }         if ( ( $enable_notifications == 1 || $enable_notifications == 3 ) 
             && -e "$boardsdir/$currentboard.mail" )
       fopen(BOARDFILE, "+<$boardsdir/$currentboard.txt", 1) || &fatal_error("cannot_open","$boardsdir/$currentboard.txt", 1);         { 
       seek BOARDFILE, 0, 0;             ToChars($subject); 
       my @buffer = <BOARDFILE>;             $subject = Censor($subject); 
       truncate BOARDFILE, 0;             NewNotify( $newthreadid, $subject ); 
       seek BOARDFILE, 0, 0;         } 
       for ($i = 0; $i < @buffer; $i++) {     } 
           if ($buffer[$i] =~ m~\A$mnum\|~o) { $buffer[$i] = ""; last; }     else { 
       }  
       print BOARDFILE qq~$mnum|$msub|$mname|$memail|$date|$mreplies|$musername|$micon|$mstate\n~;         # This is an existing thread. 
       print BOARDFILE @buffer;         ( 
       fclose(BOARDFILE);             $mnum,     $msub,      $mname, $memail, $mdate, 
             $mreplies, $musername, $micon, $mstate
       fopen(THREADFILE, ">>$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt", 1);         ) = split /\|/xsm, $yyThreadLine; 
       print THREADFILE qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$fixfile\n~;  
       fclose(THREADFILE);         if ( $mstate =~ /l/ism ) {    # locked thread 
             if ($bypass_lock_perm) {
       if (@filelist) {                 $icanbypass = checkUserLockBypass(); 
           fopen(AMP, ">>$vardir/attachments.txt") || &fatal_error("cannot_open","$vardir/attachments.txt");             }                         # only if bypass switched on 
           foreach $fixfile (@filelist) {             if ( !$icanbypass ) { fatal_error('topic_locked'); } 
               print AMP qq~$mnum|$mreplies|$subject|$name|$currentboard|$filesizekb{$fixfile}|$date|$fixfile|0\n~;         } 
           }         if ($staff) { 
           fclose(AMP);             $mstate = 
       }               $currentboard eq $annboard ? "0a$thestatus" : "0$thestatus"; 
         }    # Leave the status as is if the user isn't allowed to change it
       &ToChars($subject);  
       $subject = &Censor($subject);  # First load the current .ctb info but don't close the file before saving the changed data 
       &ReplyNotify($threadid, $subject, $mreplies) if ($enable_notifications == 1 || $enable_notifications == 3);  # or you can get wrong .ctb files if two users save at the exact same moment. 
   } # end else  # Therefore we can't use &MessageTotals("load", $threadid); here. 
  # File locking should be enabled in AdminCenter!
   if (!$iamguest) {  # Changes here on @tag must also be done in System.pm -> sub MessageTotals -> my @tag = ... 
       ${$uid.$username}{'postlayout'} = qq~$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}~;         my $newtime = ctbtime(); 
         my @tag =
       # Increment post count and lastpost date for the member.           qw(board replies views lastposter lastpostdate threadstatus repliers); 
       # Check whether zeropost board         fopen( UPDATE_CTB, "+<$datadir/$threadid.ctb", 1 ) 
       if (!${$uid.$currentboard}{'zero'}) {           or fatal_error( 'cannot_open', "$datadir/$threadid.ctb", 1 ); 
           ${$uid.$username}{'postcount'}++;         while ( my $aa = <UPDATE_CTB> ) { 
             if ( $aa =~ /^'(.*?)',"(.*?)"/xsm ) {
           if (${$uid.$username}{'position'}) {                 ${$threadid}{$1} = $2; 
               $grp_after = qq~${$uid.$username}{'position'}~;             } 
           } else {         } 
               foreach $postamount (sort { $b <=> $a } keys %Post) {         truncate UPDATE_CTB, 0; 
                   if (${$uid.$username}{'postcount'} >= $postamount) {         seek UPDATE_CTB, 0, 0; 
                       ($title, undef) = split(/\|/, $Post{$postamount}, 2);         print {UPDATE_CTB} 
                       $grp_after = $title;           qq~### ThreadID: $threadid, LastModified: $newtime ###\n\n~ 
                       last;           or croak "$croak{'print'} UPDATE_CTB"; 
                   }  
               }         # Check if thread has moved. And do necessary access check 
           }         if ( ${$threadid}{'board'} ne $currentboard ) { 
           &ManageMemberinfo("update", $username, '', '', $grp_after, ${$uid.$username}{'postcount'});             if ( AccessCheck( ${$threadid}{'board'}, 2 ) ne 'granted' ) { 
       }                 foreach my $cnt ( 0 .. $#tag ) { 
       &UserAccount($username, "update", "lastpost+lastonline");                     print {UPDATE_CTB} 
   }                       qq~'$tag[$cnt]',"${$threadid}{$tag[$cnt]}"\n~ 
                       or croak "$croak{'print'} UPDATE_CTB";
   # The thread ID, regardless of whether it's a new thread or not.                 } 
   $thread = $newthreadid || $threadid;                 fclose(UPDATE_CTB); 
                 fatal_error('no_perm_reply');
   # Let's figure out what page number to show             } 
   $pageindex = int($mreplies / $maxmessagedisplay);  
   $start     = $pageindex * $maxmessagedisplay;             # Thread has moved, but we can still post 
             # the current board is now the new board.
   ${$uid.$currentboard}{'messagecount'}++;             $currentboard = ${$threadid}{'board'}; 
   unless ($FORM{'threadid'}) {         } 
       ${$uid.$currentboard}{'threadcount'}++;  
       ++$threadcount;  # update the ctb file for the existing thread with number of replies and lastposter 
   }         ${$threadid}{'board'} = $currentboard; 
   $myname = $iamguest ? qq~Guest-$name~ : $username;         ${$threadid}{'replies'}++; 
   ${$uid.$currentboard}{'lastposttime'} = $date;         ${$threadid}{'lastposter'}   = $iamguest ? "Guest-$name" : $username; 
   ${$uid.$currentboard}{'lastposter'} = $myname;         ${$threadid}{'lastpostdate'} = $date; 
   ${$uid.$currentboard}{'lastpostid'} = $thread;         ${$threadid}{'threadstatus'} = $mstate; 
   ${$uid.$currentboard}{'lastreply'} = $mreplies;  
   ${$uid.$currentboard}{'lastsubject'} = $doadsubject;         foreach my $cnt ( 0 .. $#tag ) { 
   ${$uid.$currentboard}{'lasttopicstate'} = $mstate;             print {UPDATE_CTB} 
   ${$uid.$currentboard}{'lasticon'} = $icon;                   qq~'$tag[$cnt]',"${$threadid}{$tag[$cnt]}"\n~ 
   &BoardTotals("update", $currentboard);               or croak "$croak{'print'} UPDATE_CTB"; 
         }
   if(!$iamguest) { &Recent_Write("incr", $thread, $username, $date); }         fclose(UPDATE_CTB); 
   
   if ($favorite && !$hasfavorite) {         # end of .ctb file saving 
       require "$sourcedir/Favorites.pl";  
       &AddFav($thread, $mreplies, 1);         $mreplies = ${$threadid}{'replies'}; 
   }  
         if ($pollthread) {    # Save new Poll data
   if ($notify && !$hasnotify) {             if ( ( $iamadmin || $iamgmod ) && $FORM{'scpoll'} ) 
       &ManageThreadNotify("add", $thread, $username, ${$uid.$username}{'language'}, 1, 1);             {                 # Save ShowcasePoll 
   } elsif (!$notify && $hasnotify == 1) {                 fopen( SCFILE, ">$datadir/showcase.poll" ); 
       &ManageThreadNotify("delete", $thread, $username);                 print {SCFILE} $threadid or croak "$croak{'print'} SCFILE"; 
   }                 fclose(SCFILE); 
             }
   if ($currentboard eq $annboard) {             fopen( POLL, ">$datadir/$threadid.poll" ); 
       $yySetLocation = qq~$scripturl?virboard=$FORM{'virboard'};num=$thread/$start#$mreplies~;             print {POLL} @poll_data or croak "$croak{'print'} POLL"; 
   } else {             fclose(POLL); 
       $yySetLocation = qq~$scripturl?num=$thread/$start#$mreplies~;         } 
   }  
         fopen( BOARDFILE, "<$boardsdir/$currentboard.txt", 1 )
   &redirectexit;           or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); 
         my @buffer = <BOARDFILE>;
         fclose( BOARDFILE );
   
         foreach my $i ( 0 .. $#buffer ) {
             if ( $buffer[$i] =~ m{\A$mnum\|}oxsm ) { $buffer[$i] = q{}; last; }
         }
         fopen( BOARDFILE, ">$boardsdir/$currentboard.txt", 1 )
           or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 );
         print {BOARDFILE}
  qq~$mnum|$msub|$mname|$memail|$date|$mreplies|$musername|$micon|$mstate\n~
           or croak "$croak{'print'} BOARDFILE";
         print {BOARDFILE} @buffer or croak "$croak{'print'} BOARDFILE";
         fclose(BOARDFILE);
   
         fopen( THREADFILE, ">>$datadir/$threadid.txt" )
           or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 );
         print {THREADFILE}
  qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$fixfile\n~
           or croak "$croak{'print'} THREADFILE";
         fclose(THREADFILE);
   
         if (@filelist) {
             fopen( AMP, ">>$vardir/attachments.txt" )
               or fatal_error( 'cannot_open', "$vardir/attachments.txt" );
             foreach my $fixfile (@filelist) {
                 print {AMP}
  qq~$mnum|$mreplies|$subject|$name|$currentboard|$filesizekb{$fixfile}|$date|$fixfile|0\n~
                   or croak "$croak{'print'} AMP";
             }
             fclose(AMP);
         }
   
         ToChars($subject);
         $subject = Censor($subject);
         if ( $enable_notifications == 1 || $enable_notifications == 3 ) {
             ReplyNotify( $threadid, $subject, $mreplies );
         }
     }    # end else
   
     if ( !$iamguest ) {
         ${ $uid . $username }{'postlayout'} =
  qq~$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}~;
   
         # Increment post count and lastpost date for the member.
         # Check whether zeropost board
         if ( !${ $uid . $currentboard }{'zero'} ) {
             ${ $uid . $username }{'postcount'}++;
   
             if ( ${ $uid . $username }{'position'} ) {
                 $grp_after = qq~${$uid.$username}{'position'}~;
             }
             else {
                 foreach my $postamount (
                     reverse sort { $a <=> $b }
                     keys %Post
                   )
                 {
                     if ( ${ $uid . $username }{'postcount'} >= $postamount ) {
                         ( $title, undef ) =
                           split /\|/xsm, $Post{$postamount}, 2;
                         $grp_after = $title;
                         last;
                     }
                 }
             }
             ManageMemberinfo( 'update', $username, q{}, q{}, $grp_after,
                 ${ $uid . $username }{'postcount'} );
         }
         UserAccount( $username, 'update', 'lastpost+lastonline' );
     }
   
     # The thread ID, regardless of whether it's a new thread or not.
     $thread = $newthreadid || $threadid;
   
     # Let's figure out what page number to show
     $maxmessagedisplay ||= 10;
     $pageindex = int( $mreplies / $maxmessagedisplay );
     $start     = $pageindex * $maxmessagedisplay;
   
     ${ $uid . $currentboard }{'messagecount'}++;
     if ( !$FORM{'threadid'} ) {
         ${ $uid . $currentboard }{'threadcount'}++;
         ++$threadcount;
     }
     $myname = $iamguest ? qq~Guest-$name~ : $username;
     ${ $uid . $currentboard }{'lastposttime'}   = $date;
     ${ $uid . $currentboard }{'lastposter'}     = $myname;
     ${ $uid . $currentboard }{'lastpostid'}     = $thread;
     ${ $uid . $currentboard }{'lastreply'}      = $mreplies;
     ${ $uid . $currentboard }{'lastsubject'}    = $doadsubject;
     ${ $uid . $currentboard }{'lasttopicstate'} = $mstate;
     ${ $uid . $currentboard }{'lasticon'}       = $icon;
     BoardTotals( 'update', $currentboard );
   
     if ( !$iamguest ) { Recent_Write( 'incr', $thread, $username, $date ); }
   
     if ( $favorite && !$hasfavorite ) {
         require Sources::Favorites;
         AddFav( $thread, $mreplies, 1 );
     }
   
     if ( $notify && !$hasnotify ) {
         ManageThreadNotify( 'add', $thread, $username,
             ${ $uid . $username }{'language'},
             1, 1 );
     }
     elsif ( !$notify && $hasnotify == 1 ) {
         ManageThreadNotify( 'delete', $thread, $username );
     }
   
     my $rts = $FORM{'return_to'};
     if ( $rts == 3 ) {
         $yySetLocation = qq~$scripturl~;
         dumplog( $currentboard, $date );
         dumplog( $thread,       $date );
         if ( !$INFO{'num'} ) { MessageTotals( 'incview', $thread ); }
     }
     elsif ( $rts == 2 ) {
         $yySetLocation = qq~$scripturl?board=$currentboard~;
         dumplog( $thread, $date );
         if ( !$INFO{'num'} ) { MessageTotals( 'incview', $thread ); }
     }
     else {
         if ( $currentboard eq $annboard ) {
             $yySetLocation =
  qq~$scripturl?virboard=$FORM{'virboard'};num=$thread/$start#$mreplies~;
         }
         else {
             $yySetLocation = qq~$scripturl?num=$thread/$start#$mreplies~;
         }
     }
     redirectexit();
     return;
} }
   
# We load all the notification strings from a given language and store them in memory # We load all the notification strings from a given language and store them in memory
sub LoadNotifyMessages { sub LoadNotifyMessages {
   my $languages = shift;    my $languages   = shift;
   my $currentlang = $language;    my $currentlang = $language;
   ${$languages}{$currentlang} = 1; # Load the current language too    ${$languages}{$currentlang} = 1;    # Load the current language too
   
   foreach my $lang (keys %{$languages}) {    foreach my $lang ( keys %{$languages} ) {
       next if $notifystrings{$lang}{'boardnewtopicnotificationemail'}; # next if allready loaded         next 
       $language = $lang;           if $notifystrings{$lang} 
       &LoadLanguage('Email');           {'boardnewtopicnotificationemail'};    # next if already loaded 
       $notifystrings{$lang} = {         $language = $lang; 
           'boardnewtopicnotificationemail' => $boardnewtopicnotificationemail,         LoadLanguage('Email'); 
           'boardnotificationemail' => $boardnotificationemail,         $notifystrings{$lang} = { 
           'topicnotificationemail' => $topicnotificationemail,             'boardnewtopicnotificationemail' => $boardnewtopicnotificationemail, 
       };             'boardnotificationemail'         => $boardnotificationemail, 
       &LoadLanguage('Notify');             'topicnotificationemail'         => $topicnotificationemail, 
       $notifysubjects{$lang} = {         }; 
           '118' => $notify_txt{'118'},         LoadLanguage('Notify'); 
           '136' => $notify_txt{'136'},         $notifysubjects{$lang} = { 
       };             '118' => $notify_txt{'118'}, 
       $notifycharset{$lang} = {             '136' => $notify_txt{'136'}, 
           'emailcharset' => $emailcharset,         }; 
       };        $notifycharset{$lang} = { 'emailcharset' => $emailcharset, };
   }    }
   $language = $currentlang;    $language = $currentlang;
     return;
} }
   
sub NewNotify { sub NewNotify {
   my $thisthread = $_[0];     my ( $thisthread, $thissubject ) = @_; 
   my $thissubject = $_[1];  
   
   my $boardname;     my $thisauthor = ${ $uid . $username }{'realname'} || $maintxt{'28'}; 
   ($boardname, undef) = split(/\|/, $board{$currentboard}, 2);     my $thismessage = $message; 
   &ToChars($boardname);     $thismessage =~ s/ &nbsp; &nbsp; &nbsp;/\t/g; 
     $thismessage =~ s~\[b\](.*?)\[/b\]~*$1*~ig;
   $thissubject .= " ($boardname)";     $thismessage =~ s~\[i\](.*?)\[/i\]~/$1/~ig; 
   $thissubject =~ s/<.*?>//g;     $thismessage =~ s~\[u\](.*?)\[/u\]~_$1_~ig; 
   &FromHTML($thissubject);     $thismessage =~ s/\[.*?\]//g; 
     $thismessage =~ s/<(br|p).*?>/\n/ig;
   require "$sourcedir/Mailer.pl";     $thismessage =~ s~</?([A-Za-z](?>[^\s>/]*))(?>(?:(?>[^>"']+)|"[^"]*"|'[^']*')*)>~~gxsm; 
     FromHTML($thismessage);
   &ManageMemberinfo("load");     $thismessage =~ s/>/&gt;/gsm; 
   &ManageBoardNotify("load", $currentboard);     $thismessage =~ s/</&lt;/gsm; 
   my %languages;     my $boardname; 
   foreach (keys %theboard) {     ( $boardname, undef ) = split /\|/xsm, $board{$currentboard}, 2; 
       $languages{(split(/\|/, $theboard{$_}, 2))[0]} = 1;     ToChars($boardname); 
   }  
   &LoadNotifyMessages(\%languages);     $thissubject .= " ($boardname)"; 
     $thissubject =~ s/<.*?>//gxsm;
   while (my($curuser, $value) = each(%theboard)) {     FromHTML($thissubject); 
       my ($curlang, undef) = split(/\|/, $value, 2);  
       if ($curuser ne $username) {     require Sources::Mailer; 
           &LoadUser($curuser);  
            if (${$uid.$curuser}{'notify_me'} == 1 || ${$uid.$curuser}{'notify_me'} == 3) {     ManageMemberinfo('load'); 
               (undef, $curmail, undef) = split(/\|/, $memberinf{$curuser}, 3);     ManageBoardNotify( 'load', $currentboard ); 
               &sendmail($curmail, "$notifysubjects{$curlang}{'136'}: $thissubject", &template_email($notifystrings{$curlang}{'boardnewtopicnotificationemail'}, {'subject' => $thissubject, 'num' => $thisthread}), '', $notifycharset{$curlang}{'emailcharset'});     my %languages; 
            }     foreach ( keys %theboard ) { 
           undef %{$uid.$curuser};         $languages{ ( split /\|/xsm, $theboard{$_}, 2 )[0] } = 1; 
        }    }
   }     LoadNotifyMessages( \%languages ); 
   undef %theboard;  
   undef %memberinf;     while ( my ( $curuser, $value ) = each %theboard ) { 
         my ( $curlang, undef ) = split /\|/xsm, $value, 2;
         if ( $curuser ne $username ) {
             LoadUser($curuser);
             if (   ${ $uid . $curuser }{'notify_me'} == 1
                 || ${ $uid . $curuser }{'notify_me'} == 3 )
             {
                 ( undef, $curmail, undef ) =
                   split /\|/xsm, $memberinf{$curuser}, 3;
                 sendmail(
                     $curmail,
                     "$notifysubjects{$curlang}{'136'}: $thissubject",
                     template_email(
                         $notifystrings{$curlang}
                           {'boardnewtopicnotificationemail'},
                         { 'subject' => $thissubject, 'num' => $thisthread, 'tauthor' => $thisauthor, 'tmessage' => $thismessage }
                     ),
                     q{},
                     $notifycharset{$curlang}{'emailcharset'}
                 );
             }
             undef %{ $uid . $curuser };
         }
     }
     undef %theboard;
     undef %memberinf;
     return;
} }
   
sub ReplyNotify { sub ReplyNotify {
   my $thisthread = $_[0];     my ( $thisthread, $thissubject, $tem ) = @_; 
   my $thissubject = $_[1];     my $page = qq{$tem#$tem}; 
   my $page = qq~$_[2]#$_[2]~;  
     my $thisauthor = ${ $uid . $username }{'realname'} || $maintxt{'28'};
   my $boardname;     my $thismessage = $message; 
   ($boardname, undef) = split(/\|/, $board{$currentboard}, 2);     $thismessage =~ s/ &nbsp; &nbsp; &nbsp;/\t/gsm; 
   &ToChars($boardname);     $thismessage =~ s~\[b\](.*?)\[/b\]~*$1*~igxsm; 
     $thismessage =~ s~\[i\](.*?)\[/i\]~/$1/~igxsm;
   $thissubject .= " ($boardname)";     $thismessage =~ s~\[u\](.*?)\[/u\]~_$1_~igxsm; 
   $thissubject =~ s/<.*?>//g;     $thismessage =~ s/\[.*?\]//gxsm; 
   &FromHTML($thissubject);     $thismessage =~ s/<(br|p).*?>/\n/igxsm; 
     $thismessage =~ s~</?([A-Za-z](?>[^\s>/]*))(?>(?:(?>[^>"']+)|"[^"]*"|'[^']*')*)>~~igsxm;
   require "$sourcedir/Mailer.pl";     FromHTML($thismessage); 
     $thismessage =~ s/>/&gt;/gxsm;
   my %mailsent;     $thismessage =~ s/</&lt;/gxsm; 
   &ManageMemberinfo("load");     my $boardname; 
   if (-e "$boardsdir/$currentboard.mail") {     ( $boardname, undef ) = split /\|/xsm, $board{$currentboard}, 2; 
       &ManageBoardNotify("load", $currentboard);     ToChars($boardname); 
       my %languages;  
       foreach (keys %theboard) {     $thissubject .= " ($boardname)"; 
           $languages{(split(/\|/, $theboard{$_}, 2))[0]} = 1;     $thissubject =~ s/<.*?>//gxsm; 
       }     FromHTML($thissubject); 
       &LoadNotifyMessages(\%languages);  
     require Sources::Mailer;
       while (my($curuser, $value) = each(%theboard)) {  
           my($curlang, $notify_type, undef) = split(/\|/, $value);     my %mailsent; 
           if ($curuser ne $username && $notify_type == 2) {     ManageMemberinfo('load'); 
               &LoadUser($curuser);     if ( -e "$boardsdir/$currentboard.mail" ) { 
                if (${$uid.$curuser}{'notify_me'} == 1 || ${$uid.$curuser}{'notify_me'} == 3) {         ManageBoardNotify( 'load', $currentboard ); 
                   (undef, $curmail, undef) = split(/\|/, $memberinf{$curuser}, 3);         my %languages; 
                   &sendmail($curmail, "$notifysubjects{$curlang}{'136'}: $thissubject", &template_email($notifystrings{$curlang}{'boardnotificationemail'}, {'subject' => $thissubject, 'num' => $thisthread, 'start' => $page}), '', $notifycharset{$curlang}{'emailcharset'});         foreach ( keys %theboard ) { 
                   $mailsent{$curuser} = 1;            $languages{ ( split /\|/xsm, $theboard{$_}, 2 )[0] } = 1;
                }        }
               undef %{$uid.$curuser};         LoadNotifyMessages( \%languages ); 
            }  
       }         while ( my ( $curuser, $value ) = each %theboard ) { 
       undef %theboard;             my ( $curlang, $notify_type, undef ) = 
   }               split /\|/xsm, $value; 
   if (-e "$datadir/$thisthread.mail") {            if ( $curuser ne $username && $notify_type == 2 ) {
       &ManageThreadNotify("load", $thisthread);                 LoadUser($curuser); 
       my %languages;                 if (   ${ $uid . $curuser }{'notify_me'} == 1 
       foreach (keys %thethread) {                     || ${ $uid . $curuser }{'notify_me'} == 3 ) 
           $languages{(split(/\|/, $thethread{$_}, 2))[0]} = 1;                 { 
       }                     ( undef, $curmail, undef ) = 
       &LoadNotifyMessages(\%languages);                       split /\|/xsm, $memberinf{$curuser}, 3; 
                     sendmail(
       while (my($curuser, $value) = each(%thethread)) {                         $curmail, 
           my($curlang, $notify_type, $hasviewed) = split(/\|/, $value);                         "$notifysubjects{$curlang}{'136'}: $thissubject", 
           if ($curuser ne $username && !exists $mailsent{$curuser} && $hasviewed) {                         template_email( 
               &LoadUser($curuser);                             $notifystrings{$curlang}{'boardnotificationemail'}, 
                if (${$uid.$curuser}{'notify_me'} == 1 || ${$uid.$curuser}{'notify_me'} == 3) {                            {
                   (undef, $curmail, undef) = split(/\|/, $memberinf{$curuser}, 3);                                 'subject' => $thissubject, 
                   &sendmail($curmail, "$notifysubjects{$curlang}{'118'}: $thissubject", &template_email($notifystrings{$curlang}{'topicnotificationemail'}, {'subject' => $thissubject, 'num' => $thisthread, 'start' => $page}), '', $notifycharset{$curlang}{'emailcharset'});                                 'num' => $thisthread, 
                   $thethread{$curuser} = qq~$curlang|$notify_type|0~;                                 'start' => $page, 
               }                                 'tauthor' => $thisauthor, 
               undef %{$uid.$curuser};                                 'tmessage' => $thismessage 
           }                            }
       }                         ), 
       &ManageThreadNotify("save", $thisthread);                         q{}, 
   }                         $notifycharset{$curlang}{'emailcharset'} 
   undef %memberinf;                     ); 
                     $mailsent{$curuser} = 1;
                 }
                 undef %{ $uid . $curuser };
             }
         }
         undef %theboard;
     }
     if ( -e "$datadir/$thisthread.mail" ) {
         ManageThreadNotify( 'load', $thisthread );
         my %languages;
         foreach ( keys %thethread ) {
             $languages{ ( split /\|/xsm, $thethread{$_}, 2 )[0] } = 1;
         }
         LoadNotifyMessages( \%languages );
   
         while ( my ( $curuser, $value ) = each %thethread ) {
             my ( $curlang, $notify_type, $hasviewed ) =
               split /\|/xsm, $value;
             if (   $curuser ne $username
                 && !exists $mailsent{$curuser}
                 && $hasviewed )
             {
                 LoadUser($curuser);
                 if (   ${ $uid . $curuser }{'notify_me'} == 1
                     || ${ $uid . $curuser }{'notify_me'} == 3 )
                 {
                     ( undef, $curmail, undef ) =
                       split /\|/xsm, $memberinf{$curuser}, 3;
                     sendmail(
                         $curmail,
                         "$notifysubjects{$curlang}{'118'}: $thissubject",
                         template_email(
                             $notifystrings{$curlang}{'topicnotificationemail'},
                             {
                                 'subject' => $thissubject,
                                 'num' => $thisthread,
                                 'start' => $page,
                                 'tauthor' => $thisauthor,
                                 'tmessage' => $thismessage
                             }
                         ),
                         q{},
                         $notifycharset{$curlang}{'emailcharset'}
                     );
                     $thethread{$curuser} = qq~$curlang|$notify_type|0~;
                 }
                 undef %{ $uid . $curuser };
             }
         }
         ManageThreadNotify( 'save', $thisthread );
     }
     undef %memberinf;
     return;
} }
   
sub doshowthread { sub doshowthread {
   my ($line, $tempname, $tempdate, $temppost,$amounter);     my ( $line, $tempname, $tempdate ); 
   if ($INFO{'start'}) { $INFO{'start'} = "/$INFO{'start'}"; }    if ( $INFO{'start'} ) { $INFO{'start'} = "/$INFO{'start'}"; }
   
   unless (ref($thread_arrayref{$threadid}) || !$threadid) {  
       fopen(THREADFILE, "$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt", 1);  
       @{$thread_arrayref{$threadid}} = <THREADFILE>;  
       fclose(THREADFILE);  
   }  
   my @messages = @{$thread_arrayref{$threadid}};  
   
   if (@messages) {  
       if (@messages < $cutamount) { $cutamount = @messages; }  
       $yymain .= qq~  
   <br /><br />  
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" style="table-layout: fixed;">  
   <tr><td align="left" class="titlebg" colspan="2">  
~;  
       $showall = $post_cutts{'3'};  
   
       if (@messages => $cutamount && $showpageall) {    if ( !ref( $thread_arrayref{$threadid} ) && $threadid ) {
           $showall .= qq~ $post_cutts{'3a'} <a href="$scripturl?action=post;num=$threadid;title=PostReply$INFO{'start'};showall=yes" style="text-decoration: underline;">$post_cutts{'4'}</a> $post_cutts{'5'} ~;         fopen( THREADFILE, "$datadir/$threadid.txt" ) 
       }           or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 ); 
         @{ $thread_arrayref{$threadid} } = <THREADFILE>;
       if ($INFO{'showall'} ne '' || $cutamount eq 'all') {         fclose(THREADFILE); 
           $origcutamount = $cutamount;     } 
           $cutamount = $pidtxt{'01'};     my @messages = @{ $thread_arrayref{$threadid} }; 
           $showall = qq~$post_cutts{'3'} $post_cutts{'3a'} <a href="$scripturl?action=post;num=$threadid;title=PostReply/$INFO{'start'}" style="text-decoration: underline;"> $post_cutts{'4'}</a> $post_cutts{'6'} ~;  
       }     if (@messages) { 
       $yymain .= qq~         if ( @messages < $cutamount ) { $cutamount = @messages; } 
       <b>$post_txt{'468'} - $post_cutts{'2'} $cutamount $showall</b>         $showall = $post_cutts{'3'}; 
       </td></tr>~;  
       if ($tsreverse == 1) { @messages = reverse(@messages); }         if ( @messages => $cutamount && $showpageall ) { 
       if ($INFO{'showall'} ne '' || $cutamount eq "all") { $cutamount = 1000; }             $showall .= 
       for ($amounter = 0; $amounter < $cutamount; $amounter++) {  qq~ $post_cutts{'3a'} <a href="$scripturl?action=post;num=$threadid;title=PostReply$INFO{'start'};showall=yes" class="under">$post_cutts{'4'}</a> $post_cutts{'5'} ~; 
           (undef, $temprname, undef, $tempdate, $tempname, undef, undef, undef, $message, $ns) = split(/\|/, $messages[$amounter]);         } 
           $messagedate = $tempdate;  
           $tempdate = &timeformat($tempdate);         if ( $INFO{'showall'} ne q{} || $cutamount eq 'all' ) { 
           $parseflash = 0;             $origcutamount = $cutamount; 
             $cutamount     = $pidtxt{'01'};
           if ($tempname ne 'Guest' && -e ("$memberdir/$tempname.vars")) { &LoadUser($tempname); }             $showall = 
           if (${$uid.$tempname}{'regtime'}) {  qq~$post_cutts{'3'} $post_cutts{'3a'} <a href="$scripturl?action=post;num=$threadid;title=PostReply/$INFO{'start'}" class="under"> $post_cutts{'4'}</a> $post_cutts{'6'} ~; 
               $registrationdate = ${$uid.$tempname}{'regtime'};         } 
           } else {         $my_showmess_disnum = qq~ 
               $registrationdate = int(time);             <b>$post_txt{'468'} - $post_cutts{'2'} $cutamount $showall</b>~; 
           }        if ( $tsreverse == 1 ) { @messages = reverse @messages; }
           if (${$uid.$tempname}{'regdate'} && $messagedate > $registrationdate) {        if ( $INFO{'showall'} ne q{} || $cutamount eq 'all' ) {
               $displaynamelink = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$tempname}" class="catbg a">${$uid.$tempname}{'realname'}</a>~;             $cutamount = 1000; 
           } elsif ($tempname !~ m~Guest~ && $messagedate < $registrationdate) {         } 
               $displaynamelink = qq~$tempname - $display_txt{'470a'}~;         foreach my $amounter ( 0 .. ( $cutamount - 1 ) ) { 
           } else {             ( 
               $displaynamelink = $temprname;                 undef, $temprname, undef, $tempdate, $tempname, 
           }                 undef, undef,      undef, $message,  $ns 
             ) = split /\|/xsm, $messages[$amounter];
           $usernames_life_quote{$useraccount{$tempname}} = ${$uid.$tempname}{'realname'}; # for display names in Quotes in LivePreview             $messagedate = $tempdate; 
             $tempdate    = timeformat($tempdate);
           my $quickmessage = $message;             $parseflash  = 0; 
           $quickmessage =~ s/<(br|p).*?>/\\r\\n/ig;  
           $quickmessage =~ s/'/\\'/g;             if ( $tempname ne 'Guest' 
           my $quote_mname = $useraccount{$tempname};                 && -e ("$memberdir/$tempname.vars") ) 
           $quote_mname =~ s/'/\\'/g;             { 
           my $quote_msg_id = $tsreverse == 1 ? (@messages - $amounter -1) : $amounter;                 LoadUser($tempname); 
             }
           &wrap;             if ( ${ $uid . $tempname }{'regtime'} ) { 
           ($message, undef) = &Split_Splice_Move($message,$threadid);                 $registrationdate = ${ $uid . $tempname }{'regtime'}; 
           if ($enable_ubbc) {             } 
               if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }             else { 
               $displayname = ${$uid.$tempname}{'realname'};                 $registrationdate = int time; 
               &DoUBBC;             } 
           }             if ( ${ $uid . $tempname }{'regdate'} 
           &wrap2;                 && ( $messagedate > $registrationdate || $tempname eq 'admin' ) ) 
           &ToChars($message);             { 
           $message = &Censor($message);                 if ( $iamguest) { 
                     $displaynamelink = qq~$format_unbold{$tempname}~;
           unless ($message eq '') {                 } 
               $yymain .= qq~                 else { 
<tr><td align="left" class="catbg">                     $displaynamelink = 
<span class="small">$post_txt{'279'}: $displaynamelink~ . ($enable_markquote ? qq~&nbsp;&nbsp;<a href="javascript:void(quoteSelection('$quote_mname',$threadid,$quote_msg_id,$messagedate,''))">$img{'mquote'}</a>~ : '') . (($enable_quickjump && length($quickmessage) <= $quick_quotelength) ? qq~$menusep<a href="javascript:void(quoteSelection('$quote_mname',$threadid,$quote_msg_id,$messagedate,'$quickmessage'))">$img{'quote'}</a>~ : '') . qq~</span></td>  qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$tempname}">$format_unbold{$tempname}</a>~; 
<td class="catbg" align="right">                 } 
<span class="small">$post_txt{'280'}: $tempdate</span></td>             } 
</tr>             elsif ($tempname !~ m{Guest}sm 
<tr><td class="windowbg2" colspan="2">                 && $messagedate < $registrationdate ) 
<div onmouseup="get_selection($quote_msg_id);" style="max-height: 150px; overflow: auto;">             { 
$message                 $displaynamelink = qq~$tempname - $display_txt{'470a'}~; 
</div>             } 
</td></tr>~;            else { 
           }                 $displaynamelink = $temprname; 
       }            }
       $yymain .= "</table>\n";  
   } else {             my $quickmessage = $message; 
       $yymain .= "<!--no summary-->";             $quickmessage =~ s/<(br|p).*?>/\\r\\n/igsm; 
   }             $quickmessage =~ s/\x27/\\\x27/gxsm; 
             my $quote_mname = $useraccount{$tempname};
             $quote_mname =~ s/\x27/\\\x27/gxsm;
             my $quote_msg_id =
               $tsreverse == 1
               ? ( @messages - $amounter - 1 )
               : $amounter;
   
             wrap();
             ( $message, undef ) = Split_Splice_Move( $message, $threadid );
             if ($enable_ubbc) {
                 enable_yabbc();
                 $displayname = ${ $uid . $tempname }{'realname'};
                 DoUBBC();
             }
             wrap2();
             ToChars($message);
             $message = Censor($message);
   
             if ( $message ne q{} ) {
                 $my_enable_markquote =
                   ( $enable_markquote && $enable_quickreply )
                   ? qq~&nbsp;&nbsp;<a href="javascript:void(quoteSelection('$quote_mname',$threadid,$quote_msg_id,$messagedate,''))">$img{'mquote'}</a>~
                   : q{};
                 $my_enable_quickjump =
                   ( $enable_quickjump
                       && length($quickmessage) <= $quick_quotelength )
                   ? qq~$menusep<a href="javascript:void(quoteSelection('$quote_mname',$threadid,$quote_msg_id,$messagedate,'$quickmessage'))">$img{'quote'}</a>~
                   : q{};
   
                 $my_showmess_mess .= $mypost_showmessages_a;
                 $my_showmess_mess =~
                   s/{yabb displaynamelink}/$displaynamelink/sm;
                 $my_showmess_mess =~
                   s/{yabb my_enable_markquote}/$my_enable_markquote/sm;
                 $my_showmess_mess =~
                   s/{yabb my_enable_quickjump}/$my_enable_quickjump/sm;
                 $my_showmess_mess =~ s/{yabb tempdate}/$tempdate/sm;
                 $my_showmess_mess =~ s/{yabb quote_msg_id}/$quote_msg_id/sm;
                 $my_showmess_mess =~ s/{yabb message}/$message/sm;
   
             }
         }
         $my_showmess = $mypost_showmessages;
         $my_showmess =~ s/{yabb my_showmess_disnum}/$my_showmess_disnum/sm;
         $my_showmess =~ s/{yabb my_showmess_mess}/$my_showmess_mess/sm;
     }
     else {
         $my_showmess .= '<!--no summary-->';
     }
     $yymain .= $my_showmess;
     return;
} }
   
## Guest can send a PM to FA  ## Guest can send a PM to Admin 
## this is a hybrid broadcast message, with fixed audience of FA  ## this is a hybrid broadcast message, with fixed audience of Admin 
## and some guest posting elements in, where id/email are required. ## and some guest posting elements in, where id/email are required.
sub sendGuestPM { sub sendGuestPM {
   if (!$iamguest) { $yySetLocation = $scripturl; &redirectexit; }    if ( !$iamguest ) { $yySetLocation = $scripturl; redirectexit(); }
   if (!$PMenableGuestButton) { &fatal_error('no_access'); }    if ( !$PMenableGuestButton )  { fatal_error('no_access'); }
   if ($PMenableBm_level == 0) { &fatal_error('no_access'); }    if ( $PMenableBm_level == 0 ) { fatal_error('no_access'); }
   
   $INFO{'title'} = 'PostReply';    $INFO{'title'} = 'PostReply';
   $postthread = 2;    $postthread = 2;
   
   $name_field = qq~      <tr>     $guestpost_fields = $mypost_guest_fields; 
   <td class="windowbg" align="left" width="23%"><label for="name"><b>$post_txt{'68'}:</b></label></td>     $guestpost_fields =~ s/{yabb name}/$FORM{'name'}/sm; 
   <td class="windowbg" align="left" width="77%"><input type="text" name="name" id="name" size="25" value="$FORM{'name'}" maxlength="25" tabindex="2" /></td>     $guestpost_fields =~ s/{yabb email}/$FORM{'email'}/sm; 
     </tr>~;  
   $email_field = qq~      <tr>     if ($gpvalid_en) { 
   <td class="windowbg" width="23%"><label for="email"><b>$post_txt{'69'}:</b></label></td>         validation_code(); 
   <td class="windowbg" width="77%"><input type="text" name="email" id="email" size="25" value="$FORM{'email'}" maxlength="40" tabindex="3" /></td>         $verification_field = 
     </tr>~;             $verification eq q{} 
           ? $mypost_guest_c
   if ($gpvalid_en) {           : q{}; 
       &validation_code;         $verification_field =~ s/{yabb showcheck}/$showcheck/sm; 
       $verification_field = $verification eq ''         $verification_field =~ s/{yabb flood_text}/$flood_text/sm; 
       ? qq~  
           <tr>     } 
               <td class="windowbg" width="23%" valign="top"><label for="verification"><b>$floodtxt{'1'}:</b></label></td>     if (   $iamguest 
               <td class="windowbg" width="77%">$showcheck<br /><label for="verification"><span class="small">$floodtxt{'casewarning'}</span></label></td>         && $spam_questions_gp 
           </tr>         && -e "$langdir/$language/spam.questions" ) 
           <tr>     { 
               <td class="windowbg" width="23%" valign="top"><label for="verification"><b>$floodtxt{'3'}:</b></label></td>         SpamQuestion(); 
               <td class="windowbg" width="77%">         my $verification_question_desc; 
               <input type="text" maxlength="30" name="verification" id="verification" size="30" />         if ($spam_questions_case) { 
               </td>             $verification_question_desc = 
           </tr>               qq~<br />$post_txt{'verification_question_case'}~; 
       ~         } 
       : qq~~;         $verification_question_field = 
   }             $verification_question eq q{} 
   $sub = '';           ? $mypost_veri_c 
   $settofield = 'subject';           : q{}; 
   if ($ENV{'HTTP_USER_AGENT'} =~ /(MSIE) (\d)/) {         $verification_question_field =~ 
       if ($2 >= 7.0) { $iecopycheck = ''; } else { $iecopycheck = qq~ checked="checked"~; }           s/{yabb spam_question}/$spam_question/gsm; 
   }         $verification_question_field =~ 
   $t_title = $post_txt{'sendmessguest'};           s/{yabb verification_question_desc}/$verification_question_desc/gsm; 
   $submittxt = $post_txt{'148'};         $verification_question_field =~ 
   $destination = 'guestpm2';           s/{yabb spam_question_id}/$spam_question_id/gsm; 
   $icon = 'exclamation';         $verification_question_field =~ s/{yabb spam_question_image}/$spam_image/gsm; 
   $is_preview  = 0;     } 
   $post = 'guestpm';     $sub        = q{}; 
   $prevmain = '';     $settofield = 'subject'; 
   $preview = 'preview';     $t_title     = $post_txt{'sendmessguest'}; 
   $yytitle = $post_txt{'sendmessguest'};     $submittxt   = $post_txt{'148'}; 
   &Postpage;     $destination = 'guestpm2'; 
   &template;     $icon        = 'alert'; 
     $post        = 'guestpm';
     $prevmain    = q{};
     $yytitle     = $post_txt{'sendmessguest'};
     Postpage();
     template();
     return;
} }
   
sub sendGuestPM2 { sub sendGuestPM2 {
   if (!$iamguest) { $yySetLocation = $scripturl; &redirectexit; }    if ( !$iamguest ) { $yySetLocation = $scripturl; redirectexit(); }
   if (!$PMenableGuestButton) { &fatal_error('no_access'); }    if ( !$PMenableGuestButton )  { fatal_error('no_access'); }
   if ($PMenableBm_level == 0) { &fatal_error('no_access'); }    if ( $PMenableBm_level == 0 ) { fatal_error('no_access'); }
   if ($gpvalid_en) {    if ($gpvalid_en) {
       &validation_check($FORM{'verification'});         validation_check( $FORM{'verification'} ); 
   }    }
     if (   $iamguest
   # Poster is a Guest then evaluate the legality of name and email         && $spam_questions_gp 
   $FORM{'name'} =~ s/\A\s+//;         && -e "$langdir/$language/spam.questions" ) 
   $FORM{'name'} =~ s/\s+\Z//;     { 
   &Preview($post_txt{'75'}) unless ($FORM{'name'} ne '' && $FORM{'name'} ne '_' && $FORM{'name'} ne ' ');         SpamQuestionCheck( $FORM{'verification_question'}, 
   &Preview($post_txt{'568'}) if (length($FORM{'name'}) > 25);             $FORM{'verification_question_id'} ); 
   &Preview($post_txt{'76'}) if ($FORM{'email'} eq '');     } 
   &Preview("$post_txt{'240'} $post_txt{'69'} $post_txt{'241'}") if ($FORM{'email'} !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);  
   &Preview($post_txt{'500'}) if (($FORM{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($FORM{'email'} !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));     # Poster is a Guest then evaluate the legality of name and email 
     $FORM{'name'} =~ s/\A\s+//xsm;
   # Get the form values     $FORM{'name'} =~ s/\s+\Z//xsm; 
   $name = $FORM{'name'};  
   $email = $FORM{'email'};     # Get the form values 
   $subject = $FORM{'subject'};     $name     = $FORM{'name'}; 
   $message = $FORM{'message'};     $email    = $FORM{'email'}; 
   $ns = $FORM{'ns'};     $subject  = $FORM{'subject'}; 
   $threadid = $FORM{'threadid'};     $message  = $FORM{'message'}; 
   $posttime = $FORM{'post_entry_time'};     $ns       = $FORM{'ns'}; 
   if ($threadid =~ /\D/) { &fatal_error("only_numbers_allowed"); }     $threadid = $FORM{'threadid'}; 
     $posttime = $FORM{'post_entry_time'};
   # Check if poster isn't using a distilled email domain     if ( $threadid =~ /\D/xsm ) { fatal_error('only_numbers_allowed'); } 
   &email_domain_check($email);  
   my $spamdetected = &spamcheck("$name $subject $message");     # Check if poster isn't using a distilled email domain 
   ${$uid.$username}{'spamcount'} = 0;     email_domain_check($email); 
   $postspeed = $date - $posttime;     my $spamdetected = spamcheck("$name $subject $message"); 
   if (($speedpostdetection && $postspeed < $min_post_speed) || $spamdetected == 1) {     ${ $uid . $username }{'spamcount'} = 0; 
       ${$uid.$username}{'spamcount'}++;     $postspeed = $date - $posttime; 
       $spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};     if ( ( $speedpostdetection && $postspeed < $min_post_speed ) 
       if ($spamdetected == 1) { &fatal_error('tsc_alert'); } else { &fatal_error('speed_alert'); }         || $spamdetected == 1 ) 
   }     { 
         ${ $uid . $username }{'spamcount'}++;
   ## clean name and email - remove | from name and turn any _ to spaces fro amil         $spam_hits_left_count = 
   if ($name && $email) {           $post_speed_count - ${ $uid . $username }{'spamcount'}; 
       &ToHTML($name);         if   ( $spamdetected == 1 ) { fatal_error('tsc_alert'); } 
       $tempname = $name;         else                        { fatal_error('speed_alert'); } 
       $name =~ s/\_/ /g;     } 
       $email =~ s/\|//g;  
       &ToHTML($email);     ## clean name and email - remove | from email and turn any _ to spaces in name 
   }     if ( $name && $email ) { 
         ToHTML($name);
   # Fixes a bug with posting hexed characters.         $tempname = $name; 
   $name =~ s~amp;~~g;         $name  =~ s/\_/ /gsm; 
         $email =~ s/\|//gxsm;
   &Preview($post_txt{'75'}) unless ($username || $name);         ToHTML($email); 
   &Preview($post_txt{'76'}) unless (${$uid.$username}{'email'} || $email);     } 
   &Preview($post_txt{'77'}) unless ($subject && $subject !~ m~\A[\s_.,]+\Z~);  
   &Preview($post_txt{'78'}) unless ($message);     # Fixes a bug with posting hexed characters. 
     $name =~ s/amp;//gxsm;
   # Check Message Length Precisely  
   my $mess_len = $message;     # Check Message Length Precisely 
   $mess_len =~ s/[\r\n ]//ig;     my $mess_len = $message; 
   $mess_len =~ s/&#\d{3,}?\;/X/ig;     $mess_len =~ s/[\r\n ]//igsm; 
   if (length($mess_len) > $MaxMessLen) {     $mess_len =~ s/&\x23\d{3,}?\;/X/igxsm; 
       &Preview($post_txt{'536'} . " " . (length($mess_len) - $MaxMessLen) . " " . $post_txt{'537'});  
   }     undef $mess_len; 
   undef $mess_len;  
     spam_protection();
   if ($FORM{'preview'}) { &Preview; }  
   &spam_protection;     my $testsub = $subject; 
     $testsub =~ s/[\r\n\ ]|\&nbsp;//gsm;
   my $testsub = $subject;     if ( $testsub eq q{} ) { fatal_error( 'useless_post', $testsub ); } 
   $testsub =~ s/[\r\n\ ]|\&nbsp;//g;  
   if ($testsub eq '') { fatal_error('useless_post', $testsub); }     my $testmessage = regex_1($message); 
     if ( $testmessage eq q{} && $message ne q{} ) {
   my $testmessage = $message;         fatal_error( 'useless_post', $testmessage ); 
   $testmessage =~ s/[\r\n\ ]//g;     } 
   $testmessage =~ s/\&nbsp;//g;  
   $testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;     $subject =~ s/[\r\n]//gxsm; 
   $testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;     FromChars($subject); 
   $testmessage =~ s/\[.*?\]//g;     $convertstr = $subject; 
   if ($testmessage eq '' && $message ne '') { fatal_error('useless_post', $testmessage); }     $convertcut = $set_subjectMaxLength + ( $subject =~ /^Re: /sm ? 4 : 0 ); 
     CountChars();
   $subject =~ s/[\r\n]//g;     $subject = $convertstr; 
   &FromChars($subject);     ToHTML($subject); 
   $convertstr = $subject;     $message = regex_2($message); 
   $convertcut = $set_subjectMaxLength + ($subject =~ /^Re: / ? 4 : 0);  
   &CountChars;     FromChars($message); 
   $subject = $convertstr;     ToHTML($message); 
   &ToHTML($subject);     $message = regex_3($message); 
     CheckIcon();
   $message =~ s/\cM//g;  
   $message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;     if ( -e ("$datadir/.txt") ) { unlink "$datadir/.txt"; } 
   $message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;  
   &FromChars($message);  # User is Guest, then make sure the chosen name and email is not reserved or used by a member 
   &ToHTML($message);     if ( lc $name eq lc MemberIndex( 'check_exist', $name ) ) { 
   $message =~ s~\t~ \&nbsp; \&nbsp; \&nbsp;~g;         fatal_error( 'guest_taken', "($name)" ); 
   $message =~ s~\n~<br />~g;     } 
   $message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;     if ( lc $email eq lc MemberIndex( 'check_exist', $email ) ) { 
   &CheckIcon;         fatal_error( 'guest_taken', "($email)" ); 
     }
   if (-e ("$datadir/.txt")) { unlink("$datadir/.txt"); }  
     # Find a valid random ID for it
   # User is Guest, then make sure the chosen name and email is not reserved or used by a member     $newthreadid = getnewid(); 
   if (lc $name eq lc &MemberIndex('check_exist', $name)) { &fatal_error('guest_taken', "($name)"); }  
   if (lc $email eq lc &MemberIndex('check_exist', $email)) { &fatal_error('guest_taken', "($email)"); }     # Encode spaces in name, to avoid confusing bm 
     $name =~ s/ /%20/gsm;
   # Find a valid random ID for it     $mreplies = 0; 
   $newthreadid = &getnewid;  
   # Encode spaces in name, to avoid confusing bm     # set announcement flag according to status of current board 
   $name =~ s/ /%20/g;     if ( -e "$memberdir/broadcast.messages" ) { 
   $mreplies = 0;         fopen( INBOX, "$memberdir/broadcast.messages" ); 
         @bmessages = <INBOX>;
   # set announcement flag according to status of current board         fclose(INBOX); 
   if(-e "$memberdir/broadcast.messages") {     } 
       fopen(INBOX, "$memberdir/broadcast.messages");     fopen( INBOX, ">$memberdir/broadcast.messages" ); 
       @bmessages = <INBOX>;  
       fclose(INBOX);     # new format:  #messageid|from user|touser(s)|(ccuser(s))|(bccuser(s))| 
   }     #    subject|date|message|(parentmid)|(reply#)|ip| 
   fopen(INBOX, ">$memberdir/broadcast.messages");     #           messagestatus|flags|storefolder|attachment 
   # new format:  #messageid|from user|touser(s)|(ccuser(s))|(bccuser(s))|     print {INBOX} 
   #    subject|date|message|(parentmid)|(reply#)|ip|  "$newthreadid|$name $email|admin|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|g|||\n" 
   #       messagestatus|flags|storefolder|attachment       or croak "$croak{'print'} INBOX"; 
   print INBOX "$newthreadid|$name $email|admin|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|g|||\n";     print {INBOX} @bmessages or croak "$croak{'print'} INBOX"; 
   print INBOX @bmessages;     fclose(INBOX); 
   fclose(INBOX);     undef @bmessages; 
   undef @bmessages;  
     # The thread ID, regardless of whether it's a new thread or not
   # The thread ID, regardless of whether it's a new thread or not     $thread = $newthreadid || $threadid; 
   $thread = $newthreadid || $threadid;     $yySetLocation = $scripturl; 
   $yySetLocation = $scripturl;     redirectexit(); 
   &redirectexit;     return; 
} }
   
sub modAlert { sub modAlert {
   if ($iamguest && !$PMAlertButtonGuests) { &fatal_error('not_logged_in'); }     if ( $iamguest && !$PMAlertButtonGuests ) { 
   if (!$iamguest && !$PMenableAlertButton) { &fatal_error('no_access'); }         fatal_error('not_logged_in'); 
   if ($currentboard eq '' && !$iamguest) { &fatal_error('no_access'); }    }
   if (!$PM_level) { &fatal_error('no_access'); }     if ( !$iamguest && !$PMenableAlertButton ) { 
         fatal_error('no_access');
   my $quotemsg = $INFO{'quote'};     } 
   $postid = $INFO{'quote'};     if ( $currentboard eq q{} && !$iamguest ) { 
   $threadid = $INFO{'num'};         fatal_error('no_access'); 
   my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);     } 
     if ( !$PM_level ) { fatal_error('no_access'); }
   # Determine category  
   $curcat = ${$uid.$currentboard}{'cat'};     my $quotemsg = $INFO{'quote'}; 
   &BoardTotals("load", $currentboard);     $postid   = $INFO{'quote'}; 
     $threadid = $INFO{'num'};
   # Figure out the name of the category     my ( 
   unless ($mloaded == 1) { require "$boardsdir/forum.master"; }         $mnum,     $msub,      $mname, $memail, $mdate, 
   ($cat, $catperms) = split(/\|/, $catinfo{$curcat});         $mreplies, $musername, $micon, $mstate 
   &ToChars($cat);     ) = split /\|/xsm, $yyThreadLine; 
   
   $INFO{'title'} =~ tr/+/ /;     # Determine category 
   $postthread = 2;     $curcat = ${ $uid . $currentboard }{'cat'}; 
     BoardTotals( 'load', $currentboard );
   $name_field = $iamguest ? qq~      <tr>  
   <td class="windowbg" align="left" width="23%"><label for="name"><b>$post_txt{'68'}:</b></label></td>     # Figure out the name of the category 
   <td class="windowbg" align="left" width="77%"><input type="text" name="name" id="name" size="25" value="$FORM{'name'}" maxlength="25" tabindex="2" /></td>     get_forum_master(); 
     </tr>~ : '';     ( $cat, $catperms ) = split /\|/xsm, $catinfo{$curcat}; 
     ToChars($cat);
   $email_field = $iamguest ? qq~      <tr>  
   <td class="windowbg" width="23%"><label for="email"><b>$post_txt{'69'}:</b></label></td>     $INFO{'title'} =~ tr/+/ /; 
   <td class="windowbg" width="77%"><input type="text" name="email" id="email" size="25" value="$FORM{'email'}" maxlength="40" tabindex="3" /></td>     $postthread = 2; 
     </tr>~ : '';  
     $guestpost_fields = q{};
   if ($iamguest && $gpvalid_en) {    if ( $iamguest ) {
       &validation_code;     $guestpost_fields = $mypost_guest_fields; 
       $verification_field = $verification eq '' ? qq~     $guestpost_fields =~ s/{yabb name}/$FORM{'name'}/sm; 
           <tr>     $guestpost_fields =~ s/{yabb email}/$FORM{'email'}/sm; 
               <td class="windowbg" width="23%" valign="top"><label for="verification"><b>$floodtxt{'1'}:</b></label></td>     } 
               <td class="windowbg" width="77%">$showcheck<br /><label for="verification"><span class="small">$floodtxt{'casewarning'}</span></label></td>  
           </tr>     if ( $iamguest && $gpvalid_en ) { 
           <tr>         validation_code(); 
               <td class="windowbg" width="23%" valign="top"><label for="verification"><b>$floodtxt{'3'}:</b></label></td>         $verification_field = 
               <td class="windowbg" width="77%">             $verification eq q{} 
               <input type="text" maxlength="30" name="verification" id="verification" size="30" />           ? $mypost_guest_c 
               </td>           : q{}; 
           </tr>         $verification_field =~ s/{yabb showcheck}/$showcheck/sm; 
       ~ : '';         $verification_field =~ s/{yabb flood_text}/$flood_text/sm; 
   }    }
   
   $sub = '';     if (   $iamguest 
   $settofield = 'subject';         && $spam_questions_gp 
   if ($threadid ne '') {         && -e "$langdir/$language/spam.questions" ) 
       unless (ref($thread_arrayref{$threadid})) {    {
           fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt", 1);         SpamQuestion(); 
           @{$thread_arrayref{$threadid}} = <FILE>;         my $verification_question_desc; 
           fclose(FILE);         if ($spam_questions_case) { 
       }             $verification_question_desc = 
       if ($quotemsg ne '') {               qq~<br />$post_txt{'verification_question_case'}~; 
           ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[$quotemsg]);         } 
           $message = $mmessage;         $verification_question_field = 
           $message =~ s~<br.*?>~\n~ig;             $verification_question eq q{} 
           $message =~ s/ \&nbsp; \&nbsp; \&nbsp;/\t/ig;           ? $mypost_veri_c 
           if (!$nestedquotes) {           : q{}; 
               $message =~ s~\n{0,1}\[quote([^\]]*)\](.*?)\[/quote([^\]]*)\]\n{0,1}~\n~isg;         $verification_question_field =~ 
           }           s/{yabb spam_question}/$spam_question/gsm; 
           $mname ||= $musername || $post_txt{'470'};         $verification_question_field =~ 
           my $hidename = $musername;           s/{yabb verification_question_desc}/$verification_question_desc/gsm; 
           $hidename = $mname if $musername eq 'Guest';         $verification_question_field =~ 
           $hidename = &cloak($hidename) if $do_scramble_id;           s/{yabb spam_question_id}/$spam_question_id/gsm; 
           my $maxlengthofquote = $MaxMessLen - length(qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]\[/quote\]\n~) - 3;         $verification_question_field =~ s/{yabb spam_question_image}/$spam_image/gsm; 
           if (length $message >= $maxlengthofquote) {     } 
               require "$sourcedir/System.pl";  
               &LoadLanguage('Error'); &alertbox($error_txt{'quote_too_long'});     $sub        = q{}; 
               $message = substr($message, 0, $maxlengthofquote) . '...';     $settofield = 'subject'; 
           }     if ( $threadid ne q{} ) { 
           $message    = qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]$message\[/quote\]\n~;         if ( !ref $thread_arrayref{$threadid} ) { 
           $msubject =~ s/\bre:\s+//ig;             fopen( FILE, "$datadir/$threadid.txt" ) 
           if ($mns eq 'NS') { $nscheck = 'checked'; }               or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 ); 
       } else {             @{ $thread_arrayref{$threadid} } = <FILE>; 
           ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[0]);             fclose(FILE); 
           $msubject =~ s/\bre:\s+//ig;         } 
       }         if ( $quotemsg ne q{} ) { 
       $sub = "Re: $msubject";             ( 
       $settofield = 'message';                 $msubject, $mname,   $memail, $mdate,    $musername, 
   }                 $micon,    $mattach, $mip,    $mmessage, $mns 
             ) = split /\|/xsm, ${ $thread_arrayref{$threadid} }[$quotemsg];
   if ($ENV{'HTTP_USER_AGENT'} =~ /(MSIE) (\d)/) {             $message = $mmessage; 
       if($2 >= 7.0) { $iecopycheck = ''; } else { $iecopycheck = qq~ checked="checked"~; }             $message =~ s/<br.*?>/\n/igsm; 
   }             $message =~ s/ \&nbsp; \&nbsp; \&nbsp;/\t/igsm; 
             if ( !$nestedquotes ) {
   $t_title = $post_txt{'alertmod'};                 $message =~ 
   $submittxt = $post_txt{'148'};  s/\n{0,1}\[quote([^\]]*)\](.*?)\[\/quote([^\]]*)\]\n{0,1}/\n/isgxm; 
   $destination = 'modalert2';             } 
   $icon = 'exclamation';             $mname = isempty( $mname, isempty( $musername, $post_txt{'470'} ) ); 
   $is_preview  = 0;             my $hidename = $musername; 
   $post = 'modalert';             if ( $musername eq 'Guest' ) { $hidename = $mname; } 
   $prevmain = '';             if ($do_scramble_id) { $hidename = cloak($hidename); } 
   $preview = 'preview';             my $maxlengthofquote = 
   $yytitle = $post_txt{'alertmod'};               $MaxMessLen - 
   &Postpage;               length( 
   &template;  qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]\[/quote\]\n~ 
               ) - 3;
             if ( length $message >= $maxlengthofquote ) {
                 require Sources::System;
                 LoadLanguage('Error');
                 alertbox( $error_txt{'quote_too_long'} );
                 $message = substr( $message, 0, $maxlengthofquote ) . q{...};
             }
             $message =
  qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]$message\[/quote\]\n~;
             $msubject =~ s/\bre:\s+//igxsm;
             if ( $mns eq 'NS' ) { $nscheck = 'checked'; }
         }
         else {
             (
                 $msubject, $mname,   $memail, $mdate,    $musername,
                 $micon,    $mattach, $mip,    $mmessage, $mns
             ) = split /\|/xsm, ${ $thread_arrayref{$threadid} }[0];
             $msubject =~ s/\bre:\s+//igxsm;
         }
         $sub        = "Re: $msubject";
         $settofield = 'message';
     }
   
     $t_title     = $post_txt{'alertmod'};
     $submittxt   = $post_txt{'148'};
     $destination = 'modalert2';
     $icon        = 'alert';
     $post        = 'modalert';
     $prevmain    = q{};
     $yytitle     = $post_txt{'alertmod'};
     Postpage();
     template();
     return;
} }
   
sub modAlert2 { sub modAlert2 {
   if ($iamguest && !$PMAlertButtonGuests) { &fatal_error('not_logged_in'); }     if ( $iamguest && !$PMAlertButtonGuests ) { 
   if (!$iamguest && !$PMenableAlertButton) { &fatal_error('no_access'); }         fatal_error('not_logged_in'); 
   if (!$PM_level) { &fatal_error('no_access'); }    }
   if ($iamguest && $gpvalid_en) {    if ( !$iamguest && !$PMenableAlertButton ) {
       &validation_check($FORM{'verification'});         fatal_error('no_access'); 
   }    }
     if ( !$PM_level ) { fatal_error('no_access'); }
   # Get the form values     if ( $iamguest && $gpvalid_en ) { 
   $name = $FORM{'name'};         validation_check( $FORM{'verification'} ); 
   $email = $FORM{'email'};     } 
   $subject = $FORM{'subject'};     if (   $iamguest 
   $message = $FORM{'message'};         && $spam_questions_gp 
   $ns = $FORM{'ns'};         && -e "$langdir/$language/spam.questions" ) 
   $threadid = $FORM{'threadid'};     { 
   $postid = $FORM{'postid'};         SpamQuestionCheck( $FORM{'verification_question'}, 
   $posttime = $FORM{'post_entry_time'};             $FORM{'verification_question_id'} ); 
   if ($threadid =~ /\D/) { &fatal_error('only_numbers_allowed'); }    }
   
   if ($iamguest) {     # Get the form values 
       $name =~ s/\A\s+//;     $name     = $FORM{'name'}; 
       $name =~ s/\s+\Z//;     $gname    = $FORM{'name'}; 
       &Preview($post_txt{'75'}) unless ($name ne '' && $name ne '_' && $name ne ' ');     $email    = $FORM{'email'}; 
       &Preview($post_txt{'568'}) if (length($name) > 25);     $subject  = $FORM{'subject'}; 
       &Preview($post_txt{'76'}) if ($email eq '');     $message  = $FORM{'message'}; 
       &Preview("$post_txt{'240'} $post_txt{'69'} $post_txt{'241'}") if ($email !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);     $ns       = $FORM{'ns'}; 
       &Preview($post_txt{'500'}) if (($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($email !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));     $threadid = $FORM{'threadid'}; 
     $postid   = $FORM{'postid'};
       ## clean name and email - remove | from name and turn any _ to spaces fro amil     $posttime = $FORM{'post_entry_time'}; 
       &ToHTML($name);     if ( $threadid =~ /\D/xsm ) { fatal_error('only_numbers_allowed'); } 
       $tempname = $name;  
       $name =~ s/_/ /g;     if ($iamguest) { 
       $email =~ s/\|//g;         $name =~ s/\A\s+//xsm; 
       &ToHTML($email);         $name =~ s/\s+\Z//xsm; 
         ## clean name and email - remove | from name and turn any _ to spaces for email
       # Fixes a bug with posting hexed characters         ToHTML($name); 
       $name =~ s~amp;~~g;         $tempname = $name; 
         $name  =~ s/_/ /gsm;
       # If user is Guest, then make sure the chosen name and email is not reserved or used by a member         $email =~ s/\|//gxsm; 
       if (lc $name eq lc &MemberIndex('check_exist', $name)) { &fatal_error('guest_taken',"($name)"); }         ToHTML($email); 
       if (lc $email eq lc &MemberIndex('check_exist', $email)) { &fatal_error('guest_taken',"($email)"); }  
         # Fixes a bug with posting hexed characters
       # Encode spaces in name, to avoid confusing!         $name =~ s/amp;//gxsm; 
       $name =~ s/ /%20/g;  
       $name .= qq~ $email~;  # If user is Guest, then make sure the chosen name and email is not reserved or used by a member 
   } else {        if ( lc $name eq lc MemberIndex( 'check_exist', $name ) ) {
       $name = $username;             fatal_error( 'guest_taken', "($name)" ); 
   }        }
         if ( lc $email eq lc MemberIndex( 'check_exist', $email ) ) {
   # Check if poster isn't using a distilled email domain             fatal_error( 'guest_taken', "($email)" ); 
   &email_domain_check($email);         } 
   my $spamdetected = &spamcheck("$name $subject $message");  
   if (!${$uid.$FORM{$username}}{'spamcount'}) { ${$uid.$FORM{$username}}{'spamcount'} = 0; }         # Encode spaces in name, to avoid confusing! 
   $postspeed = $date - $posttime;         $name =~ s/ /%20/gsm; 
   if (!$iamadmin && !$iamgmod && !$iammod){         $name .= qq~ $email~; 
       if (($speedpostdetection && $postspeed < $min_post_speed) || $spamdetected == 1) {     } 
           ${$uid.$username}{'spamcount'}++;     else { 
           ${$uid.$username}{'spamtime'} = $date;         $name = $username; 
           &UserAccount($username,"update");     } 
           $spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};  
           if ($spamdetected == 1){ &fatal_error('tsc_alert'); } else { &fatal_error('speed_alert'); }     # Check if poster isn't using a distilled email domain 
       }     email_domain_check($email); 
   }     my $spamdetected = spamcheck("$name $subject $message"); 
     if ( !${ $uid . $FORM{$username} }{'spamcount'} ) {
   &Preview($post_txt{'75'}) unless ($username || $name);         ${ $uid . $FORM{$username} }{'spamcount'} = 0; 
   &Preview($post_txt{'76'}) unless (${$uid.$username}{'email'} || $email);     } 
   &Preview($post_txt{'77'}) unless ($subject && $subject !~ m~\A[\s_.,]+\Z~);     $postspeed = $date - $posttime; 
   &Preview($post_txt{'78'}) unless ($message);     if ( !$staff ) { 
         if ( ( $speedpostdetection && $postspeed < $min_post_speed )
   # Check Message Length Precisely             || $spamdetected == 1 ) 
   my $mess_len = $message;         { 
   $mess_len =~ s/[\r\n ]//ig;             ${ $uid . $username }{'spamcount'}++; 
   $mess_len =~ s/&#\d{3,}?\;/X/ig;             ${ $uid . $username }{'spamtime'} = $date; 
   if (length($mess_len) > $MaxMessLen) {             UserAccount( $username, 'update' ); 
       &Preview($post_txt{'536'} . " " . (length($mess_len) - $MaxMessLen) . " " . $post_txt{'537'});             $spam_hits_left_count = 
   }               $post_speed_count - ${ $uid . $username }{'spamcount'}; 
   undef $mess_len;             if   ( $spamdetected == 1 ) { fatal_error('tsc_alert'); } 
             else                        { fatal_error('speed_alert'); }
   if ($FORM{'preview'}) { &Preview; }        }
   &spam_protection;     } 
   
   $subject =~ s/[\r\n]//g;     spam_protection(); 
   my $tstsubject = $subject;  
   my $testsub = $subject;     $subject =~ s/[\r\n]//gxsm; 
   $testsub =~ s/ |\&nbsp;//g;     my $tstsubject = $subject; 
   if ($testsub eq '') { fatal_error('useless_post', $testsub); }     my $testsub    = $subject; 
     $testsub =~ s/ |\&nbsp;//gsm;
   my $testmessage = $message;     if ( $testsub eq q{} ) { fatal_error( 'useless_post', $testsub ); } 
   $testmessage =~ s/[\r\n\ ]//g;  
   $testmessage =~ s/\&nbsp;//g;     my $testmessage = regex_1($message); 
   $testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;     if ( $testmessage eq q{} && $message ne q{} ) { 
   $testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;         fatal_error( 'useless_post', $testmessage ); 
   $testmessage =~ s/\[.*?\]//g;     } 
   if ($testmessage eq '' && $message ne '') { fatal_error('useless_post', $testmessage); }  
     FromChars($subject);
   &FromChars($subject);     $convertstr = $subject; 
   $convertstr = $subject;     $convertcut = $set_subjectMaxLength + ( $subject =~ /^Re: /sm ? 4 : 0 ); 
   $convertcut = $set_subjectMaxLength + ($subject =~ /^Re: / ? 4 : 0);  
     CountChars();
   &CountChars;     $subject = $convertstr; 
   $subject = $convertstr;     ToHTML($subject); 
   &ToHTML($subject);     $message = regex_2($message); 
   
   $message =~ s/\cM//g;     FromChars($message); 
   $message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;     ToHTML($message); 
   $message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;     $message = regex_3($message); 
   &FromChars($message);  
   &ToHTML($message);     if ( -e ("$datadir/.txt") ) { unlink "$datadir/.txt"; } 
   $message =~ s~\t~ \&nbsp; \&nbsp; \&nbsp;~g;  
   $message =~ s~\n~<br />~g;     # Find a valid random ID for it 
   $message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;     $newthreadid = getnewid(); 
   
   if (-e ("$datadir/.txt")) { unlink("$datadir/.txt"); }     my $x; 
     my $mods    = ${ $uid . $currentboard }{'mods'};
   # Find a valid random ID for it     my $modgrps = ${ $uid . $currentboard }{'modgroups'}; 
   $newthreadid = &getnewid;     $modgrps =~ s/, /,/gsm; 
   
   # This is only for update, when comming from YaBB lower or equal version 2.2.3  # because modgroups are saved with ' ' and this MyCenter.pm does not understand ;-) 
   # I think it can be deleted around version 2.4.0 without causing mayor issues (deti).  # If no BM is allowed and no mods is assigned => send the "AlertMod" to admin 
   if ($enable_notifications eq '') { $enable_notifications = $enable_notification ? 3 : 0; }     if ( !$PMenableBm_level && !$mods ) { 
   # End update workaround         $mods = $mods ? $mods : 'admin'; 
   
   my $x;  # If BM is allowed and no mods and no moderator group is assigned => send the "AlertMod" to admin and gmods via BM 
   my $mods = ${$uid.$currentboard}{'mods'};     } 
   my $modgrps = ${$uid.$currentboard}{'modgroups'};     elsif ( $PMenableBm_level && !$mods && !$modgrps ) { 
   $modgrps =~ s/, /,/g; # because modgroups are saved with ' ' and this MyCenter.pl does not understand ;-)         $modgrps = $PMenableBm_level == 3 ? 'admins' : 'admins,gmods,fmods'; 
   # If no BM is allowed and no mods is assigned => send the "AlertMod" to admin     } 
   if (!$PMenableBm_level && !$mods) {  
       $mods = $mods ? $mods : 'admin';     # Check if there is at least one user in the moderator group 
   # If BM is allowed and no mods and no moderator group is assigned => send the "AlertMod" to admin and gmods via BM     # if not and no mod is assigned too => send the "AlertMod" to admin via PM 
   } elsif ($PMenableBm_level && !$mods && !$modgrps) {    if ( $PMenableBm_level && $modgrps ) {
       $modgrps = $PMenableBm_level == 3 ? "admins" : "admins,gmods";         if ( $modgrps =~ /admins|gmods|fmods|mods/xsm ) { $x = 1; } 
   }         else { 
   # Check if there is at least one user in the moderator group             if ( !%memberinf ) { ManageMemberinfo('load'); } 
   # if not and no mod is assigned too => send the "AlertMod" to admin via PM           MANAGEINFO: foreach ( keys %memberinf ) { 
   if ($PMenableBm_level && $modgrps) {                for ( split /,/xsm, ( split /\|/xsm, $memberinf{$_} )[4] ) {
       if ($modgrps =~ /admins|gmods|mods/) { $x = 1; }                     if ( $_ && $modgrps =~ /\b$_\b/xsm ) { 
       else {                         $x = 1; 
           &ManageMemberinfo("load") if !%memberinf;                         last MANAGEINFO; 
           manageinfo: foreach (keys %memberinf) {                     } 
               map { if ($_ && $modgrps =~ /\b$_\b/) { $x = 1; last manageinfo; } } split(/,/, (split(/\|/, $memberinf{$_}))[4]);                 } 
           }            }
           $mods = 'admin' if !$x && !$mods;             if ( !$x && !$mods ) { $mods = 'admin'; } 
       }        }
   }    }
   if ($mods) {    if ($mods) {
       managemods: foreach my $toBoardMod (split(/, ?/, $mods)) {      MANAGEMODS: foreach my $toBoardMod ( split /, ?/sm, $mods ) {
           chomp $toBoardMod;            chomp $toBoardMod;
           # Send notification (Will only work if Admin has allowed the Email Notification)  
           &LoadUser($toBoardMod);  # Send notification (Will only work if Admin has allowed the Email Notification) 
           if (${$uid.$toBoardMod}{'notify_me'} > 1 && $enable_notifications > 1 && ${$uid.$toBoardMod}{'email'} ne '') {             LoadUser($toBoardMod); 
               require "$sourcedir/Mailer.pl";             if (   ${ $uid . $toBoardMod }{'notify_me'} > 1 
               $language = ${$uid.$toBoardMod}{'language'};                 && $enable_notifications > 1 
               &LoadLanguage('Email');                 && ${ $uid . $toBoardMod }{'email'} ne q{} ) 
               &LoadLanguage('Notify');             { 
               &LoadLanguage('InstantMessage');                 require Sources::Mailer; 
               my $msubject = $tstsubject ? $tstsubject : $inmes_txt{'767'};                 $language = ${ $uid . $toBoardMod }{'language'}; 
               &ToChars($msubject);                 LoadLanguage('Email'); 
               my $chmessage = $message;                 LoadLanguage('Notify'); 
               &ToChars($chmessage);                 LoadLanguage('InstantMessage'); 
               $chmessage =~ s~\[b\](.*?)\[/b\]~*$1*~isg;                 my $msubject = $tstsubject ? $tstsubject : $inmes_txt{'767'}; 
               $chmessage =~ s~\[i\](.*?)\[/i\]~/$1/~isg;                 ToChars($msubject); 
               $chmessage =~ s~\[u\](.*?)\[/u\]~_$1_~isg;                 my $chmessage = $message; 
               $chmessage =~ s~\[.*?\]~~g;                 ToChars($chmessage); 
               $chmessage =~ s~<br.*?>~\n~ig;                 $chmessage = regex_4($chmessage); 
               $chmessage = &template_email($privatemessagenotificationemail, {'date' => &timeformat($date), 'subject' => $msubject, 'sender' => ${$uid.$username}{'realname'}, 'message' => $chmessage});                 $chmessage = template_email( 
               &sendmail(${$uid.$toBoardMod}{'email'}, $notify_txt{'145'}, $chmessage, '', $emailcharset);                     $privatemessagenotificationemail, 
                     {
           } elsif ($PMenableBm_level && $x) {                         'date'    => timeformat($date), 
               &ManageMemberinfo("load") if !%memberinf;                         'subject' => $msubject, 
               map { if ($_ && $modgrps =~ /\b$_\b/) { next managemods; } } split(/,/, (split(/\|/, $memberinf{$toBoardMod}))[4]);                         'sender'  => ${ $uid . $username }{'realname'}, 
           }                         'message' => $chmessage 
                     }
           # Send message to user                 ); 
           fopen(INBOX, "$memberdir/$toBoardMod.msg");                 if ($iamguest) { $fromname = $gname; } 
           my @inmessages = <INBOX>;                 else { $fromname = ${ $uid . $username }{'realname'}; } 
           fclose(INBOX);                 sendmail( 
           fopen(INBOX, ">$memberdir/$toBoardMod.msg");                     ${ $uid . $toBoardMod }{'email'}, 
           # new format: messageid|from user|touser(s)|(ccuser(s))|(bccuser(s))|                     qq~$notify_txt{'145'} $fromname ($msubject)~, 
           #   subject|date|message|(parentmid)|(reply#)|ip|                     $chmessage, q{}, $emailcharset 
           #       messagestatus|flags|storefolder|attachment                 ); 
           print INBOX "$newthreadid|$name|$toBoardMod|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|a|u||\n";             } 
           print INBOX @inmessages;             elsif ( $PMenableBm_level && $x ) { 
           fclose(INBOX);                 if ( !%memberinf ) { ManageMemberinfo('load'); } 
           require "$sourcedir/MyCenter.pl";                 for ( split /,/xsm, 
                     ( split /\|/xsm, $memberinf{$toBoardMod} )[4] )
                 {
                     if ( $_ && $modgrps =~ /\b$_\b/xsm ) { next MANAGEMODS; }
                 }
             }
             if   ($iamguest) { $mstatus = q~ga~; }
             else             { $mstatus = q~a~; }
   
             # Send message to user
             fopen( INBOX, "$memberdir/$toBoardMod.msg" );
             my @inmessages = <INBOX>;
             fclose(INBOX);
             fopen( INBOX, ">$memberdir/$toBoardMod.msg" );
             print {INBOX}
  "$newthreadid|$name|$toBoardMod|||$subject|$date|$message|$newthreadid|0|$user_ip|$mstatus|u||\n" 
               or croak "$croak{'print'} INBOX";
             print {INBOX} @inmessages or croak "$croak{'print'} INBOX";
             fclose(INBOX);
             require Sources::MyCenter;
           updateIMS( $toBoardMod, $newthreadid, 'messagein' );            updateIMS( $toBoardMod, $newthreadid, 'messagein' );
         }
     }
   
       }     if ( $PMenableBm_level && $x ) { 
   }         # set announcement flag according to status of current board 
             if   ($iamguest) { $mstatus = q~ga~; }
   if ($PMenableBm_level && $x) {             else             { $mstatus = q~ab~; } 
       # set announcement flag according to status of current board         #if sender is guest and Alert is going to ModGroup 
       fopen(INBOX, "$memberdir/broadcast.messages") || &fatal_error("cannot_open","$memberdir/broadcast.messages");         fopen( INBOX, "$memberdir/broadcast.messages" ) 
       my @inmessages = <INBOX>;           or fatal_error( 'cannot_open', "$memberdir/broadcast.messages" ); 
       fclose(INBOX);         my @inmessages = <INBOX>; 
       fopen(INBOX, ">$memberdir/broadcast.messages");         fclose(INBOX); 
       # new format:  #messageid|from user|touser(s)|(ccuser(s))|(bccuser(s))|         fopen( INBOX, ">$memberdir/broadcast.messages" ); 
       #    subject|date|message|(parentmid)|(reply#)|ip|         print {INBOX} 
       #       messagestatus|flags|storefolder|attachment  "$newthreadid|$name|$modgrps|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|$mstatus|||\n" 
       print INBOX "$newthreadid|$name|$modgrps|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|ab|||\n";           or croak "$croak{'print'} INBOX"; 
       print INBOX @inmessages;         print {INBOX} @inmessages or croak "$croak{'print'} INBOX"; 
       fclose(INBOX);        fclose(INBOX);
   }    }
   
   $yySetLocation = qq~$scripturl?num=$threadid/$postid#$postid~;    $yySetLocation = qq~$scripturl?num=$threadid/$postid#$postid~;
   &redirectexit;     redirectexit(); 
     return;
} }
   
1; 1;