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
This commit is contained in:
2016-08-04 08:05:11 +00:00
parent 1fc8635b71
commit d059c6476e

View File

@@ -25,6 +25,12 @@ class ratelimitfile extends ratelimit
// Add the current timestamp // Add the current timestamp
$currentTimeStamp = microtime (true)."\n"; $currentTimeStamp = microtime (true)."\n";
if ($this->debug) echo "Add entry : $currentTimeStamp"; 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); file_put_contents ($file, $currentTimeStamp, FILE_APPEND);
$lock = new lockfile (); $lock = new lockfile ();
$lock->storagelock = $this->storageDir."/lockfile.lock"; $lock->storagelock = $this->storageDir."/lockfile.lock";