ajout statistiques
This commit is contained in:
parent
869926af3f
commit
febc76934b
@ -3,6 +3,13 @@
|
||||
require_once 'config.inc.php';
|
||||
require_once 'db.class.php';
|
||||
require_once 'log.php';
|
||||
|
||||
affich_log(200);
|
||||
$page = getpost("np");
|
||||
$niveau = getpost("level");
|
||||
print '<!DOCTYPE html><html>
|
||||
<head><meta charset="utf-8">
|
||||
<title>Avion-poème</title>
|
||||
<link rel="icon" href="src/img/icon.png">
|
||||
</head><body>';
|
||||
affich_log(200, $page, $niveau);
|
||||
print '</body></html>';
|
||||
?>
|
||||
|
@ -14,7 +14,7 @@
|
||||
$result = $db->result->fetch_assoc();
|
||||
return $result['Auto_increment']-1;
|
||||
}
|
||||
function total()
|
||||
function total() //nombre d'avions poèmes présents dans la base
|
||||
{
|
||||
global $db;
|
||||
$query = "SELECT COUNT(*) as nAvion FROM avionpoeme";
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
}
|
||||
|
||||
function totalenvol()
|
||||
function totalenvol() //nombre d'avions poèmes en vol
|
||||
{
|
||||
global $db;
|
||||
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE public!=2";
|
||||
@ -43,7 +43,7 @@
|
||||
|
||||
}
|
||||
|
||||
function anonymous()
|
||||
function anonymous() //nombre d'avions poèmes envoyés anonymement
|
||||
{
|
||||
global $db;
|
||||
$query = "SELECT COUNT(*) as n FROM avionpoeme WHERE expemail=''";
|
||||
@ -53,21 +53,21 @@
|
||||
}
|
||||
|
||||
|
||||
$nAvionCree = totaltotal();
|
||||
if ($nAvionCree == 0)
|
||||
$nAvionEnvoye = totaltotal();
|
||||
if ($nAvionEnvoye == 0)
|
||||
{
|
||||
echo "Aucun avion-poème envoyé pour l'instant";
|
||||
}else
|
||||
{
|
||||
|
||||
echo "Nombre total d'avions-poème : " . $nAvionCree . EOL;
|
||||
echo "Nombre total d'avions-poème : " . $nAvionEnvoye . EOLH;
|
||||
$total = total();
|
||||
$avionSupp = $nAvionCree-$total;
|
||||
echo "Nombre d'avion supprimés : " . $avionSupp . " => " . $avionSupp/$nAvionCree*100 . "%" . EOL;
|
||||
$avionSupp = $nAvionEnvoye-$total;
|
||||
echo "Nombre d'avion supprimés : " . $avionSupp . " => " . round($avionSupp/$nAvionEnvoye*100,3) . "%" . EOLH;
|
||||
$nAvionenvol = totalenvol();
|
||||
echo "Nombre d'avions-poème en vol : " . $nAvionenvol . " => " . $nAvionenvol/$nAvionCree*100 . "%" . EOL;
|
||||
echo "Nombre d'avions-poème en vol : " . $nAvionenvol . " => " . round($nAvionenvol/$nAvionEnvoye*100) . "%" . EOLH;
|
||||
$anonymous = anonymous();
|
||||
echo "Nombre d'envois anonymes : " . $anonymous . " => " . $anonymous/$nAvionCree*100 . "%" . EOL;
|
||||
echo "Nombre d'envois anonymes : " . $anonymous . " => " . round($anonymous/$nAvionEnvoye*100) . "%" . EOLH;
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,7 +91,7 @@ class db
|
||||
|
||||
$this->result = $this->connect->query( $string ) ;
|
||||
|
||||
if ( $this->connect->error ) log_error( "Échec de la commande query => " . $this->connect->error . "<br />" . __file__ . ' ligne ' . __line__ . "\n" . $string, true, false);
|
||||
if ( $this->connect->errno > 0 ) log_error( "Échec de la commande query => " . $this->connect->error . "<br />" . __file__ . ' ligne ' . __line__ . "\n" . $string, true, false);
|
||||
//print_r( $this );
|
||||
}
|
||||
|
||||
|
@ -90,22 +90,29 @@ function replaceVariables($db, $text, $dico) :array
|
||||
while( 1 )
|
||||
{
|
||||
// Recherche les variables dans le texte
|
||||
if ($x++ >10 ) break; // empêche une boucle sans fin, il n'y a pas plus de 10 variables par texte
|
||||
$posVar = strpos( $text, "$", $posVar);
|
||||
if ($posVar !== false)
|
||||
{
|
||||
// une variable a été trouvée
|
||||
if ($x++ >10 ) break; // empêche une boucle sans fin, il n'y a pas plus de 10 variables par texte
|
||||
$posEsp = strpos( $text, " ", $posVar);
|
||||
if ($posEsp === false)
|
||||
{
|
||||
$var = substr($text, $posVar+1, strlen($text)-$posVar);
|
||||
}else
|
||||
{
|
||||
if ($posEsp == $posVar+1)
|
||||
{
|
||||
$var = "";
|
||||
}else
|
||||
{
|
||||
$var = substr($text, $posVar+1, $posEsp-$posVar-1);
|
||||
}
|
||||
}
|
||||
$posVar = $posEsp+1;
|
||||
if ($var != "")
|
||||
{
|
||||
$var = trim($var, " .\n\r)");
|
||||
|
||||
$varReplace = "$" . $var;
|
||||
if ( isset ($variables[$var]) )
|
||||
{
|
||||
@ -125,6 +132,7 @@ function replaceVariables($db, $text, $dico) :array
|
||||
$varText = '<a href="' . $varText .'">' . $varText . "</a>";
|
||||
}
|
||||
$text = str_replace($varReplace, $varText, $text); //remplace la variable dans le texte
|
||||
}
|
||||
}else {
|
||||
break;
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ function log_write($log, $level=INFO)
|
||||
|
||||
}else
|
||||
{
|
||||
echo $db->error();
|
||||
mail( $webmaster, "Erreur écriture logs => " . __file__ . " ligne " . __line__ , $log_mail);
|
||||
//echo $db->error();
|
||||
mail( $webmaster, "Erreur de connecxion à la base de données => " . __file__ . " ligne " . __line__ , $log_mail);
|
||||
}
|
||||
//$db->close();
|
||||
if ( $level == ALERT )
|
||||
@ -77,18 +77,19 @@ function affich_log( $nl, $np = 1, $level=0)
|
||||
$db = new db();
|
||||
if( !empty( $db->connect ) )
|
||||
{
|
||||
$level_s = array( "aucun" , "info" , "alerte" , "erreur" );
|
||||
$query = 'SELECT * FROM ' . $table_prefix . 'logs ORDER BY id_log DESC';
|
||||
$level_s = array( "aucun", "info", "alerte", "erreur" );
|
||||
if ($level < 0 or $level >3) $level = 0;
|
||||
$query = 'SELECT * FROM ' . $table_prefix . 'logs';
|
||||
if ( $level != 0 )
|
||||
{
|
||||
$query .= " WHERE niveau='" . $db->protect($level) . "'";
|
||||
$query .= " WHERE niveau=" . $level ;
|
||||
}
|
||||
$query .= ' ORDER BY id_log DESC';
|
||||
$db->query($query);
|
||||
$total_lignes = $db->result->num_rows;
|
||||
if ($total_lignes != 0 )
|
||||
{
|
||||
|
||||
$n_pages = round( $total_lignes / $nl ) +1;
|
||||
/////////////:: Calcule le nombre de pages de logs
|
||||
$n_pages = round( $total_lignes / $nl );
|
||||
|
||||
if ( $np == 0 )
|
||||
{
|
||||
@ -97,11 +98,29 @@ function affich_log( $nl, $np = 1, $level=0)
|
||||
{
|
||||
$np = $n_pages;
|
||||
}
|
||||
echo '<table><tr>';
|
||||
if ( $np > 1 )
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////// Bouton de choix du niveau de log
|
||||
echo "\n" . '<form action="none" method="post" enctype="multipart/form-data">';
|
||||
echo "niveau de log" . ' <select id="level" size="0" onchange="window.location.href = \'logs.php?np=\' + document.getElementById(\'np\').value + \'&level=\' + document.getElementById(\'level\').value ;">';
|
||||
|
||||
for ( $n = 0; $n <= count( $level_s ) - 1; $n++ )
|
||||
{
|
||||
echo '<td><a href="logs.php?np=' . ($np - 1) . '">Page précédente</a></td><td>';
|
||||
echo '<option value="' . $n . '"';
|
||||
if ( $n == $level )
|
||||
{
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . $level_s[ $n ] . '</option>';
|
||||
}
|
||||
echo '</select><noscript><input type="submit" name="submit" Value="none" /></noscript>';
|
||||
echo "</form>\n";
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// Bouton de choix du numéro de page
|
||||
echo "\n" . '<form action="none" method="post" enctype="multipart/form-data">';
|
||||
echo 'Page n° <select id="np" name="np" size="0" onchange="window.location.href = \'logs.php?np=\' + document.getElementById(\'np\').value + \'&level=\' + document.getElementById(\'level\').value ;">';
|
||||
for ( $n = 1; $n<= $n_pages; $n++ )
|
||||
@ -113,27 +132,24 @@ function affich_log( $nl, $np = 1, $level=0)
|
||||
}
|
||||
echo '>' . $n . '</option>';
|
||||
}
|
||||
echo '</select><noscript><input type="submit" name="submit" Value="Envoyer" /></noscript>';
|
||||
echo "</form>\n";
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
echo '</select><noscript><input type="submit" name="submit" Value="none" /></noscript>';
|
||||
echo "</form>\n</td>";
|
||||
//////////////// affiche page précédente et page suivante
|
||||
if ( $np > 1 )
|
||||
{
|
||||
echo '<a href="logs.php?np=' . ($np - 1) . '">Page précédente</a>';
|
||||
}
|
||||
if ( $np < $n_pages )
|
||||
{
|
||||
echo '<td><a href="logs.php?np=' . ($np + 1) . '">Page suivante</a></td>';
|
||||
}
|
||||
echo "\n<td>" . '<form action="none" method="post" enctype="multipart/form-data">';
|
||||
echo "niveau de log" . ' <select id="level" size="0" onchange="window.location.href = \'logs.php?np=\' + document.getElementById(\'np\').value + \'&level=\' + document.getElementById(\'level\').value ;">';
|
||||
for ( $n = 0; $n <= count( $level_s ) - 1; $n++ )
|
||||
{
|
||||
echo '<option value="' . $n . '"';
|
||||
if ( $n == $level )
|
||||
{
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . $level_s[ $n ] . '</option>';
|
||||
echo ' <a href="logs.php?np=' . ($np + 1) . '">Page suivante</a>';
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
echo '</select><noscript><input type="submit" name="submit" Value="Envoyer" /></noscript>';
|
||||
echo "</form>\n</td></tr>";
|
||||
/////////////////////// affiche les logs dans un tableau
|
||||
if ($total_lignes != 0 )
|
||||
{
|
||||
$query = 'SELECT * FROM ' . $table_prefix . 'logs';
|
||||
if ( $level != 0 )
|
||||
{
|
||||
@ -146,12 +162,12 @@ function affich_log( $nl, $np = 1, $level=0)
|
||||
while ( ($donnees =$db->result->fetch_array()) )
|
||||
{
|
||||
$niveau = $donnees["niveau"];
|
||||
echo "<tr><td>" . $donnees["date"] . "</td><td>" . $donnees["auteur"] . "</td><td>" . $donnees["log"] . "</td><td>" . $level_s[ $niveau ] . "</td></tr>\n";
|
||||
echo "<tr><td>" . $donnees["date"] . "</td><td>" . $donnees["auteur"] . "</td><td>" . htmlentities($donnees["log"], ENT_QUOTES) . "</td><td>" . $level_s[ $niveau ] . "</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}else
|
||||
{
|
||||
"aucune réponse";
|
||||
print "aucune réponse";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user