Version Notes
Localized checkout.
Download this release
Release Info
| Developer | Webinterpret |
| Extension | Webinterpret_Connector |
| Version | 1.4.0.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.6.0 to 1.4.0.0
- app/code/community/Webinterpret/Connector/Helper/Data.php +83 -0
- app/code/community/Webinterpret/Connector/Helper/Verifier.php +0 -2
- app/code/community/Webinterpret/Connector/bridge2cart/helper.php +999 -0
- app/code/community/Webinterpret/Connector/controllers/CartController.php +27 -0
- app/code/community/Webinterpret/Connector/controllers/HelperController.php +45 -0
- app/code/community/Webinterpret/Connector/etc/config.xml +1 -1
- package.xml +5 -5
app/code/community/Webinterpret/Connector/Helper/Data.php
CHANGED
|
@@ -24,6 +24,81 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 24 |
Mage::getConfig()->saveConfig('webinterpret_connector/installation_mode', 0);
|
| 25 |
}
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
public function getEnvConfig()
|
| 28 |
{
|
| 29 |
foreach (array(
|
|
@@ -299,6 +374,10 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 299 |
'type' => 'file',
|
| 300 |
'path' => 'app/code/community/Webinterpret/Connector/controllers/IndexController.php',
|
| 301 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
array(
|
| 303 |
'type' => 'file',
|
| 304 |
'path' => 'app/code/community/Webinterpret/Connector/Block/Adminhtml/Notifications.php',
|
|
@@ -331,6 +410,10 @@ class Webinterpret_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 331 |
'type' => 'file',
|
| 332 |
'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/config.php',
|
| 333 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
);
|
| 335 |
|
| 336 |
// Check file permissions
|
| 24 |
Mage::getConfig()->saveConfig('webinterpret_connector/installation_mode', 0);
|
| 25 |
}
|
| 26 |
|
| 27 |
+
public function installBridgeHelper()
|
| 28 |
+
{
|
| 29 |
+
$repo = Mage::getStoreConfig('webinterpret_connector/file_repository');
|
| 30 |
+
$dir = $this->getModuleBridgeDir();
|
| 31 |
+
|
| 32 |
+
// Install helper.php
|
| 33 |
+
$remoteFile = $repo . DS . 'bridge2cart' . DS . $this->getExtensionVersion() . DS . 'helper.php';
|
| 34 |
+
$contents = $this->downloadFile($remoteFile);
|
| 35 |
+
if ($contents === false) {
|
| 36 |
+
return false;
|
| 37 |
+
}
|
| 38 |
+
$localFile = $dir . DS . 'helper.php';
|
| 39 |
+
$contents = str_replace('exit();', '', $contents);
|
| 40 |
+
if (@file_put_contents($localFile, $contents) === false) {
|
| 41 |
+
return false;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
return true;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
public function downloadFile($url, $timeout = 10)
|
| 48 |
+
{
|
| 49 |
+
try {
|
| 50 |
+
$method = $this->getDownloadMethod();
|
| 51 |
+
|
| 52 |
+
if ($method == 'stream') {
|
| 53 |
+
$ctx = stream_context_create(array(
|
| 54 |
+
'http'=>
|
| 55 |
+
array(
|
| 56 |
+
'timeout' => $timeout,
|
| 57 |
+
),
|
| 58 |
+
'https'=>
|
| 59 |
+
array(
|
| 60 |
+
'timeout' => $timeout,
|
| 61 |
+
),
|
| 62 |
+
)
|
| 63 |
+
);
|
| 64 |
+
$contents = @file_get_contents($url, false, $ctx);
|
| 65 |
+
if ($contents !== false) {
|
| 66 |
+
return $contents;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
if ($method == 'curl') {
|
| 71 |
+
|
| 72 |
+
$ch = curl_init();
|
| 73 |
+
$headers = array(
|
| 74 |
+
"Accept: */*",
|
| 75 |
+
);
|
| 76 |
+
curl_setopt_array($ch, array(
|
| 77 |
+
CURLOPT_RETURNTRANSFER => 1,
|
| 78 |
+
CURLOPT_URL => $url,
|
| 79 |
+
CURLOPT_TIMEOUT => $timeout,
|
| 80 |
+
CURLOPT_FOLLOWLOCATION => true,
|
| 81 |
+
CURLOPT_ENCODING => '',
|
| 82 |
+
CURLOPT_HTTPHEADER => $headers,
|
| 83 |
+
));
|
| 84 |
+
|
| 85 |
+
$contents = curl_exec($ch);
|
| 86 |
+
|
| 87 |
+
if (curl_errno($ch)) {
|
| 88 |
+
curl_close($ch);
|
| 89 |
+
return false;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
curl_close($ch);
|
| 93 |
+
return $contents;
|
| 94 |
+
}
|
| 95 |
+
} catch (Exception $e) {
|
| 96 |
+
return false;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
return false;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
public function getEnvConfig()
|
| 103 |
{
|
| 104 |
foreach (array(
|
| 374 |
'type' => 'file',
|
| 375 |
'path' => 'app/code/community/Webinterpret/Connector/controllers/IndexController.php',
|
| 376 |
),
|
| 377 |
+
array(
|
| 378 |
+
'type' => 'file',
|
| 379 |
+
'path' => 'app/code/community/Webinterpret/Connector/controllers/HelperController.php',
|
| 380 |
+
),
|
| 381 |
array(
|
| 382 |
'type' => 'file',
|
| 383 |
'path' => 'app/code/community/Webinterpret/Connector/Block/Adminhtml/Notifications.php',
|
| 410 |
'type' => 'file',
|
| 411 |
'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/config.php',
|
| 412 |
),
|
| 413 |
+
array(
|
| 414 |
+
'type' => 'file',
|
| 415 |
+
'path' => 'app/code/community/Webinterpret/Connector/bridge2cart/helper.php',
|
| 416 |
+
),
|
| 417 |
);
|
| 418 |
|
| 419 |
// Check file permissions
|
app/code/community/Webinterpret/Connector/Helper/Verifier.php
CHANGED
|
@@ -3,8 +3,6 @@
|
|
| 3 |
use Webinterpret_Connector_Model_SignatureException as SignatureException;
|
| 4 |
|
| 5 |
/**
|
| 6 |
-
* Verifier helper
|
| 7 |
-
*
|
| 8 |
* @category Webinterpret
|
| 9 |
* @package Webinterpret_Connector
|
| 10 |
* @author Webinterpret Team <info@webinterpret.com>
|
| 3 |
use Webinterpret_Connector_Model_SignatureException as SignatureException;
|
| 4 |
|
| 5 |
/**
|
|
|
|
|
|
|
| 6 |
* @category Webinterpret
|
| 7 |
* @package Webinterpret_Connector
|
| 8 |
* @author Webinterpret Team <info@webinterpret.com>
|
app/code/community/Webinterpret/Connector/bridge2cart/helper.php
ADDED
|
@@ -0,0 +1,999 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Bridge helper
|
| 4 |
+
*
|
| 5 |
+
* @category Webinterpret
|
| 6 |
+
* @package Webinterpret_Connector
|
| 7 |
+
* @author Webinterpret Team <info@webinterpret.com>
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
if (!defined('DS')) {
|
| 12 |
+
define('DS', DIRECTORY_SEPARATOR);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
if (!function_exists('stripslashes_array')) {
|
| 16 |
+
function stripslashes_array($array) {
|
| 17 |
+
return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
if (!function_exists('lcfirst')) {
|
| 22 |
+
function lcfirst($str) {
|
| 23 |
+
$str[0] = strtolower($str[0]);
|
| 24 |
+
return (string)$str;
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
if (!isset($_SERVER)) {
|
| 29 |
+
$_GET = &$HTTP_GET_VARS;
|
| 30 |
+
$_POST = &$HTTP_POST_VARS;
|
| 31 |
+
$_ENV = &$HTTP_ENV_VARS;
|
| 32 |
+
$_SERVER = &$HTTP_SERVER_VARS;
|
| 33 |
+
$_COOKIE = &$HTTP_COOKIE_VARS;
|
| 34 |
+
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if (get_magic_quotes_gpc()) {
|
| 38 |
+
$_COOKIE = stripslashes_array($_COOKIE);
|
| 39 |
+
$_FILES = stripslashes_array($_FILES);
|
| 40 |
+
$_GET = stripslashes_array($_GET);
|
| 41 |
+
$_POST = stripslashes_array($_POST);
|
| 42 |
+
$_REQUEST = stripslashes_array($_REQUEST);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (!function_exists('getallheaders')) {
|
| 46 |
+
function getallheaders() {
|
| 47 |
+
$headers = '';
|
| 48 |
+
foreach ($_SERVER as $name => $value) {
|
| 49 |
+
if (substr($name, 0, 5) == 'HTTP_') {
|
| 50 |
+
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
return $headers;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
class Webinterpret_Bridge2Cart_Helper
|
| 58 |
+
{
|
| 59 |
+
const VERSION = '1.2.7.7';
|
| 60 |
+
const PLATFORM_MAGENTO = 'magento';
|
| 61 |
+
const PLATFORM_UNKNOWN = 'unknown';
|
| 62 |
+
protected static $_storeBaseDir = null;
|
| 63 |
+
|
| 64 |
+
public static function getVersion()
|
| 65 |
+
{
|
| 66 |
+
return self::VERSION;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
public static function getStoreBaseDir()
|
| 70 |
+
{
|
| 71 |
+
if (!is_null(self::$_storeBaseDir)) {
|
| 72 |
+
return self::$_storeBaseDir;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
$dir = '';
|
| 76 |
+
|
| 77 |
+
// Auto-detect Magento - Method: mod/_modules
|
| 78 |
+
$dir = realpath(dirname(__FILE__));
|
| 79 |
+
if (strpos($dir, 'mod/_modules') !== false) {
|
| 80 |
+
if (strpos($dir, 'httpdocs') !== false) {
|
| 81 |
+
$dir = substr($dir, 0, strpos($dir, 'httpdocs')) . 'httpdocs';
|
| 82 |
+
$filename = realpath($dir . DS . 'app' . DS . 'Mage.php');
|
| 83 |
+
if (file_exists($filename)) {
|
| 84 |
+
$dir = dirname(dirname($filename));
|
| 85 |
+
self::$_storeBaseDir = $dir;
|
| 86 |
+
return self::$_storeBaseDir;
|
| 87 |
+
}
|
| 88 |
+
$filename = realpath($dir . DS . 'pub' . DS . 'app' . DS . 'Mage.php');
|
| 89 |
+
if (file_exists($filename)) {
|
| 90 |
+
$dir = dirname(dirname($filename));
|
| 91 |
+
self::$_storeBaseDir = $dir;
|
| 92 |
+
return self::$_storeBaseDir;
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// Auto-detect Magento - Method: .modman
|
| 98 |
+
$dir = realpath(dirname(__FILE__));
|
| 99 |
+
if (strpos($dir, '.modman') !== false) {
|
| 100 |
+
$dir = realpath(substr($dir, 0, strpos($dir, '.modman')));
|
| 101 |
+
$filename = $dir . DS . 'app' . DS . 'Mage.php';
|
| 102 |
+
if (file_exists($filename)) {
|
| 103 |
+
$dir = dirname(dirname($filename));
|
| 104 |
+
self::$_storeBaseDir = $dir;
|
| 105 |
+
return self::$_storeBaseDir;
|
| 106 |
+
}
|
| 107 |
+
$filename = $dir . DS . 'shop' . DS . 'app' . DS . 'Mage.php';
|
| 108 |
+
if (file_exists($filename)) {
|
| 109 |
+
$dir = dirname(dirname($filename));
|
| 110 |
+
self::$_storeBaseDir = $dir;
|
| 111 |
+
return self::$_storeBaseDir;
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
// Auto-detect Magento - Method: vendor
|
| 116 |
+
$dir = realpath(dirname(__FILE__));
|
| 117 |
+
if (strpos($dir, 'vendor') !== false) {
|
| 118 |
+
$dir = realpath(substr($dir, 0, strpos($dir, 'vendor')));
|
| 119 |
+
$filename = $dir . DS . 'app' . DS . 'Mage.php';
|
| 120 |
+
if (file_exists($filename)) {
|
| 121 |
+
$dir = dirname(dirname($filename));
|
| 122 |
+
self::$_storeBaseDir = $dir;
|
| 123 |
+
return self::$_storeBaseDir;
|
| 124 |
+
}
|
| 125 |
+
$filename = $dir . DS . 'htdocs' . DS . 'app' . DS . 'Mage.php';
|
| 126 |
+
if (file_exists($filename)) {
|
| 127 |
+
$dir = dirname(dirname($filename));
|
| 128 |
+
self::$_storeBaseDir = $dir;
|
| 129 |
+
return self::$_storeBaseDir;
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
// Auto-detect Magento - Method: default
|
| 134 |
+
// app/code/community/Webinterpret/Connector/bridge2cart
|
| 135 |
+
$dir = realpath(dirname(__FILE__) . DS . '..' . DS . '..' . DS . '..' . DS . '..' . DS . '..' . DS . '..');
|
| 136 |
+
$filename = $dir . DS . 'app' . DS . 'Mage.php';
|
| 137 |
+
if (file_exists($filename)) {
|
| 138 |
+
self::$_storeBaseDir = $dir;
|
| 139 |
+
return self::$_storeBaseDir;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
$iterator = new RecursiveDirectoryIterator($_SERVER['DOCUMENT_ROOT']);
|
| 143 |
+
foreach (new RecursiveIteratorIterator($iterator) as $file) {
|
| 144 |
+
if ($file->isFile() && $file->getFilename() == 'Mage.php' &&
|
| 145 |
+
strpos($file->getPathname(), '/app/Mage.php') !== false) {
|
| 146 |
+
$dir = dirname(dirname($file->getPathname()));
|
| 147 |
+
self::$_storeBaseDir = $dir;
|
| 148 |
+
return self::$_storeBaseDir;
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
return false;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
public static function getBridgeDir()
|
| 156 |
+
{
|
| 157 |
+
$dir = realpath(dirname(__FILE__));
|
| 158 |
+
return $dir;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
public static function getPluginDir()
|
| 162 |
+
{
|
| 163 |
+
$dir = realpath(dirname(__FILE__) . DS . '..');
|
| 164 |
+
return $dir;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
public static function getProcessOwner()
|
| 168 |
+
{
|
| 169 |
+
if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
|
| 170 |
+
return posix_getpwuid(posix_geteuid());
|
| 171 |
+
}
|
| 172 |
+
return '-';
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
public static function getDownloadMethod()
|
| 176 |
+
{
|
| 177 |
+
if (ini_get('allow_url_fopen')) {
|
| 178 |
+
return 'stream';
|
| 179 |
+
}
|
| 180 |
+
if (function_exists('curl_version')) {
|
| 181 |
+
return 'curl';
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
return false;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
public static function downloadFile($url, $timeout = 10)
|
| 188 |
+
{
|
| 189 |
+
try {
|
| 190 |
+
$method = self::getDownloadMethod();
|
| 191 |
+
|
| 192 |
+
if ($method == 'stream') {
|
| 193 |
+
$ctx = stream_context_create(array(
|
| 194 |
+
'http'=>
|
| 195 |
+
array(
|
| 196 |
+
'timeout' => $timeout,
|
| 197 |
+
),
|
| 198 |
+
'https'=>
|
| 199 |
+
array(
|
| 200 |
+
'timeout' => $timeout,
|
| 201 |
+
),
|
| 202 |
+
)
|
| 203 |
+
);
|
| 204 |
+
$contents = @file_get_contents($url, false, $ctx);
|
| 205 |
+
if ($contents !== false) {
|
| 206 |
+
return $contents;
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
if ($method == 'curl') {
|
| 211 |
+
|
| 212 |
+
$ch = curl_init();
|
| 213 |
+
$headers = array(
|
| 214 |
+
"Accept: */*",
|
| 215 |
+
);
|
| 216 |
+
curl_setopt_array($ch, array(
|
| 217 |
+
CURLOPT_RETURNTRANSFER => 1,
|
| 218 |
+
CURLOPT_URL => $url,
|
| 219 |
+
CURLOPT_TIMEOUT => $timeout,
|
| 220 |
+
CURLOPT_FOLLOWLOCATION => true,
|
| 221 |
+
CURLOPT_ENCODING => '',
|
| 222 |
+
CURLOPT_HTTPHEADER => $headers,
|
| 223 |
+
));
|
| 224 |
+
|
| 225 |
+
$contents = curl_exec($ch);
|
| 226 |
+
|
| 227 |
+
if (curl_errno($ch)) {
|
| 228 |
+
curl_close($ch);
|
| 229 |
+
return false;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
curl_close($ch);
|
| 233 |
+
return $contents;
|
| 234 |
+
}
|
| 235 |
+
} catch (Exception $e) {
|
| 236 |
+
return false;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
return false;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
public static function loadBridgeConfig()
|
| 243 |
+
{
|
| 244 |
+
if (defined('M1_TOKEN')) {
|
| 245 |
+
return true;
|
| 246 |
+
}
|
| 247 |
+
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.php';
|
| 248 |
+
if (!file_exists($path)) {
|
| 249 |
+
return false;
|
| 250 |
+
}
|
| 251 |
+
require_once $path;
|
| 252 |
+
return true;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
public static function validateBridgeConfig()
|
| 256 |
+
{
|
| 257 |
+
$dir = self::getBridgeDir();
|
| 258 |
+
$path = $dir . DS . 'config.php';
|
| 259 |
+
if (!file_exists($path)) {
|
| 260 |
+
return false;
|
| 261 |
+
}
|
| 262 |
+
$contents = @file_get_contents($path);
|
| 263 |
+
if ($contents === false) {
|
| 264 |
+
return false;
|
| 265 |
+
}
|
| 266 |
+
if (strpos($contents, 'M1_TOKEN') === false) {
|
| 267 |
+
return false;
|
| 268 |
+
}
|
| 269 |
+
if (strpos($contents, '%m1_token%') !== false) {
|
| 270 |
+
return false;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
return true;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
public static function validateBridgeToken()
|
| 277 |
+
{
|
| 278 |
+
if (!isset($_GET['token'])) {
|
| 279 |
+
throw new Exception('token parameter is required.');
|
| 280 |
+
}
|
| 281 |
+
if ($_GET['token'] == '%m1_token%') {
|
| 282 |
+
throw new Exception('Invalid token.');
|
| 283 |
+
}
|
| 284 |
+
if (!defined('M1_TOKEN')) {
|
| 285 |
+
self::loadBridgeConfig();
|
| 286 |
+
if (!defined('M1_TOKEN')) {
|
| 287 |
+
throw new Exception('Failed to load bridge configuration.');
|
| 288 |
+
}
|
| 289 |
+
}
|
| 290 |
+
if (M1_TOKEN == '%m1_token%' || M1_TOKEN == '') {
|
| 291 |
+
throw new Exception('Token has not been saved in bridge configuration.');
|
| 292 |
+
}
|
| 293 |
+
if ($_GET['token'] != M1_TOKEN) {
|
| 294 |
+
throw new Exception('Incorrect token.');
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
return true;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
public static function sendResourceNotFoundResponse()
|
| 301 |
+
{
|
| 302 |
+
header('HTTP/1.0 404 Not Found');
|
| 303 |
+
header('Status: 404 Not Found');
|
| 304 |
+
echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" . PHP_EOL;
|
| 305 |
+
echo "<html><head>" . PHP_EOL;
|
| 306 |
+
echo "<title>404 Not Found</title>" . PHP_EOL;
|
| 307 |
+
echo "</head><body>" . PHP_EOL;
|
| 308 |
+
echo "<h1>Response Not Found</h1>" . PHP_EOL;
|
| 309 |
+
echo "<p>Requested resource could not be found.</p>" . PHP_EOL;
|
| 310 |
+
echo "</body></html>" . PHP_EOL;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
public static function handleRequest()
|
| 314 |
+
{
|
| 315 |
+
try {
|
| 316 |
+
$action = isset($_GET['action']) ? $_GET['action'] : false;
|
| 317 |
+
|
| 318 |
+
// Validate token
|
| 319 |
+
$validateToken = true;
|
| 320 |
+
$validateTokenExcluded = array('plugin.diagnostics');
|
| 321 |
+
if (in_array($action, $validateTokenExcluded)) {
|
| 322 |
+
$validateToken = false;
|
| 323 |
+
}
|
| 324 |
+
if ($validateToken) {
|
| 325 |
+
self::validateBridgeToken();
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
// Process action
|
| 329 |
+
if ($action) {
|
| 330 |
+
|
| 331 |
+
// Dynamically call static method
|
| 332 |
+
$method = lcfirst(str_replace(' ', '', ucwords(str_replace('.', ' ', $action)))) . 'Action';
|
| 333 |
+
if (method_exists(__CLASS__, $method)) {
|
| 334 |
+
$function = __CLASS__ . '::' . $method;
|
| 335 |
+
$response = call_user_func($function);
|
| 336 |
+
} else {
|
| 337 |
+
throw new Exception('Unknown action');
|
| 338 |
+
}
|
| 339 |
+
} else {
|
| 340 |
+
throw new Exception('action parameter is required.');
|
| 341 |
+
}
|
| 342 |
+
} catch (Exception $e) {
|
| 343 |
+
$response = self::newResponseError($e->getMessage());
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
self::sendJsonResponse($response);
|
| 347 |
+
die();
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
public static function newResponse()
|
| 351 |
+
{
|
| 352 |
+
$response = array();
|
| 353 |
+
$response['status'] = 'success';
|
| 354 |
+
$response['response_id'] = md5(uniqid(mt_rand(), true));
|
| 355 |
+
return $response;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
public static function sendJsonResponse($response)
|
| 359 |
+
{
|
| 360 |
+
header('Content-Type: application/json');
|
| 361 |
+
echo json_encode($response);
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
public static function newResponseError($message)
|
| 365 |
+
{
|
| 366 |
+
$response = array();
|
| 367 |
+
$response['status'] = 'error';
|
| 368 |
+
$response['response_id'] = md5(uniqid(mt_rand(), true));
|
| 369 |
+
$response['error_message'] = $message;
|
| 370 |
+
return $response;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
public static function pluginPingAction()
|
| 374 |
+
{
|
| 375 |
+
$response = self::newResponse();
|
| 376 |
+
return $response;
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
public static function platformCacheInfoAction()
|
| 380 |
+
{
|
| 381 |
+
$response = self::newResponse();
|
| 382 |
+
$response['cache'] = array();
|
| 383 |
+
$platform = self::getPlatform();
|
| 384 |
+
|
| 385 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 386 |
+
try {
|
| 387 |
+
self::loadMagento();
|
| 388 |
+
$types = Mage::app()->getCacheInstance()->getTypes();
|
| 389 |
+
foreach ($types as $type) {
|
| 390 |
+
$response['cache'][] = $type->getData();
|
| 391 |
+
}
|
| 392 |
+
} catch (Exception $e) {
|
| 393 |
+
$response['status'] = 'error';
|
| 394 |
+
}
|
| 395 |
+
} else {
|
| 396 |
+
$response['status'] = 'error';
|
| 397 |
+
$response['error_message'] = 'Unsupported platform';
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
return $response;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
public static function getPlatform()
|
| 404 |
+
{
|
| 405 |
+
// Detect Magento
|
| 406 |
+
$filename = self::getStoreBaseDir() . DS . 'app' . DS . 'Mage.php';
|
| 407 |
+
if (file_exists($filename)) {
|
| 408 |
+
return self::PLATFORM_MAGENTO;
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
return self::PLATFORM_UNKNOWN;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
public static function getWebinterpretKey()
|
| 415 |
+
{
|
| 416 |
+
$platform = self::getPlatform();
|
| 417 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 418 |
+
self::loadMagento();
|
| 419 |
+
$key = Mage::getStoreConfig('webinterpret_connector/key');
|
| 420 |
+
} else {
|
| 421 |
+
throw new Exception("Method is not supported on this platform: $platform");
|
| 422 |
+
}
|
| 423 |
+
return $key;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
public static function platformConfigurationUpdateAction()
|
| 427 |
+
{
|
| 428 |
+
$response = self::newResponse();
|
| 429 |
+
$platform = self::getPlatform();
|
| 430 |
+
|
| 431 |
+
if (!isset($_REQUEST['config_key'])) {
|
| 432 |
+
throw new Exception('config_key parameter is required.');
|
| 433 |
+
}
|
| 434 |
+
$key = $_REQUEST['config_key'];
|
| 435 |
+
|
| 436 |
+
if (!isset($_REQUEST['config_value'])) {
|
| 437 |
+
throw new Exception('config_value parameter is required.');
|
| 438 |
+
}
|
| 439 |
+
$value = $_REQUEST['config_value'];
|
| 440 |
+
|
| 441 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 442 |
+
self::loadMagento();
|
| 443 |
+
Mage::getConfig()->saveConfig($key, $value);
|
| 444 |
+
Mage::getConfig()->reinit();
|
| 445 |
+
} else {
|
| 446 |
+
$response['status'] = 'error';
|
| 447 |
+
$response['error_message'] = 'Unsupported platform';
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
return $response;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
public static function pluginVersionAction()
|
| 454 |
+
{
|
| 455 |
+
$response = self::newResponse();
|
| 456 |
+
$response['php_version'] = phpversion();
|
| 457 |
+
$response['plugin_helper_version'] = self::getVersion();
|
| 458 |
+
$platform = self::getPlatform();
|
| 459 |
+
$baseDir = self::getStoreBaseDir();
|
| 460 |
+
$response['platform'] = $platform;
|
| 461 |
+
|
| 462 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 463 |
+
self::loadMagento();
|
| 464 |
+
$response['magento_version'] = Mage::getVersion();
|
| 465 |
+
|
| 466 |
+
$modules = (array)Mage::getConfig()->getNode('modules')->children();
|
| 467 |
+
$edition = (array_key_exists('Enterprise_Enterprise', $modules)) ? 'Enterprise Edition' : 'Community Edition';
|
| 468 |
+
$version = Mage::getVersion();
|
| 469 |
+
|
| 470 |
+
$response['magento_version'] = "{$edition} {$version}";
|
| 471 |
+
|
| 472 |
+
$file = $baseDir . '/app/code/community/Webinterpret/Connector/etc/config.xml';
|
| 473 |
+
if (file_exists($file)) {
|
| 474 |
+
try {
|
| 475 |
+
$xml = simplexml_load_file($file);
|
| 476 |
+
$version = (string)$xml->modules[0]->Webinterpret_Connector[0]->version;
|
| 477 |
+
$response['plugin_connector_version'] = $version;
|
| 478 |
+
} catch (Exception $e) {
|
| 479 |
+
$response['status'] = 'error';
|
| 480 |
+
$response['error_message'] = 'Failed to get Magento version';
|
| 481 |
+
}
|
| 482 |
+
}
|
| 483 |
+
} else {
|
| 484 |
+
$response['status'] = 'error';
|
| 485 |
+
$response['error_message'] = 'Unsupported platform';
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
return $response;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
public static function platformInfoAction()
|
| 492 |
+
{
|
| 493 |
+
$response = self::pluginVersionAction();
|
| 494 |
+
|
| 495 |
+
$platform = self::getPlatform();
|
| 496 |
+
$response['platform'] = $platform;
|
| 497 |
+
$response['base_dir'] = self::getStoreBaseDir();
|
| 498 |
+
$response['plugin_dir'] = self::getPluginDir();
|
| 499 |
+
$response['bridge_dir'] = self::getBridgeDir();
|
| 500 |
+
$response['download_method'] = self::getDownloadMethod();
|
| 501 |
+
|
| 502 |
+
// Magento
|
| 503 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 504 |
+
$response['magento_compiler'] = self::getCompilerStatus();
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
return $response;
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
public static function pluginDiagnosticsAction()
|
| 511 |
+
{
|
| 512 |
+
$response = self::newResponse();
|
| 513 |
+
$response['php_version'] = phpversion();
|
| 514 |
+
$response['php_function_mysql_connect'] = function_exists('mysql_connect') ? 'yes' : 'no';
|
| 515 |
+
$response['php_function_mysqli_connect'] = function_exists('mysqli_connect') ? 'yes' : 'no';
|
| 516 |
+
$response['plugin_helper_version'] = self::getVersion();
|
| 517 |
+
$baseDir = self::getStoreBaseDir();
|
| 518 |
+
$response['base_dir'] = $baseDir;
|
| 519 |
+
$platform = self::getPlatform();
|
| 520 |
+
$response['platform'] = self::getPlatform();
|
| 521 |
+
|
| 522 |
+
// Magento
|
| 523 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 524 |
+
self::loadMagento();
|
| 525 |
+
|
| 526 |
+
// Get version
|
| 527 |
+
$response['magento_version'] = Mage::getVersion();
|
| 528 |
+
$modules = (array)Mage::getConfig()->getNode('modules')->children();
|
| 529 |
+
$edition = (array_key_exists('Enterprise_Enterprise', $modules)) ? 'Enterprise Edition' : 'Community Edition';
|
| 530 |
+
$version = Mage::getVersion();
|
| 531 |
+
$response['magento_version'] = "{$edition} {$version}";
|
| 532 |
+
|
| 533 |
+
// Check if module exists
|
| 534 |
+
$response['magento_module_exists'] = 'no';
|
| 535 |
+
$modules = (array)Mage::getConfig()->getNode('modules')->children();
|
| 536 |
+
if (isset($modules['Webinterpret_Connector'])) {
|
| 537 |
+
$response['magento_module_exists'] = 'yes';
|
| 538 |
+
|
| 539 |
+
// Check if Webinterpret module has been enabled
|
| 540 |
+
$response['magento_module_enabled'] = Mage::helper('core')->isModuleEnabled('Webinterpret_Connector') ? 'yes' : 'no';
|
| 541 |
+
|
| 542 |
+
// Check which version has been installed
|
| 543 |
+
$file = $baseDir . '/app/code/community/Webinterpret/Connector/etc/config.xml';
|
| 544 |
+
if (file_exists($file)) {
|
| 545 |
+
try {
|
| 546 |
+
$xml = simplexml_load_file($file);
|
| 547 |
+
$version = (string)$xml->modules[0]->Webinterpret_Connector[0]->version;
|
| 548 |
+
$response['plugin_connector_version'] = $version;
|
| 549 |
+
} catch (Exception $e) {
|
| 550 |
+
$response['status'] = 'error';
|
| 551 |
+
$response['error_message'] = 'Failed to get Magento version';
|
| 552 |
+
}
|
| 553 |
+
}
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
// Check file permissions
|
| 557 |
+
$response['report'] = Mage::helper('webinterpret_connector')->selfTest();
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
return $response;
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
public static function pluginConfigurationInfoAction()
|
| 564 |
+
{
|
| 565 |
+
$response = self::newResponse();
|
| 566 |
+
$platform = self::getPlatform();
|
| 567 |
+
$response['platform'] = $platform;
|
| 568 |
+
|
| 569 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 570 |
+
$response['webinterpret_connector'] = Mage::getStoreConfig('webinterpret_connector');
|
| 571 |
+
} else {
|
| 572 |
+
$response['status'] = 'error';
|
| 573 |
+
$response['error_message'] = 'Unsupported platform';
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
return $response;
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
public static function loadMagento()
|
| 580 |
+
{
|
| 581 |
+
if (class_exists('Mage')) {
|
| 582 |
+
return true;
|
| 583 |
+
}
|
| 584 |
+
$storeBaseDir = self::getStoreBaseDir();
|
| 585 |
+
$path = $storeBaseDir . DS . 'app' . DS .'Mage.php';
|
| 586 |
+
if (!file_exists($path)) {
|
| 587 |
+
return false;
|
| 588 |
+
}
|
| 589 |
+
require_once $path;
|
| 590 |
+
return true;
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
public static function platformPluginsInfoAction()
|
| 594 |
+
{
|
| 595 |
+
$response = self::newResponse();
|
| 596 |
+
$baseDir = self::getStoreBaseDir();
|
| 597 |
+
$platform = self::getPlatform();
|
| 598 |
+
|
| 599 |
+
// Magento
|
| 600 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 601 |
+
if (file_exists($baseDir . '/app/etc/local.xml')) {
|
| 602 |
+
$dir = $baseDir . '/app/etc/modules';
|
| 603 |
+
$files = scandir($dir);
|
| 604 |
+
$plugins = array();
|
| 605 |
+
foreach ($files as $key => $value) {
|
| 606 |
+
if (!in_array($value,array('.', '..'))) {
|
| 607 |
+
$file = $dir . DIRECTORY_SEPARATOR . $value;
|
| 608 |
+
if (is_file($file)) {
|
| 609 |
+
try {
|
| 610 |
+
$xml = simplexml_load_file($file);
|
| 611 |
+
if (is_object($xml) && $xml->modules->count() > 0 && $xml->modules[0]->count() > 0) {
|
| 612 |
+
foreach ($xml->modules[0]->children() as $module) {
|
| 613 |
+
$plugins[] = array(
|
| 614 |
+
'name' => $module->getName(),
|
| 615 |
+
'active' => (string)$module->active
|
| 616 |
+
);
|
| 617 |
+
}
|
| 618 |
+
}
|
| 619 |
+
} catch (Exception $e) {
|
| 620 |
+
// Skip
|
| 621 |
+
}
|
| 622 |
+
}
|
| 623 |
+
}
|
| 624 |
+
}
|
| 625 |
+
$response['plugins'] = $plugins;
|
| 626 |
+
}
|
| 627 |
+
} else {
|
| 628 |
+
$response['status'] = 'error';
|
| 629 |
+
$response['error_message'] = 'Unsupported platform';
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
return $response;
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
public static function platformConfigurationInfoAction()
|
| 636 |
+
{
|
| 637 |
+
$response = self::newResponse();
|
| 638 |
+
$baseDir = self::getStoreBaseDir();
|
| 639 |
+
|
| 640 |
+
if (file_exists($baseDir . '/app/etc/local.xml')) {
|
| 641 |
+
$local = @file_get_contents($baseDir . '/app/etc/local.xml');
|
| 642 |
+
if ($local === false) {
|
| 643 |
+
$response['status'] = 'error';
|
| 644 |
+
$response['error_message'] = 'Failed to read configuration file';
|
| 645 |
+
} else {
|
| 646 |
+
$response['local'] = base64_encode($local);
|
| 647 |
+
}
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
return $response;
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
public static function systemPhpInfoAction()
|
| 654 |
+
{
|
| 655 |
+
phpinfo();
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
public static function getCompilerStatus()
|
| 659 |
+
{
|
| 660 |
+
$platform = self::getPlatform();
|
| 661 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 662 |
+
self::loadMagento();
|
| 663 |
+
return defined('COMPILER_INCLUDE_PATH') ? 'enabled' : 'disabled';
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
return false;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
public static function platformCompilerUpdateAction()
|
| 670 |
+
{
|
| 671 |
+
$response = self::newResponse();
|
| 672 |
+
$platform = self::getPlatform();
|
| 673 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 674 |
+
self::loadMagento();
|
| 675 |
+
|
| 676 |
+
// Status
|
| 677 |
+
if (!isset($_REQUEST['status']) || empty($_REQUEST['status'])) {
|
| 678 |
+
throw new Exception('status parameter is required');
|
| 679 |
+
}
|
| 680 |
+
$status = $_REQUEST['status'];
|
| 681 |
+
|
| 682 |
+
// Enable or disable compiler
|
| 683 |
+
$compiler = Mage::getModel('compiler/process');
|
| 684 |
+
if ($status == 'enable') {
|
| 685 |
+
$compiler->registerIncludePath();
|
| 686 |
+
}
|
| 687 |
+
if ($status == 'disable') {
|
| 688 |
+
$compiler->registerIncludePath(false);
|
| 689 |
+
}
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
return $response;
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
public static function platformCompilerRunAction()
|
| 696 |
+
{
|
| 697 |
+
$response = self::newResponse();
|
| 698 |
+
$platform = self::getPlatform();
|
| 699 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 700 |
+
self::loadMagento();
|
| 701 |
+
$compiler = Mage::getModel('compiler/process');
|
| 702 |
+
$result = $compiler->validate();
|
| 703 |
+
if (!empty($result)) {
|
| 704 |
+
throw new Exception('Cannot run compliation process');
|
| 705 |
+
}
|
| 706 |
+
$compiler->run();
|
| 707 |
+
}
|
| 708 |
+
|
| 709 |
+
return $response;
|
| 710 |
+
}
|
| 711 |
+
|
| 712 |
+
public static function platformCompilerClearAction()
|
| 713 |
+
{
|
| 714 |
+
$response = self::newResponse();
|
| 715 |
+
$platform = self::getPlatform();
|
| 716 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 717 |
+
self::loadMagento();
|
| 718 |
+
$compiler = Mage::getModel('compiler/process');
|
| 719 |
+
$compiler->clear();
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
return $response;
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
public static function platformConfigurationRefreshAction()
|
| 726 |
+
{
|
| 727 |
+
$response = self::newResponse();
|
| 728 |
+
$platform = self::getPlatform();
|
| 729 |
+
|
| 730 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 731 |
+
self::loadMagento();
|
| 732 |
+
Mage::getConfig()->reinit();
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
return $response;
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
public static function platformCacheRefreshAction()
|
| 739 |
+
{
|
| 740 |
+
$response = self::newResponse();
|
| 741 |
+
$response['zend_cache'] = 0;
|
| 742 |
+
$response['errors'] = array();
|
| 743 |
+
$response['log'] = array();
|
| 744 |
+
$platform = self::getPlatform();
|
| 745 |
+
|
| 746 |
+
if ($platform == self::PLATFORM_MAGENTO) {
|
| 747 |
+
self::loadMagento();
|
| 748 |
+
|
| 749 |
+
$typeFilter = null;
|
| 750 |
+
if (isset($_REQUEST['types'])) {
|
| 751 |
+
if (is_array($_REQUEST['types'])) {
|
| 752 |
+
$typeFilter = $_REQUEST['types'];
|
| 753 |
+
}
|
| 754 |
+
if (is_string($_REQUEST['types'])) {
|
| 755 |
+
$typeFilter = array($_REQUEST['types']);
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
// Clear cache - method 1
|
| 760 |
+
if (is_null($typeFilter)) {
|
| 761 |
+
$app = Mage::app();
|
| 762 |
+
if ($app != null) {
|
| 763 |
+
$cache = $app->getCache();
|
| 764 |
+
if($cache != null) {
|
| 765 |
+
$cache->clean();
|
| 766 |
+
}
|
| 767 |
+
}
|
| 768 |
+
}
|
| 769 |
+
|
| 770 |
+
// Clear cache - method 2
|
| 771 |
+
$types = Mage::app()->getCacheInstance()->getTypes();
|
| 772 |
+
foreach ($types as $type) {
|
| 773 |
+
$typeId = $type->getId();
|
| 774 |
+
if (is_array($typeFilter) && !in_array($typeId, $typeFilter)) {
|
| 775 |
+
continue; // skip
|
| 776 |
+
}
|
| 777 |
+
$response['log'][] = "Clear cache: $typeId";
|
| 778 |
+
Mage::app()->getCacheInstance()->cleanType($type);
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
// Reload configuration
|
| 782 |
+
Mage::getConfig()->reinit();
|
| 783 |
+
|
| 784 |
+
// Clear Zend Cache
|
| 785 |
+
if (is_null($typeFilter)) {
|
| 786 |
+
if (extension_loaded('Zend Page Cache') && function_exists('page_cache_remove_all_cached_contents')) {
|
| 787 |
+
$response['zend_cache'] = 1;
|
| 788 |
+
page_cache_remove_all_cached_contents();
|
| 789 |
+
}
|
| 790 |
+
}
|
| 791 |
+
} else {
|
| 792 |
+
$response['status'] = 'error';
|
| 793 |
+
$response['error_message'] = 'Unsupported platform';
|
| 794 |
+
}
|
| 795 |
+
|
| 796 |
+
return $response;
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
public static function systemFileListAction()
|
| 800 |
+
{
|
| 801 |
+
$response = self::newResponse();
|
| 802 |
+
|
| 803 |
+
if (!isset($_REQUEST['dir'])) {
|
| 804 |
+
throw new Exception('dir parameter is required');
|
| 805 |
+
}
|
| 806 |
+
$dir = $_REQUEST['dir'];
|
| 807 |
+
if (!file_exists($dir)) {
|
| 808 |
+
throw new Exception('No such file or directory');
|
| 809 |
+
}
|
| 810 |
+
|
| 811 |
+
$response['result'] = array();
|
| 812 |
+
$iterator = new RecursiveDirectoryIterator($dir);
|
| 813 |
+
foreach (new RecursiveIteratorIterator($iterator) as $fileInfo) {
|
| 814 |
+
$response['result'][] = self::convertSplFileInfoToArray($fileInfo);
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
return $response;
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
public static function systemFileInfoAction()
|
| 821 |
+
{
|
| 822 |
+
$response = self::newResponse();
|
| 823 |
+
|
| 824 |
+
if (!isset($_REQUEST['file'])) {
|
| 825 |
+
throw new Exception('file parameter is required');
|
| 826 |
+
}
|
| 827 |
+
$file = $_REQUEST['file'];
|
| 828 |
+
if (!file_exists($file)) {
|
| 829 |
+
throw new Exception('No such file or directory');
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
$fileInfo = new SplFileInfo($file);
|
| 833 |
+
$response['result'] = self::convertSplFileInfoToArray($fileInfo);
|
| 834 |
+
return $response;
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
public static function systemFileRenameAction()
|
| 838 |
+
{
|
| 839 |
+
$response = self::newResponse();
|
| 840 |
+
|
| 841 |
+
if (!isset($_REQUEST['oldname'])) {
|
| 842 |
+
throw new Exception('oldname parameter is required');
|
| 843 |
+
}
|
| 844 |
+
$oldname = $_REQUEST['oldname'];
|
| 845 |
+
|
| 846 |
+
if (!isset($_REQUEST['newname'])) {
|
| 847 |
+
throw new Exception('newname parameter is required');
|
| 848 |
+
}
|
| 849 |
+
$newname = $_REQUEST['newname'];
|
| 850 |
+
|
| 851 |
+
if (!file_exists($oldname)) {
|
| 852 |
+
throw new Exception('No such file or directory');
|
| 853 |
+
}
|
| 854 |
+
|
| 855 |
+
if (!@rename($oldname, $newname)) {
|
| 856 |
+
throw new Exception('Failed to rename file');
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
return $response;
|
| 860 |
+
}
|
| 861 |
+
|
| 862 |
+
public static function systemFileChmodAction()
|
| 863 |
+
{
|
| 864 |
+
$response = self::newResponse();
|
| 865 |
+
|
| 866 |
+
if (!isset($_REQUEST['file'])) {
|
| 867 |
+
throw new Exception('file parameter is required');
|
| 868 |
+
}
|
| 869 |
+
$file = $_REQUEST['file'];
|
| 870 |
+
|
| 871 |
+
if (!isset($_REQUEST['mode'])) {
|
| 872 |
+
throw new Exception('mode parameter is required');
|
| 873 |
+
}
|
| 874 |
+
$mode = $_REQUEST['mode'];
|
| 875 |
+
|
| 876 |
+
if (!file_exists($file)) {
|
| 877 |
+
throw new Exception('No such file or directory');
|
| 878 |
+
}
|
| 879 |
+
|
| 880 |
+
if (!@chmod($file, octdec($mode))) {
|
| 881 |
+
throw new Exception('Failed to change file mode');
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
return $response;
|
| 885 |
+
}
|
| 886 |
+
|
| 887 |
+
public static function systemFileCopyAction()
|
| 888 |
+
{
|
| 889 |
+
$response = self::newResponse();
|
| 890 |
+
|
| 891 |
+
// Source
|
| 892 |
+
if (!isset($_REQUEST['source']) || empty($_REQUEST['source'])) {
|
| 893 |
+
throw new Exception('source parameter is required');
|
| 894 |
+
}
|
| 895 |
+
$source = $_REQUEST['source'];
|
| 896 |
+
|
| 897 |
+
if (filter_var($source, FILTER_VALIDATE_URL)) {
|
| 898 |
+
$contents = self::downloadFile($source);
|
| 899 |
+
if (!$contents) {
|
| 900 |
+
throw new Exception('Failed to download file');
|
| 901 |
+
}
|
| 902 |
+
} else {
|
| 903 |
+
if (!file_exists($source)) {
|
| 904 |
+
throw new Exception('Source file does not exist');
|
| 905 |
+
}
|
| 906 |
+
$contents = @file_get_contents($source);
|
| 907 |
+
}
|
| 908 |
+
|
| 909 |
+
// Destination
|
| 910 |
+
if (!isset($_REQUEST['dest']) || empty($_REQUEST['dest'])) {
|
| 911 |
+
throw new Exception('dest parameter is required');
|
| 912 |
+
}
|
| 913 |
+
$dest = $_REQUEST['dest'];
|
| 914 |
+
|
| 915 |
+
if (filter_var($dest, FILTER_VALIDATE_URL)) {
|
| 916 |
+
throw new Exception('dest cannot be an URL');
|
| 917 |
+
}
|
| 918 |
+
|
| 919 |
+
// Write file
|
| 920 |
+
if (@file_put_contents($dest, $contents) === false) {
|
| 921 |
+
throw new Exception("Failed to write file: $dest");
|
| 922 |
+
}
|
| 923 |
+
@chmod($dest, 0664);
|
| 924 |
+
|
| 925 |
+
return $response;
|
| 926 |
+
}
|
| 927 |
+
|
| 928 |
+
public static function systemFileMkdirAction()
|
| 929 |
+
{
|
| 930 |
+
$response = self::newResponse();
|
| 931 |
+
|
| 932 |
+
if (!isset($_REQUEST['pathname'])) {
|
| 933 |
+
throw new Exception('pathname parameter is required');
|
| 934 |
+
}
|
| 935 |
+
$pathname = $_REQUEST['pathname'];
|
| 936 |
+
|
| 937 |
+
$mode = octdec('0775');
|
| 938 |
+
if (isset($_REQUEST['mode'])) {
|
| 939 |
+
$mode = octdec($_REQUEST['mode']);
|
| 940 |
+
}
|
| 941 |
+
|
| 942 |
+
$recursive = false;
|
| 943 |
+
if (isset($_REQUEST['recursive'])) {
|
| 944 |
+
$recursive = (bool)$_REQUEST['recursive'];
|
| 945 |
+
}
|
| 946 |
+
|
| 947 |
+
if (!@mkdir($pathname, $mode, $recursive)) {
|
| 948 |
+
throw new Exception('Failed to make directory');
|
| 949 |
+
}
|
| 950 |
+
|
| 951 |
+
return $response;
|
| 952 |
+
}
|
| 953 |
+
|
| 954 |
+
public static function systemFileRmdirAction()
|
| 955 |
+
{
|
| 956 |
+
$response = self::newResponse();
|
| 957 |
+
|
| 958 |
+
if (!isset($_REQUEST['pathname'])) {
|
| 959 |
+
throw new Exception('pathname parameter is required');
|
| 960 |
+
}
|
| 961 |
+
$pathname = $_REQUEST['pathname'];
|
| 962 |
+
|
| 963 |
+
if (!@rmdir($pathname)) {
|
| 964 |
+
throw new Exception('Failed to remove directory');
|
| 965 |
+
}
|
| 966 |
+
|
| 967 |
+
return $response;
|
| 968 |
+
}
|
| 969 |
+
|
| 970 |
+
public static function convertSplFileInfoToArray($fileInfo)
|
| 971 |
+
{
|
| 972 |
+
$arr = array(
|
| 973 |
+
'filename' => $fileInfo->getFilename(),
|
| 974 |
+
'group' => $fileInfo->getGroup(),
|
| 975 |
+
'owner' => $fileInfo->getOwner(),
|
| 976 |
+
'path' => $fileInfo->getPath(),
|
| 977 |
+
'pathname' => $fileInfo->getPathname(),
|
| 978 |
+
'perms' => $fileInfo->getPerms(),
|
| 979 |
+
'realpath' => $fileInfo->getRealPath(),
|
| 980 |
+
'size' => $fileInfo->getSize(),
|
| 981 |
+
'type' => $fileInfo->getType(),
|
| 982 |
+
'is_dir' => $fileInfo->isDir(),
|
| 983 |
+
'is_executable' => $fileInfo->isExecutable(),
|
| 984 |
+
'is_file' => $fileInfo->isFile(),
|
| 985 |
+
'is_link' => $fileInfo->isLink(),
|
| 986 |
+
'is_readable' => $fileInfo->isReadable(),
|
| 987 |
+
'is_writable' => $fileInfo->isWritable(),
|
| 988 |
+
);
|
| 989 |
+
if ($fileInfo->isLink()) {
|
| 990 |
+
$arr['link_target'] = $fileInfo->getLinkTarget();
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
return $arr;
|
| 994 |
+
}
|
| 995 |
+
}
|
| 996 |
+
|
| 997 |
+
if (!defined('WI_HELPER_CALL_HANDLE_REQUEST') || WI_HELPER_CALL_HANDLE_REQUEST) {
|
| 998 |
+
Webinterpret_Bridge2Cart_Helper::handleRequest();
|
| 999 |
+
}
|
app/code/community/Webinterpret/Connector/controllers/CartController.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* @category Webinterpret
|
| 5 |
+
* @package Webinterpret_Connector
|
| 6 |
+
* @author Webinterpret Team <info@webinterpret.com>
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php
|
| 8 |
+
*/
|
| 9 |
+
class Webinterpret_Connector_CartController extends Mage_Core_Controller_Front_Action
|
| 10 |
+
{
|
| 11 |
+
public function indexAction()
|
| 12 |
+
{
|
| 13 |
+
$quote = Mage::getSingleton('checkout/cart')->getQuote();
|
| 14 |
+
$cart = array();
|
| 15 |
+
foreach ($quote->getAllVisibleItems() as $item) {
|
| 16 |
+
$item_option = $item->getOptionByCode('simple_product');
|
| 17 |
+
$cart[] = array(
|
| 18 |
+
'external_id' => $item->getProduct()->getId(),
|
| 19 |
+
'variant_id' => $item_option ? $item_option->getProduct()->getId() : null,
|
| 20 |
+
'quantity' => $item->getQty(),
|
| 21 |
+
'custom_options' => $item->getBuyRequest()->getOptions(),
|
| 22 |
+
);
|
| 23 |
+
}
|
| 24 |
+
header('Content-Type: application/json');
|
| 25 |
+
echo json_encode($cart);
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Webinterpret/Connector/controllers/HelperController.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* @category Webinterpret
|
| 5 |
+
* @package Webinterpret_Connector
|
| 6 |
+
* @author Webinterpret Team <info@webinterpret.com>
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php
|
| 8 |
+
*/
|
| 9 |
+
class Webinterpret_Connector_HelperController extends Mage_Core_Controller_Front_Action
|
| 10 |
+
{
|
| 11 |
+
public function indexAction()
|
| 12 |
+
{
|
| 13 |
+
try {
|
| 14 |
+
Webinterpret_Connector_Helper_Verifier::verifyRequestWebInterpretSignature();
|
| 15 |
+
define('M1_TOKEN', Mage::getStoreConfig('webinterpret_connector/key'));
|
| 16 |
+
$dir = Mage::helper('webinterpret_connector')->getModuleBridgeDir();
|
| 17 |
+
$path = $dir . DS . 'helper.php';
|
| 18 |
+
if (!file_exists($path)) {
|
| 19 |
+
$this->_forward('defaultNoRoute');
|
| 20 |
+
return;
|
| 21 |
+
}
|
| 22 |
+
require_once $path;
|
| 23 |
+
Webinterpret_Bridge2Cart_Helper::handleRequest();
|
| 24 |
+
} catch (Webinterpret_Connector_Model_SignatureException $e) {
|
| 25 |
+
header('HTTP/1.0 403 Forbidden');
|
| 26 |
+
echo $e->getMessage();
|
| 27 |
+
} catch (Exception $e) {
|
| 28 |
+
echo $e->getMessage();
|
| 29 |
+
}
|
| 30 |
+
die;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public function installAction()
|
| 34 |
+
{
|
| 35 |
+
$response = array();
|
| 36 |
+
$response['status'] = 'success';
|
| 37 |
+
$response['response_id'] = md5(uniqid(mt_rand(), true));
|
| 38 |
+
if (!Mage::helper('webinterpret_connector')->installBridgeHelper()) {
|
| 39 |
+
$response['status'] = 'error';
|
| 40 |
+
}
|
| 41 |
+
header('Content-Type: application/json');
|
| 42 |
+
echo json_encode($response);
|
| 43 |
+
die();
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Webinterpret/Connector/etc/config.xml
CHANGED
|
@@ -8,7 +8,7 @@
|
|
| 8 |
<config>
|
| 9 |
<modules>
|
| 10 |
<Webinterpret_Connector>
|
| 11 |
-
<version>1.
|
| 12 |
</Webinterpret_Connector>
|
| 13 |
</modules>
|
| 14 |
<global>
|
| 8 |
<config>
|
| 9 |
<modules>
|
| 10 |
<Webinterpret_Connector>
|
| 11 |
+
<version>1.4.0.0</version>
|
| 12 |
</Webinterpret_Connector>
|
| 13 |
</modules>
|
| 14 |
<global>
|
package.xml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Webinterpret_Connector</name>
|
| 4 |
-
<version>1.
|
| 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>
|
| 12 |
<authors><author><name>Webinterpret</name><user>webinterpret</user><email>info@webinterpret.com</email></author></authors>
|
| 13 |
-
<date>2017-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magecommunity"><dir><dir name="Webinterpret"><dir name="Connector"><dir><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="62109d018382a9bf3f302e8d353c2b85"/></dir></dir></dir></dir><file name="Footer.php" hash="160f03e528d7e9411e85d524919fd280"/><file name="Head.php" hash="0032590c9bc1776b6a3c4683da680d9e"/><dir name="Product"><file name="View.php" hash="9d033ae77fbdeee82eef7b43c09ff784"/></dir></dir><dir name="Helper"><file name="Data.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.3.2</min><max>7.0.99</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Webinterpret_Connector</name>
|
| 4 |
+
<version>1.4.0.0</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>Localized checkout.</notes>
|
| 12 |
<authors><author><name>Webinterpret</name><user>webinterpret</user><email>info@webinterpret.com</email></author></authors>
|
| 13 |
+
<date>2017-06-01</date>
|
| 14 |
+
<time>14:16:05</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir><dir name="Webinterpret"><dir name="Connector"><dir><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="62109d018382a9bf3f302e8d353c2b85"/></dir></dir></dir></dir><file name="Footer.php" hash="160f03e528d7e9411e85d524919fd280"/><file name="Head.php" hash="0032590c9bc1776b6a3c4683da680d9e"/><dir name="Product"><file name="View.php" hash="9d033ae77fbdeee82eef7b43c09ff784"/></dir></dir><dir name="Helper"><file name="Data.php" hash="2ebaa044b7b187a9887cae7765892154"/><file name="Verifier.php" hash="bef096e4d9639eceba9e07863713813f"/></dir><dir name="Model"><file name="Notification.php" hash="a62c3b7ff11cd2d1082c0d959d8eb295"/><file name="Observer.php" hash="0dda5243770ed67ca6dc04b7146535f4"/><file name="SignatureException.php" hash="9c5648a9fcada7d47086c88ef087e5ae"/></dir><dir name="StatusApi"><file name="AbstractStatusApiDiagnostics.php" hash="9ee5e9c5d5fec80554db3b8e186351f4"/><file name="PlatformDiagnostics.php" hash="4ed1af6d267eab00ccc8f9c8b6a88127"/><file name="PluginDiagnostics.php" hash="060179457dc5a10ff94d5bc199a2ff5d"/><file name="StatusApi.php" hash="5cdd2836c23f47a2ff7d17c2f4e0cab5"/><file name="StatusApiConfigurator.php" hash="01d5e2a0edc9d8f86bd830e16992ef98"/><file name="SystemDiagnostics.php" hash="a88a5dda8feb17b61e8f50de5a6c170a"/></dir><dir name="bridge2cart"><file name="bridge.php" hash="abfddf1013fe32620eb69e2f7471d6b7"/><file name="config.php" hash="ee9fb4a042465ce27bcb90de90309b04"/><file name="helper.php" hash="e0eb46061af54043ac98c413d57f2117"/></dir><dir name="controllers"><file name="CartController.php" hash="b9cb3f32037b79c3dc0a615336c17525"/><file name="ConfigurationController.php" hash="61d61f201dc54687f7779c1eddacc004"/><file name="DiagnosticsController.php" hash="9de88087e360f5a73063fe10a9192a07"/><file name="HelperController.php" hash="c7eb03f8730fb98d21ce483b84b579e1"/><file name="IndexController.php" hash="44c5c7a8e434a729b90b12a159a8be90"/></dir><dir name="etc"><file name="adminhtml.xml" hash="07e287503c40ce7c588efe7863c05002"/><file name="config.xml" hash="2ccf3c7e8b4f4e773657c223ae7025b8"/><file name="env.ini" hash="56a56296790c8b4b20ca3bee02e2e6ad"/><file name="system.xml" hash="cfe59ca34ebfef69b900f4ad275a809a"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="webinterpret"><file name="connector.xml" hash="867fafe49fa978668f6e5d7027c57aa6"/></dir></dir><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="412bd1ea314a7f0c8897e6a9225c3551"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="webinterpret"><file name="connector.xml" hash="08572e6e5b65b104d06d71b97b371df5"/></dir></dir><dir name="template"><dir name="webinterpret"><dir name="connector"><file name="footer.phtml" hash="bd48d0e36dea0936b9f28fbdada3b8c1"/><file name="head.phtml" hash="687b5575ab37f2f50a43e781e22810db"/><file name="product_view.phtml" hash="5567ce8f7687ed09c9eae407f7bc7b19"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webinterpret_Connector.xml" hash="087c2742f6bcb89ed6a77921e6493feb"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Webinterpret_Connector.csv" hash="91312fd3bd2645b88e3b3643b6b614a9"/></dir><dir name="en_US"><file name="Webinterpret_Connector.csv" hash="c382db753974630198cf029cf90b5d27"/></dir></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.3.2</min><max>7.0.99</max></php></required></dependencies>
|
| 18 |
</package>
|
