price_vcene.php
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?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] = '&';
$replacements[3] = ''';
$replacements[2] = '"';
$replacements[1] = '>';
$replacements[0] = '<';
$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>";
?>