? regex_fix.patch
Index: ad_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ad/image/ad_image.module,v
retrieving revision 1.2.2.13.2.31
diff -u -p -r1.2.2.13.2.31 ad_image.module
--- ad_image.module	11 Jan 2008 18:52:09 -0000	1.2.2.13.2.31
+++ ad_image.module	26 Feb 2008 23:32:13 -0000
@@ -15,7 +15,11 @@
 function ad_image_display_ad($ad) {
   $image = db_fetch_object(db_query('SELECT a.fid, a.url, a.tooltip, a.width, a.height, f.filepath FROM {ad_image} a INNER JOIN {files} f ON a.fid = f.fid WHERE a.aid = %d AND f.nid = %d', $ad->aid, $ad->aid));
   // Strip module path from image path if serving images from adserve.php.
-  $image_path = preg_replace('&'. drupal_get_path('module', 'ad') .'/&', '', file_create_url($image->filepath));
+  $path_to_ad_module_pieces = explode("/", drupal_get_path('module' , 'ad'));
+  $base_modules_directory = array_shift($path_to_ad_module_pieces);
+  $ad_module_directory_name = array_pop($path_to_ad_module_pieces);
+  $pattern = '/\/'. $base_modules_directory . '\/.*\/' . $ad_module_directory_name . '/';
+  $image_path = preg_replace($pattern, '', file_create_url($image->filepath));
   return ("<div class=\"image-advertisement\" id=\"ad-$ad->aid\"><a href=\"$ad->redirect/@HOSTID___\" title=\"". htmlentities($image->tooltip, ENT_QUOTES) .'"'. ad_link_attributes() ."><img src=\"$image_path\" width=\"$image->width\" height=\"$image->height\" /></a></div>");
 }
 
