*** lib/MT/Template/ContextHandlers.pm.orig	2006-08-05 04:31:55.000000000 +0900
--- lib/MT/Template/ContextHandlers.pm	2007-02-07 19:27:40.000000000 +0900
***************
*** 2049,2054 ****
--- 2049,2055 ----
      my $comment_email = "";
      my $comment_text = "";
      my $comment_url = "";
+     my $comment_digest = "";
      if ($args->{preview}) {
          local $ctx->{__stash}->{tag} = 'Preview';
          $comment_author = encode_html($ctx->_hdlr_comment_author()) || "";
***************
*** 2056,2061 ****
--- 2057,2076 ----
          $comment_text = encode_html($ctx->_hdlr_comment_body({convert_breaks=>0}), 1);
          $comment_text = '' unless defined $comment_text;
          $comment_url = encode_html($ctx->_hdlr_comment_url()) || "";
+ 
+         use Digest::SHA1;
+         my $sha1 = Digest::SHA1->new;
+         my $sha1_token = $ctx->_hdlr_comment_body({convert_breaks=>0}) . $entry_id . $ENV{'REMOTE_ADDR'} . $ctx->_hdlr_comment_author() . $ctx->_hdlr_comment_email() . $ctx->_hdlr_comment_url();
+         $sha1_token =~ s/\x0D\x0A//g;
+         $sha1_token =~ s/\x0D//g;
+         $sha1_token =~ s/\x0A//g;
+         $sha1->add($sha1_token);
+         my $FH;
+         my $salt_file = MT::ConfigMgr->instance->PluginPath .'/salt.txt';
+         open($FH, $salt_file) or die "cannot open file <$salt_file> ($!)";
+         $sha1->addfile($FH);
+         close $FH;
+         $comment_digest = $sha1->b64digest . "=";
      }
  
      my $rem_auth_token = $blog->effective_remote_auth_token() || "";
***************
*** 2098,2103 ****
--- 2113,2119 ----
  <form method="post" action="$path$comment_script" name="comments_form" onsubmit="if (this.bakecookie[0].checked) rememberMe(this)">
  $static_field
  <input type="hidden" name="entry_id" value="$entry_id" />
+ <input type="hidden" name="validated" value="$comment_digest" />
  
  <p><label for="url">URL:</label><br />
  <input tabindex="1" type="text" name="url" id="url" value="$comment_url" />
***************
*** 2163,2168 ****
--- 2179,2185 ----
  <form method="post" action="$path$comment_script" name="comments_form" onsubmit="if (this.bakecookie[0].checked) rememberMe(this)">
  $static_field
  <input type="hidden" name="entry_id" value="$entry_id" />
+ <input type="hidden" name="validated" value="$comment_digest" />
  
  <div id="name_email">
  <p><label for="author"><MT_TRANS phrase="Name:"></label><br />
