Subversion Repositories Applications.annuaire

Compare Revisions

Ignore whitespace Rev 292 → Rev 293

/trunk/jrest/services/ModificationsRss.php
1,70 → 1,28
<?php
// declare(encoding='UTF-8');
/**
* PHP Version 5
*
* @category PHP
* @package annuaire
* @author aurelien <aurelien@tela-botanica.org>
* @copyright 2010 Tela-Botanica
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @version SVN: <svn_id>
* @link /doc/annuaire/
*/
* Service
*
* @category php 5.2
* @package Annuaire::Services
* @author Aurélien PERONNET <aurelien@tela-botanica.org>
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
* @version $Id$
*/
class ModificationsRss extends JRestService {
 
Class ModificationsRss extends JRestService {
 
public function getElement($uid){
$id_annuaire = (isset($uid[0])) ? $uid[0] : Config::get('annuaire_defaut');
$this->authentifier();
 
$id_annuaire = (isset($uid[0])) ? $uid[0] : Config::get('annuaire_defaut');
$this->authentifier();
 
$controleur = new RSSControleur();
$controleur = new RSSControleur();
$modifications = $controleur->obtenirDernieresModificationsProfil($id_annuaire);
 
$this->envoyer($modifications, 'text/xml',Config::get('sortie_encodage'), false);
}
public function authentifier() {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
header('HTTP/1.0 401 Unauthorized');
header('Content-type: text/html; charset=UTF-8');
echo 'Accès interdit';
exit;
} else {
if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
return ;
}
else
{
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
header('HTTP/1.0 401 Unauthorized');
header('Content-type: text/html; charset=UTF-8');
echo 'Accès interdit';
exit ;
}
}
}
 
public function verifierAcces($id) {
$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)
." AND ".$this->config['database_ident']['ann_pwd']." = ".$this->config['database_ident']['pass_crypt_funct']."(".$this->bdd->quote($_SERVER['PHP_AUTH_PW']).")" ;
 
$res = $this->bdd->query($query);
if($res == "") {
return false ;
}
 
if (DB::isError($res)) {
die($res->getMessage());
}
 
return true ;
 
}
}
?>