annotate external/external.inc @ 0:d8a3998dac8e ad

ajout module ad
author pierre
date Fri, 20 Feb 2009 14:04:09 +0000
parents
children
rev   line source
pierre@0 1 <?php
pierre@0 2 // $Id: external.inc,v 1.1.2.1.2.2 2009/02/16 17:06:48 jeremy Exp $
pierre@0 3
pierre@0 4 /**
pierre@0 5 * @file
pierre@0 6 * Loads external ad.
pierre@0 7 *
pierre@0 8 * Copyright (c) 2006-2009.
pierre@0 9 * Jeremy Andrews <jeremy@tag1consulting.com>.
pierre@0 10 */
pierre@0 11
pierre@0 12 adserve_variable('ad_dir', getcwd() .'/');
pierre@0 13
pierre@0 14 // Attempt to utilize the file cache, if enabled.
pierre@0 15 if (function_exists('ad_cache_file_get_lock')) {
pierre@0 16
pierre@0 17 // Find the top level Drupal directory so we can access the cache files.
pierre@0 18 for ($i = 1; $i <= 20; $i++) {
pierre@0 19 if (file_exists('./includes/bootstrap.inc')) {
pierre@0 20 break;
pierre@0 21 }
pierre@0 22 chdir('..');
pierre@0 23 }
pierre@0 24 adserve_variable('root_dir', getcwd());
pierre@0 25
pierre@0 26 $cache_file = ad_cache_file_get_lock();
pierre@0 27 if ($cache_file) {
pierre@0 28 $cache = unserialize(fread(adserve_variable('fd'), filesize($cache_file)));
pierre@0 29 if (isset($cache['ad_external'])) {
pierre@0 30 $aid = adserve_variable('nids');
pierre@0 31 if ($aid && isset($cache['ad_external'][$aid]['contents'])) {
pierre@0 32 print $cache['ad_external'][$aid]['contents'];
pierre@0 33 exit(0);
pierre@0 34 }
pierre@0 35 }
pierre@0 36 }
pierre@0 37 }