fix setSenderFake

This commit is contained in:
François 2022-02-18 18:30:30 +01:00
parent 1f2bfec83a
commit 77c1bb84bd
2 changed files with 28 additions and 18 deletions

View File

@ -152,8 +152,9 @@ function rmSenderTrack ($sender) {
} }
function getSenderTrack ($sender) { function getSenderTrack ($sender) {
if (!$sender) if (!$sender)
return; return false;
return file_exists (VAR_TRACKS.$sender); return false;
//return file_exists (VAR_TRACKS.$sender);
} }
// ======================================== // ========================================
@ -210,12 +211,21 @@ function period2seconds ($periodName) {
} }
// ======================================== // ========================================
function setSenderFake ($sender, $dirLink, $dirTime) { function setSenderFake ($error, $sender, $owner, $dirLink, $dirTime, $fileName, $fileTime) {
if (!$sender) if (!$sender)
return; return;
if (!file_exists (VAR_FAKE)) if (!file_exists (VAR_FAKE))
mkdir (VAR_FAKE, 0755); mkdir (VAR_FAKE, 0755);
file_put_contents (VAR_FAKE.$sender, "time: ".$dirTime.NL."sender: ".$sender.NL); file_put_contents (VAR_FAKE.$sender,
"time: ".time ().NL.
"date: ".date ("Y-m-d H:i:s").NL.
"error: ".$error.NL.
"sender: ".$sender.NL.
"owner: ".$owner.NL.
"dirLink: ".$dirLink.NL.
"dirTime: ".$dirTime.NL.
"fileTime: ".$fileTime.NL);
"fileName: ".$fileName.NL.
rmToken ($sender); rmToken ($sender);
} }
function getSenderFake ($sender) { function getSenderFake ($sender) {
@ -245,12 +255,12 @@ function readArchiveFromLines ($lines) {
switch (true) { switch (true) {
case preg_match ("/^\s*id:\s*(\d++)\s*$/", $line, $matches): case preg_match ("/^\s*id:\s*(\d++)\s*$/", $line, $matches):
$archive [T_ID] = $matches [1]; $archive [T_ID] = $matches [1];
case preg_match ("/^\s*sender:\s*(([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6})\s*$/i", $line, $matches):
$archive [T_SENDER] = $matches [1];
break;
case preg_match ("/^\s*time:\s*(\d{4}([:-]\d{2}){5})\s*$/i", $line, $matches): case preg_match ("/^\s*time:\s*(\d{4}([:-]\d{2}){5})\s*$/i", $line, $matches):
$archive [T_TIME] = $matches [1]; $archive [T_TIME] = $matches [1];
break; break;
case preg_match ("/^\s*sender:\s*(([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6})\s*$/i", $line, $matches):
$archive [T_SENDER] = $matches [1];
break;
case preg_match ("/^\s*new:\s*([0-9a-zA-Z_-]+)\s+([0-9a-zA-Z_-]+)\s*$/", $line, $matches): case preg_match ("/^\s*new:\s*([0-9a-zA-Z_-]+)\s+([0-9a-zA-Z_-]+)\s*$/", $line, $matches):
$archive [T_NEW][] = [$matches [1], $matches [2]]; $archive [T_NEW][] = [$matches [1], $matches [2]];
break; break;
@ -729,8 +739,8 @@ function deleteAction ($linkName) {
if (! count ($archiveInfo)) if (! count ($archiveInfo))
return; return;
if ($sender != $archiveInfo [T_SENDER]) { if ($sender != $archiveInfo [T_SENDER]) {
setSenderFake ($sender, $dirLink, $dirTime); setSenderFake ("rmdir: not owner", $sender, $archiveInfo [T_SENDER], $dirLink, $dirTime, null, null);
$message .= "Tentative de supprimer un envoi dont vous n'êtes pas le propriétaire. (".$sender." != ".$archiveInfo [T_SENDER].")"; $message .= "Tentative de supprimer un envoi dont vous n'êtes pas le propriétaire";
$doLogout = true; $doLogout = true;
return; return;
} }
@ -742,11 +752,11 @@ function deleteAction ($linkName) {
continue; continue;
$fileTime = $fileLink ['upload_date']; $fileTime = $fileLink ['upload_date'];
if (! valideTime ($dirTime, $fileTime)) { if (! valideTime ($dirTime, $fileTime)) {
setSenderFake ($sender, $dirLink, $dirTime); setSenderFake ("rmdir: newfile not same time", $sender, null, $dirLink, $dirTime, $fileLink ['file_name'], $fileTime);
$message .= "Cet envoi a été forgée". $message .= "Cet envoi a été forgée".
str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"], str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"],
[$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES); [$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES);
$doLogout = true; //$doLogout = true;
return; return;
} }
$fileToDelete = true; $fileToDelete = true;
@ -817,22 +827,22 @@ function deleteAction ($linkName) {
$message .= "."; $message .= ".";
break; break;
} }
setSenderFake ($sender, $dirLink, $dirTime); setSenderFake ("rm: dir not same time", $sender, null, $dirLink, $dirTime, $fileLink ['file_name'], $fileTime);
$message .= "Cet envoi a été forgée. ". $message .= "Cet envoi a été forgée. ".
str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"], str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"],
[$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES); [$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES);
$dologout = true; //$dologout = true;
break; break;
} }
if (valideTime ($dirTime, $fileTime)) { if (valideTime ($dirTime, $fileTime)) {
setSenderFake ($sender, $dirLink, $dirTime); setSenderFake ("rm: not owner", $sender, $archiveInfo [T_SENDER], $dirLink, $dirTime, $fileLink ['file_name'], $fileTime);
$message .= "Tentative de supprimer un envoi dont vous n'êtes pas le propriétaire.". $message .= "Tentative de supprimer un envoi dont vous n'êtes pas le propriétaire.".
str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"], str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"],
[$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES); [$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES);
$doLogout = true; //$doLogout = true;
break; break;
} }
setSenderFake ($archiveInfo [T_SENDER], $dirLink, $dirTime); setSenderFake ("rm: find not owner", $archiveInfo [T_SENDER], $sender, $dirLink, $dirTime, $fileLink ['file_name'], $fileTime);
$message .= "Quelqu'un avétait revandiqué cet envoi. (".$sender." != ".$archiveInfo [T_SENDER].")"; $message .= "Quelqu'un avétait revandiqué cet envoi. (".$sender." != ".$archiveInfo [T_SENDER].")";
break; break;
} }

View File

@ -105,7 +105,7 @@ mkdir -p "${REP_PIECE_JOINTE}/"
>"${ARCHIVE_CONTENT}" >"${ARCHIVE_CONTENT}"
# Etape de rafraichissement des anciens fichiers inclus # Etape de rafraichissement des anciens fichiers inclus
echo "time: ${DATE_TEMPS}" > "${ARCHIVE_CONTENT}" echo -e "time: ${DATE_TEMPS}\nid: $(date +%s)" > "${ARCHIVE_CONTENT}"
[ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}" [ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}"
LOG_FIC "${SHRINK_CMD} -u \"${INSPECT_DIR}/in.$$\" 2>> \"${FIC_LOG}\" > \"${OLD_LINKS}\"" LOG_FIC "${SHRINK_CMD} -u \"${INSPECT_DIR}/in.$$\" 2>> \"${FIC_LOG}\" > \"${OLD_LINKS}\""