1
0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__avion-poeme/gestion/stats.php
Daniel Tartavel 37d8c8b64f 2021-04-07
2021-04-07 21:08:08 +02:00

75 lines
1.8 KiB
PHP

<?php
require_once '../session_init.php';
require_once 'config.inc.php';
require_once 'db.class.php';
require_once 'log.php';
$db = new db();
$db->open();
function totaltotal() //nombre d'avions poèmes créés depuis le début
{
global $db;
$query = "SHOW TABLE STATUS LIKE 'avionpoeme'";
$db->query($query);
$result = $db->result->fetch_assoc();
return $result['Auto_increment']-1;
}
function total()
{
global $db;
$query = "SELECT COUNT(*) as nAvion FROM avionpoeme";
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["nAvion"];
}
function totalenvol()
{
global $db;
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE public!=2";
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["n"];
}
function alea()
{
global $db;
$query = "SELECT COUNT(*) as nAvion FROM avionpoeme WHERE ";
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["n"];
}
function anonymous()
{
global $db;
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE expemail=''";
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["n"];
}
$nAvionCree = totaltotal();
if ($nAvionCree == 0)
{
echo "Aucun avion-poème envoyé pour l'instant";
}else
{
echo "Nombre total d'avions-poème : " . $nAvionCree . EOL;
$total = total();
$avionSupp = $nAvionCree-$total;
echo "Nombre d'avion supprimés : " . $avionSupp . " => " . $avionSupp/$nAvionCree*100 . "%" . EOL;
$nAvionenvol = totalenvol();
echo "Nombre d'avions-poème en vol : " . $nAvionenvol . " => " . $nAvionenvol/$nAvionCree*100 . "%" . EOL;
$anonymous = anonymous();
echo "Nombre d'envois anonymes : " . $anonymous . " => " . $anonymous/$nAvionCree*100 . "%" . EOL;
}
$db->close();