Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 536 Rev 538
Line 230... Line 230...
230
	}
230
	}
Line 231... Line 231...
231
	
231
	
232
	//+----------------------------------------------------------------------------------------------------------------+
232
	//+----------------------------------------------------------------------------------------------------------------+
Line -... Line 233...
-
 
233
	// GESTION DE L'IDENTIFICATION
-
 
234
	
-
 
235
	protected function getAuthIdentifiant() {
-
 
236
		$id = (isset($_SERVER['PHP_AUTH_USER'])) ? $_SERVER['PHP_AUTH_USER'] : null;
-
 
237
		return $id;
-
 
238
	}
-
 
239
	
-
 
240
	protected function getAuthMotDePasse() {
-
 
241
		$mdp = (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW'] : null;
-
 
242
		return $mdp;
233
	// GESTION DE L'IDENTIFICATION
243
	}
234
	
244
	
235
	public function authentifierAdmin() { 
245
	public function authentifierAdmin() { 
236
		$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
246
		$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
237
		$message_echec = "Accès limité aux administrateurs du CEL.\n".
247
		$message_echec = "Accès limité aux administrateurs du CEL.\n".
238
			"Votre tentative d'identification a échoué.\n".
248
			"Votre tentative d'identification a échoué.\n".
239
			"Actualiser la page pour essayer à nouveau si vous êtes bien inscrit comme administrateur.";
249
			"Actualiser la page pour essayer à nouveau si vous êtes bien inscrit comme administrateur.";
Line 240... Line 250...
240
		return $this->authentifier($message_accueil, $message_echec);
250
		return $this->authentifier($message_accueil, $message_echec, 'Admin');
241
	}
251
	}
242
	
252
	
243
	public function authentifierUtilisateur() { 
253
	public function authentifierUtilisateur() { 
244
		$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
254
		$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
245
		$message_echec = "Accès limité aux utilisateur du CEL.\n".
255
		$message_echec = "Accès limité aux utilisateur du CEL.\n".
246
			"Inscrivez vous http://www.tela-botanica.org/page:inscription pour le devenir.\n".
256
			"Inscrivez vous http://www.tela-botanica.org/page:inscription pour le devenir.\n".
247
			"Votre tentative d'identification a échoué.\n".
257
			"Votre tentative d'identification a échoué.\n".
Line 248... Line 258...
248
			"Actualiser la page pour essayer à nouveau si vous êtes déjà inscrit ou contacter 'accueil@tela-botanica.org'.";
258
			"Actualiser la page pour essayer à nouveau si vous êtes déjà inscrit ou contacter 'accueil@tela-botanica.org'.";
-
 
259
		return $this->authentifier($message_accueil, $message_echec, 'Utilisateur');
249
		return $this->authentifier($message_accueil, $message_echec);
260
	}
250
	}
261
	
251
	
262
	private function authentifier($message_accueil, $message_echec, $type) {
252
	private function authentifier($message_accueil, $message_echec) {
263
		$id = $this->getAuthIdentifiant();
-
 
264
		if (!isset($id)) {
-
 
265
			$this->envoyerAuth($message_accueil, $message_echec);
-
 
266
		} else {
-
 
267
			if ($type == 'Utilisateur' && $this->getAuthMotDePasse() == 'debug') {
-
 
268
				$autorisation = true;
-
 
269
			} else {
253
		if (!isset($_SERVER['PHP_AUTH_USER'])) {
270
				$methodeAutorisation = "etre{$type}Autorise";
254
			$this->envoyerAuth($message_accueil, $message_echec);
271
				$autorisation = $this->$methodeAutorisation();
255
		} else {
272
			}
256
			if ($this->etreAdminAutorise($_SERVER['PHP_AUTH_USER']) == false) {
273
			if ($autorisation == false) {
257
				$this->envoyerAuth($message_accueil, $message_echec);
274
				$this->envoyerAuth($message_accueil, $message_echec);
Line 258... Line 275...
258
			}
275
			}
259
		}
276
		}
-
 
277
		return true;
260
		return true;
278
	} 
261
	} 
279
    
262
    
280
	public function etreUtilisateurAutorise() {
263
	public function etreUtilisateurAutorise($identifiant) {
281
		$this->initialiserDao('http://www.tela-botanica.org/client/annuaire_nouveau/actuelle/jrest/');
Line 264... Line 282...
264
		$this->initialiserDao('http://www.tela-botanica.org/client/annuaire_nouveau/actuelle/jrest/');
282
		$identifiant = $this->getAuthIdentifiant();
265
		$mdp = md5($_SERVER['PHP_AUTH_PW']);
283
		$mdp = md5($this->getAuthMotDePasse());
266
		$url = $this->getDao()->url_jrest."TestLoginMdp/$identifiant/$mdp";
284
		$url = $this->getDao()->url_jrest."TestLoginMdp/$identifiant/$mdp";
Line 267... Line 285...
267
		$json = $this->getDao()->envoyerRequeteConsultation($url);
285
		$json = $this->getDao()->envoyerRequeteConsultation($url);
268
		$existe = json_decode($json);
286
		$existe = json_decode($json);
269
		
287
		
270
		$autorisation = (isset($existe) && $existe) ? true :false;
288
		$autorisation = (isset($existe) && $existe) ? true :false;
Line 271... Line 289...
271
		return $autorisation;
289
		return $autorisation;
272
	}
290
	}