<?php
header("Content-Type: text/xml; charset=utf-8");      
ini_set('max_execution_time', 0); 
$dir = '../inc/';
require_once $dir."database.php";
require_once $dir."DW_class.php";
$dw = new DWDB();
$zaman = date('d.m.Y H:i:s');
//* Seo Link oluşturma
function seo_link($link) {
$link = trim($link);
$eski = array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü',' ','\'','|','/','`','&#39;','&quot;','&',',','.','?','®',')','(','{','}','[',']');
$yeni = array('c','c','g','g','i','i','o','o','s','s','u','u','-','-','','-','','','','','','','','','','','','','','');
$seo_link = str_replace($eski,$yeni,$link);
$seo_link = strtolower($seo_link);
return $seo_link;
}
//* Seo Link oluşturma
//* Ayar Cek
$ayarcek = $dw->getRow('SELECT * FROM ayarlar WHERE id = ?', array('bindValues' => array(1)));
//* Ayar Cek
$xml ='<deals>';
$results = $dw->getResults('SELECT * FROM urunler where anaurun = 0 and durum = 1 order by id');
foreach ($results as $yaz) {
//* Marka cek
$markacek = $dw->getRow('SELECT * FROM markalar WHERE id = ?', array('bindValues' => array($yaz->marka)));
//* Marka cek
//* Resim cek
$resimcek = $dw->getRow('SELECT * FROM resimler WHERE urunid = ?', array('bindValues' => array($yaz->id)));
$resimsayisi = $dw->numRows();
if($resimsayisi == 0) {
$resim = "gorselhazir.png";
} else {
$resim = $resimcek->ortaresim;
}
//* Resim cek
$kategorisi = $dw->getRow('SELECT * FROM kategoriler WHERE id = ?', array('bindValues' => array($yaz->ustkategori)));
$link = "u/".$yaz->id."/".seo_link("$kategorisi->kategori")."/".seo_link("$yaz->urun");
$fiyatfark = $yaz->satis_fiyat - $yaz->indirimli_fiyat;
$fiyatfark = number_format($fiyatfark, 2, '.' , '');
$tarih = date('Y-m-d');
$tarih2 = date("Y-m-d", strtotime("+10 days", strtotime($tarih)));
$xml.= '<deal>
<id>'.$yaz->id.'</id>
<city>Istanbul</city>
<title><![CDATA['.$yaz->urun.']]></title>
<description><![CDATA['.$yaz->detay.']]></description>
<detail/>
<howToUse/>
<startDate>'.$tarih.' 00:00:00</startDate>
<endDate>'.$tarih2.' 00:00:00</endDate>
<hasTipped>1</hasTipped>
<tippingPoint>0</tippingPoint>
<tippingDate>2013-01-24 10:25:18</tippingDate>
<hasSoldOut>0</hasSoldOut>
<totalSold>7</totalSold>
<realPrice>'.$yaz->satis_fiyat.'</realPrice>
<dealPrice>'.$yaz->indirimli_fiyat.'</dealPrice>
<discountPrice>'.$fiyatfark.'</discountPrice>
<discountPercent>10</discountPercent>
<hasLimitedQuantity>0</hasLimitedQuantity>
<initialQuantity>0</initialQuantity>
<quantityRemaining>5</quantityRemaining>
<minimumPurchase>0</minimumPurchase>
<maximumPurchase>999</maximumPurchase>
<expirationDate/>
<dealUrl><![CDATA['.$ayarcek->sitelink.''.$link.'.html]]></dealUrl>
<imageUrl><![CDATA['.$ayarcek->sitelink.'yukleme/urun/'.$resim.']]></imageUrl>
</deal>';
}
$xml .= '</deals>';
echo $xml;
error_reporting(0);
?>