From 5414471fc1738d9f66c84edce65ada0fca313ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Didier=20Clermont=C3=A9?= Date: Tue, 23 Oct 2018 18:18:23 +0200 Subject: [PATCH] improved paste.log --- .gitignore | 3 +++ lib/Data/Filesystem.php | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e266a0dc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/data/ +/paste.log +/*~ diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index dd861405..4418622d 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -62,19 +62,7 @@ class Filesystem extends AbstractData } return self::$_instance; } - /** - * Add log - * - * @access public - * @return bool - */ - public 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); - } - + /** * Create a paste. * @@ -117,8 +105,8 @@ class Filesystem extends AbstractData $paste->attachmentname = $paste->meta->attachmentname; unset($paste->meta->attachmentname); } - self::logToChapril("READ",$pasteid); } + self::logToChapril("READ",$pasteid); return $paste; } @@ -150,8 +138,8 @@ class Filesystem extends AbstractData } $dir->close(); rmdir($discdir); - self::logToChapril("DELETE",$pasteid); } + self::logToChapril("DELETE",$pasteid); } } @@ -452,4 +440,16 @@ class Filesystem extends AbstractData { return json_decode(substr(file_get_contents($file), strlen(self::PROTECTION_LINE . PHP_EOL))); } + /** + * 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); + } }