comparison ad.module @ 2:e5584a19768b ad

maj module ad
author sly
date Wed, 15 Apr 2009 07:58:32 +0000
parents 948362c2a207
children 416ea999ed76
comparison
equal deleted inserted replaced
1:948362c2a207 2:e5584a19768b
1 <?php 1 <?php
2 // $Id: ad.module,v 1.2.2.29.2.83.2.16.2.12 2009/03/31 04:41:03 jeremy Exp $ 2 // $Id: ad.module,v 1.2.2.29.2.83.2.16.2.16 2009/04/14 14:02:11 jeremy Exp $
3 3
4 /** 4 /**
5 * @file 5 * @file
6 * An advertising system for Drupal powered websites. 6 * An advertising system for Drupal powered websites.
7 * 7 *
155 $query['u'] = $options['url']; 155 $query['u'] = $options['url'];
156 } 156 }
157 else { 157 else {
158 $query['u'] = $_GET['q']; 158 $query['u'] = $_GET['q'];
159 } 159 }
160 $src = url($base_url .'/'. $adserve, array('query' => $query)); 160 $src = htmlentities(url($base_url .'/'. $adserve, array('query' => $query)));
161 if ($options['ad_display'] == 'iframe') { 161 if ($options['ad_display'] == 'iframe') {
162 // TODO: We need to know the IFrame size before it is displayed. This 162 // TODO: We need to know the IFrame size before it is displayed. This
163 // limits the flexibility of what can be displayed in these frames. 163 // limits the flexibility of what can be displayed in these frames.
164 // For now we'll have a global value, later we'll add per-group 164 // For now we'll have a global value, later we'll add per-group
165 // over-rides. 165 // over-rides.
1332 return array( 1332 return array(
1333 '-expired' => t('Email @when before the advertisement will expire.'), 1333 '-expired' => t('Email @when before the advertisement will expire.'),
1334 'expired' => t('Email @when after the advertisement is expired.'), 1334 'expired' => t('Email @when after the advertisement is expired.'),
1335 '-active' => t('Email @when before the advertisement will be activated (if scheduled).'), 1335 '-active' => t('Email @when before the advertisement will be activated (if scheduled).'),
1336 'active' => t('Email @when after the advertisement is activated.'), 1336 'active' => t('Email @when after the advertisement is activated.'),
1337 'offline' => t('Email @when after the advertisement is taken offline.'),
1337 'click' => t('Email @when after the advertisement is clicked.'), 1338 'click' => t('Email @when after the advertisement is clicked.'),
1338 'approved' => t('Email @when after the advertisement is approved.'), 1339 'approved' => t('Email @when after the advertisement is approved.'),
1339 'denied' => t('Email @when after the advertisement is denied.'), 1340 'denied' => t('Email @when after the advertisement is denied.'),
1341 'update' => t('Email @when after the advertisement is updated.'),
1340 ); 1342 );
1341 break; 1343 break;
1342 case '-expired': 1344 case '-expired':
1343 $node = node_load($arg1->aid); 1345 $node = node_load($arg1->aid);
1344 if (isset($node->autoexpire) && $node->autoexpire) { 1346 if (isset($node->autoexpire) && $node->autoexpire) {
1529 } 1531 }
1530 1532
1531 /** 1533 /**
1532 * Builds the necessary HTML to display an image-based impressions counter. 1534 * Builds the necessary HTML to display an image-based impressions counter.
1533 */ 1535 */
1534 function ad_display_image($ad, $css = TRUE) { 1536 function ad_display_image($aid, $css = TRUE) {
1535 global $base_url; 1537 global $base_url;
1536 $adserve = variable_get('adserve', ''); 1538 $adserve = variable_get('adserve', '');
1537 $cache = variable_get('ad_cache', 'none'); 1539 $cache = variable_get('ad_cache', 'none');
1538 $variables = "?o=image"; 1540 $variables = "?o=image";
1539 if (is_object($ad)) { 1541 $variables .= "&a=$aid";
1540 $aid = $ad->aid;
1541 }
1542 else {
1543 /**
1544 * No ad is specified, so we're just tracking traffic.
1545 */
1546 $aid = 0;
1547 }
1548 $variables .= "&amp;a=$aid";
1549 if ($cache != 'none') { 1542 if ($cache != 'none') {
1550 $variables .= '&amp;c='. $cache . module_invoke('ad_cache_'. $cache, 'adcacheapi', 'display_variables', array()); 1543 $variables .= '&c='. $cache . module_invoke('ad_cache_'. $cache, 'adcacheapi', 'display_variables', array());
1551 } 1544 }
1552 $output = '<img src="'. url($base_url .'/'. $adserve . $variables) .'" height="0" width="0" alt="view counter" />'; 1545 $output = '<img src="'. htmlentities(url($base_url .'/'. $adserve . $variables)) .'" height="0" width="0" alt="view counter" />';
1553 if ($css) { 1546 if ($css) {
1554 return '<div class="ad-image-counter">'. $output .'</div>'; 1547 return '<div class="ad-image-counter">'. $output .'</div>';
1555 } 1548 }
1556 else { 1549 else {
1557 return $output; 1550 return $output;