Changeset 209 for captcha/trunk
- Timestamp:
- 05/19/06 02:20:14 (3 years ago)
- Location:
- captcha/trunk/plugins/captcha
- Files:
-
- 3 modified
-
captcha.pl (modified) (4 diffs)
-
captcha_js.cgi (modified) (1 diff)
-
captcha_js.fcgi (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
captcha/trunk/plugins/captcha/captcha.pl
r207 r209 16 16 use Authen::Captcha; 17 17 use base 'MT::Plugin'; 18 our $VERSION = '0.0 1';18 our $VERSION = '0.02'; 19 19 20 20 my $plugin = __PACKAGE__->new({ … … 25 25 author_link => 'http://profile.typekey.com/ogawa/', 26 26 version => $VERSION, 27 blog_config_template => \&config_tmpl, 28 settings => new MT::PluginSettings([ 29 ['captcha_ttl', { Default => 3600 }], 30 ]), 27 31 }); 28 32 MT->add_plugin($plugin); … … 49 53 my $md5 = $q->param('captcha_md5') or return 0; 50 54 55 my $ttl = config('blog:' . $blog->id)->{captcha_ttl}; 56 $ttl = 3600 if $ttl !~ /^\d+$/; 57 $captcha->expire($ttl); 58 51 59 ($captcha->check_code($code, $md5) > 0) ? 1 : 0; 52 60 } … … 59 67 } 60 68 69 use MT::Request; 70 sub config { 71 return {} unless $plugin; 72 my $scope = shift || 'system'; 73 my $r = MT::Request->instance; 74 my $cfg = $r->cache('captcha_config_' . $scope); 75 if (!$cfg) { 76 $cfg = $plugin->get_config_hash($scope); 77 $r->cache('captcha_config_' . $scope, $cfg); 78 } 79 $cfg; 80 } 81 82 sub config_tmpl { 83 my $tmpl = <<'EOT'; 84 <div class="setting"> 85 <div class="label"><label for="captcha_ttl"><MT_TRANS phrase="CAPTCHA TTL:"></label></div> 86 <div class="field"> 87 <input name="captcha_ttl" id ="captcha_ttl" size="5" value="<TMPL_VAR NAME=CAPTCHA_TTL ESCAPE=HTML>" /> <MT_TRANS phrase="seconds"> (max: 3600 seconds) 88 </div> 89 </div> 90 EOT 91 } 92 61 93 1; -
captcha/trunk/plugins/captcha/captcha_js.cgi
r206 r209 7 7 8 8 my $captcha = Authen::Captcha->new(data_folder => './data', 9 output_folder => './images'); 9 output_folder => './images', 10 expire => 3600); 10 11 my $captcha_length = 5; 11 12 my $captcha_img_width = 25 * $captcha_length; -
captcha/trunk/plugins/captcha/captcha_js.fcgi
r206 r209 7 7 8 8 my $captcha = Authen::Captcha->new(data_folder => './data', 9 output_folder => './images'); 9 output_folder => './images', 10 expire => 3600); 10 11 my $captcha_length = 5; 11 12 my $captcha_img_width = 25 * $captcha_length;
![(please configure the [header_logo] section in trac.ini)](/public/chrome/common/trac_banner.png)