F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\SendTopic.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\SendTopic.pm
############################################################################### ###############################################################################
# SendTopic.pl                                                                # # SendTopic.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.                      #
############################################################################### ###############################################################################
  our $VERSION = '2.6.12';
   
$sendtopicplver = 'YaBB 2.5.2 $Revision: 1.1 $'; $sendtopicpmver = 'YaBB 2.6.12 $Revision: 1651 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
if (!$sendtopicmail || $sendtopicmail == 2) { &fatal_error("not_allowed"); } if ( !$sendtopicmail || $sendtopicmail == 2 ) { fatal_error('not_allowed'); }
   
if ($regcheck) { require "$sourcedir/Decoder.pl"; } if ($gpvalid_en && $iamguest) { require Sources::Decoder; }
   
&LoadLanguage('SendTopic');  LoadLanguage('SendTopic'); 
  get_micon();
  get_template('Display');
   
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 ' ');     if ( $board eq q{} || $board eq q{_} || $board eq q{ } ) { 
   &fatal_error("no_topic_send") unless ($topic ne '' && $topic ne '_' && $topic ne ' ');         fatal_error('no_board_send'); 
   if ($iamguest) { $focus_y_name = qq~document.sendtopic.y_name.focus();~; }    }
     if ( $topic eq q{} || $topic eq q{_} || $topic eq q{ } ) {
   unless (ref($thread_arrayref{$topic})) {         fatal_error('no_topic_send'); 
       fopen(FILE, "$datadir/$topic.txt") || &fatal_error("cannot_open","$datadir/$topic.txt", 1);     } 
       @{$thread_arrayref{$topic}} = <FILE>;     if ($iamguest) { $focus_y_name = q~document.sendtopic.y_name.focus();~; } 
       fclose(FILE);  
   }     if ( !ref $thread_arrayref{$topic} ) { 
   $subject = (split(/\|/, ${$thread_arrayref{$topic}}[0], 2))[0];         fopen( FILE, "$datadir/$topic.txt" ) 
           or fatal_error( 'cannot_open', "$datadir/$topic.txt", 1 );
   $yymain .= qq~         @{ $thread_arrayref{$topic} } = <FILE>; 
<form action="$scripturl?action=sendtopic2" method="post" name="sendtopic" onsubmit="return CheckSendTopicFields();">         fclose(FILE); 
<table width="70%" border="0" align="center" cellspacing="0" cellpadding="3">     } 
   <tr>     $subject = ( split /\|/xsm, ${ $thread_arrayref{$topic} }[0], 2 )[0]; 
       <td class="titlebg" colspan="2">  
           <img src="$imagesdir/email.gif" alt="" border="0" />     if ($gpvalid_en && $iamguest) { 
           <span class="text1"><b>$sendtopic_txt{'707'}&nbsp; &#171; $subject &#187; &nbsp;$sendtopic_txt{'708'}</b></span>         validation_code(); 
       </td>         $my_valcode = $mysend_valcode; 
   </tr><tr>         $my_valcode =~ s/{yabb showcheck}/$showcheck/sm; 
       <td width="30%" class="windowbg" align="left"><label for="y_name"><b>$sendtopic_txt{'335'}:</b></label></td>         $my_valcode =~ s/{yabb flood_text}/$flood_text/sm; 
       <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>     if ( $spam_questions_gp && $iamguest && -e "$langdir/$language/spam.questions" ) { 
       <td width="30%" class="windowbg" align="left"><label for="y_email"><b>$sendtopic_txt{'336'}:</b></label></td>         SpamQuestion(); 
       <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>         my $verification_question_desc; 
   </tr><tr>         if ($spam_questions_case) { 
       <td class="windowbg" align="center" valign="top" colspan="2">             $verification_question_desc = 
           <hr width="100%" size="1" class="hr" />               qq~<br />$sendtopic_txt{'verification_question_case'}~; 
       </td>         } 
   </tr><tr>         $my_spam = $mysend_spam; 
       <td width="30%" class="windowbg" align="left"><label for="r_name"><b>$sendtopic_txt{'717'}:</b></label></td>         $my_spam =~ s/{yabb spam_question}/$spam_question/sm; 
       <td width="70%" class="windowbg" align="left"><input type="text" name="r_name" id="r_name" size="50" maxlength="50" /></td>         $my_spam =~ 
   </tr><tr>           s/{yabb verification_question_desc}/$verification_question_desc/sm; 
       <td width="30%" class="windowbg" align="left"><label for="r_email"><b>$sendtopic_txt{'718'}:</b></label></td>         $my_spam =~ s/{yabb spam_question_id}/$spam_question_id/sm; 
       <td width="70%" class="windowbg" align="left"><input type="text" name="r_email" id="r_email" size="50" maxlength="50" /></td>         $my_spam =~ s/{yabb spam_question_image}/$spam_image/sm; 
   </tr>     } 
~;  
     $my_jschecks = qq~<script type="text/javascript">
   if ($regcheck) {  
       &validation_code;  
       $yymain .= qq~  
   <tr>  
       <td class="windowbg" align="center" valign="top" colspan="2">  
           <hr width="100%" size="1" class="hr" />  
       </td>  
   </tr><tr>  
       <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>  
   </tr><tr>  
       <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>  
   </tr>  
~;  
   }  
   $yymain .= qq~  
   <tr>  
       <td class="windowbg" align="center" valign="top" colspan="2">  
           <hr width="100%" size="1" class="hr" />  
       </td>  
   </tr><tr>  
       <td class="windowbg" align="center" colspan="2">  
           <input type="hidden" name="board" value="$board" />  
           <input type="hidden" name="topic" value="$topic" />  
           <input type="submit" name="Send" value="$sendtopic_txt{'339'}" class="button" />  
       </td>  
   </tr>  
</table>  
</form>  
<script type="text/javascript" language="JavaScript">  
<!--  
   $focus_y_name    $focus_y_name
   
   function CheckSendTopicFields() {    function CheckSendTopicFields() {
       if (document.sendtopic.y_name.value == '') {        if (document.sendtopic.y_name.value == '') {
           alert("$sendtopic_txt{'error_sender_name'}");            alert("$sendtopic_txt{'error_sender_name'}");
           document.sendtopic.y_name.focus();            document.sendtopic.y_name.focus();
       return false;        return false;
       }        }
       if (document.sendtopic.y_email.value == '') {        if (document.sendtopic.y_email.value == '') {
           alert("$sendtopic_txt{'error_sender_email'}");            alert("$sendtopic_txt{'error_sender_email'}");
           document.sendtopic.y_email.focus();            document.sendtopic.y_email.focus();
       return false;        return false;
       }        }
       if (document.sendtopic.r_name.value == '') {        if (document.sendtopic.r_name.value == '') {
           alert("$sendtopic_txt{'error_recipient_name'}");            alert("$sendtopic_txt{'error_recipient_name'}");
           document.sendtopic.r_name.focus();            document.sendtopic.r_name.focus();
       return false;        return false;
       }        }
       if (document.sendtopic.r_email.value == '') {        if (document.sendtopic.r_email.value == '') {
           alert("$sendtopic_txt{'error_recipient_email'}");            alert("$sendtopic_txt{'error_recipient_email'}");
           document.sendtopic.r_email.focus();            document.sendtopic.r_email.focus();
       return false;        return false;
       }        }
       ~ . ($regcheck ? qq~         ~ . ( 
         $regcheck
         ? qq~
       if (document.sendtopic.verification.value == '') {        if (document.sendtopic.verification.value == '') {
           alert("$sendtopic_txt{'error_verification'}");            alert("$sendtopic_txt{'error_verification'}");
           document.sendtopic.verification.focus();            document.sendtopic.verification.focus();
           return false;            return false;
       }~ : '') . qq~         }~ 
         : q{}
       )
       . (
         $spam_questions_send && -e "$langdir/$language/spam.questions" 
         ? qq~
         if (document.sendtopic.verification_question.value == '') {
             alert("$sendtopic_txt{'error_verification_question'}");
             document.sendtopic.verification_question.focus();
             return false;
         }~
         : q{}
       )
       . q~
       return true;        return true;
   }    }
//-->  
</script>~; </script>~;
   $yytitle = "$sendtopic_txt{'707'}&nbsp; &#171; $subject &#187; &nbsp;$sendtopic_txt{'708'}";  
   $yynavigation = qq~&rsaquo; $sendtopic_txt{'707'}~;     $yymain .= $mysend_top; 
   &template;     $yymain =~ s/{yabb subject}/$subject/sm; 
     $yymain =~ s/{yabb realname}/${$uid.$username}{'realname'}/sm;
     $yymain =~ s/{yabb email}/${$uid.$username}{'email'}/sm;
     $yymain =~ s/{yabb my_valcode}/$my_valcode/sm;
     $yymain =~ s/{yabb my_spam}/$my_spam/sm;
     $yymain =~ s/{yabb my_jschecks}/$my_jschecks/sm;
     $yymain =~ s/{yabb board}/$board/sm;
     $yymain =~ s/{yabb topic}/$topic/sm;
   
     $yytitle =
  "$sendtopic_txt{'707'}&nbsp; &laquo; $subject &raquo; &nbsp;$sendtopic_txt{'708'}";
     $yynavigation = qq~&rsaquo; $sendtopic_txt{'707'}~;
     template();
     return;
} }
   
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 ' ');     if ( $board eq q{} || $board eq q{_} || $board eq q{ } ) { 
   &fatal_error("no_topic_send") unless ($topic ne '' && $topic ne '_' && $topic ne ' ');         fatal_error('no_board_send'); 
     }
   $yname  = $FORM{'y_name'};     if ( $topic eq q{} || $topic eq q{_} || $topic eq q{ } ) { 
   $rname  = $FORM{'r_name'};         fatal_error('no_topic_send'); 
   $yemail = $FORM{'y_email'};     } 
   $remail = $FORM{'r_email'};  
   $yname =~ s/\A\s+//;     $yname  = $FORM{'y_name'}; 
   $yname =~ s/\s+\Z//;     $rname  = $FORM{'r_name'}; 
   $yemail =~ s/\A\s+//;     $yemail = $FORM{'y_email'}; 
   $yemail =~ s/\s+\Z//;     $remail = $FORM{'r_email'}; 
   $rname =~ s/\A\s+//;     $yname  =~ s/\A\s+//xsm; 
   $rname =~ s/\s+\Z//;     $yname  =~ s/\s+\Z//xsm; 
   $remail =~ s/\A\s+//;     $yemail =~ s/\A\s+//xsm; 
   $remail =~ s/\s+\Z//;     $yemail =~ s/\s+\Z//xsm; 
     $rname  =~ s/\A\s+//xsm;
   &fatal_error("no_name","$sendtopic_txt{'335'}") unless ($yname ne '' && $yname ne '_' && $yname ne ' ');     $rname  =~ s/\s+\Z//xsm; 
   &fatal_error("sendname_too_long","$sendtopic_txt{'335'}") if (length($yname) > 25);     $remail =~ s/\A\s+//xsm; 
   &fatal_error("no_email","$sendtopic_txt{'336'}") if ($yemail eq '');     $remail =~ s/\s+\Z//xsm; 
   &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("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("no_email","$sendtopic_txt{'718'}") if ($remail eq '');  
   &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}\]?$/));  
   if ($regcheck) {  
       &validation_check($FORM{'verification'});  
   }  
   
   unless (ref($thread_arrayref{$topic})) {  
       fopen(FILE, "$datadir/$topic.txt") || &fatal_error("cannot_open","$datadir/$topic.txt", 1);  
       @{$thread_arrayref{$topic}} = <FILE>;  
       fclose(FILE);  
   }  
   $subject = (split(/\|/, ${$thread_arrayref{$topic}}[0], 2))[0];  
   &FromHTML($subject);  
   require "$sourcedir/Mailer.pl";  
   &LoadLanguage('Email');  
       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);  
   
   $yySetLocation = qq~$scripturl?num=$topic~;     if ( $yname eq q{} || $yname eq q{_} || $yname eq q{ } ) { 
   &redirectexit;         fatal_error( 'no_name', "$sendtopic_txt{'335'}" ); 
     }
     if ( length($yname) > 25 ) {
         fatal_error( 'sendname_too_long', "$sendtopic_txt{'335'}" );
     }
     if ( $yemail eq q{} ) {
         fatal_error( 'no_email', "$sendtopic_txt{'336'}" );
     }
     if ( $yemail !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/sm ) {
         fatal_error( 'invalid_character',
             "$sendtopic_txt{'336'} $sendtopic_txt{'241'}" );
     }
     if (   ( $yemail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/sm )
         || ( $yemail !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/sm ) )
     {
         fatal_error( 'invalid_email', "$sendtopic_txt{'336'}" );
     }
     if ( $rname eq q{} || $rname eq q{_} || $rname eq q{ } ) {
         fatal_error( 'no_name', "$sendtopic_txt{'717'}" );
     }
     if ( length($rname) > 25 ) {
         fatal_error( 'sendname_too_long', "$sendtopic_txt{'717'}" );
     }
     if ( $remail eq q{} ) {
         fatal_error( 'no_email', "$sendtopic_txt{'718'}" );
     }
     if ( $remail !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/sm ) {
         fatal_error( 'invalid_character',
             "$sendtopic_txt{'718'} $sendtopic_txt{'241'}" );
     }
     if (   ( $remail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/sm )
         || ( $remail !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/sm ) )
     {
         fatal_error( 'invalid_email', "$sendtopic_txt{'718'}" );
     }
   
     if ($gpvalid_en && $iamguest) {
         validation_check( $FORM{'verification'} );
     }
     if ( $spam_questions_gp && $iamguest && -e "$langdir/$language/spam.questions" ) {
         SpamQuestionCheck( $FORM{'verification_question'},
             $FORM{'verification_question_id'} );
     }
     if ( !ref $thread_arrayref{$topic} ) {
         fopen( FILE, "$datadir/$topic.txt" )
           or fatal_error( 'cannot_open', "$datadir/$topic.txt", 1 );
         @{ $thread_arrayref{$topic} } = <FILE>;
         fclose(FILE);
     }
     $subject = ( split /\|/xsm, ${ $thread_arrayref{$topic} }[0], 2 )[0];
     FromHTML($subject);
     require Sources::Mailer;
     LoadLanguage('Email');
     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 );
   
     $yySetLocation = qq~$scripturl?num=$topic~;
     redirectexit();
     return;
} }
   
1; 1;