price.php
5.63 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?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);
}
function modCodeNew ($product_id)
{
global $objCatalogs;
return $objCatalogs->db->getOne ('select new_code from catalogs_modifications where active=1 and product_id=? and new_code<>""', array (
$product_id
));
}
print '<?xml version="1.0" encoding="windows-1251" ?>';
print "<price>";
print "<date>" . date ("Y-m-d h:m") . "</date>";
print "<firmName>ExtremStyle</firmName>";
print "<firmId></firmId>";
print "<rate></rate>";
$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>";
print "<id>" . $row['id'] . "</id>";
print "<parentId>" . $row['parent_id'] . "</parentId>";
print "<name>" . $row['name'] . "</name>";
print "</category>";
}
print "</categories>";
print "<items>";
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 "<item>";
print "<id>" . $row['id'] . "</id>";
print "<categoryId>" . $row['rubric_id'] . "</categoryId>";
if ($row['rubric_id'] != 14055)
print "<group_id>0" . $row['id'] . "</group_id>";
print "<code></code>";
print "<vendor>" . htmlspecialchars (escapeLoc ($row['brend'])) . "</vendor>";
$row['ph1'] = $objCatalogs->getFilterPh1 ($row['id']);
$f = $objCatalogs->viewFilterProduct ($row['id']);
$f_arr = array ();
foreach ($f as $_f)
{
$f_arr[] = $_f['name'];
}
$f_str = (count ($f_arr) > 0) ? implode (', ', $f_arr) : '';
print "<name>" . htmlspecialchars (escapeLoc ($row['ph1'])) . ' ' . htmlspecialchars (escapeLoc ($row['list_name'])) . ' ' . htmlspecialchars (escapeLoc ($row['brend'])) . ' ' . htmlspecialchars (escapeLoc ($row['name'])) . ' ' . htmlspecialchars (escapeLoc ($f_str)) . ' ' . modCodeNew ($row['id']) . "</name>";
print "<description>" . htmlspecialchars (nohtml (stripcslashes ($row['text']))) . "</description>";
print "<url>http://extremstyle.ua/" . htmlspecialchars (escapeLoc ($row['rubric_translit'])) . "-catalogs/" . htmlspecialchars (escapeLoc ($row['translit'])) . "-" . $row['id'] . "/</url>";
print "<image>http://extremstyle.ua/uploaded/pic/catalogs/products/" . $row['pic'] . "</image>";
print "<priceRUAH>" . round ($row['cine'] - ($row['cine'] * $row['salepc'] / 100)) . "</priceRUAH>";
// print"<priceRUAH>" . $row['cine'] . "</priceRUAH>";
print "<oldprice>" . $row['cine'] . "</oldprice>";
print "<priceRUSD></priceRUSD>";
print "<stock>Íà ñêëàäå</stock>";
print "<guarantee></guarantee>";
IF ($row['is_xml2'] == 1 && $row['rubric_id'] != 14055)
{
if ($row['sex'] == 1)
$sex = 'Ìóæñêîé';
elseif ($row['sex'] == 2)
$sex = 'Æåíñêèé';
elseif ($row['sex'] == 3)
$sex = 'Äåòñêèé';
elseif ($row['sex'] == 4)
$sex = 'Óíèñåêñ';
else
$sex = '';
$res_m = $db->getAll ("
select *
from catalogs_modifications
where active=1
and product_id=?", array (
$row['id']
), DB_FETCHMODE_ASSOC);
foreach ($res_m as $row_m)
{
print '<param name="Ðàçìåð" unit="INT">' . $row_m['size'] . '</param>';
print '<param name="Öâåò">' . (($row['rubric_id'] == 14055) ? $row_m['color'] : $row_m['color2']) . '</param>';
print '<param name="Ïîë">' . $sex . '</param>';
print '<param name="Âîçðàñò"></param>';
print '<param name="Ðåïëèêà"></param>';
print '<param name="Òèï">' . htmlspecialchars (escapeLoc ($row['list_name'])) . '</param>';
print '<param name="Ìàòåðèàë"></param>';
print '<param name="Êàïþøîí"></param>';
print '<param name="Êàðìàíû"></param>';
}
}
print "</item>";
}
}
print "</items>";
print "</price>";
?>