Einzelnen Beitrag anzeigen
  #2  
Alt 26.02.2018, 09:19:57
meckermohrli meckermohrli ist offline
Anfänger
 
Registriert seit: Feb 2018
Alter: 45
Beiträge: 5
meckermohrli befindet sich auf einem aufstrebenden Ast
AW: Formular erweitern

PHP-Code:
        //inputs
        
$inputs $input->get('data', array(), 'ARRAY');

        foreach (
$inputs as $input) {

            if (
$input['name'] == 'captcha_type') {
                
$captcha_type $input['value'];
            }

            if (
$input['name'] == 'recipient') {
                
$recipient base64_decode($input['value']);
            }

            if (
$input['name'] == 'from_email') {
                
$from_email base64_decode($input['value']);
            }

            if (
$input['name'] == 'from_name') {
                
$from_name base64_decode($input['value']);
            }

            if (
$input['name'] == 'email') {
                
$email $input['value'];
            }

            if (
$input['name'] == 'name') {
                
$name $input['value'];
            }
            if (
$input['name'] == 'subject') {
                
$subject $input['value'];
            }
            if (
$input['name'] == 'message') {
                
$message nl2br($input['value']);
            }

            if (
$input['name'] == 'captcha_question') {
                
$captcha_question $input['value'];
            }

            if (
$input['name'] == 'captcha_answer') {
                
$captcha_answer $input['value'];
                
$showcaptcha true;
            }

            if (
$input['name'] == 'g-recaptcha-response') {
                
$gcaptcha $input['value'];
                
$showcaptcha true;
            }
        }

        
$output = array();
        
$output['status'] = false;

        if (
$showcaptcha) {
            if (
$captcha_type == 'gcaptcha') {
                
JPluginHelper::importPlugin('captcha');
                
$dispatcher JEventDispatcher::getInstance();
                
$res $dispatcher->trigger('onCheckAnswer');
                if (!
$res[0]) {
                    
$output['content'] = '<span class="sppb-text-danger">' JText::_('COM_SPPAGEBUILDER_ADDON_AJAX_CONTACT_INVALID_CAPTCHA') . '</span>';
                    return 
json_encode($output);
                }
            } else {
                if (
md5($captcha_question) != $captcha_answer) {
                    
$output['content'] = '<span class="sppb-text-danger">' JText::_('COM_SPPAGEBUILDER_ADDON_AJAX_CONTACT_WRONG_CAPTCHA') . '</span>';
                    return 
json_encode($output);
                }
            }
        }

        
$sender = array($email$name);

        if (!empty(
$from_email)) {
            
$sender = array($from_email$from_name);
            
$mail->addReplyTo($email$name);
        }

        
$mail->setSender($sender);
        
$mail->addRecipient($recipient);
        
$mail->setSubject($subject);
        
$mail->isHTML(true);
        
$mail->Encoding 'base64';
      
       
$message .= '<p>';
        
$message .= nl2br(JText::_('COM_SPPAGEBUILDER_ADDON_AJAX_CONTACT_NAME') . ': ' $name) . '<br>';
        
$message .= nl2br(JText::_('COM_SPPAGEBUILDER_ADDON_AJAX_CONTACT_EMAIL') . ': ' $email) . '<br>';
        
$message .= nl2br(JText::_('COM_SPPAGEBUILDER_ADDON_AJAX_CONTACT_SUBJECT') . ': ' $subject) . '<br>';
        
$message .= '</p>';
        
$message .= '<hr>';
      
      
        
$mail->setBody($message);

        if (
$mail->Send()) {
            
$output['status'] = true;
            
$output['content'] = '<span class="sppb-text-success">' JText::_('COM_SPPAGEBUILDER_ADDON_AJAX_CONTACT_SUCCESS') . '</span>';
        } else {
            
$output['content'] = '<span class="sppb-text-danger">' JText::_('COM_SPPAGEBUILDER_ADDON_AJAX_CONTACT_FAILED') . '</span>';
        }

        return 
json_encode($output);
    }

    public function 
css() {
        
$addon_id '#sppb-addon-' $this->addon->id;
        
$layout_path JPATH_ROOT '/components/com_sppagebuilder/layouts';
        
$css_path = new JLayoutFile('addon.css.button'$layout_path);

        
$use_custom_button = (isset($this->addon->settings->use_custom_button) && $this->addon->settings->use_custom_button) ? $this->addon->settings->use_custom_button 0;

        if (
$use_custom_button) {
            return 
$css_path->render(array('addon_id' => $addon_id'options' => $this->addon->settings'id' => 'btn-' $this->addon->id));
        }
    }


Mit Zitat antworten