You are here

function ad_external_ad_build_cache in Advertisement 6.2

Same name and namespace in other branches
  1. 5.2 external/ad_external.module \ad_external_ad_build_cache()
  2. 5 external/ad_external.module \ad_external_ad_build_cache()
  3. 6.3 external/ad_external.module \ad_external_ad_build_cache()
  4. 6 external/ad_external.module \ad_external_ad_build_cache()
  5. 7 external/ad_external.module \ad_external_ad_build_cache()

Download external pages and store them in the filecache.

File

external/ad_external.module, line 190
Enhances the ad module to support externally hosted ads, served via IFrames. It is recommended that you configure "Administer >> Content management >> Ads >> Settings >> Global settings >> Display type" to…

Code

function ad_external_ad_build_cache() {
  $cache = array();
  $result = db_query('SELECT * FROM {ad_external}');
  while ($external = db_fetch_object($result)) {
    $contents = file_get_contents($external->url);
    if ($contents === FALSE) {

      // Failed to download external url, don't cache the error page.
      // TODO: Watchdog log this.
      // TODO: Would it be possible to obtain the old version from the cache,
      //       if we already downloaded this page once?
      continue;
    }
    $cache['ad_external'][$external->aid]['url'] = $external->url;
    $cache['ad_external'][$external->aid]['contents'] = $contents;
  }
  return $cache;
}