Blame view

price2.php1 3.09 KB
42868d70   andryeyev   Создал GIT
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
  <?php
  set_time_limit(0);
  header("Content-Type: text/xml");
  require("./libs/setup.php");
  $setup = new setup();
  $db = $setup->db;
  
   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'<?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_xml2=?",array(1),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,b.name as brend 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>";
  print"<group_id>0" . $row['id'] . "</group_id>";  
  print"<code></code>"; 
  print"<vendor>" . htmlspecialchars(escapeLoc($row['brend'])) . "</vendor>"; 
  print"<name>" . htmlspecialchars(escapeLoc($row['name'])) . "</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>" . $row['cine'] . "</priceRUAH>"; 
  print"<priceRUSD></priceRUSD>"; 
  print"<stock>Íà ñêëàäå</stock>"; 
  print"<guarantee></guarantee>";
  $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="RU">'.$row_m['size'].'</param>';
  print'<param name="Öâåò">'.$row_m['color'].'</param>';
  print'<param name="Ïîë"></param>';
  print'<param name="Âîçðàñò"></param>';
  print'<param name="Ðåïëèêà"></param>';
  print'<param name="Òèï"></param>';
  print'<param name="Ìàòåðèàë"></param>';
  print'<param name="Êàïþøîí"></param>';
  print'<param name="Êàðìàíû"></param>';
  } 
  print"</item>";
  }}
  print"</items>";
  
  
  print"</price>";
  ?>