Returns a new or the current CAPTCHA string.
public getCAPTCHA ( boolean $new = false ) : string | ||
$new | boolean | If true, a new CAPTCHA is created and returned. The current, to-be-confirmed string otherwise. |
Результат | string | A CAPTCHA string. |
function validate(&$vars, $canAutoFill = false) { global $conf; if (!parent::validate($vars, $canAutoFill)) { if (!$GLOBALS['registry']->getAuth() && !empty($conf['forums']['captcha'])) { $vars->remove('captcha'); $this->removeVariable($varname = 'captcha'); $this->insertVariableBefore('newcomment', _("Spam protection"), 'captcha', 'figlet', true, null, null, array(Agora::getCAPTCHA(true), $conf['forums']['figlet_font'])); } return false; } return true; }
/** */ public function getForm($vars, $title, $editing = false, $new_forum = false) { global $conf; $form = new Agora_Form_Message($vars, $title); $form->setButtons($editing ? _("Save") : _("Post")); $form->addHidden('', 'url', 'text', false); /* Figure out what to do with forum IDs. */ if ($new_forum) { /* This is a new forum to be created, create the var to hold the * full path for the new forum. */ $form->addHidden('', 'new_forum', 'text', false); } else { /* This is an existing forum so create the forum ID variable. */ $form->addHidden('', 'forum_id', 'int', false); } $form->addHidden('', 'scope', 'text', false); $form->addHidden('', 'message_id', 'int', false); $form->addHidden('', 'message_parent_id', 'int', false); if (!$GLOBALS['registry']->getAuth()) { $form->addVariable(_("From"), 'posted_by', 'text', true); } /* We are replaying, so display the quote button */ if ($vars->get('message_parent_id')) { $desc = '<input type="button" value="' . _("Quote") . '" class="button" ' . 'onClick="this.form.message_body.value=this.form.message_body.value + this.form.message_body_old.value; this.form.message_body_old.value = \'\';" />'; $form->addVariable(_("Subject"), 'message_subject', 'text', true, false, $desc); $form->addHidden('', 'message_body_old', 'longtext', false); } else { $form->addVariable(_("Subject"), 'message_subject', 'text', true); } $form->addVariable(_("Message"), 'message_body', 'longtext', true); /* Check if an attachment is available and set variables for deleting * and previewing. */ if ($vars->get('attachment_preview')) { $form->addVariable(_("Delete the existing attachment?"), 'attachment_delete', 'boolean', false); $form->addVariable(_("Current attachment"), 'attachment_preview', 'html', false); } if ($this->allowAttachments()) { $form->addVariable(_("Attachment"), 'message_attachment', 'file', false); } if (!empty($conf['forums']['captcha']) && !$GLOBALS['registry']->getAuth()) { $form->addVariable(_("Spam protection"), 'captcha', 'figlet', true, null, null, array(Agora::getCAPTCHA(!$form->isSubmitted()), $conf['forums']['figlet_font'])); } return $form; }