view external/external.inc @ 8:32c1a7d9e1fa ad tip

maj module ad en 2.1
author sly
date Fri, 11 Sep 2009 11:10:20 +0000
parents d8a3998dac8e
children
line wrap: on
line source
<?php
// $Id: external.inc,v 1.1.2.1.2.2 2009/02/16 17:06:48 jeremy Exp $

/**
 * @file
 * Loads external ad.
 *
 * Copyright (c) 2006-2009.
 *   Jeremy Andrews <jeremy@tag1consulting.com>.
 */

adserve_variable('ad_dir', getcwd() .'/');

// Attempt to utilize the file cache, if enabled.
if (function_exists('ad_cache_file_get_lock')) {

  // Find the top level Drupal directory so we can access the cache files.
  for ($i = 1; $i <= 20; $i++) {
    if (file_exists('./includes/bootstrap.inc')) {
      break;
    }
    chdir('..');
  }
  adserve_variable('root_dir', getcwd());

  $cache_file = ad_cache_file_get_lock();
  if ($cache_file) {
    $cache = unserialize(fread(adserve_variable('fd'), filesize($cache_file)));
    if (isset($cache['ad_external'])) {
      $aid = adserve_variable('nids');
      if ($aid && isset($cache['ad_external'][$aid]['contents'])) {
        print $cache['ad_external'][$aid]['contents'];
        exit(0);
      }
    }
  }
}