private function getTempDir($volumeTempPath = null)
{
$testDirs = array();
if ($this->uploadTempPath) {
$testDirs[] = rtrim(realpath($this->uploadTempPath), DIRECTORY_SEPARATOR);
}
if ($volumeTempPath) {
$testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR);
}
if (function_exists('sys_get_temp_dir')) {
$testDirs[] = sys_get_temp_dir();
}
$tempDir = '';
foreach ($testDirs as $testDir) {
if (!$testDir || !is_dir($testDir)) {
continue;
}
if (is_writable($testDir)) {
$tempDir = $testDir;
$gc = time() - 3600;
foreach (glob($tempDir . DIRECTORY_SEPARATOR . 'ELF*') as $cf) {
if (filemtime($cf) < $gc) {
unlink($cf);
}
}
break;
}
}
return $tempDir;
}