PageRenderTime 59ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/includes/modules/export/googlebase.php

https://github.com/tisoft/xtcmodified
PHP | 482 lines | 414 code | 32 blank | 36 comment | 122 complexity | 39bebc8b0c5adfaa88e65fba7b0fceee MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. /* -----------------------------------------------------------------------------------------
  3. $Id$
  4. xtcModified - community made shopping
  5. http://www.xtc-modified.org
  6. Copyright (c) 2010 xtcModified
  7. -----------------------------------------------------------------------------------------
  8. based on:
  9. (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
  10. (c) 2002-2003 osCommerce(cod.php,v 1.28 2003/02/14); www.oscommerce.com
  11. (c) 2003 nextcommerce (invoice.php,v 1.6 2003/08/24); www.nextcommerce.org
  12. (c) 2005 (froogle.php, v 1188 2005/08/28); matthias - www.xt-commerce.com
  13. (c) 2006 xt-commerce; www.xt-commerce.com
  14. -----------------------------------------------------------------------------------------
  15. Erweiterung der googlebase.php (c)2009 by Hetfield - http://www.MerZ-IT-SerVice.de um folgende Funktionen:
  16. - Gewichts- oder preisabhängige Vesandkosten mit Berücksichtigung der Versandkostenfrei-Grenze
  17. - Beachtung des Mindermengenzuschlags
  18. - Zustand 'neu' fest hinterlegt
  19. - Anzeige Zahlungsarten
  20. - Anzeige Gewicht
  21. - Anzeige EAN
  22. - Auswahl der verschiedenen suchmaschinenfreundlichen URL für den Exportlink (Original/keine, Shopstat oder DirectURL)
  23. - Umlautproblematik und str_replace-Wahnsinn beseitigt
  24. updated version by franky_n
  25. Released under the GNU General Public License
  26. ---------------------------------------------------------------------------------------*/
  27. defined( '_VALID_XTC' ) or die( 'Direct Access to this location is not allowed.' );
  28. define('MODULE_GOOGLEBASE_TEXT_TITLE', 'Google Base - TXT / XML<br/>Exportmodul f&uuml;r Google Base / inkl. Felder "Zustand" und "Versandkosten"');
  29. define('MODULE_GOOGLEBASE_TEXT_DESCRIPTION', 'Export - Google Base (Tab getrennt)');
  30. define('MODULE_GOOGLEBASE_FILE_TITLE' , '<hr noshade>Dateiname');
  31. define('MODULE_GOOGLEBASE_FILE_DESC' , 'Geben Sie einen Dateinamen ein, falls die Exportdatei am Server gespeichert werden soll.<br />(Verzeichnis export/)');
  32. define('MODULE_GOOGLEBASE_STATUS_TITLE','Status');
  33. define('MODULE_GOOGLEBASE_STATUS_DESC','Modulstatus');
  34. define('MODULE_GOOGLEBASE_CURRENCY_TITLE','W&auml;hrung');
  35. define('MODULE_GOOGLEBASE_CURRENCY_DESC','Welche W&auml;hrung soll exportiert werden?');
  36. define('MODULE_GOOGLEBASE_SHIPPING_COST_TITLE','<hr noshade><b>Versandkosten</b>');
  37. define('MODULE_GOOGLEBASE_SHIPPING_COST_DESC','Die Versandkosten basieren auf dem Artikelpreis oder dem Artikelgewicht. Beispiel: 25:4.90,50:9.90,etc.. Bis 25 werden 4.90 verrechnet, dar&uuml;ber bis 50 werden 9.90 verrechnet, etc.');
  38. define('MODULE_GOOGLEBASE_SHIPPING_ART_TITLE','<hr noshade><b>Versandkosten-Methode</b>');
  39. define('MODULE_GOOGLEBASE_SHIPPING_ART_DESC','Die Versandkosten basieren auf dem Artikelpreis oder dem Artikelgewicht.');
  40. define('MODULE_GOOGLEBASE_SUMAURL_TITLE','<hr noshade><b>Suchmaschinenfreundliche URL</b>');
  41. define('MODULE_GOOGLEBASE_SUMAURL_DESC','W&auml;hlen Sie aus, ob und welche Erweiterung Sie f&uuml;r suchmaschinenfreundliche URL in Ihrem Shop nutzen');
  42. define('MODULE_GOOGLEBASE_FORMAT_TITLE','Exportformat');
  43. define('MODULE_GOOGLEBASE_FORMAT_DESC','Welches Format soll exportiert werden?');
  44. define('EXPORT_YES','Nur Herunterladen');
  45. define('EXPORT_NO','Am Server Speichern');
  46. define('CURRENCY','<hr noshade><b>W&auml;hrung:</b>');
  47. define('CURRENCY_DESC','W&auml;hrung in der Exportdatei');
  48. define('EXPORT','Bitte den Sicherungsprozess AUF KEINEN FALL unterbrechen. Dieser kann einige Minuten in Anspruch nehmen.');
  49. define('EXPORT_TYPE','<hr noshade><b>Speicherart:</b>');
  50. define('EXPORT_STATUS_TYPE','<hr noshade><b>Kundengruppe:</b>');
  51. define('EXPORT_STATUS','Bitte w&auml;hlen Sie die Kundengruppe, die Basis f&uuml;r den Exportierten Preis bildet. (Falls Sie keine Kundengruppenpreise haben, w&auml;hlen Sie <i>Gast</i>):</b>');
  52. define('CAMPAIGNS','<hr noshade><b>Kampagnen:</b>');
  53. define('CAMPAIGNS_DESC','Mit Kampagne zur Nachverfolgung verbinden.');
  54. define('SHIPPING_COUNTRY','<hr noshade><b>Land (optional):</b>');
  55. define('SHIPPING_COUNTRY_DESC','Das Land, in das der Artikel geliefert wird. Bitte geben Sie DE als Wert an. Google Base akzeptiert nur Versandkosten f&uuml;r Lieferungen innerhalb Deutschlands.<br />Hinweis: Falls kein Wert angegeben wird, nimmt Google Base an, dass sich die Versandkosten auf das Zielland des Artikels beziehen.');
  56. define('DATE_FORMAT_EXPORT', '%d.%m.%Y'); // this is used for strftime()
  57. // include needed functions
  58. class googlebase {
  59. var $code, $title, $description, $enabled;
  60. function googlebase() {
  61. global $order;
  62. $this->code = 'googlebase';
  63. $this->title = MODULE_GOOGLEBASE_TEXT_TITLE;
  64. $this->description = MODULE_GOOGLEBASE_TEXT_DESCRIPTION;
  65. $this->sort_order = MODULE_GOOGLEBASE_SORT_ORDER;
  66. $this->enabled = ((MODULE_GOOGLEBASE_STATUS == 'True') ? true : false);
  67. $this->CAT=array();
  68. $this->PARENT=array();
  69. }
  70. function process($file = MODULE_GOOGLEBASE_FILE) {
  71. // Read Modules
  72. $module_type = 'payment';
  73. $module_directory = DIR_FS_CATALOG_MODULES . 'payment/';
  74. $module_file_extension = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '.'));
  75. $directory_array = array();
  76. if ($dir = @dir($module_directory)) {
  77. while ($module_file = $dir->read()) {
  78. if (!is_dir($module_directory . $module_file)) {
  79. if (substr($module_file, strrpos($module_file, '.')) == $module_file_extension) {
  80. $directory_array[] = $module_file;
  81. }
  82. }
  83. }
  84. sort($directory_array);
  85. $dir->close();
  86. }
  87. $installed_modules = array();
  88. $module_info = array();
  89. for ($i = 0, $n = sizeof($directory_array); $i < $n; $i++) {
  90. $module_file = $directory_array[$i];
  91. include(DIR_FS_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $module_file);
  92. include($module_directory . $module_file);
  93. $class = substr($module_file, 0, strrpos($module_file, '.'));
  94. if (xtc_class_exists($class)) {
  95. $module = new $class();
  96. $module_info[] = array($module->code => $module->title);
  97. }
  98. }
  99. @xtc_set_time_limit(0);
  100. require(DIR_FS_CATALOG.DIR_WS_CLASSES . 'xtcPrice.php');
  101. $xtPrice = new xtcPrice($_POST['currencies'],$_POST['status']);
  102. if ($_POST['sumaurl'] == 'directurl') {
  103. require_once(DIR_FS_CATALOG.'inc/bluegate_seo.inc.php');
  104. $bluegateSeo = new BluegateSeo();
  105. }
  106. $schema_txt_de = "beschreibung".chr(9)."id".chr(9)."link".chr(9)."preis".chr(9)."w".chr(228)."hrung".chr(9)."titel".chr(9)."zustand".chr(9)."bild_url".chr(9)."ean".chr(9)."gewicht".chr(9)."marke".chr(9)."versand".chr(9)."zahlungsmethode".chr(9)."zahlungsrichtlinien".chr(13);
  107. $schema_xml_de = '<?xml version="1.0" encoding="UTF-8"?>'."\n".
  108. '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">'."\n".
  109. "\t".'<channel>'."\n".
  110. "\t"."\t".'<title>'.htmlspecialchars(TITLE).'</title>'."\n".
  111. "\t"."\t".'<description>'.META_DESCRIPTION.'</description>'."\n".
  112. "\t"."\t".'<link>'.HTTP_SERVER.'</link>'."\n";
  113. if ($_POST['shippingcosts'] != MODULE_GOOGLEBASE_SHIPPING_COST) {
  114. xtc_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . xtc_db_input($_POST['shippingcosts']) . "' where configuration_key = 'MODULE_GOOGLEBASE_SHIPPING_COST'");
  115. }
  116. $zahlungsmethode = '';
  117. if (defined('MODULE_PAYMENT_INSTALLED') && xtc_not_null(MODULE_PAYMENT_INSTALLED)) {
  118. $other_payments = '';
  119. $creditcard_modules = array('cc', 'moneybookers_cc', 'amoneybookers', 'uos_kreditkarte_modul', 'uos_transfer_modul', 'uos_utdirekt_kk_modul', 'worldpay', 'ipayment', 'iclear', 'paymentpartner_cc', 'wire_card_c3');
  120. $americanexpress_modules = array('cc', 'moneybookers_cc', 'amoneybookers', 'ipayment');
  121. $lastschrift_modules = array('banktransfer', 'uos_lastschrift_modul', 'uos_lastschrift_de_modul', 'uos_lastschrift_at_modul', 'uos_utdirekt_ls_modul', 'ipaymentelv', 'paymentpartner_dd');
  122. $ueberweisung_modules = array('moneyorder', 'sofortueberweisungvorkasse', 'eustandardtransfer', 'uos_vorkasse_modul', 'uos_utdirekt_vk_modul');
  123. $cash_modules = array('cash');
  124. $scheck_modules = array('moneyorder');
  125. $customers_status_query = xtc_db_query("SELECT customers_status_payment_unallowed FROM " . TABLE_CUSTOMERS_STATUS . " WHERE customers_status_id = '" . (int)$_POST['status'] . "' AND language_id = '" . (int)$_SESSION['languages_id'] . "'");
  126. $customers_status_value = xtc_db_fetch_array($customers_status_query);
  127. $installedpayments = explode(';', MODULE_PAYMENT_INSTALLED);
  128. $unallowed_payment_modules = explode(',', $customers_status_value['customers_status_payment_unallowed']);
  129. for ($i = 0, $n = sizeof($installedpayments); $i < $n; $i++) {
  130. $installedpayments[$i] = str_replace('.php','',$installedpayments[$i]);
  131. if (!in_array($installedpayments[$i], $unallowed_payment_modules)) {
  132. if (in_array($installedpayments[$i], $creditcard_modules)) { $cc = true; } else
  133. if (in_array($installedpayments[$i], $americanexpress_modules)) { $ae = true; } else
  134. if (in_array($installedpayments[$i], $lastschrift_modules)) { $la = true; } else
  135. if (in_array($installedpayments[$i], $ueberweisung_modules)) { $uw = true; } else
  136. if (in_array($installedpayments[$i], $cash_modules)) { $ca = true; } else
  137. if (in_array($installedpayments[$i], $scheck_modules)) { $sc = true; } else {
  138. $number_module_info = (count($module_info)-1);
  139. foreach ($module_info as $module_key) {
  140. foreach ($module_key as $module_attr => $module_desc) {
  141. if ($installedpayments[$i] == $module_attr) {
  142. if ($number_module_info != $module_key) {
  143. $other_payments .= $module_desc .', ';
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. if ($cc == true) { $creditcard = 'Visa,MasterCard,'; } else { $creditcard = ''; }
  152. if ($ae == true) { $americanexpress = 'AmericanExpress,'; } else { $americanexpress = ''; }
  153. if ($la == true) { $lastschrift = 'Lastschrift,'; } else { $lastschrift = ''; }
  154. if ($uw == true) { $ueberweisung = chr(220).'berweisung,'; } else { $ueberweisung = ''; }
  155. if ($ca == true) { $cash = 'Barzahlung,'; } else { $cash = ''; }
  156. if ($sc == true) { $scheck = 'Scheck'; } else { $scheck = ''; }
  157. $zahlungsmethode = $creditcard.$americanexpress.$lastschrift.$ueberweisung.$cash.$scheck;
  158. if (substr($zahlungsmethode, -1) == ',') { $zahlungsmethode = substr($zahlungsmethode, 0, -1); }
  159. if (substr($other_payments, -2) == ', ') { $other_payments = substr($other_payments, 0, -2); }
  160. $zahlungsrichtlinie = 'Wir unterst&uuml;tzen neben den Zahlungsarten '.$zahlungsmethode.' auch noch folgende Zahlungsarten '.$other_payments;
  161. }
  162. $export_query = xtc_db_query("SELECT
  163. p.products_id,
  164. pd.products_name,
  165. pd.products_description,
  166. p.products_model,
  167. p.products_ean,
  168. p.products_image,
  169. p.products_price,
  170. p.products_weight,
  171. p.products_tax_class_id,
  172. m.manufacturers_name
  173. FROM
  174. " . TABLE_PRODUCTS . " p LEFT JOIN
  175. " . TABLE_MANUFACTURERS . " m
  176. ON p.manufacturers_id = m.manufacturers_id LEFT JOIN
  177. " . TABLE_PRODUCTS_DESCRIPTION . " pd
  178. ON p.products_id = pd.products_id AND
  179. pd.language_id = '".$_SESSION['languages_id']."' LEFT JOIN
  180. " . TABLE_SPECIALS . " s
  181. ON p.products_id = s.products_id
  182. WHERE
  183. p.products_status = 1
  184. ORDER BY
  185. p.products_date_added DESC,
  186. pd.products_name");
  187. while ($products = xtc_db_fetch_array($export_query)) {
  188. $products_price = $xtPrice->xtcGetPrice($products['products_id'], $format=false, 1, $products['products_tax_class_id'], '');
  189. $categorie_query=xtc_db_query("SELECT
  190. categories_id
  191. FROM ".TABLE_PRODUCTS_TO_CATEGORIES."
  192. WHERE products_id='".$products['products_id']."'");
  193. while ($categorie_data=xtc_db_fetch_array($categorie_query)) {
  194. $categories=$categorie_data['categories_id'];
  195. }
  196. // remove trash
  197. $products_description = strip_tags($products['products_description']);
  198. $products_description = html_entity_decode($products_description);
  199. $products_description = str_replace(";",", ",$products_description);
  200. $products_description = str_replace("'",", ",$products_description);
  201. $products_description = str_replace("\n"," ",$products_description);
  202. $products_description = str_replace("\r"," ",$products_description);
  203. $products_description = str_replace("\t"," ",$products_description);
  204. $products_description = str_replace("\v"," ",$products_description);
  205. $products_description = str_replace(chr(13)," ",$products_description);
  206. $products_description = substr($products_description, 0, 65536);
  207. $products_name = strip_tags($products['products_name']);
  208. $products_name = html_entity_decode($products_name);
  209. $products_name = str_replace(";",", ",$products_name);
  210. $products_name = str_replace("'",", ",$products_name);
  211. $products_name = str_replace("\n"," ",$products_name);
  212. $products_name = str_replace("\r"," ",$products_name);
  213. $products_name = str_replace("\t"," ",$products_name);
  214. $products_name = str_replace("\v"," ",$products_name);
  215. $products_name = str_replace(chr(13)," ",$products_name);
  216. $cat = $this->buildCAT($categories);
  217. if ($products['products_image'] != ''){
  218. $image = HTTP_CATALOG_SERVER . DIR_WS_CATALOG_ORIGINAL_IMAGES .$products['products_image'];
  219. } else {
  220. $image = '';
  221. }
  222. if ($products['products_weight'] != '0.00'){
  223. $weight = number_format($products['products_weight'],2,'.','');
  224. } else {
  225. $weight = '';
  226. }
  227. $versand = '0.00';
  228. if ($products_price < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER && MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS == 'true') {
  229. if (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION == 'national' or MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION == 'both') {
  230. $customers_tax_query = xtc_db_query("SELECT customers_status_show_price_tax, customers_status_add_tax_ot FROM " . TABLE_CUSTOMERS_STATUS . " WHERE customers_status_id = '" . (int)$_POST['status'] . "' AND language_id = '" . (int)$_SESSION['languages_id'] . "'");
  231. $customers_tax_value = xtc_db_fetch_array($customers_tax_query);
  232. $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS);
  233. if ($customers_tax_value['customers_status_show_price_tax'] == 1) {
  234. $low_order_fee = xtc_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
  235. }
  236. if ($customers_tax_value['customers_status_show_price_tax'] == 0 && $customers_tax_value['customers_status_add_tax_ot'] == 1) {
  237. $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE;
  238. }
  239. if ($customers_tax_value['customers_status_show_price_tax'] == 0 && $customers_tax_value['customers_status_add_tax_ot'] != 1) {
  240. $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE;
  241. }
  242. $versand = $versand + $low_order_fee;
  243. }
  244. }
  245. if ($products_price > MODULE_SHIPPING_FREEAMOUNT_AMOUNT && MODULE_SHIPPING_FREEAMOUNT_STATUS == 'True') {
  246. $versand = $versand;
  247. } else if ($products_price > MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
  248. $versand = $versand;
  249. } else {
  250. $shipping = -1;
  251. $shippinglist = preg_split("/[:,]/" , $_POST['shippingcosts']); // Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3
  252. for ($i=0; $i<sizeof($shippinglist); $i+=2) {
  253. if ($_POST['shippingart'] == 'weight') {
  254. if ($products['products_weight'] <= $shippinglist[$i]) {
  255. $shipping = $shippinglist[$i+1];
  256. break;
  257. }
  258. } else if ($_POST['shippingart'] == 'price') {
  259. if ($products_price <= $shippinglist[$i]) {
  260. $shipping = $shippinglist[$i+1];
  261. break;
  262. }
  263. }
  264. }
  265. if ($shipping == -1) {
  266. $shipping_cost = 0;
  267. } else {
  268. $shipping_cost = $shipping;
  269. }
  270. $versand = $versand + $shipping_cost;
  271. }
  272. if ($_POST['sumaurl'] == 'shopstat') {
  273. $cat = strip_tags($this->buildCAT($categories));
  274. require_once(DIR_FS_INC . 'xtc_href_link_from_admin.inc.php');
  275. $productURL = xtc_href_link_from_admin('product_info.php', xtc_product_link($products['products_id'], $products['products_name']), 'NONSSL', false);
  276. if (!empty($_POST['campaign'])) {
  277. $productURL .= '?'.$_POST['campaign'];
  278. }
  279. } else if ($_POST['sumaurl'] == 'directurl') {
  280. $productURL = $bluegateSeo->getProductLink(xtc_product_link($products['products_id'], $products['products_name']),$connection,$_SESSION['languages_id']);
  281. if ($_POST['campaign']<>'') {
  282. $productURL .= '?'.$_POST['campaign'];
  283. }
  284. } else if ($_POST['sumaurl'] == 'original') {
  285. $productURL = HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'product_info.php?'.xtc_product_link($products['products_id'], $products['products_name']);
  286. if (!empty($_POST['campaign'])) {
  287. $productURL .= '&'.$_POST['campaign'];
  288. }
  289. }
  290. //create content
  291. $schema_txt_de .= $products_description."\t".
  292. $products['products_id']."\t".
  293. $productURL . "\t" .
  294. number_format($products_price,2,'.','')."\t".
  295. $_POST['currencies']."\t".
  296. $products_name."\t".
  297. "neu\t".
  298. $image."\t" .
  299. $products['products_ean']."\t".
  300. $weight."\t".
  301. $products['manufacturers_name']."\t".
  302. $_POST['shipping_country'].":::".number_format($versand,2,'.','')."\t" .
  303. $zahlungsmethode."\t".
  304. $zahlungsrichtlinie."\n";
  305. $schema_xml_de .= "\t"."\t".'<item>'."\n".
  306. "\t"."\t"."\t".'<beschreibung>'.$products_description.'</beschreibung>'."\n".
  307. "\t"."\t"."\t".'<g:id>'.$products['products_id'].'</g:id>'."\n".
  308. "\t"."\t"."\t".'<link>'.str_replace('&', '&amp;', $productURL).'</link>'."\n".
  309. "\t"."\t"."\t".'<g:preis>'.number_format($products_price,2,'.','').'</g:preis>'."\n".
  310. "\t"."\t"."\t".'<g:währung>'.$_POST['currencies'].'</g:währung>'."\n".
  311. "\t"."\t"."\t".'<titel>'.$products_name.'</titel>'."\n".
  312. "\t"."\t"."\t".'<g:zustand>'.'neu'.'</g:zustand>'."\n".
  313. "\t"."\t"."\t".'<g:bild_url>'.$image.'</g:bild_url>'."\n" .
  314. "\t"."\t"."\t".'<g:ean>'.$products['products_ean'].'</g:ean>'."\n".
  315. "\t"."\t"."\t".'<g:gewicht>'.$weight.'</g:gewicht>'."\n".
  316. "\t"."\t"."\t".'<g:marke>'.$products['manufacturers_name'].'</g:marke>'."\n".
  317. "\t"."\t"."\t".'<g:versand>'.$_POST['shipping_country'].':::'.number_format($versand,2,'.','').'</g:versand>'."\n" .
  318. "\t"."\t"."\t".'<g:zahlungsmethode>'.$zahlungsmethode.'</g:zahlungsmethode>'."\n" .
  319. "\t"."\t"."\t".'<g:payment_notes>'.$zahlungsrichtlinie.'</g:payment_notes>'."\n".
  320. "\t"."\t".'</item>'."\n";
  321. }
  322. $schema_xml_de .= "\t".'</channel>'."\n".
  323. '</rss>'."\n";
  324. // create File
  325. $fp = fopen(DIR_FS_DOCUMENT_ROOT.'export/' . $file, "w+");
  326. if (MODULE_GOOGLEBASE_FORMAT == 'TXT') {
  327. fputs($fp,$schema_txt_de);
  328. } else {
  329. fputs($fp,$schema_xml_de);
  330. }
  331. fclose($fp);
  332. switch ($_POST['export']) {
  333. case 'yes':
  334. // send File to Browser
  335. $extension = substr($file, -3);
  336. $fp = fopen(DIR_FS_DOCUMENT_ROOT.'export/' . $file,"rb");
  337. $buffer = fread($fp, filesize(DIR_FS_DOCUMENT_ROOT.'export/' . $file));
  338. fclose($fp);
  339. header('Content-type: application/x-octet-stream; charset=iso-8859-15');
  340. header('Content-disposition: attachment; filename=' . $file);
  341. echo $buffer;
  342. exit;
  343. break;
  344. }
  345. }
  346. function buildCAT($catID) {
  347. if (isset($this->CAT[$catID])) {
  348. return $this->CAT[$catID];
  349. } else {
  350. $cat=array();
  351. $tmpID=$catID;
  352. while ($this->getParent($catID)!=0 || $catID!=0) {
  353. $cat_select=xtc_db_query("SELECT categories_name FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE categories_id='".$catID."' and language_id='".$_SESSION['languages_id']."'");
  354. $cat_data=xtc_db_fetch_array($cat_select);
  355. $catID=$this->getParent($catID);
  356. $cat[]=$cat_data['categories_name'];
  357. }
  358. $catStr='';
  359. for ($i=count($cat);$i>0;$i--) {
  360. $catStr.=$cat[$i-1].' > ';
  361. }
  362. $this->CAT[$tmpID]=$catStr;
  363. return $this->CAT[$tmpID];
  364. }
  365. }
  366. function getParent($catID) {
  367. if (isset($this->PARENT[$catID])) {
  368. return $this->PARENT[$catID];
  369. } else {
  370. $parent_query=xtc_db_query("SELECT parent_id FROM ".TABLE_CATEGORIES." WHERE categories_id='".$catID."'");
  371. $parent_data=xtc_db_fetch_array($parent_query);
  372. $this->PARENT[$catID]=$parent_data['parent_id'];
  373. return $parent_data['parent_id'];
  374. }
  375. }
  376. function display() {
  377. $customers_statuses_array = xtc_get_customers_statuses();
  378. // build Currency Select
  379. $curr='';
  380. $currencies=xtc_db_query("SELECT code FROM ".TABLE_CURRENCIES);
  381. while ($currencies_data=xtc_db_fetch_array($currencies)) {
  382. $curr.=xtc_draw_radio_field('currencies', $currencies_data['code'],true).$currencies_data['code'].'<br />';
  383. }
  384. $campaign_array = array(array('id' => '', 'text' => TEXT_NONE));
  385. $campaign_query = xtc_db_query("select campaigns_name, campaigns_refID from ".TABLE_CAMPAIGNS." order by campaigns_id");
  386. while ($campaign = xtc_db_fetch_array($campaign_query)) {
  387. $campaign_array[] = array ('id' => 'refID='.$campaign['campaigns_refID'], 'text' => $campaign['campaigns_name'],);
  388. }
  389. $shipping_country_array = array(array('id' => '', 'text' => TEXT_NONE));
  390. $shipping_country_query = xtc_db_query("SELECT countries_iso_code_2 FROM ".TABLE_COUNTRIES." ORDER BY countries_iso_code_2");
  391. while ($shipping_country = xtc_db_fetch_array($shipping_country_query)) {
  392. $shipping_country_array[] = array('id' => strtoupper($shipping_country['countries_iso_code_2']), 'text' => strtoupper($shipping_country['countries_iso_code_2']),);
  393. }
  394. return array('text' => EXPORT_STATUS_TYPE.'<br />'.
  395. EXPORT_STATUS.'<br />'.
  396. xtc_draw_pull_down_menu('status',$customers_statuses_array, '1').'<br />'.
  397. CURRENCY.'<br />'.
  398. CURRENCY_DESC.'<br />'.
  399. $curr.
  400. '<b>'.MODULE_GOOGLEBASE_SHIPPING_COST_TITLE.'</b><br />'.
  401. MODULE_GOOGLEBASE_SHIPPING_COST_DESC.'<br />'.
  402. xtc_draw_input_field('shippingcosts',MODULE_GOOGLEBASE_SHIPPING_COST).'<br />'.
  403. '<b>'.MODULE_GOOGLEBASE_SHIPPING_ART_TITLE.'</b><br />'.
  404. MODULE_GOOGLEBASE_SHIPPING_ART_DESC.'<br />'.
  405. xtc_draw_radio_field('shippingart', 'weight',true).'Versandksten nach Gewicht<br />'.
  406. xtc_draw_radio_field('shippingart', 'price',false).'Versandkosten nach Preis<br />'.
  407. SHIPPING_COUNTRY.'<br />'.
  408. SHIPPING_COUNTRY_DESC.'<br />'.
  409. xtc_draw_pull_down_menu('shipping_country',$shipping_country_array,'DE').'<br />'.
  410. '<b>'.MODULE_GOOGLEBASE_SUMAURL_TITLE.'</b><br />'.
  411. MODULE_GOOGLEBASE_SUMAURL_DESC.'<br />'.
  412. xtc_draw_radio_field('sumaurl', 'original',true).'Originale bzw. keine<br />'.
  413. xtc_draw_radio_field('sumaurl', 'shopstat',false).'Shopstat<br />'.
  414. xtc_draw_radio_field('sumaurl', 'directurl',false).'DirectURL<br />'.
  415. CAMPAIGNS.'<br />'.
  416. CAMPAIGNS_DESC.'<br />'.
  417. xtc_draw_pull_down_menu('campaign',$campaign_array).'<br />'.
  418. EXPORT_TYPE.'<br />'.
  419. EXPORT.'<br />'.
  420. xtc_draw_radio_field('export', 'no',false).EXPORT_NO.'<br />'.
  421. xtc_draw_radio_field('export', 'yes',true).EXPORT_YES.'<br />'.
  422. '<br />' . xtc_button(BUTTON_EXPORT) .
  423. xtc_button_link(BUTTON_CANCEL, xtc_href_link(FILENAME_MODULE_EXPORT, 'set=' . $_GET['set'] . '&module=googlebase')));
  424. }
  425. function check() {
  426. if (!isset($this->_check)) {
  427. $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_GOOGLEBASE_STATUS'");
  428. $this->_check = xtc_db_num_rows($check_query);
  429. }
  430. return $this->_check;
  431. }
  432. function install() {
  433. xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_GOOGLEBASE_FILE', 'googlebase.txt', '6', '1', '', now())");
  434. xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_GOOGLEBASE_STATUS', 'True', '6', '1', 'xtc_cfg_select_option(array(\'True\', \'False\'), ', now())");
  435. xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) values ('MODULE_GOOGLEBASE_SHIPPING_COST', '25:6.90,50:9.90,10000:0.00', '6', '1', '', '', now())");
  436. xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_GOOGLEBASE_FORMAT', 'TXT', '6', '1', 'xtc_cfg_select_option(array(\'TXT\', \'XML\'), ', now())");
  437. }
  438. function remove() {
  439. xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  440. xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_GOOGLEBASE_SHIPPING_COST'");
  441. }
  442. function keys() {
  443. return array('MODULE_GOOGLEBASE_STATUS','MODULE_GOOGLEBASE_FORMAT','MODULE_GOOGLEBASE_FILE');
  444. }
  445. }
  446. ?>