Advertisement
Incubus

Kuponator XML Generator

Feb 3rd, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.69 KB | None | 0 0
  1. <?php
  2. header("Content-type: text/xml");  
  3. ob_start();
  4. $xml = '<?xml version="1.0" encoding="UTF-8"?>
  5. <discounts>
  6. <operator>
  7. <name>Bumbay</name>
  8. <url>http://bumbay.ru</url>
  9. <param></param>
  10. <logo>http://public.lablz.com/images/logoObval.png</logo>
  11. <logo264>http://kuponator.ru/pics/big/obval.com.jpg</logo264>
  12. <logo88>http://kuponator.ru/pics/small/obval.com.jpg</logo88>
  13. <logo16>http://kuponator.ru/pics/fav/obval.com.gif</logo16>
  14. </operator>
  15. <offers>
  16. ';
  17. ?>
  18. <?
  19. foreach ($offers as $offer) {
  20. foreach ($offer->city as $city) {
  21. $xml = $xml.'<offer>
  22. <id>'.$offer['id'].'</id>
  23. <url>'.'http://bumbay.ru/good/'.$offer['id'].'</url>
  24. <name>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['name'])).'</name>
  25. <description>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['short_description'])).'</description>
  26. <region>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$city['name'])).'</region>
  27. <beginsell>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['time_start'])).'</beginsell>
  28. <endsell>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['time_end'])).'</endsell>
  29. <beginvalid>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['time_start'])).'</beginvalid>
  30. <endvalid>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['time_end_coupon'])).'</endvalid>
  31. <picture>';
  32. ?>
  33.  
  34. <?
  35. foreach ($offer->goodImages as $img) {
  36. $xml = $xml.'http://bumbay.ru/images/goods/'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$img->image));
  37. //break;   
  38. }
  39. ?>
  40. <? $xml = $xml.'</picture>
  41. <price>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['good_price'])).'</price>
  42. <discount>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['skidka'])).'</discount>
  43. <discountprice>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer['price'])).'</discountprice>
  44. <pricecoupon>0</pricecoupon>
  45. <supplier>
  46. <name>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer->partner['ofice_name'])).'</name>
  47. <url>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer->partner['site'])).'</url>
  48. <tel>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer->partner['telephon'])).'</tel>
  49. <addresses>
  50. <address>
  51. <name>'.strip_tags(str_replace(array("\n",'&nbsp;','&laquo;','&raquo;','&mdash;','&ndash;','&reg;','&times;','&hellip;','&amp;'),' ',$offer->partner['f_adres'])).'</name>
  52. </address>
  53. </addresses>
  54. </supplier>
  55. </offer>
  56. ';
  57. }
  58. }
  59. ?>
  60. <? $xml = $xml.'
  61. </offers>
  62. </discounts>';
  63. echo $xml;
  64. $output = ob_get_contents();
  65. ob_end_clean();
  66. $file = fopen("action.xml","wt") or die("err");
  67. fputs($file,$output);
  68. fclose($file);
  69.  
  70. $base = file_get_contents("action.xml");
  71. $base = trim(preg_replace("/[\r\n]+/m","\r\n", $base));
  72.  
  73. $fp = fopen("action.xml", "w");
  74. fwrite($fp, $base);
  75. fclose($fp);
  76.  
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement