make recaptcha work

This commit is contained in:
Shish 2009-11-10 03:01:20 +00:00
parent 76393c2c59
commit 6bee15164f
2 changed files with 7 additions and 4 deletions

View File

@ -342,8 +342,7 @@ class CommentList extends SimpleExtension {
} }
private function is_spam_recaptcha($text) { private function is_spam_recaptcha($text) {
global $user; global $config, $user;
global $config;
if(strlen($config->get_string('comment_recaptcha_privkey')) > 0) { if(strlen($config->get_string('comment_recaptcha_privkey')) > 0) {
$resp = recaptcha_check_answer( $resp = recaptcha_check_answer(
@ -353,7 +352,7 @@ class CommentList extends SimpleExtension {
$_POST["recaptcha_response_field"]); $_POST["recaptcha_response_field"]);
if(!$resp->is_valid) { if(!$resp->is_valid) {
log_info("Captcha failed: " . $resp->error); log_info("comment", "Captcha failed: " . $resp->error);
return true; return true;
} }
} }
@ -362,6 +361,7 @@ class CommentList extends SimpleExtension {
} }
private function is_spam_akismet($text) { private function is_spam_akismet($text) {
global $config, $user;
if(strlen($config->get_string('comment_wordpress_key')) > 0) { if(strlen($config->get_string('comment_wordpress_key')) > 0) {
$comment = array( $comment = array(
'author' => $user->name, 'author' => $user->name,

View File

@ -145,11 +145,14 @@ class CommentListTheme extends Themelet {
} }
protected function build_postbox($image_id) { protected function build_postbox($image_id) {
global $config, $user;
$i_image_id = int_escape($image_id); $i_image_id = int_escape($image_id);
$hash = CommentList::get_hash(); $hash = CommentList::get_hash();
$rpk = $config->get_string("comment_recaptcha_pubkey"); $rpk = $config->get_string("comment_recaptcha_pubkey");
$reca = empty($rpk) ? "" : recaptcha_get_html($rpk); $reca = (!$user->is_anonymous() || empty($rpk)) ?
"" : recaptcha_get_html($rpk);
return " return "
<form action='".make_link("comment/add")."' method='POST'> <form action='".make_link("comment/add")."' method='POST'>
<input type='hidden' name='image_id' value='$i_image_id' /> <input type='hidden' name='image_id' value='$i_image_id' />