DTux
/
dtux__avion-poeme
Archived
1
0
Fork 0

first commit from DTux

This commit is contained in:
Daniel Tartavel 2021-03-22 12:20:39 +01:00
parent 30fac27d45
commit 944e742590
25 changed files with 1176 additions and 0 deletions

1
.htaccess Normal file
View File

@ -0,0 +1 @@
Options -Indexes

5
.kdev4/avion-poeme.kdev4 Normal file
View File

@ -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

4
avion-poeme.kdev4 Normal file
View File

@ -0,0 +1,4 @@
[Project]
CreatedFrom=
Manager=KDevCustomBuildSystem
Name=avion-poeme

1
img/.htaccess Normal file
View File

@ -0,0 +1 @@
Options -Indexes

1
include/.htaccess Normal file
View File

@ -0,0 +1 @@
Options -Indexes

37
include/config.inc.php Normal file
View File

@ -0,0 +1,37 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('serialize_precision', 8);
error_reporting(E_ALL);
date_default_timezone_set("Europe/Paris");
set_include_path(get_include_path() . ':../include');
define( 'EOL', "\n" );
define( 'LF', "\r\n" );
define( 'TAB', "\t" );
//constantes des niveaux de log
define( "INFO", 1 );
define( "ALERT", 2 );
define( "ERROR", 3 );
define( "DATE_MYSQL", "Y-m-d H:i:s" );
//variables diverses
$admin = "Daniel";
$site = "Avion Poème";
$dossier = "/www";
$basedir = dirname( $_SERVER['DOCUMENT_ROOT'] ) . $dossier;
$base_url = "https://avion-poe.me";
$base_path = "/flex/storage/avion-poe.me/site/www/";
//$url_admin = $base_url . "/admin";
$accueil = $base_url . "/index.html";
if ( !isset( $_SESSION['base_url']) )
{
$_SESSION['base_url'] = $base_url;
}
?>

35
include/config.inc.php~ Normal file
View File

@ -0,0 +1,35 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
date_default_timezone_set("Europe/Paris");
set_include_path(get_include_path() . ':../include');
define( 'EOL', "\n" );
define( 'LF', "\r\n" );
define( 'TAB', "\t" );
//constantes des niveaux de log
define( "INFO", 1 );
define( "ALERT", 2 );
define( "ERROR", 3 );
define( "DATE_MYSQL", "Y-m-d H:i:s" );
//variables diverses
$admin = "Daniel";
$site = "Avion Poème";
$dossier = "/www";
$basedir = dirname( $_SERVER['DOCUMENT_ROOT'] ) . $dossier;
$base_url = "https://avion-poe.me";
$base_path = "/flex/storage/avion-poe.me/site/www/";
//$url_admin = $base_url . "/admin";
$accueil = $base_url . "/index.html";
if ( !isset( $_SESSION['base_url']) )
{
$_SESSION['base_url'] = $base_url;
}
?>

117
include/db.class.php Normal file
View File

@ -0,0 +1,117 @@
<?php
include "log.php";
$table_prefix = "";
class db
{
private $server = "db351634-avionpoeme.sql-pro.online.net";
private $port = 3306;
private $user = "db120904";
private $passwd = "AvionPoème*DB";
private $database = "db351634_avionpoeme";
public $connect;
public $result;
public $uid;
public $message;
public $expeMail;
public $expeKnown;
public $expeLang;
public $destLang;
public $startLat;
public $startLon;
public $startName;
public $startTime;
public $StartTZ;
public $destMail;
public $destLat;
public $destLon;
public $destName;
public $status;
public $color;
public $actual_lat;
public $actual_lon;
public $bearing;
public $deliveryTime;
public $deliveryTZ;
public $deliveryTimeServer;
function __construct()
{
$this->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 . "<br />" . __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 . "<br />" . __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 .= ")";
}
}
?>

65
include/db.class.php~ Normal file
View File

@ -0,0 +1,65 @@
<?php
include "log.php";
$table_prefix = "";
class db
{
private $server = "db351634-avionpoeme.sql-pro.online.net";
private $port = 3306;
private $user = "db120904";
private $passwd = "AvionPoème*DB";
private $database = "db351634_avionpoeme";
public $connect;
public $result;
function __construct()
{
$this->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 . "<br />" . __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 . "<br />" . __file__ . ' ligne ' . __line__ . "\n" . $string, true, true);
//print_r( $this );
}
function print_error()
{
print_r( $this );
//$this->error = $this->error;
return $this->connect->error;
}
}
?>

