D:\my docs\My Received Files\Yabb\Yabb\YaBB_2.5_AEB\cgi-bin\yabb2_old\Sources\SendTopic.pl D:\WEBSITES\testbed\cgi-bin\yabb252\Sources\SendTopic.pl
############################################################################### ###############################################################################
# SendTopic.pl                                                                # # SendTopic.pl                                                                #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5 Anniversary Edition                                # # Version:        YaBB 2.5.2                                                  #
# Packaged:       July 04, 2010                                               # # Packaged:       September 30, 2012                                          #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com            #    
#               Your source for web hosting, web design, and domains.         #    
############################################################################### ###############################################################################
   
$sendtopicplver = 'YaBB 2.5 AE $Revision: 1.11 $'; $sendtopicplver = 'YaBB 2.5.2 $Revision: 1.0 $';
if ($action eq 'detailedversion') { return 1; } if ($action eq 'detailedversion') { return 1; }
   
  if (!$sendtopicmail || $sendtopicmail == 2) { &fatal_error("not_allowed"); }  
   
if ($regcheck) { require "$sourcedir/Decoder.pl"; } if ($regcheck) { require "$sourcedir/Decoder.pl"; }
   
&LoadLanguage('SendTopic'); &LoadLanguage('SendTopic');
   
sub SendTopic { sub SendTopic {
   $topic = $INFO{'topic'};    $topic = $INFO{'topic'};
   &MessageTotals("load", $topic);    &MessageTotals("load", $topic);
   $board = ${$topic}{'board'};    $board = ${$topic}{'board'};
   &fatal_error("no_board_send") unless ($board ne '' && $board ne '_' && $board ne ' ');    &fatal_error("no_board_send") unless ($board ne '' && $board ne '_' && $board ne ' ');
   &fatal_error("no_topic_send") unless ($topic ne '' && $topic ne '_' && $topic ne ' ');    &fatal_error("no_topic_send") unless ($topic ne '' && $topic ne '_' && $topic ne ' ');
     if ($iamguest) { $focus_y_name = qq~document.sendtopic.y_name.focus();~; }  
      
   unless (ref($thread_arrayref{$topic})) {    unless (ref($thread_arrayref{$topic})) {
       fopen(FILE, "$datadir/$topic.txt") || &fatal_error("cannot_open","$datadir/$topic.txt", 1);        fopen(FILE, "$datadir/$topic.txt") || &fatal_error("cannot_open","$datadir/$topic.txt", 1);
       @{$thread_arrayref{$topic}} = <FILE>;        @{$thread_arrayref{$topic}} = <FILE>;
       fclose(FILE);        fclose(FILE);
   }    }
   $subject = (split(/\|/, ${$thread_arrayref{$topic}}[0], 2))[0];    $subject = (split(/\|/, ${$thread_arrayref{$topic}}[0], 2))[0];
   
   $yymain .= qq~    $yymain .= qq~
<form action="$scripturl?action=sendtopic2" method="post">  <form action="$scripturl?action=sendtopic2" method="post" name="sendtopic" onsubmit="return CheckSendTopicFields();"> 
<table width="70%" border="0" align="center" cellspacing="0" cellpadding="3"> <table width="70%" border="0" align="center" cellspacing="0" cellpadding="3">
   <tr>    <tr>
       <td class="titlebg" colspan="2">        <td class="titlebg" colspan="2">
           <img src="$imagesdir/email.gif" alt="" border="0" />            <img src="$imagesdir/email.gif" alt="" border="0" />
           <span class="text1"><b>$sendtopic_txt{'707'}&nbsp; &#171; $subject &#187; &nbsp;$sendtopic_txt{'708'}</b></span>            <span class="text1"><b>$sendtopic_txt{'707'}&nbsp; &#171; $subject &#187; &nbsp;$sendtopic_txt{'708'}</b></span>
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td width="30%" class="windowbg" align="left"><label for="y_name"><b>$sendtopic_txt{'335'}:</b></label></td>        <td width="30%" class="windowbg" align="left"><label for="y_name"><b>$sendtopic_txt{'335'}:</b></label></td>
       <td width="70%" class="windowbg" align="left"><input type="text" name="y_name" id="y_name" size="50" maxlength="50" value="${$uid.$username}{'realname'}" /></td>        <td width="70%" class="windowbg" align="left"><input type="text" name="y_name" id="y_name" size="50" maxlength="50" value="${$uid.$username}{'realname'}" /></td>
   </tr><tr>    </tr><tr>
       <td width="30%" class="windowbg" align="left"><label for="y_email"><b>$sendtopic_txt{'336'}:</b></label></td>        <td width="30%" class="windowbg" align="left"><label for="y_email"><b>$sendtopic_txt{'336'}:</b></label></td>
       <td width="70%" class="windowbg" align="left"><input type="text" name="y_email" id="y_email" size="50" maxlength="50" value="${$uid.$username}{'email'}" /></td>        <td width="70%" class="windowbg" align="left"><input type="text" name="y_email" id="y_email" size="50" maxlength="50" value="${$uid.$username}{'email'}" /></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg" align="center" valign="top" colspan="2">        <td class="windowbg" align="center" valign="top" colspan="2">
           <hr width="100%" size="1" class="hr" />            <hr width="100%" size="1" class="hr" />
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td width="30%" class="windowbg" align="left"><label for="r_name"><b>$sendtopic_txt{'717'}:</b></label></td>        <td width="30%" class="windowbg" align="left"><label for="r_name"><b>$sendtopic_txt{'717'}:</b></label></td>
       <td width="70%" class="windowbg" align="left"><input type="text" name="r_name" id="r_name" size="50" maxlength="50" /></td>        <td width="70%" class="windowbg" align="left"><input type="text" name="r_name" id="r_name" size="50" maxlength="50" /></td>
   </tr><tr>    </tr><tr>
       <td width="30%" class="windowbg" align="left"><label for="r_email"><b>$sendtopic_txt{'718'}:</b></label></td>        <td width="30%" class="windowbg" align="left"><label for="r_email"><b>$sendtopic_txt{'718'}:</b></label></td>
       <td width="70%" class="windowbg" align="left"><input type="text" name="r_email" id="r_email" size="50" maxlength="50" /></td>        <td width="70%" class="windowbg" align="left"><input type="text" name="r_email" id="r_email" size="50" maxlength="50" /></td>
   </tr>    </tr>
~; ~;
   
   if ($regcheck) {    if ($regcheck) {
       &validation_code;        &validation_code;
       $yymain .= qq~        $yymain .= qq~
   <tr>    <tr>
       <td class="windowbg" align="center" valign="top" colspan="2">        <td class="windowbg" align="center" valign="top" colspan="2">
           <hr width="100%" size="1" class="hr" />            <hr width="100%" size="1" class="hr" />
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td width="30%" class="windowbg" align="left" valign="middle"><label for="verification"><b>$floodtxt{'1'}:</b></label></td>        <td width="30%" class="windowbg" align="left" valign="middle"><label for="verification"><b>$floodtxt{'1'}:</b></label></td>
       <td width="70%" class="windowbg" align="left" valign="middle">$showcheck<br /><label for="verification"><span class="small">$floodtxt{'casewarning'}</span></label></td>        <td width="70%" class="windowbg" align="left" valign="middle">$showcheck<br /><label for="verification"><span class="small">$floodtxt{'casewarning'}</span></label></td>
   </tr><tr>    </tr><tr>
       <td width="30%" class="windowbg" align="left"><label for="verification"><b>$floodtxt{'3'}:</b></label></td>        <td width="30%" class="windowbg" align="left"><label for="verification"><b>$floodtxt{'3'}:</b></label></td>
       <td width="70%" class="windowbg" align="left"><input type="text" maxlength="30" name="verification" id="verification" size="50" /></td>        <td width="70%" class="windowbg" align="left"><input type="text" maxlength="30" name="verification" id="verification" size="50" /></td>
   </tr>    </tr>
~; ~;
   }    }
   $yymain .= qq~    $yymain .= qq~
   <tr>    <tr>
       <td class="windowbg" align="center" valign="top" colspan="2">        <td class="windowbg" align="center" valign="top" colspan="2">
           <hr width="100%" size="1" class="hr" />            <hr width="100%" size="1" class="hr" />
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td class="windowbg" align="center" colspan="2">        <td class="windowbg" align="center" colspan="2">
           <input type="hidden" name="board" value="$board" />            <input type="hidden" name="board" value="$board" />
           <input type="hidden" name="topic" value="$topic" />            <input type="hidden" name="topic" value="$topic" />
           <input type="submit" name="Send" value="$sendtopic_txt{'339'}" class="button" />            <input type="submit" name="Send" value="$sendtopic_txt{'339'}" class="button" />
       </td>        </td>
   </tr>    </tr>
</table> </table>
</form> </form>
~;  <script type="text/javascript" language="JavaScript"> 
  <!--  
     $focus_y_name  
     
     function CheckSendTopicFields() {  
         if (document.sendtopic.y_name.value == '') {  
             alert("$sendtopic_txt{'error_sender_name'}");  
             document.sendtopic.y_name.focus();  
         return false;  
         }  
         if (document.sendtopic.y_email.value == '') {  
             alert("$sendtopic_txt{'error_sender_email'}");  
             document.sendtopic.y_email.focus();  
         return false;  
         }  
         if (document.sendtopic.r_name.value == '') {  
             alert("$sendtopic_txt{'error_recipient_name'}");  
             document.sendtopic.r_name.focus();  
         return false;  
         }  
         if (document.sendtopic.r_email.value == '') {  
             alert("$sendtopic_txt{'error_recipient_email'}");  
             document.sendtopic.r_email.focus();  
         return false;  
         }  
         ~ . ($regcheck ? qq~  
         if (document.sendtopic.verification.value == '') {  
             alert("$sendtopic_txt{'error_verification'}");  
             document.sendtopic.verification.focus();  
             return false;  
         }~ : '') . qq~  
         return true;  
     }  
  //-->  
  </script>~;  
   $yytitle = "$sendtopic_txt{'707'}&nbsp; &#171; $subject &#187; &nbsp;$sendtopic_txt{'708'}";    $yytitle = "$sendtopic_txt{'707'}&nbsp; &#171; $subject &#187; &nbsp;$sendtopic_txt{'708'}";
   $yynavigation = qq~&rsaquo; $sendtopic_txt{'707'}~;    $yynavigation = qq~&rsaquo; $sendtopic_txt{'707'}~;
   &template;    &template;
} }
   
