From d059c6476e1295c03820d99b11a909aeb24395f3 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 4 Aug 2016 08:05:11 +0000 Subject: [PATCH] ratelimitfile : raise an exception if the file already exists and is not writeable by the webserver git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2998 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- ratelimitfile.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ratelimitfile.php b/ratelimitfile.php index e0893aa..efd57e9 100644 --- a/ratelimitfile.php +++ b/ratelimitfile.php @@ -25,6 +25,12 @@ class ratelimitfile extends ratelimit // Add the current timestamp $currentTimeStamp = microtime (true)."\n"; if ($this->debug) echo "Add entry : $currentTimeStamp"; + $user = posix_getpwuid (posix_getuid()); + if (file_exists ($file) && ! is_writeable ($file)) + throw new \Exception (sprintf ( + dgettext("domframework", + "File '%s' not writeable for user '%s'"), + $file, $user["name"]), 500); file_put_contents ($file, $currentTimeStamp, FILE_APPEND); $lock = new lockfile (); $lock->storagelock = $this->storageDir."/lockfile.lock";