From 5f503cf2949eca81810dcba0b9d5290913a5ce8a Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 5 Apr 2019 14:36:33 +0200 Subject: avoid creating tmpfiles in dest dir --- it.class | 6 ++++-- 1 file 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; } -- cgit v1.2.3