Webinterpret_Connector - Version 1.2.7.3

Version Notes

- Added auto-update functionality
- Fixed bug with country redirect popup
- Fixed HTTP => HTTPS redirect bug
- Added German translations

Download this release

Release Info

Developer Webinterpret
Extension Webinterpret_Connector
Version 1.2.7.3
Comparing to
See all releases


Code changes from version 1.2.7 to 1.2.7.3

app/code/community/Webinterpret/Connector/Block/Product/Redirect.php CHANGED
@@ -26,7 +26,7 @@ class Webinterpret_Connector_Block_Product_Redirect extends Mage_Core_Block_Temp
26
  $medium .= '_pg';
27
  }
28
  }
29
- $campaign = is_null($campaign) ? Mage::getStoreConfig('general/locale/code') : $campaign;
30
 
31
  $params = array(
32
  'utm_source' => $source,
@@ -36,19 +36,24 @@ class Webinterpret_Connector_Block_Product_Redirect extends Mage_Core_Block_Temp
36
  return http_build_query($params);
37
  }
38
 
 
 
 
 
 
39
  public function getRedirectUrl($iframe = false)
40
  {
41
  $productId = $this->getProductId();
42
  if (isset($_GET['wi_pid'])) {
43
  $productId = $_GET['wi_pid'];
44
  }
45
- $redirectUrl = '//inventory.glopal.com/v1/open/redirect/product/' . $productId;
46
  $storeUrl = Mage::helper('webinterpret_connector')->getStoreBaseUrl();
47
  if (isset($_GET['wi_store_url'])) {
48
  $storeUrl = $_GET['wi_store_url'];
49
  }
50
- $scheme = parse_url($storeUrl, PHP_URL_SCHEME);
51
- $redirectUrl = $scheme . ':' . $redirectUrl;
52
  $params = array(
53
  'store_url' => $storeUrl,
54
  );
@@ -62,4 +67,16 @@ class Webinterpret_Connector_Block_Product_Redirect extends Mage_Core_Block_Temp
62
  {
63
  return $this->getRedirectUrl(true);
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
26
  $medium .= '_pg';
27
  }
28
  }
29
+ $campaign = is_null($campaign) ? $this->getLocaleCode() : $campaign;
30
 
31
  $params = array(
32
  'utm_source' => $source,
36
  return http_build_query($params);
37
  }
38
 
39
+ public function getLocaleCode()
40
+ {
41
+ return Mage::getStoreConfig('general/locale/code');
42
+ }
43
+
44
  public function getRedirectUrl($iframe = false)
45
  {
46
  $productId = $this->getProductId();
47
  if (isset($_GET['wi_pid'])) {
48
  $productId = $_GET['wi_pid'];
49
  }
50
+ $redirectUrl = 'https://inventory.glopal.com/v1/open/redirect/product/' . $productId;
51
  $storeUrl = Mage::helper('webinterpret_connector')->getStoreBaseUrl();
52
  if (isset($_GET['wi_store_url'])) {
53
  $storeUrl = $_GET['wi_store_url'];
54
  }
55
+ // $scheme = parse_url($storeUrl, PHP_URL_SCHEME);
56
+ // $redirectUrl = $scheme . ':' . $redirectUrl;
57
  $params = array(
58
  'store_url' => $storeUrl,
59
  );
67
  {
68
  return $this->getRedirectUrl(true);
69
  }
70
+
71
+ public function buildTrackEventData($category = null, $action = null, $name = null, $value = null)
72
+ {
73
+ $data = array(
74
+ 'category' => $category,
75
+ 'action' => $action,
76
+ 'name' => $name,
77
+ 'value' => $value,
78
+ 'store_locale' => $this->getLocaleCode(),
79
+ );
80
+ return http_build_query($data);
81
+ }
82
  }
app/code/community/Webinterpret/Connector/Helper/Data.php CHANGED
@@ -43,7 +43,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
43
  $dir = $this->getModuleBridgeDir();
44
 
45
  // Install bridge.php
46
- $remoteFile = $repo . DS . 'bridge2cart' . DS . '1.2' . DS . 'bridge.php';
47
  $contents = $this->downloadFile($remoteFile);
48
  if ($contents === false) {
49
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to download file: %s<br>Please contact Webinterpret support.", $remoteFile));
@@ -51,13 +51,13 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
51
  }
52
  $localFile = $dir . DS . 'bridge.php';
53
  $contents = str_replace('exit();', '', $contents);
54
- if (file_put_contents($localFile, $contents) === false) {
55
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
56
  return false;
57
  }
58
 
59
  // Install config.php
60
- $remoteFile = $repo . DS . 'bridge2cart' . DS . '1.2' . DS . 'config.php';
61
  $contents = $this->downloadFile($remoteFile);
62
  if ($contents === false) {
63
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to download file: %s<br>Please contact Webinterpret support.", $remoteFile));
@@ -65,7 +65,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
65
  }
66
  $localFile = $dir . DS . 'config.php';
67
  $contents = str_replace('exit();', '', $contents);
68
- if (file_put_contents($localFile, $contents) === false) {
69
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
70
  return false;
71
  }
@@ -75,13 +75,33 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
75
  return true;
