From a7a6ce9139661413cf38a3f7cdeb93b613954d3a Mon Sep 17 00:00:00 2001 From: pitchum Date: Sat, 18 Jun 2022 16:40:21 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20un=20logger=20sp=C3=A9cifique=20Chapri?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + lib/Data/Filesystem.php | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 07ce26ed..7e079cff 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ tst/.phpunit.result.cache .c9 /.idea/ *.iml +paste.log diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 506ab4ee..698111ea 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -95,7 +95,8 @@ class Filesystem extends AbstractData if (!is_dir($storagedir)) { mkdir($storagedir, 0700, true); } - return $this->_store($file, $paste); + self::logToChapril("CREATE",$pasteid); + return self::_store($file, $paste); } /** @@ -113,6 +114,7 @@ class Filesystem extends AbstractData ) { return false; } + self::logToChapril("READ",$pasteid); return self::upgradePreV1Format($paste); } @@ -144,6 +146,7 @@ class Filesystem extends AbstractData $dir->close(); rmdir($discdir); } + self::logToChapril("DELETE",$pasteid); } } @@ -198,7 +201,8 @@ class Filesystem extends AbstractData if (!is_dir($storagedir)) { mkdir($storagedir, 0700, true); } - return $this->_store($file, $comment); + self::logToChapril("COMMENT",$pasteid); + return self::_store($file, $comment); } /** @@ -526,4 +530,17 @@ class Filesystem extends AbstractData } unlink($srcFile); } + + /** + * Add log + * + * @access private + * @return bool + */ + private function logToChapril($message, $id=null) + { + $today = date('Y-m-d H:i:s'); + $texte_retour="$today $message \t$id\n"; + return (bool) file_put_contents("/var/www/paste.chapril.org/paste.log",$texte_retour,FILE_APPEND|LOCK_EX); + } }