D:\my docs\My Received Files\Yabb\Yabb\YaBB_2.5_AEB\cgi-bin\yabb2_old\Admin\EditEmailTemplates.pl D:\WEBSITES\testbed\cgi-bin\yabb252\Admin\EditEmailTemplates.pl
############################################################################### ###############################################################################
# EditEmailTemplates.pl                                                       # # EditEmailTemplates.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.         #    
############################################################################### ###############################################################################
   
$editemailtemplatesplver = 'YaBB 2.5 AE $Revision: 1.13 $'; $editemailtemplatesplver = 'YaBB 2.5.2 $Revision: 1.0 $';
if ($action eq 'detailedversion') { return 1; } if ($action eq 'detailedversion') { return 1; }
   
sub editemailtemplates { sub editemailtemplates {
   &is_admin_or_gmod();    &is_admin_or_gmod();
   my($editlang, $string);    my($editlang, $string);
   
   $editlang = $INFO{'lang'} || '';    $editlang = $INFO{'lang'} || '';
   $string = $INFO{'string'} || '';    $string = $INFO{'string'} || '';
   
   if(!$editlang) {    if(!$editlang) {
       # Select language        # Select language
       $yymain .= qq~        $yymain .= qq~
<form action="$adminurl?action=editemailtemplates" method="get" style="display: inline"> <form action="$adminurl?action=editemailtemplates" method="get" style="display: inline">
<input type="hidden" name="action" value="editemailtemplates" /> <input type="hidden" name="action" value="editemailtemplates" />
 <table class="bordercolor" align="center" width="440" cellspacing="1" cellpadding="4">  <table class="bordercolor" align="center" width="440" cellspacing="1" cellpadding="4">
   <tr valign="middle">    <tr valign="middle">
     <td align="left" class="titlebg">      <td align="left" class="titlebg">
       <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'1'}</b>        <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'1'}</b>
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="center" class="windowbg2">      <td align="center" class="windowbg2">
       <select name="lang">~;        <select name="lang">~;
   
       # Find all the languages        # Find all the languages
       opendir(LNGDIR, $langdir);        opendir(LNGDIR, $langdir);
       my @langitems = readdir(LNGDIR);        my @langitems = readdir(LNGDIR);
       close(LNGDIR);        close(LNGDIR);
       foreach my $item (sort {lc($a) cmp lc($b)} @langitems) {        foreach my $item (sort {lc($a) cmp lc($b)} @langitems) {
           if (-d "$langdir/$item" && $item =~ m~\A[0-9a-zA-Z_\#\%\-\:\+\?\$\&\~\,\@/]+\Z~ && -e "$langdir/$item/Email.lng") {            if (-d "$langdir/$item" && $item =~ m~\A[0-9a-zA-Z_\#\%\-\:\+\?\$\&\~\,\@/]+\Z~ && -e "$langdir/$item/Email.lng") {
               $yymain .= qq~                $yymain .= qq~
         <option value="$item">$item</option>~;           <option value="$item">$displang</option>~; 
           }            }
       }        }
   
       $yymain .= qq~        $yymain .= qq~
       </select>        </select>
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="center" class="catbg">      <td align="center" class="catbg">
      <input type="submit" value="$emaileditor{'2'}" class="button" />       <input type="submit" value="$emaileditor{'2'}" class="button" />
     </td>      </td>
   </tr>    </tr>
 </table>  </table>
</form>~; </form>~;
   }    }
   elsif(!$string) {    elsif(!$string) {
       # Select string        # Select string
   
       $yymain .= qq~        $yymain .= qq~
<form action="$adminurl?action=editemailtemplates" method="get" style="display: inline"> <form action="$adminurl?action=editemailtemplates" method="get" style="display: inline">
<input type="hidden" name="action" value="editemailtemplates" /> <input type="hidden" name="action" value="editemailtemplates" />
<input type="hidden" name="lang" value="$editlang" /> <input type="hidden" name="lang" value="$editlang" />
 <table class="bordercolor" align="center" width="440" cellspacing="1" cellpadding="4">  <table class="bordercolor" align="center" width="440" cellspacing="1" cellpadding="4">
   <tr valign="middle">    <tr valign="middle">
     <td align="left" class="titlebg">      <td align="left" class="titlebg">
       <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'3'}</b>        <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'3'}</b>
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="center" class="windowbg2">      <td align="center" class="windowbg2">
       <select name="string">~;        <select name="string">~;
   
       # Find all the strings        # Find all the strings
       &LoadLanguage('Email');        &LoadLanguage('Email');
       my @emaildescset = sort{ $emaildesc{$a} cmp $emaildesc{$b} } keys %emaildesc;        my @emaildescset = sort{ $emaildesc{$a} cmp $emaildesc{$b} } keys %emaildesc;
       foreach my $varname (@emaildescset) {        foreach my $varname (@emaildescset) {
           $yymain .= qq~            $yymain .= qq~
         <option value="$varname">$emaildesc{$varname}</option>~;          <option value="$varname">$emaildesc{$varname}</option>~;
       }        }
   
       $yymain .= qq~        $yymain .= qq~
       </select>        </select>
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="center" class="catbg">      <td align="center" class="catbg">
      <input type="submit" value="$emaileditor{'2'}" class="button" />       <input type="submit" value="$emaileditor{'2'}" class="button" />
     </td>      </td>
   </tr>    </tr>
 </table>  </table>
