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

75 lines
1.9 KiB
PHP
Raw Normal View History

2021-04-07 21:08:08 +02:00
<?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;
}
2021-07-24 10:18:09 +02:00
function total() //nombre d'avions poèmes présents dans la base
2021-04-07 21:08:08 +02:00
{
global $db;
$query = "SELECT COUNT(*) as nAvion FROM avionpoeme";
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["nAvion"];
}
2021-07-24 10:18:09 +02:00
function totalenvol() //nombre d'avions poèmes en vol
2021-04-07 21:08:08 +02:00
{
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"];
}
2021-07-24 10:18:09 +02:00
function anonymous() //nombre d'avions poèmes envoyés anonymement
2021-04-07 21:08:08 +02:00
{
global $db;
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE expemail=''";
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["n"];
}
2021-07-24 10:18:09 +02:00
$nAvionEnvoye = totaltotal();
if ($nAvionEnvoye == 0)
2021-04-07 21:08:08 +02:00
{
echo "Aucun avion-poème envoyé pour l'instant";
}else
{
2021-07-24 10:18:09 +02:00
echo "Nombre total d'avions-poème : " . $nAvionEnvoye . EOLH;
2021-04-07 21:08:08 +02:00
$total = total();
2021-07-24 10:18:09 +02:00
$avionSupp = $nAvionEnvoye-$total;
echo "Nombre d'avion supprimés : " . $avionSupp . " => " . round($avionSupp/$nAvionEnvoye*100,3) . "%" . EOLH;
2021-04-07 21:08:08 +02:00
$nAvionenvol = totalenvol();
2021-07-24 10:18:09 +02:00
echo "Nombre d'avions-poème en vol : " . $nAvionenvol . " => " . round($nAvionenvol/$nAvionEnvoye*100) . "%" . EOLH;
2021-04-07 21:08:08 +02:00
$anonymous = anonymous();
2021-07-24 10:18:09 +02:00
echo "Nombre d'envois anonymes : " . $anonymous . " => " . round($anonymous/$nAvionEnvoye*100) . "%" . EOLH;
2021-04-07 21:08:08 +02:00
}
$db->close();