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