Ejemplo n.º 1
0
 /**
  * Generate a new captcha ID or retrieve the current ID
  *
  * @param $new bool If true, generates a new challenge and returns and ID
  * @param $options array Additional options to be passed to Securimage.
  * Must include database options if not set directly in securimage.php
  *
  * @return null|string Returns null if no captcha id set and new was false, or string captcha ID
  */
 public static function getCaptchaId($new = true, array $options = array())
 {
     if (is_null($new) || (bool) $new == true) {
         $id = sha1(uniqid($_SERVER['REMOTE_ADDR'], true));
         $opts = array('no_session' => true, 'use_database' => true);
         if (sizeof($options) > 0) {
             $opts = array_merge($options, $opts);
         }
         $si = new self($opts);
         Securimage::$_captchaId = $id;
         $si->createCode();
         return $id;
     } else {
         return Securimage::$_captchaId;
     }
 }