Subversion Repositories Applications.annuaire

Rev

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

Rev 204 Rev 291
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 InscritsRss extends JRestService {
15
class InscritsRss extends JRestService {
Line 15... Line 16...
15
 
16
 
16
	public function getElement($uid){
-
 
17
 
17
	public function getElement($uid){
18
	    $mail_utilisateur = $uid[0];
18
		$mail_utilisateur = $uid[0];
19
	    $admin = (isset($uid[1])) ? $uid[1] : false;
19
		$admin = (isset($uid[1])) ? $uid[1] : false;
Line 20... Line 20...
20
	    $id_annuaire = Config::get('annuaire_defaut');
20
		$id_annuaire = Config::get('annuaire_defaut');
Line 38... Line 38...
38
        echo 'Accès interdit';
38
			echo 'Accès interdit';
39
        exit;
39
			exit;
40
        } else {
40
		} else {
41
            if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
41
			if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
42
                return ;
42
				return ;
43
            }
-
 
44
            else
-
 
45
            {
43
			} else {
46
                header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
44
				header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
47
                header('HTTP/1.0 401 Unauthorized');
45
				header('HTTP/1.0 401 Unauthorized');
48
                header('Content-type: text/html; charset=UTF-8');
46
				header('Content-type: text/html; charset=UTF-8');
49
                echo 'Accès interdit';
47
				echo 'Accès interdit';
50
                exit ;
48
				exit ;
51
            }
49
			}
52
        }
50
		}
53
    }
51
	}
Line 54... Line 52...
54
 
52
 
55
    public function verifierAcces($id) {
-
 
-
 
53
	public function verifierAcces($id) {
56
		
54
		$query = 'SELECT '.$this->config['database_ident']['ann_id'].' AS name '.
-
 
55
			'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
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)
56
			'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
 
57
			'	AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($_SERVER['PHP_AUTH_PW']).')' ;
Line 60... Line 58...
60
        $res = $this->bdd->query($query);
58
		$res = $this->bdd->query($query);
61
        
59
		
62
        if($res == "") {
60
		if ($res == '') {
Line 63... Line 61...
63
            return false ;
61
			return false ;
64
        }
62
		}
65
 
63
 
Line 66... Line 64...
66
        if (DB::isError($res)) {
64
		if (DB::isError($res)) {
67
            die($res->getMessage());
-
 
68
        }
65
			die($res->getMessage());
69
 
66
		}
70
        return true ;
67
 
71
 
68
		return true;