sub SendTopic2 { sub SendTopic2 {
   $topic = $FORM{'topic'};    $topic = $FORM{'topic'};
   $board = $FORM{'board'};    $board = $FORM{'board'};
   &fatal_error("no_board_send") unless ($board ne '' && $board ne '_' && $board ne ' ');    &fatal_error("no_board_send") unless ($board ne '' && $board ne '_' && $board ne ' ');
   &fatal_error("no_topic_send") unless ($topic ne '' && $topic ne '_' && $topic ne ' ');    &fatal_error("no_topic_send") unless ($topic ne '' && $topic ne '_' && $topic ne ' ');
   
   $yname  = $FORM{'y_name'};    $yname  = $FORM{'y_name'};
   $rname  = $FORM{'r_name'};    $rname  = $FORM{'r_name'};
   $yemail = $FORM{'y_email'};    $yemail = $FORM{'y_email'};
   $remail = $FORM{'r_email'};    $remail = $FORM{'r_email'};
   $yname =~ s/\A\s+//;    $yname =~ s/\A\s+//;
   $yname =~ s/\s+\Z//;    $yname =~ s/\s+\Z//;
   $yemail =~ s/\A\s+//;    $yemail =~ s/\A\s+//;
   $yemail =~ s/\s+\Z//;    $yemail =~ s/\s+\Z//;
   $rname =~ s/\A\s+//;    $rname =~ s/\A\s+//;
   $rname =~ s/\s+\Z//;    $rname =~ s/\s+\Z//;
   $remail =~ s/\A\s+//;    $remail =~ s/\A\s+//;
   $remail =~ s/\s+\Z//;    $remail =~ s/\s+\Z//;
   
   if ($regcheck) {    
       &validation_check($FORM{'verification'});    
   }    
   
   &fatal_error("no_name","$sendtopic_txt{'335'}") unless ($yname ne '' && $yname ne '_' && $yname ne ' ');    &fatal_error("no_name","$sendtopic_txt{'335'}") unless ($yname ne '' && $yname ne '_' && $yname ne ' ');
   &fatal_error("sendname_too_long","$sendtopic_txt{'335'}") if (length($yname) > 25);    &fatal_error("sendname_too_long","$sendtopic_txt{'335'}") if (length($yname) > 25);
   &fatal_error("no_email","$sendtopic_txt{'336'}") if ($yemail eq '');    &fatal_error("no_email","$sendtopic_txt{'336'}") if ($yemail eq '');
   &fatal_error("invalid_character","$sendtopic_txt{'336'} $sendtopic_txt{'241'}") if ($yemail !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);    &fatal_error("invalid_character","$sendtopic_txt{'336'} $sendtopic_txt{'241'}") if ($yemail !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);
   &fatal_error("invalid_email","$sendtopic_txt{'336'}") if (($yemail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($yemail !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));    &fatal_error("invalid_email","$sendtopic_txt{'336'}") if (($yemail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($yemail !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));
   &fatal_error("no_name","$sendtopic_txt{'717'}") unless ($rname ne '' && yname ne '_' && $rname ne ' ');    &fatal_error("no_name","$sendtopic_txt{'717'}") unless ($rname ne '' && yname ne '_' && $rname ne ' ');
   &fatal_error("sendname_too_long","$sendtopic_txt{'717'}") if (length($rname) > 25);    &fatal_error("sendname_too_long","$sendtopic_txt{'717'}") if (length($rname) > 25);
   &fatal_error("no_email","$sendtopic_txt{'718'}") if ($remail eq '');    &fatal_error("no_email","$sendtopic_txt{'718'}") if ($remail eq '');
     if ($regcheck) {  
         &validation_check($FORM{'verification'});  
     }  
   &fatal_error("invalid_character","$sendtopic_txt{'718'} $sendtopic_txt{'241'}") if ($remail !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);    &fatal_error("invalid_character","$sendtopic_txt{'718'} $sendtopic_txt{'241'}") if ($remail !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);
   &fatal_error("invalid_email","$sendtopic_txt{'718'}")                                            if (($remail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($remail !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));    &fatal_error("invalid_email","$sendtopic_txt{'718'}")                                            if (($remail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($remail !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));
   
   unless (ref($thread_arrayref{$topic})) {    unless (ref($thread_arrayref{$topic})) {
       fopen(FILE, "$datadir/$topic.txt") || &fatal_error("cannot_open","$datadir/$topic.txt", 1);        fopen(FILE, "$datadir/$topic.txt") || &fatal_error("cannot_open","$datadir/$topic.txt", 1);
       @{$thread_arrayref{$topic}} = <FILE>;        @{$thread_arrayref{$topic}} = <FILE>;
       fclose(FILE);        fclose(FILE);
   }    }
   $subject = (split(/\|/, ${$thread_arrayref{$topic}}[0], 2))[0];    $subject = (split(/\|/, ${$thread_arrayref{$topic}}[0], 2))[0];
   &FromHTML($subject);    &FromHTML($subject);
   require "$sourcedir/Mailer.pl";    require "$sourcedir/Mailer.pl";
   &LoadLanguage('Email');    &LoadLanguage('Email');
       my $message = &template_email($sendtopicemail, {'toname' => $rname, 'subject' => $subject, 'displayname' => $yname, 'num' => $topic});        my $message = &template_email($sendtopicemail, {'toname' => $rname, 'subject' => $subject, 'displayname' => $yname, 'num' => $topic});
   &sendmail($remail, "$sendtopic_txt{'118'}: $subject ($sendtopic_txt{'318'} $yname)", $message, $yemail);    &sendmail($remail, "$sendtopic_txt{'118'}: $subject ($sendtopic_txt{'318'} $yname)", $message, $yemail);
   
   $yySetLocation = qq~$scripturl?num=$topic~;    $yySetLocation = qq~$scripturl?num=$topic~;
   &redirectexit;    &redirectexit;
} }
   
1; 1;