open(); test(); //peripetieDatee(); peripeties(); function peripetieDatee() { global $db; require_once 'envoi_courriel.inc.php'; $flag = false; //recherche des péripéties datées $query = "SELECT * FROM peripeties WHERE quand!='' AND DATEDIFF(quand,CURDATE())=0"; $db->query($query); $peripetieTable = $result = $db->result->fetch_all(MYSQLI_ASSOC); $query = "SELECT * FROM avionpoeme WHERE atteri=0"; $db->query($query); while ( ($result = $db->result->fetch_assoc()) ) { $dicoExpe = getLang( $result['expeLang'] ); $dicoDest = getLang( $result['destLang'] ); foreach( $peripetieTable as $p ) { $indexObjet = "Objet_" . $p['indexText']; $objetMail = $dicoExpe["Objet_" . $p['indexText']]; $mailText = $dicoExpe[$p['indexText']] .EOL .EOL ; print $objetMail .EOLH; print $mailText .EOLH; envoiMail( "dtux@free.fr", $objetMail, $mailText, true);//$result['destMail'] sleep(2); envoiMail( "dtux@free.fr", $objetMail, $mailText, true);//$result['expeMail'] sleep(2); } } } function peripeties() { global $db; //recherche des péripéties non datées $query = "SELECT * FROM avionpoeme WHERE atteri = 0"; $db->query($query); $dbPeripetie = new db(); $dbPeripetie->open(); while ( ($result = $db->result->fetch_assoc()) ) { $dicoExpe = getLang( $result['expeLang'] ); $dicoDest = getLang( $result['destLang'] ); $query = "SELECT * FROM avionPeripetie LEFT JOIN peripeties USING (idPeripetie) WHERE idAvion='" . $result['idAvion'] . "'"; $dbPeripetie->query($query); while (($peripetie =$dbPeripetie->result->fetch_assoc())) { print $result["destMail"] . EOL; $indexObjet = "Objet_" . $peripetie['indexText']; $objetMail = $dicoExpe["Objet_" . $peripetie['indexText']]; $mailText = $dicoExpe[$peripetie['indexText']] .EOL .EOL ; print $indexObjet . EOL; print $mailText .EOL; //envoiMail( "dtux@free.fr", $objetMail, $mailText, true);//$result['destMail'] //sleep(2); //envoiMail( "dtux@free.fr", $objetMail, $mailText, true);//$result['expeMail'] //sleep(2); } } $dbPeripetie->close(); } function test() { $lang = array( 'fr', 'en', 'es', 'de', 'ar', 'bg', 'zh', 'ja', 'pt'); foreach ($lang as $value) { getLang( $value ); print $value; print json_last_error_msg() .EOL; } } $db->close(); ?>