From 5b95636165fe896b553389fecc120f7f37697761 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 ee344551..73ff2167 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ tst/.phpunit.result.cache .c9 /.idea/ *.iml +paste.log diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 3ba694ef..d309645b 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -97,7 +97,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); } /** @@ -115,6 +116,7 @@ class Filesystem extends AbstractData ) { return false; } + self::logToChapril("READ",$pasteid); return self::upgradePreV1Format($paste); } @@ -146,6 +148,7 @@ class Filesystem extends AbstractData $dir->close(); rmdir($discdir); } + self::logToChapril("DELETE",$pasteid); } } @@ -200,7 +203,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); } /** @@ -528,4 +532,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); + } }