1
0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__avion-poeme/peripetie.cron.php

89 lines
2.5 KiB
PHP
Raw Normal View History

2021-04-07 21:08:08 +02:00
<?php
require_once './session_init.php';
require_once 'config.inc.php';
require_once 'db.class.php';
require_once 'log.php';
$db = new db();
$db->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();
?>