Commit e8fe9e4afd1db7e5ba05899dbab27d5ace2bce0f

Authored by andryeyev
1 parent 0ef646d9

+ format price.php

Showing 1 changed file with 142 additions and 97 deletions   Show diff stats
1 <?php 1 <?php
2 -set_time_limit(0);  
3 -header("Content-Type: text/xml");  
4 -require("./libs/setup.php");  
5 -$setup = new setup();  
6 -$db = $setup->db;  
7 -$objCatalogs = $setup->setupClass("Catalogs");  
8 2
9 - function escapeLoc($loc){  
10 - $patterns = array();  
11 - $patterns[0] = '/&/';  
12 - $patterns[1] = '/\'/';  
13 - $patterns[2] = '/"/';  
14 - $patterns[3] = '/>/';  
15 - $patterns[4] = '/</';  
16 - $replacements = array();  
17 - $replacements[4] = '&amp;';  
18 - $replacements[3] = '&apos;';  
19 - $replacements[2] = '&quot;';  
20 - $replacements[1] = '&gt;';  
21 - $replacements[0] = '&lt;';  
22 -  
23 - $loc = preg_replace($patterns, $replacements, $loc);  
24 - return $loc;  
25 - }  
26 -  
27 -function nohtml($string) 3 + set_time_limit (0);
  4 + header ("Content-Type: text/xml");
  5 + require ("./libs/setup.php");
  6 + $setup = new setup ();
  7 + $db = $setup->db;
  8 + $objCatalogs = $setup->setupClass ("Catalogs");
  9 +
  10 +function escapeLoc ($loc)
28 { 11 {
29 - return preg_replace('/[^a-zà-ÿ¸\.\,\?\! 0-9]/i','',$string);; 12 + $patterns = array ();
  13 + $patterns[0] = '/&/';
  14 + $patterns[1] = '/\'/';
  15 + $patterns[2] = '/"/';
  16 + $patterns[3] = '/>/';
  17 + $patterns[4] = '/</';
  18 + $replacements = array ();
  19 + $replacements[4] = '&amp;';
  20 + $replacements[3] = '&apos;';
  21 + $replacements[2] = '&quot;';
  22 + $replacements[1] = '&gt;';
  23 + $replacements[0] = '&lt;';
  24 +
  25 + $loc = preg_replace ($patterns, $replacements, $loc);
  26 + return $loc;
30 } 27 }
31 28
32 -function modCodeNew($product_id){  
33 -global $objCatalogs;  
34 -return $objCatalogs->db->getOne('select new_code from catalogs_modifications where active=1 and product_id=? and new_code<>""',array($product_id));  
35 -} 29 +function nohtml ($string)
  30 +{
  31 + return preg_replace ('/[^a-zà-ÿ¸\.\,\?\! 0-9]/i', '', $string);
  32 +}
36 33
37 -print'<?xml version="1.0" encoding="windows-1251" ?>';  
38 -print"<price>";  
39 -print"<date>" . date("Y-m-d h:m") . "</date>";  
40 -print"<firmName>ExtremStyle</firmName>";  
41 -print"<firmId></firmId>";  
42 -print"<rate></rate>"; 34 +function modCodeNew ($product_id)
  35 +{
  36 + global $objCatalogs;
  37 + return $objCatalogs->db->getOne ('select new_code from catalogs_modifications where active=1 and product_id=? and new_code<>""', array (
  38 + $product_id
  39 + ));
  40 +}
43 41
  42 +print '<?xml version="1.0" encoding="windows-1251" ?>';
  43 +print "<price>";
  44 +print "<date>" . date ("Y-m-d h:m") . "</date>";
  45 +print "<firmName>ExtremStyle</firmName>";
  46 +print "<firmId></firmId>";
  47 +print "<rate></rate>";
