Example #1
0
 /**
  * Return the HTML of the field
  *
  * @return string the html
  * @author Teye Heimans
  */
 public function getField()
 {
     // empty the field if the value was not correct.
     if ($this->form_object->isPosted() && !$this->form_object->isCorrect()) {
         $this->setValue('', true);
     }
     // view mode enabled ?
     if ($this->getViewMode()) {
         // get the view value..
         return '';
     }
     $session_id = \session_id();
     //get url from configuration
     $configured_url = \FormHandler\Configuration::get('securimage_url');
     $url = is_null($configured_url) ? \FormHandler\Configuration::get('fhtml_dir') . 'securimage/securimage_show.php' : $configured_url;
     $url .= '?sid=' . md5(uniqid(time())) . '&session_id=' . $session_id . '&width=' . $this->width . '&height=' . $this->height . '&length=' . $this->getSize();
     $this->image->setImage($url);
     $refresh_text = \FormHandler\Language::get(44);
     $current_url = @htmlspecialchars($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], ENT_COMPAT, 'UTF-8');
     $refresh = '<a id="captcha_refresh" href="//' . $current_url . '" onclick="document.getElementById(\'' . $this->getName() . '_image\').src=\'' . $url . '\'; return false;">' . $refresh_text . '</a>';
     return $this->image->getButton() . "<br>" . $refresh . "<br>" . parent::getField();
 }