Changeset 176
- Timestamp:
- 01/19/07 11:51:41 (2 years ago)
- Files:
-
- trunk/comment_challenge/plugins/commchallenge/commchallenge.pl (modified) (4 diffs)
- trunk/comment_challenge/plugins/commchallenge/lib/commchallenge.pm (modified) (1 diff)
- trunk/comment_challenge/plugins/commchallenge/lib/commchallenge/L10N.pm (modified) (1 diff)
- trunk/comment_challenge/plugins/commchallenge/lib/commchallenge/L10N/en_us.pm (modified) (1 diff)
- trunk/comment_challenge/plugins/commchallenge/tmpl/blog_config.tmpl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/comment_challenge/plugins/commchallenge/commchallenge.pl
r170 r176 8 8 9 9 use strict; 10 use 5.006; # requires Perl 5.6.x 11 use MT 3.2; # requires MT 3.2 or later 12 use warnings; 13 10 14 use constant DEBUG_MODE => 0; 11 use MT 3.2; 15 12 16 use base 'MT::Plugin'; 13 use MT::JunkFilter qw(ABSTAIN);14 use vars qw($VERSION $plugin $_cache);15 17 16 $VERSION = '1.01'; 17 $plugin = new MT::Plugin::CommentChallenge({ 18 our $VERSION = "1.02"; 19 (our $PLUGIN_MODULE = __PACKAGE__) =~ s/^MT::Plugin:://; 20 21 my $plugin; 22 MT->add_plugin($plugin = __PACKAGE__->new({ 18 23 name => 'Comment Challenge', 19 24 version => $VERSION, … … 33 38 ['commchallenge_throttle_nobeacon', { Default => 0 }] 34 39 ]), 35 }); 36 MT->add_plugin($plugin); 40 })); 41 42 # Adding L10N bootstrapping for MT 3.2 43 if ($MT::VERSION < 3.3) { 44 foreach my $class (qw(CMS Comments Trackback)) { 45 MT->add_callback('MT::App::'.$class.'::pre_run', 1, $plugin, \&add_l10n); 46 } 47 } 37 48 38 49 require MT::Template::Context; … … 57 68 } 58 69 59 # sub apply_default_settings {60 # my $plugin = shift;61 # my ($data, $scope) = @_;62 # if ($scope ne 'system') {63 # my $sys = $plugin->get_config_obj('system');64 # my $sysdata = $sys->data();65 # if ($plugin->{settings} && $sysdata) {66 # foreach (keys %$sysdata) {67 # $data->{$_} = $sysdata->{$_}68 # if (!exists $data->{$_}) || (!defined $data->{$_});69 # }70 # }71 # } else {72 # $plugin->SUPER::apply_default_settings(@_);73 # }74 # }75 70 76 71 sub load_tmpl { … … 99 94 } 100 95 96 # We use an MT::App::CMS::pre_run callback to 97 # bootstrap the plugin's localization module 98 # and then handle the translate calls if needed. 99 sub add_l10n { 100 my ($cb,$app) = @_; 101 (my $lang = $app->current_language) =~ s/-/_/g; 102 eval "require commchallenge::L10N::$lang"; 103 } 104 sub translate { 105 my $plugin = shift; 106 return $MT::VERSION < 3.3 ? MT->instance->translate(@_) 107 : $plugin->SUPER::translate(@_); 108 } 109 101 110 # Utility debug method for writing to error log 102 111 sub debug { trunk/comment_challenge/plugins/commchallenge/lib/commchallenge.pm
r168 r176 6 6 7 7 package commchallenge; 8 9 use MT::JunkFilter qw(ABSTAIN); 8 10 9 11 use constant DEBUG_MODE => 0; trunk/comment_challenge/plugins/commchallenge/lib/commchallenge/L10N.pm
r119 r176 2 2 use strict; 3 3 4 use base 'MT::Plugin::L10N'; 4 eval { 5 require MT::Plugin::L10N; 6 @commchallenge::L10N::ISA = ('MT::Plugin::L10N'); 7 }; 8 # use base 'MT::Plugin::L10N'; 5 9 6 10 1; trunk/comment_challenge/plugins/commchallenge/lib/commchallenge/L10N/en_us.pm
r169 r176 5 5 # $Id$ 6 6 7 # Comment challenge localization file 8 # 9 # This package defines the English phrases used by the plugin 10 # and can be used as a basis for localization of Comment Challenge 11 # 12 # To create a localization, simply do the following: 13 # 14 # 1) Create a copy of this file with a name beginning with your 15 # language code and ending in '.pm'. For example, a French 16 # localization file would be named 'fr.pm'. 17 # 2) Translate the strings on the right side of the => operators 18 # below or on the following line if following a => operator. 19 # You must use a backslash to escape single quotes. 20 # 3) Replace all occurances of 'en_us' in this file with your 21 # own language code 22 # 7 23 package commchallenge::L10N::en_us; 8 9 24 use strict; 10 11 25 use base 'commchallenge::L10N'; 12 26 use vars qw( %Lexicon ); 13 %Lexicon = (); 27 28 %Lexicon = ( 29 30 # 31 # Strings from plugin template 32 # 33 'Beacon:' => 'Beacon:', 34 'BEACON_SETTING' => 'Check for MTCommentChallenge beacon in comment submissions.', 35 'BEACON_DESCRIPTION' => 36 'This option prevents spam bots from directly injecting comments into the system via the comment script.', 37 'BEACON_WARNING' => 'WARNING: Make sure that the MTCommentChallenge tag is in your templates and that they are rebuilt before enabling this option', 38 39 'THROTTLE_SETTING' => 'Deny ("throttle") submissions without beacon (instead of Junking)', 40 'THROTTLE_DESCRIPTION' => 'While throttling such submissions reduces the load on the system, it could also cause lost comments if the MTCommentChallenge tag is not in your comment form. <strong>See plugin documentation for discussion</strong> before enabling this option.', 41 42 'Challenge/Response CAPTCHA:' => 'Challenge/Response CAPTCHA:', 43 'CAPTCHA_DESCRIPTION' => 'You can optionally present your commenters with a challenge CAPTCHA. The answer given will be compared case-insensitively to the answer you provide below.', 44 'Challenge:' => 'Challenge:', 45 'Response:' => 'Response:', 46 'REBUILD_WARNING' => 'WARNING: If you change this setting and the template containing your comment form is static, you must immediately rebuild that template type after you save this configuration! For most people, this means a rebuild of your individual entries.', 47 48 'Incorrect response action:' => 'Incorrect response action:', 49 'Score comment as Junk' => 'Score comment as Junk', 50 'Inform commenter of problem' => 'Inform commenter of problem', 51 'RESPONSE_DESCRIPTION' => 'Informing the commenter of a blank or incorrect response allows them to correct the error, but if your question is too difficult, their comment is never submitted. See plugin documentation for discussion.', 52 53 # 54 # Strings within the application code 55 # 56 'This anti-spam plugin stops direct injection of comment spam into Movable Type and enables you to implement a challenge/response defense via an accessible CAPTCHA.' => 57 'This anti-spam plugin stops direct injection of comment spam into Movable Type and enables you to implement a challenge/response defense via an accessible CAPTCHA.', 58 59 'Beaconless comment from commenter \'[_1]\' throttled' => 60 'Beaconless comment from commenter \'[_1]\' throttled', 61 62 'A response to the challenge question (\'[_1]\') is required for comment submission. Please go back and enter the correct value.' => 63 'A response to the challenge question (\'[_1]\') is required for comment submission. Please go back and enter the correct value.', 64 65 'Comment throttled from commenter (\'[_1]\') due to blank challenge response.' => 66 'Comment throttled from commenter (\'[_1]\') due to blank challenge response.', 67 68 'Your response to the challenge question (\'[_1]\') was not correct. Please go back and try again.' => 69 'Your response to the challenge question (\'[_1]\') was not correct. Please go back and try again.', 70 71 'Comment throttled from commenter (\'[_1]\') due to incorrect challenge response (\'[_2]\').' => 72 'Comment throttled from commenter (\'[_1]\') due to incorrect challenge response (\'[_2]\').', 73 74 'Challenge beacon not submitted with comment.' => 75 'Challenge beacon not submitted with comment.', 76 77 'Challenge question (\'[_1]\') answered correctly.' => 78 'Challenge question (\'[_1]\') answered correctly.', 79 80 'Comment challenge question (\'[_1]\') not answered.' => 81 'Comment challenge question (\'[_1]\') not answered.', 82 83 'Answer (\'[_1]\') to challenge question (\'[_2]\') does not match stored answer (\'[_3]\').' => 84 'Answer (\'[_1]\') to challenge question (\'[_2]\') does not match stored answer (\'[_3]\').', 85 86 ); 87 88 if ($MT::VERSION < 3.3) { 89 require MT::L10N::en_us; 90 $MT::L10N::en_us::Lexicon{$_} = $Lexicon{$_} 91 foreach keys %Lexicon; 92 } 14 93 15 94 1; trunk/comment_challenge/plugins/commchallenge/tmpl/blog_config.tmpl
r119 r176 5 5 <ul> 6 6 <li> 7 <input type="checkbox" name="commchallenge_mode" id="commchallenge_mode" value="1" <TMPL_IF NAME=COMMCHALLENGE_MODE>checked="checked"</TMPL_IF> onclick="toggleAdvancedPrefs(event,'commchallenge_mode')" /> <MT_TRANS phrase=" Check for MTCommentChallenge beacon in comment submissions.">8 <p><MT_TRANS phrase=" This option prevents spam bots from directly injecting comments into the system via the comment script."> <TMPL_UNLESS NAME=COMMCHALLENGE_MODE><MT_TRANS phrase="WARNING: Make sure that the MTCommentChallenge tag is in your templates and that they are rebuilt before enabling this option"></TMPL_UNLESS> <TMPL_UNLESS NAME=COMMCHALLENGE_THROTTLE_NOBEACON><span id="nobeacon-toggle"><a href="#" onclick="show('nobeacon');hide('nobeacon-toggle');return false;">(advanced)</a></span></TMPL_UNLESS></p>7 <input type="checkbox" name="commchallenge_mode" id="commchallenge_mode" value="1" <TMPL_IF NAME=COMMCHALLENGE_MODE>checked="checked"</TMPL_IF> onclick="toggleAdvancedPrefs(event,'commchallenge_mode')" /> <MT_TRANS phrase="BEACON_SETTING"> 8 <p><MT_TRANS phrase="BEACON_DESCRIPTION"> <TMPL_UNLESS NAME=COMMCHALLENGE_MODE><MT_TRANS phrase="BEACON_WARNING"></TMPL_UNLESS> <TMPL_UNLESS NAME=COMMCHALLENGE_THROTTLE_NOBEACON><span id="nobeacon-toggle"><a href="#" onclick="show('nobeacon');hide('nobeacon-toggle');return false;">(advanced)</a></span></TMPL_UNLESS></p> 9 9 </li> 10 10 </ul> … … 16 16 <ul> 17 17 <li> 18 <input type="checkbox" name="commchallenge_throttle_nobeacon" id="commchallenge_throttle_nobeacon" value="1" <TMPL_IF NAME=COMMCHALLENGE_THROTTLE_NOBEACON>checked="checked"</TMPL_IF> /> <label for="commchallenge_throttle_nobeacon"><MT_TRANS phrase=" Deny ("throttle") submissions without beacon (instead of Junking)"></label>18 <input type="checkbox" name="commchallenge_throttle_nobeacon" id="commchallenge_throttle_nobeacon" value="1" <TMPL_IF NAME=COMMCHALLENGE_THROTTLE_NOBEACON>checked="checked"</TMPL_IF> /> <label for="commchallenge_throttle_nobeacon"><MT_TRANS phrase="THROTTLE_SETTING"></label> 19 19 </li> 20 20 </ul> 21 <p><MT_TRANS phrase=" While throttling such submissions reduces the load on the system, it could also cause lost comments if the MTCommentChallenge tag is not in your comment form. <strong>See plugin documentation for discussion</strong> before enabling this option."></p>21 <p><MT_TRANS phrase="THROTTLE_DESCRIPTION"></p> 22 22 </div> 23 23 </div> … … 30 30 <div class="label"><MT_TRANS phrase="Challenge/Response CAPTCHA:"></div> 31 31 <div class="field"> 32 <p><MT_TRANS phrase=" You can optionally present your commenters with a challenge CAPTCHA. The answer given will be compared case-insensitively to the answer you provide below."></p>32 <p><MT_TRANS phrase="CAPTCHA_DESCRIPTION"></p> 33 33 <ul> 34 34 <li> … … 41 41 </li> 42 42 </ul> 43 <p id="commchallenge_rebuild_warning" style="display:none; background-color: #faa; border: 1px solid #f00;padding: 3px;color: #333;"><MT_TRANS phrase=" WARNING: If you change this setting and the template containing your comment form is static, you must immediately rebuild that template type after you save this configuration! For most people, this means a rebuild of your individual entries."></p>43 <p id="commchallenge_rebuild_warning" style="display:none; background-color: #faa; border: 1px solid #f00;padding: 3px;color: #333;"><MT_TRANS phrase="REBUILD_WARNING"></p> 44 44 </div> 45 45 </div> … … 53 53 <li><input type="radio" name="commchallenge_inform_commenter" value="1" <TMPL_IF NAME=COMMCHALLENGE_INFORM_COMMENTER>checked="checked"</TMPL_IF> class="rb" /> <MT_TRANS phrase="Inform commenter of problem"></li> 54 54 </ul> 55 <p><MT_TRANS phrase=" Informing the commenter of a blank or incorrect response allows them to correct the error, but if your question is too difficult, their comment is never submitted. See plugin documentation for discussion."></p>55 <p><MT_TRANS phrase="RESPONSE_DESCRIPTION"></p> 56 56 </div> 57 57 </div>