18
include/entete_mail.php~ Normal file
View File

@ -0,0 +1,18 @@
<?php
if ( !isset($site) )
{
require_once( "config.inc.php" );
header( 'Location: ' . $accueil );;
}
$webmaster="contact@avion-poe.me";
$headers = "From: contact@avion-poe.me\r\n";
//$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
$headers .= "DATE: " . date( 'r' ) . "\r\n\r\n";
$html_headers = "From: contact@avion-poe.me\r\n";
//$headers .= "MIME-Version: 1.0\r\n";
$html_headers .= "Content-type: text/html; charset=UTF-8\r\n";
$html_headers .= "DATE: " . date( 'r' ) . "\r\n\r\n";
?>

View File

@ -0,0 +1,28 @@
<?php
require_once 'log.php';
function envoiMail($destinataire, $sujet, $text, $html=false)
{
$headers = "From: contact@avion-poe.me" . LF;
if ($html)
{
$headers .= "Content-type: text/html; charset=UTF-8" . LF;
}else
$headers .= "Content-type: text/plain; charset=UTF-8" . LF;
}
$headers .= "DATE: " . date( 'r' ) . LF . LF;
log_write(__FILE__ . __LINE__ . " Envoi d'un courriel à " . $courriel . "sujet:" . $sujet, INFO);
if( !mail($destinataire, $sujet, $text, $headers) ) //Sending mail
{
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$courriel . EOL . $sujet . EOL, ERROR);
return 0;
}else
{
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel avec les pièces jointes est parti:" .$courriel . EOL, INFO);
return 1;
}
}

View File

@ -0,0 +1,26 @@
<?php
require_once 'log.php';
function envoiMail($destinataire, $sujet, $text)
{
$headers = "From: contact@avion-poe.me" . LF;
$headers .= "Content-type: text/plain; charset=UTF-8" . LF;
$headers .= "DATE: " . date( 'r' ) . LF . LF;
$html_headers = "From: contact@avion-poe.me" . LF;
$html_headers .= "Content-type: text/html; charset=UTF-8" . LF;
$html_headers .= "DATE: " . date( 'r' ) . LF . LF;
log_write(__FILE__ . __LINE__ . " Envoi d'un courriel à " . $courriel . "sujet:" . $sujet, INFO);
if( !mail($destinataire, $sujet, $text, $headers) ) //Sending mail
{
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$courriel . EOL . $sujet . EOL, ERROR);
return 0;
}else
{
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel avec les pièces jointes est parti:" .$courriel . EOL, INFO);
return 1;
}
}

42
include/fonctions.inc.php Normal file
View File

