Subversion Repositories Applications.annuaire

Rev

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

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