+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page('stats/coupure.tpl',AUTH_PUBLIC);
-
-function serv_to_str($params) {
- $flags = explode(',',$params);
- $trad = Array('web' => 'site web', 'mail'=> 'redirection mail',
- 'smtp' => 'serveur sécurisé d\'envoi de mails',
- 'nntp' => 'serveur des forums de discussion');
- $ret = Array();
- foreach ($flags as $flag) {
- $ret[] = $trad[$flag];
- }
- return implode(', ',$ret);
-}
-
-if (Env::has('cp_id')) {
- $res = $globals->xdb->query("SELECT UNIX_TIMESTAMP(debut) AS debut,
- TIME_FORMAT(duree,'%kh%i') AS duree,
- resume, description, services
- FROM coupures
- WHERE id = {?}", Env::getInt('cp_id'));
- $cp = $res->fetchOneAssoc();
-}
-
-if($cp) {
- $cp['lg_services'] = serv_to_str($cp['services']);
- $page->assign_by_ref('cp',$cp);
-} else {
- $beginning_date = date("Ymd", time() - 3600*24*21) . "000000";
- $sql = "select id, UNIX_TIMESTAMP(debut) as debut, resume, services from coupures where debut > '$beginning_date' order by debut desc";
- $page->assign('coupures', $globals->xdb->iterator($sql));
-}
-
-$page->run();
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page("stats/evolution_inscrits.tpl", AUTH_COOKIE);
-
-$page->run();
-
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-
-new_skinned_page('index.tpl', AUTH_COOKIE);
-$promo = Env::getInt('promo', Session::getInt('promo'));
-
-// date de départ
-$depart = 1920;
-
-//recupere le nombre d'inscriptions par jour sur la plage concernée
-$res = $globals->xdb->iterRow(
- "SELECT promo, SUM(perms IN ('admin', 'user')) / COUNT(*) * 100
- FROM auth_user_md5
- WHERE promo >= $depart AND deces = 0
- GROUP BY promo");
-
-//genere des donnees compatibles avec GNUPLOT
-$inscrits='';
-
-// la première ligne contient le total des inscrits avant la date de départ
-list($annee, $nb) = $res->next();
-
-for ($i=$depart;$i<=date("Y");$i++) {
- if ($annee<$i) {
- if(!list($annee, $nb) = $res->next()) {
- $annee = 0;
- $nb = 0;
- }
- }
- if ($nb > 0 || $i < date("Y"))
- $inscrits .= $i." ".$nb."\n";
-}
-
-//Genere le graphique à la volée avec GNUPLOT
-header( "Content-type: image/png");
-
-$ymin = 0;
-$ymax = 100;
-
-$fin = $i+10;
-
-$gnuplot = <<<EOF2
-gnuplot <<EOF
-
-set term png small color
-set size 640/480
-set timefmt "%d/%m/%y"
-
-set xr [$depart:$fin]
-set yr [$ymin:$ymax]
-
-set title "Nombre d'inscrits par promotion depuis $depart."
-
-plot "-" using 1:2 title 'inscrits' with boxes;
-{$inscrits}
-EOF
-EOF2;
-
-passthru($gnuplot);
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-
-new_skinned_page('index.tpl', AUTH_COOKIE);
-
-//nombre de jours sur le graph
-$JOURS=Env::getInt('jours', 364);
-define('DUREEJOUR',24*3600);
-
-//recupere le nombre d'inscriptions par jour sur la plage concernée
-$res = $globals->xdb->iterRow(
- "SELECT IF( date_ins>DATE_SUB(NOW(),INTERVAL $JOURS DAY),
- TO_DAYS(date_ins)-TO_DAYS(NOW()),
- ".(-($JOURS+1)).") AS jour,
- COUNT(user_id) AS nb
- FROM auth_user_md5
- WHERE perms IN ('admin','user')
- GROUP BY jour");
-
-//genere des donnees compatibles avec GNUPLOT
-$inscrits='';
-
-// la première ligne contient le total des inscrits avant la date de départ (J - $JOURS)
-list(,$init_nb) = $res->next();
-$total = $init_nb;
-
-list($numjour, $nb) = $res->next();
-
-for ($i=-$JOURS;$i<=0;$i++) {
- if ($numjour<$i) {
- if(!list($numjour, $nb) = $res->next()) {
- $numjour = 0;
- $nb = 0;
- }
- }
- if ($numjour==$i) $total+=$nb;
- $inscrits .= date('d/m/y',$i*DUREEJOUR+time())." ".$total."\n";
-}
-
-//Genere le graphique à la volée avec GNUPLOT
-header( "Content-type: image/png");
-
-$delt = ($total - $init_nb)/10;
-$ymin = round($init_nb - $delt,0);
-$ymax = round($total + $delt,0);
-
-$gnuplot = <<<EOF2
-gnuplot <<EOF
-
-set term png small color
-set size 640/480
-set xdata time
-set timefmt "%d/%m/%y"
-
-set format x "%m/%y"
-set yr [$ymin:$ymax]
-
-set title "Nombre d'inscrits"
-
-plot "-" using 1:2 title 'inscrits' with lines;
-{$inscrits}
-EOF
-EOF2;
-
-passthru($gnuplot);
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-
-new_skinned_page('index.tpl', AUTH_COOKIE);
-$promo = Env::getInt('promo', Session::getInt('promo'));
-
-//nombre de jours sur le graph
-$JOURS=364;
-define('DUREEJOUR',24*3600);
-$res = $globals->xdb->query("SELECT min(TO_DAYS(date_ins)-TO_DAYS(now())) FROM auth_user_md5 WHERE promo = {?} AND perms IN ('admin', 'user')", $promo);
-$JOURS = -$res->fetchOneCell();
-
-//recupere le nombre d'inscriptions par jour sur la plage concernée
-$res = $globals->xdb->iterRow(
- "SELECT IF( date_ins>DATE_SUB(NOW(),INTERVAL $JOURS DAY),
- TO_DAYS(date_ins)-TO_DAYS(NOW()),
- ".(-($JOURS+1)).") AS jour,
- COUNT(user_id) AS nb
- FROM auth_user_md5
- WHERE promo = {?} AND perms IN ('admin','user')
- GROUP BY jour", $promo);
-
-//genere des donnees compatibles avec GNUPLOT
-$inscrits='';
-
-// la première ligne contient le total des inscrits avant la date de départ (J - $JOURS)
-list(,$init_nb) = $res->next();
-$total = $init_nb;
-
-list($numjour, $nb) = $res->next();
-
-for ($i=-$JOURS;$i<=0;$i++) {
- if ($numjour<$i) {
- if(!list($numjour, $nb) = $res->next()) {
- $numjour = 0;
- $nb = 0;
- }
- }
- if ($numjour==$i) $total+=$nb;
- $inscrits .= date('d/m/y',$i*DUREEJOUR+time())." ".$total."\n";
-}
-
-//Genere le graphique à la volée avec GNUPLOT
-header( "Content-type: image/png");
-
-$delt = ($total - $init_nb) / 10;
-$delt += ($delt < 1);
-$ymin = round($init_nb - $delt,0);
-$ymax = round($total + $delt,0);
-
-$gnuplot = <<<EOF2
-gnuplot <<EOF
-
-set term png small color
-set size 640/480
-set xdata time
-set timefmt "%d/%m/%y"
-
-set format x "%m/%y"
-set yr [$ymin:$ymax]
-
-set title "Nombre d'inscrits de la promotion $promo."
-
-plot "-" using 1:2 title 'inscrits' with lines;
-{$inscrits}e
-EOF
-EOF2;
-
-passthru($gnuplot);
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2004 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page("stats/index.tpl",AUTH_PUBLIC);
-$page->run();
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page('stats/nb_by_promo.tpl', AUTH_COOKIE);
-
-$res = $globals->xdb->iterRow(
- "SELECT promo,COUNT(*)
- FROM auth_user_md5
- WHERE promo > 1900 AND perms IN ('admin','user')
- GROUP BY promo
- ORDER BY promo");
-$max=0; $min=3000;
-
-while (list($promo,$nb) = $res->next()) {
- $promo = intval($promo);
- if(!isset($nbpromo[$promo/10])) {
- $nbpromo[$promo/10] = Array('','','','','','','','','',''); // tableau de 10 cases vides
- }
- $nbpromo[$promo/10][$promo%10]=Array('promo' => $promo, 'nb' => $nb);
-}
-
-$page->assign_by_ref('nbs', $nbpromo);
-$page->assign('min', $min-$min % 10);
-$page->assign('max', $max+10-$max%10);
-
-$page->run();
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page("stats/stats_promo.tpl", AUTH_COOKIE);
-
-$promo = Env::getInt('promo', Session::getInt('promo'));
-$page->assign('promo',$promo);
-$page->run();
-
-?>
+++ /dev/null
-htdocs/admin/gerer_coupure.php
-htdocs/stats/coupure.php
-htdocs/stats/graph_promo.php
-htdocs/stats/index.php
-htdocs/stats/nb_by_promo.php
-htdocs/stats/stats_promo.php
-templates/stats/coupure.tpl
-templates/stats/index.tpl
-templates/stats/nb_by_promo.tpl
-templates/stats/stats_promo.tpl
if (Env::get('submit') == 'Valider' and Env::has('url')) {
$globals->xdb->execute('UPDATE auth_user_quick
SET redirecturl = {?} WHERE user_id = {?}',
- $url, Session::getInt('uid')))
+ $url, Session::getInt('uid'));
$log->log('carva_add', 'http://'.Env::get('url'));
$page->trig("Redirection activée vers <a href='http://$url'>$url</a>");
} elseif (Env::get('submit') == "Supprimer") {
$globals->xdb->execute("UPDATE auth_user_quick
SET redirecturl = ''
WHERE user_id = {?}",
- Session::getInt('uid')))
+ Session::getInt('uid'));
$log->log("carva_del", $url);
Post::kill('url');
$page->trig('Redirection supprimée');
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+function serv_to_str($params) {
+ $flags = explode(',',$params);
+ $trad = Array('web' => 'site web', 'mail'=> 'redirection mail',
+ 'smtp' => 'serveur sécurisé d\'envoi de mails',
+ 'nntp' => 'serveur des forums de discussion');
+ $ret = Array();
+ foreach ($flags as $flag) {
+ $ret[] = $trad[$flag];
+ }
+ return implode(', ',$ret);
+}
+
+class StatsModule extends PLModule
+{
+ function handlers()
+ {
+ return array(
+ 'stats' => $this->make_hook('stats', AUTH_COOKIE),
+ 'stats/evolution' => $this->make_hook('evolution', AUTH_COOKIE),
+ 'stats/graph' => $this->make_hook('graph', AUTH_COOKIE),
+ 'stats/graph/evolution'
+ => $this->make_hook('graph_evo', AUTH_COOKIE),
+ 'stats/promos' => $this->make_hook('promos', AUTH_COOKIE),
+
+ 'stats/coupures' => $this->make_hook('coupures', AUTH_PUBLIC),
+ );
+ }
+
+ function handler_stats(&$page)
+ {
+ $page->changeTpl('stats/index.tpl');
+ return PL_OK;
+ }
+
+ function handler_evolution(&$page, $jours = 365)
+ {
+ $page->changeTpl('stats/evolution_inscrits.tpl');
+ $page->assign('jours', $jours);
+ return PL_OK;
+ }
+
+ function handler_graph_evo(&$page, $jours = 365)
+ {
+ global $globals;
+
+ define('DUREEJOUR',24*3600);
+
+ //recupere le nombre d'inscriptions par jour sur la plage concernée
+ $res = $globals->xdb->iterRow(
+ "SELECT IF( date_ins>DATE_SUB(NOW(),INTERVAL $jours DAY),
+ TO_DAYS(date_ins)-TO_DAYS(NOW()),
+ ".(-($jours+1)).") AS jour,
+ COUNT(user_id) AS nb
+ FROM auth_user_md5
+ WHERE perms IN ('admin','user')
+ GROUP BY jour");
+
+ //genere des donnees compatibles avec GNUPLOT
+ $inscrits='';
+
+ // la première ligne contient le total des inscrits avant la date de départ (J - $jours)
+ list(,$init_nb) = $res->next();
+ $total = $init_nb;
+
+ list($numjour, $nb) = $res->next();
+
+ for ($i = -$jours; $i<=0; $i++) {
+ if ($numjour<$i) {
+ if(!list($numjour, $nb) = $res->next()) {
+ $numjour = 0;
+ $nb = 0;
+ }
+ }
+ if ($numjour==$i) $total+=$nb;
+ $inscrits .= date('d/m/y',$i*DUREEJOUR+time())." ".$total."\n";
+ }
+
+ //Genere le graphique à la volée avec GNUPLOT
+ header( "Content-type: image/png");
+
+ $delt = ($total - $init_nb)/10;
+ $ymin = round($init_nb - $delt,0);
+ $ymax = round($total + $delt,0);
+
+ $gnuplot = <<<EOF2
+gnuplot <<EOF
+
+set term png small color
+set size 640/480
+set xdata time
+set timefmt "%d/%m/%y"
+
+set format x "%m/%y"
+set yr [$ymin:$ymax]
+
+set title "Nombre d'inscrits"
+
+plot "-" using 1:2 title 'inscrits' with lines;
+{$inscrits}
+EOF
+EOF2;
+
+ passthru($gnuplot);
+ exit;
+ }
+
+ function handler_graph(&$page, $promo = null)
+ {
+ global $globals;
+
+ if ($promo == 'all') {
+ // date de départ
+ $depart = 1920;
+
+ //recupere le nombre d'inscriptions par jour sur la plage concernée
+ $res = $globals->xdb->iterRow(
+ "SELECT promo, SUM(perms IN ('admin', 'user')) / COUNT(*) * 100
+ FROM auth_user_md5
+ WHERE promo >= $depart AND deces = 0
+ GROUP BY promo");
+
+ //genere des donnees compatibles avec GNUPLOT
+ $inscrits='';
+
+ // la première ligne contient le total des inscrits avant la date de départ
+ list($annee, $nb) = $res->next();
+
+ for ($i = $depart; $i <= date("Y"); $i++) {
+ if ($annee < $i) {
+ if(!list($annee, $nb) = $res->next()) {
+ $annee = 0;
+ $nb = 0;
+ }
+ }
+ if ($nb > 0 || $i < date('Y'))
+ $inscrits .= $i.' '.$nb."\n";
+ }
+
+ //Genere le graphique à la volée avec GNUPLOT
+ $fin = $i+2;
+
+ $gnuplot = <<<EOF2
+gnuplot <<EOF
+
+set term png small color
+set size 640/480
+set timefmt "%d/%m/%y"
+
+set xr [$depart:$fin]
+set yr [0:100]
+
+set title "Nombre d'inscrits par promotion depuis $depart."
+
+plot "-" using 1:2 title 'inscrits' with boxes;
+{$inscrits}
+EOF
+EOF2;
+
+ } else {
+ //nombre de jours sur le graph
+ $jours = 365;
+ define('DUREEJOUR',24*3600);
+ $res = $globals->xdb->query("SELECT min(TO_DAYS(date_ins)-TO_DAYS(now()))
+ FROM auth_user_md5
+ WHERE promo = {?}
+ AND perms IN ('admin', 'user')",
+ $promo);
+ $jours = -$res->fetchOneCell();
+
+ //recupere le nombre d'inscriptions par jour sur la plage concernée
+ $res = $globals->xdb->iterRow(
+ "SELECT IF( date_ins>DATE_SUB(NOW(),INTERVAL $jours DAY),
+ TO_DAYS(date_ins)-TO_DAYS(NOW()),
+ ".(-($jours+1)).") AS jour,
+ COUNT(user_id) AS nb
+ FROM auth_user_md5
+ WHERE promo = {?} AND perms IN ('admin','user')
+ GROUP BY jour", $promo);
+
+ //genere des donnees compatibles avec GNUPLOT
+ $inscrits='';
+
+ // la première ligne contient le total des inscrits avant la date de départ (J - $jours)
+ list(,$init_nb) = $res->next();
+ $total = $init_nb;
+
+ list($numjour, $nb) = $res->next();
+
+ for ($i = -$jours;$i<=0;$i++) {
+ if ($numjour<$i) {
+ if(!list($numjour, $nb) = $res->next()) {
+ $numjour = 0;
+ $nb = 0;
+ }
+ }
+ if ($numjour==$i) $total+=$nb;
+ $inscrits .= date('d/m/y',$i*DUREEJOUR+time())." ".$total."\n";
+ }
+
+ //Genere le graphique à la volée avec GNUPLOT
+ $delt = ($total - $init_nb) / 10;
+ $delt += ($delt < 1);
+ $ymin = round($init_nb - $delt,0);
+ $ymax = round($total + $delt,0);
+
+ $gnuplot = <<<EOF2
+gnuplot <<EOF
+
+set term png small color
+set size 640/480
+set xdata time
+set timefmt "%d/%m/%y"
+
+set format x "%m/%y"
+set yr [$ymin:$ymax]
+
+set title "Nombre d'inscrits de la promotion $promo."
+
+plot "-" using 1:2 title 'inscrits' with lines;
+{$inscrits}e
+EOF
+EOF2;
+ }
+
+ header('Content-type: image/png');
+ passthru($gnuplot);
+ exit;
+ }
+
+ function handler_promos(&$page, $promo = null)
+ {
+ global $globals;
+
+ $page->changeTpl('stats/nb_by_promo.tpl');
+
+ $res = $globals->xdb->iterRow(
+ "SELECT promo,COUNT(*)
+ FROM auth_user_md5
+ WHERE promo > 1900 AND perms IN ('admin','user')
+ GROUP BY promo
+ ORDER BY promo");
+ $max=0; $min=3000;
+
+ while (list($p,$nb) = $res->next()) {
+ $p = intval($p);
+ if(!isset($nbpromo[$p/10])) {
+ $nbpromo[$p/10] = Array('','','','','','','','','',''); // tableau de 10 cases vides
+ }
+ $nbpromo[$p/10][$p%10]=Array('promo' => $p, 'nb' => $nb);
+ }
+
+ $page->assign_by_ref('nbs', $nbpromo);
+ $page->assign('min', $min-$min % 10);
+ $page->assign('max', $max+10-$max%10);
+ $page->assign('promo', $promo);
+
+ return PL_OK;
+ }
+
+ function handler_coupures(&$page, $cp_id = null)
+ {
+ global $globals;
+
+ $page->changeTpl('stats/coupure.tpl');
+
+ if (!is_null($cp_id)) {
+ $res = $globals->xdb->query("SELECT UNIX_TIMESTAMP(debut) AS debut,
+ TIME_FORMAT(duree,'%kh%i') AS duree,
+ resume, description, services
+ FROM coupures
+ WHERE id = {?}", $cp_id);
+ $cp = $res->fetchOneAssoc();
+ }
+
+ if($cp) {
+ $cp['lg_services'] = serv_to_str($cp['services']);
+ $page->assign_by_ref('cp',$cp);
+ } else {
+ $beginning_date = date("Ymd", time() - 3600*24*21) . "000000";
+ $sql = "SELECT id, UNIX_TIMESTAMP(debut) AS debut, resume, services
+ FROM coupures where debut > '$beginning_date' order by debut desc";
+ $page->assign('coupures', $globals->xdb->iterator($sql));
+ }
+
+ return PL_OK;
+ }
+}
+
+?>
<a href="{rel}/Docs/Ethique">Services et Ethique</a>
| <a href="{rel}/Docs/Charte">Charte</a>
{min_auth level=cookie}
- | <a href="{rel}/stats/coupure.php">Disponibilité</a>
- | <a href="{rel}/stats/">Statistiques</a>
+ | <a href="{rel}/stats/coupures">Disponibilité</a>
+ | <a href="{rel}/stats">Statistiques</a>
{/min_auth}
</div>
{* *}
{**************************************************************************}
-
{if $cp}
<table class="bicol" summary="Ruptures de service">
<tr>
</table>
<p class="center">
-<a href="{$smarty.server.PHP_SELF}">retour à la liste</a>
+<a href="{rel}/stats/coupures">retour à la liste</a>
</p>
{else}
</td>
<td>
<span class="smaller">
- <a href="{$smarty.server.PHP_SELF}?cp_id={$cp.id}">{$cp.resume}</a>
+ <a href="{rel}/stats/coupures/{$cp.id}">{$cp.resume}</a>
</span>
</td>
<td>
{* *}
{**************************************************************************}
-
-<h1>
- Evolution du nombre d'inscrits au site polytechnique.org
-</h1>
+<h1>Evolution du nombre d'inscrits au site polytechnique.org</h1>
<div class="center">
-{if $smarty.request.jours eq 1826}
+{if $jours eq 1825}
[<strong>depuis 5 ans</strong>]
{else}
-[<a href="?jours=1826">depuis 5 ans</a>]
+[<a href="{rel}/stats/evolution/1825">depuis 5 ans</a>]
{/if}
-{if $smarty.request.jours eq 731}
+{if $jours eq 730}
[<strong>depuis 2 ans</strong>]
{else}
-[<a href="?jours=731">depuis 2 ans</a>]
+[<a href="{rel}/stats/evolution/730">depuis 2 ans</a>]
{/if}
-{if (!$smarty.request.jours) or ($smarty.request.jours eq 364)}
+{if $jours eq 365}
[<strong>depuis un an</strong>]
{else}
-[<a href="?jours=364">depuis un an</a>]
+[<a href="{rel}/stats/evolution/365">depuis un an</a>]
{/if}
-{if $smarty.request.jours eq 30}
+{if $jours eq 30}
[<strong>depuis un mois</strong>]
{else}
-[<a href="?jours=30">depuis 1 mois</a>]
+[<a href="{rel}/stats/evolution/30">depuis 1 mois</a>]
{/if}
</div>
<div class="center">
- <img src="{"stats/graph_evolution.php?jours="|url}{$smarty.request.jours}" alt=" [ INSCRITS ] " />
+ <img src="{rel}/stats/graph/evolution/{$jours}" alt=" [ INSCRITS ] " />
</div>
{* vim:set et sw=2 sts=2 sws=2: *}
</p>
<ul>
-<li><a href="evolution_inscrits.php">Nombre d'inscrits au cours du temps</a></li>
-<li><a href="stats_promo.php">Nombre d'inscrits dans ta promotion</a></li>
-<li><a href="nb_by_promo.php">Nombre d'inscrits par promotion</a></li>
+<li><a href="{rel}/stats/evolution">Nombre d'inscrits au cours du temps</a></li>
+<li><a href="{rel}/stats/promos/{$smarty.session.promo}">Nombre d'inscrits dans ta promotion</a></li>
+<li><a href="{rel}/stats/promos">Nombre d'inscrits par promotion</a></li>
</ul>
{* vim:set et sw=2 sts=2 sws=2: *}
{* *}
{**************************************************************************}
-
-<h1>
- Inscrits par promo
-</h1>
+<h1>Inscrits par promo</h1>
<p>
Voici le nombre d'inscrits par promo :
<th>{$lustre}-</th>
{foreach item=nb from=$nb10}
<td class="center">
- {if $nb && $nb.promo eq $smarty.request.promo}
+ {if $nb && $nb.promo eq $promo}
<span class='erreur'>{$nb.nb}</span>
{elseif $nb}
- <a href="?promo={$nb.promo}">{$nb.nb}</a>
+ <a href="{rel}/stats/promos/{$nb.promo}">{$nb.nb}</a>
{else}
-
{/if}
{/foreach}
</table>
-{if $smarty.request.promo}
+{if $promo}
<p class='center'>
-[<a href="{$smarty.server.PHP_SELF}">répartition des inscrits par promo</a>]
+[<a href="{rel}/stats/promos">répartition des inscrits par promo</a>]
</p>
-<h1>Courbe d'inscription de la promo {$smarty.request.promo}</h1>
+<h1>Courbe d'inscription de la promo {$promo}</h1>
<div class="center">
- <img src="{"stats/graph_promo.php"|url}?promo={$smarty.request.promo}" alt=" [ INSCRITS ] " />
+ <img src="{rel}/stats/graph/{$promo}" alt=" [ INSCRITS ] " />
</div>
{else}
<h1>Inscrits par promo en (%)</h1>
<div class="center">
- <img src="{"stats/graph_by_promo.php"|url}" alt="[graphe du nombre d'inscrits par promo]" />
+ <img src="{rel}/stats/graph/all" alt="[graphe du nombre d'inscrits par promo]" />
</div>
{/if}