</form>~; </form>~;
   }    }
   else {    else {
       # Show editor        # Show editor
       my $reallang = $language;        my $reallang = $language;
       $language = $editlang;        $language = $editlang;
       &LoadLanguage('Email');        &LoadLanguage('Email');
       $language = $reallang;        $language = $reallang;
   
       my $message = ${$string};        my $message = ${$string};
       &ToHTML($message);        &ToHTML($message);
       my $comment = $emaildesc{$string};        my $comment = $emaildesc{$string};
   
       $yymain .= qq~        $yymain .= qq~
<form action="$adminurl?action=editemailtemplates2;lang=$editlang;string=$string" method="post" style="display: inline"> <form action="$adminurl?action=editemailtemplates2;lang=$editlang;string=$string" method="post" style="display: inline">
 <table class="bordercolor" align="center" cellspacing="1" cellpadding="4">  <table class="bordercolor" align="center" cellspacing="1" cellpadding="4">
   <tr valign="middle">    <tr valign="middle">
     <td align="left" class="titlebg">      <td align="left" class="titlebg">
       <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'4'}</b>        <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'4'}</b>
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="left" class="windowbg2">      <td align="left" class="windowbg2">
       $emaileditor{'5'} $comment<br /><br />        $emaileditor{'5'} $comment<br /><br />
       $emaileditor{'6'}<br />        $emaileditor{'6'}<br />
       <textarea name="message" rows="20" cols="80">$message</textarea>        <textarea name="message" rows="20" cols="80">$message</textarea>
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="left" class="windowbg2">      <td align="left" class="windowbg2">
       $emaileditor{'7'}        $emaileditor{'7'}
       <ul>        <ul>
         <li>{yabb scripturl} $yabbtagdesc{'scripturl'}</li>          <li>{yabb scripturl} $yabbtagdesc{'scripturl'}</li>
         <li>{yabb adminurl} $yabbtagdesc{'adminurl'}</li>          <li>{yabb adminurl} $yabbtagdesc{'adminurl'}</li>
         <li>{yabb mbname} $yabbtagdesc{'mbname'}</li>~;          <li>{yabb mbname} $yabbtagdesc{'mbname'}</li>~;
   
   # Find the list of usable YaBB tags    # Find the list of usable YaBB tags
   foreach my $yabbtag (split(/\s+/, $yabbtags{$string})) {    foreach my $yabbtag (split(/\s+/, $yabbtags{$string})) {
       next unless $yabbtag =~ /\w/;        next unless $yabbtag =~ /\w/;
       $yymain .= qq~        $yymain .= qq~
         <li>{yabb $yabbtag} $yabbtagdesc{$yabbtag}</li>~;          <li>{yabb $yabbtag} $yabbtagdesc{$yabbtag}</li>~;
   }         }     
   
   $yymain .= qq~    $yymain .= qq~
       </ul>        </ul>
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="left" class="catbg">      <td align="left" class="catbg">
      $emaileditor{'8'}       $emaileditor{'8'}
       <br />$emaileditor{'9'} <tt>Languages/$editlang/Email.lng</tt> $emaileditor{'10'}        <br />$emaileditor{'9'} <tt>Languages/$editlang/Email.lng</tt> $emaileditor{'10'}
     </td>      </td>
   </tr>    </tr>
   <tr valign="middle">    <tr valign="middle">
     <td align="center" class="catbg">      <td align="center" class="catbg">
      <input type="submit" value="$emaileditor{'11'}" class="button" />       <input type="submit" value="$emaileditor{'11'}" class="button" />
     </td>      </td>
   </tr>    </tr>
 </table>  </table>