@ -0,0 +1,42 @@
<?php
// $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 . "<br />";
if ( isset($_GET[$var]) )
{
//echo '$_get -> $var =>' . $var . "<br />";
return $_GET[$var];
}
elseif ( isset($_POST[$var]) )
{
//echo '$_POST -> $var =>' . $var . "<br />";
return $_POST[$var];
}else
{
if ( isset($_SESSION[$var]) AND $session==true )
{
return $_SESSION[$var];
}else
{
//echo 'default -> $var =>' . $var . "<br />";
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;
}

289
include/fonctions.inc.php~ Normal file
View File

@ -0,0 +1,289 @@
<?php
// affiche le contenu dans dossier à télécharger
function affich_dir($dirname)
{
$dir = scandir($dirname);
echo "<ul>";
foreach($dir as $file)
{
if($file != '.' && $file != '..' && !is_dir( $dirname . $file ) )
{
echo '<li><a href="' . $dirname . $file . '">' . $file . '</a></li>';
}
}
echo "</ul><br /><br />";
}
// 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<br />" . 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<br />";
$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<br />" . print_r( $balises ) . __file__ . " ligne " . __line__ );
}else
{
$x = $x -1;
}
}elseif ( $pos_slash === FALSE )
{
//echo "BALISE OUVRANTE<br />";
$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 .= "</" . $balises[ $i ] . ">";
}
}
//echo "string finale => $string<br />";
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 . "<br />";
if ( isset($_GET[$var]) )
{
//echo '$_get -> $var =>' . $var . "<br />";
return $_GET[$var];
}
elseif ( isset($_POST[$var]) )
{
//echo '$_POST -> $var =>' . $var . "<br />";
return $_POST[$var];
}else
{
if ( isset($_SESSION[$var]) AND $session==true )
{
return $_SESSION[$var];
}else
{
//echo 'default -> $var =>' . $var . "<br />";
return $default;
}
}
}
// affiche les composants du menus
// pas de retour
function menu($page, $text)
{
echo '<a href="' . $page . '" class="menu"';
if ( $_SERVER['SCRIPT_NAME'] == $page ) echo ' style="color : red"';
echo '>' . $text . ' </a>';
}
function bouton_rouge( $text, $lien )
{
print '<div style="position:relative; height:400px">
<div style="position:absolute;z-index:1">
<img src="/images/bouton_rouge.png">
</div>
<div style="position:absolute;top:10px; z-index:2;">
<a href="' . $lien . '">
<center><b>' . $text .'</b></center></a>
</div>
</div>';
}
// 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 '<table class="panier_tab"><tr><th style="width : 3em; text-align : center;">n°</th><th style="width : 5em; text-align : center;">quantité</th><th align="center" style="width: 40%;">Produit</th><th style="width : 7em; text-align : center;">Durée</th><th style="width : 7em; text-align : center;">Type</th><th style="width : 8em;" align="center">Huile chaude<br />Supplément 5€</th><th style="width : 6em; text-align : center;">prix</th><th style="width : 8em; text-align : center;">total</th><th style="width : 8em; text-align : center;">valable jusqu\'au</th></tr>';
$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 '<tr><td style="padding : 5px; text-align : center;">' . ($i + 1) . '</td><td align="center">';
if ( $modif )
{
echo '<input style="color: brown;" type="text" name="qtes[' . $i . ']" value="' . $art["qte"][$i] . '" maxlength="3" size="2" onchange="document.getElementById( \'commande\' ).submit()" />';
}else
{
echo $art["qte"][$i];
}
echo '</td><td style="width: 40%;">' . $art["libelle"][$i] . '</td><td align="center">' . $art["duree"][$i] . '</td><td align="center">' . $art["type"][$i] . '</td>';
echo '<td align="center">';
if ($modif)
{
if ( $art["hc"][$i] )
{
echo '<input type="checkbox" name="huile_chaude[' . $i . ']" onchange="javascript:window.location.replace( \'' . $base_url . $path . $page . '?action=recalc&i=' . $i . '\');"';
if ( $art["huile_chaude"][$i] )
{
echo 'checked ';
}
echo '/>';
}else
{
echo 'non disponible';
}
}else
{
if ( $art["huile_chaude"][$i] )
{
echo 'oui';
$hc = 5;
}else
{
echo 'non';
$hc = 0;
}
}
echo '</td>';
$prix_article = $art["prix"][$i] + $hc;
echo '<td align="right">' . $prix_article . ' €</td><td align="right">' . $total_col . ' €</td><td align="right">' . $art["date_validite"][$i]->format("j/m/Y") . '</td></tr>';
}
echo '<tr><td colspan="4"></td><td colspan="3" align="center">total du panier</td><td align="right">' . "$total €</td><td></td></tr>";
echo '</table>';
echo "nombre de références : $nombre_ref<br />";
echo "nombre d'articles : $nombre_art";
}
function ajout_panier( $id )
{
//echo '<form method="post" action=""><input type="number" name="' . $id . '" min="0" max="999" value="1" />';
return '<img title="Ajouter au panier" src="./img/shop.png" width="24" height="24" alt="Ajouter au panier" onclick="javascript:open_panier_add(\'' . $id . '\');" />';
}
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 '<tr style="font-weight: bold;"><td text-align : center;">Article</td>';
echo '<td text-align : center;">Quantité</td>';
echo "<td text-align : center;>huile_chaude</td>";
echo '<td text-align : center;">Prix</td>';
echo '<td text-align : center;">Type</td>';
echo '<td text-align : center;">Date de validité</td>';
echo '<td style="width : 3em; text-align : center;">Total article</td>';
echo '</tr>';
while ( $donnees = mysqli_fetch_array($db->result) )
{
echo '<tr><td text-align : center;">' . $donnees["libelle"] . '</td>';
echo '<td text-align : center;">' . $donnees["quantite"] . '</td>';
if ( $donnees["huile_chaude"] )
{
echo "<td text-align : center;>huile_chaude</td>";
}
echo '<td text-align : center;">' . $donnees["prix"] . '</td>';
echo '<td text-align : center;">' . $donnees["type"] . '</td>';
echo '<td text-align : center;">' . $donnees["date_validite"] . '</td>';
$total_article = $donnees["prix"] * $donnees["quantite"];
$total += $total_article;
echo '<td style="width : 3em; text-align : center;">' . $total_article . '</td>';
}
echo '<tr><th>Total de la commande</th><th style="width : 3em; text-align : center;">' . $total . '</th></tr>';
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 '<script type="text/javascript">
<!--
window.opener.document.getElementById("panier").style.visibility="hidden";
window.close();
-->
</script>';
}
?>

