<?php
header("Content-Type: text/xml");
include_once("/home/jumponde/public_html/dbconn.inc.php3");




// first day is always shown
$today=date("m/d/y");
// get defaults
$sql="SELECT * FROM defaults";


$qres=mysql_query($sql,$dbconn);
$qrow=mysql_fetch_array($qres);

if ($qrow=mysql_fetch_array($qres)):
  extract($qrow,EXTR_OVERWRITE);
$DEALS_PRESET=$deals_preset;
$MAX_EXTRA_DAYS=$max_extra_days;
endif;



$deal_count=0;  // not to exceed DEALS_PRESET
if ($DEALS_PRESET==""): $DEALS_PRESET=20; endif;

// number of days to display depends on control panel value MAX_EXTRA_DAYS
if ($MAX_EXTRA_DAYS==""): $MAX_EXTRA_DAYS=2; endif;


$dbtoday=date("Y-m-d");

// get all stores with date's deals
$sql="SELECT stores.*, coupons.* FROM stores LEFT JOIN coupons ON stores.store_id=coupons.store_id WHERE coupons.store_id IS NOT NULL AND (coupons.coupon_startdate='$dbtoday') AND (coupons.coupon_expiration>='$dbtoday' OR coupons.coupon_expiration='$zerodatetime') AND ( coupons.coupon_flag_freebie='0' OR (coupons.coupon_flag_freebie='1' AND coupons.coupon_flag_freebie_hp='1')) AND stores.no_show!=1 AND coupons.no_show!=1 ORDER BY stores.store_name, coupons.coupon_title";



echo "<?xml version='1.0' encoding='ISO-8859-1' ?" . ">\n";
echo "<rss version='2.0'>";
echo "\n\n";
echo '<channel>';
echo "\n";
echo "<title>JumpOnDeals.com</title> 
  <link>http://www.jumpondeals.com/</link> 
  <description>Find coupons for Over 800 online stores at JumpOnDeals.com</description>
  <language>en-us</language>";
echo "<image>
  <title>JumpOnDeals.com</title> 
  <url>http://www.jumpondeals.com/images/thefinallogo.gif</url> 
  <link>http://www.jumpondeals.com/</link> 
  </image>";


$handle=mysql_query($sql);
result($handle,$dbtoday);



function result($handle,$date)
{
  

  while($result=mysql_fetch_assoc($handle))
    {
     
      $store_name=$result['store_name'];
      $store_url=$result['store_url'];
      $offername=$result['coupon_title'];
      $offerurl=$result['coupon_url'];
      $offerdesc=$result['coupon_comment'];
      $offerfrom=$result['coupon_startdate'];
      $expires=$result['coupon_expiration'];
      $coupon_id=$result['coupon_id'];
      $store_abbr=$result['store_abbr'];
      
      
      $store_url="http://www.jumpondeals.com/coupons/$store_abbr";

 

      $offername = $store_name." - ".$offername;
      
      $offername = str_replace("&","and",$offername);
      $offername = strip_tags($offername, '');
      
      print "\n";
      print "<item>\n";
      print "<title>".($offername)."</title>\n";
      print "<link>".($store_url)."</link>\n";
      print "</item>\n";
      print "\n";
      $deal_count+=1;
    }
  

}

echo "</channel>";
echo "\n</rss>";


?>