76
  }
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  public function updateBridgeConfig($key)
79
  {
80
  $dir = $this->getModuleBridgeDir();
81
 
82
  // Update config.php
83
  $localFile = $dir . DS . 'config.php';
84
- $contents = file_get_contents($localFile);
85
  if ($contents === false) {
86
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to read file: %s<br>Please update the file permissions and try again.", $localFile));
87
  return false;
@@ -89,7 +109,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
89
 
90
  $contents = str_replace('%m1_token%', $key, $contents);
91
  // $contents = str_replace('%m1_store_base_dir%', Mage::getBaseDir() . DS, $contents);
92
- if (file_put_contents($localFile, $contents) === false) {
93
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
94
  return false;
95
  }
@@ -104,7 +124,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
104
  // Truncate bridge.php
105
  $localFile = $dir . DS . 'bridge.php';
106
  $contents = "<?php // Uninstalled" . PHP_EOL;
107
- if (file_put_contents($localFile, $contents) === false) {
108
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
109
  return false;
110
  }
@@ -112,7 +132,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
112
  // Truncate config.php
113
  $localFile = $dir . DS . 'config.php';
114
  $contents = "<?php // Uninstalled" . PHP_EOL;
115
- if (file_put_contents($localFile, $contents) === false) {
116
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
117
  return false;
118
  }
@@ -125,7 +145,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
125
  try {
126
  $method = $this->getDownloadMethod();
127
 
128
- if ($method == 'file_get_contents') {
129
  $ctx = stream_context_create(array(
130
  'http'=>
131
  array(
@@ -137,7 +157,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
137
  ),
138
  )
139
  );
140
- $contents = file_get_contents($url, false, $ctx);
141
  if ($contents !== false) {
142
  return $contents;
143
  }
@@ -191,7 +211,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
191
 
192
  // Check if bridge.php exists
193
  $path = $dir . DS . 'bridge.php';
194
- $contents = file_get_contents($path);
195
  if ($contents === false) {
196
  return false;
197
  }
@@ -201,7 +221,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
201
 
202
  // Check if config.php exists
203
  $path = $dir . DS . 'config.php';
204
- $contents = file_get_contents($path);
205
  if ($contents === false) {
206
  return false;
207
  }
@@ -326,7 +346,7 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
326
  public function getDownloadMethod()
327
  {
328
  if (ini_get('allow_url_fopen')) {
329
- return 'file_get_contents';
330
  }
331
  if (function_exists('curl_version')) {
332
  return 'curl';
@@ -510,6 +530,10 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
510
  'type' => 'file',
511
  'path' => 'app/code/community/Webinterpret/Connector/Block/Analytics.php',
512
  ),
 
 
 
 
513
  array(
514
  'type' => 'file',
515
  'path' => 'app/code/community/Webinterpret/Connector/Block/Adminhtml/System/Config/Fieldset/Status.php',
@@ -524,35 +548,35 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
524
  ),
525
  array(
526
  'type' => 'file',
527
- 'path' => 'app/code/community/Webinterpret/Connector/Model/Observer.php',
528
  ),
529
  array(
530
  'type' => 'file',
531
- 'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/config.php',
532
  ),
533
  array(
534
  'type' => 'file',
535
- 'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/helper.php',
536
  ),
537
  array(
538
  'type' => 'file',
539
- 'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/bridge.php',
540
  ),
541
  array(
542
  'type' => 'file',
543
- 'path' => 'js/webinterpret/wi-pi.css',
544
  ),
545
  array(
546
  'type' => 'file',
547
- 'path' => 'js/webinterpret/wi-cr.css',
548
  ),
549
  array(
550
  'type' => 'file',
551
- 'path' => 'js/webinterpret/wi-cr.js',
552
  ),
553
  array(
554
  'type' => 'file',
555
- 'path' => 'js/webinterpret/wi-pi.js',
556
  ),
557
  );
558
 
@@ -594,4 +618,9 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
594
 
595
  return $report;
596
  }
 
 
 
 
 
597
  }
43
  $dir = $this->getModuleBridgeDir();
44
 
45
  // Install bridge.php
46
+ $remoteFile = $repo . DS . 'bridge2cart' . DS . $this->getExtensionVersion() . DS . 'bridge.php';
47
  $contents = $this->downloadFile($remoteFile);
48
  if ($contents === false) {
49
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to download file: %s<br>Please contact Webinterpret support.", $remoteFile));
51
  }
52
  $localFile = $dir . DS . 'bridge.php';
53
  $contents = str_replace('exit();', '', $contents);
54
+ if (@file_put_contents($localFile, $contents) === false) {
55
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
56
  return false;
57
  }
58
 
59
  // Install config.php
60
+ $remoteFile = $repo . DS . 'bridge2cart' . DS . $this->getExtensionVersion() . DS . 'config.php';
61
  $contents = $this->downloadFile($remoteFile);
62
  if ($contents === false) {
63
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to download file: %s<br>Please contact Webinterpret support.", $remoteFile));
65
  }
66
  $localFile = $dir . DS . 'config.php';
67
  $contents = str_replace('exit();', '', $contents);
68
+ if (@file_put_contents($localFile, $contents) === false) {
69
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
70
  return false;
71
  }
75
  return true;
76
  }
77
 
78
+ public function installBridgeHelper()
79
+ {
80
+ $repo = Mage::getStoreConfig('webinterpret_connector/file_repository');
81
+ $dir = $this->getModuleBridgeDir();
82
+
83
+ // Install helper.php
84
+ $remoteFile = $repo . DS . 'bridge2cart' . DS . $this->getExtensionVersion() . DS . 'helper.php';
85
+ $contents = $this->downloadFile($remoteFile);
86
+ if ($contents === false) {
87
+ return false;
88
+ }
89
+ $localFile = $dir . DS . 'helper.php';
90
+ $contents = str_replace('exit();', '', $contents);
91
+ if (@file_put_contents($localFile, $contents) === false) {
92
+ return false;
93
+ }
94
+
95
+ return true;
96
+ }
97
+
98
  public function updateBridgeConfig($key)
99
  {
100
  $dir = $this->getModuleBridgeDir();
101
 
102
  // Update config.php
103
  $localFile = $dir . DS . 'config.php';
104
+ $contents = @file_get_contents($localFile);
105
  if ($contents === false) {
106
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to read file: %s<br>Please update the file permissions and try again.", $localFile));
107
  return false;
109
 
110
  $contents = str_replace('%m1_token%', $key, $contents);
111
  // $contents = str_replace('%m1_store_base_dir%', Mage::getBaseDir() . DS, $contents);
112
+ if (@file_put_contents($localFile, $contents) === false) {
113
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
114
  return false;
115
  }
124
  // Truncate bridge.php
125
  $localFile = $dir . DS . 'bridge.php';
126
  $contents = "<?php // Uninstalled" . PHP_EOL;
127
+ if (@file_put_contents($localFile, $contents) === false) {
128
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
129
  return false;
130
  }
132
  // Truncate config.php
133
  $localFile = $dir . DS . 'config.php';
134
  $contents = "<?php // Uninstalled" . PHP_EOL;
135
+ if (@file_put_contents($localFile, $contents) === false) {
136
  Mage::getSingleton('adminhtml/session')->addError($this->__("Failed to write file: %s<br>Please update the file permissions and try again.", $localFile));
137
  return false;
138
  }
145
  try {
146
  $method = $this->getDownloadMethod();
147
 
148
+ if ($method == 'stream') {
149
  $ctx = stream_context_create(array(
150
  'http'=>
151
  array(
157
  ),
158
  )
159
  );
160
+ $contents = @file_get_contents($url, false, $ctx);
161
  if ($contents !== false) {
162
  return $contents;
163
  }
211
 
212
  // Check if bridge.php exists
213
  $path = $dir . DS . 'bridge.php';
214
+ $contents = @file_get_contents($path);
215
  if ($contents === false) {
216
  return false;
217
  }
221
 
222
  // Check if config.php exists
223
  $path = $dir . DS . 'config.php';
224
+ $contents = @file_get_contents($path);
225
  if ($contents === false) {
226
  return false;
227
  }
346
  public function getDownloadMethod()
347
  {
348
  if (ini_get('allow_url_fopen')) {
349
+ return 'stream';
350
  }
351
  if (function_exists('curl_version')) {
352
  return 'curl';
530
  'type' => 'file',
531
  'path' => 'app/code/community/Webinterpret/Connector/Block/Analytics.php',
532
  ),
533
+ array(
534
+ 'type' => 'file',
535
+ 'path' => 'app/code/community/Webinterpret/Connector/Block/Adminhtml/Notifications.php',
536
+ ),
537
  array(
538
  'type' => 'file',
539
  'path' => 'app/code/community/Webinterpret/Connector/Block/Adminhtml/System/Config/Fieldset/Status.php',
548
  ),
549
  array(
550
  'type' => 'file',
551
+ 'path' => 'app/code/community/Webinterpret/Connector/Model/Notification.php',
552
  ),
553
  array(
554
  'type' => 'file',
555
+ 'path' => 'app/code/community/Webinterpret/Connector/Model/Observer.php',
556
  ),
557
  array(
558
  'type' => 'file',
559
+ 'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/bridge.php',
560
  ),
561
  array(
562
  'type' => 'file',
563
+ 'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/config.php',
564
  ),
565
  array(
566
  'type' => 'file',
567
+ 'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/helper.php',
568
  ),
569
  array(
570
  'type' => 'file',
571
+ 'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/preloader.php',
572
  ),
573
  array(
574
  'type' => 'file',
575
+ 'path' => 'js/webinterpret/webinterpret.css',
576
  ),
577
  array(
578
  'type' => 'file',
579
+ 'path' => 'js/webinterpret/webinterpret.js',
580
  ),
581
  );
582
 
618
 
619
  return $report;
620
  }
621
+
622
+ public function getExtensionVersion()
623
+ {
624
+ return (string) Mage::getConfig()->getNode()->modules->Webinterpret_Connector->version;
625
+ }
626
  }
app/code/community/Webinterpret/Connector/bridge2cart/bridge.php CHANGED
@@ -1 +1,3888 @@
1
- <?php // FILE WILL BE CREATED DURING INSTALLATION
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ require_once 'preloader.php';
5
+
6
+ /*-----------------------------------------------------------------------------+
7
+ | MagneticOne |
8
+ | Copyright (c) 2012 MagneticOne.com <contact@magneticone.com> |
9
+ | All rights reserved |
10
+ +------------------------------------------------------------------------------+
11
+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "license.txt"|
12
+ | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE |
13
+ | AT THE FOLLOWING URL: http://www.magneticone.com/store/license.php |
14
+ | |
15
+ | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE |
16
+ | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT MAGNETICONE |
17
+ | (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING |
18
+ | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). |
19
+ | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT |
20
+ | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, |
21
+ | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY |
22
+ | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS |
23
+ | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS |
24
+ | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND |
25
+ | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS |
26
+ | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE |
27
+ | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE. |
28
+ | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. |
29
+ | |
30
+ | The Developer of the Code is MagneticOne, |
31
+ | Copyright (C) 2006 - 2012 All Rights Reserved. |
32
+ +------------------------------------------------------------------------------+
33
+ | |
34
+ | ATTENTION! |
35
+ +------------------------------------------------------------------------------+
36
+ | By our Terms of Use you agreed not to change, modify, add, or remove portions|
37
+ | of Bridge Script source code as it is owned by MagneticOne company. |
38
+ | You agreed not to use, reproduce, modify, adapt, publish, translate |
39
+ | the Bridge Script source code into any form, medium, or technology |
40
+ | now known or later developed throughout the universe. |
41
+ | |
42
+ | Full text of our TOS located at |
43
+ | https://www.api2cart.com/terms-of-service |
44
+ +-----------------------------------------------------------------------------*/
45
+
46
+
47
+ class M1_Bridge_Action_Update
48
+ {
49
+ var $uri = "BRIDGE_DOWNLOAD_LINK";
50
+
51
+ var $pathToTmpDir;
52
+
53
+ var $pathToFile = __FILE__;
54
+
55
+ function M1_Bridge_Action_Update()
56
+ {
57
+ $this->pathToTmpDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . "temp_c2c";
58
+ }
59
+
60
+ function perform($bridge)
61
+ {
62
+ $response = new stdClass();
63
+ if ( !($this->_checkBridgeDirPermission() && $this->_checkBridgeFilePermission()) ) {
64
+ $response->is_error = true;
65
+ $response->message = "Bridge Update couldn't be performed. Please change permission for bridge folder to 777 and bridge.php file inside it to 666";
66
+ echo serialize($response);die;
67
+ }
68
+
69
+
70
+ if ( ($data = $this->_downloadFile()) === false ) {
71
+ $response->is_error = true;
72
+ $response->message = "Bridge Version is outdated. Files couldn't be updated automatically. Please set write permission or re-upload files manually.";
73
+ echo serialize($response);die;
74
+ }
75
+
76
+ if ( !$this->_writeToFile($data, $this->pathToFile) ) {
77
+ $response->is_error = true;
78
+ $response->message = "Couln't create file in temporary folder or file is write protected.";
79
+ echo serialize($response);die;
80
+ }
81
+
82
+ $response->is_error = false;
83
+ $response->message = "Bridge successfully updated to latest version";
84
+ echo serialize($response);
85
+ die;
86
+ }
87
+
88
+ function _fetch( $uri )
89
+ {
90
+ $ch = curl_init();
91
+
92
+ curl_setopt($ch, CURLOPT_URL, $uri);
93
+ curl_setopt($ch, CURLOPT_HEADER, 0);
94
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
95
+
96
+ $response = new stdClass();
97
+
98
+ $response->body = curl_exec($ch);
99
+ $response->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
100
+ $response->content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
101
+ $response->content_length = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
102
+
103
+ curl_close($ch);
104
+
105
+ return $response;
106
+ }
107
+
108
+ function _checkBridgeDirPermission()
109
+ {
110
+ if (!is_writeable(dirname(__FILE__))) {
111
+ @chmod(dirname(__FILE__), 0777);
112
+ }
113
+ return is_writeable(dirname(__FILE__));
114
+ }
115
+
116
+ function _checkBridgeFilePermission()
117
+ {
118
+ $pathToFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . "bridge.php";
119
+ if (!is_writeable($pathToFile)) {
120
+ @chmod($pathToFile, 0666);
121
+ }
122
+ return is_writeable($pathToFile);
123
+ }
124
+
125
+ function _createTempDir()
126
+ {
127
+ @mkdir($this->pathToTmpDir, 0777);
128
+ return file_exists($this->pathToTmpDir);
129
+ }
130
+
131
+ function _removeTempDir()
132
+ {
133
+ @unlink($this->pathToTmpDir . DIRECTORY_SEPARATOR . "bridge.php_c2c");
134
+ @rmdir($this->pathToTmpDir);
135
+ return !file_exists($this->pathToTmpDir);
136
+ }
137
+
138
+ function _downloadFile()
139
+ {
140
+ $file = $this->_fetch($this->uri);
141
+ if ( $file->http_code == 200 ) {
142
+ return $file;
143
+ }
144
+ return false;
145
+ }
146
+
147
+ function _writeToFile($data, $file)
148
+ {
149
+ if (function_exists("file_put_contents")) {
150
+ $bytes = file_put_contents($file, $data->body);
151
+ return $bytes == $data->content_length;
152
+ }
153
+
154
+ $handle = @fopen($file, 'w+');
155
+ $bytes = fwrite($handle, $data->body);
156
+ @fclose($handle);
157
+
158
+ return $bytes == $data->content_length;
159
+
160
+ }
161
+
162
+ }
163
+
164
+ class M1_Bridge_Action_Query
165
+ {
166
+ function perform($bridge)
167
+ {
168
+ if (isset($_POST['query']) && isset($_POST['fetchMode'])) {
169
+ $query = base64_decode($_POST['query']);
170
+
171
+ $res = $bridge->query($query, (int)$_POST['fetchMode']);
172
+
173
+ if (is_array($res['result']) || is_bool($res['result'])) {
174
+ $result = serialize(array(
175
+ 'res' => $res['result'],
176
+ 'fetchedFields' => @$res['fetchedFields'],
177
+ 'insertId' => $bridge->getLink()->getLastInsertId(),
178
+ 'affectedRows' => $bridge->getLink()->getAffectedRows(),
179
+ ));
180
+
181
+ echo base64_encode($result);
182
+ } else {
183
+ echo base64_encode($res['message']);
184
+ }
185
+ } else {
186
+ return false;
187
+ }
188
+ }
189
+ }
190
+
191
+ class M1_Bridge_Action_Getconfig
192
+ {
193
+
194
+ function parseMemoryLimit($val)
195
+ {
196
+ $last = strtolower($val[strlen($val)-1]);
197
+ switch($last) {
198
+ case 'g':
199
+ $val *= 1024;
200
+ case 'm':
201
+ $val *= 1024;
202
+ case 'k':
203
+ $val *= 1024;
204
+ }
205
+
206
+ return $val;
207
+ }
208
+
209
+ function getMemoryLimit()
210
+ {
211
+ $memoryLimit = trim(@ini_get('memory_limit'));
212
+ if (strlen($memoryLimit) === 0) {
213
+ $memoryLimit = "0";
214
+ }
215
+ $memoryLimit = $this->parseMemoryLimit($memoryLimit);
216
+
217
+ $maxPostSize = trim(@ini_get('post_max_size'));
218
+ if (strlen($maxPostSize) === 0) {
219
+ $maxPostSize = "0";
220
+ }
221
+ $maxPostSize = $this->parseMemoryLimit($maxPostSize);
222
+
223
+ $suhosinMaxPostSize = trim(@ini_get('suhosin.post.max_value_length'));
224
+ if (strlen($suhosinMaxPostSize) === 0) {
225
+ $suhosinMaxPostSize = "0";
226
+ }
227
+ $suhosinMaxPostSize = $this->parseMemoryLimit($suhosinMaxPostSize);
228
+
229
+ if ($suhosinMaxPostSize == 0) {
230
+ $suhosinMaxPostSize = $maxPostSize;
231
+ }
232
+
233
+ if ($maxPostSize == 0) {
234
+ $suhosinMaxPostSize = $maxPostSize = $memoryLimit;
235
+ }
236
+
237
+ return min($suhosinMaxPostSize, $maxPostSize, $memoryLimit);
238
+ }
239
+
240
+ function isZlibSupported()
241
+ {
242
+ return function_exists('gzdecode');
243
+ }
244
+
245
+ function perform($bridge)
246
+ {
247
+ if (!defined("DEFAULT_LANGUAGE_ISO2")) {
248
+ define("DEFAULT_LANGUAGE_ISO2", ""); //variable for Interspire cart
249
+ }
250
+
251
+ $result = array(
252
+ "images" => array(
253
+ "imagesPath" => $bridge->config->imagesDir, // path to images folder - relative to store root
254
+ "categoriesImagesPath" => $bridge->config->categoriesImagesDir,
255
+ "categoriesImagesPaths" => $bridge->config->categoriesImagesDirs,
256
+ "productsImagesPath" => $bridge->config->productsImagesDir,
257
+ "productsImagesPaths" => $bridge->config->productsImagesDirs,
258
+ "manufacturersImagesPath" => $bridge->config->manufacturersImagesDir,
259
+ "manufacturersImagesPaths" => $bridge->config->manufacturersImagesDirs,
260
+ ),
261
+ "languages" => $bridge->config->languages,
262
+ "baseDirFs" => M1_STORE_BASE_DIR, // filesystem path to store root
263
+ "defaultLanguageIso2" => DEFAULT_LANGUAGE_ISO2,
264
+ "databaseName" => $bridge->config->Dbname,
265
+ "memoryLimit" => $this->getMemoryLimit(),
266
+ "zlibSupported" => $this->isZlibSupported(),
267
+ //"orderStatus" => $bridge->config->orderStatus,
268
+ "cartVars" => $bridge->config->cartVars,
269
+ );
270
+
271
+ echo serialize($result);
272
+ }
273
+
274
+ }
275
+
276
+
277
+ class M1_Bridge_Action_Batchsavefile extends M1_Bridge_Action_Savefile
278
+ {
279
+ function perform($bridge) {
280
+ $result = array();
281
+
282
+ foreach ($_POST['files'] as $fileInfo) {
283
+ $result[$fileInfo['id']] = $this->_saveFile(
284
+ $fileInfo['source'],
285
+ $fileInfo['target'],
286
+ (int)$fileInfo['width'],
287
+ (int)$fileInfo['height'],
288
+ $fileInfo['local_source']
289
+ );
290
+ }
291
+
292
+ echo serialize($result);
293
+ }
294
+
295
+ }
296
+
297
+ class M1_Bridge_Action_Deleteimages
298
+ {
299
+ function perform($bridge)
300
+ {
301
+ switch($bridge->config->cartType) {
302
+ case "Pinnacle361":
303
+ $this->_PinnacleDeleteImages($bridge);
304
+ break;
305
+ case "Prestashop11":
306
+ $this->_PrestaShopDeleteImages($bridge);
307
+ break;
308
+ case 'Summercart3' :
309
+ $this->_SummercartDeleteImages($bridge);
310
+ break;
311
+ }
312
+ }
313
+
314
+ function _PinnacleDeleteImages($bridge)
315
+ {
316
+ $dirs = array(
317
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'catalog/',
318
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'manufacturers/',
319
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'products/',
320
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'products/thumbs/',
321
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'products/secondary/',
322
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'products/preview/',
323
+ );
324
+
325
+ $ok = true;
326
+
327
+ foreach($dirs as $dir) {
328
+
329
+ if( !file_exists( $dir ) ) {
330
+ continue;
331
+ }
332
+
333
+ $dirHandle = opendir($dir);
334
+
335
+ while (false !== ($file = readdir($dirHandle))) {
336
+ if ($file != "." && $file != ".." && !preg_match("/^readme\.txt?$/",$file) && !preg_match("/\.bak$/i",$file)) {
337
+ $file_path = $dir . $file;
338
+ if( is_file($file_path) ) {
339
+ if(!rename($file_path, $file_path.".bak")) $ok = false;
340
+ }
341
+ }
342
+ }
343
+
344
+ closedir($dirHandle);
345
+
346
+ }
347
+
348
+ if ($ok) print "OK";
349
+ else print "ERROR";
350
+ }
351
+
352
+ function _PrestaShopDeleteImages($bridge)
353
+ {
354
+ $dirs = array(
355
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'c/',
356
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'p/',
357
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'm/',
358
+ );
359
+
360
+ $ok = true;
361
+
362
+ foreach($dirs as $dir) {
363
+
364
+ if( !file_exists( $dir ) ) {
365
+ continue;
366
+ }
367
+
368
+ $dirHandle = opendir($dir);
369
+
370
+ while (false !== ($file = readdir($dirHandle))) {
371
+ if ($file != "." && $file != ".." && preg_match( "/(\d+).*\.jpg?$/",$file )) {
372
+ $file_path = $dir . $file;
373
+ if( is_file($file_path) ) {
374
+ if(!rename($file_path, $file_path.".bak")) $ok = false;
375
+ }
376
+ }
377
+ }
378
+
379
+ closedir($dirHandle);
380
+
381
+ }
382
+
383
+ if ($ok) print "OK";
384
+ else print "ERROR";
385
+ }
386
+
387
+ function _SummercartDeleteImages($bridge)
388
+ {
389
+ $dirs = array(
390
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'categoryimages/',
391
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'manufacturer/',
392
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'productimages/',
393
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'productthumbs/',
394
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'productboximages/',
395
+ M1_STORE_BASE_DIR . $bridge->config->imagesDir . 'productlargeimages/',
396
+ );
397
+
398
+ $ok = true;
399
+
400
+ foreach($dirs as $dir) {
401
+
402
+ if( !file_exists( $dir ) ) {
403
+ continue;
404
+ }
405
+
406
+ $dirHandle = opendir($dir);
407
+
408
+ while (false !== ($file = readdir($dirHandle))) {
409
+ if (($file != ".") && ($file != "..") && !preg_match("/\.bak$/i",$file) ) {
410
+ $file_path = $dir . $file;
411
+ if( is_file($file_path) ) {
412
+ if(!rename($file_path, $file_path.".bak")) $ok = false;
413
+ }
414
+ }
415
+ }
416
+
417
+ closedir($dirHandle);
418
+
419
+ }
420
+
421
+ if ($ok) print "OK";
422
+ else print "ERROR";
423
+ }
424
+ }
425
+
426
+ class M1_Bridge_Action_Cubecart
427
+ {
428
+ function perform($bridge)
429
+ {
430
+ $dirHandle = opendir(M1_STORE_BASE_DIR . 'language/');
431
+
432
+ $languages = array();
433
+
434
+ while ($dirEntry = readdir($dirHandle)) {
435
+ if (!is_dir(M1_STORE_BASE_DIR . 'language/' . $dirEntry) || $dirEntry == '.' || $dirEntry == '..' || strpos($dirEntry, "_") !== false) {
436
+ continue;
437
+ }
438
+
439
+ $lang['id'] = $dirEntry;
440
+ $lang['iso2'] = $dirEntry;
441
+
442
+ $cnfile = "config.inc.php";
443
+
444
+ if (!file_exists(M1_STORE_BASE_DIR . 'language/' . $dirEntry . '/'. $cnfile)) {
445
+ $cnfile = "config.php";
446
+ }
447
+
448
+ if (!file_exists( M1_STORE_BASE_DIR . 'language/' . $dirEntry . '/'. $cnfile)) {
449
+ continue;
450
+ }
451
+
452
+ $str = file_get_contents(M1_STORE_BASE_DIR . 'language/' . $dirEntry . '/'.$cnfile);
453
+ preg_match("/".preg_quote('$langName')."[\s]*=[\s]*[\"\'](.*)[\"\'];/", $str, $match);
454
+
455
+ if (isset($match[1])) {
456
+ $lang['name'] = $match[1];
457
+ $languages[] = $lang;
458
+ }
459
+ }
460
+
461
+ echo serialize($languages);
462
+ }
463
+ }
464
+
465
+ class M1_Bridge_Action_Mysqlver
466
+ {
467
+ function perform($bridge)
468
+ {
469
+ $m = array();
470
+ preg_match('/^(\d+)\.(\d+)\.(\d+)/', mysql_get_server_info($bridge->getLink()), $m);
471
+ echo sprintf("%d%02d%02d", $m[1], $m[2], $m[3]);
472
+ }
473
+ }
474
+
475
+ class M1_Bridge_Action_Clearcache
476
+ {
477
+ function perform($bridge)
478
+ {
479
+ switch($bridge->config->cartType) {
480
+ case "Cubecart":
481
+ $this->_CubecartClearCache();
482
+ break;
483
+ case "Prestashop11":
484
+ $this->_PrestashopClearCache();
485
+ break;
486
+ case "Interspire":
487
+ $this->_InterspireClearCache();
488
+ break;
489
+ case "Opencart14" :
490
+ $this->_OpencartClearCache();
491
+ break;
492
+ case "XtcommerceVeyton" :
493
+ $this->_Xtcommerce4ClearCache();
494
+ break;
495
+ case "Ubercart" :
496
+ $this->_ubercartClearCache();
497
+ break;
498
+ case "Tomatocart" :
499
+ $this->_tomatocartClearCache();
500
+ break;
501
+ case "Virtuemart113" :
502
+ $this->_virtuemartClearCache();
503
+ break;
504
+ case "Magento1212" :
505
+ //$this->_magentoClearCache();
506
+ break;
507
+ case "Oscommerce3":
508
+ $this->_Oscommerce3ClearCache();
509
+ break;
510
+ case "Oxid":
511
+ $this->_OxidClearCache();
512
+ break;
513
+ case "XCart":
514
+ $this->_XcartClearCache();
515
+ break;
516
+ case "Cscart203":
517
+ $this->_CscartClearCache();
518
+ break;
519
+ case "Prestashop15":
520
+ $this->_Prestashop15ClearCache();
521
+ break;
522
+ case "Gambio":
523
+ $this->_GambioClearCache();
524
+ break;
525
+ }
526
+ }
527
+
528
+ /**
529
+ *
530
+ * @var $fileExclude - name file in format pregmatch
531
+ */
532
+
533
+ function _removeGarbage($dirs = array(), $fileExclude = '')
534
+ {
535
+ $result = true;
536
+
537
+ foreach ($dirs as $dir) {
538
+
539
+ if (!file_exists($dir)) {
540
+ continue;
541
+ }
542
+
543
+ $dirHandle = opendir($dir);
544
+
545
+ while (false !== ($file = readdir($dirHandle))) {
546
+ if ($file == "." || $file == "..") {
547
+ continue;
548
+ }
549
+
550
+ if ((trim($fileExclude) != '') && preg_match("/^" .$fileExclude . "?$/", $file)) {
551
+ continue;
552
+ }
553
+
554
+ if (is_dir($dir . $file)) {
555
+ continue;
556
+ }
557
+
558
+ if (!unlink($dir . $file)) {
559
+ $result = false;
560
+ }
561
+ }
562
+
563
+ closedir($dirHandle);
564
+ }
565
+
566
+ if ($result) {
567
+ echo 'OK';
568
+ } else {
569
+ echo 'ERROR';
570
+ }
571
+
572
+ return $result;
573
+ }
574
+
575
+ function _magentoClearCache()
576
+ {
577
+ chdir('../');
578
+
579
+ $indexes = array(
580
+ 'catalog_product_attribute',
581
+ 'catalog_product_price',
582
+ 'catalog_url',
583
+ 'catalog_product_flat',
584
+ 'catalog_category_flat',
585
+ 'catalog_category_product',
586
+ 'catalogsearch_fulltext',
587
+ 'cataloginventory_stock',
588
+ 'tag_summary'
589
+ );
590
+
591
+ $phpExecutable = getPHPExecutable();
592
+ if ($phpExecutable) {
593
+ foreach ($indexes as $index) {
594
+ exec($phpExecutable . " shell/indexer.php --reindex $index", $out);
595
+ }
596
+ echo 'OK';
597
+ } else {
598
+ echo 'Error: can not find PHP executable file.';
599
+ }
600
+
601
+ echo 'OK';
602
+ }
603
+
604
+ function _InterspireClearCache()
605
+ {
606
+ $res = true;
607
+ $file = M1_STORE_BASE_DIR . 'cache' . DIRECTORY_SEPARATOR . 'datastore' . DIRECTORY_SEPARATOR . 'RootCategories.php';
608
+ if (file_exists($file)) {
609
+ if (!unlink($file)) {
610
+ $res = false;
611
+ }
612
+ }
613
+ if ($res === true) {
614
+ echo "OK";
615
+ } else {
616
+ echo "ERROR";
617
+ }
618
+ }
619
+
620
+ function _CubecartClearCache()
621
+ {
622
+ $ok = true;
623
+
624
+ if (file_exists(M1_STORE_BASE_DIR . 'cache')) {
625
+ $dirHandle = opendir(M1_STORE_BASE_DIR . 'cache/');
626
+
627
+ while (false !== ($file = readdir($dirHandle))) {
628
+ if ($file != "." && $file != ".." && !preg_match("/^index\.html?$/", $file) && !preg_match("/^\.htaccess?$/", $file)) {
629
+ if (is_file( M1_STORE_BASE_DIR . 'cache/' . $file)) {
630
+ if (!unlink(M1_STORE_BASE_DIR . 'cache/' . $file)) {
631
+ $ok = false;
632
+ }
633
+ }
634
+ }
635
+ }
636
+
637
+ closedir($dirHandle);
638
+ }
639
+
640
+ if (file_exists(M1_STORE_BASE_DIR.'includes/extra/admin_cat_cache.txt')) {
641
+ unlink(M1_STORE_BASE_DIR.'includes/extra/admin_cat_cache.txt');
642
+ }
643
+
644
+ if ($ok) {
645
+ echo 'OK';
646
+ } else {
647
+ echo 'ERROR';
648
+ }
649
+ }
650
+
651
+ function _PrestashopClearCache()
652
+ {
653
+ $dirs = array(
654
+ M1_STORE_BASE_DIR . 'tools/smarty/compile/',
655
+ M1_STORE_BASE_DIR . 'tools/smarty/cache/',
656
+ M1_STORE_BASE_DIR . 'img/tmp/'
657
+ );
658
+
659
+ $this->_removeGarbage($dirs, 'index\.php');
660
+ }
661
+
662
+ function _OpencartClearCache()
663
+ {
664
+ $dirs = array(
665
+ M1_STORE_BASE_DIR . 'system/cache/',
666
+ );
667
+
668
+ $this->_removeGarbage($dirs, 'index\.html');
669
+ }
670
+
671
+ function _Xtcommerce4ClearCache()
672
+ {
673
+ $dirs = array(
674
+ M1_STORE_BASE_DIR . 'cache/',
675
+ );
676
+
677
+ $this->_removeGarbage($dirs, 'index\.html');
678
+ }
679
+
680
+ function _ubercartClearCache()
681
+ {
682
+ $dirs = array(
683
+ M1_STORE_BASE_DIR . 'sites/default/files/imagecache/product/',
684
+ M1_STORE_BASE_DIR . 'sites/default/files/imagecache/product_full/',
685
+ M1_STORE_BASE_DIR . 'sites/default/files/imagecache/product_list/',
686
+ M1_STORE_BASE_DIR . 'sites/default/files/imagecache/uc_category/',
687
+ M1_STORE_BASE_DIR . 'sites/default/files/imagecache/uc_thumbnail/',
688
+ );
689
+
690
+ $this->_removeGarbage($dirs);
691
+ }
692
+
693
+ function _tomatocartClearCache()
694
+ {
695
+ $dirs = array(
696
+ M1_STORE_BASE_DIR . 'includes/work/',
697
+ );
698
+
699
+ $this->_removeGarbage($dirs, '\.htaccess');
700
+ }
701
+
702
+ /**
703
+ * Try chage permissions actually :)
704
+ */
705
+ function _virtuemartClearCache()
706
+ {
707
+ $pathToImages = 'components/com_virtuemart/shop_image';
708
+
709
+ $dirParts = explode("/", $pathToImages);
710
+ $path = M1_STORE_BASE_DIR;
711
+ foreach ($dirParts as $item) {
712
+ if ($item == '') {
713
+ continue;
714
+ }
715
+
716
+ $path .= $item . DIRECTORY_SEPARATOR;
717
+ @chmod($path, 0755);
718
+ }
719
+ }
720
+
721
+ function _Oscommerce3ClearCache()
722
+ {
723
+ $dirs = array(
724
+ M1_STORE_BASE_DIR . 'osCommerce/OM/Work/Cache/',
725
+ );
726
+
727
+ $this->_removeGarbage($dirs, '\.htaccess');
728
+ }
729
+
730
+ function _GambioClearCache()
731
+ {
732
+ $dirs = array(
733
+ M1_STORE_BASE_DIR . 'cache/',
734
+ );
735
+
736
+ $this->_removeGarbage($dirs, 'index\.html');
737
+ }
738
+
739
+ function _OxidClearCache()
740
+ {
741
+ $dirs = array(
742
+ M1_STORE_BASE_DIR . 'tmp/',
743
+ );
744
+
745
+ $this->_removeGarbage($dirs, '\.htaccess');
746
+ }
747
+
748
+ function _XcartClearCache()
749
+ {
750
+ $dirs = array(
751
+ M1_STORE_BASE_DIR . 'var/cache/',
752
+ );
753
+
754
+ $this->_removeGarbage($dirs, '\.htaccess');
755
+ }
756
+
757
+ function _CscartClearCache()
758
+ {
759
+ $dir = M1_STORE_BASE_DIR . 'var/cache/';
760
+ $res = $this->removeDirRec($dir);
761
+
762
+ if ($res) {
763
+ echo 'OK';
764
+ } else {
765
+ echo 'ERROR';
766
+ }
767
+ }
768
+
769
+ function _Prestashop15ClearCache()
770
+ {
771
+ $dirs = array(
772
+ M1_STORE_BASE_DIR . 'cache/smarty/compile/',
773
+ M1_STORE_BASE_DIR . 'cache/smarty/cache/',
774
+ M1_STORE_BASE_DIR . 'img/tmp/'
775
+ );
776
+
777
+ $this->_removeGarbage($dirs, 'index\.php');
778
+ }
779
+
780
+ function removeDirRec($dir)
781
+ {
782
+ $result = true;
783
+
784
+ if ($objs = glob($dir."/*")) {
785
+ foreach ($objs as $obj) {
786
+ if (is_dir($obj)) {
787
+ //print "IS DIR! START RECURSIVE FUNCTION.\n";
788
+ $this->removeDirRec($obj);
789
+ } else {
790
+ if (!unlink($obj)) {
791
+ //print "!UNLINK FILE: ".$obj."\n";
792
+ $result = false;
793
+ }
794
+ }
795
+ }
796
+ }
797
+ if (!rmdir($dir)) {
798
+ //print "ERROR REMOVE DIR: ".$dir."\n";
799
+ $result = false;
800
+ }
801
+
802
+ return $result;
803
+ }
804
+ }
805
+
806
+
807
+ class M1_Bridge_Action_Basedirfs
808
+ {
809
+ function perform($bridge)
810
+ {
811
+ echo M1_STORE_BASE_DIR;
812
+ }
813
+ }
814
+
815
+ class M1_Bridge_Action_Phpinfo
816
+ {
817
+ function perform($bridge)
818
+ {
819
+ phpinfo();
820
+ }
821
+ }
822
+
823
+
824
+ class M1_Bridge_Action_Savefile
825
+ {
826
+ var $_imageType = null;
827
+
828
+ function perform($bridge)
829
+ {
830
+ $source = $_POST['src'];
831
+ $destination = $_POST['dst'];
832
+ $width = (int)$_POST['width'];
833
+ $height = (int)$_POST['height'];
834
+ $local = $_POST['local_source'];
835
+
836
+ echo $this->_saveFile($source, $destination, $width, $height, $local);
837
+ }
838
+
839
+ function _saveFile($source, $destination, $width, $height, $local = '')
840
+ {
841
+ if (trim($local) != '') {
842
+
843
+ if ($this->_copyLocal($local, $destination, $width, $height)) {
844
+ return "OK";
845
+ }
846
+
847
+ }
848
+
849
+ if (!preg_match('/^https?:\/\//i', $source)) {
850
+ $result = $this->_createFile($source, $destination);
851
+ } elseif ($this->_isSameHost($source)) {
852
+ $result = $this->_saveFileLocal($source, $destination);
853
+ } else {
854
+ $result = $this->_saveFileCurl($source, $destination);
855
+ }
856
+
857
+ if ($result != "OK") {
858
+ return $result;
859
+ }
860
+
861
+ $destination = M1_STORE_BASE_DIR . $destination;
862
+
863
+ if ($width != 0 && $height != 0) {
864
+ $this->_scaled2( $destination, $width, $height );
865
+ }
866
+
867
+ if ($this->cartType == "Prestashop11") {
868
+ // convert destination.gif(png) to destination.jpg
869
+ $imageGd = $this->_loadImage($destination);
870
+
871
+ if ($imageGd === false) {
872
+ return $result;
873
+ }
874
+
875
+ if (!$this->_convert($imageGd, $destination, IMAGETYPE_JPEG, 'jpg')) {
876
+ return "CONVERT FAILED";
877
+ }
878
+ }
879
+
880
+ return $result;
881
+ }
882
+
883
+ function _copyLocal($source, $destination, $width, $height)
884
+ {
885
+ $source = M1_STORE_BASE_DIR . $source;
886
+ $destination = M1_STORE_BASE_DIR . $destination;
887
+
888
+ if (!@copy($source, $destination)) {
889
+ return false;
890
+ }
891
+
892
+ if ($width != 0 && $height != 0) {
893
+ $this->_scaled2($destination, $width, $height);
894
+ }
895
+
896
+ return true;
897
+ }
898
+
899
+ function _loadImage($filename, $skipJpg = true)
900
+ {
901
+ $imageInfo = @getimagesize($filename);
902
+ if ($imageInfo === false) {
903
+ return false;
904
+ }
905
+
906
+ $this->_imageType = $imageInfo[2];
907
+
908
+ switch ($this->_imageType) {
909
+ case IMAGETYPE_JPEG:
910
+ $image = imagecreatefromjpeg($filename);
911
+ break;
912
+ case IMAGETYPE_GIF:
913
+ $image = imagecreatefromgif($filename);
914
+ break;
915
+ case IMAGETYPE_PNG:
916
+ $image = imagecreatefrompng($filename);
917
+ break;
918
+ default:
919
+ return false;
920
+ }
921
+
922
+ if ($skipJpg && ($this->_imageType == IMAGETYPE_JPEG)) {
923
+ return false;
924
+ }
925
+
926
+ return $image;
927
+ }
928
+
929
+ function _saveImage($image, $filename, $imageType = IMAGETYPE_JPEG, $compression = 85, $permissions = null)
930
+ {
931
+ $result = true;
932
+ if ($imageType == IMAGETYPE_JPEG) {
933
+ $result = imagejpeg($image, $filename, $compression);
934
+ } elseif ($imageType == IMAGETYPE_GIF) {
935
+ $result = imagegif($image, $filename);
936
+ } elseif ($imageType == IMAGETYPE_PNG) {
937
+ $result = imagepng($image, $filename);
938
+ }
939
+
940
+ if ($permissions != null) {
941
+ chmod($filename, $permissions);
942
+ }
943
+
944
+ imagedestroy($image);
945
+
946
+ return $result;
947
+ }
948
+
949
+ function _createFile($source, $destination)
950
+ {
951
+ if ($this->_create_dir(dirname($destination)) !== false) {
952
+ $destination = M1_STORE_BASE_DIR . $destination;
953
+ $body = base64_decode($source);
954
+ if ($body === false || file_put_contents($destination, $body) === false) {
955
+ return '[BRIDGE ERROR] File save failed!';
956
+ }
957
+
958
+ return 'OK';
959
+ }
960
+
961
+ return '[BRIDGE ERROR] Directory creation failed!';
962
+ }
963
+
964
+ function _saveFileLocal($source, $destination)
965
+ {
966
+ $srcInfo = parse_url($source);
967
+ $src = rtrim($_SERVER['DOCUMENT_ROOT'], "/") . $srcInfo['path'];
968
+
969
+ if ($this->_create_dir(dirname($destination)) !== false) {
970
+ $dst = M1_STORE_BASE_DIR . $destination;
971
+
972
+ if (!@copy($src, $dst)) {
973
+ return $this->_saveFileCurl($source, $destination);
974
+ }
975
+
976
+ } else {
977
+ return "[BRIDGE ERROR] Directory creation failed!";
978
+ }
979
+
980
+ return "OK";
981
+ }
982
+
983
+ function _saveFileCurl($source, $destination)
984
+ {
985
+ $source = $this->_escapeSource($source);
986
+ if ($this->_create_dir(dirname($destination)) !== false) {
987
+ $destination = M1_STORE_BASE_DIR . $destination;
988
+
989
+ $ch = curl_init();
990
+ curl_setopt($ch, CURLOPT_URL, $source);
991
+ curl_setopt($ch, CURLOPT_HEADER, 0);
992
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60);
993
+ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
994
+ curl_setopt($ch, CURLOPT_NOBODY, true);
995
+ curl_exec($ch);
996
+ $httpResponseCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
997
+
998
+ if ($httpResponseCode != 200) {
999
+ curl_close($ch);
1000
+ return "[BRIDGE ERROR] Bad response received from source, HTTP code $httpResponseCode!";
1001
+ }
1002
+
1003
+ $dst = @fopen($destination, "wb");
1004
+ if ($dst === false) {
1005
+ return "[BRIDGE ERROR] Can't create $destination!";
1006
+ }
1007
+ curl_setopt($ch, CURLOPT_NOBODY, false);
1008
+ curl_setopt($ch, CURLOPT_FILE, $dst);
1009
+ curl_setopt($ch, CURLOPT_HTTPGET, true);
1010
+ curl_exec($ch);
1011
+ if (($error_no = curl_errno($ch)) != CURLE_OK) {
1012
+ return "[BRIDGE ERROR] $error_no: " . curl_error($ch);
1013
+ }
1014
+ curl_close($ch);
1015
+ @chmod($destination, 0777);
1016
+
1017
+ return "OK";
1018
+
1019
+ } else {
1020
+ return "[BRIDGE ERROR] Directory creation failed!";
1021
+ }
1022
+ }
1023
+
1024
+ function _escapeSource($source)
1025
+ {
1026
+ return str_replace(" ", "%20", $source);
1027
+ }
1028
+
1029
+ function _create_dir($dir) {
1030
+ $dirParts = explode("/", $dir);
1031
+ $path = M1_STORE_BASE_DIR;
1032
+ foreach ($dirParts as $item) {
1033
+ if ($item == '') {
1034
+ continue;
1035
+ }
1036
+ $path .= $item . DIRECTORY_SEPARATOR;
1037
+ if (!is_dir($path)) {
1038
+ $res = @mkdir($path);
1039
+ if (!$res) {
1040
+ return false;
1041
+ }
1042
+ }
1043
+ @chmod($path, 0777);
1044
+ }
1045
+ return true;
1046
+ }
1047
+
1048
+ function _isSameHost($source)
1049
+ {
1050
+ $srcInfo = parse_url($source);
1051
+
1052
+ if (preg_match('/\.php$/', $srcInfo['path'])) {
1053
+ return false;
1054
+ }
1055
+
1056
+ $hostInfo = parse_url("http://" . $_SERVER['HTTP_HOST']);
1057
+ if (@$srcInfo['host'] == $hostInfo['host']) {
1058
+ return true;
1059
+ }
1060
+
1061
+ return false;
1062
+ }
1063
+
1064
+ /**
1065
+ * @param $image - GD image object
1066
+ * @param $filename - store sorce pathfile ex. M1_STORE_BASE_DIR . '/img/c/2.gif';
1067
+ * @param $type - IMAGETYPE_JPEG, IMAGETYPE_GIF or IMAGETYPE_PNG
1068
+ * @param $extension - file extension, this use for jpg or jpeg extension in prestashop
1069
+ *
1070
+ * @return true if success or false if no
1071
+ */
1072
+ function _convert($image, $filename, $type = IMAGETYPE_JPEG, $extension = '')
1073
+ {
1074
+ $end = pathinfo($filename, PATHINFO_EXTENSION);
1075
+
1076
+ if ($extension == '') {
1077
+ $extension = image_type_to_extension($type, false);
1078
+ }
1079
+
1080
+ if ($end == $extension) {
1081
+ return true;
1082
+ }
1083
+
1084
+ $width = imagesx($image);
1085
+ $height = imagesy($image);
1086
+
1087
+ $newImage = imagecreatetruecolor($width, $height);
1088
+
1089
+ /* Allow to keep nice look even if resized */
1090
+ $white = imagecolorallocate($newImage, 255, 255, 255);
1091
+ imagefill($newImage, 0, 0, $white);
1092
+ imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $width, $height );
1093
+ imagecolortransparent($newImage, $white);
1094
+
1095
+ $pathSave = rtrim($filename, $end);
1096
+
1097
+ $pathSave .= $extension;
1098
+
1099
+ return $this->_saveImage($newImage, $pathSave, $type);
1100
+ }
1101
+
1102
+ function _scaled($destination, $width, $height)
1103
+ {
1104
+ $image = $this->_loadImage($destination, false);
1105
+
1106
+ if ($image === false) {
1107
+ return;
1108
+ }
1109
+
1110
+ $originWidth = imagesx( $image );
1111
+ $originHeight = imagesy( $image );
1112
+
1113
+ $rw = (int)$height * (int)$originWidth / (int)$originHeight;
1114
+ $useHeight = ($rw <= $width);
1115
+
1116
+ if ($useHeight) {
1117
+ $width = (int)$rw;
1118
+ } else {
1119
+ $height = (int)((int)($width) * (int)($originHeight) / (int)($originWidth));
1120
+ }
1121
+
1122
+ $newImage = imagecreatetruecolor($width, $height);
1123
+ $white = imagecolorallocate($newImage, 255, 255, 255);
1124
+ imagefill($newImage, 0, 0, $white);
1125
+ imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $originWidth, $originHeight);
1126
+ imagecolortransparent($newImage, $white);
1127
+
1128
+ return $this->_saveImage($newImage, $destination, $this->_imageType, 100) ? "OK" : "CAN'T SCALE IMAGE";
1129
+ }
1130
+
1131
+ //scaled2 method optimizet for prestashop
1132
+ function _scaled2($destination, $destWidth, $destHeight)
1133
+ {
1134
+ $method = 0;
1135
+
1136
+ $sourceImage = $this->_loadImage($destination, false);
1137
+
1138
+ if ($sourceImage === false) {
1139
+ return "IMAGE NOT SUPPORTED";
1140
+ }
1141
+
1142
+ $sourceWidth = imagesx($sourceImage);
1143
+ $sourceHeight = imagesy($sourceImage);
1144
+
1145
+ $widthDiff = $destWidth / $sourceWidth;
1146
+ $heightDiff = $destHeight / $sourceHeight;
1147
+
1148
+ if ($widthDiff > 1 && $heightDiff > 1) {
1149
+ $nextWidth = $sourceWidth;
1150
+ $nextHeight = $sourceHeight;
1151
+ } else {
1152
+ if (intval($method) == 2 || (intval($method) == 0 AND $widthDiff > $heightDiff)) {
1153
+ $nextHeight = $destHeight;
1154
+ $nextWidth = intval(($sourceWidth * $nextHeight) / $sourceHeight);
1155
+ $destWidth = ((intval($method) == 0 ) ? $destWidth : $nextWidth);
1156
+ } else {
1157
+ $nextWidth = $destWidth;
1158
+ $nextHeight = intval($sourceHeight * $destWidth / $sourceWidth);
1159
+ $destHeight = (intval($method) == 0 ? $destHeight : $nextHeight);
1160
+ }
1161
+ }
1162
+
1163
+ $borderWidth = intval(($destWidth - $nextWidth) / 2);
1164
+ $borderHeight = intval(($destHeight - $nextHeight) / 2);
1165
+
1166
+ $destImage = imagecreatetruecolor($destWidth, $destHeight);
1167
+
1168
+ $white = imagecolorallocate($destImage, 255, 255, 255);
1169
+ imagefill($destImage, 0, 0, $white);
1170
+
1171
+ imagecopyresampled($destImage, $sourceImage, $borderWidth, $borderHeight, 0, 0, $nextWidth, $nextHeight, $sourceWidth, $sourceHeight);
1172
+ imagecolortransparent($destImage, $white);
1173
+
1174
+ return $this->_saveImage($destImage, $destination, $this->_imageType, 100) ? "OK" : "CAN'T SCALE IMAGE";
1175
+ }
1176
+ }
1177
+
1178
+ /**
1179
+ * @package api2cart
1180
+ * @author Vasul Babiy (v.babyi@magneticone.com)
1181
+ * @license Not public license
1182
+ * @link https://www.api2cart.com
1183
+ */
1184
+
1185
+ class M1_Mysqli
1186
+ {
1187
+ var $config = null; // config adapter
1188
+ var $result = array();
1189
+ var $dataBaseHandle = null;
1190
+
1191
+ /**
1192
+ * mysql constructor
1193
+ *
1194
+ * @param M1_Config_Adapter $config
1195
+ * @return M1_Mysql
1196
+ */
1197
+ function M1_Mysqli($config)
1198
+ {
1199
+ $this->config = $config;
1200
+ }
1201
+
1202
+ /**
1203
+ * @return bool|null|resource
1204
+ */
1205
+ function getDataBaseHandle()
1206
+ {
1207
+ if ($this->dataBaseHandle) {
1208
+ return $this->dataBaseHandle;
1209
+ }
1210
+
1211
+ $this->dataBaseHandle = $this->connect();
1212
+
1213
+ if (!$this->dataBaseHandle) {
1214
+ exit('[ERROR] MySQLi Query Error: Can not connect to DB');
1215
+ }
1216
+
1217
+ return $this->dataBaseHandle;
1218
+ }
1219
+
1220
+ /**
1221
+ * @return bool|null|resource
1222
+ */
1223
+ function connect()
1224
+ {
1225
+ $triesCount = 10;
1226
+ $link = null;
1227
+ $host = $this->config->Host . ($this->config->Port ? ':' . $this->config->Port : '');
1228
+ $password = stripslashes($this->config->Password);
1229
+
1230
+ while (!$link) {
1231
+ if (!$triesCount--) {
1232
+ break;
1233
+ }
1234
+
1235
+ $link = @mysqli_connect($host, $this->config->Username, $password);
1236
+ if (!$link) {
1237
+ sleep(5);
1238
+ }
1239
+ }
1240
+
1241
+ if ($link) {
1242
+ mysqli_select_db($link, $this->config->Dbname);
1243
+ } else {
1244
+ return false;
1245
+ }
1246
+
1247
+ return $link;
1248
+ }
1249
+
1250
+ /**
1251
+ * @param $sql
1252
+ *
1253
+ * @return array|bool|mysqli_result
1254
+ */
1255
+ function localQuery($sql)
1256
+ {
1257
+ $result = array();
1258
+ $dataBaseHandle = $this->getDataBaseHandle();
1259
+
1260
+ $sth = mysqli_query($dataBaseHandle, $sql);
1261
+
1262
+ if (is_bool($sth)) {
1263
+ return $sth;
1264
+ }
1265
+
1266
+ while (($row = mysqli_fetch_assoc($sth))) {
1267
+ $result[] = $row;
1268
+ }
1269
+
1270
+ return $result;
1271
+ }
1272
+
1273
+ /**
1274
+ * @param $sql
1275
+ * @param $fetchType
1276
+ *
1277
+ * @return array
1278
+ */
1279
+ function query($sql, $fetchType)
1280
+ {
1281
+ $result = array(
1282
+ 'result' => null,
1283
+ 'message' => ''
1284
+ );
1285
+
1286
+ $dataBaseHandle = $this->getDataBaseHandle();
1287
+
1288
+ if (!$dataBaseHandle) {
1289
+ $result['message'] = '[ERROR] MySQLi Query Error: Can not connect to DB';
1290
+ return $result;
1291
+ }
1292
+
1293
+ if (isset($_GET['disable_checks'])) {
1294
+ $this->localQuery('SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0');
1295
+ $this->localQuery("SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
1296
+ }
1297
+
1298
+ if (isset($_REQUEST['set_names'])) {
1299
+ @mysqli_query($dataBaseHandle, "SET NAMES " . @mysqli_real_escape_string($dataBaseHandle, $_REQUEST['set_names']));
1300
+ @mysqli_query($dataBaseHandle, "SET CHARACTER SET " . @mysqli_real_escape_string($dataBaseHandle, $_REQUEST['set_names']));
1301
+ @mysqli_query($dataBaseHandle, "SET CHARACTER_SET_CONNECTION=" . @mysqli_real_escape_string($dataBaseHandle, $_REQUEST['set_names']));
1302
+ }
1303
+
1304
+ $fetchMode = MYSQLI_ASSOC;
1305
+ switch ($fetchType) {
1306
+ case 3:
1307
+ $fetchMode = MYSQLI_BOTH;
1308
+ break;
1309
+ case 2:
1310
+ $fetchMode = MYSQLI_NUM;
1311
+ break;
1312
+ case 1:
1313
+ $fetchMode = MYSQLI_ASSOC;
1314
+ break;
1315
+ default:
1316
+ break;
1317
+ }
1318
+
1319
+ $res = mysqli_query($dataBaseHandle, $sql);
1320
+
1321
+ $triesCount = 10;
1322
+ while (mysqli_errno($dataBaseHandle) == 2013) {
1323
+ if (!$triesCount--) {
1324
+ break;
1325
+ }
1326
+ // reconnect
1327
+ $dataBaseHandle = $this->getDataBaseHandle();
1328
+ if ($dataBaseHandle) {
1329
+
1330
+ if (isset($_REQUEST['set_names'])) {
1331
+ @mysqli_query($dataBaseHandle, "SET NAMES " . @mysqli_real_escape_string($dataBaseHandle, $_REQUEST['set_names']));
1332
+ @mysqli_query($dataBaseHandle, "SET CHARACTER SET " . @mysqli_real_escape_string($dataBaseHandle, $_REQUEST['set_names']));
1333
+ @mysqli_query($dataBaseHandle, "SET CHARACTER_SET_CONNECTION=" . @mysqli_real_escape_string($dataBaseHandle, $_REQUEST['set_names']));
1334
+ }
1335
+
1336
+ // execute query once again
1337
+ $res = mysqli_query($dataBaseHandle, $sql);
1338
+ }
1339
+ }
1340
+
1341
+ if (($errno = mysqli_errno($dataBaseHandle)) != 0) {
1342
+ $result['message'] = '[ERROR] MySQLi Query Error: ' . $errno . ', ' . mysqli_error($dataBaseHandle);
1343
+ return $result;
1344
+ }
1345
+
1346
+ $fetchedFields = array();
1347
+ while ($field = mysqli_fetch_field($res)) {
1348
+ $fetchedFields[] = $field;
1349
+ }
1350
+
1351
+ $rows = array();
1352
+ while ($row = mysqli_fetch_array($res, $fetchMode)) {
1353
+ $rows[] = $row;
1354
+ }
1355
+
1356
+ if (isset($_GET['disable_checks'])) {
1357
+ $this->localQuery("SET SQL_MODE=IFNULL(@OLD_SQL_MODE,'')");
1358
+ $this->localQuery("SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS,0)");
1359
+ }
1360
+
1361
+ $result['result'] = $rows;
1362
+ $result['fetchedFields'] = $fetchedFields;
1363
+
1364
+ mysqli_free_result($res);
1365
+
1366
+ return $result;
1367
+ }
1368
+
1369
+ /**
1370
+ * @return int
1371
+ */
1372
+ function getLastInsertId()
1373
+ {
1374
+ return mysqli_insert_id($this->dataBaseHandle);
1375
+ }
1376
+
1377
+ /**
1378
+ * @return int
1379
+ */
1380
+ function getAffectedRows()
1381
+ {
1382
+ return mysqli_affected_rows($this->dataBaseHandle);
1383
+ }
1384
+
1385
+ /**
1386
+ * @return void
1387
+ */
1388
+ function __destruct()
1389
+ {
1390
+ if ($this->dataBaseHandle) {
1391
+ mysqli_close($this->dataBaseHandle);
1392
+ }
1393
+
1394
+ $this->dataBaseHandle = null;
1395
+ }
1396
+
1397
+ }
1398
+
1399
+
1400
+ class M1_Config_Adapter_Woocommerce extends M1_Config_Adapter
1401
+ {
1402
+ function M1_Config_Adapter_Woocommerce()
1403
+ {
1404
+ //@include_once M1_STORE_BASE_DIR . "wp-config.php";
1405
+ if (file_exists(M1_STORE_BASE_DIR . 'wp-config.php')) {
1406
+ $config = file_get_contents(M1_STORE_BASE_DIR . 'wp-config.php');
1407
+ } else {
1408
+ $config = file_get_contents(dirname(M1_STORE_BASE_DIR) . '/wp-config.php');
1409
+ }
1410
+
1411
+ preg_match('/define\s*\(\s*\'DB_NAME\',\s*\'(.+)\'\s*\)\s*;/', $config, $match);
1412
+ $this->Dbname = $match[1];
1413
+ preg_match('/define\s*\(\s*\'DB_USER\',\s*\'(.+)\'\s*\)\s*;/', $config, $match);
1414
+ $this->Username = $match[1];
1415
+ preg_match('/define\s*\(\s*\'DB_PASSWORD\',\s*\'(.*)\'\s*\)\s*;/', $config, $match);
1416
+ $this->Password = $match[1];
1417
+ preg_match('/define\s*\(\s*\'DB_HOST\',\s*\'(.+)\'\s*\)\s*;/', $config, $match);
1418
+ $this->setHostPort( $match[1] );
1419
+ preg_match('/\$table_prefix\s*=\s*\'(.*)\'\s*;/', $config, $match);
1420
+ $this->TblPrefix = $match[1];
1421
+ $version = $this->getCartVersionFromDb("option_value", "options", "option_name = 'woocommerce_db_version'");
1422
+
1423
+ if ( $version != '' ) {
1424
+ $this->cartVars['dbVersion'] = $version;
1425
+ }
1426
+
1427
+ $this->cartVars['categoriesDirRelative'] = 'images/categories/';
1428
+ $this->cartVars['productsDirRelative'] = 'images/products/';
1429
+ $this->imagesDir = "wp-content/uploads/images/";
1430
+ $this->categoriesImagesDir = $this->imagesDir . 'categories/';
1431
+ $this->productsImagesDir = $this->imagesDir . 'products/';
1432
+ $this->manufacturersImagesDir = $this->imagesDir;
1433
+ }
1434
+ }
1435
+
1436
+
1437
+
1438
+ class M1_Config_Adapter_Ubercart extends M1_Config_Adapter
1439
+ {
1440
+ function M1_Config_Adapter_Ubercart()
1441
+ {
1442
+ @include_once M1_STORE_BASE_DIR . "sites/default/settings.php";
1443
+
1444
+ $url = parse_url($db_url);
1445
+
1446
+ $url['user'] = urldecode($url['user']);
1447
+ // Test if database url has a password.
1448
+ $url['pass'] = isset($url['pass']) ? urldecode($url['pass']) : '';
1449
+ $url['host'] = urldecode($url['host']);
1450
+ $url['path'] = urldecode($url['path']);
1451
+ // Allow for non-standard MySQL port.
1452
+ if (isset($url['port'])) {
1453
+ $url['host'] = $url['host'] .':'. $url['port'];
1454
+ }
1455
+
1456
+ $this->setHostPort( $url['host'] );
1457
+ $this->Dbname = ltrim( $url['path'], '/' );
1458
+ $this->Username = $url['user'];
1459
+ $this->Password = $url['pass'];
1460
+
1461
+ $this->imagesDir = "/sites/default/files/";
1462
+ if( !file_exists( M1_STORE_BASE_DIR . $this->imagesDir ) ) {
1463
+ $this->imagesDir = "/files";
1464
+ }
1465
+
1466
+ if ( file_exists(M1_STORE_BASE_DIR . "/modules/ubercart/uc_cart/uc_cart.info") ) {
1467
+ $str = file_get_contents(M1_STORE_BASE_DIR . "/modules/ubercart/uc_cart/uc_cart.info");
1468
+ if ( preg_match('/version\s+=\s+".+-(.+)"/', $str, $match) != 0 ) {
1469
+ $this->cartVars['dbVersion'] = $match[1];
1470
+ unset($match);
1471
+ }
1472
+ }
1473
+
1474
+ $this->categoriesImagesDir = $this->imagesDir;
1475
+ $this->productsImagesDir = $this->imagesDir;
1476
+ $this->manufacturersImagesDir = $this->imagesDir;
1477
+ }
1478
+ }
1479
+
1480
+
1481
+
1482
+ class M1_Config_Adapter_Cubecart3 extends M1_Config_Adapter
1483
+ {
1484
+ function M1_Config_Adapter_Cubecart3()
1485
+ {
1486
+ include_once(M1_STORE_BASE_DIR . 'includes/global.inc.php');
1487
+
1488
+ $this->setHostPort($glob['dbhost']);
1489
+ $this->Dbname = $glob['dbdatabase'];
1490
+ $this->Username = $glob['dbusername'];
1491
+ $this->Password = $glob['dbpassword'];
1492
+
1493
+ $this->imagesDir = 'images/uploads';
1494
+ $this->categoriesImagesDir = $this->imagesDir;
1495
+ $this->productsImagesDir = $this->imagesDir;
1496
+ $this->manufacturersImagesDir = $this->imagesDir;
1497
+ }
1498
+ }
1499
+
1500
+ class M1_Config_Adapter_JooCart extends M1_Config_Adapter
1501
+ {
1502
+ function M1_Config_Adapter_JooCart()
1503
+ {
1504
+ require_once M1_STORE_BASE_DIR . "/configuration.php";
1505
+
1506
+ if (class_exists("JConfig")) {
1507
+
1508
+ $jconfig = new JConfig();
1509
+
1510
+ $this->setHostPort($jconfig->host);
1511
+ $this->Dbname = $jconfig->db;
1512
+ $this->Username = $jconfig->user;
1513
+ $this->Password = $jconfig->password;
1514
+
1515
+ } else {
1516
+
1517
+ $this->setHostPort($mosConfig_host);
1518
+ $this->Dbname = $mosConfig_db;
1519
+ $this->Username = $mosConfig_user;
1520
+ $this->Password = $mosConfig_password;
1521
+ }
1522
+
1523
+
1524
+ $this->imagesDir = "components/com_opencart/image/";
1525
+ $this->categoriesImagesDir = $this->imagesDir;
1526
+ $this->productsImagesDir = $this->imagesDir;
1527
+ $this->manufacturersImagesDir = $this->imagesDir;
1528
+ }
1529
+ }
1530
+
1531
+
1532
+ class M1_Config_Adapter_Prestashop11 extends M1_Config_Adapter
1533
+ {
1534
+ function M1_Config_Adapter_Prestashop11()
1535
+ {
1536
+ $confFileOne = file_get_contents(M1_STORE_BASE_DIR . "/config/settings.inc.php");
1537
+ $confFileTwo = file_get_contents(M1_STORE_BASE_DIR . "/config/config.inc.php");
1538
+
1539
+ $filesLines = array_merge(explode("\n", $confFileOne), explode("\n", $confFileTwo));
1540
+
1541
+ $execute = '$currentDir = \'\';';
1542
+
1543
+ $isComment = false;
1544
+ foreach ($filesLines as $line) {
1545
+ $startComment = preg_match("/^(\/\*)/", $line);
1546
+ $endComment = preg_match("/(\*\/)$/", $line);
1547
+
1548
+ if ($isComment) {
1549
+ if ($endComment) {
1550
+ $isComment = false;
1551
+ }
1552
+ continue;
1553
+ } elseif ($startComment) {
1554
+ $isComment = true;
1555
+ if ($endComment) {
1556
+ $isComment = false;
1557
+ }
1558
+ continue;
1559
+ }
1560
+
1561
+ if (preg_match("/^(\s*)define\(/i", $line)) {
1562
+ if ((strpos($line, '_DB_') !== false) || (strpos($line, '_PS_IMG_DIR_') !== false) || (strpos($line, '_PS_VERSION_') !== false)) {
1563
+ $execute .= " " . $line;
1564
+ }
1565
+ }
1566
+ }
1567
+
1568
+ define( '_PS_ROOT_DIR_', M1_STORE_BASE_DIR );
1569
+ eval($execute);
1570
+
1571
+ $this->setHostPort(_DB_SERVER_);
1572
+ $this->Dbname = _DB_NAME_;
1573
+ $this->Username = _DB_USER_;
1574
+ $this->Password = _DB_PASSWD_;
1575
+
1576
+ if (defined('_PS_IMG_DIR_') && defined('_PS_ROOT_DIR_')) {
1577
+
1578
+ preg_match("/(\/\w+\/)$/i", _PS_IMG_DIR_, $m);
1579
+ $this->imagesDir = $m[1];
1580
+
1581
+ } else {
1582
+ $this->imagesDir = "/img/";
1583
+ }
1584
+
1585
+ $this->categoriesImagesDir = $this->imagesDir;
1586
+ $this->productsImagesDir = $this->imagesDir;
1587
+ $this->manufacturersImagesDir = $this->imagesDir;
1588
+
1589
+ if (defined('_PS_VERSION_')) {
1590
+ $this->cartVars['dbVersion'] = _PS_VERSION_;
1591
+ }
1592
+ }
1593
+ }
1594
+
1595
+
1596
+
1597
+ class M1_Config_Adapter_Ubercart3 extends M1_Config_Adapter
1598
+ {
1599
+ function M1_Config_Adapter_Ubercart3()
1600
+ {
1601
+ @include_once M1_STORE_BASE_DIR . "sites/default/settings.php";
1602
+
1603
+ $url = $databases['default']['default'];
1604
+
1605
+ $url['username'] = urldecode($url['username']);
1606
+ $url['password'] = isset($url['password']) ? urldecode($url['password']) : '';
1607
+ $url['host'] = urldecode($url['host']);
1608
+ $url['database'] = urldecode($url['database']);
1609
+ if (isset($url['port'])) {
1610
+ $url['host'] = $url['host'] .':'. $url['port'];
1611
+ }
1612
+
1613
+ $this->setHostPort( $url['host'] );
1614
+ $this->Dbname = ltrim( $url['database'], '/' );
1615
+ $this->Username = $url['username'];
1616
+ $this->Password = $url['password'];
1617
+
1618
+ $this->imagesDir = "/sites/default/files/";
1619
+ if (!file_exists( M1_STORE_BASE_DIR . $this->imagesDir )) {
1620
+ $this->imagesDir = "/files";
1621
+ }
1622
+
1623
+ $fileInfo = M1_STORE_BASE_DIR . "/modules/ubercart/uc_cart/uc_cart.info";
1624
+ if (file_exists( $fileInfo )) {
1625
+ $str = file_get_contents( $fileInfo );
1626
+ if (preg_match('/version\s+=\s+".+-(.+)"/', $str, $match) != 0) {
1627
+ $this->cartVars['dbVersion'] = $match[1];
1628
+ unset($match);
1629
+ }
1630
+ }
1631
+
1632
+ $this->categoriesImagesDir = $this->imagesDir;
1633
+ $this->productsImagesDir = $this->imagesDir;
1634
+ $this->manufacturersImagesDir = $this->imagesDir;
1635
+ }
1636
+ }
1637
+
1638
+
1639
+ class M1_Config_Adapter_XCart extends M1_Config_Adapter
1640
+ {
1641
+ function M1_Config_Adapter_XCart()
1642
+ {
1643
+ define('XCART_START', 1);
1644
+
1645
+ $config = file_get_contents(M1_STORE_BASE_DIR . "config.php");
1646
+
1647
+ preg_match('/\$sql_host.+\'(.+)\';/', $config, $match);
1648
+ $this->setHostPort( $match[1] );
1649
+ preg_match('/\$sql_user.+\'(.+)\';/', $config, $match);
1650
+ $this->Username = $match[1];
1651
+ preg_match('/\$sql_db.+\'(.+)\';/', $config, $match);
1652
+ $this->Dbname = $match[1];
1653
+ preg_match('/\$sql_password.+\'(.*)\';/', $config, $match);
1654
+ $this->Password = $match[1];
1655
+
1656
+ $this->imagesDir = 'images/'; // xcart starting from 4.1.x hardcodes images location
1657
+ $this->categoriesImagesDir = $this->imagesDir;
1658
+ $this->productsImagesDir = $this->imagesDir;
1659
+ $this->manufacturersImagesDir = $this->imagesDir;
1660
+
1661
+ if(file_exists(M1_STORE_BASE_DIR . "VERSION")) {
1662
+ $version = file_get_contents(M1_STORE_BASE_DIR . "VERSION");
1663
+ $this->cartVars['dbVersion'] = preg_replace('/(Version| |\\n)/','',$version);
1664
+ }
1665
+
1666
+ }
1667
+ }
1668
+
1669
+ class M1_Config_Adapter_Cubecart extends M1_Config_Adapter
1670
+ {
1671
+ function M1_Config_Adapter_Cubecart()
1672
+ {
1673
+ include_once(M1_STORE_BASE_DIR . 'includes/global.inc.php');
1674
+
1675
+ $this->setHostPort($glob['dbhost']);
1676
+ $this->Dbname = $glob['dbdatabase'];
1677
+ $this->Username = $glob['dbusername'];
1678
+ $this->Password = $glob['dbpassword'];
1679
+
1680
+ $this->imagesDir = 'images';
1681
+ $this->categoriesImagesDir = $this->imagesDir;
1682
+ $this->productsImagesDir = $this->imagesDir;
1683
+ $this->manufacturersImagesDir = $this->imagesDir;
1684
+ $dirHandle = opendir(M1_STORE_BASE_DIR . 'language/');
1685
+ //settings for cube 5
1686
+ $languages = array();
1687
+ while ($dirEntry = readdir($dirHandle)) {
1688
+ $info = pathinfo($dirEntry);
1689
+ $xmlflag = false;
1690
+
1691
+ if (isset($info['extension'])) {
1692
+ $xmlflag = strtoupper($info['extension']) != "XML" ? true : false;
1693
+ }
1694
+ if (is_dir(M1_STORE_BASE_DIR . 'language/' . $dirEntry) || $dirEntry == '.' || $dirEntry == '..' || strpos($dirEntry, "_") !== false || $xmlflag) {
1695
+ continue;
1696
+ }
1697
+ $configXml = simplexml_load_file(M1_STORE_BASE_DIR . 'language/'.$dirEntry);
1698
+ if ($configXml->info->title){
1699
+ $lang['name'] = (string)$configXml->info->title;
1700
+ $lang['code'] = substr((string)$configXml->info->code,0,2);
1701
+ $lang['locale'] = substr((string)$configXml->info->code,0,2);
1702
+ $lang['currency'] = (string)$configXml->info->default_currency;
1703
+ $lang['fileName'] = str_replace(".xml","",$dirEntry);
1704
+ $languages[] = $lang;
1705
+ }
1706
+ }
1707
+ if (!empty($languages)) {
1708
+ $this->cartVars['languages'] = $languages;
1709
+ }
1710
+ if ( file_exists(M1_STORE_BASE_DIR . 'ini.inc.php') ) {
1711
+ $conf = file_get_contents (M1_STORE_BASE_DIR . 'ini.inc.php');
1712
+ preg_match("/ini\['ver'\].*/", $conf, $match);
1713
+ if (isset($match[0]) && !empty($match[0])) {
1714
+ preg_match("/\d.*/", $match[0], $project);
1715
+ if (isset($project[0]) && !empty($project[0])) {
1716
+ $version = $project[0];
1717
+ $version = str_replace(array(" ","-","_","'",");",";",")"), "", $version);
1718
+ if ($version != '') {
1719
+ $this->cartVars['dbVersion'] = strtolower($version);
1720
+ }
1721
+ }
1722
+ } else {
1723
+ preg_match("/define\('CC_VERSION.*/", $conf, $match);
1724
+ if (isset($match[0]) && !empty($match[0])) {
1725
+ preg_match("/\d.*/", $match[0], $project);
1726
+ if (isset($project[0]) && !empty($project[0])){
1727
+ $version = $project[0];
1728
+ $version = str_replace(array(" ","-","_","'",");",";",")"), "", $version);
1729
+ if ($version != '') {
1730
+ $this->cartVars['dbVersion'] = strtolower($version);
1731
+ }
1732
+ }
1733
+ }
1734
+
1735
+ }
1736
+ } elseif ( file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'ini.inc.php') ) {
1737
+ $conf = file_get_contents (M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'ini.inc.php');
1738
+ preg_match("/ini\['ver'\].*/", $conf, $match);
1739
+ if (isset($match[0]) && !empty($match[0])) {
1740
+ preg_match("/\d.*/", $match[0], $project);
1741
+ if (isset($project[0]) && !empty($project[0])) {
1742
+ $version = $project[0];
1743
+ $version = str_replace(array(" ","-","_","'",");",";",")"), "", $version);
1744
+ if ($version != '') {
1745
+ $this->cartVars['dbVersion'] = strtolower($version);
1746
+ }
1747
+ }
1748
+ } else {
1749
+ preg_match("/define\('CC_VERSION.*/", $conf, $match);
1750
+ if (isset($match[0]) && !empty($match[0])) {
1751
+ preg_match("/\d.*/", $match[0], $project);
1752
+ if (isset($project[0]) && !empty($project[0])) {
1753
+ $version = $project[0];
1754
+ $version = str_replace(array(" ","-","_","'",");",";",")"), "", $version);
1755
+ if ($version != '') {
1756
+ $this->cartVars['dbVersion'] = strtolower($version);
1757
+ }
1758
+ }
1759
+ }
1760
+ }
1761
+ }
1762
+ }
1763
+ }
1764
+
1765
+ class M1_Config_Adapter_WebAsyst extends M1_Config_Adapter
1766
+ {
1767
+ function M1_Config_Adapter_WebAsyst()
1768
+ {
1769
+ $config = simplexml_load_file(M1_STORE_BASE_DIR . 'kernel/wbs.xml');
1770
+
1771
+ $dbKey = (string)$config->FRONTEND['dbkey'];
1772
+
1773
+ $config = simplexml_load_file(M1_STORE_BASE_DIR . 'dblist'. '/' . strtoupper($dbKey) . '.xml');
1774
+
1775
+ $host = (string)$config->DBSETTINGS['SQLSERVER'];
1776
+
1777
+ $this->setHostPort($host);
1778
+ $this->Dbname = (string)$config->DBSETTINGS['DB_NAME'];
1779
+ $this->Username = (string)$config->DBSETTINGS['DB_USER'];
1780
+ $this->Password = (string)$config->DBSETTINGS['DB_PASSWORD'];
1781
+
1782
+ $this->imagesDir = 'published/publicdata/'.strtoupper($dbKey).'/attachments/SC/products_pictures';
1783
+ $this->categoriesImagesDir = $this->imagesDir;
1784
+ $this->productsImagesDir = $this->imagesDir;
1785
+ $this->manufacturersImagesDir = $this->imagesDir;
1786
+
1787
+ if ( isset($config->VERSIONS['SYSTEM']) ) {
1788
+ $this->cartVars['dbVersion'] = (string)$config->VERSIONS['SYSTEM'];
1789
+ }
1790
+ }
1791
+
1792
+ }
1793
+
1794
+ class M1_Config_Adapter_Squirrelcart242 extends M1_Config_Adapter
1795
+ {
1796
+ function M1_Config_Adapter_Squirrelcart242()
1797
+ {
1798
+ include_once(M1_STORE_BASE_DIR . 'squirrelcart/config.php');
1799
+
1800
+ $this->setHostPort($sql_host);
1801
+ $this->Dbname = $db;
1802
+ $this->Username = $sql_username;
1803
+ $this->Password = $sql_password;
1804
+
1805
+ $this->imagesDir = $img_path;
1806
+ $this->categoriesImagesDir = $img_path . "/categories";
1807
+ $this->productsImagesDir = $img_path . "/products";
1808
+ $this->manufacturersImagesDir = $img_path;
1809
+
1810
+ $version = $this->getCartVersionFromDb("DB_Version", "Store_Information", "record_number = 1");
1811
+ if ( $version != '' ) {
1812
+ $this->cartVars['dbVersion'] = $version;
1813
+ }
1814
+ }
1815
+ }
1816
+
1817
+ class M1_Config_Adapter_Opencart14 extends M1_Config_Adapter
1818
+ {
1819
+ function M1_Config_Adapter_Opencart14()
1820
+ {
1821
+ include_once( M1_STORE_BASE_DIR . "/config.php");
1822
+
1823
+ if( defined('DB_HOST') ) {
1824
+ $this->setHostPort(DB_HOST);
1825
+ } else {
1826
+ $this->setHostPort(DB_HOSTNAME);
1827
+ }
1828
+
1829
+ if( defined('DB_USER') ) {
1830
+ $this->Username = DB_USER;
1831
+ } else {
1832
+ $this->Username = DB_USERNAME;
1833
+ }
1834
+
1835
+ $this->Password = DB_PASSWORD;
1836
+
1837
+ if( defined('DB_NAME') ) {
1838
+ $this->Dbname = DB_NAME;
1839
+ } else {
1840
+ $this->Dbname = DB_DATABASE;
1841
+ }
1842
+
1843
+ $indexFileContent = '';
1844
+ $startupFileContent = '';
1845
+
1846
+ if ( file_exists(M1_STORE_BASE_DIR . "/index.php") ) {
1847
+ $indexFileContent = file_get_contents(M1_STORE_BASE_DIR . "/index.php");
1848
+ }
1849
+
1850
+ if (file_exists(M1_STORE_BASE_DIR . "/system/startup.php")) {
1851
+ $startupFileContent = file_get_contents(M1_STORE_BASE_DIR . "/system/startup.php");
1852
+ }
1853
+
1854
+ if ( preg_match("/define\('\VERSION\'\, \'(.+)\'\)/", $indexFileContent, $match) == 0 ) {
1855
+ preg_match("/define\('\VERSION\'\, \'(.+)\'\)/", $startupFileContent, $match);
1856
+ }
1857
+
1858
+ if ( count($match) > 0 ) {
1859
+ $this->cartVars['dbVersion'] = $match[1];
1860
+ unset($match);
1861
+ }
1862
+
1863
+ $this->imagesDir = "/image/";
1864
+ $this->categoriesImagesDir = $this->imagesDir;
1865
+ $this->productsImagesDir = $this->imagesDir;
1866
+ $this->manufacturersImagesDir = $this->imagesDir;
1867
+
1868
+ }
1869
+ }
1870
+
1871
+
1872
+
1873
+ class M1_Config_Adapter_Litecommerce extends M1_Config_Adapter
1874
+ {
1875
+ function M1_Config_Adapter_Litecommerce()
1876
+ {
1877
+ if ((file_exists(M1_STORE_BASE_DIR .'/etc/config.php'))){
1878
+ $file = M1_STORE_BASE_DIR .'/etc/config.php';
1879
+ $this->imagesDir = "/images";
1880
+ $this->categoriesImagesDir = $this->imagesDir."/category";
1881
+ $this->productsImagesDir = $this->imagesDir."/product";
1882
+ $this->manufacturersImagesDir = $this->imagesDir;
1883
+ } elseif(file_exists(M1_STORE_BASE_DIR .'/modules/lc_connector/litecommerce/etc/config.php')) {
1884
+ $file = M1_STORE_BASE_DIR .'/modules/lc_connector/litecommerce/etc/config.php';
1885
+ $this->imagesDir = "/modules/lc_connector/litecommerce/images";
1886
+ $this->categoriesImagesDir = $this->imagesDir."/category";
1887
+ $this->productsImagesDir = $this->imagesDir."/product";
1888
+ $this->manufacturersImagesDir = $this->imagesDir;
1889
+ }
1890
+
1891
+ $settings = parse_ini_file($file);
1892
+ $this->Host = $settings['hostspec'];
1893
+ $this->setHostPort($settings['hostspec']);
1894
+ $this->Username = $settings['username'];
1895
+ $this->Password = $settings['password'];
1896
+ $this->Dbname = $settings['database'];
1897
+ $this->TblPrefix = $settings['table_prefix'];
1898
+
1899
+ $version = $this->getCartVersionFromDb("value", "config", "name = 'version'");
1900
+ if ( $version != '' ) {
1901
+ $this->cartVars['dbVersion'] = $version;
1902
+ }
1903
+ }
1904
+ }
1905
+
1906
+
1907
+
1908
+ class M1_Config_Adapter_Oxid extends M1_Config_Adapter
1909
+ {
1910
+ function M1_Config_Adapter_Oxid()
1911
+ {
1912
+ //@include_once M1_STORE_BASE_DIR . "config.inc.php";
1913
+ $config = file_get_contents(M1_STORE_BASE_DIR . "config.inc.php");
1914
+ preg_match("/dbName(.+)?=(.+)?\'(.+)\';/", $config, $match);
1915
+ $this->Dbname = $match[3];
1916
+ preg_match("/dbUser(.+)?=(.+)?\'(.+)\';/", $config, $match);
1917
+ $this->Username = $match[3];
1918
+ preg_match("/dbPwd(.+)?=(.+)?\'(.+)\';/", $config, $match);
1919
+ $this->Password = isset($match[3])?$match[3]:'';
1920
+ preg_match("/dbHost(.+)?=(.+)?\'(.*)\';/", $config, $match);
1921
+ $this->setHostPort($match[3]);
1922
+
1923
+ //check about last slash
1924
+ $this->imagesDir = "out/pictures/";
1925
+ $this->categoriesImagesDir = $this->imagesDir;
1926
+ $this->productsImagesDir = $this->imagesDir;
1927
+ $this->manufacturersImagesDir = $this->imagesDir;
1928
+
1929
+ //add key for decoding config values in oxid db
1930
+ //check slash
1931
+ $key_config_file = file_get_contents(M1_STORE_BASE_DIR .'/core/oxconfk.php');
1932
+ preg_match("/sConfigKey(.+)?=(.+)?\"(.+)?\";/", $key_config_file, $match);
1933
+ $this->cartVars['sConfigKey'] = $match[3];
1934
+ $version = $this->getCartVersionFromDb("OXVERSION", "oxshops", "OXACTIVE=1 LIMIT 1" );
1935
+ if ( $version != '' ) {
1936
+ $this->cartVars['dbVersion'] = $version;
1937
+ }
1938
+ }
1939
+ }
1940
+
1941
+
1942
+
1943
+ class M1_Config_Adapter_XtcommerceVeyton extends M1_Config_Adapter
1944
+ {
1945
+ function M1_Config_Adapter_XtcommerceVeyton()
1946
+ {
1947
+ define('_VALID_CALL','TRUE');
1948
+ define('_SRV_WEBROOT','TRUE');
1949
+ require_once M1_STORE_BASE_DIR
1950
+ . 'conf'
1951
+ . DIRECTORY_SEPARATOR
1952
+ . 'config.php';
1953
+
1954
+ require_once M1_STORE_BASE_DIR
1955
+ . 'conf'
1956
+ . DIRECTORY_SEPARATOR
1957
+ . 'paths.php';
1958
+
1959
+ $this->setHostPort(_SYSTEM_DATABASE_HOST);
1960
+ $this->Dbname = _SYSTEM_DATABASE_DATABASE;
1961
+ $this->Username = _SYSTEM_DATABASE_USER;
1962
+ $this->Password = _SYSTEM_DATABASE_PWD;
1963
+ $this->imagesDir = _SRV_WEB_IMAGES;
1964
+ $this->TblPrefix = DB_PREFIX . "_";
1965
+
1966
+ $version = $this->getCartVersionFromDb("config_value", "config", "config_key = '_SYSTEM_VERSION'");
1967
+ if ( $version != '' ) {
1968
+ $this->cartVars['dbVersion'] = $version;
1969
+ }
1970
+
1971
+ $this->categoriesImagesDir = $this->imagesDir;
1972
+ $this->productsImagesDir = $this->imagesDir;
1973
+ $this->manufacturersImagesDir = $this->imagesDir;
1974
+ }
1975
+ }
1976
+
1977
+
1978
+ class M1_Config_Adapter_SSPremium extends M1_Config_Adapter
1979
+ {
1980
+ function M1_Config_Adapter_SSPremium()
1981
+ {
1982
+ if ( file_exists(M1_STORE_BASE_DIR . 'cfg/connect.inc.php') ){
1983
+ $config = file_get_contents(M1_STORE_BASE_DIR . 'cfg/connect.inc.php');
1984
+ preg_match("/define\(\'DB_NAME\', \'(.+)\'\);/", $config, $match);
1985
+ $this->Dbname = $match[1];
1986
+ preg_match("/define\(\'DB_USER\', \'(.+)\'\);/", $config, $match);
1987
+ $this->Username = $match[1];
1988
+ preg_match("/define\(\'DB_PASS\', \'(.*)\'\);/", $config, $match);
1989
+ $this->Password = $match[1];
1990
+ preg_match("/define\(\'DB_HOST\', \'(.+)\'\);/", $config, $match);
1991
+ $this->setHostPort( $match[1] );
1992
+
1993
+ $this->imagesDir = "products_pictures/";
1994
+ $this->categoriesImagesDir = $this->imagesDir;
1995
+ $this->productsImagesDir = $this->imagesDir;
1996
+ $this->manufacturersImagesDir = $this->imagesDir;
1997
+
1998
+ $version = $this->getCartVersionFromDb("value", "SS_system", "varName = 'version_number'");
1999
+ if ( $version != '' ) {
2000
+ $this->cartVars['dbVersion'] = $version;
2001
+ }
2002
+ } else {
2003
+ $config = include M1_STORE_BASE_DIR . "wa-config/db.php";
2004
+ $this->Dbname = $config['default']['database'];
2005
+ $this->Username = $config['default']['user'];
2006
+ $this->Password = $config['default']['password'];
2007
+ $this->setHostPort($config['default']['host']);
2008
+
2009
+ $this->imagesDir = "products_pictures/";
2010
+ $this->categoriesImagesDir = $this->imagesDir;
2011
+ $this->productsImagesDir = $this->imagesDir;
2012
+ $this->manufacturersImagesDir = $this->imagesDir;
2013
+ $this->cartVars['dbVersion'] = '5.0';
2014
+ }
2015
+
2016
+ }
2017
+
2018
+ }
2019
+
2020
+ class M1_Config_Adapter_Virtuemart113 extends M1_Config_Adapter
2021
+ {
2022
+ function M1_Config_Adapter_Virtuemart113()
2023
+ {
2024
+ require_once M1_STORE_BASE_DIR . "/configuration.php";
2025
+
2026
+ if (class_exists("JConfig")) {
2027
+
2028
+ $jconfig = new JConfig();
2029
+
2030
+ $this->setHostPort($jconfig->host);
2031
+ $this->Dbname = $jconfig->db;
2032
+ $this->Username = $jconfig->user;
2033
+ $this->Password = $jconfig->password;
2034
+
2035
+ } else {
2036
+
2037
+ $this->setHostPort($mosConfig_host);
2038
+ $this->Dbname = $mosConfig_db;
2039
+ $this->Username = $mosConfig_user;
2040
+ $this->Password = $mosConfig_password;
2041
+ }
2042
+
2043
+ if ( file_exists(M1_STORE_BASE_DIR . "/administrator/components/com_virtuemart/version.php") ) {
2044
+ $ver = file_get_contents(M1_STORE_BASE_DIR . "/administrator/components/com_virtuemart/version.php");
2045
+ if (preg_match('/\$RELEASE.+\'(.+)\'/', $ver, $match) != 0) {
2046
+ $this->cartVars['dbVersion'] = $match[1];
2047
+ unset($match);
2048
+ }
2049
+ }
2050
+
2051
+ $this->imagesDir = "components/com_virtuemart/shop_image";
2052
+ $this->categoriesImagesDir = $this->imagesDir;
2053
+ $this->productsImagesDir = $this->imagesDir;
2054
+ $this->manufacturersImagesDir = $this->imagesDir;
2055
+
2056
+ if ( is_dir( M1_STORE_BASE_DIR . 'images/stories/virtuemart/product' ) ) {
2057
+ $this->imagesDir = 'images/stories/virtuemart';
2058
+ $this->productsImagesDir = $this->imagesDir . '/product';
2059
+ $this->categoriesImagesDir = $this->imagesDir . '/category';
2060
+ $this->manufacturersImagesDir = $this->imagesDir . '/manufacturer';
2061
+ }
2062
+
2063
+ }
2064
+ }
2065
+
2066
+
2067
+ class M1_Config_Adapter_Hhgmultistore extends M1_Config_Adapter
2068
+ {
2069
+ function M1_Config_Adapter_Hhgmultistore()
2070
+ {
2071
+ define('SITE_PATH','');
2072
+ define('WEB_PATH','');
2073
+ require_once M1_STORE_BASE_DIR . "core/config/configure.php";
2074
+ require_once M1_STORE_BASE_DIR . "core/config/paths.php";
2075
+
2076
+ $baseDir = "/store_files/1/";
2077
+ $this->imagesDir = $baseDir . DIR_WS_IMAGES;
2078
+
2079
+ $this->categoriesImagesDir = $baseDir . DIR_WS_CATEGORIE_IMAGES;
2080
+ $this->productsImagesDirs['info'] = $baseDir . DIR_WS_PRODUCT_INFO_IMAGES;
2081
+ $this->productsImagesDirs['org'] = $baseDir . DIR_WS_PRODUCT_ORG_IMAGES;
2082
+ $this->productsImagesDirs['thumb'] = $baseDir . DIR_WS_PRODUCT_THUMBNAIL_IMAGES;
2083
+ $this->productsImagesDirs['popup'] = $baseDir . DIR_WS_PRODUCT_POPUP_IMAGES;
2084
+
2085
+ $this->manufacturersImagesDirs['img'] = $baseDir . DIR_WS_MANUFACTURERS_IMAGES;
2086
+ $this->manufacturersImagesDirs['org'] = $baseDir . DIR_WS_MANUFACTURERS_ORG_IMAGES;
2087
+
2088
+ $this->Host = DB_SERVER;
2089
+ $this->Username = DB_SERVER_USERNAME;
2090
+ $this->Password = DB_SERVER_PASSWORD;
2091
+ $this->Dbname = DB_DATABASE;
2092
+
2093
+ if ( file_exists(M1_STORE_BASE_DIR . "/core/config/conf.hhg_startup.php") ) {
2094
+ $ver = file_get_contents(M1_STORE_BASE_DIR . "/core/config/conf.hhg_startup.php");
2095
+ if (preg_match('/PROJECT_VERSION.+\((.+)\)\'\)/', $ver, $match) != 0) {
2096
+ $this->cartVars['dbVersion'] = $match[1];
2097
+ unset($match);
2098
+ }
2099
+ }
2100
+ }
2101
+ }
2102
+
2103
+
2104
+ class M1_Config_Adapter_Magento1212 extends M1_Config_Adapter
2105
+ {
2106
+ function M1_Config_Adapter_Magento1212()
2107
+ {
2108
+ /**
2109
+ * @var SimpleXMLElement
2110
+ */
2111
+ $config = simplexml_load_file(M1_STORE_BASE_DIR . 'app/etc/local.xml');
2112
+ $statuses = simplexml_load_file(M1_STORE_BASE_DIR . 'app/code/core/Mage/Sales/etc/config.xml');
2113
+
2114
+ $version = $statuses->modules->Mage_Sales->version;
2115
+
2116
+ $result = array();
2117
+
2118
+ if( version_compare($version, '1.4.0.25') < 0 ) {
2119
+ $statuses = $statuses->global->sales->order->statuses;
2120
+ foreach ( $statuses->children() as $status ) {
2121
+ $result[$status->getName()] = (string) $status->label;
2122
+ }
2123
+ }
2124
+
2125
+ if ( file_exists(M1_STORE_BASE_DIR . "app/Mage.php") ) {
2126
+ $ver = file_get_contents(M1_STORE_BASE_DIR . "app/Mage.php");
2127
+ if ( preg_match("/getVersionInfo[^}]+\'major\' *=> *\'(\d+)\'[^}]+\'minor\' *=> *\'(\d+)\'[^}]+\'revision\' *=> *\'(\d+)\'[^}]+\'patch\' *=> *\'(\d+)\'[^}]+}/s", $ver, $match) == 1 ) {
2128
+ $mageVersion = $match[1] . '.' . $match[2] . '.' . $match[3] . '.' . $match[4];
2129
+ $this->cartVars['dbVersion'] = $mageVersion;
2130
+ unset($match);
2131
+ }
2132
+ }
2133
+
2134
+ $this->cartVars['orderStatus'] = $result;
2135
+ $this->cartVars['AdminUrl'] = (string)$config->admin->routers->adminhtml->args->frontName;
2136
+
2137
+ $this->setHostPort((string) $config->global->resources->default_setup->connection->host);
2138
+ $this->Username = (string) $config->global->resources->default_setup->connection->username;
2139
+ $this->Dbname = (string) $config->global->resources->default_setup->connection->dbname;
2140
+ $this->Password = (string) $config->global->resources->default_setup->connection->password;
2141
+
2142
+ $this->imagesDir = 'media/';
2143
+ $this->categoriesImagesDir = $this->imagesDir . "catalog/category/";
2144
+ $this->productsImagesDir = $this->imagesDir . "catalog/product/";
2145
+ $this->manufacturersImagesDir = $this->imagesDir;
2146
+ @unlink(M1_STORE_BASE_DIR . 'app/etc/use_cache.ser');
2147
+ }
2148
+ }
2149
+
2150
+ class M1_Config_Adapter_Interspire extends M1_Config_Adapter
2151
+ {
2152
+ function M1_Config_Adapter_Interspire()
2153
+ {
2154
+ require_once M1_STORE_BASE_DIR . "config/config.php";
2155
+
2156
+ $this->setHostPort($GLOBALS['ISC_CFG']["dbServer"]);
2157
+ $this->Username = $GLOBALS['ISC_CFG']["dbUser"];
2158
+ $this->Password = $GLOBALS['ISC_CFG']["dbPass"];
2159
+ $this->Dbname = $GLOBALS['ISC_CFG']["dbDatabase"];
2160
+
2161
+ $this->imagesDir = $GLOBALS['ISC_CFG']["ImageDirectory"];
2162
+ $this->categoriesImagesDir = $this->imagesDir;
2163
+ $this->productsImagesDir = $this->imagesDir;
2164
+ $this->manufacturersImagesDir = $this->imagesDir;
2165
+
2166
+ define('DEFAULT_LANGUAGE_ISO2',$GLOBALS['ISC_CFG']["Language"]);
2167
+
2168
+ $version = $this->getCartVersionFromDb("database_version", $GLOBALS['ISC_CFG']["tablePrefix"] . "config", '1');
2169
+ if ( $version != '' ) {
2170
+ $this->cartVars['dbVersion'] = $version;
2171
+ }
2172
+ }
2173
+ }
2174
+
2175
+ class M1_Config_Adapter_Pinnacle361 extends M1_Config_Adapter
2176
+ {
2177
+ function M1_Config_Adapter_Pinnacle361()
2178
+ {
2179
+ include_once M1_STORE_BASE_DIR . 'content/engine/engine_config.php';
2180
+
2181
+ $this->imagesDir = 'images/';
2182
+ $this->categoriesImagesDir = $this->imagesDir;
2183
+ $this->productsImagesDir = $this->imagesDir;
2184
+ $this->manufacturersImagesDir = $this->imagesDir;
2185
+
2186
+ //$this->Host = DB_HOST;
2187
+ $this->setHostPort(DB_HOST);
2188
+ $this->Dbname = DB_NAME;
2189
+ $this->Username = DB_USER;
2190
+ $this->Password = DB_PASSWORD;
2191
+
2192
+ $version = $this->getCartVersionFromDb("value", (defined('DB_PREFIX') ? DB_PREFIX : '') . "settings", "name = 'AppVer'");
2193
+ if ( $version != '' ) {
2194
+ $this->cartVars['dbVersion'] = $version;
2195
+ }
2196
+ }
2197
+ }
2198
+
2199
+
2200
+
2201
+ class M1_Config_Adapter_Oscommerce22ms2 extends M1_Config_Adapter
2202
+ {
2203
+ function M1_Config_Adapter_Oscommerce22ms2()
2204
+ {
2205
+ $cur_dir = getcwd();
2206
+
2207
+ chdir(M1_STORE_BASE_DIR);
2208
+
2209
+ @require_once M1_STORE_BASE_DIR
2210
+ . "includes" . DIRECTORY_SEPARATOR
2211
+ . "configure.php";
2212
+
2213
+ chdir($cur_dir);
2214
+
2215
+ $this->imagesDir = DIR_WS_IMAGES;
2216
+
2217
+ $this->categoriesImagesDir = $this->imagesDir;
2218
+ $this->productsImagesDir = $this->imagesDir;
2219
+ if ( defined('DIR_WS_PRODUCT_IMAGES') ) {
2220
+ $this->productsImagesDir = DIR_WS_PRODUCT_IMAGES;
2221
+ }
2222
+ if ( defined('DIR_WS_ORIGINAL_IMAGES') ) {
2223
+ $this->productsImagesDir = DIR_WS_ORIGINAL_IMAGES;
2224
+ }
2225
+ $this->manufacturersImagesDir = $this->imagesDir;
2226
+
2227
+ //$this->Host = DB_SERVER;
2228
+ $this->setHostPort(DB_SERVER);
2229
+ $this->Username = DB_SERVER_USERNAME;
2230
+ $this->Password = DB_SERVER_PASSWORD;
2231
+ $this->Dbname = DB_DATABASE;
2232
+ chdir(M1_STORE_BASE_DIR);
2233
+ if ( file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'application_top.php') ) {
2234
+ $conf = file_get_contents (M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "application_top.php");
2235
+ preg_match("/define\('PROJECT_VERSION.*/", $conf, $match);
2236
+ if (isset($match[0]) && !empty($match[0])) {
2237
+ preg_match("/\d.*/", $match[0], $project);
2238
+ if (isset($project[0]) && !empty($project[0])) {
2239
+ $version = $project[0];
2240
+ $version = str_replace(array(" ","-","_","'",");"), "", $version);
2241
+ if ($version != '') {
2242
+ $this->cartVars['dbVersion'] = strtolower($version);
2243
+ }
2244
+ }
2245
+ } else {
2246
+ //if another oscommerce based cart
2247
+ if ( file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'version.php') ) {
2248
+ @require_once M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "version.php";
2249
+ if (defined('PROJECT_VERSION') && PROJECT_VERSION != '' ) {
2250
+ $version = PROJECT_VERSION;
2251
+ preg_match("/\d.*/", $version, $vers);
2252
+ if (isset($vers[0]) && !empty($vers[0])) {
2253
+ $version = $vers[0];
2254
+ $version = str_replace(array(" ","-","_"), "", $version);
2255
+ if ($version != '') {
2256
+ $this->cartVars['dbVersion'] = strtolower($version);
2257
+ }
2258
+ }
2259
+ //if zen_cart
2260
+ } else {
2261
+ if (defined('PROJECT_VERSION_MAJOR') && PROJECT_VERSION_MAJOR != '' ) {
2262
+ $this->cartVars['dbVersion'] = PROJECT_VERSION_MAJOR;
2263
+ }
2264
+ if (defined('PROJECT_VERSION_MINOR') && PROJECT_VERSION_MINOR != '' ) {
2265
+ $this->cartVars['dbVersion'] .= '.' . PROJECT_VERSION_MINOR;
2266
+ }
2267
+ }
2268
+ }
2269
+ }
2270
+ }
2271
+ chdir($cur_dir);
2272
+ }
2273
+ }
2274
+
2275
+
2276
+
2277
+ class M1_Config_Adapter_Tomatocart extends M1_Config_Adapter
2278
+ {
2279
+ function M1_Config_Adapter_Tomatocart()
2280
+ {
2281
+ $config = file_get_contents(M1_STORE_BASE_DIR . "includes/configure.php");
2282
+ preg_match("/define\(\'DB_DATABASE\', \'(.+)\'\);/", $config, $match);
2283
+ $this->Dbname = $match[1];
2284
+ preg_match("/define\(\'DB_SERVER_USERNAME\', \'(.+)\'\);/", $config, $match);
2285
+ $this->Username = $match[1];
2286
+ preg_match("/define\(\'DB_SERVER_PASSWORD\', \'(.*)\'\);/", $config, $match);
2287
+ $this->Password = $match[1];
2288
+ preg_match("/define\(\'DB_SERVER\', \'(.+)\'\);/", $config, $match);
2289
+ $this->setHostPort( $match[1] );
2290
+
2291
+ preg_match("/define\(\'DIR_WS_IMAGES\', \'(.+)\'\);/", $config, $match);
2292
+ $this->imagesDir = $match[1];
2293
+
2294
+ $this->categoriesImagesDir = $this->imagesDir.'categories/';
2295
+ $this->productsImagesDir = $this->imagesDir.'products/';
2296
+ $this->manufacturersImagesDir = $this->imagesDir . 'manufacturers/';
2297
+ if ( file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'application_top.php') ) {
2298
+ $conf = file_get_contents (M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "application_top.php");
2299
+ preg_match("/define\('PROJECT_VERSION.*/", $conf, $match);
2300
+
2301
+ if (isset($match[0]) && !empty($match[0])) {
2302
+ preg_match("/\d.*/", $match[0], $project);
2303
+ if (isset($project[0]) && !empty($project[0])) {
2304
+ $version = $project[0];
2305
+ $version = str_replace(array(" ","-","_","'",");"), "", $version);
2306
+ if ($version != '') {
2307
+ $this->cartVars['dbVersion'] = strtolower($version);
2308
+ }
2309
+ }
2310
+ } else {
2311
+ //if another version
2312
+ if ( file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'version.php') ) {
2313
+ @require_once M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "version.php";
2314
+ if (defined('PROJECT_VERSION') && PROJECT_VERSION != '' ) {
2315
+ $version = PROJECT_VERSION;
2316
+ preg_match("/\d.*/", $version, $vers);
2317
+ if (isset($vers[0]) && !empty($vers[0])) {
2318
+ $version = $vers[0];
2319
+ $version = str_replace(array(" ","-","_"), "", $version);
2320
+ if ($version != '') {
2321
+ $this->cartVars['dbVersion'] = strtolower($version);
2322
+ }
2323
+ }
2324
+ }
2325
+ }
2326
+ }
2327
+ }
2328
+ }
2329
+ }
2330
+
2331
+
2332
+
2333
+ class M1_Config_Adapter_Sunshop4 extends M1_Config_Adapter
2334
+ {
2335
+ function M1_Config_Adapter_Sunshop4()
2336
+ {
2337
+ @require_once M1_STORE_BASE_DIR
2338
+ . "include" . DIRECTORY_SEPARATOR
2339
+ . "config.php";
2340
+
2341
+ $this->imagesDir = "images/products/";
2342
+
2343
+ $this->categoriesImagesDir = $this->imagesDir;
2344
+ $this->productsImagesDir = $this->imagesDir;
2345
+ $this->manufacturersImagesDir = $this->imagesDir;
2346
+
2347
+ if ( defined('ADMIN_DIR') ) {
2348
+ $this->cartVars['AdminUrl'] = ADMIN_DIR;
2349
+ }
2350
+
2351
+ $this->setHostPort($servername);
2352
+ $this->Username = $dbusername;
2353
+ $this->Password = $dbpassword;
2354
+ $this->Dbname = $dbname;
2355
+
2356
+ if (isset($dbprefix)) {
2357
+ $this->TblPrefix = $dbprefix;
2358
+ }
2359
+
2360
+ $version = $this->getCartVersionFromDb("value", "settings", "name = 'version'");
2361
+ if ( $version != '' ) {
2362
+ $this->cartVars['dbVersion'] = $version;
2363
+ }
2364
+
2365
+ }
2366
+ }
2367
+
2368
+
2369
+
2370
+ class miSettings {
2371
+ var $arr;
2372
+
2373
+ function singleton() {
2374
+ static $instance = null;
2375
+ if ( $instance == null ) {
2376
+ $instance = new miSettings();
2377
+ }
2378
+ return $instance;
2379
+ }
2380
+
2381
+ function setArray($arr)
2382
+ {
2383
+ $this->arr[] = $arr;
2384
+ }
2385
+
2386
+ function getArray()
2387
+ {
2388
+ return $this->arr;
2389
+ }
2390
+
2391
+ }
2392
+
2393
+ class M1_Config_Adapter_Summercart3 extends M1_Config_Adapter
2394
+ {
2395
+ function M1_Config_Adapter_Summercart3()
2396
+ {
2397
+ @include_once M1_STORE_BASE_DIR . "include/miphpf/Config.php";
2398
+
2399
+ $instance = miSettings::singleton();
2400
+
2401
+ $data = $instance->getArray();
2402
+
2403
+ $this->setHostPort($data[0]['MI_DEFAULT_DB_HOST']);
2404
+ $this->Dbname = $data[0]['MI_DEFAULT_DB_NAME'];
2405
+ $this->Username = $data[0]['MI_DEFAULT_DB_USER'];
2406
+ $this->Password = $data[0]['MI_DEFAULT_DB_PASS'];
2407
+ $this->imagesDir = "/userfiles/";
2408
+
2409
+ $this->categoriesImagesDir = $this->imagesDir . "categoryimages";
2410
+ $this->productsImagesDir = $this->imagesDir . "productimages";
2411
+ $this->manufacturersImagesDir = $this->imagesDir . "manufacturer";
2412
+
2413
+ if ( file_exists(M1_STORE_BASE_DIR . "/include/VERSION") ) {
2414
+ $indexFileContent = file_get_contents(M1_STORE_BASE_DIR . "/include/VERSION");
2415
+ $this->cartVars['dbVersion'] = trim($indexFileContent);
2416
+ }
2417
+
2418
+ }
2419
+ }
2420
+
2421
+
2422
+
2423
+ class M1_Config_Adapter_Oscommerce3 extends M1_Config_Adapter
2424
+ {
2425
+ function M1_Config_Adapter_Oscommerce3()
2426
+ {
2427
+ $file = M1_STORE_BASE_DIR .'/osCommerce/OM/Config/settings.ini';
2428
+ $settings=parse_ini_file($file);
2429
+ $this->imagesDir = "/public/";
2430
+ $this->categoriesImagesDir = $this->imagesDir."/categories";
2431
+ $this->productsImagesDir = $this->imagesDir."/products";
2432
+ $this->manufacturersImagesDir = $this->imagesDir;
2433
+
2434
+ $this->Host = $settings['db_server'];
2435
+ $this->setHostPort($settings['db_server_port']);
2436
+ $this->Username = $settings['db_server_username'];
2437
+ $this->Password = $settings['db_server_password'];
2438
+ $this->Dbname = $settings['db_database'];
2439
+ }
2440
+ }
2441
+
2442
+
2443
+
2444
+ class M1_Config_Adapter_Prestashop15 extends M1_Config_Adapter
2445
+ {
2446
+ function M1_Config_Adapter_Prestashop15()
2447
+ {
2448
+ $confFileOne = file_get_contents(M1_STORE_BASE_DIR . "/config/settings.inc.php");
2449
+ $confFileTwo = file_get_contents(M1_STORE_BASE_DIR . "/config/config.inc.php");
2450
+
2451
+ $filesLines = array_merge(explode("\n", $confFileOne), explode("\n", $confFileTwo));
2452
+
2453
+ $execute = '$currentDir = \'\';';
2454
+
2455
+ $isComment = false;
2456
+ foreach ($filesLines as $line) {
2457
+ $startComment = preg_match("/^(\/\*)/", $line);
2458
+ $endComment = preg_match("/(\*\/)$/", $line);
2459
+
2460
+ if ($isComment) {
2461
+ if ($endComment) {
2462
+ $isComment = false;
2463
+ }
2464
+ continue;
2465
+ } elseif ($startComment) {
2466
+ $isComment = true;
2467
+ if ($endComment) {
2468
+ $isComment = false;
2469
+ }
2470
+ continue;
2471
+ }
2472
+
2473
+ if (preg_match("/^(\s*)define\(/i", $line)) {
2474
+ if ((strpos($line, '_DB_') !== false) || (strpos($line, '_PS_IMG_DIR_') !== false) || (strpos($line, '_PS_VERSION_') !== false)) {
2475
+ $execute .= " " . $line;
2476
+ }
2477
+ }
2478
+ }
2479
+
2480
+ define( '_PS_ROOT_DIR_', M1_STORE_BASE_DIR );
2481
+ eval($execute);
2482
+
2483
+ $this->setHostPort(_DB_SERVER_);
2484
+ $this->Dbname = _DB_NAME_;
2485
+ $this->Username = _DB_USER_;
2486
+ $this->Password = _DB_PASSWD_;
2487
+
2488
+ if (defined('_PS_IMG_DIR_') && defined('_PS_ROOT_DIR_')) {
2489
+
2490
+ preg_match("/(\/\w+\/)$/i", _PS_IMG_DIR_ ,$m);
2491
+ $this->imagesDir = $m[1];
2492
+
2493
+ } else {
2494
+ $this->imagesDir = "/img/";
2495
+ }
2496
+
2497
+ $this->categoriesImagesDir = $this->imagesDir;
2498
+ $this->productsImagesDir = $this->imagesDir;
2499
+ $this->manufacturersImagesDir = $this->imagesDir;
2500
+
2501
+ if (defined('_PS_VERSION_')) {
2502
+ $this->cartVars['dbVersion'] = _PS_VERSION_;
2503
+ }
2504
+ }
2505
+ }
2506
+
2507
+
2508
+
2509
+
2510
+ class M1_Config_Adapter_Gambio extends M1_Config_Adapter
2511
+ {
2512
+ function M1_Config_Adapter_Gambio()
2513
+ {
2514
+ $cur_dir = getcwd();
2515
+
2516
+ chdir(M1_STORE_BASE_DIR);
2517
+
2518
+ @require_once M1_STORE_BASE_DIR . "includes/configure.php";
2519
+
2520
+ chdir($cur_dir);
2521
+
2522
+ $this->imagesDir = DIR_WS_IMAGES;
2523
+
2524
+ $this->categoriesImagesDir = $this->imagesDir;
2525
+ $this->productsImagesDir = $this->imagesDir;
2526
+ if (defined('DIR_WS_PRODUCT_IMAGES')) {
2527
+ $this->productsImagesDir = DIR_WS_PRODUCT_IMAGES;
2528
+ }
2529
+ if (defined('DIR_WS_ORIGINAL_IMAGES')) {
2530
+ $this->productsImagesDir = DIR_WS_ORIGINAL_IMAGES;
2531
+ }
2532
+ $this->manufacturersImagesDir = $this->imagesDir;
2533
+
2534
+ $this->Host = DB_SERVER;
2535
+ //$this->setHostPort(DB_SERVER);
2536
+ $this->Username = DB_SERVER_USERNAME;
2537
+ $this->Password = DB_SERVER_PASSWORD;
2538
+ $this->Dbname = DB_DATABASE;
2539
+
2540
+ chdir(M1_STORE_BASE_DIR);
2541
+ if (file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'application_top.php')) {
2542
+ $conf = file_get_contents (M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "application_top.php");
2543
+ preg_match("/define\('PROJECT_VERSION.*/", $conf, $match);
2544
+ if (isset($match[0]) && !empty($match[0])) {
2545
+ preg_match("/\d.*/", $match[0], $project);
2546
+ if (isset($project[0]) && !empty($project[0])) {
2547
+ $version = $project[0];
2548
+ $version = str_replace(array(" ","-","_","'",");"), "", $version);
2549
+ if ($version != '') {
2550
+ $this->cartVars['dbVersion'] = strtolower($version);
2551
+ }
2552
+ }
2553
+ } else {
2554
+ //if another oscommerce based cart
2555
+ if ( file_exists(M1_STORE_BASE_DIR . DIRECTORY_SEPARATOR . 'version_info.php') ) {
2556
+ @require_once M1_STORE_BASE_DIR . DIRECTORY_SEPARATOR . "version_info.php";
2557
+ if (defined('PROJECT_VERSION') && PROJECT_VERSION != '' ) {
2558
+ $version = PROJECT_VERSION;
2559
+ preg_match("/\d.*/", $version, $vers);
2560
+ if (isset($vers[0]) && !empty($vers[0])) {
2561
+ $version = $vers[0];
2562
+ $version = str_replace(array(" ","-","_"), "", $version);
2563
+ if ($version != '') {
2564
+ $this->cartVars['dbVersion'] = strtolower($version);
2565
+ }
2566
+ }
2567
+ //if zen_cart
2568
+ } else {
2569
+ if (defined('PROJECT_VERSION_MAJOR') && PROJECT_VERSION_MAJOR != '' ) {
2570
+ $this->cartVars['dbVersion'] = PROJECT_VERSION_MAJOR;
2571
+ }
2572
+ if (defined('PROJECT_VERSION_MINOR') && PROJECT_VERSION_MINOR != '' ) {
2573
+ $this->cartVars['dbVersion'] .= '.' . PROJECT_VERSION_MINOR;
2574
+ }
2575
+ }
2576
+ }
2577
+ }
2578
+ }
2579
+ chdir($cur_dir);
2580
+ }
2581
+ }
2582
+
2583
+
2584
+
2585
+ class M1_Config_Adapter_Shopware extends M1_Config_Adapter
2586
+ {
2587
+ function M1_Config_Adapter_Shopware()
2588
+ {
2589
+ $configs = include(M1_STORE_BASE_DIR . "config.php");
2590
+ $this->setHostPort($configs['db']['host']);
2591
+ $this->Username = $configs['db']['username'];
2592
+ $this->Password = $configs['db']['password'];
2593
+ $this->Dbname = $configs['db']['dbname'];
2594
+ }
2595
+ }
2596
+
2597
+ class M1_Config_Adapter_AceShop extends M1_Config_Adapter
2598
+ {
2599
+ function M1_Config_Adapter_AceShop()
2600
+ {
2601
+ require_once M1_STORE_BASE_DIR . "/configuration.php";
2602
+
2603
+ if (class_exists("JConfig")) {
2604
+
2605
+ $jconfig = new JConfig();
2606
+
2607
+ $this->setHostPort($jconfig->host);
2608
+ $this->Dbname = $jconfig->db;
2609
+ $this->Username = $jconfig->user;
2610
+ $this->Password = $jconfig->password;
2611
+
2612
+ } else {
2613
+
2614
+ $this->setHostPort($mosConfig_host);
2615
+ $this->Dbname = $mosConfig_db;
2616
+ $this->Username = $mosConfig_user;
2617
+ $this->Password = $mosConfig_password;
2618
+ }
2619
+
2620
+
2621
+ $this->imagesDir = "components/com_aceshop/opencart/image/";
2622
+ $this->categoriesImagesDir = $this->imagesDir;
2623
+ $this->productsImagesDir = $this->imagesDir;
2624
+ $this->manufacturersImagesDir = $this->imagesDir;
2625
+ }
2626
+ }
2627
+
2628
+
2629
+ class M1_Config_Adapter_Cscart203 extends M1_Config_Adapter
2630
+ {
2631
+ function M1_Config_Adapter_Cscart203()
2632
+ {
2633
+ define("IN_CSCART", 1);
2634
+ define("CSCART_DIR", M1_STORE_BASE_DIR);
2635
+ define("AREA", 1);
2636
+ define("DIR_ROOT", M1_STORE_BASE_DIR);
2637
+ define("DIR_CSCART", M1_STORE_BASE_DIR);
2638
+ define('DS', DIRECTORY_SEPARATOR);
2639
+ define('BOOTSTRAP', '');
2640
+ require_once M1_STORE_BASE_DIR . 'config.php';
2641
+ defined('DIR_IMAGES') or define('DIR_IMAGES', DIR_ROOT . '/images/');
2642
+
2643
+ //For CS CART 1.3.x
2644
+ if( isset( $db_host ) && isset($db_name) && isset($db_user) && isset($db_password) ) {
2645
+ $this->setHostPort($db_host);
2646
+ $this->Dbname = $db_name;
2647
+ $this->Username = $db_user;
2648
+ $this->Password = $db_password;
2649
+ $this->imagesDir = str_replace(M1_STORE_BASE_DIR, '', IMAGES_STORAGE_DIR );
2650
+ } else {
2651
+
2652
+ $this->setHostPort($config['db_host']);
2653
+ $this->Dbname = $config['db_name'];
2654
+ $this->Username = $config['db_user'];
2655
+ $this->Password = $config['db_password'];
2656
+ $this->imagesDir = str_replace(M1_STORE_BASE_DIR, '', DIR_IMAGES);
2657
+ }
2658
+
2659
+ $this->categoriesImagesDir = $this->imagesDir;
2660
+ $this->productsImagesDir = $this->imagesDir;
2661
+ $this->manufacturersImagesDir = $this->imagesDir;
2662
+
2663
+ if( defined('MAX_FILES_IN_DIR') ) {
2664
+ $this->cartVars['cs_max_files_in_dir'] = MAX_FILES_IN_DIR;
2665
+ }
2666
+
2667
+ if( defined('PRODUCT_VERSION') ) {
2668
+ $this->cartVars['dbVersion'] = PRODUCT_VERSION;
2669
+ }
2670
+ }
2671
+ }
2672
+
2673
+
2674
+ class M1_Config_Adapter_WPecommerce extends M1_Config_Adapter
2675
+ {
2676
+ function M1_Config_Adapter_WPecommerce()
2677
+ {
2678
+ //@include_once M1_STORE_BASE_DIR . "wp-config.php";
2679
+ $config = file_get_contents(M1_STORE_BASE_DIR . "wp-config.php");
2680
+ preg_match("/define\(\'DB_NAME\', \'(.+)\'\);/", $config, $match);
2681
+ $this->Dbname = $match[1];
2682
+ preg_match("/define\(\'DB_USER\', \'(.+)\'\);/", $config, $match);
2683
+ $this->Username = $match[1];
2684
+ preg_match("/define\(\'DB_PASSWORD\', \'(.*)\'\);/", $config, $match);
2685
+ $this->Password = $match[1];
2686
+ preg_match("/define\(\'DB_HOST\', \'(.+)\'\);/", $config, $match);
2687
+ $this->setHostPort( $match[1] );
2688
+ preg_match("/(table_prefix)(.*)(')(.*)(')(.*)/", $config, $match);
2689
+ $this->TblPrefix = $match[4];
2690
+ $version = $this->getCartVersionFromDb("option_value", "options", "option_name = 'wpsc_version'");
2691
+ if ( $version != '' ) {
2692
+ $this->cartVars['dbVersion'] = $version;
2693
+ } else {
2694
+ if ( file_exists(M1_STORE_BASE_DIR . "wp-content".DIRECTORY_SEPARATOR."plugins".DIRECTORY_SEPARATOR."wp-shopping-cart".DIRECTORY_SEPARATOR."wp-shopping-cart.php") ) {
2695
+ $conf = file_get_contents (M1_STORE_BASE_DIR . "wp-content".DIRECTORY_SEPARATOR."plugins".DIRECTORY_SEPARATOR."wp-shopping-cart".DIRECTORY_SEPARATOR."wp-shopping-cart.php");
2696
+ preg_match("/define\('WPSC_VERSION.*/", $conf, $match);
2697
+ if (isset($match[0]) && !empty($match[0])) {
2698
+ preg_match("/\d.*/", $match[0], $project);
2699
+ if (isset($project[0]) && !empty($project[0])) {
2700
+ $version = $project[0];
2701
+ $version = str_replace(array(" ","-","_","'",");",")",";"), "", $version);
2702
+ if ($version != '') {
2703
+ $this->cartVars['dbVersion'] = strtolower($version);
2704
+ }
2705
+ }
2706
+ }
2707
+ }
2708
+ }
2709
+ if ( file_exists(M1_STORE_BASE_DIR . "wp-content/plugins/shopp/Shopp.php") || file_exists(M1_STORE_BASE_DIR . "wp-content/plugins/wp-e-commerce/editor.php") ) {
2710
+ $this->imagesDir = "wp-content/uploads/wpsc/";
2711
+ $this->categoriesImagesDir = $this->imagesDir.'category_images/';
2712
+ $this->productsImagesDir = $this->imagesDir.'product_images/';
2713
+ $this->manufacturersImagesDir = $this->imagesDir;
2714
+ } elseif ( file_exists(M1_STORE_BASE_DIR . "wp-content/plugins/wp-e-commerce/wp-shopping-cart.php") ) {
2715
+ $this->imagesDir = "wp-content/uploads/";
2716
+ $this->categoriesImagesDir = $this->imagesDir."wpsc/category_images/";
2717
+ $this->productsImagesDir = $this->imagesDir;
2718
+ $this->manufacturersImagesDir = $this->imagesDir;
2719
+ } else {
2720
+ $this->imagesDir = "images/";
2721
+ $this->categoriesImagesDir = $this->imagesDir;
2722
+ $this->productsImagesDir = $this->imagesDir;
2723
+ $this->manufacturersImagesDir = $this->imagesDir;
2724
+ }
2725
+ }
2726
+ }
2727
+
2728
+
2729
+
2730
+ class M1_Config_Adapter_LemonStand extends M1_Config_Adapter
2731
+ {
2732
+ function M1_Config_Adapter_LemonStand()
2733
+ {
2734
+ include (M1_STORE_BASE_DIR . 'phproad/system/phpr.php');
2735
+ include (M1_STORE_BASE_DIR . 'phproad/modules/phpr/classes/phpr_securityframework.php');
2736
+
2737
+ define('PATH_APP','');
2738
+
2739
+
2740
+ if(phpversion() > 5)
2741
+ {
2742
+ eval ('Phpr::$config = new MockConfig();
2743
+ Phpr::$config->set("SECURE_CONFIG_PATH", M1_STORE_BASE_DIR . "config/config.dat");
2744
+ $framework = Phpr_SecurityFramework::create();');
2745
+ }
2746
+
2747
+ $config_content = $framework->get_config_content();
2748
+
2749
+ $this->setHostPort($config_content['mysql_params']['host']);
2750
+ $this->Dbname = $config_content['mysql_params']['database'];
2751
+ $this->Username = $config_content['mysql_params']['user'];
2752
+ $this->Password = $config_content['mysql_params']['password'];
2753
+
2754
+ $this->categoriesImagesDir = '/uploaded/thumbnails/';
2755
+ $this->productsImagesDir = '/uploaded/';
2756
+ $this->manufacturersImagesDir = '/uploaded/thumbnails/';
2757
+
2758
+ $version = $this->getCartVersionFromDb("version_str", "core_versions", "moduleId = 'shop'");
2759
+ $this->cartVars['dbVersion'] = $version;
2760
+
2761
+ }
2762
+ }
2763
+
2764
+ class MockConfig {
2765
+ var $_data = array();
2766
+ function set($key, $value)
2767
+ {
2768
+ $this->_data[$key] = $value;
2769
+ }
2770
+
2771
+ function get($key, $default = 'default')
2772
+ {
2773
+ return isset($this->_data[$key]) ? $this->_data[$key] : $default;
2774
+ }
2775
+ }
2776
+
2777
+ class M1_Config_Adapter_DrupalCommerce extends M1_Config_Adapter
2778
+ {
2779
+
2780
+ function M1_Config_Adapter_DrupalCommerce()
2781
+ {
2782
+ @include_once M1_STORE_BASE_DIR . "sites/default/settings.php";
2783
+
2784
+ $url = $databases['default']['default'];
2785
+
2786
+ $url['username'] = urldecode($url['username']);
2787
+ $url['password'] = isset($url['password']) ? urldecode($url['password']) : '';
2788
+ $url['host'] = urldecode($url['host']);
2789
+ $url['database'] = urldecode($url['database']);
2790
+ if (isset($url['port'])) {
2791
+ $url['host'] = $url['host'] .':'. $url['port'];
2792
+ }
2793
+
2794
+ $this->setHostPort( $url['host'] );
2795
+ $this->Dbname = ltrim( $url['database'], '/' );
2796
+ $this->Username = $url['username'];
2797
+ $this->Password = $url['password'];
2798
+
2799
+ $this->imagesDir = "/sites/default/files/";
2800
+ if( !file_exists( M1_STORE_BASE_DIR . $this->imagesDir ) ) {
2801
+ $this->imagesDir = "/files";
2802
+ }
2803
+
2804
+
2805
+ $fileInfo = M1_STORE_BASE_DIR . "/sites/all/modules/commerce/commerce.info";
2806
+ if ( file_exists( $fileInfo ) ) {
2807
+ $str = file_get_contents( $fileInfo );
2808
+ if ( preg_match('/version\s+=\s+".+-(.+)"/', $str, $match) != 0 ) {
2809
+ $this->cartVars['dbVersion'] = $match[1];
2810
+ unset($match);
2811
+ }
2812
+ }
2813
+
2814
+ $this->categoriesImagesDir = $this->imagesDir;
2815
+ $this->productsImagesDir = $this->imagesDir;
2816
+ $this->manufacturersImagesDir = $this->imagesDir;
2817
+
2818
+
2819
+ }
2820
+ }
2821
+
2822
+ class M1_Config_Adapter_SSFree extends M1_Config_Adapter
2823
+ {
2824
+ function M1_Config_Adapter_SSFree()
2825
+ {
2826
+ $config = file_get_contents(M1_STORE_BASE_DIR . 'cfg/connect.inc.php');
2827
+ preg_match("/define\(\'DB_NAME\', \'(.+)\'\);/", $config, $match);
2828
+ $this->Dbname = $match[1];
2829
+ preg_match("/define\(\'DB_USER\', \'(.+)\'\);/", $config, $match);
2830
+ $this->Username = $match[1];
2831
+ preg_match("/define\(\'DB_PASS\', \'(.*)\'\);/", $config, $match);
2832
+ $this->Password = $match[1];
2833
+ preg_match("/define\(\'DB_HOST\', \'(.+)\'\);/", $config, $match);
2834
+ $this->setHostPort( $match[1] );
2835
+
2836
+ $this->imagesDir = "products_pictures/";
2837
+ $this->categoriesImagesDir = $this->imagesDir;
2838
+ $this->productsImagesDir = $this->imagesDir;
2839
+ $this->manufacturersImagesDir = $this->imagesDir;
2840
+
2841
+ $generalInc = file_get_contents(M1_STORE_BASE_DIR . 'cfg/general.inc.php');
2842
+
2843
+ preg_match("/define\(\'CONF_CURRENCY_ISO3\', \'(.+)\'\);/", $generalInc, $match);
2844
+ if (count($match) != 0) {
2845
+ $this->cartVars['iso3Currency'] = $match[1];
2846
+ }
2847
+
2848
+ preg_match("/define\(\'CONF_CURRENCY_ID_LEFT\', \'(.+)\'\);/", $generalInc, $match);
2849
+ if (count($match) != 0) {
2850
+ $this->cartVars['currencySymbolLeft'] = $match[1];
2851
+ }
2852
+
2853
+ preg_match("/define\(\'CONF_CURRENCY_ID_RIGHT\', \'(.+)\'\);/", $generalInc, $match);
2854
+ if (count($match) != 0) {
2855
+ $this->cartVars['currencySymbolRight'] = $match[1];
2856
+ }
2857
+ }
2858
+
2859
+ }
2860
+
2861
+ class M1_Config_Adapter_Zencart137 extends M1_Config_Adapter
2862
+ {
2863
+ function M1_Config_Adapter_Zencart137()
2864
+ {
2865
+ $cur_dir = getcwd();
2866
+
2867
+ chdir(M1_STORE_BASE_DIR);
2868
+
2869
+ @require_once M1_STORE_BASE_DIR
2870
+ . "includes" . DIRECTORY_SEPARATOR
2871
+ . "configure.php";
2872
+
2873
+ chdir($cur_dir);
2874
+
2875
+ $this->imagesDir = DIR_WS_IMAGES;
2876
+
2877
+ $this->categoriesImagesDir = $this->imagesDir;
2878
+ $this->productsImagesDir = $this->imagesDir;
2879
+ if ( defined('DIR_WS_PRODUCT_IMAGES') ) {
2880
+ $this->productsImagesDir = DIR_WS_PRODUCT_IMAGES;
2881
+ }
2882
+ if ( defined('DIR_WS_ORIGINAL_IMAGES') ) {
2883
+ $this->productsImagesDir = DIR_WS_ORIGINAL_IMAGES;
2884
+ }
2885
+ $this->manufacturersImagesDir = $this->imagesDir;
2886
+
2887
+ //$this->Host = DB_SERVER;
2888
+ $this->setHostPort(DB_SERVER);
2889
+ $this->Username = DB_SERVER_USERNAME;
2890
+ $this->Password = DB_SERVER_PASSWORD;
2891
+ $this->Dbname = DB_DATABASE;
2892
+ if ( file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . 'version.php') ) {
2893
+ @require_once M1_STORE_BASE_DIR
2894
+ . "includes" . DIRECTORY_SEPARATOR
2895
+ . "version.php";
2896
+ $major = PROJECT_VERSION_MAJOR;
2897
+ $minor = PROJECT_VERSION_MINOR;
2898
+ if (defined('EXPECTED_DATABASE_VERSION_MAJOR') && EXPECTED_DATABASE_VERSION_MAJOR != '' ) {
2899
+ $major = EXPECTED_DATABASE_VERSION_MAJOR;
2900
+ }
2901
+ if (defined('EXPECTED_DATABASE_VERSION_MINOR') && EXPECTED_DATABASE_VERSION_MINOR != '' ) {
2902
+ $minor = EXPECTED_DATABASE_VERSION_MINOR;
2903
+ }
2904
+
2905
+ if ( $major != '' && $minor != '' ) {
2906
+ $this->cartVars['dbVersion'] = $major.'.'.$minor;
2907
+ }
2908
+
2909
+ }
2910
+ }
2911
+ }
2912
+
2913
+
2914
+
2915
+
2916
+ class M1_Config_Adapter
2917
+ {
2918
+ var $Host = 'localhost';
2919
+ var $Port = null;//"3306";
2920
+ var $Username = 'root';
2921
+ var $Password = '';
2922
+ var $Dbname = '';
2923
+ var $TblPrefix = '';
2924
+
2925
+ var $cartType = 'Oscommerce22ms2';
2926
+ var $imagesDir = '';
2927
+ var $categoriesImagesDir = '';
2928
+ var $productsImagesDir = '';
2929
+ var $manufacturersImagesDir = '';
2930
+ var $categoriesImagesDirs = '';
2931
+ var $productsImagesDirs = '';
2932
+ var $manufacturersImagesDirs = '';
2933
+
2934
+ var $languages = array();
2935
+ var $cartVars = array();
2936
+
2937
+ function create()
2938
+ {
2939
+ if (isset($_GET["action"]) && $_GET["action"] == "update") {
2940
+ return null;
2941
+ }
2942
+
2943
+ $cartType = $this->_detectCartType();
2944
+ $className = "M1_Config_Adapter_" . $cartType;
2945
+
2946
+ $obj = new $className();
2947
+ $obj->cartType = $cartType;
2948
+
2949
+ return $obj;
2950
+ }
2951
+
2952
+ function _detectCartType()
2953
+ {
2954
+ // Zencart137
2955
+ if (file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "configure.php")
2956
+ && file_exists(M1_STORE_BASE_DIR . "ipn_main_handler.php")
2957
+ ) {
2958
+ return "Zencart137";
2959
+ }
2960
+
2961
+ //osCommerce
2962
+ /* is if not tomatocart */
2963
+ if (file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "configure.php")
2964
+ && !file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "toc_constants.php")
2965
+ ) {
2966
+ return "Oscommerce22ms2";
2967
+ }
2968
+
2969
+ if (file_exists(M1_STORE_BASE_DIR . "/includes/configure.php")) {
2970
+ return "Gambio";
2971
+ }
2972
+
2973
+ //JooCart
2974
+ if (file_exists(M1_STORE_BASE_DIR . '/components/com_opencart/opencart.php')) {
2975
+ return 'JooCart';
2976
+ }
2977
+
2978
+ //ACEShop
2979
+ if (file_exists(M1_STORE_BASE_DIR . '/components/com_aceshop/aceshop.php')) {
2980
+ return 'AceShop';
2981
+ }
2982
+
2983
+ //Litecommerce
2984
+ if ((file_exists(M1_STORE_BASE_DIR .'/etc/config.php'))
2985
+ || (file_exists(M1_STORE_BASE_DIR .'/modules/lc_connector/litecommerce/etc/config.php'))
2986
+ ) {
2987
+ return "Litecommerce";
2988
+ }
2989
+
2990
+ //Prestashop11
2991
+ if (file_exists(M1_STORE_BASE_DIR . "config/config.inc.php")) {
2992
+ if (file_exists(M1_STORE_BASE_DIR . "cache/class_index.php")) {
2993
+ return "Prestashop15";
2994
+ }
2995
+ return "Prestashop11";
2996
+ }
2997
+
2998
+ /*
2999
+ * Virtuemart113
3000
+ */
3001
+ if (file_exists(M1_STORE_BASE_DIR . "configuration.php")) {
3002
+ return "Virtuemart113";
3003
+ }
3004
+
3005
+ /*
3006
+ * Pinnacle361
3007
+ */
3008
+ if (file_exists(M1_STORE_BASE_DIR . 'content/engine/engine_config.php')) {
3009
+ return "Pinnacle361";
3010
+ }
3011
+
3012
+ // Magento1212, we can be sure that PHP is >= 5.2.0
3013
+ if (file_exists(M1_STORE_BASE_DIR . 'app/etc/local.xml')) {
3014
+ return "Magento1212";
3015
+ }
3016
+
3017
+ //Cubecart3
3018
+ if (file_exists(M1_STORE_BASE_DIR . 'includes/global.inc.php')) {
3019
+ return "Cubecart";
3020
+ }
3021
+
3022
+ //Cscart203 - 3
3023
+ if (file_exists(M1_STORE_BASE_DIR . "config.local.php") || file_exists(M1_STORE_BASE_DIR . "partner.php")) {
3024
+ return "Cscart203";
3025
+ }
3026
+
3027
+ //Opencart14
3028
+ if ((file_exists(M1_STORE_BASE_DIR . "system/startup.php")
3029
+ || (file_exists(M1_STORE_BASE_DIR . "common.php"))
3030
+ || (file_exists(M1_STORE_BASE_DIR . "library/locator.php"))
3031
+ ) && file_exists(M1_STORE_BASE_DIR . "config.php")
3032
+ ) {
3033
+ return "Opencart14";
3034
+ }
3035
+
3036
+ //Shopware
3037
+ if (file_exists(M1_STORE_BASE_DIR . "config.php") && file_exists(M1_STORE_BASE_DIR . "shopware.php")) {
3038
+ return "Shopware";
3039
+ }
3040
+
3041
+ //XCart
3042
+ if (file_exists(M1_STORE_BASE_DIR . "config.php")) {
3043
+ return "XCart";
3044
+ }
3045
+
3046
+ //LemonStand
3047
+ if (file_exists(M1_STORE_BASE_DIR . "boot.php")) {
3048
+ return "LemonStand";
3049
+ }
3050
+
3051
+ //Interspire
3052
+ if (file_exists(M1_STORE_BASE_DIR . "config/config.php")) {
3053
+ return "Interspire";
3054
+ }
3055
+
3056
+ //Squirrelcart242
3057
+ if (file_exists(M1_STORE_BASE_DIR . 'squirrelcart/config.php')) {
3058
+ return "Squirrelcart242";
3059
+ }
3060
+
3061
+ //Shopscript WebAsyst
3062
+ if (file_exists(M1_STORE_BASE_DIR . 'kernel/wbs.xml')) {
3063
+ return "WebAsyst";
3064
+ }
3065
+
3066
+ //Shopscript Premium
3067
+ if (file_exists(M1_STORE_BASE_DIR . 'cfg/general.inc.php') && file_exists(M1_STORE_BASE_DIR . 'cfg/connect.inc.php')) {
3068
+ return "SSFree";
3069
+ }
3070
+
3071
+ //Shopscript Premium
3072
+ if (file_exists(M1_STORE_BASE_DIR . 'cfg/connect.inc.php')) {
3073
+ return "SSPremium";
3074
+ }
3075
+
3076
+ //ShopScript5
3077
+ if (file_exists(M1_STORE_BASE_DIR . 'wa.php') && file_exists(M1_STORE_BASE_DIR . 'wa-config/db.php')) {
3078
+ return "SSPremium";
3079
+ }
3080
+
3081
+ //Summercart3
3082
+ if (file_exists(M1_STORE_BASE_DIR . 'sclic.lic') && file_exists(M1_STORE_BASE_DIR . 'include/miphpf/Config.php')) {
3083
+ return "Summercart3";
3084
+ }
3085
+
3086
+ //XtcommerceVeyton
3087
+ if (file_exists(M1_STORE_BASE_DIR . 'conf/config.php')) {
3088
+ return "XtcommerceVeyton";
3089
+ }
3090
+
3091
+ //Ubercart
3092
+ if (file_exists(M1_STORE_BASE_DIR . 'sites/default/settings.php' )) {
3093
+ if (file_exists( M1_STORE_BASE_DIR . '/modules/ubercart/uc_store/includes/coder_review_uc3x.inc')) {
3094
+ return "Ubercart3";
3095
+ } elseif (file_exists(M1_STORE_BASE_DIR . 'sites/all/modules/commerce/includes/commerce.controller.inc')) {
3096
+ return "DrupalCommerce";
3097
+ }
3098
+
3099
+ return "Ubercart";
3100
+ }
3101
+
3102
+ //Woocommerce
3103
+ if (file_exists(M1_STORE_BASE_DIR . 'wp-config.php')
3104
+ && file_exists(M1_STORE_BASE_DIR . 'wp-content/plugins/woocommerce/woocommerce.php')
3105
+ ) {
3106
+ return 'Woocommerce';
3107
+ }
3108
+
3109
+ if (file_exists(dirname(M1_STORE_BASE_DIR) . '/wp-config.php')
3110
+ && file_exists(M1_STORE_BASE_DIR . 'wp-content/plugins/woocommerce/woocommerce.php')
3111
+ ) {
3112
+ return 'Woocommerce';
3113
+ }
3114
+
3115
+ //WPecommerce
3116
+ if (file_exists(M1_STORE_BASE_DIR . 'wp-config.php')) {
3117
+ return 'WPecommerce';
3118
+ }
3119
+
3120
+ //OXID e-shop
3121
+ if (file_exists( M1_STORE_BASE_DIR . 'config.inc.php')) {
3122
+ return 'Oxid';
3123
+ }
3124
+
3125
+ //HHGMultistore
3126
+ if (file_exists(M1_STORE_BASE_DIR . 'core/config/configure.php')) {
3127
+ return 'Hhgmultistore';
3128
+ }
3129
+
3130
+ //SunShop
3131
+ if (file_exists(M1_STORE_BASE_DIR . "include" . DIRECTORY_SEPARATOR . "config.php")
3132
+ || file_exists(M1_STORE_BASE_DIR . "include" . DIRECTORY_SEPARATOR . "db_mysql.php")
3133
+ ) {
3134
+ return "Sunshop4";
3135
+ }
3136
+
3137
+ //Tomatocart
3138
+ if (file_exists(M1_STORE_BASE_DIR . "includes" . DIRECTORY_SEPARATOR . "configure.php")
3139
+ && file_exists(M1_STORE_BASE_DIR. "includes" . DIRECTORY_SEPARATOR . "toc_constants.php")
3140
+ ) {
3141
+ return 'Tomatocart';
3142
+ }
3143
+
3144
+ die ("BRIDGE_ERROR_CONFIGURATION_NOT_FOUND");
3145
+ }
3146
+
3147
+ function getAdapterPath($cartType)
3148
+ {
3149
+ return M1_STORE_BASE_DIR . M1_BRIDGE_DIRECTORY_NAME . DIRECTORY_SEPARATOR
3150
+ . "app" . DIRECTORY_SEPARATOR
3151
+ . "class" . DIRECTORY_SEPARATOR
3152
+ . "config_adapter" . DIRECTORY_SEPARATOR . $cartType . ".php";
3153
+ }
3154
+
3155
+ function setHostPort($source)
3156
+ {
3157
+ $source = trim($source);
3158
+
3159
+ if ($source == '') {
3160
+ $this->Host = 'localhost';
3161
+ return;
3162
+ }
3163
+
3164
+ $conf = explode(":", $source);
3165
+
3166
+ if (isset($conf[0]) && isset($conf[1])) {
3167
+ $this->Host = $conf[0];
3168
+ $this->Port = $conf[1];
3169
+ } elseif ($source[0] == '/') {
3170
+ $this->Host = 'localhost';
3171
+ $this->Port = $source;
3172
+ } else {
3173
+ $this->Host = $source;
3174
+ }
3175
+ }
3176
+
3177
+ function connect()
3178
+ {
3179
+ if (function_exists('mysql_connect')) {
3180
+ $link = new M1_Mysql($this);
3181
+ } elseif (function_exists('mysqli_connect')) {
3182
+ $link = new M1_Mysqli($this);
3183
+ } elseif (extension_loaded('pdo_mysql')) {
3184
+ $link = new M1_Pdo($this);
3185
+ } else {
3186
+ $link = false;
3187
+ }
3188
+
3189
+ return $link;
3190
+ }
3191
+
3192
+ function getCartVersionFromDb($field, $tableName, $where)
3193
+ {
3194
+ $version = '';
3195
+
3196
+ $link = $this->connect();
3197
+ if (!$link) {
3198
+ return '[ERROR] MySQL Query Error: Can not connect to DB';
3199
+ }
3200
+
3201
+ $result = $link->localQuery("
3202
+ SELECT " . $field . " AS version
3203
+ FROM " . $this->TblPrefix . $tableName . "
3204
+ WHERE " . $where
3205
+ );
3206
+
3207
+ if (is_array($result) && isset($result[0]['version'])) {
3208
+ $version = $result[0]['version'];
3209
+ }
3210
+
3211
+ return $version;
3212
+ }
3213
+ }
3214
+
3215
+
3216
+ class M1_Bridge
3217
+ {
3218
+ var $_link = null; //mysql connection link
3219
+ var $config = null; //config adapter
3220
+
3221
+ /**
3222
+ * Bridge constructor
3223
+ *
3224
+ * @param M1_Config_Adapter $config
3225
+ * @return M1_Bridge
3226
+ */
3227
+ function M1_Bridge($config)
3228
+ {
3229
+ $this->config = $config;
3230
+
3231
+ if ($this->getAction() != "savefile" && $this->getAction() != "update") {
3232
+ $this->_link = $this->config->connect();
3233
+ }
3234
+ }
3235
+
3236
+ function getTablesPrefix()
3237
+ {
3238
+ return $this->config->TblPrefix;
3239
+ }
3240
+
3241
+ function getLink()
3242
+ {
3243
+ return $this->_link;
3244
+ }
3245
+
3246
+ function query($sql, $fetchMode)
3247
+ {
3248
+ return $this->_link->query($sql, $fetchMode);
3249
+ }
3250
+
3251
+ function getAction()
3252
+ {
3253
+ if (isset($_GET['action'])) {
3254
+ return str_replace('.', '', $_GET['action']);
3255
+ }
3256
+
3257
+ return '';
3258
+ }
3259
+
3260
+ function run()
3261
+ {
3262
+ $action = $this->getAction();
3263
+
3264
+ if ($action != "update") {
3265
+ $this->_selfTest();
3266
+ }
3267
+
3268
+ if ($action == "checkbridge") {
3269
+ echo "BRIDGE_OK";
3270
+ return;
3271
+ }
3272
+
3273
+ if ($action == "update") {
3274
+ $this->_checkPossibilityUpdate();
3275
+ }
3276
+
3277
+ $className = "M1_Bridge_Action_" . ucfirst($action);
3278
+ if (!class_exists($className)) {
3279
+ echo 'ACTION_DO_NOT EXIST' . PHP_EOL;
3280
+ die;
3281
+ }
3282
+
3283
+ $actionObj = new $className();
3284
+ @$actionObj->cartType = @$this->config->cartType;
3285
+ $actionObj->perform($this);
3286
+ $this->_destroy();
3287
+ }
3288
+
3289
+ function isWritable($dir)
3290
+ {
3291
+ if (!@is_dir($dir)) {
3292
+ return false;
3293
+ }
3294
+
3295
+ $dh = @opendir($dir);
3296
+
3297
+ if ($dh === false) {
3298
+ return false;
3299
+ }
3300
+
3301
+ while (($entry = readdir($dh)) !== false) {
3302
+ if ($entry == "." || $entry == ".." || !@is_dir($dir . DIRECTORY_SEPARATOR . $entry)) {
3303
+ continue;
3304
+ }
3305
+
3306
+ if (!$this->isWritable($dir . DIRECTORY_SEPARATOR . $entry)) {
3307
+ return false;
3308
+ }
3309
+ }
3310
+
3311
+ if (!is_writable($dir)) {
3312
+ return false;
3313
+ }
3314
+
3315
+ return true;
3316
+ }
3317
+
3318
+ function _destroy()
3319
+ {
3320
+ $this->_link = null;
3321
+ }
3322
+
3323
+ function _checkPossibilityUpdate()
3324
+ {
3325
+ if (!is_writable(M1_STORE_BASE_DIR . "/" . M1_BRIDGE_DIRECTORY_NAME . "/")) {
3326
+ die("ERROR_TRIED_TO_PERMISSION" . M1_STORE_BASE_DIR . "/" . M1_BRIDGE_DIRECTORY_NAME . "/");
3327
+ }
3328
+
3329
+ if (!is_writable(M1_STORE_BASE_DIR . "/". M1_BRIDGE_DIRECTORY_NAME . "/bridge.php")) {
3330
+ die("ERROR_TRIED_TO_PERMISSION_BRIDGE_FILE" . M1_STORE_BASE_DIR . "/" . M1_BRIDGE_DIRECTORY_NAME . "/bridge.php");
3331
+ }
3332
+ }
3333
+
3334
+ function _selfTest()
3335
+ {
3336
+ if (!isset($_GET['ver']) || $_GET['ver'] != M1_BRIDGE_VERSION) {
3337
+ die ('ERROR_BRIDGE_VERSION_NOT_SUPPORTED');
3338
+ }
3339
+
3340
+ if (isset($_GET['token']) && $_GET['token'] == M1_TOKEN) {
3341
+ // good :)
3342
+ } else {
3343
+ die('ERROR_INVALID_TOKEN');
3344
+ }
3345
+
3346
+ if ((!isset($_GET['storetype']) || $_GET['storetype'] == 'target') && $this->getAction() == 'checkbridge') {
3347
+
3348
+ if (trim($this->config->imagesDir) != "") {
3349
+ if (!file_exists(M1_STORE_BASE_DIR . $this->config->imagesDir) && is_writable(M1_STORE_BASE_DIR)) {
3350
+ if (!@mkdir(M1_STORE_BASE_DIR . $this->config->imagesDir, 0777, true)) {
3351
+ die('ERROR_TRIED_TO_CREATE_IMAGE_DIR' . M1_STORE_BASE_DIR . $this->config->imagesDir);
3352
+ }
3353
+ }
3354
+
3355
+ if (!$this->isWritable(M1_STORE_BASE_DIR . $this->config->imagesDir)) {
3356
+ die('ERROR_NO_IMAGES_DIR '.M1_STORE_BASE_DIR . $this->config->imagesDir);
3357
+ }
3358
+ }
3359
+
3360
+ if (trim($this->config->categoriesImagesDir) != "") {
3361
+ if (!file_exists(M1_STORE_BASE_DIR . $this->config->categoriesImagesDir) && is_writable(M1_STORE_BASE_DIR)) {
3362
+ if (!@mkdir(M1_STORE_BASE_DIR . $this->config->categoriesImagesDir, 0777, true)) {
3363
+ die('ERROR_TRIED_TO_CREATE_IMAGE_DIR' . M1_STORE_BASE_DIR . $this->config->categoriesImagesDir);
3364
+ }
3365
+ }
3366
+
3367
+ if (!$this->isWritable(M1_STORE_BASE_DIR . $this->config->categoriesImagesDir)) {
3368
+ die('ERROR_NO_IMAGES_DIR '.M1_STORE_BASE_DIR . $this->config->categoriesImagesDir);
3369
+ }
3370
+ }
3371
+
3372
+ if (trim($this->config->productsImagesDir) != "") {
3373
+ if (!file_exists(M1_STORE_BASE_DIR . $this->config->productsImagesDir) && is_writable(M1_STORE_BASE_DIR)) {
3374
+ if (!@mkdir(M1_STORE_BASE_DIR . $this->config->productsImagesDir, 0777, true)) {
3375
+ die('ERROR_TRIED_TO_CREATE_IMAGE_DIR' . M1_STORE_BASE_DIR . $this->config->productsImagesDir);
3376
+ }
3377
+ }
3378
+
3379
+ if (!$this->isWritable(M1_STORE_BASE_DIR . $this->config->productsImagesDir)) {
3380
+ die('ERROR_NO_IMAGES_DIR '.M1_STORE_BASE_DIR . $this->config->productsImagesDir);
3381
+ }
3382
+ }
3383
+
3384
+ if (trim($this->config->manufacturersImagesDir) != "") {
3385
+ if (!file_exists(M1_STORE_BASE_DIR . $this->config->manufacturersImagesDir) && is_writable(M1_STORE_BASE_DIR)) {
3386
+ if (!@mkdir(M1_STORE_BASE_DIR . $this->config->manufacturersImagesDir, 0777, true)) {
3387
+ die('ERROR_TRIED_TO_CREATE_IMAGE_DIR' . M1_STORE_BASE_DIR . $this->config->manufacturersImagesDir);
3388
+ }
3389
+ }
3390
+
3391
+ if (!$this->isWritable(M1_STORE_BASE_DIR . $this->config->manufacturersImagesDir)) {
3392
+ die('ERROR_NO_IMAGES_DIR '.M1_STORE_BASE_DIR . $this->config->manufacturersImagesDir);
3393
+ }
3394
+ }
3395
+ }
3396
+ }
3397
+ }
3398
+
3399
+
3400
+ /**
3401
+ * @package api2cart
3402
+ * @author Vasul Babiy (v.babyi@magneticone.com)
3403
+ * @license Not public license
3404
+ * @link https://www.api2cart.com
3405
+ */
3406
+
3407
+ class M1_Mysql
3408
+ {
3409
+ var $config = null; // config adapter
3410
+ var $result = array();
3411
+ var $dataBaseHandle = null;
3412
+
3413
+ /**
3414
+ * mysql constructor
3415
+ *
3416
+ * @param M1_Config_Adapter $config
3417
+ * @return M1_Mysql
3418
+ */
3419
+ function M1_Mysql($config)
3420
+ {
3421
+ $this->config = $config;
3422
+ }
3423
+
3424
+ /**
3425
+ * @return bool|null|resource
3426
+ */
3427
+ function getDataBaseHandle()
3428
+ {
3429
+ if ($this->dataBaseHandle) {
3430
+ return $this->dataBaseHandle;
3431
+ }
3432
+
3433
+ $this->dataBaseHandle = $this->connect();
3434
+
3435
+ if (!$this->dataBaseHandle) {
3436
+ exit('[ERROR] MySQL Query Error: Can not connect to DB');
3437
+ }
3438
+
3439
+ return $this->dataBaseHandle;
3440
+ }
3441
+
3442
+ /**
3443
+ * @return bool|null|resource
3444
+ */
3445
+ function connect()
3446
+ {
3447
+ $triesCount = 10;
3448
+ $link = null;
3449
+ $host = $this->config->Host . ($this->config->Port ? ':' . $this->config->Port : '');
3450
+ $password = stripslashes($this->config->Password);
3451
+
3452
+ while (!$link) {
3453
+ if (!$triesCount--) {
3454
+ break;
3455
+ }
3456
+
3457
+ $link = @mysql_connect($host, $this->config->Username, $password);
3458
+ if (!$link) {
3459
+ sleep(5);
3460
+ }
3461
+ }
3462
+
3463
+ if ($link) {
3464
+ mysql_select_db($this->config->Dbname, $link);
3465
+ } else {
3466
+ return false;
3467
+ }
3468
+
3469
+ return $link;
3470
+ }
3471
+
3472
+ /**
3473
+ * @param string $sql sql query
3474
+ *
3475
+ * @return array
3476
+ */
3477
+ function localQuery($sql)
3478
+ {
3479
+ $result = array();
3480
+ $dataBaseHandle = $this->getDataBaseHandle();
3481
+
3482
+ $sth = mysql_query($sql, $dataBaseHandle);
3483
+
3484
+ if (is_bool($sth)) {
3485
+ return $sth;
3486
+ }
3487
+
3488
+ while (($row = mysql_fetch_assoc($sth)) != false) {
3489
+ $result[] = $row;
3490
+ }
3491
+
3492
+ return $result;
3493
+ }
3494
+
3495
+ /**
3496
+ * @param string $sql sql query
3497
+ * @param int $fetchType fetch Type
3498
+ *
3499
+ * @return array
3500
+ */
3501
+ function query($sql, $fetchType)
3502
+ {
3503
+ $result = array(
3504
+ 'result' => null,
3505
+ 'message' => '',
3506
+ );
3507
+ $dataBaseHandle = $this->getDataBaseHandle();
3508
+
3509
+ if (!$dataBaseHandle) {
3510
+ $result['message'] = '[ERROR] MySQL Query Error: Can not connect to DB';
3511
+ return $result;
3512
+ }
3513
+
3514
+ if (isset($_GET['disable_checks'])) {
3515
+ $this->localQuery('SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0');
3516
+ $this->localQuery("SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
3517
+ }
3518
+
3519
+ if (isset($_REQUEST['set_names'])) {
3520
+ @mysql_query("SET NAMES " . @mysql_real_escape_string($_REQUEST['set_names']), $dataBaseHandle);
3521
+ @mysql_query("SET CHARACTER SET " . @mysql_real_escape_string($_REQUEST['set_names']), $dataBaseHandle);
3522
+ @mysql_query("SET CHARACTER_SET_CONNECTION=" . @mysql_real_escape_string($_REQUEST['set_names']), $dataBaseHandle);
3523
+ }
3524
+
3525
+ $fetchMode = MYSQL_ASSOC;
3526
+ switch ($fetchType) {
3527
+ case 3:
3528
+ $fetchMode = MYSQL_BOTH;
3529
+ break;
3530
+ case 2:
3531
+ $fetchMode = MYSQL_NUM;
3532
+ break;
3533
+ case 1:
3534
+ $fetchMode = MYSQL_ASSOC;
3535
+ break;
3536
+ default:
3537
+ break;
3538
+ }
3539
+
3540
+ $res = mysql_query($sql, $dataBaseHandle);
3541
+
3542
+ $triesCount = 10;
3543
+ while (mysql_errno($dataBaseHandle) == 2013) {
3544
+ if (!$triesCount--) {
3545
+ break;
3546
+ }
3547
+ // reconnect
3548
+ $dataBaseHandle = $this->getDataBaseHandle();
3549
+ if ($dataBaseHandle) {
3550
+
3551
+ if (isset($_REQUEST['set_names'])) {
3552
+ @mysql_query("SET NAMES " . @mysql_real_escape_string($_REQUEST['set_names']), $dataBaseHandle);
3553
+ @mysql_query("SET CHARACTER SET " . @mysql_real_escape_string($_REQUEST['set_names']), $dataBaseHandle);
3554
+ @mysql_query("SET CHARACTER_SET_CONNECTION=" . @mysql_real_escape_string($_REQUEST['set_names']), $dataBaseHandle);
3555
+ }
3556
+
3557
+ // execute query once again
3558
+ $res = mysql_query($sql, $dataBaseHandle);
3559
+ }
3560
+ }
3561
+
3562
+ if (($errno = mysql_errno($dataBaseHandle)) != 0) {
3563
+ $result['message'] = '[ERROR] Mysql Query Error: ' . $errno . ', ' . mysql_error($dataBaseHandle);
3564
+ return $result;
3565
+ }
3566
+
3567
+ if (!is_resource($res)) {
3568
+ $result['result'] = $res;
3569
+ return $result;
3570
+ }
3571
+
3572
+ $fetchedFields = array();
3573
+ while (($field = mysql_fetch_field($res)) !== false) {
3574
+ $fetchedFields[] = $field;
3575
+ }
3576
+
3577
+ $rows = array();
3578
+ while (($row = mysql_fetch_array($res, $fetchMode)) !== false) {
3579
+ $rows[] = $row;
3580
+ }
3581
+
3582
+ if (isset($_GET['disable_checks'])) {
3583
+ $this->localQuery("SET SQL_MODE=IFNULL(@OLD_SQL_MODE,'')");
3584
+ $this->localQuery("SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS,0)");
3585
+ }
3586
+
3587
+ $result['result'] = $rows;
3588
+ $result['fetchedFields'] = $fetchedFields;
3589
+
3590
+ mysql_free_result($res);
3591
+ return $result;
3592
+ }
3593
+
3594
+ /**
3595
+ * @return int
3596
+ */
3597
+ function getLastInsertId()
3598
+ {
3599
+ return mysql_insert_id($this->dataBaseHandle);
3600
+ }
3601
+
3602
+ /**
3603
+ * @return int
3604
+ */
3605
+ function getAffectedRows()
3606
+ {
3607
+ return mysql_affected_rows($this->dataBaseHandle);
3608
+ }
3609
+
3610
+ /**
3611
+ * @return void
3612
+ */
3613
+ function __destruct()
3614
+ {
3615
+ if ($this->dataBaseHandle) {
3616
+ mysql_close($this->dataBaseHandle);
3617
+ }
3618
+
3619
+ $this->dataBaseHandle = null;
3620
+ }
3621
+ }
3622
+
3623
+
3624
+ /**
3625
+ * @package api2cart
3626
+ * @author Vasul Babiy (v.babyi@magneticone.com)
3627
+ * @license Not public license
3628
+ * @link https://www.api2cart.com
3629
+ */
3630
+
3631
+ class M1_Pdo
3632
+ {
3633
+ var $config = null; // config adapter
3634
+ var $noResult = array('delete', 'update', 'move', 'truncate', 'insert', 'set', 'create', 'drop');
3635
+ var $dataBaseHandle = null;
3636
+
3637
+ var $insertedId = 0;
3638
+ var $affectedRows = 0;
3639
+
3640
+ /**
3641
+ * pdo constructor
3642
+ *
3643
+ * @param M1_Config_Adapter $config configuration
3644
+ * @return M1_Pdo
3645
+ */
3646
+ function M1_Pdo($config)
3647
+ {
3648
+ $this->config = $config;
3649
+ }
3650
+
3651
+ /**
3652
+ * @return bool|null|PDO
3653
+ */
3654
+ function getDataBaseHandle()
3655
+ {
3656
+ if ($this->dataBaseHandle) {
3657
+ return $this->dataBaseHandle;
3658
+ }
3659
+
3660
+ $this->dataBaseHandle = $this->connect();
3661
+
3662
+ if (!$this->dataBaseHandle) {
3663
+ exit('[ERROR] MySQL Query Error: Can not connect to DB');
3664
+ }
3665
+
3666
+ return $this->dataBaseHandle;
3667
+ }
3668
+
3669
+ /**
3670
+ * @return bool|PDO
3671
+ */
3672
+ function connect()
3673
+ {
3674
+ $triesCount = 3;
3675
+ $host = $this->config->Host . ($this->config->Port ? ':' . $this->config->Port : '');
3676
+ $password = stripslashes($this->config->Password);
3677
+ $dbName = $this->config->Dbname;
3678
+
3679
+ while ($triesCount) {
3680
+ try {
3681
+ $link = new PDO("mysql:host=$host; dbname=$dbName", $this->config->Username, $password);
3682
+ $link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
3683
+
3684
+ return $link;
3685
+
3686
+ } catch (PDOException $e) {
3687
+ $triesCount--;
3688
+
3689
+ // fix invalid port
3690
+ $host = $this->config->Host;
3691
+ }
3692
+ }
3693
+ return false;
3694
+ }
3695
+
3696
+ /**
3697
+ * @param string $sql sql query
3698
+ *
3699
+ * @return array|bool
3700
+ */
3701
+ function localQuery($sql)
3702
+ {
3703
+ $result = array();
3704
+ $dataBaseHandle = $this->getDataBaseHandle();
3705
+
3706
+ $sth = $dataBaseHandle->query($sql);
3707
+
3708
+ foreach ($this->noResult as $statement) {
3709
+ if (!$sth || strpos(strtolower(trim($sql)), $statement) === 0) {
3710
+ return true;
3711
+ }
3712
+ }
3713
+
3714
+ while (($row = $sth->fetch(PDO::FETCH_ASSOC)) != false) {
3715
+ $result[] = $row;
3716
+ }
3717
+
3718
+ return $result;
3719
+ }
3720
+
3721
+ /**
3722
+ * @param string $sql sql query
3723
+ * @param int $fetchType fetch Type
3724
+ *
3725
+ * @return array
3726
+ */
3727
+ function query($sql, $fetchType)
3728
+ {
3729
+ $result = array(
3730
+ 'result' => null,
3731
+ 'message' => '',
3732
+ 'fetchedFields' => array()
3733
+ );
3734
+ $dataBaseHandle = $this->getDataBaseHandle();
3735
+
3736
+ if (isset($_GET['disable_checks'])) {
3737
+ $dataBaseHandle->exec('SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0');
3738
+ $dataBaseHandle->exec("SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
3739
+ }
3740
+
3741
+ if (isset($_REQUEST['set_names'])) {
3742
+ $dataBaseHandle->exec("SET NAMES '" . ($_REQUEST['set_names']) . "'");
3743
+ $dataBaseHandle->exec("SET CHARACTER SET '" . ($_REQUEST['set_names']) . "'");
3744
+ $dataBaseHandle->exec("SET CHARACTER_SET_CONNECTION = '" . ($_REQUEST['set_names']) . "'");
3745
+ }
3746
+
3747
+ switch ($fetchType) {
3748
+ case 3:
3749
+ $dataBaseHandle->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_BOTH);
3750
+ break;
3751
+ case 2:
3752
+ $dataBaseHandle->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM);
3753
+ break;
3754
+ case 1:
3755
+ default:
3756
+ $dataBaseHandle->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
3757
+ break;
3758
+ }
3759
+
3760
+ try {
3761
+ $res = $dataBaseHandle->query($sql);
3762
+ $this->affectedRows = $res->rowCount();
3763
+ $this->insertedId = $dataBaseHandle->lastInsertId();
3764
+ } catch (PDOException $e) {
3765
+ $result['message'] = '[ERROR] Mysql Query Error: ' . $e->getCode() . ', ' . $e->getMessage();
3766
+ return $result;
3767
+ }
3768
+
3769
+ foreach ($this->noResult as $statement) {
3770
+ if (!$res || strpos(strtolower(trim($sql)), $statement) === 0) {
3771
+ $result['result'] = true;
3772
+ return $result;
3773
+ }
3774
+ }
3775
+
3776
+ $rows = array();
3777
+ while (($row = $res->fetch()) !== false) {
3778
+ $rows[] = $row;
3779
+ }
3780
+
3781
+ if (isset($_GET['disable_checks'])) {
3782
+ $this->localQuery("SET SQL_MODE=IFNULL(@OLD_SQL_MODE,'')");
3783
+ $this->localQuery("SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS,0)");
3784
+ }
3785
+
3786
+ $result['result'] = $rows;
3787
+
3788
+ unset($res);
3789
+ return $result;
3790
+ }
3791
+
3792
+ /**
3793
+ * @return string|int
3794
+ */
3795
+ function getLastInsertId()
3796
+ {
3797
+ return $this->insertedId;
3798
+ }
3799
+
3800
+ /**
3801
+ * @return int
3802
+ */
3803
+ function getAffectedRows()
3804
+ {
3805
+ return $this->affectedRows;
3806
+ }
3807
+
3808
+ /**
3809
+ * @return void
3810
+ */
3811
+ function __destruct()
3812
+ {
3813
+ $this->dataBaseHandle = null;
3814
+ }
3815
+ }
3816
+
3817
+
3818
+ define('M1_BRIDGE_VERSION', '21');
3819
+
3820
+ define('M1_BRIDGE_DIRECTORY_NAME', basename(getcwd()));
3821
+
3822
+ ini_set('display_errors', 1);
3823
+ if (substr(phpversion(), 0, 1) == 5) {
3824
+ error_reporting(E_ALL & ~E_STRICT);
3825
+ } else {
3826
+ error_reporting(E_ALL);
3827
+ }
3828
+
3829
+ require_once 'config.php';
3830
+
3831
+ function stripslashes_array($array) {
3832
+ return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
3833
+ }
3834
+
3835
+ function getPHPExecutable() {
3836
+ $paths = explode(PATH_SEPARATOR, getenv('PATH'));
3837
+ $paths[] = PHP_BINDIR;
3838
+ foreach ($paths as $path) {
3839
+ // we need this for XAMPP (Windows)
3840
+ if (isset($_SERVER["WINDIR"]) && strstr($path, 'php.exe') && file_exists($path) && is_file($path)) {
3841
+ return $path;
3842
+ } else {
3843
+ $phpExecutable = $path . DIRECTORY_SEPARATOR . "php" . (isset($_SERVER["WINDIR"]) ? ".exe" : "");
3844
+ if (file_exists($phpExecutable) && is_file($phpExecutable)) {
3845
+ return $phpExecutable;
3846
+ }
3847
+ }
3848
+ }
3849
+ return false;
3850
+ }
3851
+
3852
+ if (!isset($_SERVER))
3853
+ {
3854
+ $_GET = &$HTTP_GET_VARS;
3855
+ $_POST = &$HTTP_POST_VARS;
3856
+ $_ENV = &$HTTP_ENV_VARS;
3857
+ $_SERVER = &$HTTP_SERVER_VARS;
3858
+ $_COOKIE = &$HTTP_COOKIE_VARS;
3859
+ $_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
3860
+ }
3861
+
3862
+ if (get_magic_quotes_gpc()) {
3863
+ $_COOKIE = stripslashes_array($_COOKIE);
3864
+ $_FILES = stripslashes_array($_FILES);
3865
+ $_GET = stripslashes_array($_GET);
3866
+ $_POST = stripslashes_array($_POST);
3867
+ $_REQUEST = stripslashes_array($_REQUEST);
3868
+ }
3869
+
3870
+ if (isset($_SERVER['SCRIPT_FILENAME'])) {
3871
+ $scriptPath = $_SERVER['SCRIPT_FILENAME'];
3872
+ if ( isset($_SERVER['PATH_TRANSLATED']) && $_SERVER['PATH_TRANSLATED'] != "" ) {
3873
+ $scriptPath = $_SERVER['PATH_TRANSLATED'];
3874
+ }
3875
+ define("M1_STORE_BASE_DIR", preg_replace('/[^\/\\\]*[\/\\\][^\/\\\]*$/', '', $scriptPath));
3876
+ } else {
3877
+ //Windows IIS
3878
+ define("M1_STORE_BASE_DIR", preg_replace('/[^\/\\\]*[\/\\\][^\/\\\]*$/', '', realpath(dirname(__FILE__) . "/../")));
3879
+ }
3880
+ $adapter = new M1_Config_Adapter();
3881
+ $bridge = new M1_Bridge($adapter->create());
3882
+
3883
+ if (!$bridge->getLink()) {
3884
+ die ('ERROR_BRIDGE_CANT_CONNECT_DB');
3885
+ }
3886
+
3887
+ $bridge->run();
3888
+ ?>
app/code/community/Webinterpret/Connector/bridge2cart/config.php CHANGED
@@ -1,2 +1,44 @@
1
- <?php // FILE WILL BE CREATED DURING INSTALLATION
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
1
+ <?php
2
+ /*-----------------------------------------------------------------------------+
3
+ | MagneticOne |
4
+ | Copyright (c) 2012 MagneticOne.com <contact@magneticone.com> |
5
+ | All rights reserved |
6
+ +------------------------------------------------------------------------------+
7
+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "license.txt"|
8
+ | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE |
9
+ | AT THE FOLLOWING URL: http://www.magneticone.com/store/license.php |
10
+ | |
11
+ | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE |
12
+ | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT MAGNETICONE |
13
+ | (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING |
14
+ | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). |
15
+ | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT |
16
+ | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, |
17
+ | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY |
18
+ | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS |
19
+ | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS |
20
+ | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND |
21
+ | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS |
22
+ | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE |
23
+ | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE. |
24
+ | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. |
25
+ | |
26
+ | The Developer of the Code is MagneticOne, |
27
+ | Copyright (C) 2006 - 2012 All Rights Reserved. |
28
+ +------------------------------------------------------------------------------+
29
+ | |
30
+ | ATTENTION! |
31
+ +------------------------------------------------------------------------------+
32
+ | By our Terms of Use you agreed not to change, modify, add, or remove portions|
33
+ | of Bridge Script source code as it is owned by MagneticOne company. |
34
+ | You agreed not to use, reproduce, modify, adapt, publish, translate |
35
+ | the Bridge Script source code into any form, medium, or technology |
36
+ | now known or later developed throughout the universe. |
37
+ | |
38
+ | Full text of our TOS located at |
39
+ | https://www.api2cart.com/terms-of-service |
40
+ +-----------------------------------------------------------------------------*/
41
+
42
+
43
+ define("M1_TOKEN", "b15949a7e20e3406dd7c01ecd28bab03");
44
 
