Agora::getCAPTCHA PHP Метод

getCAPTCHA() публичный Метод

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 getCAPTCHA($new = false)
    {
        global $session;
        if ($new || !$session->get('agora', 'captcha')) {
            $captcha = '';
            for ($i = 0; $i < 5; ++$i) {
                $captcha .= chr(rand(65, 90));
            }
            $session->set('agora', 'captcha', $captcha);
        }
        return $session->get('agora', 'captcha');
    }

Usage Example

Пример #1
0
 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;
 }
All Usage Examples Of Agora::getCAPTCHA