F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Admin\MailMembers.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Admin\MailMembers.pm
############################################################################### ###############################################################################
# MailMembers.pl                                                              # # MailMembers.pm                                                              #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
############################################################################### ###############################################################################
  use CGI::Carp qw(fatalsToBrowser);
  our $VERSION = '2.6.12';
   
$mailmembersplver = 'YaBB 2.5.2 $Revision: 1.1 $'; $mailmemberspmver = 'YaBB 2.6.12 $Revision: 1710 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
if ($iamguest) { &admin_fatal_error("no_access"); } if ($iamguest) { fatal_error('no_access'); }
   
&LoadLanguage('Main');  LoadLanguage('Main'); 
&LoadLanguage('MemberList');  LoadLanguage('MemberList'); 
   
$reused = 0; $reused = 0;
   
sub Mailing { sub Mailing {
   if ($iamguest) { &admin_fatal_error("no_access"); }    if ($iamguest) { fatal_error('no_access'); }
   $yymain .= qq~    $yymain .= qq~
<div style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">  <div class="rightboxdiv"> 
   <table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">     <table class="bordercolor border-space pad-cell"> 
   <tr>  
       <td width="100%" valign="middle" class="titlebg">  
       <span style="float: left;">  
       <img src="$imagesdir/register.gif" alt="" border="0" style="vertical-align: middle;" /><b> $admintxt{'19'}</b>  
       </span>  
       <form action="$adminurl?action=mailinggrps" method="post" name="mailgrps" style="display: inline;">  
       <span style="float: right;">  
           <input type="submit" value="$amv_txt{'53'}" class="button" />  
       </span>  
       </form>  
       </td>  
   </tr>  
   </table>  
   <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>  
   <form name="adv_membermail" action="$adminurl?action=mailing2" method="post" style="display: inline;" onsubmit="return checkIfSelected(); return submitproc();">  
   
   <div class="windowbg2" style="width: 100%; border: 1px #cccccc solid;">  
   <div class="windowbg2" style="float: left; width: 44%; height: 260px; margin: 1%; border: 1px #cccccc solid;">  
   <table border="0" width="98%" cellspacing="0" cellpadding="3" align="center" class="windowbg2">  
   <tr>  
       <td align="left" width="100%"><label for="field1"><b>$amv_txt{'40'}:</b><br /><span class="small">$amv_txt{'46'}</span></label></td>  
   </tr>  
   <tr>  
       <td align="left" width="100%">  
   ~;  
   my $grpselect;  
   my $groupcnt = 0;  
   foreach (sort { $a cmp $b } keys %Group) {  
       unless($_ eq "Moderator") {  
           ($title, $dummy) = split(/\|/, $Group{$_}, 2);  
           $grpselect .= qq~\n<option value="$_"> $title</option>~;  
           $groupcnt++;  
       }  
   }  
   foreach (@nopostorder) {  
       ($title, $dummy) = split(/\|/, $NoPost{$_}, 2);  
       $grpselect .= qq~\n<option value="$_"> $title</option>~;  
       $groupcnt++;  
   }  
   foreach (sort { $b <=> $a } keys %Post) {  
       ($title, $dummy) = split(/\|/, $Post{$_}, 2);  
       $grpselect .= qq~\n<option value="$title"> $title</option>~;  
       $groupcnt++;  
   }  
   if ($groupcnt > 12) { $groupcnt = 12; }  
   $yymain .= qq~  
   <select name="field1" id="field1" size="$groupcnt" multiple="multiple" style="width: 100%; font-size: 11px;">  
   $grpselect  
   </select>  
   <label for="check_all"><b>$amv_txt{"42a"}: </b></label><input type="checkbox" name="check_all" id="check_all" value="1" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="javascript: if (this.checked) selectCheckAll(true); else selectCheckAll(false);" />  
   </td>  
   </tr>  
   </table>  
   </div>  
   ~;  
   
   unless ($groupcnt == 0) {  
   
       $yymain .= qq~  
   <div class="windowbg2" style="float: left; width: 50%; height: 260px; margin: 1%; border: 1px #cccccc solid;">  
   
   <table border="0" width="98%" cellspacing="0" cellpadding="3" align="center" class="windowbg2">  
       <tr>        <tr>
          <td align="left" width="100%"><label for="emailsubject"><b>$amv_txt{'1'}:</b></label></td>             <td class="titlebg"> 
                 $admin_img{'register'}<b> $admintxt{'19'}</b>
                 <form action="$adminurl?action=mailinggrps" method="post" name="mailgrps" style="display: inline;" accept-charset="$yymycharset">
                     <span style="float: right;">
                     <input type="submit" value="$amv_txt{'53'}" class="button" />
                     </span>
                 </form>
             </td>
       </tr>        </tr>
     </table>
     <script src="$yyhtml_root/ubbc.js" type="text/javascript"></script>
     <form name="adv_membermail" action="$adminurl?action=mailing2" method="post" style="display: inline;" onsubmit="return checkIfSelected(); return submitproc();" accept-charset="$yymycharset">
         <div class="windowbg2 border">
             <div class="windowbg2 border" style="float: left; width: 44%; margin: 1%; height:260px">
                 <table class="windowbg2 pad-cell" style="width: 98%">
                     <tr>
                         <td><label for="field1"><b>$amv_txt{'40'}:</b><br /><span class="small">$amv_txt{'46'}</span></label></td>
                     </tr><tr>
                         <td>
  ~;
     my $grpselect;
     my $groupcnt = 0;
     foreach ( sort { $a cmp $b } keys %Group ) {
         if ( $_ ne 'Moderator' ) {
             ( $title, $dummy ) = split /\|/xsm, $Group{$_}, 2;
             $grpselect .= qq~\n<option value="$_"> $title</option>~;
             $groupcnt++;
         }
     }
     foreach (@nopostorder) {
         ( $title, $dummy ) = split /\|/xsm, $NoPost{$_}, 2;
         $grpselect .= qq~\n<option value="$_"> $title</option>~;
         $groupcnt++;
     }
     foreach ( reverse sort { $a <=> $b } keys %Post ) {
         ( $title, $dummy ) = split /\|/xsm, $Post{$_}, 2;
         $grpselect .= qq~\n<option value="$title"> $title</option>~;
         $groupcnt++;
     }
     if ( $groupcnt > 12 ) { $groupcnt = 12; }
     $yymain .= qq~
                             <select name="field1" id="field1" size="$groupcnt" multiple="multiple" style="width: 100%; font-size: 11px;">
                             $grpselect
                             </select>
                             <label for="check_all"><b>$amv_txt{"42a"}: </b></label><input type="checkbox" name="check_all" id="check_all" value="1" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="javascript: if (this.checked) selectCheckAll(true); else selectCheckAll(false);" />
                         </td>
                     </tr>
                 </table>
             </div>
  ~;
   
     if ( $groupcnt != 0 ) {
         $yymain .= qq~
  <div class="windowbg2 border" style="float: left; width: 50%; margin: 1%; height:260px">
     <table class="windowbg2 pad-cell" style="width: 98%">
       <tr>        <tr>
          <td align="left" width="100%"><input type="text" value="" size="40" name="emailsubject" id="emailsubject" style="width: 100%" /></td>             <td><label for="emailsubject"><b>$amv_txt{'1'}:</b></label></td> 
         </tr><tr>
             <td><input type="text" value="" size="40" name="emailsubject" id="emailsubject" style="width: 100%" /></td>
         </tr><tr>
             <td><label for="emailtext"><b>$amv_txt{'2'}:</b></label></td>
         </tr><tr>
             <td><textarea cols="38" rows="9" name="emailtext" id="emailtext" style="width:100%"></textarea></td>
         </tr><tr>
             <td><span class="small">$amv_txt{'39'}</span></td>
       </tr>        </tr>
     </table>
         <input type="hidden" name="reused" value="$reused" />
  </div>
  <div class="windowbg2" style="float: left; width: 44%; margin: 0 1%; border: 0;">
     <table class="windowbg2 pad-cell" style="width: 98%">
       <tr>        <tr>
          <td align="left" width="100%"><label for="emailtext"><b>$amv_txt{'2'}:</b></label></td>             <td class="windowbg2 vtop"><b>$amv_txt{'49'}:</b></td> 
       </tr>        </tr>
     </table>
  </div>
  <div class="windowbg2" style="float: left; width: 50%; margin: 0 1%; border: 0;">
     <table class="windowbg2 pad-cell" style="width: 98%">
       <tr>        <tr>
          <td align="left" width="100%"><textarea cols="38" rows="9" name="emailtext" id="emailtext" style="width:100%"></textarea></td>             <td class="windowbg2 vtop"><b>$amv_txt{'47'}:</b></td> 
       </tr>        </tr>
     </table>
  </div>
  <div class="windowbg2 border" style="float: left; width: 44%; margin: 1%; height:145px">
     <table class="windowbg2 pad-cell" style="width: 98%">
       <tr>        <tr>
       <td align="left" width="100%"><span class="small">$amv_txt{'39'}</span></td>             <td class="windowbg2 vtop"> 
       </tr>                 <span class="small">$amv_txt{'50'}</span> 
   </table>             </td> 
       <input type="hidden" name="reused" value="$reused" />         </tr><tr> 
   </div>             <td class="windowbg2 center vtop"> 
                 <input type="submit" name="convert" value="$amv_txt{'49'}" style="width: 100%;" class="button" />
   <div class="windowbg2" style="float: left; width: 44%; margin: 1%; margin-top: 0; margin-bottom: 0; border: 0;">             </td> 
   <table border="0" width="98%" cellspacing="0" cellpadding="3" align="center" class="windowbg2">         </tr>~; 
   <tr>  
   <td class="windowbg2" align="left" valign="top"><b>$amv_txt{'49'}:</b></td>         if ( -e "$vardir/yabbaddress.csv" ) { 
   </tr>             $yymain .= qq~<tr> 
   </table>             <td class="windowbg2 center vtop"> 
   </div>                 <input type="button" value="$amv_txt{'51'}" class="button" onclick="MailListWin('$adminurl?action=mailing3');" /> 
             </td>
   <div class="windowbg2" style="float: left; width: 50%; margin: 1%; margin-top: 0; margin-bottom: 0; border: 0;">         </tr>~; 
   <table border="0" width="98%" cellspacing="0" cellpadding="3" align="center" class="windowbg2">         } 
   <tr>  
   <td class="windowbg2" align="left" valign="top"><b>$amv_txt{'47'}:</b></td>  
   </tr>  
   </table>  
   </div>  
   
   <div class="windowbg2" style="float: left; width: 44%; height: 145px; margin: 1%; border: 1px #cccccc solid;">  
   <table border="0" width="98%" style="height: 100%" cellspacing="0" cellpadding="3" align="center" class="windowbg2">  
   <tr>  
   <td class="windowbg2" align="left" valign="top">  
       <span class="small">$amv_txt{'50'}</span>  
   </td>  
   </tr>  
   <tr>  
   <td class="windowbg2" align="center" valign="top">  
       <input type="submit" name="convert" value="$amv_txt{'49'}" style="width: 100%;" class="button" />  
   </td>  
   </tr>~;  
   
       if (-e "$vardir/yabbaddress.csv") {  
       $yymain .= qq~  
   <tr>  
   <td class="windowbg2" align="center" valign="top">  
       <input type="button" value="$amv_txt{'51'}" class="button" onclick="MailListWin('$adminurl?action=mailing3');" />  
   </td>  
   </tr>~;  
       }  
   
       $yymain .= qq~  
   </table>  
   </div>  
<script language="JavaScript1.2" type="text/javascript">  
<!--  
   function MailListWin(FileName,WindowName) {  
       WindowFeature="resizable=no,scrollbars=yes,menubar=yes,directories=no,toolbar=no,location=no,status=no,width=400,height=400,screenX=0,screenY=0,top=0,left=0"   
       newWindow=open(FileName,WindowName,WindowFeature);  
       if (newWindow.opener == null) { newWindow.opener = self; }  
       if (newWindow.focus) { newWindow.focus(); }  
   }  
// -->  
</script>  
   
   <div class="windowbg2" style="float: left; width: 50%; height: 145px; margin: 1%; border: 1px #cccccc solid; overflow: auto;">         $yymain .= q~ 
   ~;     </table> 
       if (-e ("$vardir/maillist.dat")) {  </div> 
           fopen(FILE, "$vardir/maillist.dat");  <script type="text/javascript"> 
           @maillist = <FILE>;     function MailListWin(FileName,WindowName) { 
           fclose(FILE);         WindowFeature="resizable=no,scrollbars=yes,menubar=yes,directories=no,toolbar=no,location=no,status=no,width=400,height=400,screenX=0,screenY=0,top=0,left=0"; 
           $yymain .= qq~         newWindow=open(FileName,WindowName,WindowFeature); 
       <table border="0" width="99%" cellspacing="0" cellpadding="3" align="center" class="windowbg2">         if (newWindow.opener === null || newWindow.opener === undefined ) { newWindow.opener = self; } 
       ~;         if (newWindow.focus) { newWindow.focus(); } 
           foreach $curmail (@maillist) {     } 
               chomp $curmail;  </script> 
               ($otime, $osubject, $otext, $osender) = split(/\|/, $curmail);  <div class="windowbg2 border" style="float: left; width: 50%; margin: 1%; overflow: auto; height:145px"> 
               &LoadUser($osender);     ~; 
               $thetime = &timeformat($otime);         if ( -e ("$vardir/maillist.dat") ) { 
             fopen( FILE, "$vardir/maillist.dat" );
               $jsubject = $osubject;             @maillist = <FILE>; 
               $jtext = $otext;             fclose(FILE); 
               &ToJS($jsubject);             $yymain .= q~ 
               &ToJS($jtext);         <table class="windowbg2 pad-cell" style="width: 98%"> 
             <colgroup>
               $yymain .= qq~                 <col span="4" style="width:auto" /> 
           <tr>             </colgroup> 
               <td class="windowbg2" align="left" valign="middle">  ~; 
                   <input type="radio" name="usemail" value="$otime" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="showMail('$jsubject', '$jtext', '$otime');" />             foreach my $curmail (@maillist) { 
               </td>                 chomp $curmail; 
               <td class="windowbg2" align="left" valign="top"><span class="small">$thetime<br />${$uid.$osender}{'realname'}</span></td>                 ( $otime, $osubject, $otext, $osender ) = split /\|/xsm, 
               <td class="windowbg2" align="left" valign="top"><span class="small">$osubject</span></td>                   $curmail; 
               <td class="windowbg2" align="left" valign="middle"><a href="$adminurl?action=deletemail;delmail=$otime"><img src="$imagesdir/admin_rem.gif" border="0" alt="del" /></a></td>                 LoadUser($osender); 
           </tr>                 $thetime = timeformat($otime); 
           ~;  
           }                 $jsubject = $osubject; 
           $yymain .= qq~                 $jtext = $otext; 
       </table>                 ToJS($jsubject); 
       ~;                 ToJS($jtext); 
       }  
       $yymain .= qq~                 $yymain .= qq~<tr> 
   </div>                 <td class="windowbg2"> 
                     <input type="radio" name="usemail" value="$otime" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="showMail('$jsubject', '$jtext', '$otime');" />
   <div class="windowbg2" style="float: left; width: 44%; margin: 1%; margin-top: 0; border: 0;">                 </td> 
   &nbsp;                 <td class="windowbg2 vtop"><span class="small">$thetime<br />${$uid.$osender}{'realname'}</span></td> 
   </div>                 <td class="windowbg2 vtop"><span class="small">$osubject</span></td> 
                 <td class="windowbg2"><a href="$adminurl?action=deletemail;delmail=$otime"><img src="$admin_img{'admin_rem'}" alt="del" /></a></td>
   <div class="windowbg2" style="float: left; width: 50%; margin: 1%; margin-top: 0; border: 0;">             </tr>~; 
   <table border="0" width="100%" cellspacing="0" cellpadding="0">             } 
   <tr>             $yymain .= q~ 
   <td align="center">             <tr><td class="windowbg2 small" colspan="4">&nbsp;</td></tr> 
       <input type="submit" name="mailsend" value="$amv_txt{'41'}" style="width: 100%;" class="button" />         </table> 
   </td>         ~; 
   </tr>         } 
   </table>         $yymain .= qq~ 
   </div>    </div>
     <div class="windowbg2" style="float: left; width: 44%; margin: 1%; margin-top: 0; border: 0;">
<div style="clear: both;"></div>     &nbsp; 
     </div>
     <div class="windowbg2" style="float: left; width: 50%; margin: 1%; margin-top: 0; border: 0;">
         <table>
             <tr>
                 <td class="center"><input type="submit" name="mailsend" value="$amv_txt{'41'}" style="width: 100%;" class="button" /></td>
             </tr>
         </table>
     </div>
     <div style="clear: both;"></div>
</div> </div>
   
</form> </form>
   
<script type="text/javascript"> <script type="text/javascript">
function checkIfSelected() { function checkIfSelected() {
   for(var x = 0; x < document.adv_membermail.field1.options.length; x++) if(document.adv_membermail.field1.options[x].selected) return true;     if( document.adv_membermail.field1.options.selectedIndex == -1 ) { 
   alert("$amv_txt{'48a'}"); return false;         alert("$amv_txt{'48a'}"); 
}          return false; 
     } else {
     return true;
     }
  }
   
function selectCheckAll(tchecked) { function selectCheckAll(tchecked) {
   for(var x = 0; x < document.adv_membermail.field1.options.length; x++) document.adv_membermail.field1.options[x].selected = tchecked;    for(var x = 0; x < document.adv_membermail.field1.options.length; x++) document.adv_membermail.field1.options[x].selected = tchecked;
} }
   
function showMail(thesubject, thetext, thetime) { function showMail(thesubject, thetext, thetime) {
   thetext=thetext.replace(/\<br \\/\>/g, "\\n");    thetext=thetext.replace(/\<br \\/\>/g, "\\n");
   document.adv_membermail.emailsubject.value = thesubject;    document.adv_membermail.emailsubject.value = thesubject;
   document.adv_membermail.emailtext.value = thetext;    document.adv_membermail.emailtext.value = thetext;
   document.adv_membermail.reused.value = thetime;    document.adv_membermail.reused.value = thetime;
} }
//-->  
</script> </script>
</div> </div>
   ~;    ~;
   }    }
   
   $yytitle = $admin_txt{'6'};    $yytitle = $admin_txt{'6'};
   $action_area = 'mailing';    $action_area = 'mailing';
   &AdminTemplate;     AdminTemplate(); 
     return;
} }
   
