Index: modules/banner/banner.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/banner/banner.module,v
retrieving revision 1.56
diff -u -r1.56 banner.module
--- modules/banner/banner.module	8 Apr 2006 13:31:40 -0000	1.56
+++ modules/banner/banner.module	8 Apr 2006 16:52:44 -0000
@@ -85,6 +85,22 @@
     '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 10, 25)),
     '#description' => t('If using the file cache handler, specify here the maximum number of cache files that should be created. Using only one cache file guarantees that banners will be disabled exactly when they cross a threshold such as being displayed the maximum allowed number of times. On busier sites, it can boost performance to use multiple cache files.'),
   );
+  
+  // output settings
+ $form['output'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('HTML output settings'),
+  );
+  $form['output']['banner_javascript'] = array(
+    '#type' => 'radios',
+    '#title' => t('JavaScript output for banners'),
+    '#default_value' => variable_get('banner_javascript', '1'),
+    '#options' => array(
+       '0' => t('no javascript'),
+       '1' => t('javascript (default)'),
+    ),
+    '#description' => t('Would you like the module to call banner_file.php for displaying banners to use a flat <img> tag?'),
+  );
 
   // taxonomy settings
   $vocabulary = variable_get('banner_vocabulary', array());
@@ -1591,7 +1607,11 @@
       $banners[$tid][$banner->id]->week_max_views = $banner->week_max_views;
       $banners[$tid][$banner->id]->max_views = $banner->max_views;
       $banners[$tid][$banner->id]->filename = file_create_url($banner->path);
-      $banners[$tid][$banner->id]->html = "document.write('".str_replace(array("'", "\n", "\r"), array("\"", " ", " "), theme('banner_show', $banner))."')";
+	  if (variable_get('banner_javascript', '1') == 1) {
+        $banners[$tid][$banner->id]->html = "document.write('".str_replace(array("'", "\n", "\r"), array("\"", " ", " "), theme('banner_show', $banner))."')";
+	  } else {
+	    $banners[$tid][$banner->id]->html = str_replace(array("'", "\n", "\r"), array("\"", " ", " "), theme('banner_show', $banner));
+      }
     }
   }
 
@@ -1706,9 +1726,162 @@
       $tid = $tids[0];
     }
 
-    $file = $files[variable_get('banner_cache', '0')] ."?pos=$group&amp;path=$path&amp;tid=$tid&amp;max=". variable_get('banner_cache_max', '1');
-    return '<script type="text/javascript" language="javascript" src="'."$base_url/$file".'"></script>';
+    if (variable_get('banner_javascript', '1') == 1) {
+      $file = $files[variable_get('banner_cache', '0')] ."?pos=$group&amp;path=$path&amp;tid=$tid&amp;max=". variable_get('banner_cache_max', '1');
+      return '<script type="text/javascript" language="javascript" src="'."$base_url/$file".'"></script>';
+      } else {
+        return banner_file($group, $tid);
+      }
+    }
+  }
+
+function banner_file($pos, $tid) { // This function has been cut-and-paste from banner_file
+
+  $position = (int) $pos;
+  $taxonomy = (int) $tid;
+
+  // get banners with 'enabled' status and decide which one to show
+  $result = db_query('SELECT * FROM {banner} WHERE status = 1');
+  while ($banner = db_fetch_object($result)) {
+    $tids = array(0 => 0); //_banner_get_tids($banner->id);
+    foreach ($tids as $tid) {
+      for ($n=0; $n<$banner->chance; $n++) {
+        $ballot[$tid][$banner->position][] = $banner->id;
+      }
+    }
+    $banners[$banner->id] = $banner;
+  }
+
+  $max = count($ballot[$taxonomy][$position]) - 1;
+  if ($max > 0) {
+    $random = mt_rand(0, $max);
+  }
+  else {
+    $random = 0;
+  }
+
+  $id = $ballot[$taxonomy][$position][$random];
+  $banner = $banners[$id];
+
+  // update view statistics
+  $result = db_query("SELECT uid, sid FROM {sessions} WHERE sid = '%s'", $_COOKIE['PHPSESSID']);
+  if (db_num_rows($result)) {
+    $session = db_fetch_object($result);
+    $uid = $session->uid;
+  }
+  if ($uid != 1 && $uid != $banner->uid) {
+    // don't update view stats for the admin user
+    db_query("UPDATE {banner} SET views = views + 1, day_views = day_views + 1, week_views = week_views + 1 WHERE id = %d", $id);
+  }
+
+  if ($banner->max_views > 0 && $banner->views >= $banner->max_views) {
+    // reached maximum views, set status (5) "blocked"
+    db_query("UPDATE {banner} SET status = 5 WHERE id = %d", $id);
+  }
+  else if ($banner->day_max_views > 0 && $banner->day_views >= $banner->day_max_views) {
+    // reached day's maximum views, set status (2) "day's limit reached"
+    db_query("UPDATE {banner} SET status = 2 WHERE id = %d", $id);
+  }
+  else if ($banner->week_max_views > 0 && $banner->week_views >= $banner->week_max_views) {
+    // reached week's maximum views, set status (3) "week's limit reached"
+    db_query("UPDATE {banner} SET status = 3 WHERE id = %d", $id);
+  }
+
+  // display the banner
+  // print "document.write('".str_replace(array("'", "\n", "\r"), array("\"", " ", " "), theme('banner_show', $banner))."')";
+  return theme('banner_show', $banner);
 }
 
 // all supported mime types - same as below in _banner_supported_mime_types
