Public Member Functions

ilBMFWSDL_Cache Class Reference

Inheritance diagram for ilBMFWSDL_Cache:
Collaboration diagram for ilBMFWSDL_Cache:

Public Member Functions

 ilBMFWSDL_Cache ()
 _cacheDir ()
 _cacheDir return the path to the cache, if it doesn't exist, make it
 get ($wsdl_fname, $proxy_params=array(), $cache=0)
 get retreives file from cache if it exists, otherwise retreive from net, add to cache, and return from cache

Detailed Description

Definition at line 572 of file class.ilBMFWSDL.php.


Member Function Documentation

ilBMFWSDL_Cache::_cacheDir (  ) 

_cacheDir return the path to the cache, if it doesn't exist, make it

Definition at line 581 of file class.ilBMFWSDL.php.

References $dir.

Referenced by get().

                         {
        $dir = getenv("WSDLCACHE");
        if (!$dir) $dir = "./wsdlcache";
        @mkdir($dir, 0700);
        return $dir;
    }

Here is the caller graph for this function:

ilBMFWSDL_Cache::get ( wsdl_fname,
proxy_params = array(),
cache = 0 
)

get retreives file from cache if it exists, otherwise retreive from net, add to cache, and return from cache

Definition at line 593 of file class.ilBMFWSDL.php.

References $result, _cacheDir(), and ilBMFBase::_raiseSoapFault().

                                                               {
        $cachename = ilBMFWSDL_Cache::_cacheDir() . "/" . md5($wsdl_fname);
        $cacheinfo = $cachename.".info";
        $cachename .= ".wsdl";
        $md5_wsdl = "";
        $file_data = '';
        if (WSDL_CACHE_USE && file_exists($cachename)) {
            $wf = fopen($cachename,"rb");
            if ($wf) {
                $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 + WSDL_CACHE_MAX_AGE < time()) {
                    # expired
                    $md5_wsdl = ""; # refetch
                }
            }
        }
        if (!$md5_wsdl) {
            // is it a local file?
            // this section should be replace by curl at some point
            if (!preg_match('/^(http|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]);
                }
                $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, nohttp body", $wsdl_fname);
                }
            }
            
            $md5_wsdl = md5($file_data);
            
            if (WSDL_CACHE_USE) {
                $fp = fopen($cachename, "wb");
                fwrite($fp, $file_data);
                fclose($fp);
            }
        }
        if (WSDL_CACHE_USE && $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 (  ) 

Definition at line 574 of file class.ilBMFWSDL.php.

References ilBMFBase::ilBMFBase().

                               {
        parent::ilBMFBase('WSDLCACHE');
    }

Here is the call graph for this function:


The documentation for this class was generated from the following file: