Subversion Repositories Applications.annuaire

Rev

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

Rev 74 Rev 204
Line 14... Line 14...
14
Class InscritsRss extends JRestService {
14
Class InscritsRss extends JRestService {
Line 15... Line 15...
15
 
15
 
Line 16... Line 16...
16
	public function getElement($uid){
16
	public function getElement($uid){
-
 
17
 
17
 
18
	    $mail_utilisateur = $uid[0];
-
 
19
	    $admin = (isset($uid[1])) ? $uid[1] : false;
-
 
20
	    $id_annuaire = Config::get('annuaire_defaut');
-
 
21
	    
-
 
22
	    if($admin) {
Line 18... Line 23...
18
	    $mail_utilisateur = $uid[0];
23
	    	$this->authentifier();		
19
	    $id_annuaire = Config::get('annuaire_defaut');
24
	    }
Line 20... Line 25...
20
 
25
 
21
	    $controleur = new RSSControleur();
26
	    $controleur = new RSSControleur();
-
 
27
		$inscrits = $controleur->obtenirDerniersInscritsRSS($id_annuaire, $admin);
-
 
28
 
-
 
29
		$this->envoyer($inscrits, 'text/xml',Config::get('sortie_encodage'), false);
-
 
30
	}
-
 
31
	
-
 
32
	
-
 
33
	public function authentifier() {
-
 
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
            }
-
 
44
            else
-
 
45
            {
-
 
46
                header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
-
 
47
                header('HTTP/1.0 401 Unauthorized');
-
 
48
                header('Content-type: text/html; charset=UTF-8');
-
 
49
                echo 'Accès interdit';
-
 
50
                exit ;
-
 
51
            }
-
 
52
        }
-
 
53
    }
-
 
54
 
-
 
55
    public function verifierAcces($id) {
-
 
56
		
-
 
57
        $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)
-
 
58
        ." AND ".$this->config['database_ident']['ann_pwd']." = ".$this->config['database_ident']['pass_crypt_funct']."(".$this->bdd->quote($_SERVER['PHP_AUTH_PW']).")" ;
-
 
59
 
-
 
60
        $res = $this->bdd->query($query);
-
 
61
        
-
 
62
        if($res == "") {
-
 
63
            return false ;
-
 
64
        }
-
 
65
 
-
 
66
        if (DB::isError($res)) {
-
 
67
            die($res->getMessage());
-
 
68
        }
22
		$inscrits = $controleur->obtenirDerniersInscritsRSS($id_annuaire);
69
 
23
 
70
        return true ;
24
		$this->envoyer($inscrits, 'text/xml',Config::get('sortie_encodage'), false);
71