Subversion Repositories eFlore/Applications.cel

Rev

Rev 936 | Rev 986 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 936 Rev 970
Line 83... Line 83...
83
							 'admin' => false
83
							 'admin' => false
84
							);
84
							);
Line 85... Line 85...
85
							
85
							
86
		if ($this->identificationEstDemandee($uid)) { 	
86
		if ($this->identificationEstDemandee($uid)) { 	
87
			if (!$utilisateur = $this->utilisateurEstIdentifie()) { 
87
			if (!$utilisateur = $this->utilisateurEstIdentifie()) { 
88
				if ($this->IdentifierUtilisateur($uid[0],$uid[1],1)) { 
88
				if ($this->identifierUtilisateur($uid[0],$uid[1],1)) { 
89
					$utilisateur= $this->chargerInfosUtilisateur($uid[0]);
89
					$utilisateur= $this->chargerInfosUtilisateur($uid[0]);
90
					$utilisateur['connecte'] = true;
90
					$utilisateur['connecte'] = true;
91
				}
91
				}
92
			}
92
			}
93
			else {
93
			else {
94
				$utilisateur = $this->chargerInfosUtilisateur($utilisateur);
94
				$utilisateur = $this->chargerInfosUtilisateur($utilisateur);
95
				$utilisateur['connecte'] = true;
95
				$utilisateur['connecte'] = true;
96
			}
96
			}
97
		}
97
		}
98
		else {
98
		else {
99
			$this->DeconnecterUtilisateur();
99
			$this->deconnecterUtilisateur();
Line 100... Line 100...
100
		}
100
		}
101
 
101
 
Line 144... Line 144...
144
    function utilisateurEstIdentifieSession() {
144
    function utilisateurEstIdentifieSession() {
145
    	return (isset($_SESSION["user"]) && isset($_SESSION["user"]["courriel"])) ? $_SESSION["user"]["courriel"] : false;
145
    	return (isset($_SESSION["user"]) && isset($_SESSION["user"]["courriel"])) ? $_SESSION["user"]["courriel"] : false;
146
   	}
146
   	}
Line 147... Line 147...
147
   	
147
   	
148
   	function utilisateurEstIdentifieCookie() {
148
   	function utilisateurEstIdentifieCookie() {
149
   		return isset($_COOKIE["cel_name"]) && ($this->IdentifierUtilisateurSansEncryptionMotDePasse($_COOKIE["cel_name"], $_COOKIE["cel_password"])) ? $_COOKIE["cel_name"] : false;	
149
   		return isset($_COOKIE["cel_name"]) && ($this->identifierUtilisateurSansEncryptionMotDePasse($_COOKIE["cel_name"], $_COOKIE["cel_password"])) ? $_COOKIE["cel_name"] : false;	
Line 150... Line 150...
150
   	}
150
   	}
151
 
151
 
152
    function SetUtilisateur($user, $remember=1) {
152
    function setUtilisateur($user, $remember=1) {
153
    	$_SESSION["user"] = $user;
153
    	$_SESSION["user"] = $user;
154
    	$this->SetPersistentCookie("cel_id", $user["id"], $remember);
154
    	$this->setPersistentCookie("cel_id", $user["id_utilisateur"], $remember);
155
    	$this->SetPersistentCookie("cel_name", $user["name"], $remember);
155
    	$this->setPersistentCookie("cel_name", $user["courriel"], $remember);
-
 
156
    	$this->setPersistentCookie("cel_password", $user["mot_de_passe"], $remember);
-
 
157
    	$this->setPersistentCookie("cel_remember", $remember, $remember);
156
    	$this->SetPersistentCookie("cel_password", $user["password"], $remember);
158
    	
Line 157... Line 159...
157
    	$this->SetPersistentCookie("cel_remember", $remember, $remember);
159
    	print_r($_COOKIE);
158
    }
160
    }
159
 
161
 
160
    function DeconnecterUtilisateur() {
162
    function deconnecterUtilisateur() {
161
    	 $_SESSION["user"] = "";
163
    	 $_SESSION["user"] = "";
162
    	 $this->SupprimerCookie("cel_id");
164
    	 $this->supprimerCookie("cel_id");
163
    	 $this->SupprimerCookie("cel_name");
165
    	 $this->supprimerCookie("cel_name");
Line 164... Line 166...
164
    	 $this->SupprimerCookie("cel_password");
166
    	 $this->supprimerCookie("cel_password");
-
 
167
    	 $this->supprimerCookie("cel_remember");
165
    	 $this->SupprimerCookie("cel_remember");
168
    }
166
    }
169
 
167
 
170
    function setPersistentCookie($name, $value, $remember = 1) {
Line 168... Line 171...
168
    function SetPersistentCookie($name, $value, $remember = 1) {
171
    		
169
    	SetCookie($name, $value, time() + ($remember ? 90*24*60*60 : 60 * 60),'/');
172
    	SetCookie($name, $value, time() + ($remember ? (60*60*24*100) : (60*60)),'/');
170
    	$_COOKIE[$name] = $value;
173
    	$_COOKIE[$name] = $value;
Line 171... Line 174...
171
    }
174
    }
Line 172... Line 175...
172
 
175
 
Line 173... Line 176...
173
    function SupprimerCookie($name) {
176
    function supprimerCookie($name) {
174
    	 SetCookie($name, "", 1,'/'); $_COOKIE[$name] = "";
177
    	 SetCookie($name, "", 1,'/'); $_COOKIE[$name] = "";
175
    }
178
    }
176
 
179
 
177
	function IdentifierUtilisateur($login, $mot_de_passe, $remember = 1) {
180
	function identifierUtilisateur($login, $mot_de_passe, $remember = 1) {
178
		
181
		
Line 179... Line 182...
179
		$identification = false;
182
		$identification = false;
180
		
183
		
Line 181... Line 184...
181
		if ($utilisateur = $this->chargerInfosUtilisateur($login)) {		 	
184
		if ($utilisateur = $this->chargerInfosUtilisateur($login)) {		 	
Line 182... Line 185...
182
			if ($utilisateur['mot_de_passe'] == $this->encrypterMotDePasse($mot_de_passe) || $mot_de_passe == "debug") {
185
			if ($utilisateur['mot_de_passe'] == $this->encrypterMotDePasse($mot_de_passe) || $mot_de_passe == "debug") {
Line 183... Line 186...
183
    	    	$this->SetUtilisateur($utilisateur, $remember);
186
    	    	$this->setUtilisateur($utilisateur, $remember);
184
        		$identification = true;
187
        		$identification = true;
185
	        }
188
	        }
186
		}
189
		}
187
		
190
		
188
		return $identification;
191
		return $identification;
Line 189... Line 192...
189
	}
192
	}