diff --git a/library/SSRS/Soap/NTLM.php b/library/SSRS/Soap/NTLM.php index 33b4fd6..5922f46 100755 --- a/library/SSRS/Soap/NTLM.php +++ b/library/SSRS/Soap/NTLM.php @@ -17,8 +17,11 @@ class NTLM extends \SoapClient { function __construct($wsdl, $options = array()) { if (empty($options['cache_wsdl_path'])) { - $options['cache_wsdl_path'] = '/tmp/' . md5($wsdl) . '.wsdl'; + $options['cache_wsdl_path'] = sys_get_temp_dir(); } + if(!preg_match('/'.preg_quote(DIRECTORY_SEPARATOR, '/').'$/', $options['cache_wsdl_path'])) + $options['cache_wsdl_path'] .= DIRECTORY_SEPARATOR; + $options['cache_wsdl_path'] .= md5($wsdl) . '.wsdl'; if (array_key_exists('username', $options)) { $this->setUsername($options['username']); @@ -79,16 +82,20 @@ public function setPassword($password) { public function setCachePath($file) { $folder = dirname($file); + $testFilePath = $folder.DIRECTORY_SEPARATOR.uniqid('test-cache-'); if (file_exists($file) && false === is_writable($file)) { throw new RuntimeException("WSDL cache file not writeable"); } elseif (false === is_dir($folder)) { throw new RuntimeException("WSDL cache parent folder does not exist"); - } elseif (false === is_writeable($folder)) { + } elseif (touch($testFilePath) === false) { throw new RuntimeException("WSDL cache parent folder not writeable"); + } else { + @unlink($testFilePath); } $this->_cachePath = $file; + return $this; }