Subversion Repositories Applications.annuaire

Rev

Rev 538 | Rev 565 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 538 Rev 561
Line 349... Line 349...
349
	protected function getUtilisateur() {
349
	protected function getUtilisateur() {
350
		return (isset($_SESSION['coel_utilisateur']) ? $_SESSION['coel_utilisateur'] : '');
350
		return (isset($_SESSION['coel_utilisateur']) ? $_SESSION['coel_utilisateur'] : '');
351
	}
351
	}
Line 352... Line 352...
352
 
352
 
-
 
353
	protected function authentifier() {
353
	protected function authentifier() {
354
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
354
		if (!isset($_SERVER['PHP_AUTH_USER'])) {
355
			if (!isset($_SERVER['PHP_AUTH_USER'])) {
355
			header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
356
				header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
356
			header('HTTP/1.0 401 Unauthorized');
357
				header('HTTP/1.0 401 Unauthorized');
357
			header('Content-type: text/html; charset=UTF-8');
358
				header('Content-type: text/html; charset=UTF-8');
Line 367... Line 368...
367
				echo 'Accès interdit';
368
					echo 'Accès interdit';
368
				exit ;
369
					exit ;
369
			}
370
				}
370
		}
371
			}
371
	}
372
		}
-
 
373
	}
Line 372... Line 374...
372
 
374
 
-
 
375
	protected function verifierAcces($id = null, $mdp = null) {
373
	protected function verifierAcces($id = null, $mdp = null) {
376
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
374
		$id = is_null($id) ? $_SERVER['PHP_AUTH_USER'] : $id;
377
			$id = is_null($id) ? $_SERVER['PHP_AUTH_USER'] : $id;
Line 375... Line 378...
375
		$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
378
			$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
376
 
379
	
Line 384... Line 387...
384
		$identifie = false;
387
			$identifie = false;
385
		if (isset($resultat['courriel'])) {
388
			if (isset($resultat['courriel'])) {
386
			$identifie = true;
389
				$identifie = true;
387
		}
390
			}
388
		return $identifie;
391
			return $identifie;
-
 
392
		} else {
-
 
393
			return true; // ça fait un peu mal...
-
 
394
		}
389
	}
395
	}
Line 390... Line 396...
390
 
396
 
391
	/**
397
	/**
392
	 * Envoie une demande d'authentification HTTP puis compare le couple
398
	 * Envoie une demande d'authentification HTTP puis compare le couple
Line 396... Line 402...
396
	 * @TODO redondant avec les trucs du dessus :'(
402
	 * @TODO redondant avec les trucs du dessus :'(
397
	 */
403
	 */
398
	protected function authentificationHttpSimple() {
404
	protected function authentificationHttpSimple() {
399
		$autorise = true;
405
		$autorise = true;
400
		// contrôle d'accès
406
		// contrôle d'accès
-
 
407
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
401
		$nomUtil = $_SERVER['PHP_AUTH_USER'];
408
			$nomUtil = $_SERVER['PHP_AUTH_USER'];
402
		$mdp = $_SERVER['PHP_AUTH_PW'];
409
			$mdp = $_SERVER['PHP_AUTH_PW'];
403
		$autorise = (($nomUtil == $this->config['database_ident']['username']) && ($mdp == $this->config['database_ident']['password']));
410
			$autorise = (($nomUtil == $this->config['database_ident']['username']) && ($mdp == $this->config['database_ident']['password']));
-
 
411
		}
404
		// entêtes HTTP
412
		// entêtes HTTP
405
		if (! $autorise) {
413
		if (! $autorise) {
406
			header('WWW-Authenticate: Basic realm="Annuaire de Tela Botanica"');
414
			header('WWW-Authenticate: Basic realm="Annuaire de Tela Botanica"');
407
			header('HTTP/1.0 401 Unauthorized');
415
			header('HTTP/1.0 401 Unauthorized');
408
			echo 'Veuillez vous authentifier pour utiliser ce service';
416
			echo 'Veuillez vous authentifier pour utiliser ce service';