From da53f197541ecf35613ae141001df474e01a523f 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 acf17490..5ac28e94 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ tst/.phpunit.result.cache .c9 /.idea/ *.iml +paste.log diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 2b8240bc..282e35f1 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -96,7 +96,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); } /** @@ -114,6 +115,7 @@ class Filesystem extends AbstractData ) { return false; } + self::logToChapril("READ",$pasteid); return self::upgradePreV1Format($paste); } @@ -145,6 +147,7 @@ class Filesystem extends AbstractData $dir->close(); rmdir($discdir); } + self::logToChapril("DELETE",$pasteid); } } @@ -199,7 +202,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); } /** @@ -527,4 +531,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); + } }