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
|
<?php
require_once("".chemin."cls_mysql.php");
//require("/usr/local/etc/httpd/htdocs/classes/cls_mysql.php");
class ClsAuth {
var $id_session = "";
var $departement = 0;
var $idacces = 0;
var $msg="";
function InitSes (){
session_start();
$this->id_session = session_id();
return true;
}
function VerifDbAcces($user,$mpass,$table_acces='acces',$chp_login='login',$chp_pass='pass')
{
$db = new DataBase; // Instanciation de l'objet $db
if($db->DbConnect())
{ // accès à la méthode DbConnect de l'objet
$sql="select * from ".$table_acces." where ".$chp_login." ='".$user."' and ".$chp_pass." = '".$mpass."'";
if($tab = $db->DbSelect ($sql)){
foreach($tab as $element) {
if($element[$chp_login]==$user && $element[$chp_pass]==$mpass)
{
$this->departement = $element[departement];
$this->idacces = $element[id_acces];
$db->DbClose();
return true;
}
}
}
else {
$db->DbClose();
return false;
}
}
else {
$db->DbClose();
return false;
}
}
function registerSessionVar($valuel,$valuemp,$table_acces="acces",$chp_login="login",$chp_pass="pass")
{
if($valuel!= "" && $valuemp!= ""){
if( $this->VerifDbAcces($valuel,$valuemp,$table_acces,$chp_login,$chp_pass)==true){
session_register('login') or die("1 - Echec enregistrement variable session");
session_register('pass') or die("1 - Echec enregistrement variable session");
return true;
}
else
return false;
}
else
return false;
}
function VerifSessionVar($valuel,$valuemp,$table_acces="acces",$chp_login="login",$chp_pass="pass")
{
if( $valuel!="" && $valuemp!="" ){
if( $this->VerifDbAcces($valuel,$valuemp,$table_acces,$chp_login,$chp_pass) ){
return true;
}
else return false;
}
else return false;
}
function VideSessionVar()
{
session_destroy();
return true;
}
};
?> |
Partager