diff --git a/avionpoeme.php b/avionpoeme.php index 44520cd..1308ab8 100644 --- a/avionpoeme.php +++ b/avionpoeme.php @@ -28,6 +28,7 @@ if (!empty ($erreur)) { echo json_encode($erreur); + log_error("erreur lors de l'acquisition des données:" . EOLH . print_r($erreur, true)); }else { $db->newPlane(); diff --git a/cron.php b/cron.php index 3ee15a9..9643008 100644 --- a/cron.php +++ b/cron.php @@ -1,16 +1,20 @@ query($query); - $dbPeripetie = new db(); - $dbPeripetie->open(); - - while ( ($result = $db->result->fetch_assoc()) ) - { - $dicoExpe = getLang( $result['expeLang'] ); - $dicoDest = getLang( $result['destLang'] ); - $db->urlAvion = $base_url . "/?avionpoeme=" . $result['idAvion']; - $query = "SELECT *, UNIX_TIMESTAMP(date) as dateArrivee FROM avionPeripetie LEFT JOIN peripeties USING (idPeripetie) WHERE idAvion='" . $result['idAvion'] . "' AND mailSent=false AND TIMEDIFF(CONCAT_WS(' ',CURDATE(),CURTIME()), date) > '00:00'"; - $dbPeripetie->query($query); - while (($peripetie = $dbPeripetie->result->fetch_assoc())) - { - $db->datePeripetie = formatteDate($result['expeLang'],$peripetie['dateArrivee'], $result['startTZ']); - $indexObjet = "Objet_" . $peripetie['indexText']; - $objetMail = replaceVariables($db, $dicoExpe["Objet_" . $peripetie['indexText']], $dicoExpe); - $mailText = replaceVariables($db, $dicoExpe[$peripetie['indexText']], $dicoExpe) .EOLH .EOLH ; - print $mailText .EOLH; - print "envoi courriel au destinataire" .EOLH; - $r = true; //envoiMail( $result['destMail'], $objetMail, $mailText, true); - //sleep(2); - $db->datePeripetie = formatteDate($result['destLang'],$peripetie['dateArrivee'], $result['deliveryTZ']); - $objetMail = replaceVariables($db, $dicoDest["Objet_" . $peripetie['indexText']], $dicoDest); - $mailText = replaceVariables($db, $dicoDest[$peripetie['indexText']], $dicoDest) .EOLH .EOLH ; - print $mailText .EOLH; - print "envoi courriel à l'expéditeur" .EOLH; - $s = true; //envoiMail( $result['expeMail'], $objetMail, $mailText, true); - //sleep(2); - if ($r AND $s) - { - $query = "UPDATE avionPeripetie SET mailSent=true WHERE idAP='" . $peripetie['idAP'] ."'"; - $db->query($query); - } - } - } - $dbPeripetie->close(); - } -*/ function peripeties() //recherche des péripéties non datées { global $db, $base_url; @@ -100,15 +61,10 @@ foreach ( $peripeties as $peripetie) { + print "avion poème n° " . $peripetie['idAvion'] .EOL; $db->getPlane($peripetie['idAvion']); $dicoExpe = getLang( $db->expeLang ); - if ( $db->expeLang == $db->destLang ) - { - $dicoDest =''; - }else - { - $dicoDest = getLang( $db->destLang ); - } + $dicoDest = getLang( $db->destLang ); // TODO calcul de la nouvelle date d'arrivée $dateExpe = new DateTime("@$db->startTime"); $dateDest = new DateTime("@$db->deliveryTime"); @@ -116,38 +72,41 @@ $numericInterval = (($interval->days*24 + $interval->h)*60 + $interval->i)*60 + $interval->s; $addDate = $numericInterval * 15/100; $db->deliveryTime += $addDate; - $query = "UPDATE avionpoeme SET deliveryTime=FROM_UNIXTIME(" . $this->deliveryTime . ")"; + $db->deliveryTimeServer += $addDate; + $query = "UPDATE avionpoeme SET deliveryTime=FROM_UNIXTIME(" . $db->deliveryTime . "), deliveryTimeServer=FROM_UNIXTIME(" . $db->deliveryTimeServer . ") WHERE idAvion='" . $peripetie['idAvion'] . "'" ; $db->query($query); $db->urlAvion = $base_url . "/?avionpoeme=" . $db->uid; $db->datePeripetie = formatteDate($db->expeLang, $db->deliveryTime, $db->startTZ); $indexObjet = "Objet_" . $peripetie['indexText']; - $objetMail = replaceVariables($db, $dicoExpe["Objet_" . $peripetie['indexText']], $dicoExpe); - $mailText = replaceVariables($db, $dicoExpe[$peripetie['indexText']], $dicoExpe) .EOLH .EOLH ; - print $mailText .EOLH; + $result = replaceVariables($db, $dicoExpe["Objet_" . $peripetie['indexText']], $dicoExpe); + $objetMail = $result["text"]; + $result = replaceVariables($db, $dicoExpe[$peripetie['indexText']], $dicoExpe); + $mailText = $result["text"]; + //$html = $result['html']; sleep(1); - if (empty($dicoDest)) - { - print "envoi courriel à l'expéditeur et au destinataire en BCC" .EOLH; - $r = envoiMail( $db->expeMail, $objetMail, $mailText, false, '', $db->destMail ); - $s = $r; //pour l'update de la BD - }else - { - print "envoi courriel à l'expéditeur" .EOLH; - $r = envoiMail( $db->expeMail, $objetMail, $mailText, false); + print "envoi courriel à l'expéditeur" .EOL; + $r = envoiMail( $db->expeMail, $objetMail, $mailText); + $db->datePeripetie = formatteDate($db->destLang, $db->deliveryTime, $db->deliveryTZ); + $result = replaceVariables($db, $dicoDest["Objet_" . $peripetie['indexText']], $dicoDest); + $objetMail = $result["text"]; + $result = replaceVariables($db, $dicoDest[$peripetie['indexText']], $dicoDest); + $mailText = $result["text"] .EOLH .EOLH; + print "envoi courriel au destinataire" .EOL; + $s = envoiMail( $db->destMail, $objetMail, $mailText); + sleep(1); + //print "r=" . $r ." => s=" .$s .EOLH; - $db->datePeripetie = formatteDate($db->destLang, $db->deliveryTime, $db->deliveryTZ); - $objetMail = replaceVariables($db, $dicoDest["Objet_" . $peripetie['indexText']], $dicoDest); - $mailText = replaceVariables($db, $dicoDest[$peripetie['indexText']], $dicoDest) .EOLH .EOLH ; - print "envoi courriel au destinataire" .EOLH; - $s = envoiMail( $db->destMail, $objetMail, $mailText, false); - sleep(1); - //print "r=" . $r ." => s=" .$s .EOLH; - } if ($r AND $s) { $query = "UPDATE avionPeripetie SET mailSent=true WHERE idAP='" . $peripetie['idAP'] ."'"; $db->query($query); + }else + { + print "table avion péripétie non mise à jour" .EOL; + print "UPDATE avionPeripetie SET mailSent=true WHERE idAP='" . $peripetie['idAP'] ."'" .EOL; } + + sleep(1); } } @@ -156,26 +115,35 @@ { global $db; //recherche des avions atteris - $query = "SELECT * FROM avionpoeme WHERE atteri = 0 AND TIMEDIFF(CONCAT_WS(' ',CURDATE(),CURTIME()),deliveryTime) > '00:00'"; + $query = "SELECT * FROM avionpoeme WHERE atteri = 0 AND TIMEDIFF(CONCAT_WS(' ',CURDATE(),CURTIME()),deliveryTimeServer) > '00:00'"; $db->query($query); $avionArrive = $db->result->fetch_all(MYSQLI_ASSOC); foreach ($avionArrive as $avion) { + print "avion poème n° " . $avion['idAvion'] . EOLH; $dicoExpe = getLang( $avion['expeLang'] ); $dicoDest = getLang( $avion['destLang'] ); $index = "Notification_Arrivee_Expediteur"; $indexObjet = "Objet_"; $objetMail = replaceVariables($db, $dicoExpe[$indexObjet . $index], $dicoExpe); - $mailText = replaceVariables($db, $dicoExpe[$index], $dicoExpe) . EOL . EOL ; - print $mailText . EOLH; - print "envoi courriel à l'expéditeur" . EOLH; - $r = envoiMail( $avion['destMail'], $objetMail, $mailText);// + $result = replaceVariables($db, $dicoExpe[$index], $dicoExpe); + $mailText= $result["text"]; + print "envoi courriel à l'expéditeur". EOLH; + $r = envoiMail( $avion['expeMail'], $objetMail["text"], $mailText); sleep(1); $index = "Notification_Arrivee_Destinataire"; + $objetMail = replaceVariables($db, $dicoDest[$indexObjet . $index], $dicoDest); - $mailText = replaceVariables($db, $dicoDest[$index], $dicoDest) .EOLH .EOLH ; + $result = replaceVariables($db, $dicoDest[$index], $dicoDest); + log_write(__FILE__ . EOL . __LINE__ . EOL . "#" .print_r($result, true) . "#", INFO); + $mailText = $result["text"]; + $html = $result['html']; + if ( $html ) + { + $mailText = "\n" . $mailText . ""; + } print "envoi courriel au destinataire" . EOLH; - $s = envoiMail( $avion['expeMail'], $objetMail, $mailText); + $s = envoiMail( $avion['destMail'], $objetMail["text"], $mailText, $html); if ($r AND $s) { $query = "UPDATE avionpoeme SET atteri=true WHERE idAvion='" . $avion['idAvion'] ."'"; diff --git a/gestion/genere_lang.php b/gestion/genere_lang.php index fc1cc70..fbc7601 100644 --- a/gestion/genere_lang.php +++ b/gestion/genere_lang.php @@ -2,6 +2,7 @@ require_once '../session_init.php'; require_once 'config.inc.php'; + require_once 'fonctions.inc.php'; if ( isset($_GET["ok"] )) { @@ -91,15 +92,20 @@ fwrite($fhx, '}'); fclose($fhx); } - $fh = fopen("lang/lang.json","r"); + $fh = fopen("../lang/lang.json","r"); $str = fgets($fh); fclose($fh); $lang = json_decode( $str, true); foreach ($lang as $key => $value) { - getLang( $key ); - print $key; - print json_last_error_msg() .EOL; + print $key ." : "; + if ( getLang($key, true) !== false ) + { + print json_last_error_msg() . EOLH; + }else + { + print "erreur à l'ouverture du fichier"; + } } } ?> diff --git a/include/config.inc.php b/include/config.inc.php index ff010f7..a26e75c 100644 --- a/include/config.inc.php +++ b/include/config.inc.php @@ -20,9 +20,12 @@ $site = "Avion Poème"; $dossier = "/www"; $basedir = dirname( $_SERVER['DOCUMENT_ROOT'] ) . $dossier; -$base_url = "http://avion-poe.me"; +$base_url = "https://avion-poe.me"; $base_path = "/flex/storage/avion-poe.me/site/www/"; $url_admin = $base_url . "/gestion"; $accueil = $base_url . "/index.html"; - +if (empty( $_SERVER["PHP_AUTH_USER"])) +{ + $_SERVER["PHP_AUTH_USER"] = 'script'; +} ?> diff --git a/include/db.class.php b/include/db.class.php index eee0b60..3fa0e69 100644 --- a/include/db.class.php +++ b/include/db.class.php @@ -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 . "
" . __file__ . ' ligne ' . __line__ . "\n" . $string, true, true); + if ( $this->connect->error ) log_error( "Échec de la commande query => " . $this->connect->error . "
" . __file__ . ' ligne ' . __line__ . "\n" . $string, true, false); //print_r( $this ); } @@ -120,15 +120,15 @@ class db $query .= "FROM_UNIXTIME(" . $this->protect($this->deliveryTimeServer) . "), '"; $query .= $this->protect($this->deliveryMethod) . "','"; $query .= "0')"; - //print_r($this); $this->query($query); $this->uid = $this->connect->insert_id; echo "{'uid':'" . $this->uid . "'}"; $this->startTimeRFC822 = formatteDate( $this->expeLang, $this->startTime, $this->startTZ); $this->deliveryTimeRFC822 = formatteDate( $this->destLang, $this->deliveryTime, $this->deliveryTZ ); $this->urlAvion = $base_url . "/?avionpoeme=" . $this->uid; - courrielEnvoi($this); $this->newPeripetie(); + courrielEnvoi($this); + } function getPlane($uid) diff --git a/include/envoi_courriel.inc.php b/include/envoi_courriel.inc.php index 59350c7..7a37fbf 100644 --- a/include/envoi_courriel.inc.php +++ b/include/envoi_courriel.inc.php @@ -12,8 +12,17 @@ function courrielEnvoi( $db ) // Message à l'expéditeur $indexObjet = "Objet_" . $expediteurIndex; - $objetMail = replaceVariables($db, $dicoExpe[$indexObjet], $dicoExpe); - $mailText = replaceVariables($db, $dicoExpe[$expediteurIndex], $dicoExpe) .EOL .EOL ; + $result = replaceVariables($db, $dicoExpe[$indexObjet], $dicoExpe); + log_write("indexObjet" .EOLH . print_r($result, true)); + $objetMail = $result['text']; + $result = replaceVariables($db, $dicoExpe[$expediteurIndex], $dicoExpe) ; + log_write("indexObjet" .EOLH . print_r($result, true)); + $mailText = $result['text']; + $html = $result['html']; + if ( $html ) + { + $mailText = "\n" . $mailText . ""; + } if ( $db->expeKnown == false ) { $destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurConnu"; @@ -21,18 +30,25 @@ function courrielEnvoi( $db ) { $destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurAnonyme"; } - - saveMail( $db, $db->expeMail, $objetMail, $mailText); + saveMail( $db, $db->expeMail, $objetMail, $mailText, $html); // message au destinataire $indexObjet = "Objet_" . $destinataireIndex; - $objetMail = replaceVariables($db, $dicoExpe[$indexObjet], $dicoDest); - $mailText = replaceVariables($db, $dicoDest[$destinataireIndex], $dicoDest) .EOL .EOL ; - - saveMail( $db, $db->destMail, $objetMail, $mailText); + $result = replaceVariables($db, $dicoDest[$indexObjet], $dicoDest); + log_write("indexObjet" .EOLH . print_r($result, true)); + $objetMail = $result['text']; + $result = replaceVariables($db, $dicoDest[$destinataireIndex], $dicoDest); + log_write("indexObjet" .EOLH . print_r($result, true)); + $mailText = $result['text']; + $html = $result['html']; + if ( $html ) + { + $message = "\n" . $message . ""; + } + saveMail( $db, $db->destMail, $objetMail, $mailText, $html); } -function saveMail( $db, $destinataire, $objet, $text, $html=FALSE) +function saveMail( $db, $destinataire, $objet, $text, $html=false) { $query = "INSERT INTO courriels VALUES ('0', '" . $db->protect($destinataire) . "', '" . $db->protect($objet) . "', '" . $db->protect($text) . "', '" . (int)$html . "')"; $db->query($query); @@ -44,20 +60,22 @@ function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='') if ( !empty($cc)) $headers .= "Cc: " . $cc . LF; if ( !empty($bcc)) $headers .= "Bcc: " . $bcc . LF; - if (empty($html)) - { - $headers .= "Content-type: text/plain; charset=UTF-8" . LF; - }else + if ($html) { $headers .= "Content-type: text/html; charset=UTF-8" . LF; nl2br($text); + }else + { + $headers .= "Content-type: text/plain; charset=UTF-8" . LF; + $text = str_replace("\n","\r\n", $text); } $headers .= "DATE: " . date( 'r' ) . LF . LF; - + $destinataire = "dtux@free.fr"; log_write(__FILE__ . __LINE__ . " Envoi d'un courriel à " . $destinataire . "sujet:" . $sujet, INFO); - if( !mail($destinataire, $sujet, wordwrap($text, 70 , "\r\n"), $headers) ) //Sending mail + if( !mail($destinataire, $sujet, wordwrap($text, 1000 , "\r\n"), $headers) ) //Sending mail { - log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$destinataire . EOL . $sujet, ERROR); + $error = error_get_last(); + log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$destinataire . EOL . $sujet . EOL . print_r($error, true) . EOL . wordwrap($text, 1000 , "\r\n"), ERROR); return false; }else { diff --git a/include/fonctions.inc.php b/include/fonctions.inc.php index ef3f93e..e1fc1b6 100644 --- a/include/fonctions.inc.php +++ b/include/fonctions.inc.php @@ -25,56 +25,76 @@ function getpost( $var ) { return; } - } // 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"); +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; - } +} -function getLang( $lang ) +function getLang( $lang, $gestion=false ) +{ + $dico = array(); + if ( empty($lang) ) { - $dico = array(); - if ( empty($lang) ) - { - $lang="en"; - } - if (($fh = fopen('lang/'.$lang, 'r') )) - { - $str = fgets($fh); - fclose($fh); - $dico = json_decode($str, true); - return $dico; - } + $lang="en"; } + $langPath ='lang/'.$lang; + if ($gestion) + $langPath = "../" . $langPath; + if (($fh = fopen($langPath, 'r') )) + { + $str = fgets($fh); + fclose($fh); + $dico = json_decode($str, true); + return $dico; + }else + { + return false; + } +} function formatteDate($locale, $date, $tz) { $formatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::FULL, $tz, IntlDateFormatter::GREGORIAN ); if ($formatter == null) { - log_write(InvalidConfigException(intl_get_error_message())); + log_write(__FILE__ . EOLH . __LINE__ . EOLH . "Formatter error : locale = " . $locale . "tz = " . $tz . "Formatter = " . print_r($formatter, true) . InvalidConfigException(intl_get_error_message()),ERROR); } return $formatter->format($date); } -function replaceVariables($db, $text, $dico) +/* Remplace les variables dans les textes + +*/ +function replaceVariables($db, $text, $dico) :array { - $variables = array( 'expediteur' => 'expeMail', 'destinataire' => 'destMail', 'date_depart' => 'startTimeRFC822', 'date_arrivee' => 'deliveryTimeRFC822', 'new_date_arrivee' => 'datePeripetie', 'message' => 'message', 'url_avion' => 'url_avion', 'onglet_apropos' => 'onglet_apropos', 'NB_avion_poeme' => 'avionJournalier', "url_avion" => "urlAvion"); + $variables = array( 'expediteur' => 'expeMail', 'destinataire' => 'destMail', 'date_depart' => 'startTimeRFC822', 'date_arrivee' => 'deliveryTimeRFC822', 'new_date_arrivee' => 'datePeripetie', 'message' => 'message', 'onglet_apropos' => 'onglet_apropos', 'NB_avion_poeme' => 'avionJournalier', "url_avion" => "urlAvion"); $posVar = 0 ; $x =0; + $result = array(); + // si contient la variable '$message' alors le text est en html + if (strpos($text, '$message') === false) + { + $html = false; + }else + { + $html = true; + } while( 1 ) { + // Recherche les variables dans le texte $posVar = strpos( $text, "$", $posVar); if ($posVar !== false) { - if ($x++ >10 ) break; + // 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) { @@ -83,23 +103,33 @@ function replaceVariables($db, $text, $dico) { $var = substr($text, $posVar+1, $posEsp-$posVar-1); } - $var = trim($var, " .\n\r"); $posVar = $posEsp+1; - $varReplace = "$" . $var; + $var = trim($var, " .\n\r"); + + $varReplace = "$" . $var; if ( isset ($variables[$var]) ) { $dbVar = $variables[$var]; - $text = str_replace($varReplace, $db->$dbVar, $text); + $varText = $db->$dbVar; + //$text = str_replace($varReplace, $db->$dbVar, $text); }elseif ( isset ($dico[$var]) ) { - $text = str_replace($varReplace, $dico[$var], $text); + $varText = $dico[$var]; + //$text = str_replace($varReplace, $dico[$var], $text); }else { log_error( "La variable => " . $var . "n'est pas reconnue
" . __file__ . ' ligne ' . __line__ . "\n" , true, false); } + if ($html and (strpos($var, "url") !== false)) + { + $varText = '' . $varText . ""; + } + $text = str_replace($varReplace, $varText, $text); }else { break; } } - return $text; + $result['html'] = $html; + $result['text'] = $text; + return $result; } diff --git a/include/log.php b/include/log.php index 1f4f85a..b28a4f8 100644 --- a/include/log.php +++ b/include/log.php @@ -140,7 +140,7 @@ function affich_log( $nl, $np = 1, $level=0) $query .= " WHERE niveau='" . $level . "'"; } - $query .= ' ORDER BY date DESC LIMIT ' . ( ( ( $np - 1 ) * $nl ) ) . ',' . $nl; + $query .= ' ORDER BY id_log DESC LIMIT ' . ( ( ( $np - 1 ) * $nl ) ) . ',' . $nl; $db->query( $query ); echo "\n"; while ( ($donnees =$db->result->fetch_array()) ) diff --git a/sql/db351634_avionpoeme.sql b/sql/db351634_avionpoeme.sql new file mode 100644 index 0000000..fe7fbec --- /dev/null +++ b/sql/db351634_avionpoeme.sql @@ -0,0 +1,204 @@ +-- phpMyAdmin SQL Dump +-- version 4.9.5 +-- https://www.phpmyadmin.net/ +-- +-- Hôte : db120904.sql-pro.online.net +-- Généré le : ven. 23 avr. 2021 à 10:40 +-- 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`; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `avionPeripetie` +-- + +CREATE TABLE `avionPeripetie` ( + `idAP` int(10) UNSIGNED NOT NULL, + `idAvion` int(10) UNSIGNED NOT NULL, + `idPeripetie` int(10) UNSIGNED NOT NULL, + `date` datetime NOT NULL, + `mailSent` tinyint(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Stock les péripeties de chaque avion'; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `avionpoeme` +-- + +CREATE TABLE `avionpoeme` ( + `idAvion` 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, + `public` tinyint(1) NOT NULL COMMENT '0 = privé 1=public, 2=supprimé', + `color` varchar(9) NOT NULL COMMENT ' le code hexa de la couleur de l''avion aleatoire parmis la liste.', + `deliveryTime` timestamp NOT NULL, + `deliveryTZ` text NOT NULL, + `deliveryTimeServer` timestamp NOT NULL, + `deliveryMethod` text CHARACTER SET utf8mb4 NOT NULL, + `atteri` tinyint(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `courriels` +-- + +CREATE TABLE `courriels` ( + `id` int(10) UNSIGNED NOT NULL, + `destinataire` text NOT NULL, + `objet` text NOT NULL, + `message` text NOT NULL, + `html` tinyint(1) NOT NULL COMMENT 'false = text, true = html' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='stockage des courriels en attente d''envoie'; + +-- -------------------------------------------------------- + +-- +-- 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; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `peripeties` +-- + +CREATE TABLE `peripeties` ( + `idPeripetie` int(11) NOT NULL, + `indexText` text NOT NULL COMMENT 'Contient l''index pour la traduction', + `probabilite` decimal(5,1) UNSIGNED NOT NULL COMMENT 'en pourcentage', + `effet` tinyint(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', + `quand` date DEFAULT NULL, + `quand_fonction` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Déchargement des données de la table `peripeties` +-- + +INSERT INTO `peripeties` (`idPeripetie`, `indexText`, `probabilite`, `effet`, `quand`, `quand_fonction`) VALUES +(1, 'Peripetie_Perturbation', '20.0', 15, NULL, NULL), +(2, 'Peripetie_Vents_porteurs', '20.0', -15, NULL, NULL), +(3, 'Peripetie_Collision_Oiseau', '0.5', 0, NULL, NULL), +(4, 'Peripetie_OVNI', '0.5', 0, NULL, NULL), +(5, 'Peripetie_Drone', '0.5', 0, NULL, NULL), +(6, 'Peripetie_LogicielLibre', '100.0', 0, '2021-04-05', NULL), +(7, 'Peripetie_Poesie', '100.0', 0, '2022-03-21', NULL); + +-- +-- Index pour les tables déchargées +-- + +-- +-- Index pour la table `avionPeripetie` +-- +ALTER TABLE `avionPeripetie` + ADD PRIMARY KEY (`idAP`); + +-- +-- Index pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + ADD PRIMARY KEY (`idAvion`), + ADD UNIQUE KEY `status_index` (`idAvion`), + ADD KEY `expe_mail_index` (`expeMail`(40)), + ADD KEY `dest_mail_index` (`destMail`(40)), + ADD KEY `delivery_date_index` (`deliveryTime`); + +-- +-- Index pour la table `courriels` +-- +ALTER TABLE `courriels` + ADD PRIMARY KEY (`id`); + +-- +-- 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 (`idPeripetie`); + +-- +-- AUTO_INCREMENT pour les tables déchargées +-- + +-- +-- AUTO_INCREMENT pour la table `avionPeripetie` +-- +ALTER TABLE `avionPeripetie` + MODIFY `idAP` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + MODIFY `idAvion` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT pour la table `courriels` +-- +ALTER TABLE `courriels` + MODIFY `id` 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 `idPeripetie` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; +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/db351634_avionpoeme_database.sql b/sql/db351634_avionpoeme_database.sql new file mode 100644 index 0000000..c23ab9f --- /dev/null +++ b/sql/db351634_avionpoeme_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 : ven. 23 avr. 2021 à 10:41 +-- 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/db351634_avionpoeme_metadata.sql b/sql/db351634_avionpoeme_metadata.sql new file mode 100644 index 0000000..ec52d87 --- /dev/null +++ b/sql/db351634_avionpoeme_metadata.sql @@ -0,0 +1,73 @@ + +-- +-- Index pour les tables déchargées +-- + +-- +-- Index pour la table `avionPeripetie` +-- +ALTER TABLE `avionPeripetie` + ADD PRIMARY KEY (`idAP`); + +-- +-- Index pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + ADD PRIMARY KEY (`idAvion`), + ADD UNIQUE KEY `status_index` (`idAvion`), + ADD KEY `expe_mail_index` (`expeMail`(40)), + ADD KEY `dest_mail_index` (`destMail`(40)), + ADD KEY `delivery_date_index` (`deliveryTime`); + +-- +-- Index pour la table `courriels` +-- +ALTER TABLE `courriels` + ADD PRIMARY KEY (`id`); + +-- +-- 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 (`idPeripetie`); + +-- +-- AUTO_INCREMENT pour les tables déchargées +-- + +-- +-- AUTO_INCREMENT pour la table `avionPeripetie` +-- +ALTER TABLE `avionPeripetie` + MODIFY `idAP` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT pour la table `avionpoeme` +-- +ALTER TABLE `avionpoeme` + MODIFY `idAvion` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT pour la table `courriels` +-- +ALTER TABLE `courriels` + MODIFY `id` 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 `idPeripetie` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; diff --git a/sql/db351634_avionpoeme_table_avionPeripetie.sql b/sql/db351634_avionpoeme_table_avionPeripetie.sql new file mode 100644 index 0000000..b240543 --- /dev/null +++ b/sql/db351634_avionpoeme_table_avionPeripetie.sql @@ -0,0 +1,14 @@ + +-- -------------------------------------------------------- + +-- +-- Structure de la table `avionPeripetie` +-- + +CREATE TABLE `avionPeripetie` ( + `idAP` int(10) UNSIGNED NOT NULL, + `idAvion` int(10) UNSIGNED NOT NULL, + `idPeripetie` int(10) UNSIGNED NOT NULL, + `date` datetime NOT NULL, + `mailSent` tinyint(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Stock les péripeties de chaque avion'; diff --git a/sql/db351634_avionpoeme_table_avionpoeme.sql b/sql/db351634_avionpoeme_table_avionpoeme.sql new file mode 100644 index 0000000..8ccfd08 --- /dev/null +++ b/sql/db351634_avionpoeme_table_avionpoeme.sql @@ -0,0 +1,31 @@ + +-- -------------------------------------------------------- + +-- +-- Structure de la table `avionpoeme` +-- + +CREATE TABLE `avionpoeme` ( + `idAvion` 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, + `public` tinyint(1) NOT NULL COMMENT '0 = privé 1=public, 2=supprimé', + `color` varchar(9) NOT NULL COMMENT ' le code hexa de la couleur de l''avion aleatoire parmis la liste.', + `deliveryTime` timestamp NOT NULL, + `deliveryTZ` text NOT NULL, + `deliveryTimeServer` timestamp NOT NULL, + `deliveryMethod` text CHARACTER SET utf8mb4 NOT NULL, + `atteri` tinyint(1) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/sql/db351634_avionpoeme_table_courriels.sql b/sql/db351634_avionpoeme_table_courriels.sql new file mode 100644 index 0000000..b708639 --- /dev/null +++ b/sql/db351634_avionpoeme_table_courriels.sql @@ -0,0 +1,14 @@ + +-- -------------------------------------------------------- + +-- +-- Structure de la table `courriels` +-- + +CREATE TABLE `courriels` ( + `id` int(10) UNSIGNED NOT NULL, + `destinataire` text NOT NULL, + `objet` text NOT NULL, + `message` text NOT NULL, + `html` tinyint(1) NOT NULL COMMENT 'false = text, true = html' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='stockage des courriels en attente d''envoie'; diff --git a/sql/db351634_avionpoeme_table_logs.sql b/sql/db351634_avionpoeme_table_logs.sql new file mode 100644 index 0000000..120867b --- /dev/null +++ b/sql/db351634_avionpoeme_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/db351634_avionpoeme_table_peripeties.sql b/sql/db351634_avionpoeme_table_peripeties.sql new file mode 100644 index 0000000..01b638a --- /dev/null +++ b/sql/db351634_avionpoeme_table_peripeties.sql @@ -0,0 +1,28 @@ + +-- -------------------------------------------------------- + +-- +-- Structure de la table `peripeties` +-- + +CREATE TABLE `peripeties` ( + `idPeripetie` int(11) NOT NULL, + `indexText` text NOT NULL COMMENT 'Contient l''index pour la traduction', + `probabilite` decimal(5,1) UNSIGNED NOT NULL COMMENT 'en pourcentage', + `effet` tinyint(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', + `quand` date DEFAULT NULL, + `quand_fonction` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Déchargement des données de la table `peripeties` +-- + +INSERT INTO `peripeties` (`idPeripetie`, `indexText`, `probabilite`, `effet`, `quand`, `quand_fonction`) VALUES +(1, 'Peripetie_Perturbation', '20.0', 15, NULL, NULL), +(2, 'Peripetie_Vents_porteurs', '20.0', -15, NULL, NULL), +(3, 'Peripetie_Collision_Oiseau', '0.5', 0, NULL, NULL), +(4, 'Peripetie_OVNI', '0.5', 0, NULL, NULL), +(5, 'Peripetie_Drone', '0.5', 0, NULL, NULL), +(6, 'Peripetie_LogicielLibre', '100.0', 0, '2021-04-05', NULL), +(7, 'Peripetie_Poesie', '100.0', 0, '2022-03-21', NULL);
dateauteurlogniveau