Salve a tutti,
mi sono iscritto in questo forum nella speranza che qualcuno possa darmi una mano anche se da molto segue le vostre discussioni (molto utili)
Ho questo plugin di Joomla al quale dovrei aggiungere una checkbox da spuntare obbligatoriamente prima dell'invio del form con il classico testo della privacy ma dopo tutte le prove che ho fatto mi da sempre errore...
Codice PHP:
if($this->params->get('use_recaptcha') == 1 && stripos($buffer, '{nomeplugin}')) { $app = JFactory::getApplication(); $lang = $this->_getLanguage(); $pubkey = $this->params->get('public_key', ''); $server = 'https://www.google.com/recaptcha/api'; $output .= '<script src="'. $server . '/js/recaptcha_ajax.js"></script>'; $output .= '<script>jQuery(document).ready(function() {Recaptcha.create("' . $pubkey . '", "dynamic_recaptcha_1", {theme: "clean",' . $lang . 'tabindex: 0});});</script>'; } // output the main wrapper $output .= '<div class="nomepluginForm">'; // // output the form // // get the current page URL $cur_url = ((!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS']!='off')) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $cur_url = preg_replace('@%[0-9A-Fa-f]{1,2}@mi', '', htmlspecialchars($cur_url, ENT_QUOTES, 'UTF-8')); // $output .= '<form action="'.$cur_url.'" method="post">'; if( $this->params->get('date_field') == 1 || $this->params->get('time_field') == 1 || $this->params->get('size_field') == 1 ) { $output .= '<div class="nomeplugin-party-details">'; } if($this->params->get('date_field') == 1) { $output .= '<div class="nomeplugin-date"><input type="text" class="auto-kal required" placeholder="'.JText::_('PLG_nomeplugin_DATE_PLACEHOLDER').'" name="nomeplugin-date" /></div>'; } if($this->params->get('time_field') == 1) { $output .= '<div class="nomeplugin-time"><input type="text" class="required" placeholder="'.JText::_('PLG_nomeplugin_TIME_PLACEHOLDER').'" name="nomeplugin-time" /></div>'; } if($this->params->get('size_field') == 1) { $output .= '<input type="text" class="required" placeholder="'.JText::_('PLG_nomeplugin_SIZE_PLACEHOLDER').'" name="nomeplugin-size" />'; } if( $this->params->get('date_field') == 1 || $this->params->get('time_field') == 1 || $this->params->get('size_field') == 1 ) { $output .= '</div>'; }
$output .= '<div class="nomeplugin-party-info">'; if($this->params->get('name_field') == 1) { $output .= '<input type="text" class="required" placeholder="'.JText::_('PLG_nomeplugin_NAME_PLACEHOLDER').'" name="nomeplugin-name" />'; } if($this->params->get('email_field') == 1) { $output .= '<input type="email" class="required" placeholder="'.JText::_('PLG_nomeplugin_EMAIL_PLACEHOLDER').'" name="nomeplugin-email" />'; } if($this->params->get('phone_field') == 1) { $output .= '<input type="text" class="required" placeholder="'.JText::_('PLG_nomeplugin_PHONE_PLACEHOLDER').'" name="nomeplugin-phone" />'; } if($this->params->get('text_field') == 1) { $output .= '<textarea name="nomeplugin-text" class="required" placeholder="'.JText::_('PLG_nomeplugin_TEXT_PLACEHOLDER').'"></textarea>'; } if($this->params->get('additional_text') != '') { $output .= '<small>'.$this->params->get('additional_text').'</small>'; } if($this->params->get('use_recaptcha') == 1) { $output .= '<div id="dynamic_recaptcha_1"></div>'; } $output .= '<p><input type="submit" value="'.JText::_('PLG_nomeplugin_SEND_BTN').'" class="submit button-border" /></p>';
$output .= '</div>'; $output .= '<input type="hidden" value="'.$cur_url.'" name="return" />'; $output .= JHtml::_( 'form.token' ); $output .= '</form>'; // close the main wrapper $output .= '</div>'; // replace the {nomeplugin} string with the generated output $buffer = str_replace('{nomeplugin}', $output, $buffer); // save the changes in the buffer JResponse::setBody($buffer); return true; } // Prepare the form function onAfterInitialise() { $post = JRequest::get('post'); if(isset($post['nomeplugin-text'])) { $app = JFactory::getApplication(); // if reCaptcha is enabled if($this->params->get('use_recaptcha') == 1) { JPluginHelper::importPlugin('captcha'); $dispatcher = JDispatcher::getInstance(); $res = $dispatcher->trigger('onCheckAnswer', $post['recaptcha_response_field']); if(!$res[0]){ $app->redirect($post['return'],JText::_('PLG_nomeplugin_RECAPTCHA_ERROR'),"error"); } } // check the token JSession::checkToken() or die( 'Invalid Token' ); // if the reCaptcha and token are correct - check the mail data: // get the mailing api $mailer = JFactory::getMailer(); // set the sender $config = JFactory::getConfig(); $sender = array( $config->get('config.mailfrom'), $config->get('config.fromname') ); $mailer->setSender($sender); // set the recipient if(trim($this->params->get('emails')) != '') { $mailer->addRecipient(explode(',', $this->params->get('emails'))); // use XSS filters $filter = JFilterInput::getInstance(); // Fields $name = $this->params->get('name_field') == 1 ? $filter->clean($post['nomeplugin-name']) : ''; $email = $this->params->get('email_field') == 1 ? $filter->clean($post['nomeplugin-email']) : ''; $phone = $this->params->get('phone_field') == 1 ? $filter->clean($post['nomeplugin-phone']) : ''; $date = $this->params->get('date_field') == 1 ? $filter->clean($post['nomeplugin-date']) : ''; $time = $this->params->get('time_field') == 1 ? $filter->clean($post['nomeplugin-time']) : ''; $size = $this->params->get('size_field') == 1 ? $filter->clean($post['nomeplugin-size']) : ''; $text = trim($filter->clean($post['nomeplugin-text'])); $title = JText::_('PLG_nomeplugin_STANDARD_SUBJECT') . $config->get('config.sitename'); if( ($this->params->get('name_field') == 0 || ($this->params->get('name_field') == 1 && $name != '')) && ($this->params->get('email_field') == 0 || ($this->params->get('email_field') == 1 && $email != '')) && ($this->params->get('phone_field') == 0 || ($this->params->get('phone_field') == 1 && $phone != '')) && ($this->params->get('date_field') == 0 || ($this->params->get('date_field') == 1 && $date != '')) && ($this->params->get('time_field') == 0 || ($this->params->get('time_field') == 1 && $time != '')) && ($this->params->get('size_field') == 0 || ($this->params->get('size_field') == 1 && $size != '')) ) {
Grazie