</form>~; </form>~;
   }    }
   
   $yytitle = $admintxt{'a4_label4'};    $yytitle = $admintxt{'a4_label4'};
   $action_area = 'editemailtemplates';    $action_area = 'editemailtemplates';
   &AdminTemplate();    &AdminTemplate();
} }
   
sub editemailtemplates2 { sub editemailtemplates2 {
   &is_admin_or_gmod();    &is_admin_or_gmod();
   my($editlang, $string, $message);    my($editlang, $string, $message);
   
   $editlang = $INFO{'lang'};    $editlang = $INFO{'lang'};
   $string = $INFO{'string'};    $string = $INFO{'string'};
   $message = $FORM{'message'};    $message = $FORM{'message'};
   
   $message =~ s~(\~|\\)~\\$1~g;    $message =~ s~(\~|\\)~\\$1~g;
   $message =~ s/\r(?=\n*)//g;    $message =~ s/\r(?=\n*)//g;
   
   &admin_fatal_error('no_info') unless $message && $string;    &admin_fatal_error('no_info') unless $message && $string;
   
   # Read the current file    # Read the current file
   fopen(LANG, "$langdir/$editlang/Email.lng") || &admin_fatal_error('cannot_open_language',"$langdir/$editlang/Email.lng", 1);    fopen(LANG, "$langdir/$editlang/Email.lng") || &admin_fatal_error('cannot_open_language',"$langdir/$editlang/Email.lng", 1);
   my $langfile = join('', <LANG>);    my $langfile = join('', <LANG>);
   fclose(LANG);    fclose(LANG);
   
   # Vague hardcoded error since it was tampered with    # Vague hardcoded error since it was tampered with
   &admin_fatal_error('error_occurred', 'Language Error') unless $string =~ /\Q$string\E/;    &admin_fatal_error('error_occurred', 'Language Error') unless $string =~ /\Q$string\E/;
   
   # Make the change    # Make the change
   $langfile =~ s!\$\Q$string\E = qq~.+?~;!\$$string = qq~$message~;!s;    $langfile =~ s!\$\Q$string\E = qq~.+?~;!\$$string = qq~$message~;!s;
   
   # Write it out    # Write it out
   fopen(LANG, ">$langdir/$editlang/Email.lng") || &admin_fatal_error('cannot_open_language',"$langdir/$editlang/Email.lng", 1);    fopen(LANG, ">$langdir/$editlang/Email.lng") || &admin_fatal_error('cannot_open_language',"$langdir/$editlang/Email.lng", 1);
   print LANG $langfile;    print LANG $langfile;
   fclose(LANG);    fclose(LANG);
   
   $yySetLocation = qq~$adminurl~;    $yySetLocation = qq~$adminurl~;
   &redirectexit();    &redirectexit();
} }
   
1; 1;