Subversion Repositories Applications.annuaire

Compare Revisions

Ignore whitespace Rev 256 → Rev 257

/trunk/jrest/services/NbInscrits.php
New file
0,0 → 1,51
<?php
/**
* 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/
*/
 
Class NbInscrits extends JRestService {
 
public function getRessource() {
$this->getElement(array());
}
public function getElement($uid){
 
$id_annuaire = Config::get('annuaire_defaut');
if(isset($uid[0])) {
$id_annuaire = $uid[0];
}
$json = true;
if(isset($uid[1]) && $uid[1] == 'html') {
$json = false;
}
 
$controleur = new AnnuaireControleur();
$valeurs = $controleur->chargerNombreAnnuaireListeInscrits($id_annuaire);
if(!$json) {
$valeurs = '<html>
</head>
<meta content="text/html; charset='.Config::get('sortie_encodage').'" http-equiv="Content-Type">
</head>'.
'<body>
<div id="contenu">'.$valeurs.'
</div>
</body>'.
'</html>';
}
 
$this->envoyer($valeurs,'text/html',Config::get('sortie_encodage'),$json);
}
}
?>
/trunk/jrest/services/ModificationsRss.php
New file
0,0 → 1,70
<?php
/**
* 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/
*/
 
Class ModificationsRss extends JRestService {
 
public function getElement($uid){
 
$id_annuaire = (isset($uid[0])) ? $uid[0] : Config::get('annuaire_defaut');
$this->authentifier();
 
$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 ;
 
}
}
?>
/trunk/jrest/services/TelaUtilisateurs.php
New file
0,0 → 1,50
<?php
/**
* Encodage en entrée : utf8
* Encodage en sortie : utf8
*
* @author Grégoire Duché <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version $Id$
* @copyright 2009
*/
 
class TelaUtilisateurs extends JRestService {
/**
* Méthode appelée quand aucun paramêtre n'est passée dans l'url et avec une requête de type GET.
*/
public function getRessource() {
$this->getElement(array());
}
public function getElement($params = array()) {
/**
* Utilise l'API google pour donner le nombre de visiteurs
* et compte le nombre d'inscrits.
* */
// Utilisation du fichier de configuration pour récupérer les identifiants de google analytics
$email_google = $this->config['google']['email_google'];
$password_google = $this->config['google']['password_google'];
$id_site_google = $this->config['google']['id_site_google'];
 
include_once '../services/GoogleAnalyticsAPI.php';
$ga = new GoogleAnalyticsAPI($email_google, $password_google, $id_site_google, date('Y-m-d', time() - 60 * 600), date('Y-m-d', time()));
 
$id_annuaire = Config::get('annuaire_defaut');
if(isset($uid[0])) {
$id_annuaire = $uid[0];
}
 
$controleur = new AnnuaireControleur();
$nb_inscrits = $controleur->chargerNombreAnnuaireListeInscrits($id_annuaire);
$info[] = $nb_inscrits;
$info[] = $ga->getMetric('visitors');
$this->envoyer($info);
}
}
?>