app/code/community/Webinterpret/Connector/bridge2cart/helper.php CHANGED
@@ -56,7 +56,7 @@ if (!function_exists('getallheaders')) {
56
 
57
  class Webinterpret_Bridge2Cart_Helper
58
  {
59
- const VERSION = '1.0.7';
60
  const PLATFORM_MAGENTO = 'magento';
61
  const PLATFORM_UNKNOWN = 'unknown';
62
  protected static $_storeBaseDir = null;
@@ -172,6 +172,73 @@ class Webinterpret_Bridge2Cart_Helper
172
  return '-';
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  public static function loadBridgeConfig()
176
  {
177
  if (defined('M1_TOKEN')) {
@@ -192,7 +259,7 @@ class Webinterpret_Bridge2Cart_Helper
192
  if (!file_exists($path)) {
193
  return false;
194
  }
195
- $contents = file_get_contents($path);
196
  if ($contents === false) {
197
  return false;
198
  }
@@ -309,7 +376,6 @@ tQMgSP58oPZ6Nq6qM6KrlmkCAwEAAQ==
309
  -----END PUBLIC KEY-----
310
  EOD;
311
  $ok = openssl_verify($data, $signature, $publicKey, OPENSSL_ALGO_SHA1);
312
- openssl_free_key($publicKey);
313
 
314
  if ($ok == 1) {
315
  return true;
@@ -516,12 +582,10 @@ EOD;
516
 
517
  $platform = self::getPlatform();
518
  $response['platform'] = $platform;
519
- $baseDir = self::getStoreBaseDir();
520
- $response['base_dir'] = $baseDir;
521
- $pluginDir = self::getPluginDir();
522
- $response['plugin_dir'] = $pluginDir;
523
- $bridgeDir = self::getBridgeDir();
524
- $response['bridge_dir'] = $bridgeDir;
525
 
526
  // Magento
527
  if ($platform == self::PLATFORM_MAGENTO) {
@@ -662,7 +726,7 @@ EOD;
662
  $baseDir = self::getStoreBaseDir();
663
 
664
  if (file_exists($baseDir . '/app/etc/local.xml')) {
665
- $local = file_get_contents($baseDir . '/app/etc/local.xml');
666
  if ($local === false) {
667
  $response['status'] = 'error';
668
  $response['error_message'] = 'Failed to read configuration file';
@@ -763,4 +827,205 @@ EOD;
763
 
764
  return $response;
765
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  }
56
 
57
  class Webinterpret_Bridge2Cart_Helper
58
  {
59
+ const VERSION = '1.2.7.3';
60
  const PLATFORM_MAGENTO = 'magento';
61
  const PLATFORM_UNKNOWN = 'unknown';
62
  protected static $_storeBaseDir = null;
172
  return '-';
173
  }
174
 
175
+ public static function getDownloadMethod()
176
+ {
177
+ if (ini_get('allow_url_fopen')) {
178
+ return 'stream';
179
+ }
180
+ if (function_exists('curl_version')) {
181
+ return 'curl';
182
+ }
183
+
184
+ return false;
185
+ }
186
+
187
+ public static function downloadFile($url, $timeout = 10)
188
+ {
189
+ try {
190
+ $method = self::getDownloadMethod();
191
+
192
+ if ($method == 'stream') {
193
+ $ctx = stream_context_create(array(
194
+ 'http'=>
195
+ array(
196
+ 'timeout' => $timeout,
197
+ ),
198
+ 'https'=>
199
+ array(
200
+ 'timeout' => $timeout,
201
+ ),
202
+ )
203
+ );
204
+ $contents = @file_get_contents($url, false, $ctx);
205
+ if ($contents !== false) {
206
+ return $contents;
207
+ }
208
+ }
209
+
210
+ if ($method == 'curl') {
211
+
212
+ $ch = curl_init();
213
+ $headers = array(
214
+ "Accept: */*",
215
+ );
216
+ curl_setopt_array($ch, array(
217
+ CURLOPT_RETURNTRANSFER => 1,
218
+ CURLOPT_URL => $url,
219
+ CURLOPT_TIMEOUT => $timeout,
220
+ CURLOPT_FOLLOWLOCATION => true,
221
+ CURLOPT_ENCODING => '',
222
+ CURLOPT_HTTPHEADER => $headers,
223
+ ));
224
+
225
+ $contents = curl_exec($ch);
226
+
227
+ if (curl_errno($ch)) {
228
+ curl_close($ch);
229
+ return false;
230
+ }
231
+
232
+ curl_close($ch);
233
+ return $contents;
234
+ }
235
+ } catch (Exception $e) {
236
+ return false;
237
+ }
238
+
239
+ return false;
240
+ }
241
+
242
  public static function loadBridgeConfig()
243
  {
244
  if (defined('M1_TOKEN')) {
259
  if (!file_exists($path)) {
260
  return false;
261
  }
262
+ $contents = @file_get_contents($path);
263
  if ($contents === false) {
264
  return false;
265
  }
376
  -----END PUBLIC KEY-----
377
  EOD;
378
  $ok = openssl_verify($data, $signature, $publicKey, OPENSSL_ALGO_SHA1);
 
379
 
380
  if ($ok == 1) {
381
  return true;
582
 
583
  $platform = self::getPlatform();
584
  $response['platform'] = $platform;
585
+ $response['base_dir'] = self::getStoreBaseDir();
586
+ $response['plugin_dir'] = self::getPluginDir();
587
+ $response['bridge_dir'] = self::getBridgeDir();
588
+ $response['download_method'] = self::getDownloadMethod();
 
 
589
 
590
  // Magento
591
  if ($platform == self::PLATFORM_MAGENTO) {
726
  $baseDir = self::getStoreBaseDir();
727
 
728
  if (file_exists($baseDir . '/app/etc/local.xml')) {
729
+ $local = @file_get_contents($baseDir . '/app/etc/local.xml');
730
  if ($local === false) {
731
  $response['status'] = 'error';
732
  $response['error_message'] = 'Failed to read configuration file';
827
 
828
  return $response;
829
  }
830
+
831
+ public static function systemFileListAction()
832
+ {
833
+ $response = self::newResponse();
834
+
835
+ if (!isset($_REQUEST['dir'])) {
836
+ throw new Exception('dir parameter is required');
837
+ }
838
+ $dir = $_REQUEST['dir'];
839
+ if (!file_exists($dir)) {
840
+ throw new Exception('No such file or directory');
841
+ }
842
+
843
+ $response['result'] = array();
844
+ $iterator = new RecursiveDirectoryIterator($dir);
845
+ foreach (new RecursiveIteratorIterator($iterator) as $fileInfo) {
846
+ $response['result'][] = self::convertSplFileInfoToArray($fileInfo);
847
+ }
848
+
849
+ return $response;
850
+ }
851
+
852
+ public static function systemFileInfoAction()
853
+ {
854
+ $response = self::newResponse();
855
+
856
+ if (!isset($_REQUEST['file'])) {
857
+ throw new Exception('file parameter is required');
858
+ }
859
+ $file = $_REQUEST['file'];
860
+ if (!file_exists($file)) {
861
+ throw new Exception('No such file or directory');
862
+ }
863
+
864
+ $fileInfo = new SplFileInfo($file);
865
+ $response['result'] = self::convertSplFileInfoToArray($fileInfo);
866
+ return $response;
867
+ }
868
+
869
+ public static function systemFileRenameAction()
870
+ {
871
+ $response = self::newResponse();
872
+
873
+ if (!isset($_REQUEST['oldname'])) {
874
+ throw new Exception('oldname parameter is required');
875
+ }
876
+ $oldname = $_REQUEST['oldname'];
877
+
878
+ if (!isset($_REQUEST['newname'])) {
879
+ throw new Exception('newname parameter is required');
880
+ }
881
+ $newname = $_REQUEST['newname'];
882
+
883
+ if (!file_exists($oldname)) {
884
+ throw new Exception('No such file or directory');
885
+ }
886
+
887
+ if (!@rename($oldname, $newname)) {
888
+ throw new Exception('Failed to rename file');
889
+ }
890
+
891
+ return $response;
892
+ }
893
+
894
+ public static function systemFileChmodAction()
895
+ {
896
+ $response = self::newResponse();
897
+
898
+ if (!isset($_REQUEST['file'])) {
899
+ throw new Exception('file parameter is required');
900
+ }
901
+ $file = $_REQUEST['file'];
902
+
903
+ if (!isset($_REQUEST['mode'])) {
904
+ throw new Exception('mode parameter is required');
905
+ }
906
+ $mode = $_REQUEST['mode'];
907
+
908
+ if (!file_exists($file)) {
909
+ throw new Exception('No such file or directory');
910
+ }
911
+
912
+ if (!@chmod($file, octdec($mode))) {
913
+ throw new Exception('Failed to change file mode');
914
+ }
915
+
916
+ return $response;
917
+ }
918
+
919
+ public static function systemFileCopyAction()
920
+ {
921
+ $response = self::newResponse();
922
+
923
+ // Source
924
+ if (!isset($_REQUEST['source']) || empty($_REQUEST['source'])) {
925
+ throw new Exception('source parameter is required');
926
+ }
927
+ $source = $_REQUEST['source'];
928
+
929
+ if (filter_var($source, FILTER_VALIDATE_URL)) {
930
+ $contents = self::downloadFile($source);
931
+ if (!$contents) {
932
+ throw new Exception('Failed to download file');
933
+ }
934
+ } else {
935
+ if (!file_exists($source)) {
936
+ throw new Exception('Source file does not exist');
937
+ }
938
+ $contents = @file_get_contents($source);
939
+ }
940
+
941
+ // Destination
942
+ if (!isset($_REQUEST['dest']) || empty($_REQUEST['dest'])) {
943
+ throw new Exception('dest parameter is required');
944
+ }
945
+ $dest = $_REQUEST['dest'];
946
+
947
+ if (filter_var($dest, FILTER_VALIDATE_URL)) {
948
+ throw new Exception('dest cannot be an URL');
949
+ }
950
+
951
+ // Write file
952
+ if (file_put_contents($dest, $contents) === false) {
953
+ throw new Exception("Failed to write file: $dest");
954
+ }
955
+ @chmod($dest, 0664);
956
+
957
+ return $response;
958
+ }
959
+
960
+ public static function systemFileMkdirAction()
961
+ {
962
+ $response = self::newResponse();
963
+
964
+ if (!isset($_REQUEST['pathname'])) {
965
+ throw new Exception('pathname parameter is required');
966
+ }
967
+ $pathname = $_REQUEST['pathname'];
968
+
969
+ $mode = octdec('0775');
970
+ if (isset($_REQUEST['mode'])) {
971
+ $mode = octdec($_REQUEST['mode']);
972
+ }
973
+
974
+ $recursive = false;
975
+ if (isset($_REQUEST['recursive'])) {
976
+ $recursive = (bool)$_REQUEST['recursive'];
977
+ }
978
+
979
+ if (!@mkdir($pathname, $mode, $recursive)) {
980
+ throw new Exception('Failed to make directory');
981
+ }
982
+
983
+ return $response;
984
+ }
985
+
986
+ public static function systemFileRmdirAction()
987
+ {
988
+ $response = self::newResponse();
989
+
990
+ if (!isset($_REQUEST['pathname'])) {
991
+ throw new Exception('pathname parameter is required');
992
+ }
993
+ $pathname = $_REQUEST['pathname'];
994
+
995
+ if (!@rmdir($pathname)) {
996
+ throw new Exception('Failed to remove directory');
997
+ }
998
+
999
+ return $response;
1000
+ }
1001
+
1002
+ public static function convertSplFileInfoToArray($fileInfo)
1003
+ {
1004
+ $arr = array(
1005
+ 'filename' => $fileInfo->getFilename(),
1006
+ 'group' => $fileInfo->getGroup(),
1007
+ 'owner' => $fileInfo->getOwner(),
1008
+ 'path' => $fileInfo->getPath(),
1009
+ 'pathname' => $fileInfo->getPathname(),
1010
+ 'perms' => $fileInfo->getPerms(),
1011
+ 'realpath' => $fileInfo->getRealPath(),
1012
+ 'size' => $fileInfo->getSize(),
1013
+ 'type' => $fileInfo->getType(),
1014
+ 'is_dir' => $fileInfo->isDir(),
1015
+ 'is_executable' => $fileInfo->isExecutable(),
1016
+ 'is_file' => $fileInfo->isFile(),
1017
+ 'is_link' => $fileInfo->isLink(),
1018
+ 'is_readable' => $fileInfo->isReadable(),
1019
+ 'is_writable' => $fileInfo->isWritable(),
1020
+ );
1021
+ if ($fileInfo->isLink()) {
1022
+ $arr['link_target'] = $fileInfo->getLinkTarget();
1023
+ }
1024
+
1025
+ return $arr;
1026
+ }
1027
+ }
1028
+
1029
+ if (!defined('WI_HELPER_CALL_HANDLE_REQUEST') || WI_HELPER_CALL_HANDLE_REQUEST) {
1030
+ Webinterpret_Bridge2Cart_Helper::handleRequest();
1031
  }
app/code/community/Webinterpret/Connector/bridge2cart/preloader.php CHANGED
@@ -8,6 +8,7 @@
8
  * @license http://opensource.org/licenses/osl-3.0.php
9
  */
10
 
 
11
  require_once 'helper.php';
12
 
13
  // Verify digital signature
8
  * @license http://opensource.org/licenses/osl-3.0.php
9
  */
10
 
11
+ define('WI_HELPER_CALL_HANDLE_REQUEST', false);
12
  require_once 'helper.php';
13
 
14
  // Verify digital signature
app/code/community/Webinterpret/Connector/controllers/HelperController.php CHANGED
@@ -21,4 +21,17 @@ class Webinterpret_Connector_HelperController extends Mage_Core_Controller_Front
21
  Webinterpret_Bridge2Cart_Helper::handleRequest();
22
  die();
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
21
  Webinterpret_Bridge2Cart_Helper::handleRequest();
22
  die();
23
  }
24
+
25
+ public function installAction()
26
+ {
27
+ $response = array();
28
+ $response['status'] = 'success';
29
+ $response['response_id'] = md5(uniqid(mt_rand(), true));
30
+ if (!Mage::helper('webinterpret_connector')->installBridgeHelper()) {
31
+ $response['status'] = 'error';
32
+ }
33
+ header('Content-Type: application/json');
34
+ echo json_encode($response);
35
+ die();
36
+ }
37
  }
app/code/community/Webinterpret/Connector/etc/config.xml CHANGED
@@ -8,7 +8,7 @@
8
  <config>
9
  <modules>
10
  <Webinterpret_Connector>
11
- <version>1.2.7</version>
12
  </Webinterpret_Connector>
13
  </modules>
14
  <global>
@@ -91,7 +91,7 @@
91
  </adminhtml>
92
  <default>
93
  <webinterpret_connector>
94
- <enabled><![CDATA[0]]></enabled>
95
  <key><![CDATA[]]></key>
96
  <file_repository><![CDATA[https://webstores.webinterpret.com]]></file_repository>
97
  <footer_enabled><![CDATA[1]]></footer_enabled>
@@ -103,6 +103,7 @@
103
  <head><![CDATA[]]></head>
104
  <installation_mode><![CDATA[1]]></installation_mode>
105
  <global_notifications_enabled><![CDATA[1]]></global_notifications_enabled>
 
106
  </webinterpret_connector>
107
  </default>
108
  </config>
8
  <config>
9
  <modules>
10
  <Webinterpret_Connector>
11
+ <version>1.2.7.3</version>
12
  </Webinterpret_Connector>
13
  </modules>
14
  <global>
91
  </adminhtml>
92
  <default>
93
  <webinterpret_connector>
94
+ <enabled><![CDATA[1]]></enabled>
95
  <key><![CDATA[]]></key>
96
  <file_repository><![CDATA[https://webstores.webinterpret.com]]></file_repository>
97
  <footer_enabled><![CDATA[1]]></footer_enabled>
103
  <head><![CDATA[]]></head>
104
  <installation_mode><![CDATA[1]]></installation_mode>
105
  <global_notifications_enabled><![CDATA[1]]></global_notifications_enabled>
106
+ <automatic_updates_enabled><![CDATA[1]]></automatic_updates_enabled>
107
  </webinterpret_connector>
108
  </default>
109
  </config>
app/code/community/Webinterpret/Connector/etc/system.xml CHANGED
@@ -19,11 +19,41 @@
19
  <settings translate="label">
20
  <label>Settings</label>
21
  <frontend_type>text</frontend_type>
22
- <sort_order>20</sort_order>
23
  <show_in_default>1</show_in_default>
24
  <show_in_website>0</show_in_website>
25
  <show_in_store>0</show_in_store>
26
  <expanded>1</expanded>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  <fields>
28
  <active translate="label comment">
29
  <label>Enabled</label>
@@ -36,16 +66,6 @@
36
  <show_in_website>0</show_in_website>
37
  <show_in_store>0</show_in_store>
38
  </active>
39
- <key translate="label comment">
40
- <label>Webinterpret Key</label>
41
- <comment>Unique key for your store. If you don't have one then register at Webinterpret.com to get a new key.</comment>
42
- <config_path>webinterpret_connector/key</config_path>
43
- <frontend_type>text</frontend_type>
44
- <sort_order>20</sort_order>
45
- <show_in_default>1</show_in_default>
46
- <show_in_website>0</show_in_website>
47
- <show_in_store>0</show_in_store>
48
- </key>
49
  <footer_enabled translate="label comment">
50
  <label>Country Selector</label>
51
  <comment>Link to your international stores in the footer. Links appear after your products have been translated.</comment>
@@ -68,6 +88,17 @@
68
  <show_in_website>0</show_in_website>
69
  <show_in_store>0</show_in_store>
70
  </product_redirect_enabled>
 
 
 
 
 
 
 
 
 
 
 
71
  <global_notifications_enabled translate="label comment">
72
  <label>Admin Panel Notifications</label>
73
  <comment>Display notifications in Admin Panel to help you keep track of what's new or if something has changed.</comment>
@@ -80,16 +111,7 @@
80
  <show_in_store>0</show_in_store>
81
  </global_notifications_enabled>
82
  </fields>
83
- </settings>
84
- <status translate="label">
85
- <label>Status</label>
86
- <expanded>1</expanded>
87
- <frontend_model>webinterpret_connector/adminhtml_system_config_fieldset_status</frontend_model>
88
- <sort_order>30</sort_order>
89
- <show_in_default>1</show_in_default>
90
- <show_in_website>0</show_in_website>
91
- <show_in_store>0</show_in_store>
92
- </status>
93
  </groups>
94
  </webinterpret_connector>
95
  </sections>
19
  <settings translate="label">
20
  <label>Settings</label>
21
  <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
  <show_in_default>1</show_in_default>
24
  <show_in_website>0</show_in_website>
25
  <show_in_store>0</show_in_store>
26
  <expanded>1</expanded>
27
+ <fields>
28
+ <key translate="label comment">
29
+ <label>Webinterpret Key</label>
30
+ <comment>Unique key for your store. If you don't have one then register at Webinterpret.com to get a new key.</comment>
31
+ <config_path>webinterpret_connector/key</config_path>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>20</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>0</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ </key>
38
+ </fields>
39
+ </settings>
40
+ <status translate="label">
41
+ <label>Status</label>
42
+ <expanded>1</expanded>
43
+ <frontend_model>webinterpret_connector/adminhtml_system_config_fieldset_status</frontend_model>
44
+ <sort_order>20</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>0</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </status>
49
+ <advanced translate="label">
50
+ <label>Advanced</label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>30</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>0</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ <expanded>0</expanded>
57
  <fields>
58
  <active translate="label comment">
59
  <label>Enabled</label>
66
  <show_in_website>0</show_in_website>
67
  <show_in_store>0</show_in_store>
68
  </active>
 
 
 
 
 
 
 
 
 
 
69
  <footer_enabled translate="label comment">
70
  <label>Country Selector</label>
71
  <comment>Link to your international stores in the footer. Links appear after your products have been translated.</comment>
88
  <show_in_website>0</show_in_website>
89
  <show_in_store>0</show_in_store>
90
  </product_redirect_enabled>
91
+ <automatic_updates_enabled translate="label comment">
92
+ <label>Automatic Software Updates</label>
93
+ <comment>Allow this extension to automatically update its software with new features and improvements.</comment>
94
+ <config_path>webinterpret_connector/automatic_updates_enabled</config_path>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>adminhtml/system_config_source_yesno</source_model>
97
+ <sort_order>50</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>0</show_in_website>
100
+ <show_in_store>0</show_in_store>
101
+ </automatic_updates_enabled>
102
  <global_notifications_enabled translate="label comment">
103
  <label>Admin Panel Notifications</label>
104
  <comment>Display notifications in Admin Panel to help you keep track of what's new or if something has changed.</comment>
111
  <show_in_store>0</show_in_store>
112
  </global_notifications_enabled>
113
  </fields>
114
+ </advanced>
 
 
 
 
 
 
 
 
 
115
  </groups>
116
  </webinterpret_connector>
117
  </sections>
app/design/adminhtml/default/default/template/webinterpret/system/config/fieldset/status.phtml.bak DELETED
@@ -1,91 +0,0 @@
1
- <?php
2
- /**
3
- * @see Webinterpret_Connector_Block_Adminhtml_System_Config_Fieldset_Status
4
- */
5
- ?>
6
- <style>
7
- div.webinterpret-status {
8
- background: #fff;
9
- border: 1px solid #CCCCCC;
10
- margin-bottom: 10px;
11
- padding: 10px;
12
- }
13
- div.webinterpret-status table {
14
- padding: 0;
15
- margin: 0;
16
- border-collapse: collapse;
17
- width: 100%;
18
- }
19
- div.webinterpret-status table th,
20
- div.webinterpret-status table td {
21
- border: 1px solid #ccc;
22
- padding: 5px;
23
- margin: 0;
24
- }
25
- div.webinterpret-status table td.pass {
26
- color: #3c763d;
27
- background-color: #dff0d8;
28
- font-weight: bold;
29
- }
30
- div.webinterpret-status table td.fail {
31
- color: #a94442;
32
- background-color: #f2dede;
33
- font-weight: bold;
34
- }
35
- div.webinterpret-status p.test-connection {
36
- margin-top: 10px;
37
- }
38
- </style>
39
- <?php
40
- $report = Mage::helper('webinterpret_connector')->selfTest();
41
- ?>
42
- <div class="webinterpret-status">
43
- <h4><?php echo $this->__('Installation Information'); ?></h4>
44
- <table>
45
- <tr>
46
- <th width="120px"><?php echo $this->__('Component'); ?></th>
47
- <th width="60px"><?php echo $this->__('Status'); ?></th>
48
- <th><?php echo $this->__('Details'); ?></th>
49
- <tr>
50
- <td>PHP version</td>
51
- <td class="pass">Pass</td>
52
- <td><?php echo $report['php_version']['info']; ?></td>
53
- </tr>
54
- <tr>
55
- <td>Magento version</td>
56
- <td class="pass">Pass</td>
57
- <td><?php echo $report['magento_version']['info']; ?></td>
58
- </tr>
59
- <tr>
60
- <td>Webinterpret Key</td>
61
- <?php if ($report['webinterpret_key']['has_errors']): ?>
62
- <td class="fail">Fail</td>
63
- <td>
64
- <?php foreach ($report['webinterpret_key']['errors'] as $error): ?>
65
- <?php echo "<p>" . $error . "</p>"; ?>
66
- <?php endforeach; ?>
67
- </td>
68
- <?php else: ?>
69
- <td class="pass">Pass</td>
70
- <td><?php echo $report['webinterpret_key']['info']; ?></td>
71
- <?php endif; ?>
72
- </tr>
73
- <tr>
74
- <td>File permissions</td>
75
- <?php
76
- if ($report['connector_files']['has_errors']) {
77
- echo "<td class=\"fail\">Fail</td>";
78
- echo "<td>";
79
- foreach ($report['connector_files']['errors'] as $error) {
80
- echo "<p>" . $error . "</p>";
81
- }
82
- echo "</td>";
83
- } else {
84
- echo "<td class=\"pass\">Pass</td>";
85
- echo "<td>All files have the correct file permissions</td>";
86
- }
87
- ?>
88
- </td>
89
- </table>
90
- <p class="test-connection"><a href="<?php echo $this->getRemoteTestUrl(); ?>" target="_blank">Test Connection</a></p>
91
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/webinterpret/connector.xml CHANGED
@@ -38,15 +38,19 @@ Product view
38
 
39
  <!-- Header -->
40
  <reference name="head">
 
41
  <action method="addItem"><type>js_css</type><name>webinterpret/wi-cr.css</name></action>
42
  <action method="addItem"><type>js</type><name>webinterpret/wi-cr.js</name></action>
43
  <action method="addItem"><type>js_css</type><name>webinterpret/wi-pi.css</name></action>
44
  <action method="addItem"><type>js</type><name>webinterpret/wi-pi.js</name></action>
 
 
 
45
  </reference>
46
 
47
  <!-- Product Redirect -->
48
  <reference name="before_body_end">
49
- <block type="webinterpret_connector/product_redirect" name="webinterpret_connector_product_redirect" as="wi_product_redirect" template="webinterpret/product_redirect.phtml" />
50
  </reference>
51
 
52
  </catalog_product_view>
38
 
39
  <!-- Header -->
40
  <reference name="head">
41
+ <!--
42
  <action method="addItem"><type>js_css</type><name>webinterpret/wi-cr.css</name></action>
43
  <action method="addItem"><type>js</type><name>webinterpret/wi-cr.js</name></action>
44
  <action method="addItem"><type>js_css</type><name>webinterpret/wi-pi.css</name></action>
45
  <action method="addItem"><type>js</type><name>webinterpret/wi-pi.js</name></action>
46
+ -->
47
+ <action method="addItem"><type>js_css</type><name>webinterpret/webinterpret.css</name></action>
48
+ <action method="addItem"><type>js</type><name>webinterpret/webinterpret.js</name></action>
49
  </reference>
50
 
51
  <!-- Product Redirect -->
52
  <reference name="before_body_end">
53
+ <block type="webinterpret_connector/product_redirect" name="webinterpret_connector_product_redirect" as="wi_product_redirect" template="webinterpret/connector/product_redirect.phtml" />
54
  </reference>
55
 
56
  </catalog_product_view>
app/design/frontend/base/default/template/webinterpret/connector/product_redirect.phtml CHANGED
@@ -24,40 +24,26 @@
24
  </div>
25
  <script>
26
  //<![CDATA[
27
- if (window.wi_cr) {
28
- window.wi_cr.redirect('<?php echo $this->getRedirectUrl() ?>', '<?php echo $this->getUtmUrlQuery(null, "pr") ?>');
29
  }
30
- //]]>
31
- </script>
32
- <!-- end webinterpret_product_redirect -->
33
- <?php endif; ?>
34
- <?php endif; ?>
35
- <?php if (!Mage::helper('webinterpret_connector')->isUserNotAllowSaveCookie()): ?>
36
- <?php if (Mage::helper('webinterpret_connector')->isProductOverlayEnabled()): ?>
37
- <!-- webinterpret_product_overlay -->
38
- <div id="wi-fixedBar" class="hidden">
39
- <button id="wi-showProduct">
40
- <span id="wi-flag">
41
- <img />
42
- </span>
43
- <span id="wi-pi-link-mobile" class="wi-link wi-visible-xs"></span>
44
- <span class="wi-hidden-xs">
45
- <span id="wi-pi-link" class="wi-link"></span> <span id="wi-pi-link-description"></span></span>
46
- </button>
47
- <button id="wi-hideGlopal">
48
- <span id="wi-pi-hide-mobile" class="wi-link wi-visible-xs"></span>
49
- <span id="wi-pi-hide" class="wi-link wi-hidden-xs"></span>
50
- </button>
51
- </div>
52
- <div id="wi-overlay" class="hidden"></div>
53
- <script>
54
- //<![CDATA[
55
- if (window.wi_pi) {
56
- window.wi_pi.popup('<?php echo $this->getOverlayUrl() ?>', '<?php echo $this->getUtmUrlQuery(null, "po") ?>');
57
  }
58
  //]]>
59
  </script>
60
- <!-- end webinterpret_product_overlay -->
61
  <?php endif; ?>
62
  <?php endif; ?>
63
  <!-- end webinterpret_product_view -->
24
  </div>
25
  <script>
26
  //<![CDATA[
27
+ if (window._paq) {
28
+ _paq.push(['trackEvent', 'redirect', '<?php echo $this->buildTrackEventData("redirect", "pageview", "product_redirect") ?>']);
29
  }
30
+ if (window._paq && !window.jQuery) {
31
+ _paq.push(['trackEvent', 'redirect', '<?php echo $this->buildTrackEventData("redirect", "error", "jquery_not_found") ?>']);
32
+ }
33
+ if (window.jQuery && jQuery().webinterpret_RedirectModal) {
34
+ jQuery('#wi-cr-modal').webinterpret_RedirectModal({
35
+ url : '<?php echo $this->getRedirectUrl() ?>',
36
+ utm : '<?php echo $this->getUtmUrlQuery(null, "pr") ?>',
37
+ store_locale : '<?php echo $this->getLocaleCode() ?>'
38
+ });
39
+ } else {
40
+ if (window._paq) {
41
+ _paq.push(['trackEvent', 'redirect', '<?php echo $this->buildTrackEventData("redirect", "error", "webinterpret_js_not_found") ?>']);
42
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
  //]]>
45
  </script>
46
+ <!-- end webinterpret_product_redirect -->
47
  <?php endif; ?>
48
  <?php endif; ?>
49
  <!-- end webinterpret_product_view -->
app/locale/de_DE/Webinterpret_Connector.csv ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Webinterpret","Webinterpret"
2
+ "Settings","Einstellung""
3
+ "Enabled","Aktiviert"
4
+ "Turn integration with Webinterpret ON or OFF.","Integration mit Webinterpret an- oder ausschalten"
5
+ "Webinterpret Key","Webinterpret-Schlüssel"
6
+ "Unique key for your store. If you don't have one then register at Webinterpret.com to get a new key.","Ein einzigartiger Schlüssel für Ihr Geschäft. Falls Sie keinen haben, registrieren Sie sich auf Webinterpret.com, um einen neuen Schlüssel zu erhalten."
7
+ "Country Selector","Länderauswahl"
8
+ "Link to your international stores in the footer. Links appear after your products have been translated.","Der Link zu Ihrem internationalen Geschäft befindet sich in der Fußzeile. Die Links erscheinen, nachdem Ihre Produkte übersetzt wurden."
9
+ "Country Redirector Popup","Länder-Umleitungspopup"
10
+ "Redirect international visitors (using geolocation) via popup to translated product pages.","Leitet internationale Besucher (mit der Hilfe von Geolocation) durch Popups auf die übersetzte Produktseite um."
11
+ "Automatic Software Updates","Automatische Softwareaktualisierungen"
12
+ "Allow this extension to automatically update its software with new features and improvements.","Erlauben Sie dieser Erweiterung, sich automatisch für neue Funktionen und Verbesserungen zu aktualisieren."
13
+ "Admin Panel Notifications","Admin-Panel-Benachrichtigungen"
14
+ "Display notifications in Admin Panel to help you keep track of what's new or if something has changed.","Benachrichtungen im Admin-Panel anzeigen, damit Sie immer verfolgen können, ob es etwas Neues gibt oder ob sich etwas geändert hat."
15
+ "Status","Status"
16
+ "To continue installing Webinterpret, <a href=""%s"">click here</a>","Um mit der Installation von Webinterpret fortzufahren, <a href=""%s"">klicken Sie hier</a>"
17
+ "Webinterpret extension has stopped working. For more details, <a href=""%s"">click here</a>","Die Webinterpret-Erweiterung funktioniert nicht mehr. <a href=""%s"">Klicken Sie hier</a> für weitere Details"
18
+ "Webinterpret Key is not correct. Please try again.","Der Webinterpret-Schlüssel ist nicht korrekt. Bitter versuchen Sie es erneut."
19
+ "Failed to download file: %s<br>Please contact Webinterpret support.","Download der Datei fehlgeschlagen: %s<br>Bitte kontaktieren Sie den Webinterpret-Support."
20
+ "Failed to write file: %s<br>Please update the file permissions and try again.","Fehler beim Schreiben der Datei: %s<br>Bitte ändern Sie Dateiberechtigungen und versuchen Sie es erneut."
21
+ "Failed to read file: %s<br>Please update the file permissions and try again.","Fehler beim Lesen der Datei: %s<br>Bitte ändern Sie Dateiberechtigungen und versuchen Sie es erneut."
22
+ "Webinterpret Key","Webinterpret-Schlüssel"
23
+ "Key is valid","Der Schlüssel ist gültig"
24
+ "Key is missing. Please enter your Webinterpret Key. If you do not have one then <a href=""https://webstores.webinterpret.com"" target=""_blank"">click here to register</a>","Der Schlüssel fehlt. Bitte geben Sie Ihren Webinterpret-Schlüssel ein. Falls Sie keinen haben, <a href=""https://webstores.webinterpret.com"" target=""_blank"">klicken Sie hier, um sich zu registrieren</a>"
25
+ "Incorrect key. Please try entering your key again or <a href=""https://webstores.webinterpret.com"" target=""_blank"">get a new key</a>","Falscher Schlüssel. Bitte versuchen Sie erneut Ihren Schlüssel einzugeben oder <a href=""https://webstores.webinterpret.com"" target=""_blank"">holen Sie sich einen neuen Schlüssel</a>"
26
+ "Integration","Integration"
27
+ "Extension is ON","Erweiterungen sind eingeschaltet"
28
+ "Integration is turned OFF. Please set ""Enabled"" field to ""Yes"" and click the ""Save Config"" button.","Integrationen sind ausgeschaltet. Bitte stellen Sie das ""Aktivieren""-Feld auf ""Ja"" und klicken Sie auf den ""Änderungen speichern""-Knopf."
29
+ "Bridge Files","Dateien überbrücken"
30
+ "Bridge is installed","Überbrückung ist installiert."
31
+ "Bridge is not installed. Please click ""Save Config"" button to install it.","Überbrückung ist nicht installiert. Bitte klicken Sie auf den ""Kontiguration speichern""-Knopf, um sie zu installieren."
32
+ "Bridge is not installed. Please set ""Enabled"" field to ""Yes"" and click the ""Save Config"" button.","Überbrückung ist nicht installiert. Bitte stellen Sie das ""Aktivieren""-Feld auf ""Ja"" und klicken Sie auf den ""Kontiguration speichern""-Knopf."
33
+ "PHP","PHP"
34
+ "Unsupported PHP version. Please upgrade to version 5 or higher.","Nicht unterstützte PHP-Version. Bitte upgraden Sie auf Version 5 oder neuer."
35
+ "Magento","Magento"
36
+ "Unsupported Magento version. Please upgrade to version 1.6 or higher.","Nicht untersützte Magento-Version. Bitte upgraden Sie auf Version 1.6 oder neuer."
37
+ "OpenSSL","OpenSSL"
38
+ "OpenSSL not found. Please install OpenSSL on this server.","OpenSSL nicht gefunden. Bitte installieren Sie OpenSSL auf diesem Server."
39
+ "Download Method","Downloadmethode"
40
+ "No supported download method was found. Please enable allow_url_fopen in php.ini or install cURL on this server.","Eine nicht unterstützte Downloadmethode wurde gefunden. Bitte aktivieren Sie allow_url_fopen in php.ini oder installieren Sie cURL auf diesem Server."
41
+ "Using %s","%s wird verwendet"
42
+ "Extension Files","Erweiterungsdateien"
43
+ "File","Datei"
44
+ "Directory","Verzeichnis"
45
+ "File is not writable: %s<br>Please update the file permissions.","Datei kann nicht geschrieben werden: %s<br>Bitte ändern Sie Dateiberechtigungen."
46
+ "Directory is not writable: %s<br>Please update the file permissions.","Verzeichnis kann nicht geschrieben werden: %s<br>Bitte ändern Sie Dateiberechtigungen."
47
+ "File is missing: %s<br>Please upload the file or reinstall this extension using Magento Connect Manager.","Datei fehlt: %s<br>Bitte laden Sie die Datei hoch oder installieren Sie diese Erweiterung erneut mit dem Magento Connect Manager."
48
+ "Extension is installed","Erweiterung wurde installiert."
app/locale/en_US/Webinterpret_Connector.csv CHANGED
@@ -1,48 +1 @@
1
- "Webinterpret","Webinterpret"
2
- "Settings","Settings"
3
- "Enabled","Enabled"
4
- "Turn integration with Webinterpret ON or OFF.","Turn integration with Webinterpret ON or OFF."
5
- "Webinterpret Key","Webinterpret Key"
6
- "Unique key for your store. If you don't have one then register at Webinterpret.com to get a new key.","Unique key for your store. If you don't have one then register at Webinterpret.com to get a new key."
7
- "Country Selector","Country Selector"
8
- "Link to your international stores in the footer. Links appear after your products have been translated.","Link to your international stores in the footer. Links appear after your products have been translated."
9
- "Country Redirector Popup","Country Redirector Popup"
10
- "Redirect international visitors (using geolocation) via popup to translated product pages.","Redirect international visitors (using geolocation) via popup to translated product pages."
11
- "Automatic Software Updates","Automatic Software Updates"
12
- "Allow this extension to automatically update its software with new features and improvements.","Allow this extension to automatically update its software with new features and improvements."
13
- "Admin Panel Notifications","Admin Panel Notifications"
14
- "Display notifications in Admin Panel to help you keep track of what's new or if something has changed.","Display notifications in Admin Panel to help you keep track of what's new or if something has changed."
15
- "Status","Status"
16
- "To continue installing Webinterpret, <a href=""%s"">click here</a>","To continue installing Webinterpret, <a href=""%s"">click here</a>"
17
- "Webinterpret extension has stopped working. For more details, <a href=""%s"">click here</a>","Webinterpret extension has stopped working. For more details, <a href=""%s"">click here</a>"
18
- "Webinterpret Key is not correct. Please try again.","Webinterpret Key is not correct. Please try again."
19
- "Failed to download file: %s<br>Please contact Webinterpret support.","Failed to download file: %s<br>Please contact Webinterpret support."
20
- "Failed to write file: %s<br>Please update the file permissions and try again.","Failed to write file: %s<br>Please update the file permissions and try again."
21
- "Failed to read file: %s<br>Please update the file permissions and try again.","Failed to read file: %s<br>Please update the file permissions and try again."
22
- "Webinterpret Key","Webinterpret Key"
23
- "Key is valid","Key is valid"
24
- "Key is missing. Please enter your Webinterpret Key. If you do not have one then <a href=""https://webstores.webinterpret.com"" target=""_blank"">click here to register</a>","Key is missing. Please enter your Webinterpret Key. If you do not have one then <a href=""https://webstores.webinterpret.com"" target=""_blank"">click here to register</a>"
25
- "Incorrect key. Please try entering your key again or <a href=""https://webstores.webinterpret.com"" target=""_blank"">get a new key</a>","Incorrect key. Please try entering your key again or <a href=""https://webstores.webinterpret.com"" target=""_blank"">get a new key</a>"
26
- "Integration","Integration"
27
- "Extension is ON","Extension is ON"
28
- "Integration is turned OFF. Please set ""Enabled"" field to ""Yes"" and click the ""Save Config"" button.","Integration is turned OFF. Please set ""Enabled"" field to ""Yes"" and click the ""Save Config"" button."
29
- "Bridge Files","Bridge Files"
30
- "Bridge is installed","Bridge is installed"
31
- "Bridge is not installed. Please click ""Save Config"" button to install it.","Bridge is not installed. Please click ""Save Config"" button to install it."
32
- "Bridge is not installed. Please set ""Enabled"" field to ""Yes"" and click the ""Save Config"" button.","Bridge is not installed. Please set ""Enabled"" field to ""Yes"" and click the ""Save Config"" button."
33
- "PHP","PHP"
34
- "Unsupported PHP version. Please upgrade to version 5 or higher.","Unsupported PHP version. Please upgrade to version 5 or higher."
35
- "Magento","Magento"
36
- "Unsupported Magento version. Please upgrade to version 1.6 or higher.","Unsupported Magento version. Please upgrade to version 1.6 or higher."
37
- "OpenSSL","OpenSSL"
38
- "OpenSSL not found. Please install OpenSSL on this server.","OpenSSL not found. Please install OpenSSL on this server."
39
- "Download Method","Download Method"
40
- "No supported download method was found. Please enable allow_url_fopen in php.ini or install cURL on this server.","No supported download method was found. Please enable allow_url_fopen in php.ini or install cURL on this server."
41
- "Using %s","Using %s"
42
- "Extension Files","Extension Files"
43
- "File","File"
44
- "Directory","Directory"
45
- "File is not writable: %s<br>Please update the file permissions.","File is not writable: %s<br>Please update the file permissions."
46
- "Directory is not writable: %s<br>Please update the file permissions.","Directory is not writable: %s<br>Please update the file permissions."
47
- "File is missing: %s<br>Please upload the file or reinstall this extension using Magento Connect Manager.","File is missing: %s<br>Please upload the file or reinstall this extension using Magento Connect Manager."
48
- "Extension is installed","Extension is installed"
1
+ "Webinterpret","Webinterpret"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/webinterpret/{wi-pi.css → webinterpret.css} RENAMED
@@ -1,3 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .wi-popupOpen {
2
  overflow: hidden;
3
  max-height: 100%;
@@ -177,3 +309,4 @@
177
  */
178
  100% {transform: translateY(2000px); opacity: 0;}
179
  }
 
1
+
2
+ #wi-cr {
3
+ visibility: hidden;
4
+ z-index: -9000;
5
+ position: fixed;
6
+ top: 0;
7
+ right: 0;
8
+ bottom: 0;
9
+ left: 0;
10
+ background: none;
11
+ background-color: rgba(0, 0, 0, 0)
12
+ transition: background-color 0.25s ease;
13
+ -moz-transition: background-color 0.25s ease;
14
+ -webkit-transition: background-color 0.25s ease;
15
+ }
16
+
17
+ #wi-cr.visible {
18
+ visibility: visible;
19
+ z-index: 9000;
20
+ background-color: rgba(0, 0, 0, 0.25);
21
+ }
22
+
23
+ #wi-cr-modal {
24
+ font-family: 'Open Sans', sans-serif;
25
+ color: #333;
26
+ opacity: 0;
27
+ top: 50%;
28
+ left: 50%;
29
+ position: fixed;
30
+ transform: translate(-50%, -50%);
31
+ -o-transform: translate(-50%, -50%);
32
+ -ms-transform: translate(-50%, -50%);
33
+ -moz-transform: translate(-50%, -50%);
34
+ -webkit-transform: translate(-50%, -50%);
35
+ border-radius: 2px;
36
+ background: white;
37
+ padding: 30px;
38
+ transition: opacity 0.25s ease;
39
+ -moz-transition: opacity 0.25s ease;
40
+ -webkit-transition: opacity 0.25s ease;
41
+ }
42
+
43
+ #wi-cr.visible #wi-cr-modal {
44
+ opacity: 1;
45
+ }
46
+
47
+ #wi-cr-flag {
48
+ width: 100px;
49
+ height: 100px;
50
+ border-radius: 100%;
51
+ margin: 15px auto;
52
+ display: block;
53
+ box-shadow: 0px 3px 4.7px 0.3px rgba(0, 0, 0, 0.24);
54
+ }
55
+
56
+ #wi-cr-title,#wi-cr-button {
57
+ font-weight: 600;
58
+ font-size: 18px;
59
+ }
60
+
61
+ #wi-cr-title,#wi-cr-text {
62
+ text-align: center;
63
+ margin: 0 0 15px;
64
+ }
65
+
66
+ #wi-cr-text {
67
+ font-weight: normal;
68
+ font-size: 16px;
69
+ }
70
+
71
+ #wi-cr-button {
72
+ background: #009ddf;
73
+ border: 0 none;
74
+ border-radius: 4px;
75
+ color: white;
76
+ box-shadow: 0px 3px 4.7px 0.3px rgba(0, 0, 0, 0.24);
77
+ display: block;
78
+ padding: 25px 70px;
79
+ line-height: 1.33333;
80
+ text-align: center;
81
+ text-decoration: none;
82
+ cursor: pointer;
83
+ vertical-align: middle;
84
+ touch-action: manipulation;
85
+ white-space: nowrap;
86
+ margin: 0 50px;
87
+ }
88
+
89
+ #wi-cr-close {
90
+ cursor: pointer;
91
+ position: absolute;
92
+ right: 0;
93
+ top: 0;
94
+ font-size: 24px;
95
+ line-height: 1;
96
+ width: 24px;
97
+ height: 24px;
98
+ text-align: center;
99
+ background: white;
100
+ padding: 13px;
101
+ border-radius: 100%;
102
+ margin: -25px -25px 0 0;
103
+ box-sizing: content-box;
104
+ box-shadow: 0px 3px 4.7px 0.3px rgba(0, 0, 0, 0.24);
105
+ }
106
+
107
+ #wi-cr.ie8 {
108
+ background:transparent;
109
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#40000000,endColorstr=#40000000);
110
+ zoom: 1;
111
+ }
112
+
113
+ .ie8 #wi-cr-close {
114
+ margin: 0 0 -25px -25px;
115
+ box-shadow: none;
116
+ border-radius: 0;
117
+ }
118
+
119
+ @media(max-width:767px) {
120
+ #wi-cr-close {
121
+ margin: 0 0 -25px -25px;
122
+ box-shadow: none;
123
+ border-radius: 0;
124
+ }
125
+
126
+ #wi-cr-button {
127
+ margin: 0;
128
+ }
129
+ }
130
+
131
+ /*********************************************************************/
132
+
133
  .wi-popupOpen {
134
  overflow: hidden;
135
  max-height: 100%;
309
  */
310
  100% {transform: translateY(2000px); opacity: 0;}
311
  }
312
+
js/webinterpret/webinterpret.js ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery.noConflict();
2
+ (function($) {
3
+ if (!$.Webinterpret) {
4
+ $.Webinterpret = new Object();
5
+ };
6
+
7
+ $.Webinterpret.RedirectModal = function(el, options) {
8
+ var base = this;
9
+ base.$el = $(el);
10
+ base.el = el;
11
+ base.$el.data('Webinterpret.RedirectModal', base);
12
+ base.visible = false;
13
+ base.visitor_locale = null;
14
+
15
+ // Current time
16
+ base.now = function() {
17
+ return (new Date()).getTime();
18
+ };
19
+
20
+ // Modal expiry
21
+ base.expires = function() {
22
+ return base.now() + base.options.expires;
23
+ };
24
+
25
+ // Track event
26
+ base.trackEvent = function(category, action, name, value) {
27
+ category = typeof category !== 'undefined' ? category : 'unknown';
28
+ action = typeof action !== 'undefined' ? action : 'unknown';
29
+ name = typeof name !== 'undefined' ? name : null;
30
+ value = typeof value !== 'undefined' ? value : null;
31
+
32
+ var data = {
33
+ 'category': category,
34
+ 'action': action,
35
+ 'name': name,
36
+ 'value': value,
37
+ 'store_locale': base.options.store_locale,
38
+ 'visitor_locale': base.visitor_locale
39
+ };
40
+
41
+ if (window._paq) {
42
+ _paq.push(['trackEvent', category, base.httpBuildQuery(data)]);
43
+ }
44
+ }
45
+
46
+ base.httpBuildQuery = function(formdata, numeric_prefix, arg_separator) {
47
+ var value, key, tmp = [],
48
+ that = this;
49
+
50
+ var _http_build_query_helper = function(key, val, arg_separator) {
51
+ var k, tmp = [];
52
+ if (val === true) {
53
+ val = '1';
54
+ } else if (val === false) {
55
+ val = '0';
56
+ }
57
+ if (val != null) {
58
+ if (typeof val === 'object') {
59
+ for (k in val) {
60
+ if (val[k] != null) {
61
+ tmp.push(_http_build_query_helper(key + '[' + k + ']', val[k], arg_separator));
62
+ }
63
+ }
64
+ return tmp.join(arg_separator);
65
+ } else if (typeof val !== 'function') {
66
+ return that.urlEncode(key) + '=' + that.urlEncode(val);
67
+ } else {
68
+ throw new Error('There was an error processing for http_build_query().');
69
+ }
70
+ } else {
71
+ return '';
72
+ }
73
+ };
74
+
75
+ if (!arg_separator) {
76
+ arg_separator = '&';
77
+ }
78
+ for (key in formdata) {
79
+ value = formdata[key];
80
+ if (numeric_prefix && !isNaN(key)) {
81
+ key = String(numeric_prefix) + key;
82
+ }
83
+ var query = _http_build_query_helper(key, value, arg_separator);
84
+ if (query !== '') {
85
+ tmp.push(query);
86
+ }
87
+ }
88
+
89
+ return tmp.join(arg_separator);
90
+ }
91
+
92
+ // URL encode string
93
+ base.urlEncode = function(str) {
94
+ str = (str + '').toString();
95
+ return encodeURIComponent(str)
96
+ .replace(/!/g, '%21')
97
+ .replace(/'/g, '%27')
98
+ .replace(/\(/g, '%28')
99
+ .replace(/\)/g, '%29')
100
+ .replace(/\*/g, '%2A')
101
+ .replace(/%20/g, '+');
102
+ }
103
+
104
+ // Test if user has closed modal
105
+ base.isHidden = function() {
106
+ return (parseInt(localStorage.getItem('webinterpret-redirect-hide')) > base.now());
107
+ }
108
+
109
+ // Parse visitor locale from request
110
+ base.parseVisitorLocale = function(data) {
111
+ if (!data.hasOwnProperty('url')) {
112
+ return null;
113
+ }
114
+ if (data.url.indexOf('glopal.at') > -1) {
115
+ return 'de_AT';
116
+ }
117
+ if (data.url.indexOf('glopal.be') > -1) {
118
+ return 'fr_BE';
119
+ }
120
+ if (data.url.indexOf('glopal.ca') > -1) {
121
+ return 'en_CA';
122
+ }
123
+ if (data.url.indexOf('glopal.co.uk') > -1) {
124
+ return 'en_GB';
125
+ }
126
+ if (data.url.indexOf('glopal.com') > -1) {
127
+ return 'en_US';
128
+ }
129
+ if (data.url.indexOf('glopal.com.au') > -1) {
130
+ return 'en_AU';
131
+ }
132
+ if (data.url.indexOf('glopal.de') > -1) {
133
+ return 'de_DE';
134
+ }
135
+ if (data.url.indexOf('glopal.es') > -1) {
136
+ return 'es_ES';
137
+ }
138
+ if (data.url.indexOf('glopal.eu') > -1) {
139
+ return 'en_IE';
140
+ }
141
+ if (data.url.indexOf('glopal.fr') > -1) {
142
+ return 'fr_FR';
143
+ }
144
+ if (data.url.indexOf('glopal.it') > -1) {
145
+ return 'it_IT';
146
+ }
147
+ return null;
148
+ }
149
+
150
+ // Fill modal with content
151
+ base.fill = function(data) {
152
+ data.flag = data.flag.replace('/media/webinterpret', '/js/webinterpret');
153
+ $('#wi-cr-flag').attr('src', data.flag);
154
+ $('#wi-cr-title').text(data.title);
155
+ $('#wi-cr-text').text(data.text);
156
+ if (base.options.utm) {
157
+ data.url = String(data.url) + '?' + base.options.utm;
158
+ }
159
+ $('#wi-cr-button').text(data.button).attr('href', data.url);
160
+ };
161
+
162
+ // Display or hide modal
163
+ base.display = function(state) {
164
+ if (state === true) {
165
+ base.trackEvent('redirect', 'show', 'show_modal');
166
+ }
167
+ var wi_cr = $("#wi-cr").toggleClass('visible', base.visible = !!state);
168
+ if (wi_cr.is('.ie8')) {
169
+ var timeout;
170
+ function update_position() {
171
+ var modal = $('#wi-cr-modal');
172
+ modal.css('top', (wi_cr.height() - modal.outerHeight()) / 2) + 'px !important';
173
+ modal.css('left', (wi_cr.width() - modal.outerWidth()) / 2) + 'px !important';
174
+ }
175
+ update_position();
176
+ $(window).resize(function(){
177
+ clearTimeout(timeout);
178
+ timeout = setTimeout(update_position, 500);
179
+ });
180
+ }
181
+ };
182
+
183
+ // Initalize modal
184
+ base.init = function() {
185
+ try {
186
+ base.options = $.extend({},$.Webinterpret.RedirectModal.defaultOptions, options);
187
+
188
+ if (base.isHidden()) {
189
+ base.trackEvent('redirect', 'hidden', 'modal_is_hidden');
190
+ return;
191
+ }
192
+
193
+ // Click on close button
194
+ $('#wi-cr-close').click(function() {
195
+ base.display(false);
196
+ localStorage.setItem('webinterpret-redirect-hide', base.expires().toString());
197
+ base.trackEvent('redirect', 'click', 'close_modal_button');
198
+ });
199
+
200
+ // Click on page background
201
+ if (base.options.closeOnPageBackgroundClick) {
202
+ $('#wi-cr').click(function(e) {
203
+ if (e.target != this) {
204
+ return;
205
+ }
206
+ localStorage.setItem('webinterpret-redirect-hide', base.expires().toString());
207
+ base.display(false);
208
+ base.trackEvent('redirect', 'click', 'close_page_background');
209
+ });
210
+ }
211
+
212
+ // Click on OK button
213
+ $('#wi-cr-button').click(function(e) {
214
+ if (e.target != this) {
215
+ return;
216
+ }
217
+ e.preventDefault();
218
+ base.display(false);
219
+ base.trackEvent('redirect', 'click', 'open');
220
+ window.location = $('#wi-cr-button').attr('href');
221
+ });
222
+
223
+ // Get modal content based on product and geolocation
224
+ $.ajax({
225
+ url: base.options.url,
226
+ dataType: 'json',
227
+ jsonp: 'callback',
228
+ success: function(data) {
229
+ if (!data || (typeof data != 'object')) {
230
+ base.trackEvent('redirect', 'error', 'data_not_found');
231
+ return;
232
+ }
233
+ if (data.hasOwnProperty('status') && data.status == 'error') {
234
+ if (data.hasOwnProperty('errors') && (data.errors.constructor === Array)) {
235
+ if (data.errors.length > 0 && data.errors[0].hasOwnProperty('name')) {
236
+ var errorCode = data.errors[0].name.toLowerCase();
237
+ switch (errorCode) {
238
+ case 'notsupportedcountry':
239
+ var countryCode = 'N/A';
240
+ if (data.errors[0].hasOwnProperty('description')) {
241
+ countryCode = data.errors[0].description.substring(0, 2).toLowerCase();
242
+ }
243
+ base.trackEvent('redirect', 'error', 'visitor_locale_not_supported_' + countryCode);
244
+ break;
245
+ case 'store_url':
246
+ base.trackEvent('redirect', 'error', 'store_url_not_found');
247
+ break;
248
+ case 'availability':
249
+ base.trackEvent('redirect', 'error', 'product_not_available');
250
+ break;
251
+ default:
252
+ base.trackEvent('redirect', 'error', 'error_' + errorCode);
253
+ }
254
+ return;
255
+ }
256
+ }
257
+ base.trackEvent('redirect', 'error', 'no_error_code_found');
258
+ return;
259
+ }
260
+ if (!data.hasOwnProperty('available')) {
261
+ base.trackEvent('redirect', 'error', 'availability_status_not_found');
262
+ return;
263
+ }
264
+
265
+ try {
266
+ base.visitor_locale = base.parseVisitorLocale(data);
267
+ base.fill(data);
268
+ base.display(true);
269
+ } catch (err) {
270
+ base.trackEvent('redirect', 'error', 'show_modal_failed');
271
+ }
272
+ },
273
+ error: function (jqXHR, textStatus, errorThrown) {
274
+ base.trackEvent('redirect', 'error', 'ajax_error_' + textStatus);
275
+ }
276
+ });
277
+ } catch (err) {
278
+ base.trackEvent('redirect', 'error', 'init_modal_failed');
279
+ }
280
+ };
281
+
282
+ base.init();
283
+ };
284
+
285
+ $.Webinterpret.RedirectModal.defaultOptions = {
286
+ url : null,
287
+ utm : null,
288
+ store_locale : null,
289
+ expires : 3600,
290
+ closeOnPageBackgroundClick : false
291
+ };
292
+
293
+ $.fn.webinterpret_RedirectModal = function(options) {
294
+ return this.each(function(){
295
+ (new $.Webinterpret.RedirectModal(this, options));
296
+ });
297
+ };
298
+
299
+ })(jQuery);
js/webinterpret/wi-cr.css DELETED
@@ -1,128 +0,0 @@
1
- #wi-cr {
2
- visibility: hidden;
3
- z-index: -9000;
4
- position: fixed;
5
- top: 0;
6
- right: 0;
7
- bottom: 0;
8
- left: 0;
9
- background: none;
10
- background-color: rgba(0, 0, 0, 0)
11
- transition: background-color 0.25s ease;
12
- -moz-transition: background-color 0.25s ease;
13
- -webkit-transition: background-color 0.25s ease;
14
- }
15
-
16
- #wi-cr.visible {
17
- visibility: visible;
18
- z-index: 9000;
19
- background-color: rgba(0, 0, 0, 0.25);
20
- }
21
-
22
- #wi-cr-modal {
23
- font-family: 'Open Sans', sans-serif;
24
- color: #333;
25
- opacity: 0;
26
- top: 50%;
27
- left: 50%;
28
- position: fixed;
29
- transform: translate(-50%, -50%);
30
- -o-transform: translate(-50%, -50%);
31
- -ms-transform: translate(-50%, -50%);
32
- -moz-transform: translate(-50%, -50%);
33
- -webkit-transform: translate(-50%, -50%);
34
- border-radius: 2px;
35
- background: white;
36
- padding: 30px;
37
- transition: opacity 0.25s ease;
38
- -moz-transition: opacity 0.25s ease;
39
- -webkit-transition: opacity 0.25s ease;
40
- }
41
-
42
- #wi-cr.visible #wi-cr-modal {
43
- opacity: 1;
44
- }
45
-
46
- #wi-cr-flag {
47
- width: 100px;
48
- height: 100px;
49
- border-radius: 100%;
50
- margin: 15px auto;
51
- display: block;
52
- box-shadow: 0px 3px 4.7px 0.3px rgba(0, 0, 0, 0.24);
53
- }
54
-
55
- #wi-cr-title,#wi-cr-button {
56
- font-weight: 600;
57
- font-size: 18px;
58
- }
59
-
60
- #wi-cr-title,#wi-cr-text {
61
- text-align: center;
62
- margin: 0 0 15px;
63
- }
64
-
65
- #wi-cr-text {
66
- font-weight: normal;
67
- font-size: 16px;
68
- }
69
-
70
- #wi-cr-button {
71
- background: #009ddf;
72
- border: 0 none;
73
- border-radius: 4px;
74
- color: white;
75
- box-shadow: 0px 3px 4.7px 0.3px rgba(0, 0, 0, 0.24);
76
- display: block;
77
- padding: 25px 70px;
78
- line-height: 1.33333;
79
- text-align: center;
80
- text-decoration: none;
81
- cursor: pointer;
82
- vertical-align: middle;
83
- touch-action: manipulation;
84
- white-space: nowrap;
85
- margin: 0 50px;
86
- }
87
-
88
- #wi-cr-close {
89
- cursor: pointer;
90
- position: absolute;
91
- right: 0;
92
- top: 0;
93
- font-size: 24px;
94
- line-height: 1;
95
- width: 24px;
96
- height: 24px;
97
- text-align: center;
98
- background: white;
99
- padding: 13px;
100
- border-radius: 100%;
101
- margin: -25px -25px 0 0;
102
- box-sizing: content-box;
103
- box-shadow: 0px 3px 4.7px 0.3px rgba(0, 0, 0, 0.24);
104
- }
105
-
106
- #wi-cr.ie8 {
107
- background:transparent;
108
- filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#40000000,endColorstr=#40000000);
109
- zoom: 1;
110
- }
111
-
112
- .ie8 #wi-cr-close {
113
- margin: 0 0 -25px -25px;
114
- box-shadow: none;
115
- border-radius: 0;
116
- }
117
-
118
- @media(max-width:767px) {
119
- #wi-cr-close {
120
- margin: 0 0 -25px -25px;
121
- box-shadow: none;
122
- border-radius: 0;
123
- }
124
-
125
- #wi-cr-button {
126
- margin: 0;
127
- }
128
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/webinterpret/wi-cr.js DELETED
@@ -1,81 +0,0 @@
1
- (function($) {
2
- if (!$) {
3
- window.wi_cr = null;
4
- return;
5
- }
6
-
7
- window.wi_cr = this;
8
- this.visible = false;
9
- this.utm = '';
10
-
11
- this.fill = function(data) {
12
- $("#wi-cr-flag").attr('src', data.flag);
13
- $("#wi-cr-title").text(data.title);
14
- $("#wi-cr-text").text(data.text);
15
- $("#wi-cr-button").text(data.button).attr('href', data.url);
16
- };
17
-
18
- this.display = function(state) {
19
- var wi_cr = $("#wi-cr").toggleClass('visible', this.visible = !!state);
20
-
21
- if (wi_cr.is('.ie8')) {
22
- var timeout;
23
- function update_position() {
24
- var modal = $('#wi-cr-modal');
25
- modal.css('top', (wi_cr.height() - modal.outerHeight()) / 2) + 'px !important';
26
- modal.css('left', (wi_cr.width() - modal.outerWidth()) / 2) + 'px !important';
27
- }
28
- update_position();
29
- $(window).resize(function(){
30
- clearTimeout(timeout);
31
- timeout = setTimeout(update_position, 500);
32
- });
33
- }
34
- };
35
-
36
- this.now = function() {
37
- return (new Date()).getTime();
38
- };
39
-
40
- this.expires = function() {
41
- return this.now() + (30 * 24 * 60 * 60 * 1000);
42
- };
43
-
44
- var that = this;
45
-
46
- $("#wi-cr-close").click(function() {
47
- that.display(false);
48
- localStorage.setItem('wi-cr-hidden', that.expires().toString());
49
- });
50
-
51
- $("#wi-cr").click(function(e) {
52
- if (e.target != this )
53
- return;
54
- localStorage.setItem('wi-cr-hidden', that.expires().toString());
55
- that.display(false);
56
- });
57
-
58
- $("#wi-cr-button").click(function(e) {
59
- if (e.target != this )
60
- return;
61
- that.display(false);
62
- });
63
-
64
- this.redirect = function(url, utm) {
65
- that.utm = utm;
66
- if (parseInt(localStorage.getItem('wi-cr-hidden')) > this.now())
67
- return;
68
- $.ajax({
69
- 'url': url,
70
- 'dataType': 'json',
71
- 'jsonp': 'callback',
72
- 'success': function(data) {
73
- if (!data || !data.available)
74
- return;
75
- data.url = String(data.url) + '?' + that.utm;
76
- that.fill(data);
77
- that.display(true);
78
- },
79
- });
80
- };
81
- })(window.jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/webinterpret/wi-pi.js DELETED
@@ -1,127 +0,0 @@
1
- (function($) {
2
- if (!$) {
3
- window.wi_pi = null;
4
- throw new Error("WI: Failed to detect jQuery");
5
- }
6
-
7
- window.wi_pi = this;
8
- that = this;
9
-
10
- this.fill = function(data) {
11
- $("#wi-flag img").attr('src', data.flag);
12
- $("#wi-pi-link").text(data.text.link);
13
- $("#wi-pi-link-mobile").text(data.text.link_mobile);
14
- $("#wi-pi-link-description").text(data.text.link_description);
15
- $("#wi-pi-hide").text(data.text.hide);
16
- $("#wi-pi-hide-mobile").text(data.text.hide_mobile);
17
- };
18
-
19
- this.now = function() {
20
- return (new Date()).getTime();
21
- };
22
-
23
- this.expires = function() {
24
- return this.now() + (30 * 24 * 60 * 60 * 1000);
25
- };
26
-
27
- this.is_permahidden = function() {
28
- return parseInt(localStorage.getItem('wi-pi-hidden')) > this.now();
29
- };
30
-
31
- this.permahide = function(e) {
32
- localStorage.setItem('wi-pi-hidden', this.expires().toString());
33
- };
34
-
35
- //this.visible = this.is_permahidden() || false;
36
- this.visible = true;
37
- this.utm = '';
38
- this.origin = '';
39
-
40
- this.receiveMessage = function(e) {
41
- var origin = e.origin || e.originalEvent.origin;
42
-
43
- // if (origin !== that.origin)
44
- // return;
45
-
46
- var data = e.data || e.originalEvent.data;
47
-
48
- if (data.indexOf('redirect:') == 0)
49
- window.top.location = data.substr(9);
50
- else if(data == 'close')
51
- that.display(false);
52
- };
53
-
54
- this.onResponse = function(data) {
55
- if (!(data && data.available && data.origin && data.url))
56
- return;
57
-
58
- if (window.location.protocol == 'http:') {
59
- data.url = data.url.replace('https:', 'http:');
60
- }
61
-
62
- that.url = String(data.url) + '?' + that.utm;
63
- that.fill(data);
64
-
65
- $(window).off('message').on('message', that.receiveMessage);
66
-
67
- $('#wi-hideGlopal').off('click').click(function(e) {
68
- that.permahide();
69
- that.visible = false;
70
- that.showOverlay(false);
71
- that.showBar(false);
72
- });
73
-
74
- $('#wi-showProduct').off('click').click(function(e) {
75
- that.display(true);
76
- });
77
-
78
- $('#wi-overlay').removeClass('hidden');
79
- $('#wi-fixedBar').removeClass('hidden');
80
-
81
- that.display(that.visible);
82
- }
83
-
84
- this.showOverlay = function(url) {
85
- var state = this.visible = !!url,
86
- overlay = $('#wi-overlay').toggleClass('visible', state);
87
- $('body').toggleClass('wi-popupOpen', state);
88
-
89
- if (this.iframe)
90
- this.iframe.remove();
91
-
92
- this.iframe = url ? $('<iframe>', {
93
- src: url,
94
- id: 'wi-frame',
95
- frameborder: 0,
96
- allowtransparency: true,
97
- }).appendTo(overlay) : undefined;
98
-
99
- return overlay;
100
- };
101
-
102
- this.showBar = function(state) {
103
- $('#wi-fixedBar').toggleClass('visible', state);
104
- };
105
-
106
- this.popup = function(url, utm) {
107
- if (!url)
108
- throw new Error("WI: no api url provided");
109
-
110
- if (this.is_permahidden())
111
- return;
112
-
113
- this.utm = utm;
114
- $.ajax({
115
- 'url': url,
116
- 'dataType': 'json',
117
- 'jsonp': 'callback',
118
- 'success': this.onResponse,
119
- });
120
- };
121
-
122
- this.display = function(state) {
123
- this.visible = !!state;
124
- this.showOverlay(this.visible ? this.url : null);
125
- this.showBar(!state);
126
- }
127
- })(window.jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,22 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Webinterpret_Connector</name>
4
- <version>1.2.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Integrate Magento with Webinterpret.</summary>
10
  <description>Translate and market your products internationally with Webinterpret. This is the official Magento extension for integrating with Webinterpret.</description>
11
- <notes>- Added country selector feature&#xD;
12
- - Added country redirector popup feature&#xD;
13
- - Added admin notification feature&#xD;
14
- - Added installation status to configuration section&#xD;
15
- - Improved data security using digital signatures</notes>
16
  <authors><author><name>Webinterpret</name><user>webinterpret</user><email>info@webinterpret.com</email></author></authors>
17
- <date>2016-03-07</date>
18
- <time>01:48:48</time>
19
- <contents><target name="magecommunity"><dir name="Webinterpret"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="5e1935e32f1b5d10f0b76fee427a23a6"/><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Status.php" hash="99b95c7991e91a4d4d98efdaf8007b88"/></dir></dir></dir></dir><file name="Analytics.php" hash="4a1d28d7b4c1bdd3910b00100df34334"/><file name="Footer.php" hash="ba32851bb2001e7c4bda98647f270d5a"/><file name="Head.php" hash="1261ad40df9f0dc708178d78d63158d8"/><dir name="Product"><file name="Redirect.php" hash="3cfdb35bb55ff671e00a00dc55c7224d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="85bd7feb7c60695ff02c3a2b46f20af8"/></dir><dir name="Model"><file name="Notification.php" hash="c07217955b49cec14a78df14bedd919b"/><file name="Observer.php" hash="7d037662b540cdce42843b7e2b95b663"/></dir><dir name="bridge2cart"><file name="bridge.php" hash="b62f79681638ae6f7425c9e1f472b4fb"/><file name="config.php" hash="153d0a81abccc30f053aff442961f09e"/><file name="helper.php" hash="9a1d04c7a2df2425907b9c622cd74a45"/><file name="preloader.php" hash="2cb01bd6da51c350bc51daedb4d76e69"/></dir><dir name="controllers"><file name="ApiController.php" hash="8992304485021375a3af10f5e61da6e8"/><file name="HelperController.php" hash="97230b101dcb07439a26bd287c2c359c"/><file name="IndexController.php" hash="e9e0d304539657969bfce8c2b33451a6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="07e287503c40ce7c588efe7863c05002"/><file name="config.xml" hash="c97bf45a65a5db34d86a01c7350d99a8"/><file name="system.xml" hash="bf5b3ce4c9c50aa5a4fe08900b80e782"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webinterpret_Connector.xml" hash="087c2742f6bcb89ed6a77921e6493feb"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="webinterpret"><file name="connector.xml" hash="8a7ccb15ac57e7042f3e195664c8a1b5"/></dir></dir><dir name="template"><dir name="webinterpret"><dir name="connector"><file name="analytics.phtml" hash="c46ca2f6c420c5f3c26889cd97debe99"/><file name="footer.phtml" hash="271951d77602462872c325108863b9ca"/><file name="head.phtml" hash="107312871a7b2730532db8d986de5726"/><file name="product_redirect.phtml" hash="8e91e9513f430f4d751b8cd30b35bb2b"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="webinterpret"><dir name="system"><dir name="config"><file name="activate.phtml" hash="5ef389ad58cb1be9cc666fecd8379fbf"/><dir name="fieldset"><file name="banner.phtml" hash="921b677bd3e52d9c86172bdf26ab4a37"/><file name="status.phtml" hash="658ad2722ec5678a031b2141a45d32c0"/><file name="status.phtml.bak" hash="bdfa2e7b4ca251f9404b40d158cd2bdb"/></dir></dir></dir></dir></dir><dir name="layout"><dir name="webinterpret"><file name="connector.xml" hash="867fafe49fa978668f6e5d7027c57aa6"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="webinterpret"><dir name="flags"><file name="flag-at.png" hash="4b25c35462292c96ed63cdec1bf2a620"/><file name="flag-au.png" hash="257d4975ff4116933fefa2203246bdac"/><file name="flag-be.png" hash="6019f3255488f9ad20a94297cb727cd1"/><file name="flag-de.png" hash="f9cd1fdeec5f4324293d1a2b78ec0d4a"/><file name="flag-es.png" hash="3093c6e1acb830ee36aacf6a05792f87"/><file name="flag-fr.png" hash="b7439e4d985f157e8918a4d185abb6b1"/><file name="flag-ie.png" hash="b3532a63fa08d0f1681f73a444482199"/><file name="flag-it.png" hash="53270fd8fd0f626c839f7f260b630d48"/><file name="flag-uk.png" hash="25348c2592f135d83ba48ac2d9fc47fe"/><file name="flag-us.png" hash="99e4ef1110c6aeb4407ddbedb6bba8e7"/></dir><file name="wi-cr.css" hash="87513f167c0e8ccc88bc60158b6bcf51"/><file name="wi-cr.js" hash="b6ad4819153096633f6fb9908aaeb41d"/><file name="wi-pi.css" hash="af9fdebd5584df82a751d76b1e771b7e"/><file name="wi-pi.js" hash="47e736989808eae966c75200d4172a1e"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Webinterpret_Connector.csv" hash="27dd99917620a58ff665823d809b7565"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Webinterpret_Connector</name>
4
+ <version>1.2.7.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Integrate Magento with Webinterpret.</summary>
10
  <description>Translate and market your products internationally with Webinterpret. This is the official Magento extension for integrating with Webinterpret.</description>
11
+ <notes>- Added auto-update functionality&#xD;
12
+ - Fixed bug with country redirect popup&#xD;
13
+ - Fixed HTTP =&gt; HTTPS redirect bug&#xD;
14
+ - Added German translations</notes>
 
15
  <authors><author><name>Webinterpret</name><user>webinterpret</user><email>info@webinterpret.com</email></author></authors>
16
+ <date>2016-03-24</date>
17
+ <time>17:36:20</time>
18
+ <contents><target name="magecommunity"><dir name="Webinterpret"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="5e1935e32f1b5d10f0b76fee427a23a6"/><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Status.php" hash="99b95c7991e91a4d4d98efdaf8007b88"/></dir></dir></dir></dir><file name="Analytics.php" hash="4a1d28d7b4c1bdd3910b00100df34334"/><file name="Footer.php" hash="ba32851bb2001e7c4bda98647f270d5a"/><file name="Head.php" hash="1261ad40df9f0dc708178d78d63158d8"/><dir name="Product"><file name="Redirect.php" hash="95125c9c86725f37d3eeb4a348197225"/></dir></dir><dir name="Helper"><file name="Data.php" hash="fe067ae2addaa1e208366ebd5146a25c"/></dir><dir name="Model"><file name="Notification.php" hash="c07217955b49cec14a78df14bedd919b"/><file name="Observer.php" hash="7d037662b540cdce42843b7e2b95b663"/></dir><dir name="bridge2cart"><file name="bridge.php" hash="7ebb391c35533fba8de77cfa5f21f291"/><file name="config.php" hash="8dc216ae9f0ed8cff616cb2e547a66fd"/><file name="helper.php" hash="7560a3620a23a43bfe5b0916ad54623c"/><file name="preloader.php" hash="8a8ada3537394687defdc28d4b6077e8"/></dir><dir name="controllers"><file name="ApiController.php" hash="8992304485021375a3af10f5e61da6e8"/><file name="HelperController.php" hash="c3d5347a39df19b8618cfba5f6b46356"/><file name="IndexController.php" hash="e9e0d304539657969bfce8c2b33451a6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="07e287503c40ce7c588efe7863c05002"/><file name="config.xml" hash="cc72363e185e9777962372c05d9e68ee"/><file name="system.xml" hash="5ded04fa4ab1d12507a4aff2219fa54b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webinterpret_Connector.xml" hash="087c2742f6bcb89ed6a77921e6493feb"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="webinterpret"><file name="connector.xml" hash="9e07d874db123d6152aa0136d0c7e2c7"/></dir></dir><dir name="template"><dir name="webinterpret"><dir name="connector"><file name="analytics.phtml" hash="c46ca2f6c420c5f3c26889cd97debe99"/><file name="footer.phtml" hash="271951d77602462872c325108863b9ca"/><file name="head.phtml" hash="107312871a7b2730532db8d986de5726"/><file name="product_redirect.phtml" hash="9f397d8a4e0ba6fe0e17e5b3f0e68566"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="webinterpret"><dir name="system"><dir name="config"><file name="activate.phtml" hash="5ef389ad58cb1be9cc666fecd8379fbf"/><dir name="fieldset"><file name="banner.phtml" hash="921b677bd3e52d9c86172bdf26ab4a37"/><file name="status.phtml" hash="658ad2722ec5678a031b2141a45d32c0"/></dir></dir></dir></dir></dir><dir name="layout"><dir name="webinterpret"><file name="connector.xml" hash="867fafe49fa978668f6e5d7027c57aa6"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="webinterpret"><dir name="flags"><file name="flag-at.png" hash="4b25c35462292c96ed63cdec1bf2a620"/><file name="flag-au.png" hash="257d4975ff4116933fefa2203246bdac"/><file name="flag-be.png" hash="6019f3255488f9ad20a94297cb727cd1"/><file name="flag-de.png" hash="f9cd1fdeec5f4324293d1a2b78ec0d4a"/><file name="flag-es.png" hash="3093c6e1acb830ee36aacf6a05792f87"/><file name="flag-fr.png" hash="b7439e4d985f157e8918a4d185abb6b1"/><file name="flag-ie.png" hash="b3532a63fa08d0f1681f73a444482199"/><file name="flag-it.png" hash="53270fd8fd0f626c839f7f260b630d48"/><file name="flag-uk.png" hash="25348c2592f135d83ba48ac2d9fc47fe"/><file name="flag-us.png" hash="99e4ef1110c6aeb4407ddbedb6bba8e7"/></dir><file name="webinterpret.css" hash="c1d5c817a9ec0c085ce843258dd7ff62"/><file name="webinterpret.js" hash="07d50b3562c4f9f71fafbf1ec18e8ab2"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Webinterpret_Connector.csv" hash="832847bc730d22c330d17732d7c52915"/></dir><dir name="de_DE"><file name="Webinterpret_Connector.csv" hash="95709b4e8cb46d02bba504f7b69dd761"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php></required></dependencies>
21
  </package>