Inheritance diagram for ilBMFWSDL_Cache:
Collaboration diagram for ilBMFWSDL_Cache:Public Member Functions | |
| ilBMFWSDL_Cache ($cacheUse=WSDL_CACHE_USE, $cacheMaxAge=WSDL_CACHE_MAX_AGE) | |
| ilBMFWSDL_Cache constructor | |
| _cacheDir () | |
| _cacheDir return the path to the cache, if it doesn't exist, make it | |
| get ($wsdl_fname, $proxy_params=array(), $cache=0) | |
| Retrieves a file from cache if it exists, otherwise retreive from net, add to cache, and return from cache. | |
Data Fields | |
| $_cacheUse = null | |
| $_cacheMaxAge = null | |
Definition at line 873 of file class.ilBMFWSDL.php.
| ilBMFWSDL_Cache::_cacheDir | ( | ) |
_cacheDir return the path to the cache, if it doesn't exist, make it
Definition at line 910 of file class.ilBMFWSDL.php.
References $dir.
Referenced by get().
Here is the caller graph for this function:| ilBMFWSDL_Cache::get | ( | $ | wsdl_fname, | |
| $ | proxy_params = array(), |
|||
| $ | cache = 0 | |||
| ) |
Retrieves a file from cache if it exists, otherwise retreive from net, add to cache, and return from cache.
| string | URL to WSDL | |
| array | proxy parameters | |
| int | expected MD5 of WSDL URL public |
Definition at line 928 of file class.ilBMFWSDL.php.
References _cacheDir(), and ilBMFBase_Object::_raiseSoapFault().
{
$cachename = $md5_wsdl = $file_data = '';
if ($this->_cacheUse) {
// Try to retrieve WSDL from cache
$cachename = ilBMFWSDL_Cache::_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl';
if (file_exists($cachename)) {
$wf = fopen($cachename, 'rb');
if ($wf) {
// Reading cached file
$file_data = fread($wf, filesize($cachename));
$md5_wsdl = md5($file_data);
fclose($wf);
}
if ($cache) {
if ($cache != $md5_wsdl) {
return $this->_raiseSoapFault('WSDL Checksum error!', $wsdl_fname);
}
} else {
$fi = stat($cachename);
$cache_mtime = $fi[8];
//print cache_mtime, time()
if ($cache_mtime + $this->_cacheMaxAge < time()) {
// expired
$md5_wsdl = ''; // refetch
}
}
}
}
if (!$md5_wsdl) {
// Not cached or not using cache. Retrieve WSDL from URL
// is it a local file?
// this section should be replace by curl at some point
if (!preg_match('/^(https?|file):\/\//', $wsdl_fname)) {
if (!file_exists($wsdl_fname)) {
return $this->_raiseSoapFault("Unable to read local WSDL $wsdl_fname", $wsdl_fname);
}
if (function_exists('file_get_contents')) {
$file_data = file_get_contents($wsdl_fname);
} else {
$file_data = implode('',file($wsdl_fname));
}
} else {
$uri = explode('?', $wsdl_fname);
$rq =& new HTTP_Request($uri[0], $proxy_params);
// the user agent HTTP_Request uses fouls things up
if (isset($uri[1])) {
$rq->addRawQueryString($uri[1]);
}
if (isset($proxy_params['proxy_host']) &&
isset($proxy_params['proxy_port']) &&
isset($proxy_params['proxy_user']) &&
isset($proxy_params['proxy_pass'])) {
$rq->setProxy($proxy_params['proxy_host'], $proxy_params['proxy_port'],
$proxy_params['proxy_user'], $proxy_params['proxy_pass']);
} elseif (isset($proxy_params['proxy_host']) &&
isset($proxy_params['proxy_port'])) {
$rq->setProxy($proxy_params['proxy_host'], $proxy_params['proxy_port']);
}
$result = $rq->sendRequest();
if (PEAR::isError($result)) {
return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname," . $rq->getResponseCode(), $wsdl_fname);
}
$file_data = $rq->getResponseBody();
if (!$file_data) {
return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname);
}
}
$md5_wsdl = md5($file_data);
if ($this->_cacheUse) {
$fp = fopen($cachename, "wb");
fwrite($fp, $file_data);
fclose($fp);
}
}
if ($this->_cacheUse && $cache && $cache != $md5_wsdl) {
return $this->_raiseSoapFault("WSDL Checksum error!", $wsdl_fname);
}
return $file_data;
}
Here is the call graph for this function:| ilBMFWSDL_Cache::ilBMFWSDL_Cache | ( | $ | cacheUse = WSDL_CACHE_USE, |
|
| $ | cacheMaxAge = WSDL_CACHE_MAX_AGE | |||
| ) |
ilBMFWSDL_Cache constructor
| boolean | use caching | |
| int | cache max lifetime (in seconds) public |
Definition at line 898 of file class.ilBMFWSDL.php.
References ilBMFBase::ilBMFBase().
{
parent::ilBMFBase('WSDLCACHE');
$this->_cacheUse = $cacheUse;
$this->_cacheMaxAge = $cacheMaxAge;
}
Here is the call graph for this function:| ilBMFWSDL_Cache::$_cacheMaxAge = null |
Definition at line 889 of file class.ilBMFWSDL.php.
| ilBMFWSDL_Cache::$_cacheUse = null |
Definition at line 882 of file class.ilBMFWSDL.php.
1.7.1