Login password

Signaler
Messages postés
33
Date d'inscription
jeudi 17 août 2006
Statut
Membre
Dernière intervention
1 juin 2007
-
Messages postés
1406
Date d'inscription
mercredi 17 août 2005
Statut
Membre
Dernière intervention
28 août 2007
-
je peut pas accéder au base pour verifier login et password des utilisateur et voici les fichiers .
Merci d'avance.

---------------------page Admin--------------------------------------
<?php
session_start();
include ("../classes/Page.class.php");
include ("../classes/User.class.php");
//session_start(); //Variable session.auto_start = on in php.ini file
if (!($_SESSION["Login"]) || ($_SESSION["Login"] == "")) {
 Header("Location: ../index.php?logonerror");
 exit();
}
$usr = new User($_SESSION["Login"]);
$webPage = new Page(NULL,serialize($usr));
/*************** Ajouter le contenu de la page *******************/
$webPage->AddContent($usr->Display("black"));
/*********************** Afficher la page ************************/
echo $webPage->getPage();
?>


-----------------------page index-------------------------------------
<?
session_start();
include("./classes/User.class.php");


//session_start(); //Variable session.auto_start = on in php.ini file
//echo $_POST['login'] . ".
";
//echo $_POST['password']. ".
";


if(isset($_GET['logoff']))
{
 session_unset();
 session_destroy();
}
if( isset($_POST['login']) && $_POST['login'] != "")
{
 $usr = new User(trim($_POST['login']));
 //$usr->Login = $_POST['login'];
 $usr->SetPassword($_POST['password']);
 //echo $usr->UsrPasswd . "
";
 if($usr->CheckPassword()){
  $_SESSION['Login'] = $usr->Login;
  $_SESSION['UsrFName'] = $usr->UsrFName;
  $_SESSION['UsrLName'] = $usr->UsrLName;
  $_SESSION['USRGRPPRIVILIGE'] = $usr->GetPrivilege();
  Header("Location: ../admin/admin.php");
  exit("aprés redirection à admin.php");
 }
 else{
  //echo "\$usr->CheckPassword() return False
";
  //$page = $_SERVER['PHP_SELF'] . "?logonerror";
  Header("Location: {$_SERVER['PHP_SELF']}?logonerror");
  exit("aprés redirection à {$_SERVER['PHP_SELF']}");
 }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0033)http://optinet/backoffice/login.x -->
<HTML><HEAD><TITLE>login</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><LINK
href="login_fichiers/optinet.css" type=text/css rel=stylesheet>
<SCRIPT language=JavaScript
src="login_fichiers/fonctions.js;jsessionid=F84F524B81A61AC257F18E42E9467AE0">
</SCRIPT>
 <META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
 
    ----

      ,

     
     ,
   
 

             <TD align=middle width="98%">
Bienvenue sur le site de suivi de l'interconnexion TT
</TD>
&nbsp;

&nbsp;

&nbsp;

 
    ----

     
<table cellspacing =0 cellpadding= 0 width="100%" border=0>
         
            ----

             , </td>
             
                  <center>
                    AUTHENTIFICATION
                  </center>
                  ,
              ,
              &nbsp;,
              ,
           
         
       

                 
            ----

              ,
              <table cellspacing=6 cellpadding=1 width="100%" border=0>
                 
                    ----

                     , &nbsp;</td>
                      &nbsp;,
                   
                 
               


             <?php
         if(isset($_GET['logonerror'])){
  echo "<center> Wrong login and/or password.

     Please try again.
</center>";
  }
  if(isset($_GET['logoff'])) echo "Session fermée.
";
        ?>
  <form <?php echo "action ="{$_SERVER['PHP_SELF']}""; ?> method= "post">
                                     
                      ----

                                                 ,
                     
                      ----

                        login:&nbsp;&nbsp;
                       ,
                       
                          &nbsp;,
                     
                      ----

                        mot de passe:&nbsp;&nbsp;
                       ,
                       
                          &nbsp;&nbsp;,
                     
                      ----

                        &nbsp;,
                        ,
                     
                      ----

                        &nbsp;,
                       
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ,
                     
                      <!-- dans le cas de retour de nouvelle inscription-->
                   
                 
<!--<center>Merci de vous identifier p.</center>-->
                </form></td>
              <td bgcolor=#dddddd></td>
            </tr>
          </tbody>
        </table>
                 
            ----

              ,
              ,
              ,
           
         
       
</td>
    </tr>
  </tbody>
</table>
</HTML>
---------------------page user.class-----------------------------------------------
<?php
if(!defined("PHP_USER_CLASS"))
{
define("PHP_USER_CLASS",1,True);
include("OraBase.class.php");
include("Frame.class.php");
class User
{
 var $Login;
 var $UsrGrpName;
 var $UsrFName;
 var $UsrLName;
 var $UsrFunction;
 var $UsrEmail;
 var $UsrPasswd;
 var $UsrPrivilege;


 function User($Login=""){
  $this->Login = $Login;
  if(($Login != "") && $this->Check()){
   $this->Load();
  }
  else {
   $this->UsrGrpName = "";
   $this->UsrFName = "";
   $this->UsrLName = "";
   $this->UsrFunction = "";
   $this->UsrEmail = "";
   $this->UsrPasswd = "";
   $this->UsrPrivilege = "00000000000";
  }
  //echo $this->Display();
 }
 function SetPassword($UsrPasswd){
  $this->UsrPasswd = sha1($UsrPasswd);
 }
 function Add()
 {
  $OraDb = new OraBase();
  $OraDb->connect();  $OraDb->Query "select Login from users where Login '$this->Login'";
  $results = $OraDb->Execute();
  //echo count($results)."
";
  list($key,$value) = each($results);
     if(!isset($value[0])){//s'il n'y a 1 autre user ayant le même login
  //echo "User Add : UsrEmail : $this->UsrEmail
";
  $OraDb->Query = "insert into users values('$this->Login','$this->UsrGrpName','$this->UsrFName','$this->UsrLName','$this->UsrFunction','$this->UsrEmail','$this->UsrPasswd')";
  if($OraDb->Execute()) return True;
  return False;
  }
  else{
  echo "Opération User->Add a échoué: '$this->Login' : Utilisateur existant
";
  return False;
  }
 }
 function Delete()
 {
  $OraDb = new OraBase();
  $OraDb->connect();  $OraDb->Query "select Login from users where Login '$this->Login'";
  $results = $OraDb->Execute();
  //echo count($results)."
";
  list($key,$value) = each($results);
     if(isset($value[0])){//s'il n'y a 1 autre user ayant le même login
  //echo "User Add : UsrEmail : $this->UsrEmail
";
   $OraDb->Query = "DELETE FROM USERS WHERE LOGIN='$this->Login'";
   if($OraDb->Execute()) return True;
   return False;
  }
  else{
   throw new Exception("Opération User->Delete a échouée: '$this->Login' : Utilisateur absent
");
   return False;
  }
 }
 function Load(){
  $OraDb = new OraBase();
  $OraDb->connect();  $OraDb->Query "select * from users where Login '$this->Login'";
  $results = $OraDb->Execute();
  //print_r($results);
  if($results){
    reset($results);
    $oparray = array();
       $this->UsrPasswd = $results['USRPASSWD'][0];
    $this->UsrEmail = $results['USREMAIL'][0];
    $this->UsrFunction = $results['USRFUNCTION'][0];
    $this->UsrLName = $results['USRLNAME'][0];
    $this->UsrFName = $results['USRFNAME'][0];
    $this->UsrGrpName = $results['USRGRPNAME'][0];
    $this->Login = $results['LOGIN'][0];
    $this->UsrPrivilege = $this->GetPrivilege();
    return True;
   }
  echo "Opération User->Load a échoué: '$this->Login' : Utilisateur absent
";
  return False;
 }
 function Update()
 {
  if($this->Check()){
   $OraDb = new OraBase();
   $OraDb->connect();
   $OraDb->Query = "update users set USRGRPName='$this->UsrGrpName',USRFNAME='$this->UsrFName',USRLNAME='$this->UsrLName',USRFUNCTION='$this->UsrFunction',USREMAIL='$this->UsrEmail',USRPASSWD='$this->UsrPasswd' where Login='$this->Login'";
   return($OraDb->Execute());
  }
  else return FALSE;//User absent
 }
 //return True if a user exists, else return false
 function Check()
 {
  $OraDb = new OraBase();
  $OraDb->connect();  $OraDb->Query "select Login from users where Login '$this->Login'";
  $results = $OraDb->Execute();
  list($key,$value) = each($results);
     if(isset($value[0])) return True;
  else return False;
 }
 //return True if $this->Login and $this->UsrPasswd match, else return false
 function CheckPassword()
 {
  $OraDb = new OraBase();
  $OraDb->connect();  $OraDb->Query "select login from users where Login '$this->Login' and UsrPasswd = '".$this->UsrPasswd."'";
  $results = $OraDb->Execute();
  list($key,$value) = each($results);
     if(isset($value[0])) return True;
  else return False;
 }
 function Display($color="Green",$passwd=False,$priv=True)
 {
  $strUser = "
  \n\";
  $bool = True;
  foreach($this as $key => $value) {
   if($value==\"\") $value=\"&nbsp;\";
   $bool = true;
   if($key=='UsrPrivilege') $bool = $priv;
   if($key=='UsrPasswd') $bool = $passwd;
      if($bool)$strUser .= \"
       ----

         $key : |
        $value,
       \";
  }
  $strUser . = "
";
  $frame = new Frame("Utilisateur : $this->Login",$strUser,"center","70%");
  return $frame->getFrame();
  /*$strUser = "\";
  $strUser .= \"----
Login :, $this->Login, \";
  $strUser .= \"----
UsrGrpName :, $this->UsrGrpName, \";
  $strUser .= \"----
UsrFName :, $this->UsrFName, \";
  $strUser .= \"----
UsrLName :, $this->UsrLName , \";
  $strUser .= \"----
UsrFunction :, $this->UsrFunction , \";
  $strUser .= \"----
UsrEmail :, $this->UsrEmail, \";
  if($passwd==true)
   $strUser .= \"----
UsrPasswd :, $this->UsrPasswd, \";
  if($priv==true)
  $strUser .= \"----
UsrPrivilege :, $this->UsrPrivilege, \";
  $strUser .= "
";
  return $strUser;*/
 }
 function GetPrivilege()
 {
  $OraDb = new OraBase();
  $OraDb->connect();  $OraDb->Query "select USRGRPPRIVILIGE from usergroup where USRGRPNAME (select USRGRPNAME from  users where LOGIN='$this->Login')";
  $results = $OraDb->Execute();
  if($results){
   list($key,$value) = each($results);
   if(isset($value[0])) return $value[0];
   else return False;
  }
  return False;
 }
 function HasPrivilege($Priv)
 {
  global $PRIVILEGE;
  //echo "In HasPrivilege
";
  //echo "Paramètre : $Priv
";
  if($Priv == -1) return True ; //All User Has This Privilege
  if((isset($this->UsrPrivilege)) && ($this->UsrPrivilege != ""))
  {
   //echo "\$this->UsrPrivilege is set and != ""
";
   if(is_numeric($Priv)) {


    //echo "Priv is numeric : $Priv
";
    if(($Priv<0) || ($Priv > (count($PRIVILEGE)-1))) return False;
    return ($this->UsrPrivilege[$Priv] == "1");
   }
   else {
    //echo "$Priv is String
";
    $key = array_search($Priv,$PRIVILEGE);
    if(($key===NULL) || ($key===""))return False;
    //if($key==="") echo "vide
";
    //if($key===NULL) echo "NULL
";
    //echo "$key not null : $key
";
    return ($this->UsrPrivilege[$key] == "1");
   }
  }
  else{
   //echo "\$this->UsrPrivilege is not set or == ""
";
   return False;
  }
 }
 function IsAdministrator()
 {
  global $ADMIN_PRIV;


  if((isset($this->UsrPrivilege)) && ($this->UsrPrivilege != ""))
  {
   for($i=0;$i<count($ADMIN_PRIV);$i++){
    if($this->UsrPrivilege[$ADMIN_PRIV[$i]]!== '1')return False;
   }
   return True;
  }
 }
 function GetUsers()
 {
  $OraDb = new OraBase();
  $OraDb->connect();
  $OraDb->Query = "SELECT LOGIN FROM USERS ORDER BY LOGIN";
  $_UsrNames = $OraDb->Execute();
  $UsrNames = array();
  if($_UsrNames){
   foreach($_UsrNames['LOGIN'] as $key => $value){
    $UsrNames["$key"] = "$value";
   }
   return  $UsrNames;
  }
  else return False;
 }
}
}
?>

< body>

1 réponse

Messages postés
1406
Date d'inscription
mercredi 17 août 2005
Statut
Membre
Dernière intervention
28 août 2007
7
Salut,

Comment dire... Tu sais lire de l'anglais ?

Ben si oui, je te conseil cette lecture :
How To Ask Questions The Smart Way

Et si tu ne veux pas tout lire, je pense que ces chapitres te concernent tout particulièrement :
Volume is not precision
Be explicit about your question

A+