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

95 lines
2.7 KiB
PHP
Raw Permalink 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-10-30 12:37:27 +02:00
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;
2021-10-30 12:37:27 +02:00
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE atteri!=1";
2021-04-07 21:08:08 +02:00
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["n"];
}
2021-10-30 12:37:27 +02:00
function alea($nAvionEnvoye)
{
global $db;
$query = "SELECT DISTINCT deliveryMethod FROM avionpoeme";
$db->query($query);
$result = $db->result->fetch_all(MYSQLI_ASSOC);
//var_dump($result);
foreach ( $result as $method )
{
$query = "SELECT COUNT(*) as nAvion FROM avionpoeme WHERE deliveryMethod='" . $method["deliveryMethod"] . "'";
$db->query($query);
$result = $db->result->fetch_assoc();
echo "Méthode => " . $method["deliveryMethod"] . " nombre d'avion poèmes => " . $result["nAvion"] . " => " . round($result["nAvion"]/$nAvionEnvoye*100,2) . "%" . EOLH;
}
}
function anonymous() //nombre d'avions poèmes envoyés anonymement
2021-04-07 21:08:08 +02:00
{
global $db;
2021-10-30 12:37:27 +02:00
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE expeknown='0'";
2021-04-07 21:08:08 +02:00
$db->query($query);
$result = $db->result->fetch_assoc();
return $result["n"];
}
2021-10-30 12:37:27 +02:00
function deleted()
2021-04-07 21:08:08 +02:00
{
global $db;
2021-10-30 12:37:27 +02:00
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE public='2'";
2021-04-07 21:08:08 +02:00
$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;
2021-10-30 12:37:27 +02:00
echo "Nombre d'avion supprimés : " . $avionSupp . " => " . round($avionSupp/$nAvionEnvoye*100,2) . "%" . EOLH;
2021-04-07 21:08:08 +02:00
$nAvionenvol = totalenvol();
2021-10-30 12:37:27 +02:00
echo "Nombre d'avions-poème en vol : " . $nAvionenvol . " => " . round($nAvionenvol/$nAvionEnvoye*100,2) . "%" . EOLH;
2021-04-07 21:08:08 +02:00
$anonymous = anonymous();
2021-10-30 12:37:27 +02:00
echo "Nombre d'envois anonymes : " . $anonymous . " => " . round($anonymous/$nAvionEnvoye*100,2) . "%" . EOLH;
$deleted = deleted();
echo "Nombre d'avions anonymisés(effacés) : " . $deleted . " => " . round($deleted/$nAvionEnvoye*100,2) . "%" . EOLH;
alea($nAvionEnvoye);
2021-04-07 21:08:08 +02:00
}
$db->close();