<commit_before><?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * @category Controller
 * @author <NAME>
 *
 * handles contact-page/form
 */
class Contact extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
    }
    
    public function index()
    {
        if($this->input->post('contact_submit'))
        {
            $this->load->library('form_validation');
            $this->form_validation->set_rules([
                [
                    'field' => 'name',
                    'label' => 'Name',
                    'rules' => 'required|min_length[8]'
                ],
                [
                    'field' => 'subject',
                    'label' => 'Betreff',
                    'rules' => 'required|min_length[4]'
                ],
                [
                    'field' => 'customer_email',
                    'label' => 'Email',
                    'rules' => 'required|valid_email'
                ],
                [
                    'field' => 'text',
                    'label' => 'Text',
                    'rules' => 'required|min_length[10]'
                ]
            ]);
            
            if($this->form_validation->run())
            {
                $this->load->library('ReCaptcha_wrapper');                
                $this->config->load('secure');
                $recaptcha = new \ReCaptcha\ReCaptcha($this->config->item('recaptcha_secret_key'));
                $resp = $recaptcha->verify($this->input->post('g-recaptcha-response'), $this->input->server('remote_addr'));
                if ($resp->isSuccess()) {
                    if ($this->send()) {
                        $this->session->set_flashdata('email_send', true);
                        redirect(base_url('contact/thanks'));
                    } else {
                        redirect(base_url());
                    }
                } else {
                    $msg ='<p>Bitte verifizieren Sie sich [reCaptcha]</p>';
                }
            }
        }
        
        $this->load->helper('form');
        
        $this->data['emails'] = $this->config->item('emails');
        
        $this->data['subview'] = 'contact';
        $this->load->view('layout', $this->data);
    }
    
    private function send()
    {
        $this->load->library('email');
        $this->config->load('secure');
        $this->email->initialize($this->config->item('email_settings'));
        
        $from = $this->input->post('customer_email');
        $to = $this->input->post('to_email');
        $to = (array_key_exists($to, $this->config->item('emails'))) ? $this->config->item('emails')[$to] : $this->config->item('emails')['Webmaster'];
        $name = ($this->input->post('name')) ? $this->input->post('name') : $from;
        
        $this->email->from($from, $name);
        $this->email->to($to);
        
        $this->email->subject($this->input->post('subject'));
        $this->email->message("INFO: Diese E-Mail wurde automatisch von der Homepage [fotoblog.venturedahlitz.com] erstellt [Kontaktformular]\r\n\r\n" . $name . " schrieb am " . date("d.m.Y") . ":\r\n\r\n" . $this->input->post('message') . "\r\n\r\nE-Mail Adresse des Absenders: " . $from . "\r\n\r\nBitte antworten Sie nicht auf diese E-Mail.");
        
        return $this->email->send();
    }
    
    public function thanks()
    {
        if(!$this->session->flashdata('email_send'))
            redirect(base_url());
        
        $this->data['subview'] = 'thanks';
        $this->load->view('layout', $this->data);
    }
}
<commit_msg>fixed 'email-not-send'-problem<commit_after><?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * @category Controller
 * @author <NAME>
 *
 * handles contact-page/form
 */
class Contact extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
    }
    
    public function index()
    {
        if($this->input->post('contact_submit'))
        {
            $this->load->library('form_validation');
            $this->form_validation->set_rules([
                [
                    'field' => 'name',
                    'label' => 'Name',
                    'rules' => 'required|min_length[8]'
                ],
                [
                    'field' => 'subject',
                    'label' => 'Betreff',
                    'rules' => 'required|min_length[4]'
                ],
                [
                    'field' => 'customer_email',
                    'label' => 'Email',
                    'rules' => 'required|valid_email'
                ],
                [
                    'field' => 'text',
                    'label' => 'Text',
                    'rules' => 'required|min_length[10]'
                ]
            ]);
            
            if($this->form_validation->run())
            {
                $this->load->library('ReCaptcha_wrapper');                
                $this->config->load('secure');
                $recaptcha = new \ReCaptcha\ReCaptcha($this->config->item('recaptcha_secret_key'));
                $resp = $recaptcha->verify($this->input->post('g-recaptcha-response'), $this->input->server('remote_addr'));
                if ($resp->isSuccess()) {
                    if ($this->send()) {
                        $this->session->set_flashdata('email_send', true);
                        redirect(base_url('contact/thanks'));
                    } else {
                        redirect(base_url());
                    }
                } else {
                    $msg ='<p>Bitte verifizieren Sie sich [reCaptcha]</p>';
                }
            }
        }
        
        $this->load->helper('form');
        
        $this->data['emails'] = $this->config->item('emails');
        
        $this->data['subview'] = 'contact';
        $this->load->view('layout', $this->data);
    }
    
    private function send()
    {
        $this->load->library('email');
        $this->config->load('secure');
        $this->email->initialize($this->config->item('email_settings'));
        
        $from = $this->input->post('customer_email');
        $to = $this->input->post('to_email');
        $to = (array_key_exists($to, $this->config->item('emails'))) ? $this->config->item('emails')[$to] : $this->config->item('emails')['Webmaster'];
        $name = ($this->input->post('name')) ? $this->input->post('name') : $from;
        
        $this->email->from($from, $name);
        $this->email->to($to);
        
        $this->email->subject($this->input->post('subject'));
        $this->email->message("INFO: Diese E-Mail wurde automatisch von der Homepage [fotoblog.venturedahlitz.com] erstellt [Kontaktformular]\r\n\r\n" . $name . " schrieb am " . date("d.m.Y") . ":\r\n\r\n" . $this->input->post('text') . "\r\n\r\nE-Mail Adresse des Absenders: " . $from . "\r\n\r\nBitte antworten Sie nicht auf diese E-Mail.");
        
        return $this->email->send();
    }
    
    public function thanks()
    {
        if(!$this->session->flashdata('email_send'))
            redirect(base_url());
        
        $this->data['subview'] = 'thanks';
        $this->load->view('layout', $this->data);
    }
}

{'fraction_non_alphanumeric': 0.17792311799252536, 'fraction_numerical': 0.0010678056593699946, 'mean_word_length': 1.4835929731521378, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 181, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3714586', 'n_tokens_mistral': 2215, 'n_tokens_neox': 2067, 'n_words': 295}