function __construct() { if (Captcha::is_answered()) { $this->question = $_REQUEST['captcha_question']; $this->answer = $_REQUEST['captcha_answer']; } else { $i = rand() % 15; $j = rand() % 15; $this->question = "{$i} + {$j} = "; //$this->question = format_number($i) . " + " . format_number($j) . " = "; $this->answer = $i + $j; $this->answer = sha1(CAPTCHA_SECRET . $this->answer); } }
setcookie('author_subscribe', isset($_POST['author_subscribe']) ? 1 : 0, time() + 60 * 60 * 24 * 365 * 2, '/'); // is it valid? global $invalid_fields; if (strlen(@$_REQUEST['author_name']) < 3) { $invalid_fields['author_name'] = "Enter your name"; } if (strlen(@$_REQUEST['author_email']) > 0 && strpos(@$_REQUEST['author_email'], '@') === false) { $invalid_fields['author_email'] = "Enter a valid email address"; } if (strlen(@$_REQUEST['body']) < 4) { $invalid_fields['body'] = "Enter a message"; } if ($comment->is_spam()) { $invalid_fields[''] = "Go away spammer!."; } if (!Captcha::is_answered()) { $invalid_fields['captcha'] = "Go away spammer!."; } $ok = count($invalid_fields) == 0; // store if ($ok) { $ok = Comments::add_comment($page->url, $comment); } // store and done if ($ok) { // send email to subscribers $mail_subject = "Reply to blog post '{$page->title}'"; $mail_from = BLOG_TITLE . "<*****@*****.**>"; $mail_headers = "From: {$mail_from}\r\nReply-To: {$mail_from}"; $mail_body = "{$comment->author_name} has replied to a blog post *{$page->title}*, to which you are subscribed.\n\n"; $mail_body .= "Url: " . $page->full_url() . "#comment-" . $comment->id . "\n\n";