本文整理汇总了PHP中Captcha::is_answered方法的典型用法代码示例。如果您正苦于以下问题:PHP Captcha::is_answered方法的具体用法?PHP Captcha::is_answered怎么用?PHP Captcha::is_answered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Captcha
的用法示例。
在下文中一共展示了Captcha::is_answered方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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);
}
}
示例2: setcookie
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 . "<blog@twanvl.nl>";
$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";