Webinterpret_Connector - Version 1.2.7.4

Version Notes

- Fixed bug related to bridge

Download this release

Release Info

Developer Webinterpret
Extension Webinterpret_Connector
Version 1.2.7.4
Comparing to
See all releases


Code changes from version 1.2.7.3 to 1.2.7.4

app/code/community/Webinterpret/Connector/bridge2cart/bridge.php CHANGED
@@ -1,3888 +1 @@
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
- ?>
1
+ <?php // THIS FILE SHOULD BE WRITEABLE BY THE WEB SERVER
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Webinterpret/Connector/bridge2cart/config.php CHANGED
@@ -1,44 +1 @@
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
-
1
+ <?php // THIS FILE SHOULD BE WRITEABLE BY THE WEB SERVER
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2.7.3';
60
  const PLATFORM_MAGENTO = 'magento';
61
  const PLATFORM_UNKNOWN = 'unknown';
62
  protected static $_storeBaseDir = null;
56
 
57
  class Webinterpret_Bridge2Cart_Helper
58
  {
59
+ const VERSION = '1.2.7.4';
60
  const PLATFORM_MAGENTO = 'magento';
61
  const PLATFORM_UNKNOWN = 'unknown';
62
  protected static $_storeBaseDir = null;
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.3</version>
12
  </Webinterpret_Connector>
13
  </modules>
14
  <global>
8
  <config>
9
  <modules>
10
  <Webinterpret_Connector>
11
+ <version>1.2.7.4</version>
12
  </Webinterpret_Connector>
13
  </modules>
14
  <global>
package.xml CHANGED
@@ -1,21 +1,19 @@
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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Webinterpret_Connector</name>
4
+ <version>1.2.7.4</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>- Fixed bug related to bridge&#xD;
12
+ </notes>
 
 
13
  <authors><author><name>Webinterpret</name><user>webinterpret</user><email>info@webinterpret.com</email></author></authors>
14
+ <date>2016-03-25</date>
15
+ <time>10:42:00</time>
16
+ <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="e5a5f652b9b3a52a6a62d62a37c2e730"/><file name="config.php" hash="e5a5f652b9b3a52a6a62d62a37c2e730"/><file name="helper.php" hash="43317ad4a5ee22b10dc147781320d08f"/><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="a9dcf2ba5f8999f14d2395ccbf7166d7"/><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>
17
  <compatible/>
18
  <dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php></required></dependencies>
19
  </package>