4,7 → 4,7 |
public function consulter($ressources, $parametres) { |
$options = array( |
'stockage_mode' => Cache::STOCKAGE_MODE_FICHIER, |
'stockage_chemin' => $this->getTmpDir(), |
'stockage_chemin' => Fichier::getDossierTmp(), |
'controle_ecriture' => false, |
'mise_en_cache' => true, |
'cache_id_prefixe' => null, |
93,74 → 93,5 |
' - diff. : '.($meta02['expiration'] - $meta01['expiration']).'<br/>'; |
} |
} |
|
/** |
* Determine system TMP directory and detect if we have read access |
* |
* inspired from Zend_File_Transfer_Adapter_Abstract & Zend_Cache |
* |
* @return string |
*/ |
public function getTmpDir() { |
$tmpdir = array(); |
foreach (array($_ENV, $_SERVER) as $tab) { |
foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) { |
if (isset($tab[$key])) { |
if (($key == 'windir') or ($key == 'SystemRoot')) { |
$dir = realpath($tab[$key] . '\\temp'); |
} else { |
$dir = realpath($tab[$key]); |
} |
if ($this->isGoodTmpDir($dir)) { |
return $dir; |
} |
} |
} |
} |
$upload = ini_get('upload_tmp_dir'); |
if ($upload) { |
$dir = realpath($upload); |
if ($this->isGoodTmpDir($dir)) { |
return $dir; |
} |
} |
if (function_exists('sys_get_temp_dir')) { |
$dir = sys_get_temp_dir(); |
if ($this->isGoodTmpDir($dir)) { |
return $dir; |
} |
} |
// Attemp to detect by creating a temporary file |
$tempFile = tempnam(md5(uniqid(rand(), TRUE)), ''); |
if ($tempFile) { |
$dir = realpath(dirname($tempFile)); |
unlink($tempFile); |
if ($this->isGoodTmpDir($dir)) { |
return $dir; |
} |
} |
if ($this->isGoodTmpDir('/tmp')) { |
return '/tmp'; |
} |
if ($this->isGoodTmpDir('\\temp')) { |
return '\\temp'; |
} |
} |
|
/** |
* Verify if the given temporary directory is readable and writable |
* |
* @param $dir temporary directory |
* @return boolean true if the directory is ok |
*/ |
protected function isGoodTmpDir($dir){ |
if (is_readable($dir)) { |
if (is_writable($dir)) { |
return true; |
} |
} |
return false; |
} |
|
} |
?> |