44 48
45 -$res = $db->getAll("select * from catalogs_rubrics where is_xml=?",array(0),DB_FETCHMODE_ASSOC);  
46 -//print_r($res);  
47 -$rubrics = array();  
48 -print"<categories>";  
49 -foreach($res as $row){  
50 -$rubrics[] = $row['id'];  
51 -print"<category>";  
52 -print"<id>" . $row['id'] . "</id>";  
53 -print"<parentId>" . $row['parent_id'] . "</parentId>";  
54 -print"<name>" . $row['name'] . "</name>";  
55 -print"</category>"; 49 +$res = $db->getAll ("select * from catalogs_rubrics where is_xml=?", array (
  50 + 0
  51 +), DB_FETCHMODE_ASSOC);
  52 +// print_r($res);
  53 +$rubrics = array ();
  54 +print "<categories>";
  55 +foreach ($res as $row)
  56 +{
  57 + $rubrics[] = $row['id'];
  58 + print "<category>";
  59 + print "<id>" . $row['id'] . "</id>";
  60 + print "<parentId>" . $row['parent_id'] . "</parentId>";
  61 + print "<name>" . $row['name'] . "</name>";
  62 + print "</category>";
56 } 63 }
57 -print"</categories>"; 64 +print "</categories>";
58 65
59 -print"<items>";  
60 -foreach($rubrics as $rub){  
61 -$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);  
62 -foreach($res as $row){  
63 -print"<item>";  
64 -print"<id>" . $row['id'] . "</id>";  
65 -print"<categoryId>" . $row['rubric_id'] . "</categoryId>";  
66 -if($row['rubric_id']!=14055)print"<group_id>0" . $row['id'] . "</group_id>";  
67 -print"<code></code>";  
68 -print"<vendor>" . htmlspecialchars(escapeLoc($row['brend'])) . "</vendor>";  
69 -$row['ph1'] = $objCatalogs->getFilterPh1($row['id']);  
70 -$f = $objCatalogs->viewFilterProduct($row['id']);  
71 -$f_arr = array();  
72 -foreach($f as $_f){$f_arr[] = $_f['name'];}  
73 -$f_str = (count($f_arr)>0) ? implode(', ',$f_arr) : '';  
74 -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>";  
75 -print"<description>" . htmlspecialchars(nohtml(stripcslashes($row['text']))) . "</description>";  
76 -print"<url>http://extremstyle.ua/" . htmlspecialchars(escapeLoc($row['rubric_translit'])) . "-catalogs/" . htmlspecialchars(escapeLoc($row['translit'])) . "-" . $row['id'] . "/</url>";  
77 -print"<image>http://extremstyle.ua/uploaded/pic/catalogs/products/" . $row['pic'] . "</image>";  
78 -print"<priceRUAH>" . round($row['cine'] - ($row['cine']*$row['salepc']/100)) . "</priceRUAH>";  
79 -//print"<priceRUAH>" . $row['cine'] . "</priceRUAH>";  
80 -print"<oldprice>" . $row['cine'] . "</oldprice>";  
81 -print"<priceRUSD></priceRUSD>";  
82 -print"<stock>Íà ñêëàäå</stock>";  
83 -print"<guarantee></guarantee>";  
84 -IF($row['is_xml2']==1 && $row['rubric_id']!=14055){  
85 -if($row['sex']==1)$sex = 'Ìóæñêîé';  
86 -elseif($row['sex']==2)$sex = 'Æåíñêèé';  
87 -elseif($row['sex']==3)$sex = 'Äåòñêèé';  
88 -elseif($row['sex']==4)$sex = 'Óíèñåêñ';  
89 -else $sex = '';  
90 -$res_m = $db->getAll("select * from catalogs_modifications where active=1 and product_id=?",array($row['id']),DB_FETCHMODE_ASSOC);  
91 -foreach($res_m as $row_m){  
92 -print'<param name="Ðàçìåð" unit="INT">'.$row_m['size'].'</param>';  
93 -print'<param name="Öâåò">'.(($row['rubric_id']==14055)?$row_m['color']:$row_m['color2']).'</param>';  
94 -print'<param name="Ïîë">'.$sex.'</param>';  
95 -print'<param name="Âîçðàñò"></param>';  
96 -print'<param name="Ðåïëèêà"></param>';  
97 -print'<param name="Òèï">'.htmlspecialchars(escapeLoc($row['list_name'])).'</param>';  
98 -print'<param name="Ìàòåðèàë"></param>';  
99 -print'<param name="Êàïþøîí"></param>';  
100 -print'<param name="Êàðìàíû"></param>';  
101 -}  
102 -}  
103 -  
104 -print"</item>";  
105 -}}  
106 -print"</items>"; 66 +print "<items>";
  67 +
  68 + foreach ($rubrics as $rub)
  69 + {
  70 + $res = $db->getAll ("
  71 + select p.*,r.translit as rubric_translit,r.is_xml2,b.name as brend,r.list_name
  72 + from catalogs_products p
  73 + LEFT JOIN catalogs_rubrics r ON r.id=p.rubric_id
  74 + LEFT JOIN catalogs_brends b ON b.id=p.brend_id
  75 + where p.rubric_id=?
  76 + and p.count_modifications>0",
  77 + array (
  78 + $rub
  79 + ), DB_FETCHMODE_ASSOC);
  80 +
  81 + foreach ($res as $row)
  82 + {
  83 + print "<item>";
  84 + print "<id>" . $row['id'] . "</id>";
  85 + print "<categoryId>" . $row['rubric_id'] . "</categoryId>";
  86 +
  87 + if ($row['rubric_id'] != 14055)
  88 + print "<group_id>0" . $row['id'] . "</group_id>";
  89 +
  90 + print "<code></code>";
  91 + print "<vendor>" . htmlspecialchars (escapeLoc ($row['brend'])) . "</vendor>";
  92 +
  93 + $row['ph1'] = $objCatalogs->getFilterPh1 ($row['id']);
  94 + $f = $objCatalogs->viewFilterProduct ($row['id']);
  95 + $f_arr = array ();
  96 + foreach ($f as $_f)
  97 + {
  98 + $f_arr[] = $_f['name'];
  99 + }
  100 +
  101 + $f_str = (count ($f_arr) > 0) ? implode (', ', $f_arr) : '';
  102 + 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>";
  103 + print "<description>" . htmlspecialchars (nohtml (stripcslashes ($row['text']))) . "</description>";
  104 + print "<url>http://extremstyle.ua/" . htmlspecialchars (escapeLoc ($row['rubric_translit'])) . "-catalogs/" . htmlspecialchars (escapeLoc ($row['translit'])) . "-" . $row['id'] . "/</url>";
  105 + print "<image>http://extremstyle.ua/uploaded/pic/catalogs/products/" . $row['pic'] . "</image>";
  106 + print "<priceRUAH>" . round ($row['cine'] - ($row['cine'] * $row['salepc'] / 100)) . "</priceRUAH>";
  107 + // print"<priceRUAH>" . $row['cine'] . "</priceRUAH>";
  108 + print "<oldprice>" . $row['cine'] . "</oldprice>";
  109 + print "<priceRUSD></priceRUSD>";
  110 + print "<stock>Íà ñêëàäå</stock>";
  111 + print "<guarantee></guarantee>";
  112 +
  113 + IF ($row['is_xml2'] == 1 && $row['rubric_id'] != 14055)
  114 + {
  115 + if ($row['sex'] == 1)
  116 + $sex = 'Ìóæñêîé';
  117 + elseif ($row['sex'] == 2)
  118 + $sex = 'Æåíñêèé';
  119 + elseif ($row['sex'] == 3)
  120 + $sex = 'Äåòñêèé';
  121 + elseif ($row['sex'] == 4)
  122 + $sex = 'Óíèñåêñ';
  123 + else
  124 + $sex = '';
  125 +
  126 + $res_m = $db->getAll ("
  127 + select *
  128 + from catalogs_modifications
  129 + where active=1
  130 + and product_id=?", array (
  131 + $row['id']
  132 + ), DB_FETCHMODE_ASSOC);
  133 +
  134 + foreach ($res_m as $row_m)
  135 + {
  136 + print '<param name="Ðàçìåð" unit="INT">' . $row_m['size'] . '</param>';
  137 + print '<param name="Öâåò">' . (($row['rubric_id'] == 14055) ? $row_m['color'] : $row_m['color2']) . '</param>';
  138 + print '<param name="Ïîë">' . $sex . '</param>';
  139 + print '<param name="Âîçðàñò"></param>';
  140 + print '<param name="Ðåïëèêà"></param>';
  141 + print '<param name="Òèï">' . htmlspecialchars (escapeLoc ($row['list_name'])) . '</param>';
  142 + print '<param name="Ìàòåðèàë"></param>';
  143 + print '<param name="Êàïþøîí"></param>';
  144 + print '<param name="Êàðìàíû"></param>';
  145 + }
  146 + }
  147 +
  148 + print "</item>";
  149 + }
  150 + }
107 151
  152 +print "</items>";
108 153
109 -print"</price>"; 154 +print "</price>";
110 ?> 155 ?>
111 \ No newline at end of file 156 \ No newline at end of file