BUG : message sans ID + json vide caractère non UTF8
This commit is contained in:
parent
da87e6025f
commit
4ef6352d59
5 changed files with 55 additions and 17 deletions
15
README.md
15
README.md
|
@ -49,6 +49,21 @@ Editer el fichier config.yaml et paramétrer ce dont vous avez besoin, notaement
|
|||
|
||||
Pour le daemon, le script ini.d se trouve dans *init.d/lighten-mailbox*
|
||||
|
||||
## Changelog
|
||||
|
||||
* Futur :
|
||||
* BUG index.html si eml masque lien des archives !
|
||||
* MAX usage... par IP et/ou cookies... ? (pour éviter que le service ne soit détourné)
|
||||
* Estimer temps/durée (avant validation)
|
||||
* Prévenir de "combien de personne avant vous" avant validation et combien de temps ça va prendre (estimation possible avec le size de tout les spooler en cours + config débit download)
|
||||
* Mot de passe personnalisé sur archive (pour l'instant on met le mot de passe mail)
|
||||
* Tabulator :
|
||||
* Faire meilleur recherche (avec OU / ET... (plusieurs champs quoi)
|
||||
* recherche dans toutes les colonnes
|
||||
* transformer en PDF jsPDF http://tabulator.info/docs/4.5/download#pdf
|
||||
* imprimer
|
||||
* Multi serveur ?
|
||||
|
||||
## Licence
|
||||
|
||||
By [David Mercereau](https://david.mercereau.info) Licence : [![Créative Common Zero](https://lighten-mailbox.zici.fr/assets/img/CC-Zero-badge.svg)](https://creativecommons.org/publicdomain/zero/1.0/deed.fr)
|
||||
|
|
|
@ -6,6 +6,13 @@ use PHPMailer\PHPMailer\PHPMailer;
|
|||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
function cleanTxt($char) {
|
||||
return preg_replace(
|
||||
"([^a-zA-Z0-9@-])",
|
||||
'',
|
||||
$char
|
||||
);
|
||||
}
|
||||
function splitEmailAddress($email){
|
||||
$split = explode('@', $email);
|
||||
$arr['user']=$split[0];
|
||||
|
@ -276,9 +283,8 @@ function imapAutoDetect($session_id, $user, $domain, $password) {
|
|||
return $imapConnexion;
|
||||
}
|
||||
|
||||
function jsonMessage($mod, $parser, $header, $messageEML, $folder, $format) {
|
||||
// Id sans les < > du début et de la fin
|
||||
$idClean=substr(substr($header->message_id, 0, -1), 1);
|
||||
function jsonMessage($mod, $idClean, $parser, $header, $messageEML, $folder, $format) {
|
||||
|
||||
// Enregistrement du json
|
||||
$arrayTmp['filename']=$idClean;
|
||||
$arrayTmp['message_id']='';
|
||||
|
@ -389,10 +395,8 @@ function jsonMessage($mod, $parser, $header, $messageEML, $folder, $format) {
|
|||
unset($arrayTmp);
|
||||
}
|
||||
|
||||
function saveMessage($session_id, $parser, $header, $messageEML, $folder, $format, $mod) {
|
||||
function saveMessage($session_id, $idClean, $parser, $header, $messageEML, $folder, $format, $mod) {
|
||||
global $config;
|
||||
// Id sans les < > du début et de la fin
|
||||
$idClean=substr(substr($header->message_id, 0, -1), 1);
|
||||
toLog(5, "idClean : ".$idClean);
|
||||
// Gestion des pièces jointes :
|
||||
|
||||
|
@ -540,8 +544,15 @@ function imapGetData($mod, $session_id, $server, $port, $user, $password, $secur
|
|||
//~ if ($mod != 'preview') {
|
||||
//~ array_push($dataJson, jsonMessage($mod, $parser, $header, $messageEML, $folder, $format));
|
||||
//~ } else {
|
||||
array_push($dataJson, jsonMessage($mod, $parser, $header, $messageEML, $folder, $format));
|
||||
saveMessage($session_id, $parser, $header, $messageEML, $folder, $format, $mod);
|
||||
|
||||
// Bug des messages sans id, on en génère un
|
||||
if (empty($header->message_id)) {
|
||||
$idClean=rand(1000, mt_getrandmax()).rand(1000, mt_getrandmax()).rand(1000, mt_getrandmax());
|
||||
} else {
|
||||
$idClean=cleanTxt(substr(substr($header->message_id, 0, -1), 1));
|
||||
}
|
||||
array_push($dataJson, jsonMessage($mod, $idClean, $parser, $header, $messageEML, $folder, $format));
|
||||
saveMessage($session_id, $idClean, $parser, $header, $messageEML, $folder, $format, $mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -557,8 +568,13 @@ function imapGetData($mod, $session_id, $server, $port, $user, $password, $secur
|
|||
}
|
||||
if ($mod != 'preview') {
|
||||
toLog(4, "Enregistrement json/js messages");
|
||||
file_put_contents($config['dir'][$mod].'/'.$session_id.'/messages.json', json_encode($dataJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||
file_put_contents($config['dir'][$mod].'/'.$session_id.'/messages.js', 'var messages_json = '.json_encode($dataJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE).';');
|
||||
if (count($dataJson) > 0) {
|
||||
file_put_contents($config['dir'][$mod].'/'.$session_id.'/messages.json', json_encode($dataJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_IGNORE));
|
||||
file_put_contents($config['dir'][$mod].'/'.$session_id.'/messages.js', 'var messages_json = '.json_encode($dataJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_IGNORE).';');
|
||||
if (json_last_error() != 0) {
|
||||
toLog(1, "Erreur dans le json : ".json_last_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$return['totalSize']=$totalSize;
|
||||
|
@ -802,8 +818,12 @@ function mailSend($to, $subject, $body) {
|
|||
$mail->setFrom($config['mailer']['from'], $config['mailer']['from']);
|
||||
if (isset($config['mailer']['replyto'])) { $mail->addReplyTo($config['mailer']['replyto']); }
|
||||
if (isset($config['mailer']['bcc'])) { $mail->AddBCC($config['mailer']['bcc']); }
|
||||
// Ccontenu
|
||||
$mail->addAddress($to);
|
||||
if ($config['maintenance']['active'] == true) {
|
||||
$mail->addAddress($config['maintenance']['emailForTest']);
|
||||
} else {
|
||||
$mail->addAddress($to);
|
||||
}
|
||||
// Contenu
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = $config['mailer']['subjectprefix'].' '.$subject;
|
||||
|
|
|
@ -166,7 +166,10 @@ if (isset($_GET['DeleteApproval']) && isset($_GET['session_id'])) {
|
|||
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3 form-box">
|
||||
<form role="form" action="" method="post" class="f1">
|
||||
<h3><?= _('Lighten your mailbox') ?></h3>
|
||||
<?php if (isset($_GET['session_id'])) {
|
||||
<?php
|
||||
if ($config['maintenance']['active'] == true && $_SERVER["REMOTE_ADDR"] != $config['maintenance']['ipForTest']) {
|
||||
echo '<p>'.$config['maintenance']['publicMsg'].'</p>';
|
||||
} elseif (isset($_GET['session_id'])) {
|
||||
|
||||
try {
|
||||
$session = $db->prepare("SELECT session.user, session.domain, session.what
|
||||
|
@ -352,7 +355,7 @@ if (isset($_GET['DeleteApproval']) && isset($_GET['session_id'])) {
|
|||
</div>
|
||||
<div class="f1-buttons">
|
||||
<input class="f1-cgu" type="checkbox" name="f1-cgu" id="f1-cgu">
|
||||
<label for="f1-cgu"><a href="./cgu.html"><?= _('I accept the general terms of use') ?></a></label>
|
||||
<label for="f1-cgu"><a href="./cgu.html" target="_blank"><?= _('I accept the general terms of use') ?></a></label>
|
||||
<button type="button" class="btn btn-next"><?= _('Next') ?></button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
Binary file not shown.
|
@ -8,7 +8,7 @@ msgstr ""
|
|||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-05 11:38+0100\n"
|
||||
"PO-Revision-Date: 2020-11-05 11:44+0100\n"
|
||||
"PO-Revision-Date: 2020-11-05 15:15+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr_FR\n"
|
||||
|
@ -208,7 +208,7 @@ msgstr "De"
|
|||
|
||||
#: index.php:315
|
||||
msgid "To"
|
||||
msgstr "A"
|
||||
msgstr "au"
|
||||
|
||||
#: index.php:322
|
||||
msgid "The emails that can be found"
|
||||
|
@ -377,7 +377,7 @@ msgstr "Nombre d'e-mails sélectionnés"
|
|||
|
||||
#: index.php:461
|
||||
msgid "Selected email sizes"
|
||||
msgstr "Tailles d'e-mail sélectionnées"
|
||||
msgstr "Taille d'e-mail sélectionnés"
|
||||
|
||||
#: index.php:465
|
||||
msgid "Over quota : Your archive exceeds the allowed quota size. A tip: reduce the time range (just 1 years, 6 months ...)"
|
||||
|
|
Loading…
Reference in a new issue