| ############################################################################### |
| ############################################################################### |
| # EditEmailTemplates.pl # |
| # EditEmailTemplates.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); |
| |
| use English '-no_match_vars'; |
| |
| our $VERSION = '2.6.12'; |
| |
| |
| $editemailtemplatesplver = 'YaBB 2.5.2 $Revision: 1.1 $'; |
| $editemailtemplatespmver = 'YaBB 2.6.12 $Revision: 1710 $'; |
| 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'} || q{}; |
| $string = $INFO{'string'} || ''; |
| $string = $INFO{'string'} || q{}; |
| |
| |
| if(!$editlang) { |
| if ( !$editlang ) { |
| # Select language |
| |
| $yymain .= qq~ |
| # Select language |
| |
| $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"> |
| <div class="bordercolor rightboxdiv"> |
| <tr valign="middle"> |
| <table class="border-space pad-cell"> |
| <td align="left" class="titlebg"> |
| <tr> |
| <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'1'}</b> |
| <td class="titlebg"> |
| </td> |
| $admin_img{'prefimg'} <b>$emaileditor{'1'}</b> |
| </tr> |
| </td> |
| <tr valign="middle"> |
| </tr><tr> |
| <td align="center" class="windowbg2"> |
| <td class="windowbg2 center"> |
| <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); |
| closedir 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" |
| my $displang = $item; |
| && $item =~ m{\A[0-9a-zA-Z_\#\%\-\:\+\?\$\&\~\,\@/]+\Z}sm |
| $displang =~ s~(.+?)\_(.+?)$~$1 ($2)~gi; |
| && -e "$langdir/$item/Email.lng" ) |
| $yymain .= qq~ |
| { |
| <option value="$item">$displang</option>~; |
| my $displang = $item; |
| } |
| $displang =~ s/(.+?)\_(.+?)$/$1 ($2)/gism; |
| |
| $yymain .= qq~ |
| |
| <option value="$item">$displang</option>~; |
| } |
| } |
| |
| } |
| |
| |
| $yymain .= qq~ |
| $yymain .= qq~ |
| </select> |
| </select> |
| </td> |
| </td> |
| </tr> |
| </tr><tr> |
| <tr valign="middle"> |
| <td class="catbg center"> |
| <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> |
| </div> |
| </form>~; |
| </form>~; |
| } |
| } |
| elsif(!$string) { |
| elsif ( !$string ) { |
| # Select string |
| |
| |
| |
| $yymain .= qq~ |
| # Select string |
| <form action="$adminurl?action=editemailtemplates" method="get" style="display: inline"> |
| |
| <input type="hidden" name="action" value="editemailtemplates" /> |
| |
| <input type="hidden" name="lang" value="$editlang" /> |
| |
| <table class="bordercolor" align="center" width="440" cellspacing="1" cellpadding="4"> |
| |
| <tr valign="middle"> |
| |
| <td align="left" class="titlebg"> |
| |
| <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'3'}</b> |
| |
| </td> |
| |
| </tr> |
| |
| <tr valign="middle"> |
| |
| <td align="center" class="windowbg2"> |
| |
| <select name="string">~; |
| |
| |
| |
| # Find all the strings |
| |
| &LoadLanguage('Email'); |
| |
| my @emaildescset = sort{ $emaildesc{$a} cmp $emaildesc{$b} } keys %emaildesc; |
| |
| foreach my $varname (@emaildescset) { |
| |
| $yymain .= qq~ |
| |
| <option value="$varname">$emaildesc{$varname}</option>~; |
| |
| } |
| |
| |
| |
| $yymain .= qq~ |
| $yymain .= qq~ |
| </select> |
| <form action="$adminurl?action=editemailtemplates" method="get" style="display: inline"> |
| </td> |
| <input type="hidden" name="action" value="editemailtemplates" /> |
| </tr> |
| <input type="hidden" name="lang" value="$editlang" /> |
| <tr valign="middle"> |
| <div class="bordercolor rightboxdiv"> |
| <td align="center" class="catbg"> |
| <table class="border-space pad-cell"> |
| <input type="submit" value="$emaileditor{'2'}" class="button" /> |
| <tr> |
| </td> |
| <td class="titlebg"> |
| </tr> |
| $admin_img{'prefimg'} <b>$emaileditor{'3'}</b> |
| </table> |
| </td> |
| |
| </tr><tr> |
| |
| <td class="windowbg2 center"> |
| |
| <select name="string">~; |
| |
| |
| |
| # Find all the strings |
| |
| LoadLanguage('Email'); |
| |
| my @emaildescset = |
| |
| sort { $emaildesc{$a} cmp $emaildesc{$b} } keys %emaildesc; |
| |
| foreach my $varname (@emaildescset) { |
| |
| $yymain .= qq~ |
| |
| <option value="$varname">$emaildesc{$varname}</option>~; |
| |
| } |
| |
| |
| |
| $yymain .= qq~ |
| |
| </select> |
| |
| </td> |
| |
| </tr><tr> |
| |
| <td class="catbg center"> |
| |
| <input type="submit" value="$emaileditor{'2'}" class="button" /> |
| |
| </td> |
| |
| </tr> |
| |
| </table> |
| |
| </div> |
| </form>~; |
| </form>~; |
| } |
| } |
| else { |
| else { |
| # Show editor |
| |
| my $reallang = $language; |
| |
| $language = $editlang; |
| |
| &LoadLanguage('Email'); |
| |
| $language = $reallang; |
| |
| |
| |
| my $message = ${$string}; |
| |
| &ToHTML($message); |
| |
| my $comment = $emaildesc{$string}; |
| |
| |
| |
| $yymain .= qq~ |
| # Show editor |
| <form action="$adminurl?action=editemailtemplates2;lang=$editlang;string=$string" method="post" style="display: inline"> |
| my $reallang = $language; |
| <table class="bordercolor" align="center" cellspacing="1" cellpadding="4"> |
| $language = $editlang; |
| <tr valign="middle"> |
| LoadLanguage('Email'); |
| <td align="left" class="titlebg"> |
| $language = $reallang; |
| <img src="$imagesdir/preferences.gif" alt="" border="0" /><b>$emaileditor{'4'}</b> |
| |
| </td> |
| my $message = ${$string}; |
| </tr> |
| ToHTML($message); |
| <tr valign="middle"> |
| my $comment = $emaildesc{$string}; |
| <td align="left" class="windowbg2"> |
| |
| $emaileditor{'5'} $comment<br /><br /> |
| $yymain .= qq~ |
| $emaileditor{'6'}<br /> |
| <form action="$adminurl?action=editemailtemplates2;lang=$editlang;string=$string" method="post" style="display: inline" accept-charset="$yymycharset"> |
| <textarea name="message" rows="20" cols="80">$message</textarea> |
| <div class="bordercolor rightboxdiv"> |
| </td> |
| <table class="border-space pad-cell" style="margin-bottom: .5em;"> |
| </tr> |
| <tr> |
| <tr valign="middle"> |
| <td class="titlebg"> |
| <td align="left" class="windowbg2"> |
| $admin_img{'prefimg'} <b>$emaileditor{'4'}</b> |
| $emaileditor{'7'} |
| </td> |
| <ul> |
| </tr><tr> |
| <li>{yabb scripturl} $yabbtagdesc{'scripturl'}</li> |
| <td class="windowbg2"> |
| <li>{yabb adminurl} $yabbtagdesc{'adminurl'}</li> |
| $emaileditor{'5'} $comment<br /><br /> |
| <li>{yabb mbname} $yabbtagdesc{'mbname'}</li>~; |
| $emaileditor{'6'}<br /> |
| |
| <textarea name="message" rows="20" cols="80">$message</textarea> |
| # Find the list of usable YaBB tags |
| </td> |
| foreach my $yabbtag (split(/\s+/, $yabbtags{$string})) { |
| </tr><tr> |
| next unless $yabbtag =~ /\w/; |
| <td class="windowbg2"> |
| $yymain .= qq~ |
| $emaileditor{'7'} |
| <li>{yabb $yabbtag} $yabbtagdesc{$yabbtag}</li>~; |
| <ul> |
| } |
| <li>{yabb scripturl} $yabbtagdesc{'scripturl'}</li> |
| |
| <li>{yabb adminurl} $yabbtagdesc{'adminurl'}</li> |
| $yymain .= qq~ |
| <li>{yabb mbname} $yabbtagdesc{'mbname'}</li>~; |
| </ul> |
| |
| </td> |
| # Find the list of usable YaBB tags |
| </tr> |
| foreach my $yabbtag ( split /\s+/xsm, $yabbtags{$string} ) { |
| <tr valign="middle"> |
| if ( $yabbtag !~ /\w/xsm ) { next; } |
| <td align="left" class="catbg"> |
| $yymain .= qq~ |
| $emaileditor{'8'} |
| <li>{yabb $yabbtag} $yabbtagdesc{$yabbtag}</li>~; |
| <br />$emaileditor{'9'} <tt>Languages/$editlang/Email.lng</tt> $emaileditor{'10'} |
| } |
| </td> |
| |
| </tr> |
| $yymain .= qq~ |
| <tr valign="middle"> |
| </ul> |
| <td align="center" class="catbg"> |
| </td> |
| <input type="submit" value="$emaileditor{'11'}" class="button" /> |
| </tr> |
| </td> |
| </table> |
| </tr> |
| </div> |
| </table> |
| <div class="bordercolor rightboxdiv"> |
| |
| <table class="border-space pad-cell"> |
| |
| <tr> |
| |
| <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th> |
| |
| </tr><tr> |
| |
| <td class="catbg center"> |
| |
| <input type="submit" value="$emaileditor{'11'}" class="button" /> |
| |
| <div class="small">$emaileditor{'8'}<br />$emaileditor{'9'} <span style="font-family:monospace">Languages/$editlang/Email.lng</span> $emaileditor{'10'}</div> |
| |
| </td> |
| |
| </tr> |
| |
| </table> |
| |
| </div> |
| </form>~; |
| </form>~; |
| } |
| } |
| |
| |
| $yytitle = $admintxt{'a4_label4'}; |
| $yytitle = $admintxt{'a4_label4'}; |
| $action_area = 'editemailtemplates'; |
| $action_area = 'editemailtemplates'; |
| &AdminTemplate(); |
| AdminTemplate(); |
| |
| return; |
| } |
| } |
| |
| |
| sub editemailtemplates2 { |
| sub editemailtemplates2 { |
| &is_admin_or_gmod(); |
| is_admin_or_gmod(); |
| my($editlang, $string, $message); |
| |
| |
| |
| $editlang = $INFO{'lang'}; |
| |
| $string = $INFO{'string'}; |
| |
| $message = $FORM{'message'}; |
| |
| |
| |
| $message =~ s~(\~|\\)~\\$1~g; |
| |
| $message =~ s/\r(?=\n*)//g; |
| |
| |
| |
| &admin_fatal_error('no_info') unless $message && $string; |
| |
| |
| |
| # Read the current file |
| |
| fopen(LANG, "$langdir/$editlang/Email.lng") || &admin_fatal_error('cannot_open_language',"$langdir/$editlang/Email.lng", 1); |
| |
| my $langfile = join('', <LANG>); |
| |
| fclose(LANG); |
| |
| |
| |
| # Vague hardcoded error since it was tampered with |
| |
| &admin_fatal_error('error_occurred', 'Language Error') unless $string =~ /\Q$string\E/; |
| |
| |
| |
| # Make the change |
| |
| $langfile =~ s!\$\Q$string\E = qq~.+?~;!\$$string = qq~$message~;!s; |
| |
| |
| |
| # Write it out |
| |
| fopen(LANG, ">$langdir/$editlang/Email.lng") || &admin_fatal_error('cannot_open_language',"$langdir/$editlang/Email.lng", 1); |
| |
| print LANG $langfile; |
| |
| fclose(LANG); |
| |
| |
| |
| $yySetLocation = qq~$adminurl~; |
| my $editlang = $INFO{'lang'}; |
| &redirectexit(); |
| my $string = $INFO{'string'}; |
| |
| my $message = $FORM{'message'}; |
| |
| |
| |
| $message =~ s/(\~|\\)/\\$1/gxsm; |
| |
| $message =~ s/\r(?=\n*)//gxsm; |
| |
| |
| |
| if ( !$message || !$string ) { fatal_error('no_info'); } |
| |
| |
| |
| # Read the current file |
| |
| fopen( LANG, "$langdir/$editlang/Email.lng" ) |
| |
| || fatal_error( 'cannot_open_language', |
| |
| "$langdir/$editlang/Email.lng", 1 ); |
| |
| my $langfile = do { local $INPUT_RECORD_SEPARATOR = undef; <LANG> }; |
| |
| fclose(LANG); |
| |
| |
| |
| # Vague hardcoded error since it was tampered with |
| |
| if ( $string !~ /\Q$string\E/xsm ) { |
| |
| fatal_error( 'error_occurred', 'Language Error' ); |
| |
| } |
| |
| |
| |
| # Make the change |
| |
| $langfile =~ s/\$\Q$string\E = qq~.+?~;/\$$string = qq~$message~;/sm; |
| |
| |
| |
| # Write it out |
| |
| fopen( LANG, ">$langdir/$editlang/Email.lng" ) |
| |
| || fatal_error( 'cannot_open_language', |
| |
| "$langdir/$editlang/Email.lng", 1 ); |
| |
| print {LANG} $langfile or croak "$croak{'print'} LANG"; |
| |
| fclose(LANG); |
| |
| |
| |
| $yySetLocation = qq~$adminurl?editemailtemplates&lang=$editlang~; |
| |
| redirectexit(); |
| |
| return; |
| } |
| } |
| |
| |
| 1; |
| 1; |
| |
| |