1,18 → 1,15 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Service fournissant le nom de visiteur journalier sur le |
* site tela-botanica.org grâce aux stats de Google Analytics. |
* |
* @category php 5.2 |
* @package Annuaire::Services |
* @author Grégoire DUCHÉ <gregoire@tela-botanica.org> |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Copyright (c) 2009, 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$ |
* 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 { |
|
/** |
22,28 → 19,21 |
$this->getElement(array()); |
} |
|
/** |
* Utilise l'API google pour donner le nombre de visiteurs |
* et compte le nombre d'inscrits. |
*/ |
public function getElement($params = array()) { |
// 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']; |
|
$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])) { |
if(isset($uid[0])) { |
$id_annuaire = $uid[0]; |
} |
|
$controleur = new AnnuaireControleur(); |
$controleur = new AnnuaireControleur(); |
$nb_inscrits = $controleur->chargerNombreAnnuaireListeInscrits($id_annuaire); |
|
$info[] = $nb_inscrits; |
$info[] = $ga->getMetric('visitors'); |
|
//TODO externaliser ceci |
$en_ligne = file_get_contents('/home/telabotap/www/nb_sessions_active.json'); |
$info[] = json_decode($en_ligne); |
|
$this->envoyer($info); |
} |