Changeset 26
- Timestamp:
- 08/30/09 21:03:00 (1 year ago)
- Files:
-
- trunk/examples/httpd-blogsum.conf (modified) (1 diff)
- trunk/index.cgi (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/httpd-blogsum.conf
r17 r26 15 15 SetHandler perl-script 16 16 PerlHandler Apache::PerlRun 17 PerlModule strict CGI DBI DBD::SQLite HTML::Template XML::RSS Captcha::reCAPTCHA HTML::Entities HTTP::Request::Common URI::_foreign Errno Net::HTTP IO::Select Compress::Zlib Log::Agent URI::http LWP::Protocol::http Carp::Heavy17 PerlModule strict CGI DBI DBD::SQLite HTML::Template XML::RSS Net::SMTP Captcha::reCAPTCHA HTML::Entities HTTP::Request::Common URI::_foreign Errno Net::HTTP IO::Select Compress::Zlib Log::Agent URI::http LWP::Protocol::http Carp::Heavy 18 18 Options ExecCGI 19 19 Order deny,allow trunk/index.cgi
r25 r26 20 20 my $comment_max_length = '1000'; 21 21 my $comments_allowed = 0; 22 my $smtp_server = 'localhost:25'; 23 my $smtp_sender = 'blogsum@example.com'; 22 24 23 25 … … 240 242 241 243 if ($cgi->param('recaptcha_response_field') && $cgi->param('comment') && $cgi->param('id')) { 244 242 245 # test our captcha 243 246 my $result = $captcha->check_answer( $captcha_seckey, $ENV{'REMOTE_ADDR'}, $cgi->param('recaptcha_challenge_field'), $cgi->param('recaptcha_response_field') ); 247 244 248 if ($result->{'is_valid'}) { 249 245 250 # save comment 246 251 my $comment = $cgi->param('comment'); … … 250 255 $sth->execute($cgi->param('id'), $cgi->param('name') || 'anonymous', $cgi->param('email') || undef, $cgi->param('url') || undef, substr(HTML::Entities::encode($cgi->param('comment')), 0, $comment_max_length)) || die $dbh->errstr; 251 256 $template->param( message => 'comment awaiting moderation, thank you' ); 257 258 # send email notification 259 my $smtp = Net::SMTP->new($smtp_server); 260 $smtp->mail($ENV{USER}); 261 $smtp->to("$blog_owner\n"); 262 $smtp->data(); 263 $smtp->datasend("From: $smtp_sender\n"); 264 $smtp->datasend("To: $blog_owner\n"); 265 $smtp->datasend("Subject: $blog_title comment submission\n\n"); 266 $smtp->datasend("You have received a new comment submission.\n\n"); 267 $smtp->datasend(sprintf("From: %s\n", $cgi->param('name') || 'anonymous')); 268 $smtp->datasend(sprintf("Date: %s\n", scalar(localtime))); 269 $smtp->datasend(sprintf("Comment:\n\"%s\"\n\n", substr(HTML::Entities::encode($cgi->param('comment')), 0, $comment_max_length))); 270 $smtp->datasend("Moderate comments at ${blog_url}admin.cgi?view=moderate\n"); 271 $smtp->dataend(); 272 $smtp->quit; 252 273 } else { 253 274 $template->param( error => $friendly_errors{ $result->{'error'} } );
