/**
  * Rendering the output of the captcha
  *
  * @return string
  */
 public function render()
 {
     $this->objectManager->get(\Evoweb\SfRegister\Services\Session::class)->remove('captchaWasValidPreviously');
     if ($this->captcha !== null) {
         /** @noinspection PhpUndefinedMethodInspection */
         $values = array_values($this->captcha->makeCaptcha());
         $output = array_combine($this->keys, $values);
     } else {
         $output = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_captcha_notinstalled', 'SfRegister', array('sr_freecap'));
     }
     return $output;
 }
 /**
  * Checks the tipUrl and returns the form.
  *
  * @return string
  */
 protected function tipform()
 {
     $content = '';
     $tipUrl = t3lib_div::_GP('tipUrl');
     $tipHash = (string) t3lib_div::_GP('tipHash');
     $calculatedHmac = t3lib_div::hmac($tipUrl, $this->hmacSalt);
     if ($tipHash !== $calculatedHmac) {
         // Show 404 error
         $GLOBALS['TSFE']->pageNotFoundAndExit($this->pi_getLL('no_valid_url'));
     } else {
         $GLOBALS['TSFE']->set_no_cache();
         $tipData = t3lib_div::_GP('TIPFORM');
         $tipData['recipient'] = $this->getRecipients($tipData['recipient']);
         list($tipData['email']) = explode(',', $this->getRecipients($tipData['email']));
         $url = strip_tags($tipUrl);
         // Preparing markers
         $wrappedSubpartArray = array();
         $subpartArray = array();
         $markerArray = array();
         $markerArray['###FORM_URL###'] = t3lib_div::getIndpEnv('REQUEST_URI');
         $markerArray['###URL###'] = $url;
         $markerArray['###URL_ENCODED###'] = rawurlencode($url);
         $markerArray['###URL_SPECIALCHARS###'] = htmlspecialchars($url);
         $markerArray['###URL_DISPLAY###'] = htmlspecialchars(strlen($url) > 70 ? t3lib_div::fixed_lgd_cs($url, 30) . t3lib_div::fixed_lgd_cs($url, -30) : $url);
         $markerArray['###HASH###'] = t3lib_div::hmac($url, $this->hmacSalt);
         $markerArray['###HASH_ENCODED###'] = t3lib_div::hmac(rawurlencode($url), $this->hmacSalt);
         // Because htmlspecialchared urls are resolved correctly (browsers convert the link themselves) we just need the normal hash
         $markerArray['###HASH_SPECIALCHARS###'] = t3lib_div::hmac($url, $this->hmacSalt);
         $markerArray['###TAF_LABEL_ERROR###'] = $this->pi_getLL('error');
         $markerArray['###TAF_ERROR_EXPL###'] = $this->pi_getLL('error_expl');
         $markerArray['###TAF_LABEL_NAME###'] = $this->pi_getLL('name');
         $markerArray['###TAF_LABEL_EMAIL###'] = $this->pi_getLL('email');
         $markerArray['###TAF_TITLE###'] = $this->pi_getLL('title');
         $markerArray['###TAF_LABEL_PATH###'] = $this->pi_getLL('path');
         $markerArray['###TAF_LABEL_EMAIL_RECIPENT###'] = $this->pi_getLL('email_recipent');
         $markerArray['###TAF_LABEL_MESSAGE###'] = $this->pi_getLL('message');
         $markerArray['###TAF_LABEL_HTML###'] = $this->pi_getLL('html');
         if (!$this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'checkbox_html', 'sDEF')) {
             $subpartArray['###HTML_INSERT###'] = '';
         }
         $markerArray['###TAF_LABEL_MUST###'] = $this->pi_getLL('must');
         $markerArray['###TAF_LABEL_SEND###'] = $this->pi_getLL('send');
         $disclaimer = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'disclaimer_text', 'sDEF');
         if (empty($disclaimer)) {
             $disclaimer = $this->pi_getLL('disclaimer');
         }
         $markerArray['###TAF_DISCLAIMER###'] = $disclaimer;
         $markerArray['###TAF_CONFIRMATION###'] = $this->pi_getLL('confirmation');
         $markerArray['###TAF_LABEL_BACK###'] = $this->pi_getLL('back');
         $markerArray['###FORM_CAPTCHA_RESPONSE###'] = $this->pi_getLL('form_captcha_response');
         $wrappedSubpartArray['###LINK###'] = array('<a href="' . htmlspecialchars($url) . '">', '</a>');
         // code inserted to use free Captcha
         if (is_object($this->freeCap)) {
             $markerArray = array_merge($markerArray, $this->freeCap->makeCaptcha());
         } else {
             $subpartArray['###CAPTCHA_INSERT###'] = '';
         }
         // code inserted to use free Captcha
         // validation
         $error = 0;
         $sent = 0;
         if (t3lib_div::_GP('sendTip')) {
             if ($this->validate($tipData, $url)) {
                 $this->sendTip($tipData, $url);
                 $sent = 1;
             } else {
                 $error = 1;
             }
         }
         // Display form
         if ($sent) {
             $subpart = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_TIPFORM_SENT###');
             $markerArray['###RECIPIENT###'] = htmlspecialchars($tipData['recipient']);
             $content = $this->cObj->substituteMarkerArrayCached($subpart, $markerArray, $subpartArray, $wrappedSubpartArray);
         } else {
             $captchaHTMLoutput = t3lib_extMgm::isLoaded('captcha') ? '<img src="' . t3lib_extMgm::siteRelPath('captcha') . 'captcha/captcha.php" alt="" />' : '';
             // Generate Captcha data and store string in session:
             $subpart = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_TIPFORM###');
             $markerArray['###MESSAGE###'] = htmlspecialchars($tipData['message']);
             $markerArray['###RECIPIENT###'] = htmlspecialchars($tipData['recipient']);
             // Pre-fill form data if FE user in logged in
             if ($GLOBALS['TSFE']->loginUser) {
                 $markerArray['###YOUR_EMAIL###'] = $GLOBALS['TSFE']->fe_user->user['email'];
                 $markerArray['###YOUR_NAME###'] = $GLOBALS['TSFE']->fe_user->user['name'];
             } else {
                 $markerArray['###YOUR_EMAIL###'] = htmlspecialchars($tipData['email']);
                 $markerArray['###YOUR_NAME###'] = htmlspecialchars($tipData['name']);
             }
             $markerArray['###HTML_MESSAGE###'] = $tipData['html_message'] ? 'checked' : '';
             $markerArray['###CAPTCHA_HTML###'] = $captchaHTMLoutput;
             if (!$error) {
                 $subpartArray['###ERROR_MSG###'] = '';
             }
             // Substitute
             $content = $this->cObj->substituteMarkerArrayCached($subpart, $markerArray, $subpartArray, $wrappedSubpartArray);
         }
     }
     return $content;
 }