diff --git a/README.md b/README.md index 3f94b9c..33bda55 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ USER="web242" * Futur : * Orientation "serveur dédier" limiter a une liste de @domaine et ou un serveur + * Mode backup et non archive... en tout cas permettre la modification des texte de présentation... / incrustation dans le html... * 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) diff --git a/archive b/archive new file mode 120000 index 0000000..7367058 --- /dev/null +++ b/archive @@ -0,0 +1 @@ +/mnt/f2l/lighten-mailbox-archive/ \ No newline at end of file diff --git a/body-end.php b/body-end.php new file mode 100644 index 0000000..dc97f22 --- /dev/null +++ b/body-end.php @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/composer.json b/composer.json index 831a292..f942252 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,8 @@ "require": { "league/oauth2-client": "^2.4", "league/oauth2-google": "^3.0", - "pear/net_dns2": "^1.4", - "phpmailer/phpmailer": "^6.1" + "pear/net_dns2": "^1.5", + "phpmailer/phpmailer": "^6.8", + "php-mime-mail-parser/php-mime-mail-parser": "^7.1" } } diff --git a/daemon.note b/daemon.note new file mode 100644 index 0000000..769109a --- /dev/null +++ b/daemon.note @@ -0,0 +1,2 @@ +su - web242 -s /bin/bash -c "php /var/www/lighten-mailbox.zici.fr/web/daemon.php -d /var/www/lighten-mailbox.zici.fr/web" + diff --git a/daemon.php b/daemon.php index f822450..134e6ea 100644 --- a/daemon.php +++ b/daemon.php @@ -80,9 +80,9 @@ while (true) { // copy($config['dir']['templateTab']['html'], $config['dir']['archive']."/".$spoolerNextArray['session_id']."/"); // toLog(5, $config['dir']['templateTab']['html'] . '-'. $config['dir']['archive']."/".$spoolerNextArray['session_id']."/"); // Copy asset (lib) - recurse_copy($config['dir']['templateTab'], $config['dir']['archive']."/".$spoolerNextArray['session_id']); + recurse_copy($config['dir']['absolut'].'/'.$config['dir']['templateTab'], $config['dir']['absolut'].'/'.$config['dir']['archive']."/".$spoolerNextArray['session_id']); // On zip - if (Zip($config['dir']['archive']."/".$spoolerNextArray['session_id']."/", $config['dir']['archive']."/".$fileNameGen)) { + if (Zip($config['dir']['absolut'].'/'.$config['dir']['archive']."/".$spoolerNextArray['session_id']."/", $config['dir']['absolut'].'/'.$config['dir']['archive']."/".$fileNameGen)) { toLog(2, "Le ZIP est fait, on l'enregistre : ".$fileNameGen); // Enregistrement de l'archive : $req = $db->prepare("INSERT INTO archive (session_id, file) VALUES (:session_id, :file)"); @@ -94,7 +94,7 @@ while (true) { $req->bindParam('id', $spoolerNextArray['id'], PDO::PARAM_INT); $req->execute(); // Ménage - rrmdir($config['dir']['archive']."/".$spoolerNextArray['session_id']."/"); + rrmdir($config['dir']['absolut'].'/'.$config['dir']['archive']."/".$spoolerNextArray['session_id']."/"); // Notification archive prête $urlSpool=$config['baseUrl'].'spool_'.$spoolerNextArray['session_id']; @@ -117,12 +117,24 @@ while (true) { $req = $db->prepare("UPDATE spooler SET status = 0 WHERE id = :id"); $req->bindParam('id', $spoolerNextArray['id'], PDO::PARAM_INT); $req->execute(); + $mailSend_return = mailSend(username2email($spoolerNextArray['user'], $spoolerNextArray['domain']), _('Archive error'), _('Hello').'

+ +'._('Sorry but the archiving encountered too many errors for you to download.')); + if ($mailSend_return != true) { + toLog(1, 'Erreur mailSend '.$mailSend_return); + } } } else { - toLog(2, "Erreur dans le spooler sur la session ".$spoolerNextArray['session_id']); - $req = $db->prepare("UPDATE spooler SET status = 0 WHERE session_id = :id"); + toLog(2, "Erreur dans le spooler sur la session ".$spoolerNextArray['session_id'].' : '.$imapGetData_return['resultMsg']); + $req = $db->prepare("UPDATE spooler SET status = 0 WHERE id = :id"); $req->bindParam('id', $spoolerNextArray['id'], PDO::PARAM_INT); $req->execute(); + $mailSend_return = mailSend(username2email($spoolerNextArray['user'], $spoolerNextArray['domain']), _('Archive error'), _('Hello').'

+ +'._('Sorry but the archiving encountered too many errors for you to download.')); + if ($mailSend_return != true) { + toLog(1, 'Erreur mailSend '.$mailSend_return); + } } } else if ($spoolerNextArray['task'] == 2) { toLog(3, "Suppression demandé dans le spooler pour la session ".$spoolerNextArray['session_id']); @@ -152,8 +164,8 @@ while (true) { // Ménage dans els try { $archive = $db->prepare("SELECT session_id, file - FROM archive - WHERE dateCreate < '".date('Y-m-d', time()-$config['archive']['life'])."'"); + FROM archive + WHERE dateCreate < '".date('Y-m-d', time()-$config['archive']['life']*86400)."'"); $archive->execute(); } catch ( PDOException $e ) { toLog(1, "SELECT archive, error : ".$e->getMessage(), 0); @@ -164,7 +176,7 @@ while (true) { } else { foreach($archiveArrayFetch as $archiveFetch) { toLog(2, 'Suppression de l\'archives expiré : '.$archiveFetch['file']); - unlink($config['dir']['archive'].'/'.$archiveFetch['file']); + unlink($config['dir']['absolut'].'/'.$config['dir']['archive'].'/'.$archiveFetch['file']); $req = $db->prepare("DELETE FROM archive WHERE session_id = :session_id"); $req->bindParam('session_id', $archiveFetch['session_id'], PDO::PARAM_INT); $req->execute(); diff --git a/functions.php b/functions.php index 53160d2..0d7114c 100644 --- a/functions.php +++ b/functions.php @@ -14,6 +14,7 @@ function cleanTxt($char) { ); } function folderCleanName($folderName) { + #$folderName = utf8_encode(imap_utf7_decode()); $folderName = preg_replace( "(\[|\])", '', @@ -529,6 +530,7 @@ function imapGetData($mod, $session_id, $server, $port, $user, $password, $secur foreach($imapfolder as $folder) { // Connexion sur le dossier toLog(5, "Connexion sur le dossier ".$folder); + toLog(5, "Connexion sur le dossier ".folderCleanName($folder)); $serverImapOpenString = serverImapOpenString($server, $port, $secure, $auth, $cert, $folder, $format); sleep(2); imap_reopen($mailbox, $serverImapOpenString, null, 0);