0byt3m1n1-V2
Path:
/
home
/
nlpacade
/
www
/
arcaneoverseas.com
/
application
/
controllers
/
admin
/
[
Home
]
File: login.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Login extends CI_Controller { /** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see http://codeigniter.com/user_guide/general/urls.html * */ public function __construct() { parent::__construct(); //test Login with Cokies // header("location:http://localhost/codeigniter/index.php/login/index"); } public function index() { // echo md5("admin"); $this->load->library('layout'); $this->layout->set_idPage('login'); $this->layout->set_theme('admin/default'); // var_dump(get_cookie('UserCokies'));die; if( $this->session->userdata("logged_in") == true){ redirect('admin/notification/contact'); }elseif(($this->input->cookie('UserCokies') && get_cookie('UserCokies') != "")) { // echo "in"; $cookies = explode("&", get_cookie('UserCokies')); $user = $this->doctrine->em->getRepository('Entities\User')->findOneBy(array('id' => $cookies[0])); if ($user != "") { /* Nb Contact */ $contact = $this->doctrine->em->getRepository('Entities\Contact')->findByLu("non"); $data = array( 'user_id' => $user->getId(), 'nom' => $user->getNom(), 'prenom' => $user->getPrenom(), 'photo' => $user->getPhoto(), 'Derniere_connexion' => '12/12/2011 23:34', 'contact' => count($contact), 'logged_in' => TRUE ); $this->session->set_userdata($data); redirect('admin/notification/contact'); } } $this->layout->view('admin/login'); } /** * Views mot de passe oublier * */ public function mot_de_passe_oublier() { $this->load->library('layout'); $this->layout->set_theme('admin/default'); $this->layout->set_idPage('login'); $this->layout->view('admin/mot_de_passe_oublier'); //Post adresse email if ($this->input->post('email')) { $user = $this->doctrine->em->getRepository('Entities\User')->findOneBy(array('supprimer' => 'false', 'email' => $this->input->post('email'))); if (is_null($user)) { $this->session->set_flashdata('message', 'L’adresse email que vous avez saisi n’est pas associé à aucun compte .'); redirect('admin/login/mot_de_passe_oublier/'); } elseif ($user->getEtat() == "non") { $this->session->set_flashdata('message', 'Votre compte a été désactivé,<br> veuillez <a href="">contacter</a> l’administrateur pour plus d’information'); redirect('admin/login/mot_de_passe_oublier/'); } else { /* New mot de passe */ $new_passwod = $this->wd_generatePassword(8); $user->setPassword(md5($new_passwod)); $this->doctrine->em->flush(); //parse file $this->load->library('parser'); $data_file = array( 'app_title' => getAppTitre(), 'nom' => $user->getNom() . " " . $user->getPrenom(), 'email' => $user->getEmail(), 'password' => $new_passwod ); $file = $this->parser->parse('admin/tpl_passe_oublier', $data_file); //echo $file;die; //envoi email $this->load->library('email'); $this->email->clear(); $this->email->from(getAppEmail(), getAppTitre()); $this->email->to($user->getEmail()); $this->email->subject('Vous avez demandé un nouveau mot de passe ' . getAppTitre()); $this->email->message($file); // echo $this->email->print_debugger(); if (!$this->email->send()) { $this->session->set_flashdata('message', 'Une erreur système est survenue , veuillez essaie une autre fois'); redirect('admin/login/mot_de_passe_oublier/'); } else { /* * Redirecte* */ $this->session->set_flashdata('message_success', 'Félicitation Votre mot de passe a bien été initialisé.<br> Veuillez consulter votre boite email Un email est vous envoyer pour indiquez le nouveau mot de passe.'); redirect('admin/login/index/'); } } } } /** * Générer une nouvelle mot de passe * */ public function wd_generatePassword($length = 8, $possible = '$=@#23456789bcdfghjkmnpqrstvwxyz') { $password = ''; $possible_length = strlen($possible) - 1; # # add random characters to $password for $length # while ($length--) { # # pick a random character from the possible ones # $except = substr($password, -$possible_length / 2); for ($n = 0; $n < 5; $n++) { $char = $possible{mt_rand(0, $possible_length)}; # # we don't want this character if it's already in the password # unless it's far enough (half of our possible length). # note: we have 4 tries to find a suitable one. # if (strpos($except, $char) === false) { break; } } $password .= $char; } return $password; } /* * authentification */ public function auth() { if ($this->input->post('password') && $this->input->post('email')) { $user = $this->doctrine->em->getRepository('Entities\User')->findOneBy(array('email' => $this->input->post('email'), 'password' => md5($this->input->post('password')),'etat' => 'oui')); // var_dump($user);die; if (is_null($user)) { $this->session->set_flashdata('message', 'L’adresse email ou le mot de passe que vous avez saisi n’est pas associé à aucun compte .'); redirect('admin/login/index/'); } else { /* Nb Contact */ $contact = $this->doctrine->em->getRepository('Entities\Contact')->findByLu("non"); $data = array( 'user_id' => $user->getId(), 'nom' => $user->getNom(), 'prenom' => $user->getPrenom(), 'photo' => $user->getPhoto(), 'Derniere_connexion' => '12/12/2011 23:34', 'contact' => count($contact), 'logged_in' => TRUE ); // var_dump(get_cookie('UserCokies'));die; //set cokies if (!(get_cookie('UserCokies')) && $this->input->post('remember') == "true") { setcookie("UserCokies", $user->getId() . "&" . $user->getPassword(), ( time() + 86400 * 90)); } $this->session->set_userdata($data); redirect('admin/notification/contact'); } } } /** * * * */ public function logout() { $this->session->sess_destroy(); setCookie('UserCokies'); // var_dump( get_cookie('remMeSpa'));die; redirect('admin/login/index'); } } /* End of file welcome.php */ /* Location: ./application/controllers/welcome.php */
©
2018.