price_vcene.php 2.73 KB
<?php
set_time_limit(0);
//header("Content-Type: text/xml");
require("./libs/setup.php");
$setup = new setup();
$db = $setup->db;
$objCatalogs = $setup->setupClass("Catalogs");

 function escapeLoc($loc){
        $patterns = array();
        $patterns[0] = '/&/';
        $patterns[1] = '/\'/';
        $patterns[2] = '/"/';
        $patterns[3] = '/>/';
        $patterns[4] = '/</';
        $replacements = array();
        $replacements[4] = '&amp;';
        $replacements[3] = '&apos;';
        $replacements[2] = '&quot;';
        $replacements[1] = '&gt;';
        $replacements[0] = '&lt;';
		
        $loc = preg_replace($patterns, $replacements, $loc);
		return $loc;
 }
 
function nohtml($string)
{
    return preg_replace('/[^a-zà-ÿ¸\.\,\?\! 0-9]/i','',$string);;
} 

print'<yml_catalog date="'.date("Y-m-d h:m").'">';
print"<shop>";
print"<name>ExtremStyle.ua  - èíòåðíåò ìàãàçèí</name>";
print"<company>ExtremStyle</company>"; 
print"<url>http://extremstyle.ua/</url>";

print'<currencies>';
print'<currency id="USD" rate="1.00"/>';            
print'<currency id="UAH" rate="8.08"/>';
print'</currencies>'; 


$res = $db->getAll("select * from catalogs_rubrics where is_xml=?",array(0),DB_FETCHMODE_ASSOC);
//print_r($res);
$rubrics = array();
print"<categories>";
foreach($res as $row){
$rubrics[] = $row['id'];
print"<category id='".$row['id']."' parentId='".$row['parent_id']."'>".$row['name']."</category>";
}
print"</categories>";

print"<offers>";
foreach($rubrics as $rub){
$res = $db->getAll("select p.*,r.translit as rubric_translit,r.is_xml2,b.name as brend,r.list_name from catalogs_products p LEFT JOIN catalogs_rubrics r ON r.id=p.rubric_id LEFT JOIN catalogs_brends b ON b.id=p.brend_id where p.rubric_id=? and p.count_modifications>0",array($rub),DB_FETCHMODE_ASSOC);
foreach($res as $row){
print'<offer id="'.$row['id'].'" available="true">';
print"<url>http://extremstyle.ua/" . htmlspecialchars(escapeLoc($row['rubric_translit'])) . "-catalogs/" . htmlspecialchars(escapeLoc($row['translit'])) . "-" . $row['id'] . "/</url>"; 
print"<price>" . $row['cine'] . "</price>";
print"<currencyId>UAH</currencyId>"; 
print"<categoryId>" . $row['rubric_id'] . "</categoryId>";
print"<picture>http://extremstyle.ua/uploaded/pic/catalogs/products/" . $row['pic'] . "</picture>"; 
print"<delivery>false</delivery>";
$row['ph1'] = $objCatalogs->getFilterPh1($row['id']); 
print"<name>" . htmlspecialchars(escapeLoc($row['ph1'])) .' '. htmlspecialchars(escapeLoc($row['list_name'])) .' '. htmlspecialchars(escapeLoc($row['brend'])) .' '. htmlspecialchars(escapeLoc($row['name'])) . "</name>"; 
print"<description>" . htmlspecialchars(nohtml(stripcslashes($row['text']))) . "</description>"; 
print"</offer>";
}}
print"</offers>";


print"</shop>";
print"</yml_catalog>";
?>