From 77c1bb84bd039c915b59203a3a8602e97890ac58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Fri, 18 Feb 2022 18:30:30 +0100 Subject: [PATCH] fix setSenderFake --- src/Jirafeau/a.php | 44 +++++++++++++++++++++++++++----------------- src/bash/filter.sh | 2 +- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Jirafeau/a.php b/src/Jirafeau/a.php index 4f7b5d1..b3646b0 100644 --- a/src/Jirafeau/a.php +++ b/src/Jirafeau/a.php @@ -152,8 +152,9 @@ function rmSenderTrack ($sender) { } function getSenderTrack ($sender) { if (!$sender) - return; - return file_exists (VAR_TRACKS.$sender); + return false; + 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) return; if (!file_exists (VAR_FAKE)) 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); } function getSenderFake ($sender) { @@ -245,12 +255,12 @@ function readArchiveFromLines ($lines) { switch (true) { case preg_match ("/^\s*id:\s*(\d++)\s*$/", $line, $matches): $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): $archive [T_TIME] = $matches [1]; 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): $archive [T_NEW][] = [$matches [1], $matches [2]]; break; @@ -729,9 +739,9 @@ function deleteAction ($linkName) { if (! count ($archiveInfo)) return; if ($sender != $archiveInfo [T_SENDER]) { - setSenderFake ($sender, $dirLink, $dirTime); - $message .= "Tentative de supprimer un envoi dont vous n'êtes pas le propriétaire. (".$sender." != ".$archiveInfo [T_SENDER].")"; - $doLogout = true; + 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"; + $doLogout = true; return; } $fileToDelete = false; @@ -742,11 +752,11 @@ function deleteAction ($linkName) { continue; $fileTime = $fileLink ['upload_date']; 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". str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"], [$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES); - $doLogout = true; + //$doLogout = true; return; } $fileToDelete = true; @@ -817,22 +827,22 @@ function deleteAction ($linkName) { $message .= "."; 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. ". str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"], [$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES); - $dologout = true; + //$dologout = true; break; } 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.". str_replace (["___FILENAME___", "___DIRTIME___", "___FILETIME___"], [$fileLink ['file_name'], $dirTime , $fileTime], M_INCONSISTENT_DATES); - $doLogout = true; + //$doLogout = true; 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].")"; break; } diff --git a/src/bash/filter.sh b/src/bash/filter.sh index 908baf6..3ffc464 100644 --- a/src/bash/filter.sh +++ b/src/bash/filter.sh @@ -105,7 +105,7 @@ mkdir -p "${REP_PIECE_JOINTE}/" >"${ARCHIVE_CONTENT}" # 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}" LOG_FIC "${SHRINK_CMD} -u \"${INSPECT_DIR}/in.$$\" 2>> \"${FIC_LOG}\" > \"${OLD_LINKS}\""