function SimpleRss($sUrl, $vCacheTime = 300, $iNumItems = -1, $sInputEncoding = '', $sOutputEncoding = 'UTF-8') { $this->oRssObject = new RssObject(); // this object holds the returned data $this->iNumItems = $iNumItems; $this->sInputEncoding = $sInputEncoding; $this->sOutputEncoding = $sOutputEncoding; // make sure caching hasn't been disabled if ($vCacheTime) { $oCache = new PhpCache($sUrl . '_' . $this->iNumItems, $vCacheTime); } // is caching disabled or if not has the cache expired if (!$vCacheTime || !$oCache->Check()) { $oHttp = new Http(); // request feed if ($sData = $oHttp->Get($sUrl)) { $this->bSuccessful = $this->Parse($sData); // do we want to cache result if ($vCacheTime) { $oCache->Set($this->oRssObject); } } } else { // get data from cache $this->oRssObject = $oCache->Get(); $this->bSuccessful = true; $this->bCached = true; } // check to see if request was successful, if not try and retrieve stale cache if (!$this->bSuccessful && $vCacheTime && $oCache->Exists()) { // make cache fresh $oCache->ReValidate(); // get data from cache $this->oRssObject = $oCache->Get(); $this->bSuccessful = true; $this->bCached = true; // mark as stale request $this->bStaleCache = true; } }