| 74 |
aurelien |
1 |
<?php
|
| 291 |
jpm |
2 |
// declare(encoding='UTF-8');
|
| 74 |
aurelien |
3 |
/**
|
| 291 |
jpm |
4 |
* Service
|
|
|
5 |
*
|
|
|
6 |
* @category php 5.2
|
|
|
7 |
* @package Annuaire::Services
|
|
|
8 |
* @author Aurélien PERONNET <aurelien@tela-botanica.org>
|
|
|
9 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
10 |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
|
|
|
11 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
12 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
|
|
13 |
* @version $Id$
|
|
|
14 |
*/
|
|
|
15 |
class InscritsRss extends JRestService {
|
| 74 |
aurelien |
16 |
|
|
|
17 |
public function getElement($uid){
|
| 291 |
jpm |
18 |
$mail_utilisateur = $uid[0];
|
|
|
19 |
$admin = (isset($uid[1])) ? $uid[1] : false;
|
|
|
20 |
$id_annuaire = Config::get('annuaire_defaut');
|
|
|
21 |
|
|
|
22 |
if ($admin) {
|
|
|
23 |
$this->authentifier();
|
|
|
24 |
}
|
| 74 |
aurelien |
25 |
|
| 291 |
jpm |
26 |
$controleur = new RSSControleur();
|
| 204 |
aurelien |
27 |
$inscrits = $controleur->obtenirDerniersInscritsRSS($id_annuaire, $admin);
|
| 74 |
aurelien |
28 |
|
|
|
29 |
$this->envoyer($inscrits, 'text/xml',Config::get('sortie_encodage'), false);
|
|
|
30 |
}
|
| 204 |
aurelien |
31 |
|
|
|
32 |
|
|
|
33 |
public function authentifier() {
|
| 291 |
jpm |
34 |
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
|
|
35 |
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
|
|
|
36 |
header('HTTP/1.0 401 Unauthorized');
|
|
|
37 |
header('Content-type: text/html; charset=UTF-8');
|
|
|
38 |
echo 'Accès interdit';
|
|
|
39 |
exit;
|
|
|
40 |
} else {
|
|
|
41 |
if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
|
|
|
42 |
return ;
|
|
|
43 |
} else {
|
|
|
44 |
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
|
|
|
45 |
header('HTTP/1.0 401 Unauthorized');
|
|
|
46 |
header('Content-type: text/html; charset=UTF-8');
|
|
|
47 |
echo 'Accès interdit';
|
|
|
48 |
exit ;
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
}
|
| 204 |
aurelien |
52 |
|
| 291 |
jpm |
53 |
public function verifierAcces($id) {
|
|
|
54 |
$query = 'SELECT '.$this->config['database_ident']['ann_id'].' AS name '.
|
|
|
55 |
'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
|
|
|
56 |
'WHERE '.$this->config['database_ident']['ann_id'].' = '.$this->bdd->quote($id).' '.
|
|
|
57 |
' AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($_SERVER['PHP_AUTH_PW']).')' ;
|
|
|
58 |
$res = $this->bdd->query($query);
|
| 204 |
aurelien |
59 |
|
| 291 |
jpm |
60 |
if ($res == '') {
|
|
|
61 |
return false ;
|
|
|
62 |
}
|
| 204 |
aurelien |
63 |
|
| 291 |
jpm |
64 |
if (DB::isError($res)) {
|
|
|
65 |
die($res->getMessage());
|
|
|
66 |
}
|
| 204 |
aurelien |
67 |
|
| 291 |
jpm |
68 |
return true;
|
|
|
69 |
}
|
| 74 |
aurelien |
70 |
}
|
|
|
71 |
?>
|