| 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 |
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
|
- |
|
| 356 |
header('HTTP/1.0 401 Unauthorized');
|
- |
|
| 357 |
header('Content-type: text/html; charset=UTF-8');
|
- |
|
| 358 |
echo 'Accès interdit';
|
- |
|
| 359 |
exit;
|
- |
|
| 360 |
} else {
|
- |
|
| 361 |
if ($this->verifierAcces()) {
|
- |
|
| 362 |
return ;
|
- |
|
| 363 |
} else {
|
355 |
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
| 364 |
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
|
356 |
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
|
| 365 |
header('HTTP/1.0 401 Unauthorized');
|
357 |
header('HTTP/1.0 401 Unauthorized');
|
| 366 |
header('Content-type: text/html; charset=UTF-8');
|
358 |
header('Content-type: text/html; charset=UTF-8');
|
| - |
|
359 |
echo 'Accès interdit';
|
| - |
|
360 |
exit;
|
| - |
|
361 |
} else {
|
| - |
|
362 |
if ($this->verifierAcces()) {
|
| - |
|
363 |
return ;
|
| - |
|
364 |
} else {
|
| - |
|
365 |
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
|
| - |
|
366 |
header('HTTP/1.0 401 Unauthorized');
|
| - |
|
367 |
header('Content-type: text/html; charset=UTF-8');
|
| 367 |
echo 'Accès interdit';
|
368 |
echo 'Accès interdit';
|
| - |
|
369 |
exit ;
|
| 368 |
exit ;
|
370 |
}
|
| 369 |
}
|
371 |
}
|
| 370 |
}
|
372 |
}
|
| Line 371... |
Line 373... |
| 371 |
}
|
373 |
}
|
| - |
|
374 |
|
| 372 |
|
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;
|
| 375 |
$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
|
378 |
$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
|
| 376 |
|
379 |
|
| 377 |
$requete = 'SELECT '.$this->config['database_ident']['ann_id'].' AS courriel '.
|
380 |
$requete = 'SELECT '.$this->config['database_ident']['ann_id'].' AS courriel '.
|
| 378 |
'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
|
381 |
'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
|
| 379 |
'WHERE '.$this->config['database_ident']['ann_id'].' = '.$this->bdd->quote($id).' '.
|
382 |
'WHERE '.$this->config['database_ident']['ann_id'].' = '.$this->bdd->quote($id).' '.
|
| 380 |
' AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($mdp).')' ;
|
383 |
' AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($mdp).')' ;
|
| 381 |
|
384 |
|
| 382 |
$resultat = $this->bdd->query($requete)->fetch();
|
385 |
$resultat = $this->bdd->query($requete)->fetch();
|
| 383 |
|
386 |
|
| 384 |
$identifie = false;
|
387 |
$identifie = false;
|
| - |
|
388 |
if (isset($resultat['courriel'])) {
|
| - |
|
389 |
$identifie = true;
|
| - |
|
390 |
}
|
| - |
|
391 |
return $identifie;
|
| 385 |
if (isset($resultat['courriel'])) {
|
392 |
} else {
|
| 386 |
$identifie = true;
|
- |
|
| 387 |
}
|
393 |
return true; // ça fait un peu mal...
|
| Line 388... |
Line 394... |
| 388 |
return $identifie;
|
394 |
}
|
| 389 |
}
|
395 |
}
|
| 390 |
|
396 |
|
| 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';
|