예제 #1
0
 public function index()
 {
     $data = array();
     $data['title'] = $this->lang->line('contact');
     $post = $this->input->post();
     if (empty($post)) {
         $this->load->view('templates/header', $data);
         $this->load->view('templates/nav', $data);
         $this->load->view('contact', $data);
         $this->load->view('templates/footer', $data);
     } else {
         $rules = array(array('field' => 'motif', 'label' => $this->lang->line('motif'), 'rules' => 'trim|required', 'errors' => array('required' => $this->lang->line('required_field'))), array('field' => 'message', 'label' => $this->lang->line('your_message'), 'rules' => 'trim|required', 'errors' => array('required' => $this->lang->line('required_field'))));
         $this->form_validation->set_rules($rules);
         if ($this->form_validation->run() == FALSE) {
             $this->load->view('templates/header', $data);
             $this->load->view('templates/nav', $data);
             $this->load->view('contact', $data);
             $this->load->view('templates/footer', $data);
         } else {
             // Envoi d'email pour info
             $subject = '12parfait - Contact - ' . $post['motif'];
             $body = 'Message envoyé par "' . $this->session->userdata['user']->email . '" :<br/><br/>';
             $body .= $post['message'];
             send_email_interception('*****@*****.**', $subject, $body);
             $this->session->set_flashdata('success', $this->lang->line('message_successfully_sent'));
             redirect(site_url(), 'location');
             exit;
         }
     }
 }
예제 #2
0
 /**
  * Fonction d'oubli de mot de passe.
  */
 public function forgotten_password()
 {
     $data = array();
     $data['title'] = $this->lang->line('forgotten_password');
     $post = $this->input->post();
     if (empty($post)) {
         $this->load->view('templates/header', $data);
         $this->load->view('templates/nav', $data);
         $this->load->view('forgotten_password', $data);
         $this->load->view('templates/footer', $data);
     } else {
         $rules = array(array('field' => 'email', 'label' => $this->lang->line('email'), 'rules' => 'required|valid_email|in_database_email', 'errors' => array('required' => $this->lang->line('required_field'), 'valid_email' => $this->lang->line('valid_email'), 'in_database_email' => $this->lang->line('not_in_database_email'))));
         $this->form_validation->set_rules($rules);
         if ($this->form_validation->run() == FALSE) {
             $this->load->view('templates/header', $data);
             $this->load->view('templates/nav', $data);
             $this->load->view('forgotten_password', $data);
             $this->load->view('templates/footer', $data);
         } else {
             $where = array('email' => $post['email']);
             $hash = random_string('alnum', 255);
             $donnees_echapees = array('hash' => $hash, 'date_hash' => date('Y-m-d H:i:s'));
             $this->user_model->update($where, $donnees_echapees);
             $subject = '12parfait - Mot de passe oublié';
             $body = 'Pour réinitialiser votre mot de passe, veuillez cliquer sur <a href="' . site_url('reset_password/' . $hash) . '">ce lien</a>';
             send_email_interception($post['email'], $subject, $body);
             $this->session->set_flashdata('info', $this->lang->line('reset_password_email_sent'));
             redirect(site_url('connection'), 'location');
             exit;
         }
     }
 }