예제 #1
0
 /**
  * FormHandler::captchaField()
  *
  * Creates a captchafield on the form using Securimage - A PHP class for creating and managing form CAPTCHA images
  *
  * @param string $title: The title of the field
  * @param string $name: The name of the field
  * @param int $size: The size of the field
  * @param int $maxlength: The allowed max input of the field
  * @param string $extra: CSS, Javascript or other which are inserted into the HTML tag
  * @return void
  * @access public
  * @author Johan Wiegel
  * @since 27-11-2007
  */
 function CaptchaField($title, $name, $size = null, $maxlength = null, $extra = null)
 {
     static $bCaptcha = true;
     if ($bCaptcha) {
         $bCaptcha = false;
         require_once FH_INCLUDE_DIR . 'fields/class.TextField.php';
         // create the field
         $fld = new TextField($this, $name);
         if ($this->isPosted()) {
             $fld->setValidator('FH_CAPTCHA');
         }
         if (!empty($size)) {
             $fld->setSize($size);
         }
         if (!empty($maxlength)) {
             $fld->setMaxlength($maxlength);
         }
         if (!empty($extra)) {
             $fld->setExtra($extra);
         }
         $this->ImageButton(FH_FHTML_DIR . 'securimage/securimage_show.php?sid=' . md5(uniqid(time())), null, 'onclick="return false;" style="cursor:default;"');
         // register the field
         $this->_registerField($name, $fld, $title);
         // empty the field if the value was not correct.
         if ($this->isPosted() && !$this->isCorrect()) {
             $this->setValue($name, "", true);
         }
     } else {
         trigger_error("Only one captchafield in a form", E_USER_WARNING);
     }
 }