\"Soirees')\n"; if ($rand == 2) echo " document.write('\"Niko\'s')\n"; } function grab_300x100_ad_js() { $rand = rand(1,2); if ($rand == 1) echo " document.write('\"RiverStreet')\n"; if ($rand == 2) echo " document.write('\"Chatt-a-Foodie\"/')\n"; } $current_datetime = date('Y-m-d H:i:s'); $current_date = date('Y-m-d'); $day_begin = $current_date.' 00:00:00'; $day_end = $current_datetime.' 23:59:59'; $adtype = $_REQUEST["adtype"]; if((!$adtype)||($adtype != "300x250" && $adtype != "300x100")) { exit; } if($adtype == "300x250") { $ad_width = "300"; $ad_height = "250"; } if($adtype == "300x100") { $ad_width = "300"; $ad_height = "100"; } $query_adserve = "SELECT DISTINCT a1.*, COUNT(a2.adid) AS todays_impressions FROM ads a1 LEFT JOIN adimpressions a2 ON a1.adid=a2.adid && a2.dateadded <= '$day_end' && a2.dateadded >= '$day_begin' WHERE a1.adtype = '$adtype' && a1.startdate <= '$day_end' && a1.enddate >= '$day_begin' && a1.status = 'active' GROUP BY a1.adid ORDER BY todays_impressions ASC LIMIT 1 "; $result_adserve = mysql_query($query_adserve); $numrows_adserve = mysql_num_rows($result_adserve); while ($row = mysql_fetch_array($result_adserve)) { $adid = $row['adid']; $destination = $row['destination']; $urlencoded_destination = urlencode($destination); $clickTag = "http://www.chattanoogabridge.com/click?adid=".$adid."&dest=".$destination; $clickTag = urlencode($clickTag); $graphic_path = $row['graphic_path']; $graphic_type = $row['graphic_type']; $graphic_code = $row['graphic_code']; $title = $row['title']; $title = stripslashes(htmlspecialchars(strip_tags(htmlDecode($title)), ENT_QUOTES)); $display_url = $row['display_url']; if(($graphic_type == "flash")&&($graphic_code)) { echo " document.write('".$graphic_code."');document.write('
\"\"/
');\n"; } if(($graphic_type == "flash")&&(!$graphic_code)) { echo " document.write('');document.write('
\"\"/
');\n"; } if($graphic_type != "flash") { echo " document.write('\"$title\"/');document.write('
\"\"/
');\n"; } } if(!$numrows_adserve) { if($adtype == "300x250") { echo grab_300x250_ad_js(); } if($adtype == "300x100") { echo grab_300x100_ad_js(); } } // echo "document.write('The current page is: $current_page. The current referer is: $current_referer. The current uri is: $current_uri')\n"; ?>