156
include/log.php Normal file
View File

@ -0,0 +1,156 @@
<?php
if ( !isset($site) )
{
require_once( "config.inc.php" );
header( 'Location: ' . $accueil );
}
require_once( "db.class.php" );
// $level => 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 ( "<br />", "\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<br />\n";
$log_err = 'erreur dans la requête<br/>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() . "<br />" . __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 '<table><tr>';
if ( $np > 1 )
{
echo '<td><a href="logs.php?np=' . ($np - 1) . '">Page précédente</a></td><td>';
}
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++ )
{
echo '<option value="' . $n . '"';
if ( $n == $np )
{
echo ' selected="selected"';
}
echo '>' . $n . '</option>';
}
echo '</select><noscript><input type="submit" name="submit" Value="none" /></noscript>';
echo "</form>\n</td>";
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 '</select><noscript><input type="submit" name="submit" Value="Envoyer" /></noscript>';
echo "</form>\n</td></tr>";
$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( ) . "<br />" . __file__ . " ligne " . __line__ );
echo "<table border='1' width='90%'><tr><td><b>date</b></td><td><b>auteur</b></td><td><b>log</b></td><td><b>niveau</b></td></tr>\n";
while ( $db->connect->mysqli_fetch_array( $db->result ) )
{
$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 "</table>\n";
}else
{
"aucune réponse";
}
}
}
?>

155
include/log.php~ Normal file
View File

@ -0,0 +1,155 @@
<?php
if ( !isset($site) )
{
require_once( "config.inc.php" );
header( 'Location: ' . $accueil );
}
require_once( "db.class.php" );
require_once( "entete_mail.php" );
// $level => 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 ( "<br />", "\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<br />\n";
$log_err = 'erreur dans la requête<br/>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() . "<br />" . __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 '<table><tr>';
if ( $np > 1 )
{
echo '<td><a href="logs.php?np=' . ($np - 1) . '">Page précédente</a></td><td>';
}
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++ )
{
echo '<option value="' . $n . '"';
if ( $n == $np )
{
echo ' selected="selected"';
}
echo '>' . $n . '</option>';
}
echo '</select><noscript><input type="submit" name="submit" Value="none" /></noscript>';
echo "</form>\n</td>";
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 '</select><noscript><input type="submit" name="submit" Value="Envoyer" /></noscript>';
echo "</form>\n</td></tr>";
$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( ) . "<br />" . __file__ . " ligne " . __line__ );
echo "<table border='1' width='90%'><tr><td><b>date</b></td><td><b>auteur</b></td><td><b>log</b></td><td><b>niveau</b></td></tr>\n";
while ( $db->connect->mysqli_fetch_array( $db->result ) )
{
$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 "</table>\n";
}else
{
"aucune réponse";
}
}
}
?>

8
include/plane.class.php Normal file
View File

@ -0,0 +1,8 @@
<?php
class plane()
{
}
?>

0
include/plane.class.php~ Normal file
View File

25
sql/database.sql Normal file
View File

@ -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`;

48
sql/extra.sql Normal file
View File

@ -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;

83
sql/table_avionpoeme.sql Normal file
View File

@ -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 */;

14
sql/table_logs.sql Normal file
View File

@ -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;

16
sql/table_peripeties.sql Normal file
View File

@ -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;

1
src/.htaccess Normal file
View File

@ -0,0 +1 @@
Options -Indexes

1
todo.txt Normal file
View File

@ -0,0 +1 @@