2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Check for failure to write at creation stage so not to go in loop

This commit is contained in:
Adam Zammit
2013-07-15 12:09:26 +10:00
parent 0f76ed7c64
commit 9bfc175adf

View File

@@ -39,6 +39,8 @@ function tempdir($dir, $prefix='', $mode=0700)
{ {
if (substr($dir, -1) != '/') $dir .= '/'; if (substr($dir, -1) != '/') $dir .= '/';
if (is_writable($dir))
{
do do
{ {
$path = $dir.$prefix.mt_rand(0, 9999999); $path = $dir.$prefix.mt_rand(0, 9999999);
@@ -46,6 +48,9 @@ function tempdir($dir, $prefix='', $mode=0700)
return $path; return $path;
} }
else
die(T_("Error: Cannot write to temporary directory"));
}
$tempdir = realpath(dirname(__FILE__) . '/../include/limesurvey/tmp'); $tempdir = realpath(dirname(__FILE__) . '/../include/limesurvey/tmp');
$operator_id = get_operator_id(); $operator_id = get_operator_id();
@@ -60,8 +65,6 @@ if ($operator_id)
$rs = $db->GetRow($sql); $rs = $db->GetRow($sql);
if (!empty($rs)) if (!empty($rs))
{
if (is_writable($tempdir))
{ {
$zipdir=tempdir($tempdir); $zipdir=tempdir($tempdir);
@@ -101,5 +104,4 @@ if ($operator_id)
unlink($zipfile); unlink($zipfile);
} }
} }
}
exit(); exit();