alpha_full/admin/stats/graphIP.php
2026-04-06 22:58:51 +02:00

58 lines
2.2 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
require_once("jpgraph/src/jpgraph.php");
require_once("jpgraph/src/jpgraph_bar.php");
if(file_exists("../../_include/dataBaseConnect.php")) {$includePathConf="../../_conf";include ("../../_include/dataBaseConnect.php");}
if (isset($debug[2]) && $debug[2] == '1' ) {$includePathConf="../../../_conf"; if(file_exists("../../../_include/dataBaseConnect.php")) include ("../../../_include/dataBaseConnect.php");}
// -----------------------------------------------------
// Mode Test
// -----------------------------------------------------
if (isset($_SESSION['modeTest'])) $modeTest=$_SESSION['modeTest']; else $modeTest=1;
if ($modeTest==2) {
// prendre la BDD prod
include ($includePathConf. "/prod.dbConnect.php");
// pour affichage environnement
$bdd=$bddProd;
$idPdo=$idPdoProd;
}
$reqSelect="SELECT ip, count(ip) as `nb` FROM stats group by ip HAVING `nb`>5 order by `nb` desc ;";
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .=monDebug(2, ['reqSelect' => $reqSelect],'graphPays');}
$resConn=$idPdo->query($reqSelect);
$l=0;
while ($tbP=$resConn->fetch(PDO::FETCH_ASSOC)) {
$data[$l]=$tbP['nb'];
$lib[$l]=$tbP['ip'];
// echo '$data[' .$l. ']=' .$data[$l];
$l++;
}
$largeur = 470;
$hauteur = 1400;
if(count($lib)> 60) $hauteur = 18 * count($lib);
$graph = new Graph($largeur, $hauteur, "auto");
$graph->setScale("textlin");
$histo = new BarPlot($data);
// $graph->SetBackgroundImage("mer_antilles_fond.jpg",BGIMG_FILLFRAME);
// $graph->img->SetAntiAliasing("white");
$graph->SetShadow();
$graph->add($histo);
// gauche-droit-haut-bas
$graph->Set90AndMargin(110, 40, 30, 30);
$graph->xaxis->SetPos('SIDE_LEFT');
$graph->yaxis->SetLabelMargin(-12);
$graph->xaxis->SetColor('black','blue');
$graph->yaxis->scale->SetGrace(0);
$graph->yaxis->SetPos('max');
$graph->yaxis->SetTickSide(SIDE_LEFT);
$histo->SetFillgradient('#8080FF','#D5EAFF',GRAD_WIDE_MIDVER);
$histo->value->Show();
$histo->value->SetFormat('%d');
$histo->SetValuePos('center');
$graph->xaxis->SetTickLabels($lib);
$graph->xaxis->SetTextLabelInterval(1);
$graph->title->SET("Histogramme du nombre de revisite par IP > 5");
$graph->stroke();
?>