From 944e7425904fcc272ed7c2e1b6b90694ceeba9ff Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Mon, 22 Mar 2021 12:20:39 +0100 Subject: [PATCH] first commit from DTux --- .htaccess | 1 + .kdev4/avion-poeme.kdev4 | 5 + avion-poeme.kdev4 | 4 + img/.htaccess | 1 + include/.htaccess | 1 + include/config.inc.php | 37 ++++ include/config.inc.php~ | 35 ++++ include/db.class.php | 117 +++++++++++++ include/db.class.php~ | 65 +++++++ include/entete_mail.php~ | 18 ++ include/envoi_courriel.inc.php | 28 ++++ include/envoi_courriel.inc.php~ | 26 +++ include/fonctions.inc.php | 42 +++++ include/fonctions.inc.php~ | 289 ++++++++++++++++++++++++++++++++ include/log.php | 156 +++++++++++++++++ include/log.php~ | 155 +++++++++++++++++ include/plane.class.php | 8 + include/plane.class.php~ | 0 sql/database.sql | 25 +++ sql/extra.sql | 48 ++++++ sql/table_avionpoeme.sql | 83 +++++++++ sql/table_logs.sql | 14 ++ sql/table_peripeties.sql | 16 ++ src/.htaccess | 1 + todo.txt | 1 + 25 files changed, 1176 insertions(+) create mode 100644 .htaccess create mode 100644 .kdev4/avion-poeme.kdev4 create mode 100644 avion-poeme.kdev4 create mode 100644 img/.htaccess create mode 100644 include/.htaccess create mode 100644 include/config.inc.php create mode 100644 include/config.inc.php~ create mode 100644 include/db.class.php create mode 100644 include/db.class.php~ create mode 100644 include/entete_mail.php~ create mode 100644 include/envoi_courriel.inc.php create mode 100644 include/envoi_courriel.inc.php~ create mode 100644 include/fonctions.inc.php create mode 100644 include/fonctions.inc.php~ create mode 100644 include/log.php create mode 100644 include/log.php~ create mode 100644 include/plane.class.php create mode 100644 include/plane.class.php~ create mode 100644 sql/database.sql create mode 100644 sql/extra.sql create mode 100644 sql/table_avionpoeme.sql create mode 100644 sql/table_logs.sql create mode 100644 sql/table_peripeties.sql create mode 100644 src/.htaccess create mode 100644 todo.txt diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..5a928f6 --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +Options -Indexes diff --git a/.kdev4/avion-poeme.kdev4 b/.kdev4/avion-poeme.kdev4 new file mode 100644 index 0000000..e325233 --- /dev/null +++ b/.kdev4/avion-poeme.kdev4 @@ -0,0 +1,5 @@ +[Buildset] +BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x16\x00a\x00v\x00i\x00o\x00n\x00-\x00p\x00o\x00e\x00m\x00e) + +[Project] +VersionControlSupport=kdevgit diff --git a/avion-poeme.kdev4 b/avion-poeme.kdev4 new file mode 100644 index 0000000..e2c963c --- /dev/null +++ b/avion-poeme.kdev4 @@ -0,0 +1,4 @@ +[Project] +CreatedFrom= +Manager=KDevCustomBuildSystem +Name=avion-poeme diff --git a/img/.htaccess b/img/.htaccess new file mode 100644 index 0000000..5a928f6 --- /dev/null +++ b/img/.htaccess @@ -0,0 +1 @@ +Options -Indexes diff --git a/include/.htaccess b/include/.htaccess new file mode 100644 index 0000000..5a928f6 --- /dev/null +++ b/include/.htaccess @@ -0,0 +1 @@ +Options -Indexes diff --git a/include/config.inc.php b/include/config.inc.php new file mode 100644 index 0000000..4728af1 --- /dev/null +++ b/include/config.inc.php @@ -0,0 +1,37 @@ + diff --git a/include/config.inc.php~ b/include/config.inc.php~ new file mode 100644 index 0000000..b428324 --- /dev/null +++ b/include/config.inc.php~ @@ -0,0 +1,35 @@ + diff --git a/include/db.class.php b/include/db.class.php new file mode 100644 index 0000000..0c95a33 --- /dev/null +++ b/include/db.class.php @@ -0,0 +1,117 @@ +open(); + } + + function open() + { + if ( !$this->connect ) + { + $this->connect = new mysqli( $this->server, $this->user, $this->passwd, $this->database ); + if ( $this->connect->connect_errno ) + { + log_error( "Échec de la connexion : => " . $this->connect->connect_error . "
" . __file__ . ' ligne ' . __line__); + return false; + } + } + $this->connect->set_charset("utf8"); + return true; + } + + function close() + { + $this->connect->close(); + $this->connect = 0; + } + + function protect( $string ) + { + return $this->connect->real_escape_string( $string ); + } + + function query( $string ) + { + + //log_write( $string ); + if ( empty( $this->connect ) ) $this->open(); + + $this->result = $this->connect->query( $string ) ; + + if ( $this->connect->error ) log_error( "Échec de la commande query => " . $this->connect->error . "
" . __file__ . ' ligne ' . __line__ . "\n" . $string, true, true); + //print_r( $this ); + } + + function print_error() + { + print_r( $this ); + //$this->error = $this->error; + return $this->connect->error; + } + + function newPlane() + { + $query = "INSERT INTO avionpoeme SET ("; + $query .= $this->message . ", "; + $query .= $this->expeMail . ", "; + $query .= $this->expeKnown . ", "; + $query .= $this->expeLang . ", "; + $query .= $this->destLang . ", "; + $query .= $this->startLat . ", "; + $query .= $this->startLon . ", "; + $query .= $this->startName . ", "; + $query .= $this->startTime . ", "; + $query .= $this->StartTZ . ", "; + $query .= $this->destMail . ", "; + $query .= $this->destLat . ", "; + $query .= $this->destLon . ", "; + $query .= $this->destName . ", "; + $query .= $this->status . ", "; + $query .= $this->color . ", "; + $query .= $this->actual_lat . ", "; + $query .= $this->actual_lon . ", "; + $query .= $this->bearing . ", "; + $query .= $this->deliveryTime . ", "; + $query .= $this->deliveryTZ . ", "; + $query .= $this->deliveryTimeServer . ", "; + $query .= ")"; + } +} + +?> diff --git a/include/db.class.php~ b/include/db.class.php~ new file mode 100644 index 0000000..cc88e82 --- /dev/null +++ b/include/db.class.php~ @@ -0,0 +1,65 @@ +open(); + } + + function open() + { + if ( !$this->connect ) + { + $this->connect = new mysqli( $this->server, $this->user, $this->passwd, $this->database ); + if ( $this->connect->connect_errno ) + { + log_error( "Échec de la connexion : => " . $this->connect->connect_error . "
" . __file__ . ' ligne ' . __line__); + return false; + } + } + $this->connect->set_charset("utf8"); + return true; + } + + function close() + { + $this->connect->close(); + $this->connect = 0; + } + + function protect( $string ) + { + return $this->connect->real_escape_string( $string ); + } + + function query( $string ) + { + + //log_write( $string ); + if ( empty( $this->connect ) ) $this->open(); + + $this->result = $this->connect->query( $string ) ; + + if ( $this->connect->error ) log_error( "Échec de la commande query => " . $this->connect->error . "
" . __file__ . ' ligne ' . __line__ . "\n" . $string, true, true); + //print_r( $this ); + } + + function print_error() + { + print_r( $this ); + //$this->error = $this->error; + return $this->connect->error; + } +} + +?> diff --git a/include/entete_mail.php~ b/include/entete_mail.php~ new file mode 100644 index 0000000..58e0dc6 --- /dev/null +++ b/include/entete_mail.php~ @@ -0,0 +1,18 @@ + diff --git a/include/envoi_courriel.inc.php b/include/envoi_courriel.inc.php new file mode 100644 index 0000000..ea8e00f --- /dev/null +++ b/include/envoi_courriel.inc.php @@ -0,0 +1,28 @@ +' . $var . "
"; + if ( isset($_GET[$var]) ) + { + //echo '$_get -> $var =>' . $var . "
"; + return $_GET[$var]; + } + elseif ( isset($_POST[$var]) ) + { + //echo '$_POST -> $var =>' . $var . "
"; + return $_POST[$var]; + }else + { + if ( isset($_SESSION[$var]) AND $session==true ) + { + return $_SESSION[$var]; + }else + { + //echo 'default -> $var =>' . $var . "
"; + return $default; + } + } + +} + + +// MET LA PREMIÈRE LETTRE D'UN MOT EN MAJUSCULE ( utf8 compliant ) + +function mb_ucfirst($str) { + $char = mb_substr($str,0,1,"UTF8"); + $str = mb_substr( $str, 1, NULL, "UTF8"); + $char = mb_strtoupper( $char, "UTF8"); + return $char . $str; + } + diff --git a/include/fonctions.inc.php~ b/include/fonctions.inc.php~ new file mode 100644 index 0000000..a02195b --- /dev/null +++ b/include/fonctions.inc.php~ @@ -0,0 +1,289 @@ +"; + foreach($dir as $file) + { + if($file != '.' && $file != '..' && !is_dir( $dirname . $file ) ) + { + echo '
  • ' . $file . '
  • '; + } + + } + echo "

    "; +} + + +// vérifie que la césure de la chaine de caractère ne se fait pas au mileiu d'une balise html +// $n l nombre de caractères à garder + +function verif_partiel( $string, $n) +{ + $string = trim( stripslashes( $string ) ); + $string = mb_substr( $string, 0, $n ); + $pos = strrpos( $string, " " ); + $string = substr( $string, 0, $pos ); + $x = $z = 0; + $pos1 = $pos_d = 0; + $balises = array(); + + do + { + $z = $z + 1; + if ( $z >=50 ) + { + log_error( "verif_partiel : erreur de boucle sans fin dans la ligne : $string
    " . print_r( $balises ) . __file__ . " ligne " . __line__ ); + } + + $pos1 = strpos( $string, "<", $pos_d ); + if ( $pos1 !== FALSE ) + { + $pos2 = strpos( $string, ">", $pos1 ); + $pos3 = strpos( $string, "<", $pos1+1 ); + + if ( $pos1 AND $pos2 === FALSE ) + { + $string = substr( $string, 0, $pos1); + }else + { + if ( $pos3 !== FALSE AND $pos3 < $pos2 ) + { + $pos1 = $pos3; + } + $pos_d = $pos2 + 1; + + $balise_e = $titre = "panier"; + $css = "main.css";substr( $string, $pos1, $pos2 - $pos1 + 1 ); + $pos = strpos( $balise_e, " " ); + + if ( $pos !== FALSE ) + { + $pos2 = $pos + $pos1; + } + $pos_slash = strpos( $balise_e, "/" ); + if ( $pos_slash !== FALSE AND $pos_slash == 1 ) + { + //echo "BALISE FERMANTE
    "; + $balise = trim( substr ( $balise_e, 2, ($pos2 - $pos1 - 2) ) ); + if ( $balises[ $x-1 ] != $balise ) + { + log_error( "verif_partiel : erreur de balise '$balise_e' dans la ligne : $string
    " . print_r( $balises ) . __file__ . " ligne " . __line__ ); + }else + { + $x = $x -1; + } + }elseif ( $pos_slash === FALSE ) + { + //echo "BALISE OUVRANTE
    "; + $balises[ $x++ ] = trim( substr ( $balise_e, 1, ($pos2 - $pos1 -1) ) ); + } + } + } + }while ( $pos1 !== FALSE ); + $string .= " ..."; + if ( $x >0 ) + { + for ( $i = $x-1; $i >= 0; $i--) + { + $string .= ""; + } + } + //echo "string finale => $string
    "; + return $string; +} + +// $var clef à rechercher dans $_POST, $_GET, et $_SESSION (si $session=true) +// $default valeur retournée si aucune valeur n'est trouvée +// $session: si true, rechercher aussi dans $_SESSION + +// + +function getpost( $var, $default="", $session=false ) +{ + //echo '$var =>' . $var . "
    "; + if ( isset($_GET[$var]) ) + { + //echo '$_get -> $var =>' . $var . "
    "; + return $_GET[$var]; + } + elseif ( isset($_POST[$var]) ) + { + //echo '$_POST -> $var =>' . $var . "
    "; + return $_POST[$var]; + }else + { + if ( isset($_SESSION[$var]) AND $session==true ) + { + return $_SESSION[$var]; + }else + { + //echo 'default -> $var =>' . $var . "
    "; + return $default; + } + } + +} + +// affiche les composants du menus +// pas de retour + +function menu($page, $text) +{ + echo '' . $text . ' '; +} + +function bouton_rouge( $text, $lien ) +{ + print '
    +
    + +
    +
    + +
    ' . $text .'
    +
    +
    '; +} + +// MET LA PREMIÈRE LETTRE D'UN MOT EN MAJUSCULE ( utf8 compliant ) + +function mb_ucfirst($str) { + $char = mb_substr($str,0,1,"UTF8"); + $str = mb_substr( $str, 1, NULL, "UTF8"); + $char = mb_strtoupper( $char, "UTF8"); + return $char . $str; + } + +// affiche le panier en cours +// si $modif =,= true affiche une case de saisie avec la quantité + +function affiche_panier( $modif=false ) +{ + global $base_url, $path, $page; + $total = 0; + $hc = 0; + //echo "============";print_r($_SESSION);echo "#################"; + $nombre_ref = $_SESSION['panier_n_ref']; + $nombre_art = 0; + echo ''; + $art = $_SESSION["panier"]; + for ($i = 0 ; $i < $nombre_ref ; $i++ ) + { + $nombre_art += $art["qte"][$i]; + $total += $total_col = $art["qte"][$i] * ( $art["prix"][$i] + ($art["huile_chaude"][$i]?5:0) ); + echo ''; + echo ''; + $prix_article = $art["prix"][$i] + $hc; + echo ''; + } + echo '"; + echo '
    quantitéProduitDuréeTypeHuile chaude
    Supplément 5€
    prixtotalvalable jusqu\'au
    ' . ($i + 1) . ''; + if ( $modif ) + { + echo ''; + }else + { + echo $art["qte"][$i]; + } + echo '' . $art["libelle"][$i] . '' . $art["duree"][$i] . '' . $art["type"][$i] . ''; + if ($modif) + { + if ( $art["hc"][$i] ) + { + echo ''; + }else + { + echo 'non disponible'; + } + }else + { + if ( $art["huile_chaude"][$i] ) + { + echo 'oui'; + $hc = 5; + }else + { + echo 'non'; + $hc = 0; + } + } + echo '' . $prix_article . ' €' . $total_col . ' €' . $art["date_validite"][$i]->format("j/m/Y") . '
    total du panier' . "$total €
    '; + + echo "nombre de références : $nombre_ref
    "; + echo "nombre d'articles : $nombre_art"; + +} + +function ajout_panier( $id ) +{ + //echo '
    '; + return 'Ajouter au panier'; +} + +function affiche_commande( $id ) +{ + $total = 0; + $db = new db(); + $db->open(); + $query = "SELECT * FROM commandes_articles AS ca LEFT JOIN articles AS art ON ca.id_art=art.id LEFT join libelle_art AS la ON la.id=art.id_libelle WHERE ca.id_commande='" . $db->protect($id) . "'"; + $db->query( $query ); + echo 'Article'; + echo 'Quantité'; + echo "huile_chaude"; + echo 'Prix'; + echo 'Type'; + echo 'Date de validité'; + echo 'Total article'; + echo ''; + while ( $donnees = mysqli_fetch_array($db->result) ) + { + + echo '' . $donnees["libelle"] . ''; + echo '' . $donnees["quantite"] . ''; + if ( $donnees["huile_chaude"] ) + { + echo "huile_chaude"; + } + echo '' . $donnees["prix"] . ''; + echo '' . $donnees["type"] . ''; + echo '' . $donnees["date_validite"] . ''; + $total_article = $donnees["prix"] * $donnees["quantite"]; + $total += $total_article; + echo '' . $total_article . ''; + + + } + echo 'Total de la commande' . $total . ''; + return $total; + $db->close(); +} + +function delete_cart() +{ + $_SESSION['panier'] = array(); + $_SESSION['panier_n_ref'] = 0; + if ( ! session_regenerate_id( true) ) + { + log_error("impossible de régénérer l'ID de session"); + } + print ''; +} +?> diff --git a/include/log.php b/include/log.php new file mode 100644 index 0000000..627f19a --- /dev/null +++ b/include/log.php @@ -0,0 +1,156 @@ + INFO, ALERT, ERROR +function log_write($log, $level=INFO) +{ + require_once( "envoi_courriel.inc.php" ); + global $table_prefix; + $user = ( !empty( $_SERVER["PHP_AUTH_USER"])?$_SERVER["PHP_AUTH_USER"]:'' ); + $log_mail = str_replace ( "
    ", "\n", $log ) . "\n"; + $log_mail .= ( !empty( $_SERVER["REQUEST_METHOD"])?'$_SERVER["REQUEST_METHOD"]' . $_SERVER["REQUEST_METHOD"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["QUERY_STRING"])?'$_SERVER["QUERY_STRING"]' . $_SERVER["QUERY_STRING"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["HTTP_ACCEPT_LANGUAGE"])?'$_SERVER["HTTP_ACCEPT_LANGUAGE"]' . $_SERVER["HTTP_ACCEPT_LANGUAGE"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["HTTP_USER_AGENT"])?'$_SERVER["HTTP_USER_AGENT"]' . $_SERVER["HTTP_USER_AGENT"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REMOTE_ADDR"])?'$_SERVER["REMOTE_ADDR"]' . $_SERVER["REMOTE_ADDR"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REMOTE_HOST"])?'$_SERVER["REMOTE_HOST"]' . $_SERVER["REMOTE_HOST"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REMOTE_USER"])?'$_SERVER["REMOTE_USER"]' . $_SERVER["REMOTE_USER"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REQUEST_URI"])?'$_SERVER["REQUEST_URI"]' . $_SERVER["REQUEST_URI"] . "\n":'' ); + $log_mail .= "Utilisateur: $user \n"; + $log_mail .= ( !empty( $_SERVER["ORIG_PATH_INFO"])?'$_SERVER["ORIG_PATH_INFO"]' . $_SERVER["ORIG_PATH_INFO"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["PATH_INFO"])?'$_SERVER["PATH_INFO"]' . $_SERVER["PATH_INFO"] . "\n":'' ); + $db1 = new db(); + $db1->open(); + if( !empty( $db1->connect ) ) + { + $query = 'INSERT INTO ' . $db1->protect($table_prefix) . 'logs SET date=NOW(), auteur="' . $db1->protect( $user ) . '", log="' . $db1->protect($log) . '", niveau="' . $db1->protect($level) . '"'; + $db1->query( $query ); + if ( !$db1->result ) + { + $text = $db1->error() . "\n\n" . $log_mail; + envoiMail( $webmaster, "Erreur écriture logs => " . __file__ . " ligne " . __line__, $text ); + } + $db1->close(); + }else + { + echo $db1->error(); + envoiMail( $webmaster, "Erreur écriture logs => " . __file__ . " ligne " . __line__ , $log_mail); + } + if ( $level == ALERT ) + { + envoiMail( $webmaster, "Alerte Site Web", $log_mail ); + }elseif ( $level == ERROR ) + { + envoiMail( $webmaster, "Erreur Site Web", $log_mail ); + } +} + +// $w_db = true -> écrire les logs dans la base (défaut) +// $die = true -> execute die() -> termine le programme +function log_error($log, $w_db=true, $die=false) +{ + global $webmaster, $headers, $accueil, $db; + if ( $w_db ) log_write($log, ERROR); + echo "$log
    \n"; + $log_err = 'erreur dans la requête
    un rapport détaillé a été envoyé au webmaster'; + if ( $die ) + { + echo "\n"; + die( $log_err ); + }else + { + $_SESSION['error'] = $log_err; + //header( 'Location: ' . $accueil ); + } +} + +function affich_log( $nl, $np = 1, $level=INFO ) +{ + global $table_prefix, $base_url, $path, $page; + if( !empty( $db->open() ) ) + { + $level_s = array( "aucun" , "info" , "alerte" , "erreur" ); + $query = 'SELECT * FROM ' . $table_prefix . 'logs'; + if ( $level != 0 ) + { + $query .= " WHERE niveau='" . $db->protect($level) . "'"; + } + $db->query($query) OR log_error($db->error() . "
    " . __file__ . " ligne " . __line__ ); + $total_lignes = $db->result->num_rows(); + if ($total_lignes != 0 ) + { + + $n_pages = round( $total_lignes / $nl ) +1; + + if ( $np == 0 ) + { + $np = 1; + }elseif ( $np > $n_pages ) + { + $np = $n_pages; + } + echo ''; + if ( $np > 1 ) + { + echo '"; + if ( $np < $n_pages ) + { + echo ''; + } + echo "\n"; + $query = 'SELECT * FROM ' . $table_prefix . 'logs'; + if ( $level != 0 ) + { + $query .= " WHERE niveau='" . $level . "'"; + } + + $query .= ' ORDER BY date DESC LIMIT ' . ( ( ( $np - 1 ) * $nl ) ) . ',' . $nl; + $db->query( $query ) OR log_error( $db->error( ) . "
    " . __file__ . " ligne " . __line__ ); + echo "
    Page précédente'; + } + echo "\n" . ''; + echo 'Page n° '; + echo "\nPage suivante" . '
    '; + echo "niveau de log" . ' '; + echo "
    \n
    \n"; + while ( $db->connect->mysqli_fetch_array( $db->result ) ) + { + $niveau = $donnees["niveau"]; + echo "\n"; + } + echo "
    dateauteurlogniveau
    " . $donnees["date"] . "" . $donnees["auteur"] . "" . $donnees["log"] . "" . $level_s[ $niveau ] . "
    \n"; + }else + { + "aucune réponse"; + } + } +} +?> diff --git a/include/log.php~ b/include/log.php~ new file mode 100644 index 0000000..17651f9 --- /dev/null +++ b/include/log.php~ @@ -0,0 +1,155 @@ + INFO, ALERT, ERROR +function log_write($log, $level=INFO) +{ + global $table_prefix, $webmaster, $headers; + $user = ( !empty( $_SERVER["PHP_AUTH_USER"])?$_SERVER["PHP_AUTH_USER"]:'' ); + $log_mail = str_replace ( "
    ", "\n", $log ) . "\n"; + $log_mail .= ( !empty( $_SERVER["REQUEST_METHOD"])?'$_SERVER["REQUEST_METHOD"]' . $_SERVER["REQUEST_METHOD"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["QUERY_STRING"])?'$_SERVER["QUERY_STRING"]' . $_SERVER["QUERY_STRING"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["HTTP_ACCEPT_LANGUAGE"])?'$_SERVER["HTTP_ACCEPT_LANGUAGE"]' . $_SERVER["HTTP_ACCEPT_LANGUAGE"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["HTTP_USER_AGENT"])?'$_SERVER["HTTP_USER_AGENT"]' . $_SERVER["HTTP_USER_AGENT"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REMOTE_ADDR"])?'$_SERVER["REMOTE_ADDR"]' . $_SERVER["REMOTE_ADDR"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REMOTE_HOST"])?'$_SERVER["REMOTE_HOST"]' . $_SERVER["REMOTE_HOST"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REMOTE_USER"])?'$_SERVER["REMOTE_USER"]' . $_SERVER["REMOTE_USER"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["REQUEST_URI"])?'$_SERVER["REQUEST_URI"]' . $_SERVER["REQUEST_URI"] . "\n":'' ); + $log_mail .= "Utilisateur: $user \n"; + $log_mail .= ( !empty( $_SERVER["ORIG_PATH_INFO"])?'$_SERVER["ORIG_PATH_INFO"]' . $_SERVER["ORIG_PATH_INFO"] . "\n":'' ); + $log_mail .= ( !empty( $_SERVER["PATH_INFO"])?'$_SERVER["PATH_INFO"]' . $_SERVER["PATH_INFO"] . "\n":'' ); + $db1 = new db(); + $db1->open(); + if( !empty( $db1->connect ) ) + { + $query = 'INSERT INTO ' . $db1->protect($table_prefix) . 'logs SET date=NOW(), auteur="' . $db1->protect( $user ) . '", log="' . $db1->protect($log) . '", niveau="' . $db1->protect($level) . '"'; + $db1->query( $query ); + if ( !$db1->result ) + { + $text = $db1->error() . "\n\n" . $log_mail; + mail( $webmaster, "Erreur écriture logs => " . __file__ . " ligne " . __line__, $text, $headers ); + } + $db1->close(); + }else + { + echo $db1->error(); + mail( $webmaster, "Erreur écriture logs => " . __file__ . " ligne " . __line__ , $log_mail, $headers ); + } + if ( $level == ALERT ) + { + mail( $webmaster, "Alerte Site Web", $log_mail, $headers ); + }elseif ( $level == ERROR ) + { + mail( $webmaster, "Erreur Site Web", $log_mail, $headers ); + } +} + +// $db = true -> écrire les logs dans la base (défaut) +// $die = true -> execute die() +function log_error($log, $w_db=true, $die=false) +{ + global $webmaster, $headers, $accueil, $db; + if ( $w_db ) log_write($log, ERROR); + echo "$log
    \n"; + $log_err = 'erreur dans la requête
    un rapport détaillé a été envoyé au webmaster'; + if ( $die ) + { + echo "\n"; + die( $log_err ); + }else + { + $_SESSION['error'] = $log_err; + //header( 'Location: ' . $accueil ); + } +} + +function affich_log( $nl, $np = 1, $level=INFO ) +{ + global $table_prefix, $webmaster, $headers, $base_url , $path , $page; + if( !empty( $db->open() ) ) + { + $level_s = array( "aucune" , "info" , "alerte" , "erreur" ); + $query = 'SELECT * FROM ' . $table_prefix . 'logs'; + if ( $level != 0 ) + { + $query .= " WHERE niveau='" . $db->protect($level) . "'"; + } + $db->query($query) OR log_error($db->error() . "
    " . __file__ . " ligne " . __line__ ); + $total_lignes = $db->result->num_rows(); + if ($total_lignes != 0 ) + { + + $n_pages = round( $total_lignes / $nl ) +1; + + if ( $np == 0 ) + { + $np = 1; + }elseif ( $np > $n_pages ) + { + $np = $n_pages; + } + echo ''; + if ( $np > 1 ) + { + echo '"; + if ( $np < $n_pages ) + { + echo ''; + } + echo "\n"; + $query = 'SELECT * FROM ' . $table_prefix . 'logs'; + if ( $level != 0 ) + { + $query .= " WHERE niveau='" . $level . "'"; + } + + $query .= ' ORDER BY date DESC LIMIT ' . ( ( ( $np - 1 ) * $nl ) ) . ',' . $nl; + $db->query( $query ) OR log_error( $db->error( ) . "
    " . __file__ . " ligne " . __line__ ); + echo "
    Page précédente'; + } + echo "\n" . '
    '; + echo 'Page n° '; + echo "
    \n
    Page suivante" . '
    '; + echo "niveau de log" . ' '; + echo "
    \n
    \n"; + while ( $db->connect->mysqli_fetch_array( $db->result ) ) + { + $niveau = $donnees["niveau"]; + echo "\n"; + } + echo "
    dateauteurlogniveau
    " . $donnees["date"] . "" . $donnees["auteur"] . "" . $donnees["log"] . "" . $level_s[ $niveau ] . "
    \n"; + }else + { + "aucune réponse"; + } + } +} +?> diff --git a/include/plane.class.php b/include/plane.class.php new file mode 100644 index 0000000..8cc4945 --- /dev/null +++ b/include/plane.class.php @@ -0,0 +1,8 @@ + diff --git a/include/plane.class.php~ b/include/plane.class.php~ new file mode 100644 index 0000000..e69de29 diff --git a/sql/database.sql b/sql/database.sql new file mode 100644 index 0000000..f756842 --- /dev/null +++ b/sql/database.sql @@ -0,0 +1,25 @@ +-- phpMyAdmin SQL Dump +-- version 4.9.5 +-- https://www.phpmyadmin.net/ +-- +-- Hôte : db120904.sql-pro.online.net +-- Généré le : sam. 20 mars 2021 à 16:46 +-- Version du serveur : 5.7.19-0ubuntu0.16.04.1 +-- Version de PHP : 7.0.32-0ubuntu0.16.04.1 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Base de données : `db351634_avionpoeme` +-- +CREATE DATABASE IF NOT EXISTS `db351634_avionpoeme` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +USE `db351634_avionpoeme`; diff --git a/sql/extra.sql b/sql/extra.sql new file mode 100644 index 0000000..33da4e3 --- /dev/null +++ b/sql/extra.sql @@ -0,0 +1,48 @@ + +-- +-- Index pour les tables déchargées +-- + +-- +-- Index pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + ADD PRIMARY KEY (`uid`), + ADD KEY `expe_mail_index` (`expeMail`(40)), + ADD KEY `dest_mail_index` (`destMail`(40)), + ADD KEY `delivery_date_index` (`deliveryTime`); + +-- +-- Index pour la table `logs` +-- +ALTER TABLE `logs` + ADD PRIMARY KEY (`id_log`), + ADD KEY `date_index` (`date`); + +-- +-- Index pour la table `peripeties` +-- +ALTER TABLE `peripeties` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT pour les tables déchargées +-- + +-- +-- AUTO_INCREMENT pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + MODIFY `uid` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT pour la table `logs` +-- +ALTER TABLE `logs` + MODIFY `id_log` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT pour la table `peripeties` +-- +ALTER TABLE `peripeties` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; diff --git a/sql/table_avionpoeme.sql b/sql/table_avionpoeme.sql new file mode 100644 index 0000000..798f558 --- /dev/null +++ b/sql/table_avionpoeme.sql @@ -0,0 +1,83 @@ +-- phpMyAdmin SQL Dump +-- version 4.9.5 +-- https://www.phpmyadmin.net/ +-- +-- Hôte : db120904.sql-pro.online.net +-- Généré le : sam. 20 mars 2021 à 17:16 +-- Version du serveur : 5.7.19-0ubuntu0.16.04.1 +-- Version de PHP : 7.0.32-0ubuntu0.16.04.1 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Base de données : `db351634_avionpoeme` +-- + +-- -------------------------------------------------------- + +-- +-- Structure de la table `avionpoeme` +-- + +CREATE TABLE `avionpoeme` ( + `uid` int(10) UNSIGNED NOT NULL, + `message` text CHARACTER SET utf8mb4 NOT NULL, + `expeMail` text NOT NULL, + `expeKnown` tinyint(1) NOT NULL DEFAULT '0' COMMENT ' true/false en fonction de si l''utilisateur choisi de devoiler son addresse mail pour la premiere', + `expeLang` varchar(3) NOT NULL DEFAULT 'fr' COMMENT ' langue de l''envoyeur format 2 lettres (''en'',''fr'',''ar'')', + `destLang` varchar(3) NOT NULL COMMENT 'langue du destinataire format 2 lettres (''en'',''fr'',''ar'')', + `startLat` float NOT NULL, + `startLon` float NOT NULL, + `startName` text NOT NULL, + `startTime` timestamp NOT NULL COMMENT 'unix time en TZ du depart', + `StartTZ` text CHARACTER SET utf8mb4 NOT NULL, + `destMail` text NOT NULL, + `destLat` float NOT NULL, + `destLon` float NOT NULL, + `destName` text NOT NULL, + `status` tinyint(1) NOT NULL COMMENT '0 = privé, 1=public, 2=supprimé', + `color` varchar(7) NOT NULL COMMENT ' le code hexa de la couleur de l''avion aleatoire parmis la liste.', + `actual_lat` int(11) NOT NULL, + `actual_lon` int(11) NOT NULL, + `bearing` smallint(6) NOT NULL, + `deliveryTime` timestamp NOT NULL, + `deliveryTZ` text NOT NULL, + `deliveryTimeServer` timestamp NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Index pour les tables déchargées +-- + +-- +-- Index pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + ADD PRIMARY KEY (`uid`), + ADD KEY `expe_mail_index` (`expeMail`(40)), + ADD KEY `dest_mail_index` (`destMail`(40)), + ADD KEY `delivery_date_index` (`deliveryTime`); + +-- +-- AUTO_INCREMENT pour les tables déchargées +-- + +-- +-- AUTO_INCREMENT pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + MODIFY `uid` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/sql/table_logs.sql b/sql/table_logs.sql new file mode 100644 index 0000000..120867b --- /dev/null +++ b/sql/table_logs.sql @@ -0,0 +1,14 @@ + +-- -------------------------------------------------------- + +-- +-- Structure de la table `logs` +-- + +CREATE TABLE `logs` ( + `id_log` int(11) NOT NULL, + `date` datetime NOT NULL, + `auteur` varchar(10) NOT NULL, + `log` text NOT NULL, + `niveau` tinyint(4) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/sql/table_peripeties.sql b/sql/table_peripeties.sql new file mode 100644 index 0000000..0557cd5 --- /dev/null +++ b/sql/table_peripeties.sql @@ -0,0 +1,16 @@ + +-- -------------------------------------------------------- + +-- +-- Structure de la table `peripeties` +-- + +CREATE TABLE `peripeties` ( + `id` int(11) NOT NULL, + `probabilite` tinyint(3) UNSIGNED NOT NULL COMMENT 'en pourcentage', + `effet` int(11) NOT NULL COMMENT '-x => diminue la vitesse de l''avion de x, +x augmente la vitesse de l''avion de x, 0 => avion détruit', + `mail_expe` tinyint(1) NOT NULL DEFAULT '0', + `mail_dest` tinyint(1) NOT NULL DEFAULT '0', + `quand` date DEFAULT NULL, + `quand_fonction` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/src/.htaccess b/src/.htaccess new file mode 100644 index 0000000..5a928f6 --- /dev/null +++ b/src/.htaccess @@ -0,0 +1 @@ +Options -Indexes diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/todo.txt @@ -0,0 +1 @@ +