summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2019-04-05 14:36:33 +0200
committerUrban Müller2019-04-05 14:36:33 +0200
commit5f503cf2949eca81810dcba0b9d5290913a5ce8a (patch)
treecf22444d5eea9d465a75a24d3d0400d74fa92f73
parent7243fa31a6bb8ae20d444294bb5c7cf67ec99e3d (diff)
downloaditools-5f503cf2949eca81810dcba0b9d5290913a5ce8a.tar.gz
itools-5f503cf2949eca81810dcba0b9d5290913a5ce8a.tar.bz2
itools-5f503cf2949eca81810dcba0b9d5290913a5ce8a.zip
avoid creating tmpfiles in dest dir
-rw-r--r--it.class6
1 files changed, 4 insertions, 2 deletions
diff --git a/it.class b/it.class
index 714ffc4..768ee02 100644
--- a/it.class
+++ b/it.class
@@ -1108,9 +1108,11 @@ static function file_put($filename, $data, $p = array())
if ($p['mkdir'] && $filename != "-")
@mkdir(dirname($filename));
- $tmpfile = dirname($filename) . "/.it_put." . basename($filename) . "." . getmypid();
+ $tmp = $GLOBALS['ULTRAHOME'] . "/tmp";
+ $tmpdir = is_dir($tmp) && stat($tmp)[0] == stat(dirname($filename))[0] ? $tmp : dirname($filename);
+ $tmpfile = "$tmpdir/.it_put." . basename($filename) . "." . getmypid();
if (($result = it::file_put_contents($filename == "-" ? "php://stdout" : $tmpfile, $data)) !== false && $filename != "-")
- $result = rename($tmpfile, $filename);
+ $result = rename($tmpfile, $filename);
return $result;
}