1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<?php
session_start();
class authentificationuserMultiActionController
{
private $_registry;
public function __construct(Registry $registry){
$this->_registry = $registry;
}
public function authentificationuser_action()
{
require_once(FRAMEWORK_PATH.'models/usersmodel.php');
require_once(FRAMEWORK_PATH.'models/connectemodel.php');
require_once(FRAMEWORK_PATH.'actions/connectes.module.php');
$adapter = $this->_registry->getSetting('adpt');
$usermodel = new UsersModel($adapter);
$template = $this->_registry->getObject('tpl');
$template->set_file('user','home.html');
$template->set_file('gestion','welcome.html');
//Create or sync your table structure with the defined fields in the mapper
$connectemodel = new ConnecteModel($adapter);
//Create or sync your table structure with the defined fields in the mapper
$connectemodel->migrate();
$dressip = $_SERVER['REMOTE_ADDR'];
$nrbeconnecte=$connectemodel->query(" select count(*) as nbre_connectes from connectes where
ip='".$dressip."' ");
foreach($nrbeconnecte as $key => $value) {
// ici c'est pour recuperer nbres de connecte dans welcome
$template->set_var('nbre_connectes',utf8_encode($value->nbre_connectes));
}
$usermodel->migrate();
$identifiant =utf8_encode( addslashes( $_POST["identifiant"] ));
$password = $_POST["password"];
if(!empty($_POST['identifiant']) && !empty($_POST['password']))
{
$user = $usermodel->query(" SELECT Identifiant, Password FROM users
where Identifiant='$identifiant' ");
/*
echo '<pre>';
print_r ($user);
echo '</pre>';
*/
foreach ($user as $key => $value)
{
// meme chose pour ici recuperer le identifiant connecté
$template->set_var('identifiant',utf8_encode($value->Identifiant));
if($value->Password == $password && $value->Identifiant==$identifiant)
{
//session identifiant
$_SESSION["identifiant"]= $identifiant;
$template->pparse('result_user', 'gestion');
}
else
$template->pparse('result_user', 'user');
}
}
else
{
$template->pparse('result_user', 'user');
}
}
}
?> |
Partager