- added mail return address to expeditor of ap\n- debug of error on peripetie datetime
This commit is contained in:
parent
ecf570ee87
commit
4dd37cda7b
36
cron.php
36
cron.php
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
//chdir('/var/www/html/avion-poeme/');
|
||||
|
||||
require_once 'session_init.php';
|
||||
require_once 'config.inc.php';
|
||||
require_once 'db.class.php';
|
||||
@ -9,11 +10,10 @@
|
||||
$db = new db();
|
||||
//test();
|
||||
$_SERVER["PHP_AUTH_USER"] = "cron";
|
||||
//peripetieDatee();
|
||||
print "envoi des courriers en attente" . EOLH;
|
||||
//peripetieDatee(); // désactivée pour l'instant
|
||||
envoiCourrielEnattente();
|
||||
print "envoi des péripéties" . EOLH;
|
||||
peripeties();
|
||||
//peripeties();
|
||||
print "Envoi des arrivées" . EOLH;
|
||||
arrivee();
|
||||
anonymisation();
|
||||
@ -62,6 +62,7 @@
|
||||
$dbPeripetie->query($query);
|
||||
$peripeties = $dbPeripetie->result->fetch_all(MYSQLI_ASSOC);
|
||||
$dbPeripetie->close();
|
||||
//print_r($peripeties);
|
||||
foreach ( $peripeties as $peripetie)
|
||||
{
|
||||
print "péripétie " . $peripetie["idAP"] . " - avion poème n° " . $peripetie['idAvion'] .EOLH;
|
||||
@ -77,11 +78,15 @@
|
||||
$dicoExpe = getLang( $db->expeLang );
|
||||
$dicoDest = getLang( $db->destLang );
|
||||
// TODO calcul de la nouvelle date d'arrivée
|
||||
$dateExpe = new DateTime("@$db->startTime");
|
||||
$dateDest = new DateTime("@$db->deliveryTime");
|
||||
$startTime = date("c", $db->startTime);
|
||||
$deliveryTime = date("c", $db->deliveryTime);
|
||||
$dateExpe = new DateTime($startTime);
|
||||
print_r($dateExpe);
|
||||
$dateDest = new DateTime($deliveryTime);
|
||||
print_r($dateDest);
|
||||
$interval = $dateExpe->diff($dateDest);
|
||||
$numericInterval = (($interval->days*24 + $interval->h)*60 + $interval->i)*60 + $interval->s;
|
||||
$addDate = $numericInterval * 15/100;
|
||||
$addDate = $numericInterval * 15/100; //TODO calculer d'après les données de la péripétie(voir table péripétie de la base de données)
|
||||
$db->deliveryTime += $addDate;
|
||||
$db->deliveryTimeServer += $addDate;
|
||||
$query = "UPDATE avionpoeme SET deliveryTime=FROM_UNIXTIME(" . $db->deliveryTime . "), deliveryTimeServer=FROM_UNIXTIME(" . $db->deliveryTimeServer . ") WHERE idAvion='" . $peripetie['idAvion'] . "'" ;
|
||||
@ -96,17 +101,16 @@
|
||||
//$html = $result['html'];
|
||||
sleep(1);
|
||||
print "envoi courriel à l'expéditeur : " . $db->expeMail . EOLH . $mailText .EOLH;
|
||||
$r = envoiMail( $db->expeMail, $objetMail, $mailText);
|
||||
$r = envoiMail("contact@avion-poe.me", $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"];
|
||||
print "envoi courriel au destinataire : " . $db->destMail . EOLH . $mailText .EOLH;
|
||||
$s = envoiMail( $db->destMail, $objetMail, $mailText);
|
||||
$s = envoiMail($db->expeMail, $db->destMail, $objetMail, $mailText);
|
||||
sleep(1);
|
||||
//print "r=" . $r ." => s=" .$s .EOLH;
|
||||
|
||||
if ($r AND $s)
|
||||
{
|
||||
$query = "UPDATE avionPeripetie SET mailSent=true WHERE idAP='" . $peripetie['idAP'] ."'";
|
||||
@ -146,7 +150,7 @@
|
||||
$result = replaceVariables((object)$avion, $dicoExpe[$index], $dicoExpe);
|
||||
$mailText= $result["text"];
|
||||
print "envoi courriel à l'expéditeur : " . $avion['expeMail'] . EOLH . $mailText .EOLH;
|
||||
$r = envoiMail( $avion['expeMail'], $objetMail["text"], $mailText);
|
||||
$r = envoiMail("contact@avion-poe.me", $avion['expeMail'], $objetMail["text"], $mailText);
|
||||
|
||||
//envoi notification arrivée destinataire
|
||||
$index = "Notification_Arrivee_Destinataire";
|
||||
@ -159,14 +163,14 @@
|
||||
$mailText = "<html><head></head>\n<body>" . $mailText . "</body></html>";
|
||||
}
|
||||
print "envoi courriel au destinataire : " . $avion['destMail'] . EOLH . $mailText .EOLH;
|
||||
sleep(1);
|
||||
$s = envoiMail( $avion['destMail'], $objetMail["text"], $mailText, $html);
|
||||
sleep(3);
|
||||
$s = envoiMail($avion['expeMail'], $avion['destMail'], $objetMail["text"], $mailText, $html);
|
||||
if ($r AND $s)
|
||||
{
|
||||
$query = "UPDATE avionpoeme SET atteri=true WHERE idAvion='" . $avion['idAvion'] ."'";
|
||||
$db->query($query);
|
||||
}
|
||||
sleep(1);
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,13 +182,14 @@
|
||||
$courriels = $db->result->fetch_all(MYSQLI_ASSOC);
|
||||
foreach( $courriels as $courriel)
|
||||
{
|
||||
$r = envoiMail( $courriel['destinataire'], $courriel['objet'], $courriel['message'], $courriel['html']);
|
||||
//TODO changer l'expéditeur, doit être l'expéditeur de l'avion-poême.
|
||||
$r = envoiMail("contact@avion-poe.me", $courriel['destinataire'], $courriel['objet'], $courriel['message'], $courriel['html']);
|
||||
if ($r)
|
||||
{
|
||||
$query = "DELETE FROM courriels WHERE id='" . $courriel['id'] . "'";
|
||||
$db->query($query);
|
||||
}
|
||||
sleep(1);
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,3 +218,4 @@
|
||||
}
|
||||
}
|
||||
$db->close();
|
||||
?>
|
||||
|
@ -7,7 +7,6 @@ if (!isset($site)) {
|
||||
require_once "config.inc.php";
|
||||
require_once "log.php";
|
||||
require_once "fonctions.inc.php";
|
||||
require_once "envoi_courriel.inc.php";
|
||||
|
||||
$table_prefix = "";
|
||||
class db
|
||||
@ -197,10 +196,17 @@ class db
|
||||
function savePeripetie()
|
||||
{
|
||||
|
||||
$query = "INSERT INTO avionPeripetie VALUES ('0','";
|
||||
$query .= $this->protect($this->uid) . "','";
|
||||
$query .= $this->protect($this->idPeripetie) . "', ";
|
||||
$query .= "FROM_UNIXTIME(" . $this->protect($this->datePeripetie) . "), '0')";
|
||||
$query = "INSERT INTO avionPeripetie ('expeMail', 'idAvion', 'idPeripetie', 'date'), VALUES (";
|
||||
if ($this->expeKnown)
|
||||
{
|
||||
$query .= "'" . $this->protect($this->expeMail) . "',";
|
||||
}else
|
||||
{
|
||||
$query .= "'contact@avion-poe.me',";
|
||||
}
|
||||
$query .= "'" . $this->protect($this->uid) . "',";
|
||||
$query .= "'" . $this->protect($this->idPeripetie) . "', ";
|
||||
$query .= "FROM_UNIXTIME(" . $this->protect($this->datePeripetie) . "))";
|
||||
log_write("savePeripetie " . $query);
|
||||
//$query .= $this->protect($this->effetPeripetie) . "', '";
|
||||
//$query .= $this->protect($this->expeMail) . "', '";
|
||||
|
@ -2,7 +2,6 @@
|
||||
require_once 'log.php';
|
||||
require_once 'fonctions.inc.php';
|
||||
|
||||
|
||||
function courrielEnvoi( $db )
|
||||
{
|
||||
$dicoExpe = getLang( $db->expeLang );
|
||||
@ -60,6 +59,8 @@ function envoiMail($expediteur,$destinataire, $sujet, $text, $html=false, $cc=''
|
||||
{
|
||||
require_once 'include/swiftmailer/autoload.php';
|
||||
//require_once 'include/swiftmailer/swiftmailer/lib/swift_init.php';
|
||||
try
|
||||
{
|
||||
$transport = (new Swift_SmtpTransport('smtpauth.online.net', 465, 'ssl'))
|
||||
->setUsername('contact@avion-poe.me')
|
||||
->setPassword('AvionPoème*27juillet');
|
||||
@ -95,6 +96,11 @@ function envoiMail($expediteur,$destinataire, $sujet, $text, $html=false, $cc=''
|
||||
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" . $destinataire . EOL . $sujet . EOL . print_r($failure, true) . EOL . wordwrap($text, 1000 , "\r\n"), ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (\Swift_TransportException $ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user