                
<?php
include('lib/site.module.php');

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'don2009_db';

ini_set('memory_limit', '512M');         //-----------------------------------------

$dbconnect = mysql_connect($dbhost, $dbuser, $dbpass) or die("not connect");
mysql_select_db($dbname, $dbconnect) or die ("not select");		
mysql_query("SET NAMES 'UTF8'", $dbconnect);         //-----------------------------------------

$query = "  SELECT *,
			REPLACE(xcompanygroupname, ' ', '_') AS xcompanygroupname,
			REPLACE(xproductname, ' ', '_') AS xproductname
			FROM xxproduct
			LEFT JOIN xxproductgroup ON(xproductgroupid=xgroupid)
			LEFT JOIN xxcompanygroup USING(xcompanygroupid)
			LEFT JOIN (
				SELECT xproductid AS xpriceproductid, round(xproductdetailint) AS xpint, IF(xproductdetailint,0,1) AS xorder
				FROM xxproductdetail
				LEFT JOIN xxgroupdetail USING (xgroupdetailid)
				WHERE xtitle LIKE '%قیمت%'
			)s1 ON (xproductid = xpriceproductid)
			WHERE xshow and xproductgroupid = 8 and xproductgroupid = 9 
			ORDER BY xproductid DESC
			LIMIT 30";
					
$result = mysql_query($query, $dbconnect);

$now = date("D, d M Y H:i:s T");

$output = "<?xml version=\"1.0\"?>
           <rss version=\"2.0\">
                
				    <channel>
                    <title>مناسبترین قیمتهای کالاهای دیجیتال در فروشگاه اینترنتی دنیا کالا</title>
                    <link>http://www.donyakala.com/pricerss_creator.php</link>
                    <description>The best price of digital stufs in Donya Kala Online Shop</description>
                    <language>utf-8</language>
                    <pubDate>$now</pubDate>
                    <lastBuildDate>$now</lastBuildDate>
                    <docs>http://donyakala.com</docs>
                    <managingEditor>info@donyakala.com</managingEditor>
                    <webMaster>info@donyakala.com</webMaster>";
            
while ($row = mysql_fetch_array($result))
        {
			$price = $row['xpint'] ? '('.htmlspecialchars(number_format($row['xpint'])).' ریال)' : '';          //-----------------------------------------
			$company = ($row['xproductgroup']);
			
			$name = htmlspecialchars($row['xproductname']) ;    //-----------------------------------------
			$return = htmlspecialchars($row['xpint']);         //-----------------------------------------
			
			
    $output .= "<item><title>$company $name  $price </title>
	                 
                    <link>"."http://www.donyakala.com/{$row['xproductgroupen']}/{$row['xcompanygroupname']}/{$row['xproductname']}"."</link>
                    <price></price>
					<description>".htmlspecialchars($row['xproddesc'])."</description>
                </item>" ;
}
$output .= "</channel></rss>";
	

file_put_contents('showrssprice_printscaner.xml', $output);

?>

