Module: website Branch: master Commit: 1e070b16a9435bb51498e5738149074a50f60ca7 URL: http://source.winehq.org/git/website.git/?a=commit;h=1e070b16a9435bb51498e57...
Author: Jeremy Newman jnewman@codeweavers.com Date: Tue Aug 5 10:34:20 2008 -0500
return of the banner ad disabling code (ad is now disabled after 10 views)
---
bin/ad | 59 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/bin/ad b/bin/ad index 8465bd6..e7c20da 100644 --- a/bin/ad +++ b/bin/ad @@ -1,4 +1,4 @@ -<?PHP +<?php
/* Banner Ad Code */ /* For WineHQ */ @@ -6,33 +6,56 @@ // path for banner ad $bannerads_path = '../images/bannerads/';
+// max count until we stop displaying ads for user +$max_ads = 10; + +// check cookie for ad counter +$whqac = 0; +if (isset($_COOKIE['whqac'])) + $whqac = $_COOKIE['whqac']; +unset($_COOKIE["whqac"]); +$whqac++; + +// randomly select a banner and display it +if ($whqac >= $max_ads) +{ + // display fixed ad + $whqac = $max_ads; + $img = "../images/blank.gif"; +} +else +{ + // get random ad + $ads = array(); + $d = opendir($bannerads_path); + while($entry = readdir($d)) + { + if(!ereg("(.+)\.png$", $entry, $arr)) + continue; + array_push($ads, $arr[1]); + } + closedir($d); + sort($ads); + $img = $bannerads_path.$ads[(rand(1,count($ads))-1)]; +} + // da banner +setcookie("whqac", $whqac, time()+60*60*24*365); header("Expires: Mon, 1 Jan 2006 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache");
-// get random ad -$ads = array(); -$d = opendir($bannerads_path); -while($entry = readdir($d)) -{ - if(!ereg("(.+)\.png$", $entry, $arr)) - continue; - array_push($ads, $arr[1]); -} -closedir($d); -sort($ads); -$img = $ads[(rand(1,count($ads))-1)]; - ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> - <title>Banner Ad</title> + <title>WineHQ Banner Ad</title> </head> -<body bgcolor="#FFFFFF" text="#000000" marginwidth="0" marginheight="0" style="margin:0px;"><a href="http://www.codeweavers.com/products/support_wine/" -target="_top"><img src="../images/bannerads/<?=$img?>" -width="468" height="60" border="0" alt="Support the Wine Project" title="Support the Wine Project" /></a></body> +<body bgcolor="#E2E2E2" text="#000000" marginwidth="0" marginheight="0" style="margin:0px;"> +<a href="http://www.codeweavers.com/products/support_wine/" target="_top"><img +src="<?=$img?>" width="468" height="60" border="0" alt="Support the Wine Project" +title="Support the Wine Project" /></a> +</body> </html>