sub Mailing2 { sub Mailing2 {
   if ($iamguest) { &fatal_error('no_access'); }    if ($iamguest) { fatal_error('no_access'); }
   if (!$FORM{'mailsend'} && !$FORM{'convert'}) { &fatal_error('no_access'); }    if ( !$FORM{'mailsend'} && !$FORM{'convert'} ) { fatal_error('no_access'); }
   @convlist = ();    @convlist = ();
   if ($FORM{'mailsend'} && $FORM{'emailtext'} ne '') {    if ( $FORM{'mailsend'} && $FORM{'emailtext'} ne q{} ) {
       $FORM{'emailsubject'} =~ s~\|~&#124;~g;         $FORM{'emailsubject'} =~ s/\|/&\x23124;/gsm; 
       $FORM{'emailtext'} =~ s~\|~&#124;~g;         $FORM{'emailtext'}    =~ s/\|/&\x23124;/gsm; 
       $FORM{'emailtext'} =~ s~\r~~g;         $FORM{'emailtext'}    =~ s/\r//gsm; 
       $mailline = qq~$date|$FORM{'emailsubject'}|$FORM{'emailtext'}|$username~;         $mailline = 
       &MailList($mailline);           qq~$date|$FORM{'emailsubject'}|$FORM{'emailtext'}|$username~; 
   }         MailList($mailline); 
   (@mailgroups) = split(/\, /, $FORM{'field1'});     } 
   &ManageMemberinfo("load");     (@mailgroups) = split /\, /sm, $FORM{'field1'}; 
   $i = 0;     ManageMemberinfo('load'); 
   my ($emailsubject,$emailtext);     $i = 0; 
   foreach my $user (keys %memberinf) {     my ( $emailsubject, $emailtext ); 
       ($memrealname, $mememail, $memposition, $memposts, $memaddgrp) = split(/\|/, $memberinf{$user} );     foreach my $user ( keys %memberinf ) { 
       &FromHTML($memrealname);         ( $memrealname, $mememail, $memposition, $memposts, $memaddgrp ) = 
           split /\|/xsm, $memberinf{$user};
       if ($FORM{'mailsend'} && $FORM{'emailtext'} ne '') {         FromHTML($memrealname); 
           $emailsubject = $FORM{'emailsubject'};  
           $emailsubject =~ s~\[name\]~$memrealname~ig;         if ( $FORM{'mailsend'} && $FORM{'emailtext'} ne q{} ) { 
           $emailsubject =~ s~\[username\]~$user~ig;             $emailsubject = $FORM{'emailsubject'}; 
           $emailtext = $FORM{'emailtext'};             $emailsubject =~ s/\[name\]/$memrealname/igxsm; 
           $emailtext =~ s~\[name\]~$memrealname~ig;             $emailsubject =~ s/\[username\]/$user/igxsm; 
           $emailtext =~ s~\[username\]~$user~ig;             $emailtext = $FORM{'emailtext'}; 
       }             $emailtext =~ s/\[name\]/$memrealname/igxsm; 
             $emailtext =~ s/\[username\]/$user/igxsm;
       $mailit = 0;         } 
       foreach $element (@mailgroups) {  
           chomp $element;         $mailit = 0; 
           if ($element eq $memposition) { $mailit = 1; }         foreach my $element (@mailgroups) { 
           foreach $memberaddgroups (split(/, /, $memaddgrp)) {             chomp $element; 
               chomp $memberaddgroups;             if ( $element eq $memposition ) { $mailit = 1; } 
               if ($element eq $memberaddgroups) { $mailit = 1; last; }             foreach my $memberaddgroups ( split /, /sm, $memaddgrp ) { 
           }                 chomp $memberaddgroups; 
           if ($mailit) { last; }                if ( $element eq $memberaddgroups ) { $mailit = 1; last; }
       }            }
       if ($mailit && $FORM{'mailsend'}) {             if ($mailit) { last; } 
           require "$sourcedir/Mailer.pl";         } 
           &sendmail($mememail, $emailsubject, $emailtext);         if ( $mailit && $FORM{'mailsend'} ) { 
       } elsif ($mailit && $FORM{'convert'}) {             require Sources::Mailer; 
           if ($memrealname =~ /&#(\d{3,}?)\;/ig) { $memrealname = $user; }             sendmail( $mememail, $emailsubject, $emailtext ); 
           $convlist[$i] = qq~$memrealname\;$mememail\n~;         } 
           $i++;         elsif ( $mailit && $FORM{'convert'} ) { 
       }            if ( $memrealname =~ /&\x23(\d{3,}?)\;/igxsm ) { $memrealname = $user; }
   }             $convlist[$i] = qq~$memrealname\;$mememail\n~; 
   undef %memberinf;             $i++; 
   if (@convlist) {         } 
       fopen(ADDRESSLIST, ">$vardir/yabbaddress.csv", 1);     } 
       print ADDRESSLIST "Name\;E-mail Address\n";     undef %memberinf; 
       print ADDRESSLIST @convlist;     if (@convlist) { 
       fclose(ADDRESSLIST);         fopen( ADDRESSLIST, ">$vardir/yabbaddress.csv", 1 ); 
   } elsif ($FORM{'convert'}) {         print {ADDRESSLIST} "Name\;E-mail Address\n" 
       unlink "$vardir/yabbaddress.csv"           or croak "$croak{'print'} ADDRESSLIST"; 
   }         print {ADDRESSLIST} @convlist or croak "$croak{'print'} ADDRESSLIST"; 
         fclose(ADDRESSLIST);
   $yySetLocation = qq~$adminurl?action=mailing~;     } 
   &redirectexit;     elsif ( $FORM{'convert'} ) { 
         unlink "$vardir/yabbaddress.csv";
     }
   
     $yySetLocation = qq~$adminurl?action=mailing~;
     redirectexit();
     return;
} }
   
sub Mailing3 { sub Mailing3 {
   fopen(FILE, "$vardir/yabbaddress.csv");     fopen( FILE, "$vardir/yabbaddress.csv" ); 
   @addlist = <FILE>;    @addlist = <FILE>;
   fclose(FILE);    fclose(FILE);
   print qq~Content-disposition: inline; filename=yabbaddress.csv\n\n~;     print qq~Content-disposition: inline; filename=yabbaddress.csv\n\n~ or croak "$croak{'print'} yabbaddress"; 
   foreach $curadd (@addlist) {    foreach my $curadd (@addlist) {
       chomp $curadd;        chomp $curadd;
       print qq~$curadd\n~;         print qq~$curadd\n~ or croak "$croak{'print'} yabbaddress"; 
   }    }
     return;
} }
   
sub MailingMembers { sub MailingMembers {
   $sortmode = "";     $sortmode = q{}; 
   $selPos   = "";     $selPos   = q{}; 
   $selUser  = "";     $selUser  = q{}; 
   
   if ($FORM{'sortform'} eq "position") { $selPos = qq~ selected="selected"~; }     if ( $FORM{'sortform'} eq 'position' ) { 
   else { $selUser = qq~ selected="selected"~; }         $selPos = q~ selected="selected"~; 
     }
   if    ($INFO{'sort'}     ne "") { $sortmode = ";sort=" . $INFO{'sort'}; }    else { $selUser = q~ selected="selected"~; }
   elsif ($FORM{'sortform'} ne "") { $sortmode = ";sort=" . $FORM{'sortform'}; }  
     if ( $INFO{'sort'} ne q{} ) { $sortmode = ';sort=' . $INFO{'sort'}; }
   if ($iamguest) { &admin_fatal_error("no_access"); }     elsif ( $FORM{'sortform'} ne q{} ) { 
   $yymain .= qq~         $sortmode = ';sort=' . $FORM{'sortform'}; 
<div style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">     } 
   <table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">  
   <tr>     if ($iamguest) { fatal_error('no_access'); } 
       <td width="100%" valign="middle" class="titlebg">     $yymain .= qq~ 
       <span style="float: left;">  <div class="rightboxdiv"> 
       <img src="$imagesdir/register.gif" alt="" border="0" style="vertical-align: middle;" /><b> $admintxt{'19'}</b>     <table class="bordercolor border-space pad-cell"> 
       </span>     <tr> 
       <form action="$adminurl?action=mailinggrps" method="post" name="selsort" style="display: inline">             <td class="titlebg"> 
       <span style="float: right;">         <span style="float: left;"> 
       <label for="sortform"><b>$ml_txt{'1'}</b></label>              $admin_img{'register'}<b> $admintxt{'19'}</b> 
       <select name="sortform" id="sortform" style="font-size: 9pt;" onchange="submit()">         </span> 
           <option value="username"$selUser>$ml_txt{'35'}</option>                 <form action="$adminurl?action=mailinggrps" method="post" name="selsort" style="display: inline" accept-charset="$yymycharset"> 
           <option value="position"$selPos>$ml_txt{'87'}</option>         <span style="float: right;"> 
       </select>         <label for="sortform"><b>$ml_txt{'1'}</b></label> 
       &nbsp;         <select name="sortform" id="sortform" style="font-size: 9pt;" onchange="submit()"> 
       <input type="button" value="$amv_txt{'54'}" class="button" onclick="window.location.href=\'$adminurl?action=mailing\'" />             <option value="username"$selUser>$ml_txt{'35'}</option> 
       </span>             <option value="position"$selPos>$ml_txt{'87'}</option> 
       </form>         </select> 
       </td>         &nbsp; 
   </tr>         <input type="button" value="$amv_txt{'54'}" class="button" onclick="window.location.href=\'$adminurl?action=mailing\'" /> 
   </table>         </span> 
   <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>         </form> 
   <form name="adv_membermail" action="$adminurl?action=mailmultimembers;$sortmode" method="post" style="display: inline" onsubmit="return checkIfChecked(this); return submitproc()">         </td> 
   <input type="hidden" name="button" value="1" />     </tr> 
     </table>
   <div class="windowbg2" style="width: 100%; border: 1px #cccccc solid;">     <script src="$yyhtml_root/ubbc.js" type="text/javascript"></script> 
     <form name="adv_membermail" action="$adminurl?action=mailmultimembers;$sortmode" method="post" style="display: inline" onsubmit="return checkIfChecked(this); return submitproc()" accept-charset="$yymycharset">
   <div class="windowbg" style="float: left; width: 44%; height: 260px; margin: 1%; border: 1px #cccccc inset; overflow: auto;">     <input type="hidden" name="button" value="1" /> 
   <table border="0" width="99%" cellspacing="0" cellpadding="3" class="windowbg">     <div class="windowbg2 border"> 
   ~;         <div class="windowbg border" style="float: left; width: 44%; margin: 1%; overflow: auto; height:260px"> 
             <table class="windowbg pad-cell" style="width:98%">
   %TopMembers = ();     ~; 
   
   &ManageMemberinfo("load");     %TopMembers = (); 
   while (($membername, $value) = each(%memberinf)) {  
       ($memberrealname, undef, $memposition, $memposts) = split(/\|/, $value);     ManageMemberinfo('load'); 
       $pstsort    = 99999999 - $memposts;     while ( ( $membername, $value ) = each %memberinf ) { 
       $sortgroups = "";         ( $memberrealname, undef, $memposition, $memposts ) = split /\|/xsm, 
       $j          = 0;           $value; 
         $pstsort    = 99_999_999 - $memposts;
       if ($membername eq $username) {         $sortgroups = q{}; 
           $sortgroups = "!!!";         $j          = 0; 
       } else {  
           if ($FORM{'sortform'} eq "position" || $INFO{'sort'} eq "position") {        if ( $membername eq $username ) {
               foreach my $key (keys %Group) {             $sortgroups = '!!!'; 
                   if ($memposition eq $key) {         } 
                       if    ($key eq "Administrator")    { $sortgroups = "aaa.$pstsort.$memberrealname"; }         else { 
                       elsif ($key eq "Global Moderator") { $sortgroups = "bbb.$pstsort.$memberrealname"; }             if (   $FORM{'sortform'} eq 'position' 
                   }                 || $INFO{'sort'} eq 'position' ) 
               }             { 
               if (!$sortgroups) {                foreach my $key ( keys %Group ) {
                   foreach (sort { $a <=> $b } keys %NoPost) {                     if ( $memposition eq $key ) { 
                       if ($memposition eq $_) {                        if ( $key eq 'Administrator' ) {
                           $sortgroups = "ddd.$memposition.$pstsort.$memberrealname";                             $sortgroups = "aaa.$pstsort.$memberrealname"; 
                       }                        }
                   }                         elsif ( $key eq 'Global Moderator' ) { 
               }                             $sortgroups = "bbb.$pstsort.$memberrealname"; 
               if (!$sortgroups) {                         } 
                   $sortgroups = "eee.$pstsort.$memposition.$memberrealname";                         elsif ( $key eq 'Mid Moderator' ) { 
               }                             $sortgroups = "bcc.$pstsort.$memberrealname"; 
                         }
           } else {                     } 
               $sortgroups = $memberrealname;                 } 
           }                 if ( !$sortgroups ) { 
       }                     foreach ( sort { $a <=> $b } keys %NoPost ) { 
       $TopMembers{$membername} = $sortgroups;                         if ( $memposition eq $_ ) { 
   }                             $sortgroups = 
   my @toplist = sort { lc $TopMembers{$a} cmp lc $TopMembers{$b} } keys %TopMembers;                               "ddd.$memposition.$pstsort.$memberrealname"; 
                         }
   $memcount = @toplist;                     } 
                 }
   $b         = 0;                 if ( !$sortgroups ) { 
   $numshown  = 0;                     $sortgroups = "eee.$pstsort.$memposition.$memberrealname"; 
   $actualnum = 0;                 } 
   
   while (($numshown < $memcount)) {             } 
       $user = $toplist[$b];             else { 
                 $sortgroups = $memberrealname;
       ($memrealname, $mememail, $memposition, $memposts) = split(/\|/, $memberinf{$user});             } 
         }
       if ($user eq $username) { $bagcolor = "windowbg2"; }         $TopMembers{$membername} = $sortgroups; 
       else { $bagcolor = "windowbg"; }    }
       if ($memrealname ne "") {     my @toplist = 
       sort { lc $TopMembers{$a} cmp lc $TopMembers{$b} } keys %TopMembers;
           $addel = qq~<input type="checkbox" name="member$actualnum" value="$user" class="windowbg" style="border: 0;" />~;  
           $actualnum++;     $memcount = @toplist; 
   
           my $memberinfo = "$memposition";     $bb        = 0; 
           if ($memberinfo eq "Administrator") {     $numshown  = 0; 
               ($memberinfo, undef) = split(/\|/, $Group{"Administrator"}, 2);     $actualnum = 0; 
           } elsif ($memberinfo eq "Global Moderator") {  
               ($memberinfo, undef) = split(/\|/, $Group{"Global Moderator"}, 2);     while ( ( $numshown < $memcount ) ) { 
           } else {         $user = $toplist[$bb]; 
               foreach my $key (sort { $a <=> $b } keys %NoPost) {  
                   if ($key eq $memberinfo) {         ( $memrealname, $mememail, $memposition, $memposts ) = split /\|/xsm, 
                       ($memberinfo, undef) = split(/\|/, $NoPost{$key}, 2);           $memberinf{$user}; 
                   }  
               }        if   ( $user eq $username ) { $bagcolor = 'windowbg2'; }
           }        else                        { $bagcolor = 'windowbg'; }
         if ( $memrealname ne q{} ) {
           $viewmembinfo = $memberinfo;             $addel = 
           &ToJS($memberinfo);  qq~<input type="checkbox" name="member$actualnum" value="$user" class="windowbg" style="border: 0;" />~; 
           $tmp_postcount = $memposts;             $actualnum++; 
           $checkinfo     = $memberinfo;  
           $checkinfo =~ s/\, /\'\|\'/g;             my $memberinfo = "$memposition"; 
           $CheckingAll .= qq~"'$checkinfo'", ~;             if ( $memberinfo eq 'Administrator' ) { 
                 ( $memberinfo, undef ) = split /\|/xsm, $Group{'Administrator'},
           if ($do_scramble_id) { $cloakusername = &cloak($user); } else { $cloakusername = $user; }                   2; 
           $linkuser = qq~<a href="$scripturl?action=viewprofile;username=$cloakusername"><b>$memrealname</b></a>~;             } 
             elsif ( $memberinfo eq 'Global Moderator' ) {
           $yymain .= qq~                 ( $memberinfo, undef ) = split /\|/xsm, 
           <tr>                   $Group{'Global Moderator'}, 2; 
           <td class="$bagcolor" align="center" valign="middle">$addel</td>             } 
           <td class="$bagcolor" align="left" valign="middle">$linkuser - $viewmembinfo</td>             elsif ( $memberinfo eq 'Mid Moderator' ) { 
           </tr>~;                 ( $memberinfo, undef ) = split /\|/xsm, 
       }                   $Group{'Mid Moderator'}, 2; 
             }
       $numshown++;             else { 
       $b++;                 foreach my $key ( sort { $a <=> $b } keys %NoPost ) { 
   }                     if ( $key eq $memberinfo ) { 
   undef @toplist;                         ( $memberinfo, undef ) = split /\|/xsm, $NoPost{$key}, 
   undef %memberinf;                           2; 
                     }
   $yymain .= qq~                 } 
   </table>             } 
   </div>  
   ~;             $viewmembinfo = $memberinfo; 
             ToJS($memberinfo);
   unless ($memcount == 0) {             $tmp_postcount = $memposts; 
       if ($FORM{'sortform'} eq "") { $FORM{'sortform'} = $INFO{'sort'}; }             $checkinfo     = $memberinfo; 
       if (!$FORM{'reversed'}) { $FORM{'reversed'} = $INFO{'reversed'}; }             $checkinfo =~ s/\, /\'\|\'/gsm; 
             $CheckingAll .= qq~"'$checkinfo'", ~;
       @groupinfo = ();  
       $i         = 0;             if   ($do_scramble_id) { $cloakusername = cloak($user); } 
       $z         = 0;             else                   { $cloakusername = $user; } 
             ToChars($memrealname);
       ($title, $dummy) = split(/\|/, $Group{"Administrator"}, 2);             $linkuser = 
       &ToJS($title);  qq~<a href="$scripturl?action=viewprofile;username=$cloakusername"><b>$memrealname</b></a>~; 
       $groupinfo[$i] = $title;  
       $i++;             $yymain .= qq~<tr> 
       $grp_data = qq~"'$title'", ~;                 <td class="$bagcolor center">$addel</td> 
       ($title, $dummy) = split(/\|/, $Group{"Global Moderator"}, 2);                 <td class="$bagcolor">$linkuser - $viewmembinfo</td> 
       &ToJS($title);             </tr>~; 
       $groupinfo[$i] = $title;         } 
       $i++;  
       $grp_data .= qq~"'$title'", ~;         $numshown++; 
         $bb++;
       foreach (@nopostorder) {     } 
           ($title, $dummy) = split(/\|/, $NoPost{$_}, 2);     undef @toplist; 
           &ToJS($title);     undef %memberinf; 
           $groupinfo[$i] = $title;  
           $grp_data .= qq~"'$title'", ~;     $yymain .= q~ 
           $i++;     </table> 
           $z++;     </div> 
       }     ~; 
   
       $groupcnt = $i;     if ( $memcount != 0 ) { 
       $grp_data .= qq~""~;         if ( $FORM{'sortform'} eq q{} ) { $FORM{'sortform'} = $INFO{'sort'}; } 
         if ( !$FORM{'reversed'} ) { $FORM{'reversed'} = $INFO{'reversed'}; }
       $yymain .= qq~  
   <div class="windowbg2" style="float: left; width: 50%; height: 260px; margin: 1%; padding: 4px; border: 1px #cccccc solid;">         @groupinfo = (); 
         $i         = 0;
   <table border="0" width="100%" cellspacing="0" cellpadding="2" class="windowbg2">         $z         = 0; 
       <tr>  
          <td align="left" width="100%"><label for="emailsubject"><b>$amv_txt{'1'}:</b></label></td>         ( $title, $dummy ) = split /\|/xsm, $Group{'Administrator'}, 2; 
       </tr>         ToJS($title); 
       <tr>         $groupinfo[$i] = $title; 
          <td align="left" width="100%"><input type="text" value="" size="40" name="emailsubject" id="emailsubject" style="width: 100%" /></td>         $i++; 
       </tr>         $grp_data = qq~"'$title'", ~; 
   
         ( $title, $dummy ) = split /\|/xsm, $Group{'Global Moderator'}, 2;
         ToJS($title);
         $groupinfo[$i] = $title;
         $i++;
         $grp_data .= qq~"'$title'", ~;
   
         ( $title, $dummy ) = split /\|/xsm, $Group{'Mid Moderator'}, 2;
         ToJS($title);
         $groupinfo[$i] = $title;
         $i++;
         $grp_data .= qq~"'$title'", ~;
   
         foreach (@nopostorder) {
             ( $title, $dummy ) = split /\|/xsm, $NoPost{$_}, 2;
             ToJS($title);
             $groupinfo[$i] = $title;
             $grp_data .= qq~"'$title'", ~;
             $i++;
             $z++;
         }
   
         $groupcnt = $i;
         $grp_data .= q~""~;
   
         $yymain .= qq~
     <div class="windowbg2 border padd-cell" style="float: left; width: 50%; margin: 1%; height:260px">
         <table class="windowbg2 pad-cell">
       <tr>        <tr>
          <td align="left" width="100%"><label for="emailtext"><b>$amv_txt{'2'}:</b></label></td>                <td><label for="emailsubject"><b>$amv_txt{'1'}:</b></label></td> 
             </tr><tr>
                 <td><input type="text" value="" size="40" name="emailsubject" id="emailsubject" style="width: 100%" /></td>
             </tr><tr>
                 <td><label for="emailtext"><b>$amv_txt{'2'}:</b></label></td>
             </tr><tr>
                 <td><textarea cols="38" rows="9" name="emailtext" id="emailtext" style="width:100%"></textarea></td>
             </tr><tr>
                 <td><span class="small">$amv_txt{'39'}</span></td>
       </tr>        </tr>
       <tr>     </table> 
          <td align="left" width="100%"><textarea cols="38" rows="9" name="emailtext" id="emailtext" style="width:100%"></textarea></td>         <input type="hidden" name="reused" value="$reused" /> 
       </tr>     </div> 
       <tr>  
       <td align="left" width="100%"><span class="small">$amv_txt{'39'}</span></td>  
       </tr>  
   </table>  
       <input type="hidden" name="reused" value="$reused" />  
   </div>  
   
   <div class="windowbg2" style="float: left; width: 44%; margin: 1%; margin-top: 0; border: 0;">  
   <table border="0" width="100%" cellspacing="0" cellpadding="3" class="windowbg2">  
   <tr>  
   <td class="windowbg2" align="left" valign="top" nowrap="nowrap"><label for="check_all"><b>$amv_txt{'42'}:</b></label></td>  
   <td class="windowbg2" align="left" valign="top"><input type="checkbox" name="check_all" id="check_all" value="1" class="windowbg2" style="border: 0;" onclick="javascript: if (this.checked) selectCheckAllmemb(true); else selectCheckAllmemb(false);" /></td>  
   </tr>  
   <tr>  
   <td class="windowbg2" align="left" valign="top" nowrap="nowrap"><label for="field1"><b>$amv_txt{'40'}:</b></label></td>  
   <td class="windowbg2" align="left" valign="top">  
       <label for="field1"><span class="small">$amv_txt{'46'}</span></label><br />  
       <select name="field1" id="field1" size="$groupcnt" multiple="multiple" onchange="selectCheck()">~;  
   
       $i = 0;  
       while ($i < $groupcnt) {  
           $yymain .= qq~  
           <option value="$i">$groupinfo[$i]</option>~;  
           $i++;  
       }  
   
       $yymain .= qq~  
       </select>  
   </td>  
   </tr>  
   </table>  
   </div>  
   
   <div class="windowbg2" style="float: left; width: 50%; margin: 1%; margin-top: 0; margin-bottom: 0; border: 0;">  
   <table border="0" width="100%" cellspacing="0" cellpadding="3" class="windowbg2">  
   <tr>  
   <td class="windowbg2" align="left" valign="top"><b>$amv_txt{'47'}:</b></td>  
   </tr>  
   </table>  
   </div>  
   
   <div class="windowbg2" style="float: left; width: 50%; height: 115px; margin: 1%; border: 1px #cccccc solid; overflow: auto;">  
   ~;  
       if (-e ("$vardir/maillist.dat")) {  
           fopen(FILE, "$vardir/maillist.dat");  
           @maillist = <FILE>;  
           fclose(FILE);  
           $yymain .= qq~  
       <table border="0" width="99%" cellspacing="0" cellpadding="3" class="windowbg2">  
       ~;  
           foreach $curmail (@maillist) {  
               chomp $curmail;  
               ($otime, $osubject, $otext, $osender) = split(/\|/, $curmail);  
               &LoadUser($osender);  
               $thetime = &timeformat($otime);  
   
               $jsubject = $osubject;  
               $jtext    = $otext;  
               &ToJS($jsubject);  
               &ToJS($jtext);  
   
               $yymain .= qq~  
           <tr>  
               <td class="windowbg2" align="left" valign="middle">  
                   <input type="radio" name="usemail" value="$otime" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="showMailmemb('$jsubject', '$jtext', '$otime');" />  
               </td>  
               <td class="windowbg2" align="left" valign="top"><span class="small">$thetime<br />${$uid.$osender}{'realname'}</span></td>  
               <td class="windowbg2" align="left" valign="top"><span class="small">$osubject</span></td>  
               <td class="windowbg2" align="left" valign="middle"><a href="$adminurl?action=deletemail;delmail=$otime"><img src="$imagesdir/admin_rem.gif" border="0" alt="del" /></a></td>  
           </tr>  
           ~;  
           }  
           $yymain .= qq~  
       </table>  
       ~;  
       }  
       $yymain .= qq~  
   </div>  
   
   
   <div class="windowbg2" style="float: left; width: 44%; margin: 1%; margin-top: 0; border: 0;">  
   <table border="0" width="100%" cellspacing="0" cellpadding="0">  
   <tr>  
   <td align="center">  
       &nbsp;  
   </td>  
   </tr>  
   </table>  
   </div>  
   
   <div class="windowbg2" style="float: left; width: 50%; margin: 1%; margin-top: 0; border: 0;">  
   <table border="0" width="100%" cellspacing="0" cellpadding="0">  
   <tr>  
   <td align="center">  
       <input type="submit" name="mailsend" value="$amv_txt{'41'}" style="width: 100%;" class="button" />  
   </td>  
   </tr>  
   </table>  
   </div>  
   
<div style="clear: both;"></div>     <div class="windowbg2" style="float: left; width: 44%; margin: 0 1% 1% 1%; border: 0;"> 
         <table class="windowbg2 pad-cell">
         <tr>
             <td class="windowbg2 vtop" style="white-space: nowrap;"><label for="check_all"><b>$amv_txt{'42'}:</b></label></td>
             <td class="windowbg2 vtop"><input type="checkbox" name="check_all" id="check_all" value="1" class="windowbg2" style="border: 0;" onclick="javascript: if (this.checked) selectCheckAllmemb(true); else selectCheckAllmemb(false);" /></td>
         </tr><tr>
             <td class="windowbg2 vtop" style="white-space: nowrap;"><label for="field1"><b>$amv_txt{'40'}:</b></label></td>
             <td class="windowbg2 vtop">
         <label for="field1"><span class="small">$amv_txt{'46'}</span></label><br />
         <select name="field1" id="field1" size="$groupcnt" multiple="multiple" onchange="selectCheck()">~;
   
         $i = 0;
         while ( $i < $groupcnt ) {
             $yymain .= qq~
             <option value="$i">$groupinfo[$i]</option>~;
             $i++;
         }
   
         $yymain .= qq~
         </select>
     </td>
     </tr>
     </table>
     </div>
     <div class="windowbg2" style="float: left; width: 50%; margin: 0 1%; border: 0;">
         <table class="windowbg2 pad-cell">
             <tr>
                 <td