Compare commits
No commits in common. "c448478c3994fece803fa03c1aa1878250fb7acc" and "aa5ae1824db35d49007fbfb9b8f03d25bcd54afc" have entirely different histories.
c448478c39
...
aa5ae1824d
11
README.md
11
README.md
@ -41,14 +41,3 @@ git clone https://git.kaz.bzh/KAZ/depollueur.git
|
|||||||
|
|
||||||
make -j $(nproc)
|
make -j $(nproc)
|
||||||
```
|
```
|
||||||
|
|
||||||
##Astuces
|
|
||||||
|
|
||||||
|
|
||||||
Pour la mise au point dans Kaz, il faut bloquer la mise à jour automatique avec :
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
touch /kaz/git/depollueur/dontupdage
|
|
||||||
/kaz/bin/container.sh stop jirafeau postfix; docker system prune; /kaz/bin/install.sh jirafeau postfix
|
|
||||||
```
|
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
a.php?s=mel@domain.org&t=password + [action] => manage account
|
a.php?s=mel@domain.org&t=password + [action] => manage account
|
||||||
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter]
|
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
use PHPMailer\PHPMailer\SMTP;
|
use PHPMailer\PHPMailer\SMTP;
|
||||||
use PHPMailer\PHPMailer\Exception;
|
use PHPMailer\PHPMailer\Exception;
|
||||||
@ -26,7 +25,6 @@ require (JIRAFEAU_ROOT . 'lib/lang.php');
|
|||||||
|
|
||||||
define ('VAR_TOKENS', $cfg ['var_root'].'tokens/');
|
define ('VAR_TOKENS', $cfg ['var_root'].'tokens/');
|
||||||
define ('VAR_TRACKS', $cfg ['var_root'].'tracks/');
|
define ('VAR_TRACKS', $cfg ['var_root'].'tracks/');
|
||||||
define ('VAR_LANG', $cfg ['var_root'].'lang/');
|
|
||||||
define ('VAR_PERIOD', $cfg ['var_root'].'period/');
|
define ('VAR_PERIOD', $cfg ['var_root'].'period/');
|
||||||
define ('VAR_FAKE', $cfg ['var_root'].'fake/');
|
define ('VAR_FAKE', $cfg ['var_root'].'fake/');
|
||||||
define ('VAR_ADMIN', $cfg ['var_root'].'admin/');
|
define ('VAR_ADMIN', $cfg ['var_root'].'admin/');
|
||||||
@ -40,7 +38,6 @@ define ('TOKEN_USE_LIMIT', "-2 hours");
|
|||||||
define ('TOKEN_LOGIN_LIMIT', "-15 minutes");
|
define ('TOKEN_LOGIN_LIMIT', "-15 minutes");
|
||||||
define ('TOKEN_LOGOUT_LIMIT', "-8 hours");
|
define ('TOKEN_LOGOUT_LIMIT', "-8 hours");
|
||||||
define ('DEFAULT_PERIOD', "month");
|
define ('DEFAULT_PERIOD', "month");
|
||||||
define ('DEFAULT_LANG', "fr");
|
|
||||||
|
|
||||||
define ('E_BAD_ARCHIVE_NAME', 'Bad archive name format');
|
define ('E_BAD_ARCHIVE_NAME', 'Bad archive name format');
|
||||||
define ('E_CREATE_ZIP', "Impossible de créer l'archive.");
|
define ('E_CREATE_ZIP', "Impossible de créer l'archive.");
|
||||||
@ -75,7 +72,7 @@ define ('M_WELCOME', "<p>Informations concernant le compte : <b>___SENDER___</b>
|
|||||||
define ('M_INCONSISTENT_DATES',
|
define ('M_INCONSISTENT_DATES',
|
||||||
" (dates incohéantes avec ___FILENAME___ : ___DIRTIME___ != ___FILETIME___)");
|
" (dates incohéantes avec ___FILENAME___ : ___DIRTIME___ != ___FILETIME___)");
|
||||||
|
|
||||||
define ('A_ACTION', 'a'); // action : T_LOGIN, T_LOGOUT, A_RECORD+(on|off), A_LANG(fr|en|br), A_PERIOD(minute|hour|day|week|month|quarter)
|
define ('A_ACTION', 'a'); // action : T_LOGIN, T_LOGOUT, A_RECORD+(on|off), A_PERIOD(minute|hour|day|week|month|quarter)
|
||||||
define ('A_GET', 'g'); // get archive
|
define ('A_GET', 'g'); // get archive
|
||||||
define ('A_HASH', 'h'); // file to update or delete
|
define ('A_HASH', 'h'); // file to update or delete
|
||||||
define ('A_OPEN_TOKEN', 'o'); // ask token
|
define ('A_OPEN_TOKEN', 'o'); // ask token
|
||||||
@ -84,7 +81,6 @@ define ('A_TOKEN', 't'); // session token
|
|||||||
define ('A_UPDATE', 'u'); // update perriod for file or archive
|
define ('A_UPDATE', 'u'); // update perriod for file or archive
|
||||||
define ('A_RECORD', 'r'); // get track status
|
define ('A_RECORD', 'r'); // get track status
|
||||||
define ('A_PERIOD', 'p'); // get period status
|
define ('A_PERIOD', 'p'); // get period status
|
||||||
define ('A_LANG', 'l'); // get lang status
|
|
||||||
define ('A_DELETE', 'd'); // delete file ou archive + (sender+token)
|
define ('A_DELETE', 'd'); // delete file ou archive + (sender+token)
|
||||||
define ('T_BAD_PASW', 'bad_psw');
|
define ('T_BAD_PASW', 'bad_psw');
|
||||||
define ('T_CREATE', "create");
|
define ('T_CREATE', "create");
|
||||||
@ -111,7 +107,6 @@ define ('T_ARCHIVE_TITLE', "archive_content");
|
|||||||
define ('T_ARCHIVE_MIME', "text/kaz_email_archive");
|
define ('T_ARCHIVE_MIME', "text/kaz_email_archive");
|
||||||
|
|
||||||
|
|
||||||
$langText = ['fr' => "Francais", 'br' => "Breton", 'en' => "english"];
|
|
||||||
$periodText = ['minute' => "minute", 'hour' => "heure", 'day' => "jour", 'week' => "semaine", 'month' => "mois"];
|
$periodText = ['minute' => "minute", 'hour' => "heure", 'day' => "jour", 'week' => "semaine", 'month' => "mois"];
|
||||||
// XXX , 'quarter' => "trimestre"];
|
// XXX , 'quarter' => "trimestre"];
|
||||||
$periodButton = ['hour' => ["🕕", ">1 heure"],
|
$periodButton = ['hour' => ["🕕", ">1 heure"],
|
||||||
@ -156,19 +151,6 @@ if (isset ($_REQUEST [A_PERIOD]) && !empty ($_REQUEST [A_PERIOD])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================================
|
|
||||||
if (isset ($_REQUEST [A_LANG]) && !empty ($_REQUEST [A_LANG])) {
|
|
||||||
if (!preg_match ("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i", $_REQUEST [A_LANG]))
|
|
||||||
$content = DEFAULT_LANG.NL;
|
|
||||||
else
|
|
||||||
$content = getSenderLang ($_REQUEST [A_LANG]).NL;
|
|
||||||
header ('HTTP/1.0 200 OK');
|
|
||||||
header ('Content-Length: ' . strlen ($content));
|
|
||||||
header ('Content-Type: text/plain');
|
|
||||||
echo $content;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
$doUpdate = false;
|
$doUpdate = false;
|
||||||
if (isset ($_REQUEST [A_UPDATE]) && !empty ($_REQUEST [A_UPDATE])) {
|
if (isset ($_REQUEST [A_UPDATE]) && !empty ($_REQUEST [A_UPDATE])) {
|
||||||
@ -211,29 +193,6 @@ function isSenderTrack ($sender) {
|
|||||||
return $sender && file_exists (VAR_TRACKS.$sender);
|
return $sender && file_exists (VAR_TRACKS.$sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================================
|
|
||||||
function setSenderLang ($sender, $lang) {
|
|
||||||
if (!$sender)
|
|
||||||
return;
|
|
||||||
if (!file_exists (VAR_LANG))
|
|
||||||
mkdir (VAR_LANG, 0755);
|
|
||||||
if (empty ($lang) || DEFAULT_LANG == $lang) {
|
|
||||||
rmSenderLang ($sender);
|
|
||||||
} else
|
|
||||||
file_put_contents (VAR_LANG.$sender, $lang.NL);
|
|
||||||
}
|
|
||||||
function rmSenderLang ($sender) {
|
|
||||||
if (!$sender)
|
|
||||||
return;
|
|
||||||
if (file_exists (VAR_LANG.$sender))
|
|
||||||
unlink (VAR_LANG.$sender);
|
|
||||||
}
|
|
||||||
function getSenderLang ($sender) {
|
|
||||||
if ($sender && file_exists (VAR_LANG.$sender))
|
|
||||||
return trim (file (VAR_LANG.$sender)[0]);
|
|
||||||
return DEFAULT_LANG;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
function setSenderPeriod ($sender, $period) {
|
function setSenderPeriod ($sender, $period) {
|
||||||
if (!$sender)
|
if (!$sender)
|
||||||
@ -762,17 +721,10 @@ if ($doDownload) {
|
|||||||
$modif = true;
|
$modif = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dstName = ($link ['file_name'] ? $link ['file_name'] : M_NO_FILENAME);
|
$srcName = $dstName = ($link ['file_name'] ? $link ['file_name'] : M_NO_FILENAME);
|
||||||
if (in_array ($dstName, $singleName)) {
|
if (in_array ($srcName, $singleName))
|
||||||
$dstFilename = $dstName;
|
for ($i = 0; $i < 10000; ++$i) {
|
||||||
$dstExtension = "";
|
$dstName = sprintf ("%s-%2d", $srcName, $i);
|
||||||
$dstExtensionPos = strrpos ($dstName, '.');
|
|
||||||
if ($dstExtensionPos) {
|
|
||||||
$dstFilename = substr ($dstName, 0, $dstExtensionPos);
|
|
||||||
$dstExtension = substr ($dstName, $dstExtensionPos);
|
|
||||||
}
|
|
||||||
for ($i = 1; $i < 10000; ++$i) {
|
|
||||||
$dstName = sprintf ("%s-%02d%s", $dstFilename, $i, $dstExtension);
|
|
||||||
if (!in_array ($dstName, $singleName)) {
|
if (!in_array ($dstName, $singleName)) {
|
||||||
if (isset ($archiveContent [T_RENAME]))
|
if (isset ($archiveContent [T_RENAME]))
|
||||||
++$archiveContent [T_RENAME];
|
++$archiveContent [T_RENAME];
|
||||||
@ -782,7 +734,6 @@ if ($doDownload) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$singleName [] = $dstName;
|
$singleName [] = $dstName;
|
||||||
$archiveContent [$cat][T_ENTRIES][] = [T_HASH => $link ['hash'], T_FILENAME => $dstName, T_CRYPT_KEY => $cryptKey, T_CRYPTED => $link ['crypted']];
|
$archiveContent [$cat][T_ENTRIES][] = [T_HASH => $link ['hash'], T_FILENAME => $dstName, T_CRYPT_KEY => $cryptKey, T_CRYPTED => $link ['crypted']];
|
||||||
}
|
}
|
||||||
@ -983,10 +934,6 @@ if (isset ($_REQUEST [A_ACTION])) {
|
|||||||
rmSenderTrack ($sender);
|
rmSenderTrack ($sender);
|
||||||
$message .= "Votre suivi à été mise à jour.";
|
$message .= "Votre suivi à été mise à jour.";
|
||||||
break;
|
break;
|
||||||
case preg_match ("/^".A_LANG."(".implode ("|", array_keys ($langText)).")$/i", $_REQUEST [A_ACTION], $matches):
|
|
||||||
setSenderLang ($sender, $matches [1]);
|
|
||||||
$message .= "Votre lang à été mise à jour.";
|
|
||||||
break;
|
|
||||||
case preg_match ("/^".A_PERIOD."(".implode ("|", array_keys ($periodText)).")$/i", $_REQUEST [A_ACTION], $matches):
|
case preg_match ("/^".A_PERIOD."(".implode ("|", array_keys ($periodText)).")$/i", $_REQUEST [A_ACTION], $matches):
|
||||||
setSenderPeriod ($sender, $matches [1]);
|
setSenderPeriod ($sender, $matches [1]);
|
||||||
$message .= "Votre période à été mise à jour.";
|
$message .= "Votre période à été mise à jour.";
|
||||||
@ -1087,7 +1034,6 @@ div.frame {border: 1px; border-style: solid; padding: 1em; margin: 1em;}
|
|||||||
$defaultChecked = [];
|
$defaultChecked = [];
|
||||||
$defaultChecked [isSenderTrack ($sender) ? "on" : "off"] = ' checked="checked"';
|
$defaultChecked [isSenderTrack ($sender) ? "on" : "off"] = ' checked="checked"';
|
||||||
$defaultChecked [getSenderPeriod ($sender)] = ' selected="selected"';
|
$defaultChecked [getSenderPeriod ($sender)] = ' selected="selected"';
|
||||||
$defaultChecked [getSenderLang ($sender)] = ' selected="selected"';
|
|
||||||
echo
|
echo
|
||||||
'<form method="post">'.
|
'<form method="post">'.
|
||||||
'Je veux que Kaz suive tous mes futurs envois: '.
|
'Je veux que Kaz suive tous mes futurs envois: '.
|
||||||
@ -1103,15 +1049,6 @@ echo
|
|||||||
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
||||||
foreach ($periodText as $item => $text)
|
foreach ($periodText as $item => $text)
|
||||||
echo ' <option value="'.A_PERIOD.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
echo ' <option value="'.A_PERIOD.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
||||||
echo
|
|
||||||
'</select> '.
|
|
||||||
'<button type="submit">'."valider".'</button>'.
|
|
||||||
'</form>'.
|
|
||||||
'<form method="post">'.
|
|
||||||
'Je préfère envoyer mes messages en langue '.
|
|
||||||
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
|
||||||
foreach ($langText as $item => $text)
|
|
||||||
echo ' <option value="'.A_LANG.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
|
||||||
echo
|
echo
|
||||||
'</select> '.
|
'</select> '.
|
||||||
'<button type="submit">'."valider".'</button>'.
|
'<button type="submit">'."valider".'</button>'.
|
||||||
|
@ -46,7 +46,7 @@ $link = jirafeau_get_link($link_name);
|
|||||||
if (count($link) == 0) {
|
if (count($link) == 0) {
|
||||||
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
||||||
echo '<div class="error"><p>' . t('FILE_404') .
|
echo '<div class="error"><p>' . t('FILE_404') .
|
||||||
'</p></div>';
|
'</p></div>';
|
||||||
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ if (!file_exists(VAR_FILES . $p . $link['hash'])) {
|
|||||||
jirafeau_delete_link($link_name);
|
jirafeau_delete_link($link_name);
|
||||||
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
||||||
echo '<div class="error"><p>'.t('FILE_NOT_AVAIL').
|
echo '<div class="error"><p>'.t('FILE_NOT_AVAIL').
|
||||||
'</p></div>';
|
'</p></div>';
|
||||||
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -86,28 +86,27 @@ if (!empty($delete_code) && $delete_code == $link['link_code']) {
|
|||||||
if (isset($_POST['do_delete'])) {
|
if (isset($_POST['do_delete'])) {
|
||||||
jirafeau_delete_link($link_name);
|
jirafeau_delete_link($link_name);
|
||||||
echo '<div class="message"><p>'.t('FILE_DELETED').
|
echo '<div class="message"><p>'.t('FILE_DELETED').
|
||||||
'</p></div>';
|
'</p></div>';
|
||||||
} else { ?>
|
} else { ?>
|
||||||
<div>
|
<div>
|
||||||
<form action="f.php" method="post" id="submit_delete_post" class="form login">
|
<form action="f.php" method="post" id="submit_delete_post" class="form login">
|
||||||
<input type="hidden" name="do_delete" value=1/>
|
<input type="hidden" name="do_delete" value=1/>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend> <?php echo t('CONFIRM_DEL') ?> </legend>
|
<legend> <?php echo t('CONFIRM_DEL') ?> </legend>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<?php echo t('GONNA_DEL') . ' "' . jirafeau_escape($link['file_name']) . '" (' . jirafeau_human_size($link['file_size']) . ').' ?>
|
<?php echo t('GONNA_DEL') . ' "' . jirafeau_escape($link['file_name']) . '" (' . jirafeau_human_size($link['file_size']) . ').' ?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<?php echo t('USING_SERVICE'). ' <a href="tos.php" target="_blank" rel="noopener noreferrer">' . t('TOS') . '</a>.' ?>
|
<?php echo t('USING_SERVICE'). ' <a href="tos.php" target="_blank" rel="noopener noreferrer">' . t('TOS') . '</a>.' ?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<input type="submit" id="submit_delete" value="<?php echo t('DELETE'); ?>"
|
<input type="submit" id="submit_delete" value="<?php echo t('DELETE'); ?>" <?php $action_delete="'f.php?h=' . $link_name . '&d=' . $delete_code'; document.getElementById('submit_delete').submit ();"; ?>
|
||||||
<?php $action_delete="'f.php?h=' . $link_name . '&d=' . $delete_code'; document.getElementById('submit_delete').submit ();"; ?>
|
onclick="document.getElementById('submit_delete_post').action='<?php echo $action_delete; ?>"/>
|
||||||
onclick="document.getElementById('submit_delete_post').action='<?php echo $action_delete; ?>" />
|
</td></tr>
|
||||||
</td></tr>
|
</table>
|
||||||
</table>
|
</fieldset></form></div><?php
|
||||||
</fieldset></form></div><?php
|
}
|
||||||
}
|
|
||||||
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -116,9 +115,9 @@ if ($link['time'] != JIRAFEAU_INFINITY && time() > $link['time']) {
|
|||||||
jirafeau_delete_link($link_name);
|
jirafeau_delete_link($link_name);
|
||||||
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
||||||
echo '<div class="error"><p>'.
|
echo '<div class="error"><p>'.
|
||||||
t('FILE_EXPIRED') . ' ' .
|
t('FILE_EXPIRED') . ' ' .
|
||||||
t('FILE_DELETED') .
|
t('FILE_DELETED') .
|
||||||
'</p></div>';
|
'</p></div>';
|
||||||
require(JIRAFEAU_ROOT . 'lib/template/footer.php');
|
require(JIRAFEAU_ROOT . 'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -126,7 +125,7 @@ if ($link['time'] != JIRAFEAU_INFINITY && time() > $link['time']) {
|
|||||||
if (empty($crypt_key) && $link['crypted']) {
|
if (empty($crypt_key) && $link['crypted']) {
|
||||||
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
||||||
echo '<div class="error"><p>' . t('FILE_404') .
|
echo '<div class="error"><p>' . t('FILE_404') .
|
||||||
'</p></div>';
|
'</p></div>';
|
||||||
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -140,16 +139,16 @@ if (!empty($link['key'])) {
|
|||||||
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
||||||
echo '<div>' .
|
echo '<div>' .
|
||||||
'<form action="f.php" method="post" id="submit_post" class="form login">'; ?>
|
'<form action="f.php" method="post" id="submit_post" class="form login">'; ?>
|
||||||
<input type = "hidden" name = "jirafeau" value = "<?php echo JIRAFEAU_VERSION ?>"/><?php
|
<input type = "hidden" name = "jirafeau" value = "<?php echo JIRAFEAU_VERSION ?>"/><?php
|
||||||
echo '<fieldset>' .
|
echo '<fieldset>' .
|
||||||
'<legend>' . t('PSW_PROTEC') .
|
'<legend>' . t('PSW_PROTEC') .
|
||||||
'</legend><table><tr><td>' .
|
'</legend><table><tr><td>' .
|
||||||
t('GIMME_PSW') . ' : ' .
|
t('GIMME_PSW') . ' : ' .
|
||||||
'<input type = "password" name = "key" />' .
|
'<input type = "password" name = "key" />' .
|
||||||
'</td></tr>' .
|
'</td></tr>' .
|
||||||
'<tr><td>' .
|
'<tr><td>' .
|
||||||
t('USING_SERVICE'). ' <a href="tos.php" target="_blank" rel="noopener noreferrer">' . t('TOS') . '</a>.' .
|
t('USING_SERVICE'). ' <a href="tos.php" target="_blank" rel="noopener noreferrer">' . t('TOS') . '</a>.' .
|
||||||
'</td></tr>';
|
'</td></tr>';
|
||||||
|
|
||||||
if ($link['onetime'] == 'O') {
|
if ($link['onetime'] == 'O') {
|
||||||
echo '<tr><td id="self_destruct">' .
|
echo '<tr><td id="self_destruct">' .
|
||||||
@ -164,13 +163,13 @@ if (!empty($link['key'])) {
|
|||||||
document.getElementById('submit_download').submit ();"/><?php
|
document.getElementById('submit_download').submit ();"/><?php
|
||||||
if ($cfg['preview'] && jirafeau_is_viewable($link['mime_type'])) {
|
if ($cfg['preview'] && jirafeau_is_viewable($link['mime_type'])) {
|
||||||
?><input type="submit" id = "submit_preview" value="<?php echo t('PREVIEW'); ?>"
|
?><input type="submit" id = "submit_preview" value="<?php echo t('PREVIEW'); ?>"
|
||||||
onclick="document.getElementById('submit_post').action='<?php
|
onclick="document.getElementById('submit_post').action='<?php
|
||||||
echo 'f.php?h=' . $link_name . '&p=1';
|
echo 'f.php?h=' . $link_name . '&p=1';
|
||||||
if (!empty($crypt_key)) {
|
if (!empty($crypt_key)) {
|
||||||
echo '&k=' . urlencode($crypt_key);
|
echo '&k=' . urlencode($crypt_key);
|
||||||
} ?>';
|
} ?>';
|
||||||
document.getElementById('submit_preview').submit ();"/><?php
|
document.getElementById('submit_preview').submit ();"/><?php
|
||||||
}
|
}
|
||||||
echo '</td></tr></table></fieldset></form></div>';
|
echo '</td></tr></table></fieldset></form></div>';
|
||||||
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
@ -182,7 +181,7 @@ if (!empty($link['key'])) {
|
|||||||
sleep(2);
|
sleep(2);
|
||||||
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
||||||
echo '<div class="error"><p>' . t('ACCESS_KO') .
|
echo '<div class="error"><p>' . t('ACCESS_KO') .
|
||||||
'</p></div>';
|
'</p></div>';
|
||||||
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -192,38 +191,38 @@ if (!empty($link['key'])) {
|
|||||||
if (!$password_challenged && !$do_download && !$do_preview) {
|
if (!$password_challenged && !$do_download && !$do_preview) {
|
||||||
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
require(JIRAFEAU_ROOT.'lib/template/header.php');
|
||||||
echo '<div>' .
|
echo '<div>' .
|
||||||
'<form action="f.php" method="post" id="submit_post" class="form download">'; ?>
|
'<form action="f.php" method="post" id="submit_post" class="form download">'; ?>
|
||||||
<input type = "hidden" name = "jirafeau" value = "<?php echo JIRAFEAU_VERSION ?>"/><?php
|
<input type = "hidden" name = "jirafeau" value = "<?php echo JIRAFEAU_VERSION ?>"/><?php
|
||||||
echo '<fieldset><legend>' . jirafeau_escape($link['file_name']) . '</legend><table>' .
|
echo '<fieldset><legend>' . jirafeau_escape($link['file_name']) . '</legend><table>' .
|
||||||
'<tr><td>' .
|
'<tr><td>' .
|
||||||
t('NOW_DOWNLOADING') . ' "' . jirafeau_escape($link['file_name']) . '" (' . jirafeau_human_size($link['file_size']) . ').' .
|
t('NOW_DOWNLOADING') . ' "' . jirafeau_escape($link['file_name']) . '" (' . jirafeau_human_size($link['file_size']) . ').' .
|
||||||
'</td></tr>' .
|
'</td></tr>' .
|
||||||
'<tr><td>' .
|
'<tr><td>' .
|
||||||
t('USING_SERVICE'). ' <a href="tos.php" target="_blank" rel="noopener noreferrer">' . t('TOS') . '</a>.' .
|
t('USING_SERVICE'). ' <a href="tos.php" target="_blank" rel="noopener noreferrer">' . t('TOS') . '</a>.' .
|
||||||
'</td></tr>';
|
'</td></tr>';
|
||||||
|
|
||||||
if ($link['onetime'] == 'O') {
|
if ($link['onetime'] == 'O') {
|
||||||
echo '<tr><td id="self_destruct">' .
|
echo '<tr><td id="self_destruct">' .
|
||||||
t('AUTO_DESTRUCT') .
|
t('AUTO_DESTRUCT') .
|
||||||
'</td></tr>';
|
'</td></tr>';
|
||||||
} ?>
|
} ?>
|
||||||
<tr><td><input type="submit" id = "submit_download" value="<?php echo t('DL'); ?>"
|
<tr><td><input type="submit" id = "submit_download" value="<?php echo t('DL'); ?>"
|
||||||
onclick="document.getElementById('submit_post').action='<?php
|
onclick="document.getElementById('submit_post').action='<?php
|
||||||
echo 'f.php?h=' . $link_name . '&d=1';
|
echo 'f.php?h=' . $link_name . '&d=1';
|
||||||
if (!empty($crypt_key)) {
|
if (!empty($crypt_key)) {
|
||||||
echo '&k=' . urlencode($crypt_key);
|
echo '&k=' . urlencode($crypt_key);
|
||||||
} ?>';
|
} ?>';
|
||||||
document.getElementById('submit_post').submit ();"/><?php
|
document.getElementById('submit_post').submit ();"/><?php
|
||||||
|
|
||||||
if ($cfg['preview'] && jirafeau_is_viewable($link['mime_type'])) {
|
if ($cfg['preview'] && jirafeau_is_viewable($link['mime_type'])) {
|
||||||
?><input type="submit" id = "submit_preview" value="<?php echo t('PREVIEW'); ?>"
|
?><input type="submit" id = "submit_preview" value="<?php echo t('PREVIEW'); ?>"
|
||||||
onclick="document.getElementById('submit_post').action='<?php
|
onclick="document.getElementById('submit_post').action='<?php
|
||||||
echo 'f.php?h=' . $link_name . '&p=1';
|
echo 'f.php?h=' . $link_name . '&p=1';
|
||||||
if (!empty($crypt_key)) {
|
if (!empty($crypt_key)) {
|
||||||
echo '&k=' . urlencode($crypt_key);
|
echo '&k=' . urlencode($crypt_key);
|
||||||
} ?>';
|
} ?>';
|
||||||
document.getElementById('submit_post').submit ();"/><?php
|
document.getElementById('submit_post').submit ();"/><?php
|
||||||
}
|
}
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
echo '</table></fieldset></form></div>';
|
echo '</table></fieldset></form></div>';
|
||||||
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
require(JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
@ -289,4 +288,3 @@ if ($link['onetime'] == 'O') {
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -48,8 +48,7 @@ EX_TEMPFAIL=75
|
|||||||
EX_UNAVAILABLE=69
|
EX_UNAVAILABLE=69
|
||||||
EX_TOO_LARGE=552
|
EX_TOO_LARGE=552
|
||||||
INSPECT_DIR=/var/spool/filter
|
INSPECT_DIR=/var/spool/filter
|
||||||
DIR_LOG=/var/log/mail
|
FIC_LOG=/var/log/mail/filter.log
|
||||||
FIC_LOG=${DIR_LOG}/filter.log
|
|
||||||
SENDMAIL="/usr/sbin/sendmail -G -i"
|
SENDMAIL="/usr/sbin/sendmail -G -i"
|
||||||
MAILS=/tmp/FILTER
|
MAILS=/tmp/FILTER
|
||||||
MAX_KEEP_IN_MAIL=5ki
|
MAX_KEEP_IN_MAIL=5ki
|
||||||
@ -61,13 +60,10 @@ JIRAFEAU_LOCAL=http://depot
|
|||||||
JIRAFEAU_TIME=month
|
JIRAFEAU_TIME=month
|
||||||
MD5_CMD=/usr/bin/md5sum
|
MD5_CMD=/usr/bin/md5sum
|
||||||
DISCLAMER_CMD=altermime
|
DISCLAMER_CMD=altermime
|
||||||
MAX_FINAL_SIZE=307200 # 300ki
|
MAX_FINAL_SIZE=204800 # 200ki
|
||||||
ARCHIVE_TITLE="archive_content"
|
ARCHIVE_TITLE="archive_content"
|
||||||
ARCHIVE_MIME="text/kaz_email_archive"
|
ARCHIVE_MIME="text/kaz_email_archive"
|
||||||
|
|
||||||
KEEP_FAILED=true
|
|
||||||
DEBUG=
|
|
||||||
|
|
||||||
#################### FONCTIONS ############################################
|
#################### FONCTIONS ############################################
|
||||||
BOLD='[1m'
|
BOLD='[1m'
|
||||||
RED='[0;31m'
|
RED='[0;31m'
|
||||||
@ -79,9 +75,8 @@ CYAN='[0;36m'
|
|||||||
NC='[0m' # No Color
|
NC='[0m' # No Color
|
||||||
NL='
|
NL='
|
||||||
'
|
'
|
||||||
|
|
||||||
#--------------------- Fichier de LOG -------------------
|
#--------------------- Fichier de LOG -------------------
|
||||||
LOG_FIC () {
|
LOG_FIC() {
|
||||||
echo "${BLUE}$(date +%d-%m-%Y-%H-%M-%S)${NC} : $*" >> "${FIC_LOG}"
|
echo "${BLUE}$(date +%d-%m-%Y-%H-%M-%S)${NC} : $*" >> "${FIC_LOG}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,12 +85,6 @@ quitFilter () {
|
|||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
keepFailed () {
|
|
||||||
[ -z "${KEEP_FAILED}" ] && return
|
|
||||||
mkdir -p "${DIR_LOG}/pb/"
|
|
||||||
cp "$1" "${DIR_LOG}/pb/"
|
|
||||||
}
|
|
||||||
|
|
||||||
#################### MAIN #################################################
|
#################### MAIN #################################################
|
||||||
echo "${NL}" >> "${FIC_LOG}"
|
echo "${NL}" >> "${FIC_LOG}"
|
||||||
LOG_FIC "${GREEN}######################################## filter start${NC}"
|
LOG_FIC "${GREEN}######################################## filter start${NC}"
|
||||||
@ -135,7 +124,7 @@ ARCHIVE_CONTENT="${REP_PIECE_JOINTE}/archive-content.txt"
|
|||||||
JIRAFEAU_ERROR="${REP_PIECE_JOINTE}/jirafeau-error.txt"
|
JIRAFEAU_ERROR="${REP_PIECE_JOINTE}/jirafeau-error.txt"
|
||||||
|
|
||||||
# Clean up when done or when aborting.
|
# Clean up when done or when aborting.
|
||||||
[ -z "${DEBUG}" ] && trap "rm -rf in.$$ in.$$.altered ${REP_PIECE_JOINTE}" 0 1 2 3 15
|
trap "rm -rf in.$$ in.$$.altered ${REP_PIECE_JOINTE}" 0 1 2 3 15
|
||||||
|
|
||||||
if ! cat > "in.$$"; then
|
if ! cat > "in.$$"; then
|
||||||
LOG_FIC "${RED}Cannot save mail to file${NC}"
|
LOG_FIC "${RED}Cannot save mail to file${NC}"
|
||||||
@ -143,7 +132,8 @@ if ! cat > "in.$$"; then
|
|||||||
fi
|
fi
|
||||||
LOG_FIC "\n" \
|
LOG_FIC "\n" \
|
||||||
" size: ${YELLOW}$(wc -c < "${INSPECT_DIR}/in.$$")${NC}"
|
" size: ${YELLOW}$(wc -c < "${INSPECT_DIR}/in.$$")${NC}"
|
||||||
[ -n "${DEBUG}" ] && (mkdir -p "${DIR_LOG}/pb/" ; cp "${INSPECT_DIR}/in.$$" "${DIR_LOG}/pb/in.$$.orig")
|
# XXX trace
|
||||||
|
# cp "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.bak"
|
||||||
|
|
||||||
mkdir -p "${REP_PIECE_JOINTE}/"
|
mkdir -p "${REP_PIECE_JOINTE}/"
|
||||||
>"${OLD_LINKS}"
|
>"${OLD_LINKS}"
|
||||||
@ -156,7 +146,8 @@ echo "time: ${DATE_TEMPS}\nid: $(date +%s)" > "${ARCHIVE_CONTENT}"
|
|||||||
LOG_FIC "${CYAN}${SHRINK_CMD} -u \"${INSPECT_DIR}/in.$$\" 2>> \"${FIC_LOG}\" > \"${OLD_LINKS}\"${NC}"
|
LOG_FIC "${CYAN}${SHRINK_CMD} -u \"${INSPECT_DIR}/in.$$\" 2>> \"${FIC_LOG}\" > \"${OLD_LINKS}\"${NC}"
|
||||||
"${SHRINK_CMD}" -u "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" > "${OLD_LINKS}"
|
"${SHRINK_CMD}" -u "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" > "${OLD_LINKS}"
|
||||||
|
|
||||||
cat "${OLD_LINKS}" | grep "${JIRAFEAU_URL}" | while read REMOTE_LINK; do
|
cat "${OLD_LINKS}" | grep "${JIRAFEAU_URL}" | while read REMOTE_LINK
|
||||||
|
do
|
||||||
REMOTE_REF=$(echo "${REMOTE_LINK}" | sed -e 's/.*h=\([^&]*\).*/\1/' -e 's/.*http.*//')
|
REMOTE_REF=$(echo "${REMOTE_LINK}" | sed -e 's/.*h=\([^&]*\).*/\1/' -e 's/.*http.*//')
|
||||||
[ -z "${REMOTE_REF}" ] && continue
|
[ -z "${REMOTE_REF}" ] && continue
|
||||||
REMOTE_KEY=$(echo "${REMOTE_LINK}" | grep "k=" | sed 's%.*k=\([^&]*\).*%\1%')
|
REMOTE_KEY=$(echo "${REMOTE_LINK}" | grep "k=" | sed 's%.*k=\([^&]*\).*%\1%')
|
||||||
@ -170,8 +161,10 @@ LOG_FIC " - archive starts with: ${NL}${YELLOW}$(cat ${ARCHIVE_CONTENT})${NC}"
|
|||||||
# Etape extraction des pieces jointes
|
# Etape extraction des pieces jointes
|
||||||
LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${INSPECT_DIR}/in.$$ ${NC}"
|
LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${INSPECT_DIR}/in.$$ ${NC}"
|
||||||
"${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" -d "${REP_PIECE_JOINTE}" "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" | {
|
"${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" -d "${REP_PIECE_JOINTE}" "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" | {
|
||||||
while read ATTACH_TMP_NAME; do
|
while read ATTACH_TMP_NAME
|
||||||
if [ -d "${ATTACH_TMP_NAME}" ]; then
|
do
|
||||||
|
if [ -d "${ATTACH_TMP_NAME}" ]
|
||||||
|
then
|
||||||
ATTACH_MEDIA="${ATTACH_TMP_NAME}/media"
|
ATTACH_MEDIA="${ATTACH_TMP_NAME}/media"
|
||||||
ATTACH_NAME=$(grep "^Name: " "${ATTACH_TMP_NAME}/meta" | cut -c 7- )
|
ATTACH_NAME=$(grep "^Name: " "${ATTACH_TMP_NAME}/meta" | cut -c 7- )
|
||||||
ATTACH_CONTENT_TYPE=$(grep "^Content-Type: " "${ATTACH_TMP_NAME}/meta" | cut -c 15- )
|
ATTACH_CONTENT_TYPE=$(grep "^Content-Type: " "${ATTACH_TMP_NAME}/meta" | cut -c 15- )
|
||||||
@ -192,8 +185,8 @@ LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${IN
|
|||||||
case "${JIR_TOKEN}" in
|
case "${JIR_TOKEN}" in
|
||||||
"" | no | *Error* | \<* )
|
"" | no | *Error* | \<* )
|
||||||
LOG_FIC " - ${RED}Can't upload <${ATTACH_NAME}> <${ATTACH_CONTENT_TYPE}> <$(wc -c < "${ATTACH_MEDIA}")> (${JIR_TOKEN}) <in.$$.bak>. It will be not change in e-mail.${NC}"
|
LOG_FIC " - ${RED}Can't upload <${ATTACH_NAME}> <${ATTACH_CONTENT_TYPE}> <$(wc -c < "${ATTACH_MEDIA}")> (${JIR_TOKEN}) <in.$$.bak>. It will be not change in e-mail.${NC}"
|
||||||
echo "url:"
|
echo "new:"
|
||||||
keepFailed "${INSPECT_DIR}/in.$$"
|
cp "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.bak"
|
||||||
echo "UPLOAD_FAIL" >> "${JIRAFEAU_ERROR}"
|
echo "UPLOAD_FAIL" >> "${JIRAFEAU_ERROR}"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
@ -223,7 +216,7 @@ LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${IN
|
|||||||
"" | no | *Error* | \<* )
|
"" | no | *Error* | \<* )
|
||||||
LOG_FIC " - ${RED}can't upload archive (${JIR_TOKEN}) <in.$$.bak>, substitution couldn't be done${NC}"
|
LOG_FIC " - ${RED}can't upload archive (${JIR_TOKEN}) <in.$$.bak>, substitution couldn't be done${NC}"
|
||||||
echo "arch: bad"
|
echo "arch: bad"
|
||||||
keepFailed "${INSPECT_DIR}/in.$$"
|
cp "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.bak"
|
||||||
echo "ARCHIVE_FAIL" >> "${JIRAFEAU_ERROR}"
|
echo "ARCHIVE_FAIL" >> "${JIRAFEAU_ERROR}"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
@ -240,7 +233,8 @@ LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${IN
|
|||||||
LOG_FIC "${CYAN}${SHRINK_CMD} -s \"${MAX_KEEP_IN_MAIL}\" \"${INSPECT_DIR}/in.$$\" \"${INSPECT_DIR}/in.$$.altered\" 2>> \"${FIC_LOG}\"${NC}"
|
LOG_FIC "${CYAN}${SHRINK_CMD} -s \"${MAX_KEEP_IN_MAIL}\" \"${INSPECT_DIR}/in.$$\" \"${INSPECT_DIR}/in.$$.altered\" 2>> \"${FIC_LOG}\"${NC}"
|
||||||
} | "${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.altered" 2>> "${FIC_LOG}"
|
} | "${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.altered" 2>> "${FIC_LOG}"
|
||||||
|
|
||||||
[ -n "${DEBUG}" ] && (mkdir -p "${DIR_LOG}/pb/" ; cp "${INSPECT_DIR}/in.$$.altered" "${DIR_LOG}/pb/in.$$.altered")
|
# XXX trace
|
||||||
|
# cp "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.altered" /var/mail/tmp/
|
||||||
|
|
||||||
if [ -s "${JIRAFEAU_ERROR}" ]; then
|
if [ -s "${JIRAFEAU_ERROR}" ]; then
|
||||||
LOG_FIC " - ${RED}upload fail${NC}"
|
LOG_FIC " - ${RED}upload fail${NC}"
|
||||||
@ -253,7 +247,6 @@ if [ "$(wc -l < "${ARCHIVE_CONTENT}")" -ge 3 ]; then
|
|||||||
actualSize=$(wc -c < "${INSPECT_DIR}/in.$$.altered")
|
actualSize=$(wc -c < "${INSPECT_DIR}/in.$$.altered")
|
||||||
if [ ${actualSize} -ge $MAX_FINAL_SIZE ]; then
|
if [ ${actualSize} -ge $MAX_FINAL_SIZE ]; then
|
||||||
LOG_FIC " - ${RED}too big even after diet ${INSPECT_DIR}/in.$$.altered (${actualSize})${NC}"
|
LOG_FIC " - ${RED}too big even after diet ${INSPECT_DIR}/in.$$.altered (${actualSize})${NC}"
|
||||||
keepFailed "${INSPECT_DIR}/in.$$"
|
|
||||||
quitFilter "${EX_TOO_LARGE}"
|
quitFilter "${EX_TOO_LARGE}"
|
||||||
fi
|
fi
|
||||||
LOG_FIC " - ${GREEN}send with : ${SENDMAIL} $@ ${INSPECT_DIR}/in.$$.altered ${NC}"
|
LOG_FIC " - ${GREEN}send with : ${SENDMAIL} $@ ${INSPECT_DIR}/in.$$.altered ${NC}"
|
||||||
@ -263,7 +256,6 @@ else
|
|||||||
actualSize=$(wc -c < "${INSPECT_DIR}/in.$$")
|
actualSize=$(wc -c < "${INSPECT_DIR}/in.$$")
|
||||||
if [ ${actualSize} -ge $MAX_FINAL_SIZE ]; then
|
if [ ${actualSize} -ge $MAX_FINAL_SIZE ]; then
|
||||||
LOG_FIC " - ${RED}too big without diet ${INSPECT_DIR}/in.$$ (${actualSize}) ${NC}"
|
LOG_FIC " - ${RED}too big without diet ${INSPECT_DIR}/in.$$ (${actualSize}) ${NC}"
|
||||||
keepFailed "${INSPECT_DIR}/in.$$"
|
|
||||||
quitFilter "${EX_TOO_LARGE}"
|
quitFilter "${EX_TOO_LARGE}"
|
||||||
fi
|
fi
|
||||||
LOG_FIC " - ${GREEN}send without attach file${NC}"
|
LOG_FIC " - ${GREEN}send without attach file${NC}"
|
||||||
|
@ -32,15 +32,14 @@
|
|||||||
// knowledge of the CeCILL-B license and that you accept its terms. //
|
// knowledge of the CeCILL-B license and that you accept its terms. //
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <algorithm>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <regex>
|
#include <algorithm>
|
||||||
#include <set>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "kazDebug.hpp"
|
#include "kazDebug.hpp"
|
||||||
#include "kazMisc.hpp"
|
#include "kazMisc.hpp"
|
||||||
@ -56,10 +55,6 @@ static const string TMPL_DOWNLOAD = "{{DOWNLOAD}}";
|
|||||||
static const string TMPL_FILENAME = "{{FILENAME}}";
|
static const string TMPL_FILENAME = "{{FILENAME}}";
|
||||||
static const string CID = "cid:";
|
static const string CID = "cid:";
|
||||||
|
|
||||||
// "l=/" => v1 compatibility
|
|
||||||
static const regex archiveURLSignature (".*(([&?]g=)|([&?]l=/)).*");
|
|
||||||
|
|
||||||
|
|
||||||
static const string KAZ_PLAIN_HR = "______________________________________________________________________________";
|
static const string KAZ_PLAIN_HR = "______________________________________________________________________________";
|
||||||
static const string KAZ_PLAIN_START = "~~ PJ-KAZ !"; // don't end whith space
|
static const string KAZ_PLAIN_START = "~~ PJ-KAZ !"; // don't end whith space
|
||||||
static const string KAZ_PLAIN_STOP = KAZ_PLAIN_START+" ~~";
|
static const string KAZ_PLAIN_STOP = KAZ_PLAIN_START+" ~~";
|
||||||
@ -98,8 +93,8 @@ vector <string>
|
|||||||
Attachment::stringsToUpdate ({KAZ_PLAIN_START, "\""+CID});
|
Attachment::stringsToUpdate ({KAZ_PLAIN_START, "\""+CID});
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
const string MainAttachment::templatePlainAddLink (" * "+TMPL_FILENAME+" <"+TMPL_DOWNLOAD+">\r\n");
|
const string MainAttachment::templatePlainAddLink (" - "+TMPL_DOWNLOAD+" "+TMPL_FILENAME+"\r\n");
|
||||||
const string MainAttachment::templatePlainAllLink ("\r\n * "+KAZ_PLAIN_DOWLOAD_ALL+" <"+TMPL_DOWNLOAD+">\r\n");
|
const string MainAttachment::templatePlainAllLink ("\r\n"+KAZ_PLAIN_DOWLOAD_ALL+"\r\n * "+TMPL_DOWNLOAD+"\r\n");
|
||||||
|
|
||||||
const string MainAttachment::templateHtmlHeader (KAZ_HTML_START+"<p style=\"clear: left; padding: 1pc 0 0 0; font-size:10px; color:#969696;\">"+KAZ_PLAIN_START+"</p><hr>\n"
|
const string MainAttachment::templateHtmlHeader (KAZ_HTML_START+"<p style=\"clear: left; padding: 1pc 0 0 0; font-size:10px; color:#969696;\">"+KAZ_PLAIN_START+"</p><hr>\n"
|
||||||
"<div class=\"kaz\">"
|
"<div class=\"kaz\">"
|
||||||
@ -172,7 +167,6 @@ MainAttachment::addLink (string &plain, string &html, const string &url, const s
|
|||||||
plain += plainNewOneLink;
|
plain += plainNewOneLink;
|
||||||
string htmlNewOneLink (templateHtmlAddLink);
|
string htmlNewOneLink (templateHtmlAddLink);
|
||||||
string codedUrl (url);
|
string codedUrl (url);
|
||||||
// XXX amp ?
|
|
||||||
replaceAll (codedUrl, "&", "&");
|
replaceAll (codedUrl, "&", "&");
|
||||||
replaceAll (htmlNewOneLink, TMPL_DOWNLOAD, codedUrl);
|
replaceAll (htmlNewOneLink, TMPL_DOWNLOAD, codedUrl);
|
||||||
replaceAll (htmlNewOneLink, TMPL_FILENAME, name);
|
replaceAll (htmlNewOneLink, TMPL_FILENAME, name);
|
||||||
@ -224,9 +218,9 @@ MainAttachment::getDisclaim (string &plain, string &html) const {
|
|||||||
string allPlainLinks (templatePlainAllLink);
|
string allPlainLinks (templatePlainAllLink);
|
||||||
replaceAll (allPlainLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
replaceAll (allPlainLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
||||||
plain += allPlainLinks;
|
plain += allPlainLinks;
|
||||||
string allHtmlLinks (templateHtmlAllLink);
|
string allLinks (templateHtmlAllLink);
|
||||||
replaceAll (allHtmlLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
replaceAll (allLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
||||||
html += allHtmlLinks;
|
html += allLinks;
|
||||||
}
|
}
|
||||||
html += templateHtmlFooter;
|
html += templateHtmlFooter;
|
||||||
plain += "\r\n\r\n"+KAZ_WEB_SITE+"\r\n"+KAZ_PLAIN_HR+"\r\n"+KAZ_PLAIN_STOP+"\r\n";
|
plain += "\r\n\r\n"+KAZ_WEB_SITE+"\r\n"+KAZ_PLAIN_HR+"\r\n"+KAZ_PLAIN_STOP+"\r\n";
|
||||||
@ -251,7 +245,6 @@ MainAttachment::addPrevious (const string &href, const string &name, const bool
|
|||||||
|
|
||||||
void
|
void
|
||||||
MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
||||||
// plain text => "* name <url>"
|
|
||||||
DEF_LOG ("Attachment::extractedPlainKAZ", "extractedPlainKAZ: " << extractedPlainKAZ);
|
DEF_LOG ("Attachment::extractedPlainKAZ", "extractedPlainKAZ: " << extractedPlainKAZ);
|
||||||
for (string::size_type startPos (0);
|
for (string::size_type startPos (0);
|
||||||
(startPos = extractedPlainKAZ.find ("http", startPos)) != string::npos;
|
(startPos = extractedPlainKAZ.find ("http", startPos)) != string::npos;
|
||||||
@ -264,30 +257,22 @@ MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
|||||||
|
|
||||||
if (extractedPlainKAZ [stopPos])
|
if (extractedPlainKAZ [stopPos])
|
||||||
++stopPos;
|
++stopPos;
|
||||||
streamoff stopName = startPos;
|
|
||||||
startPos = stopPos;
|
startPos = stopPos;
|
||||||
|
|
||||||
// get all href but KAZ_WEB_SITE
|
// get all href but KAZ_WEB_SITE
|
||||||
// the archive link will be skip by filter.sh
|
// the archive link will be skip by filter.sh
|
||||||
if (href == KAZ_WEB_SITE)
|
if (href == KAZ_WEB_SITE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// backward find name
|
string::size_type nextPos = extractedPlainKAZ.find ("http", startPos);
|
||||||
string::size_type startName = extractedPlainKAZ.rfind ("* ", stopName);
|
string name (extractedPlainKAZ, startPos, (nextPos == string::npos ? extractedPlainKAZ.length () : nextPos) - startPos);
|
||||||
string name;
|
// skip [> \r\n\t]
|
||||||
|
nextPos = name.find_first_not_of ("[> \t\r\n\"]");
|
||||||
if (startName != string::npos) {
|
if (nextPos != string::npos)
|
||||||
name = string (extractedPlainKAZ, startName+3, stopName - startName - 3);
|
name.erase (0, nextPos);
|
||||||
// skip [> \r\n\t]
|
// stop before [>\r\n\t]
|
||||||
string::size_type nextPos = name.find_first_not_of ("[>< \t\r\n\"]");
|
nextPos = name.find_first_of ("[\"]");
|
||||||
if (nextPos != string::npos)
|
if (nextPos != string::npos)
|
||||||
name.erase (0, nextPos);
|
name.erase (nextPos);
|
||||||
// stop before [>\r\n\t]
|
|
||||||
nextPos = name.find_first_of ("[\"<]");
|
|
||||||
if (nextPos != string::npos)
|
|
||||||
name.erase (nextPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG ("plain name: " << name);
|
LOG ("plain name: " << name);
|
||||||
addPrevious (href, name);
|
addPrevious (href, name);
|
||||||
}
|
}
|
||||||
@ -296,7 +281,6 @@ MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
|||||||
// ================================================================================
|
// ================================================================================
|
||||||
void
|
void
|
||||||
MainAttachment::extractLinks (const vector<string> &liOne) {
|
MainAttachment::extractLinks (const vector<string> &liOne) {
|
||||||
// html text => "<li ...><a href="url">name</a>"
|
|
||||||
DEF_LOG ("Attachment::extractedPlainKAZ", "liOne.size: " << liOne.size ());
|
DEF_LOG ("Attachment::extractedPlainKAZ", "liOne.size: " << liOne.size ());
|
||||||
for (const string &one : liOne) {
|
for (const string &one : liOne) {
|
||||||
if (caseInsensitiveFind (one, CLASS_ONE) == string::npos)
|
if (caseInsensitiveFind (one, CLASS_ONE) == string::npos)
|
||||||
@ -369,11 +353,10 @@ MainAttachment::extractPreviousKAZ (ifstream &mbox) {
|
|||||||
void
|
void
|
||||||
MainAttachment::removePreviousArchive () {
|
MainAttachment::removePreviousArchive () {
|
||||||
vector<string> toRemove;
|
vector<string> toRemove;
|
||||||
for (map <string, string>::const_iterator it = previousLinks.begin (); it != previousLinks.end (); ++it) {
|
for (map <string, string>::const_iterator it = previousLinks.begin (); it != previousLinks.end (); ++it)
|
||||||
const string key (it->first);
|
if (it->first.find ("&g=") != string::npos ||
|
||||||
if (regex_match (key, archiveURLSignature))
|
it->first.find ("&l=/") != string::npos) // v1 compatibility
|
||||||
toRemove.push_back (key);
|
toRemove.push_back (it->first);
|
||||||
}
|
|
||||||
for (string old : toRemove)
|
for (string old : toRemove)
|
||||||
previousLinks.erase (old);
|
previousLinks.erase (old);
|
||||||
}
|
}
|
||||||
@ -538,10 +521,8 @@ MainAttachment::substitute (ifstream &mbox, ofstream &outbox, const SizeArg &min
|
|||||||
continue;
|
continue;
|
||||||
for (EmbeddedData &embedded : attachP->embeddedData)
|
for (EmbeddedData &embedded : attachP->embeddedData)
|
||||||
readDownloadUrl (embedded.downloadUrl);
|
readDownloadUrl (embedded.downloadUrl);
|
||||||
// XXX test empty ?
|
|
||||||
}
|
}
|
||||||
readArchiveUrl ();
|
readArchiveUrl ();
|
||||||
removePreviousArchive ();
|
|
||||||
string plainDisclaim, htmlDisclaim;
|
string plainDisclaim, htmlDisclaim;
|
||||||
getDisclaim (plainDisclaim, htmlDisclaim);
|
getDisclaim (plainDisclaim, htmlDisclaim);
|
||||||
// copy email
|
// copy email
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
// knowledge of the CeCILL-B license and that you accept its terms. //
|
// knowledge of the CeCILL-B license and that you accept its terms. //
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define LAST_VERSION "2.1 2022-10-30 eMailShrinker"
|
#define LAST_VERSION "2.0 2022-02-08 eMailShrinker"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -188,10 +188,10 @@ main (int argc, char** argv) {
|
|||||||
MainAttachment attachment (mbox);
|
MainAttachment attachment (mbox);
|
||||||
mbox.close ();
|
mbox.close ();
|
||||||
|
|
||||||
// if (attachment.getBoundary ().empty ()) {
|
if (attachment.getBoundary ().empty ()) {
|
||||||
// cerr << "no attachment" << endl;
|
cerr << "no attachment" << endl;
|
||||||
// return 1;
|
return 1;
|
||||||
// }
|
}
|
||||||
// parse structure
|
// parse structure
|
||||||
mbox.open (inputName);
|
mbox.open (inputName);
|
||||||
attachment.markSignificant (minAttachSize, mbox);
|
attachment.markSignificant (minAttachSize, mbox);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
// knowledge of the CeCILL-B license and that you accept its terms. //
|
// knowledge of the CeCILL-B license and that you accept its terms. //
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define LAST_VERSION "1.1 2022-10-30 jirafeauAPI"
|
#define LAST_VERSION "1.0 2021-02-21 jirafeauAPI"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -281,13 +281,12 @@ main (int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt (easyhandle, CURLOPT_MIMEPOST, multipart);
|
curl_easy_setopt (easyhandle, CURLOPT_MIMEPOST, multipart);
|
||||||
CURLcode res (curl_easy_perform (easyhandle));
|
curl_easy_perform (easyhandle);
|
||||||
curl_easy_cleanup (easyhandle);
|
curl_easy_cleanup (easyhandle);
|
||||||
cout << readBuffer << endl;
|
cout << readBuffer << endl;
|
||||||
|
|
||||||
showTime ("Upload");
|
showTime ("Upload");
|
||||||
if (res != CURLE_OK)
|
|
||||||
cerr << prog << " failed: " << curl_easy_strerror (res) << endl;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
#ifndef _kaz_Attachment_hpp
|
#ifndef _kaz_Attachment_hpp
|
||||||
#define _kaz_Attachment_hpp
|
#define _kaz_Attachment_hpp
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <regex>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "EmbeddedData.hpp"
|
#include "EmbeddedData.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user