Version Notes
Optimized production ready release.
Download this release
Release Info
Developer | Conversify.com |
Extension | conversify |
Version | 1.1.0 |
Comparing to | |
See all releases |
Version 1.1.0
- app/code/community/Conversify/ScriptManager/Block/Conversion.php +32 -0
- app/code/community/Conversify/ScriptManager/Block/Scriptmanager.php +148 -0
- app/code/community/Conversify/ScriptManager/Helper/Crypt.php +41 -0
- app/code/community/Conversify/ScriptManager/Helper/Data.php +31 -0
- app/code/community/Conversify/ScriptManager/Helper/Orderinfo.php +58 -0
- app/code/community/Conversify/ScriptManager/Helper/Pagetype.php +53 -0
- app/code/community/Conversify/ScriptManager/Helper/Productinfo.php +46 -0
- app/code/community/Conversify/ScriptManager/Helper/Shoppingcart.php +51 -0
- app/code/community/Conversify/ScriptManager/Helper/vendor/GibberishAES.php +437 -0
- app/code/community/Conversify/ScriptManager/Model/Observer.php +13 -0
- app/code/community/Conversify/ScriptManager/etc/adminhtml.xml +22 -0
- app/code/community/Conversify/ScriptManager/etc/config.xml +64 -0
- app/code/community/Conversify/ScriptManager/etc/system.xml +52 -0
- app/design/frontend/base/default/layout/conversifyscriptmanager.xml +19 -0
- app/design/frontend/base/default/template/conversifyscriptmanager/conversion.phtml +15 -0
- app/design/frontend/base/default/template/conversifyscriptmanager/scriptmanager.phtml +22 -0
- app/etc/modules/Conversify_ScriptManager.xml +9 -0
- app/locale/en_US/Conversify_ScriptManager.csv +6 -0
- package.xml +41 -0
app/code/community/Conversify/ScriptManager/Block/Conversion.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Block_Conversion extends Mage_Core_Block_Template
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Render Google Tag Manager script
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
protected function _toHtml()
|
21 |
+
{
|
22 |
+
if (!$this->helper('conversifyscriptmanager')->isConversifyAvailable()) {
|
23 |
+
return '';
|
24 |
+
}
|
25 |
+
|
26 |
+
if (!version_compare(Mage::getVersion(), '1.7', '>=') || (version_compare(Mage::getVersion(), '1.7', '>=') && !Mage::helper('core/cookie')->isUserNotAllowSaveCookie())) {
|
27 |
+
return parent::_toHtml();
|
28 |
+
} else {
|
29 |
+
return '<!--- Conversify not available due to user cookie restrictions --->';
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Conversify/ScriptManager/Block/Scriptmanager.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Block_Scriptmanager extends Mage_Core_Block_Template
|
14 |
+
{
|
15 |
+
|
16 |
+
const DATA_PAGETYPE = 'pagetype';
|
17 |
+
const DATA_CART = 'cart';
|
18 |
+
const DATA_GIBBER = 'gibber';
|
19 |
+
const DATA_PRODUCT = 'product';
|
20 |
+
const DATA_ORDERS = 'orders';
|
21 |
+
const DATA_APIKEY = 'apikey';
|
22 |
+
const DATA_VISITOR = 'visitorinfo';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Render Conversify Script Manager block
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
protected function _toHtml()
|
30 |
+
{
|
31 |
+
if (!$this->helper('conversifyscriptmanager')->isConversifyAvailable()) {
|
32 |
+
return '';
|
33 |
+
}
|
34 |
+
|
35 |
+
if (!version_compare(Mage::getVersion(), '1.7', '>=') || (version_compare(Mage::getVersion(), '1.7', '>=') && !Mage::helper('core/cookie')->isUserNotAllowSaveCookie())) {
|
36 |
+
return parent::_toHtml();
|
37 |
+
} else {
|
38 |
+
return '<!--- Conversify not available due to user cookie restrictions --->';
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Get support data for the Conversify script
|
44 |
+
*
|
45 |
+
* @return array|string
|
46 |
+
*/
|
47 |
+
public function getConversifyData() {
|
48 |
+
/* @var $cHelper Conversify_ScriptManager_Helper_Crypt */
|
49 |
+
$cHelper = $this->helper('conversifyscriptmanager/crypt');
|
50 |
+
|
51 |
+
$CFY = array(
|
52 |
+
self::DATA_CART => $cHelper->gibberCrypt(
|
53 |
+
json_encode(
|
54 |
+
$this->_getCart()
|
55 |
+
)
|
56 |
+
),
|
57 |
+
self::DATA_PRODUCT => (bool) Mage::getStoreConfig(Conversify_ScriptManager_Helper_Data::XML_PATH_STOCK_INFO) ? $cHelper->gibberCrypt(
|
58 |
+
json_encode(
|
59 |
+
$this->_getProductInfo()
|
60 |
+
)
|
61 |
+
) : null,
|
62 |
+
|
63 |
+
/**
|
64 |
+
* DISABLED: CAUSING HIGH LOAD ON SEVERAL SETUPS
|
65 |
+
*/
|
66 |
+
self::DATA_ORDERS => false ? $cHelper->gibberCrypt(
|
67 |
+
json_encode(
|
68 |
+
$this->_getOrderInfo()
|
69 |
+
)
|
70 |
+
) : null,
|
71 |
+
self::DATA_PAGETYPE => $this->getPagetype(),
|
72 |
+
self::DATA_GIBBER => (bool)$cHelper->isGibberCryptSupported()
|
73 |
+
);
|
74 |
+
|
75 |
+
if ($cHelper->isGibberCryptSupported()) {
|
76 |
+
return $cHelper->gibberCrypt(json_encode($CFY));
|
77 |
+
}
|
78 |
+
return $CFY;
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
public function getAPIKey() {
|
83 |
+
return Mage::getStoreConfig(Conversify_ScriptManager_Helper_Data::XML_PATH_APIKEY);
|
84 |
+
}
|
85 |
+
|
86 |
+
public function isGibberish() {
|
87 |
+
return $this->helper('conversifyscriptmanager/crypt')->isGibberCryptSupported();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Getter for the current page type
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
public function getPagetype() {
|
96 |
+
/* @var $pagetypeHelper Conversify_ScriptManager_Helper_Pagetype */
|
97 |
+
$pagetypeHelper = $this->helper('conversifyscriptmanager/pagetype');
|
98 |
+
return $pagetypeHelper->getPageType();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Getter for the cart
|
103 |
+
*
|
104 |
+
* @return array|null|string
|
105 |
+
*/
|
106 |
+
private function _getCart() {
|
107 |
+
try {
|
108 |
+
/* @var $cartHelper Conversify_ScriptManager_Helper_Shoppingcart */
|
109 |
+
$cartHelper = $this->helper('conversifyscriptmanager/shoppingcart');
|
110 |
+
|
111 |
+
return $cartHelper->getCart();
|
112 |
+
} catch (Exception $e) {}
|
113 |
+
return null;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Getter for product info
|
118 |
+
*
|
119 |
+
* @return array|null
|
120 |
+
*/
|
121 |
+
private function _getProductInfo() {
|
122 |
+
try {
|
123 |
+
if ($this->_getPagetype() == 'product') {
|
124 |
+
/* @var $productInfoHelper Conversify_ScriptManager_Helper_Productinfo */
|
125 |
+
$productInfoHelper = $this->helper('conversifyscriptmanager/productinfo');
|
126 |
+
return $productInfoHelper->getProductInfo();
|
127 |
+
}
|
128 |
+
} catch (Exception $e) {}
|
129 |
+
return null;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Getter for order date info
|
134 |
+
*
|
135 |
+
* @return array|null
|
136 |
+
*/
|
137 |
+
private function _getOrderInfo() {
|
138 |
+
try {
|
139 |
+
/* @var $orderInfoHelper Conversify_ScriptManager_Helper_Orderinfo */
|
140 |
+
$orderInfoHelper = $this->helper('conversifyscriptmanager/orderinfo');
|
141 |
+
return $orderInfoHelper->getOrderInfo();
|
142 |
+
} catch (Exception $e) {}
|
143 |
+
return null;
|
144 |
+
}
|
145 |
+
|
146 |
+
}
|
147 |
+
|
148 |
+
|
app/code/community/Conversify/ScriptManager/Helper/Crypt.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
require_once dirname(__FILE__) . '/vendor/GibberishAES.php';
|
14 |
+
|
15 |
+
class Conversify_ScriptManager_Helper_Crypt extends Mage_Core_Helper_Abstract {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Check if the AES encrypting is usable on the current installation
|
19 |
+
*
|
20 |
+
* @return bool
|
21 |
+
*/
|
22 |
+
public function isGibberCryptSupported() {
|
23 |
+
return (function_exists('openssl_encrypt') && version_compare(PHP_VERSION, '5.3.3', '>=')) || function_exists('mcrypt_encrypt');
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Encrypt the data. Returns the unaltered data if encrypting is not supported on the current installation.
|
29 |
+
*
|
30 |
+
* @param string $data
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function gibberCrypt($data) {
|
34 |
+
if ($this->isGibberCryptSupported()) {
|
35 |
+
try {
|
36 |
+
return GibberishAES::enc($data, 'c0nv3rs1fy');
|
37 |
+
} catch (Exception $e) {}
|
38 |
+
}
|
39 |
+
return $data;
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Conversify/ScriptManager/Helper/Data.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Helper_Data extends Mage_Core_Helper_Abstract
|
14 |
+
{
|
15 |
+
const XML_PATH_ACTIVE = 'conversify/global/active';
|
16 |
+
const XML_PATH_APIKEY = 'conversify/global/apikey';
|
17 |
+
const XML_PATH_STOCK_INFO = 'conversify/global/stock_info';
|
18 |
+
const XML_PATH_ORDER_INFO = 'conversify/global/order_info';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Check if the Conversify script loader is enabled
|
22 |
+
*
|
23 |
+
* @param null $store
|
24 |
+
* @return bool
|
25 |
+
*/
|
26 |
+
public function isConversifyAvailable($store = null)
|
27 |
+
{
|
28 |
+
$apikey = Mage::getStoreConfig(self::XML_PATH_APIKEY, $store);
|
29 |
+
return $apikey && Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Conversify/ScriptManager/Helper/Orderinfo.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Helper_Orderinfo extends Mage_Core_Helper_Abstract {
|
14 |
+
|
15 |
+
public function getOrderInfo() {
|
16 |
+
$prodLastOrder = null;
|
17 |
+
|
18 |
+
if (Mage::helper('conversifyscriptmanager/pagetype')->getPageType() == Conversify_ScriptManager_Helper_Pagetype::PAGETYPE_PRODUCT) {
|
19 |
+
/* @var $product Mage_Catalog_Model_Product */
|
20 |
+
$product = Mage::registry('current_product');
|
21 |
+
|
22 |
+
if ($product instanceof Mage_Catalog_Model_Product) {
|
23 |
+
$prodLastOrder = $this->_getLastOrderItemCreatedAt($product->getId());
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
return array(
|
28 |
+
'last_order' => $this->_getLastOrderItemCreatedAt(),
|
29 |
+
'product_last_order' => $prodLastOrder
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param int $product_id
|
35 |
+
* @return Mage_Sales_Model_Order_Item
|
36 |
+
*/
|
37 |
+
private function _getLastOrderItemCreatedAt($product_id = null) {
|
38 |
+
$orderItems = Mage::getModel('sales/order_item')->getCollection()
|
39 |
+
->getSelect()
|
40 |
+
->joinInner(array('order' => Mage::getSingleton('core/resource')->getTableName('sales/order')), 'order.entity_id = main_table.order_id')
|
41 |
+
->order('main_table.order_id DESC')
|
42 |
+
->limit(1);
|
43 |
+
|
44 |
+
if (!is_null($product_id)) {
|
45 |
+
$orderItems->where('product_id=?', $product_id);
|
46 |
+
}
|
47 |
+
|
48 |
+
/* @var $query Varien_Db_Statement_Pdo_Mysql */
|
49 |
+
$query = $orderItems->query();
|
50 |
+
|
51 |
+
$items = $query->fetchAll();
|
52 |
+
if (count($items) > 0) {
|
53 |
+
return strtotime($items[0]['created_at']);
|
54 |
+
}
|
55 |
+
|
56 |
+
return null;
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Conversify/ScriptManager/Helper/Pagetype.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Helper_Pagetype extends Mage_Core_Helper_Abstract {
|
14 |
+
|
15 |
+
const PAGETYPE_PRODUCT = 'product';
|
16 |
+
const PAGETYPE_INDEX = 'index';
|
17 |
+
const PAGETYPE_LIST = 'list';
|
18 |
+
const PAGETYPE_CHECKOUT_PROCESS = 'checkout_process';
|
19 |
+
const PAGETYPE_CHECKOUT_SUCCESS = 'checkout_success';
|
20 |
+
const PAGETYPE_CART = 'shoppingcart';
|
21 |
+
const PAGETYPE_MISC = 'misc';
|
22 |
+
|
23 |
+
public function getPageType() {
|
24 |
+
try {
|
25 |
+
$actionName = strtolower(Mage::app()->getFrontController()->getAction()->getFullActionName());
|
26 |
+
|
27 |
+
switch ($actionName) {
|
28 |
+
case 'cms_index_index';
|
29 |
+
return self::PAGETYPE_INDEX;
|
30 |
+
case 'catalog_category_view':
|
31 |
+
return Mage::registry('current_category') ?
|
32 |
+
self::PAGETYPE_LIST : self::PAGETYPE_MISC;
|
33 |
+
case 'catalog_product_view':
|
34 |
+
return Mage::registry('current_product') ?
|
35 |
+
self::PAGETYPE_PRODUCT : self::PAGETYPE_MISC;
|
36 |
+
case 'checkout_onepage_index':
|
37 |
+
return self::PAGETYPE_CHECKOUT_PROCESS;
|
38 |
+
case 'checkout_onepage_success':
|
39 |
+
return self::PAGETYPE_CHECKOUT_SUCCESS;
|
40 |
+
}
|
41 |
+
} catch (Exception $e) {}
|
42 |
+
|
43 |
+
if (stripos($_SERVER['REQUEST_URI'], '/onestepcheckout') !== false) {
|
44 |
+
return self::PAGETYPE_CHECKOUT_PROCESS;
|
45 |
+
}
|
46 |
+
|
47 |
+
if (stripos($_SERVER['REQUEST_URI'], 'checkout/cart') !== false) {
|
48 |
+
return self::PAGETYPE_CART;
|
49 |
+
}
|
50 |
+
|
51 |
+
return self::PAGETYPE_MISC;
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Conversify/ScriptManager/Helper/Productinfo.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Helper_Productinfo extends Mage_Core_Helper_Abstract {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Retrieve info on the current product (times sold, stock)
|
17 |
+
*
|
18 |
+
* @return array|null
|
19 |
+
*/
|
20 |
+
public function getProductInfo() {
|
21 |
+
/* @var $product Mage_Catalog_Model_Product */
|
22 |
+
$product = Mage::registry('current_product');
|
23 |
+
|
24 |
+
if (!($product instanceof Mage_Catalog_Model_Product)) {
|
25 |
+
return null;
|
26 |
+
}
|
27 |
+
|
28 |
+
/* @var $productCollection Mage_Reports_Model_Resource_Product_Collection */
|
29 |
+
$productCollection = Mage::getResourceModel('reports/product_collection');
|
30 |
+
|
31 |
+
/* @var $catalogInventory Mage_CatalogInventory_Model_Stock_Item */
|
32 |
+
$catalogInventory = Mage::getModel('cataloginventory/stock_item');
|
33 |
+
|
34 |
+
$timesSold = $productCollection
|
35 |
+
->addOrderedQty()
|
36 |
+
->addAttributeToFilter('sku', $product->getSku())
|
37 |
+
->setOrder('ordered_qty', 'desc')
|
38 |
+
->getFirstItem()
|
39 |
+
->ordered_qty;
|
40 |
+
|
41 |
+
return array(
|
42 |
+
'times_sold_alltime' => $timesSold,
|
43 |
+
'stock' => intval($catalogInventory->loadByProduct($product)->getQty())
|
44 |
+
);
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Conversify/ScriptManager/Helper/Shoppingcart.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Helper_Shoppingcart extends Mage_Core_Helper_Abstract {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Get the cart, if there are any contents
|
17 |
+
*
|
18 |
+
* @return array|null
|
19 |
+
*/
|
20 |
+
public function getCart() {
|
21 |
+
/* @var $customerSession Mage_Customer_Model_Session */
|
22 |
+
$customerSession = Mage::getSingleton("customer/session");
|
23 |
+
|
24 |
+
/* @var $cart Mage_Sales_Model_Quote */
|
25 |
+
$cart = Mage::getModel('checkout/cart')->getQuote();
|
26 |
+
|
27 |
+
if (is_null($cart->getGrandTotal())) {
|
28 |
+
return null;
|
29 |
+
}
|
30 |
+
|
31 |
+
$contents = array();
|
32 |
+
foreach ($cart->getAllItems() as $item) {
|
33 |
+
/* @var $item Mage_Sales_Model_Quote_Item */
|
34 |
+
$contents[] = array(
|
35 |
+
'name' => $item->getName(),
|
36 |
+
'sku' => $item->getSku(),
|
37 |
+
'qty' => $item->getQty(),
|
38 |
+
'id' => $item->getProductId(),
|
39 |
+
'price' => $item->getPrice(),
|
40 |
+
'row' => $item->getRowTotal(),
|
41 |
+
'row_tax' => $item->getRowTotalInclTax()
|
42 |
+
);
|
43 |
+
}
|
44 |
+
|
45 |
+
return array(
|
46 |
+
'grand_total' => $cart->getGrandTotal(),
|
47 |
+
'logged_in' => $customerSession->isLoggedIn(),
|
48 |
+
'contents' => $contents
|
49 |
+
);
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Conversify/ScriptManager/Helper/vendor/GibberishAES.php
ADDED
@@ -0,0 +1,437 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* Support module for AES encryption
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Gibberish AES, a PHP Implementation
|
13 |
+
*
|
14 |
+
* See Gibberish AES javascript encryption library, @link https://github.com/mdp/gibberish-aes
|
15 |
+
*
|
16 |
+
* This implementation is based on initial code proposed by nbari at dalmp dot com
|
17 |
+
* @link http://www.php.net/manual/en/function.openssl-decrypt.php#107210
|
18 |
+
*
|
19 |
+
* Requirements:
|
20 |
+
*
|
21 |
+
* OpenSSL functions installed and PHP version >= 5.3.3 (preferred case)
|
22 |
+
* or
|
23 |
+
* Mcrypt functions installed.
|
24 |
+
*
|
25 |
+
* If none of these functions exist, the class will try to use openssl
|
26 |
+
* from the command line (avoid this case).
|
27 |
+
*
|
28 |
+
* Usage:
|
29 |
+
*
|
30 |
+
* // This is a secret key, keep it in a safe place and don't loose it.
|
31 |
+
* $key = 'my secret key';
|
32 |
+
*
|
33 |
+
* // The string to be encrypted.
|
34 |
+
* $string = 'my secret message';
|
35 |
+
*
|
36 |
+
* // This is the result after encryption of the given string.
|
37 |
+
* $encrypted_string = GibberishAES::enc($string, $key);
|
38 |
+
*
|
39 |
+
* // This is the result after decryption of the previously encrypted string.
|
40 |
+
* // $decrypted_string == $string (should be).
|
41 |
+
* $decrypted_string = GibberishAES::dec($encrypted_string, $key);
|
42 |
+
* echo $decrypted_string;
|
43 |
+
*
|
44 |
+
* // The default key-size is 256 bits. 128 and 192 bits are also allowed.
|
45 |
+
* // Example:
|
46 |
+
* $old_key_size = GibberishAES::size();
|
47 |
+
* GibberishAES::size(192);
|
48 |
+
* // The short way: $old_key_size = GibberishAES::size(192);
|
49 |
+
* $encrypted_string = GibberishAES::enc($string, $key);
|
50 |
+
* $decrypted_string = GibberishAES::dec($encrypted_string, $key);
|
51 |
+
* GibberishAES::size($old_key_size);
|
52 |
+
* echo $decrypted_string;
|
53 |
+
*
|
54 |
+
* @author Ivan Tcholakov <ivantcholakov@gmail.com>, 2012-2014.
|
55 |
+
* Code repository: @link https://github.com/ivantcholakov/gibberish-aes-php
|
56 |
+
*
|
57 |
+
* @version 1.1
|
58 |
+
*
|
59 |
+
* @license The MIT License (MIT)
|
60 |
+
* @link http://opensource.org/licenses/MIT
|
61 |
+
*/
|
62 |
+
|
63 |
+
class GibberishAES {
|
64 |
+
|
65 |
+
protected static $key_size = 256; // The default key size in bits
|
66 |
+
protected static $valid_key_sizes = array(128, 192, 256); // Sizes in bits
|
67 |
+
|
68 |
+
protected static $openssl_random_pseudo_bytes_exists = null;
|
69 |
+
protected static $openssl_encrypt_exists = null;
|
70 |
+
protected static $openssl_decrypt_exists = null;
|
71 |
+
protected static $mcrypt_exists = null;
|
72 |
+
protected static $openssl_cli_exists = null;
|
73 |
+
|
74 |
+
// This is a static class, instances are disabled.
|
75 |
+
final private function __construct() {}
|
76 |
+
final private function __clone() {}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Crypt AES (256, 192, 128)
|
80 |
+
*
|
81 |
+
* @param string $string The input message to be encrypted.
|
82 |
+
* @param string $pass The key (string representation).
|
83 |
+
* @return mixed base64 encrypted string, FALSE on failure.
|
84 |
+
*/
|
85 |
+
public static function enc($string, $pass) {
|
86 |
+
|
87 |
+
$key_size = self::$key_size;
|
88 |
+
|
89 |
+
// Set a random salt.
|
90 |
+
$salt = self::random_pseudo_bytes(8);
|
91 |
+
|
92 |
+
$salted = '';
|
93 |
+
$dx = '';
|
94 |
+
|
95 |
+
// Lengths in bytes:
|
96 |
+
$key_length = (int) ($key_size / 8);
|
97 |
+
$block_length = 16; // 128 bits, iv has the same length.
|
98 |
+
// $salted_length = $key_length (32, 24, 16) + $block_length (16) = (48, 40, 32)
|
99 |
+
$salted_length = $key_length + $block_length;
|
100 |
+
|
101 |
+
while (strlen($salted) < $salted_length) {
|
102 |
+
|
103 |
+
$dx = md5($dx.$pass.$salt, true);
|
104 |
+
$salted .= $dx;
|
105 |
+
}
|
106 |
+
|
107 |
+
$key = substr($salted, 0, $key_length);
|
108 |
+
$iv = substr($salted, $key_length, $block_length);
|
109 |
+
|
110 |
+
$encrypted = self::aes_cbc_encrypt($string, $key, $iv);
|
111 |
+
|
112 |
+
return $encrypted !== false ? base64_encode('Salted__'.$salt.$encrypted) : false;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Decrypt AES (256, 192, 128)
|
117 |
+
*
|
118 |
+
* @param string $string The input message to be decrypted.
|
119 |
+
* @param string $pass The key (string representation).
|
120 |
+
* @return mixed base64 decrypted string, FALSE on failure.
|
121 |
+
*/
|
122 |
+
public static function dec($string, $pass) {
|
123 |
+
|
124 |
+
$key_size = self::$key_size;
|
125 |
+
|
126 |
+
// Lengths in bytes:
|
127 |
+
$key_length = (int) ($key_size / 8);
|
128 |
+
$block_length = 16;
|
129 |
+
|
130 |
+
$data = base64_decode($string);
|
131 |
+
$salt = substr($data, 8, 8);
|
132 |
+
$encrypted = substr($data, 16);
|
133 |
+
|
134 |
+
/**
|
135 |
+
* From https://github.com/mdp/gibberish-aes
|
136 |
+
*
|
137 |
+
* Number of rounds depends on the size of the AES in use
|
138 |
+
* 3 rounds for 256
|
139 |
+
* 2 rounds for the key, 1 for the IV
|
140 |
+
* 2 rounds for 128
|
141 |
+
* 1 round for the key, 1 round for the IV
|
142 |
+
* 3 rounds for 192 since it's not evenly divided by 128 bits
|
143 |
+
*/
|
144 |
+
$rounds = 3;
|
145 |
+
if ($key_size == 128) {
|
146 |
+
$rounds = 2;
|
147 |
+
}
|
148 |
+
|
149 |
+
$data00 = $pass.$salt;
|
150 |
+
$md5_hash = array();
|
151 |
+
$md5_hash[0] = md5($data00, true);
|
152 |
+
$result = $md5_hash[0];
|
153 |
+
|
154 |
+
for ($i = 1; $i < $rounds; $i++) {
|
155 |
+
|
156 |
+
$md5_hash[$i] = md5($md5_hash[$i - 1].$data00, true);
|
157 |
+
$result .= $md5_hash[$i];
|
158 |
+
}
|
159 |
+
|
160 |
+
$key = substr($result, 0, $key_length);
|
161 |
+
$iv = substr($result, $key_length, $block_length);
|
162 |
+
|
163 |
+
return self::aes_cbc_decrypt($encrypted, $key, $iv);
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Sets the key-size for encryption/decryption in number of bits
|
168 |
+
* @param mixed $newsize The new key size. The valid integer values are: 128, 192, 256 (default)
|
169 |
+
* $newsize may be NULL or may be omited - in this case
|
170 |
+
* this method is just a getter of the current key size value.
|
171 |
+
* @return integer Returns the old key size value.
|
172 |
+
*/
|
173 |
+
public static function size($newsize = null) {
|
174 |
+
|
175 |
+
$result = self::$key_size;
|
176 |
+
|
177 |
+
if (is_null($newsize)) {
|
178 |
+
return $result;
|
179 |
+
}
|
180 |
+
|
181 |
+
$newsize = (string) $newsize;
|
182 |
+
|
183 |
+
if ($newsize == '') {
|
184 |
+
return $result;
|
185 |
+
}
|
186 |
+
|
187 |
+
$valid_integer = ctype_digit($newsize);
|
188 |
+
|
189 |
+
$newsize = (int) $newsize;
|
190 |
+
|
191 |
+
if (!$valid_integer || !in_array($newsize, self::$valid_key_sizes)) {
|
192 |
+
|
193 |
+
trigger_error(
|
194 |
+
'GibberishAES: Invalid key size value was to be set. It should be integer value (number of bits) amongst: 128, 192, 256.',
|
195 |
+
E_USER_WARNING
|
196 |
+
);
|
197 |
+
|
198 |
+
} else {
|
199 |
+
|
200 |
+
self::$key_size = $newsize;
|
201 |
+
}
|
202 |
+
|
203 |
+
return $result;
|
204 |
+
}
|
205 |
+
|
206 |
+
// Non-public methods ------------------------------------------------------
|
207 |
+
|
208 |
+
protected static function random_pseudo_bytes($length) {
|
209 |
+
|
210 |
+
if (!isset(self::$openssl_random_pseudo_bytes_exists)) {
|
211 |
+
self::$openssl_random_pseudo_bytes_exists = function_exists('openssl_random_pseudo_bytes');
|
212 |
+
}
|
213 |
+
|
214 |
+
if (self::$openssl_random_pseudo_bytes_exists) {
|
215 |
+
return openssl_random_pseudo_bytes($length);
|
216 |
+
}
|
217 |
+
|
218 |
+
// Borrowed from http://phpseclib.com/
|
219 |
+
|
220 |
+
$rnd = '';
|
221 |
+
|
222 |
+
for ($i = 0; $i < $length; $i++) {
|
223 |
+
|
224 |
+
$sha = hash('sha256', mt_rand());
|
225 |
+
$char = mt_rand(0, 30);
|
226 |
+
$rnd .= chr(hexdec($sha[$char].$sha[$char + 1]));
|
227 |
+
}
|
228 |
+
|
229 |
+
return $rnd;
|
230 |
+
}
|
231 |
+
|
232 |
+
protected static function aes_cbc_encrypt($string, $key, $iv) {
|
233 |
+
|
234 |
+
$key_size = self::$key_size;
|
235 |
+
|
236 |
+
if (!isset(self::$openssl_encrypt_exists)) {
|
237 |
+
self::$openssl_encrypt_exists = function_exists('openssl_encrypt')
|
238 |
+
&& version_compare(PHP_VERSION, '5.3.3', '>='); // We need $iv parameter.
|
239 |
+
}
|
240 |
+
|
241 |
+
if (self::$openssl_encrypt_exists) {
|
242 |
+
return openssl_encrypt($string, "aes-$key_size-cbc", $key, true, $iv);
|
243 |
+
}
|
244 |
+
|
245 |
+
if (!isset(self::$mcrypt_exists)) {
|
246 |
+
self::$mcrypt_exists = function_exists('mcrypt_encrypt');
|
247 |
+
}
|
248 |
+
|
249 |
+
if (self::$mcrypt_exists) {
|
250 |
+
|
251 |
+
// Info: http://www.chilkatsoft.com/p/php_aes.asp
|
252 |
+
// http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation
|
253 |
+
|
254 |
+
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
|
255 |
+
|
256 |
+
if (mcrypt_generic_init($cipher, $key, $iv) != -1) {
|
257 |
+
|
258 |
+
$encrypted = mcrypt_generic($cipher, self::pkcs7_pad($string));
|
259 |
+
mcrypt_generic_deinit($cipher);
|
260 |
+
mcrypt_module_close($cipher);
|
261 |
+
|
262 |
+
return $encrypted;
|
263 |
+
}
|
264 |
+
|
265 |
+
return false;
|
266 |
+
}
|
267 |
+
|
268 |
+
if (!isset(self::$openssl_cli_exists)) {
|
269 |
+
self::$openssl_cli_exists = self::openssl_cli_exists();
|
270 |
+
}
|
271 |
+
|
272 |
+
if (self::$openssl_cli_exists) {
|
273 |
+
|
274 |
+
$cmd = 'echo '.self::escapeshellarg($string).' | openssl enc -e -a -A -aes-'.$key_size.'-cbc -K '.self::strtohex($key).' -iv '.self::strtohex($iv);
|
275 |
+
|
276 |
+
exec($cmd, $output, $return);
|
277 |
+
|
278 |
+
if ($return == 0 && isset($output[0])) {
|
279 |
+
return base64_decode($output[0]);
|
280 |
+
}
|
281 |
+
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
|
285 |
+
trigger_error(
|
286 |
+
'GibberishAES: System requirements failure, please, check them.',
|
287 |
+
E_USER_WARNING
|
288 |
+
);
|
289 |
+
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
|
293 |
+
protected static function aes_cbc_decrypt($crypted, $key, $iv) {
|
294 |
+
|
295 |
+
$key_size = self::$key_size;
|
296 |
+
|
297 |
+
if (!isset(self::$openssl_decrypt_exists)) {
|
298 |
+
self::$openssl_decrypt_exists = function_exists('openssl_decrypt')
|
299 |
+
&& version_compare(PHP_VERSION, '5.3.3', '>='); // We need $iv parameter.
|
300 |
+
}
|
301 |
+
|
302 |
+
if (self::$openssl_decrypt_exists) {
|
303 |
+
return openssl_decrypt($crypted, "aes-$key_size-cbc", $key, true, $iv);
|
304 |
+
}
|
305 |
+
|
306 |
+
if (!isset(self::$mcrypt_exists)) {
|
307 |
+
self::$mcrypt_exists = function_exists('mcrypt_encrypt');
|
308 |
+
}
|
309 |
+
|
310 |
+
if (self::$mcrypt_exists) {
|
311 |
+
|
312 |
+
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
|
313 |
+
|
314 |
+
if (mcrypt_generic_init($cipher, $key, $iv) != -1) {
|
315 |
+
|
316 |
+
$decrypted = mdecrypt_generic($cipher, $crypted);
|
317 |
+
mcrypt_generic_deinit($cipher);
|
318 |
+
mcrypt_module_close($cipher);
|
319 |
+
|
320 |
+
return self::remove_pkcs7_pad($decrypted);
|
321 |
+
}
|
322 |
+
|
323 |
+
return false;
|
324 |
+
}
|
325 |
+
|
326 |
+
if (!isset(self::$openssl_cli_exists)) {
|
327 |
+
self::$openssl_cli_exists = self::openssl_cli_exists();
|
328 |
+
}
|
329 |
+
|
330 |
+
if (self::$openssl_cli_exists) {
|
331 |
+
|
332 |
+
$string = base64_encode($crypted);
|
333 |
+
|
334 |
+
$cmd = 'echo '.self::escapeshellarg($string).' | openssl enc -d -a -A -aes-'.$key_size.'-cbc -K '.self::strtohex($key).' -iv '.self::strtohex($iv);
|
335 |
+
|
336 |
+
exec($cmd, $output, $return);
|
337 |
+
|
338 |
+
if ($return == 0 && isset($output[0])) {
|
339 |
+
return $output[0];
|
340 |
+
}
|
341 |
+
|
342 |
+
return false;
|
343 |
+
}
|
344 |
+
|
345 |
+
trigger_error(
|
346 |
+
'GibberishAES: System requirements failure, please, check them.',
|
347 |
+
E_USER_WARNING
|
348 |
+
);
|
349 |
+
|
350 |
+
return false;
|
351 |
+
}
|
352 |
+
|
353 |
+
// See http://www.php.net/manual/en/function.mcrypt-decrypt.php#105985
|
354 |
+
|
355 |
+
protected static function pkcs7_pad($string) {
|
356 |
+
|
357 |
+
$block_length = 16; // 128 bits: $block_length = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
|
358 |
+
$pad = $block_length - (strlen($string) % $block_length);
|
359 |
+
|
360 |
+
return $string.str_repeat(chr($pad), $pad);
|
361 |
+
}
|
362 |
+
|
363 |
+
protected static function remove_pkcs7_pad($string) {
|
364 |
+
|
365 |
+
$block_length = 16; // 128 bits: $block_length = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
|
366 |
+
$len = strlen($string);
|
367 |
+
$pad = ord($string[$len - 1]);
|
368 |
+
|
369 |
+
if ($pad > 0 && $pad <= $block_length) {
|
370 |
+
|
371 |
+
$valid_pad = true;
|
372 |
+
|
373 |
+
for ($i = 1; $i <= $pad; $i++) {
|
374 |
+
|
375 |
+
if (ord($string[$len - $i]) != $pad) {
|
376 |
+
$valid_pad = false;
|
377 |
+
break;
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
if ($valid_pad) {
|
382 |
+
$string = substr($string, 0, $len - $pad);
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
return $string;
|
387 |
+
}
|
388 |
+
|
389 |
+
protected static function openssl_cli_exists() {
|
390 |
+
|
391 |
+
exec('openssl version', $output, $return);
|
392 |
+
|
393 |
+
return $return == 0;
|
394 |
+
}
|
395 |
+
|
396 |
+
protected static function strtohex($string) {
|
397 |
+
|
398 |
+
$result = '';
|
399 |
+
|
400 |
+
foreach (str_split($string) as $c) {
|
401 |
+
$result .= sprintf("%02X", ord($c));
|
402 |
+
}
|
403 |
+
|
404 |
+
return $result;
|
405 |
+
}
|
406 |
+
|
407 |
+
protected static function escapeshellarg($arg) {
|
408 |
+
|
409 |
+
if (strtolower(substr(php_uname('s'), 0, 3 )) == 'win') {
|
410 |
+
|
411 |
+
// See http://stackoverflow.com/questions/6427732/how-can-i-escape-an-arbitrary-string-for-use-as-a-command-line-argument-in-windo
|
412 |
+
|
413 |
+
// Sequence of backslashes followed by a double quote:
|
414 |
+
// double up all the backslashes and escape the double quote
|
415 |
+
$arg = preg_replace('/(\\*)"/g', '$1$1\\"', $arg);
|
416 |
+
|
417 |
+
// Sequence of backslashes followed by the end of the arg,
|
418 |
+
// which will become a double quote later:
|
419 |
+
// double up all the backslashes
|
420 |
+
$arg = preg_replace('/(\\*)$/', '$1$1', $arg);
|
421 |
+
|
422 |
+
// All other backslashes do not need modifying
|
423 |
+
|
424 |
+
// Double-quote the whole thing
|
425 |
+
$arg = '"'.$arg.'"';
|
426 |
+
|
427 |
+
// Escape shell metacharacters.
|
428 |
+
$arg = preg_replace('/([\(\)%!^"<>&|;, ])/g', '^$1', $arg);
|
429 |
+
|
430 |
+
return $arg;
|
431 |
+
}
|
432 |
+
|
433 |
+
// See http://markushedlund.com/dev-tech/php-escapeshellarg-with-unicodeutf-8-support
|
434 |
+
return "'" . str_replace("'", "'\\''", $arg) . "'";
|
435 |
+
}
|
436 |
+
|
437 |
+
}
|
app/code/community/Conversify/ScriptManager/Model/Observer.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Conversify
|
4 |
+
*
|
5 |
+
* This Magento plugin makes it easy to integrate Conversify in your webshop
|
6 |
+
*
|
7 |
+
* @category Conversify
|
8 |
+
* @package Magento Plugin
|
9 |
+
* @author Conversfiy.com
|
10 |
+
* @copyright 2014 Conversify.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Conversify_ScriptManager_Model_Observer{}
|
app/code/community/Conversify/ScriptManager/etc/adminhtml.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<conversify translate="title" module="conversifyscriptmanager">
|
12 |
+
<title>Conversify Script Manager</title>
|
13 |
+
</conversify>
|
14 |
+
</children>
|
15 |
+
</config>
|
16 |
+
</children>
|
17 |
+
</system>
|
18 |
+
</children>
|
19 |
+
</admin>
|
20 |
+
</resources>
|
21 |
+
</acl>
|
22 |
+
</config>
|
app/code/community/Conversify/ScriptManager/etc/config.xml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Conversify_ScriptManager>
|
5 |
+
<version>0.2</version>
|
6 |
+
</Conversify_ScriptManager>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<conversifyscriptmanager>
|
11 |
+
<class>Conversify_ScriptManager_Model</class>
|
12 |
+
</conversifyscriptmanager>
|
13 |
+
</models>
|
14 |
+
<blocks>
|
15 |
+
<conversifyscriptmanager>
|
16 |
+
<class>Conversify_ScriptManager_Block</class>
|
17 |
+
</conversifyscriptmanager>
|
18 |
+
</blocks>
|
19 |
+
<helpers>
|
20 |
+
<conversifyscriptmanager>
|
21 |
+
<class>Conversify_ScriptManager_Helper</class>
|
22 |
+
</conversifyscriptmanager>
|
23 |
+
</helpers>
|
24 |
+
</global>
|
25 |
+
<frontend>
|
26 |
+
<translate>
|
27 |
+
<modules>
|
28 |
+
<Conversify_ScriptManager>
|
29 |
+
<files>
|
30 |
+
<default>Conversify_ScriptManager.csv</default>
|
31 |
+
</files>
|
32 |
+
</Conversify_ScriptManager>
|
33 |
+
</modules>
|
34 |
+
</translate>
|
35 |
+
<layout>
|
36 |
+
<updates>
|
37 |
+
<conversifyscriptmanager>
|
38 |
+
<file>conversifyscriptmanager.xml</file>
|
39 |
+
</conversifyscriptmanager>
|
40 |
+
</updates>
|
41 |
+
</layout>
|
42 |
+
</frontend>
|
43 |
+
<adminhtml>
|
44 |
+
<translate>
|
45 |
+
<modules>
|
46 |
+
<Conversify_ScriptManager>
|
47 |
+
<files>
|
48 |
+
<default>Conversify_ScriptManager.csv</default>
|
49 |
+
</files>
|
50 |
+
</Conversify_ScriptManager>
|
51 |
+
</modules>
|
52 |
+
</translate>
|
53 |
+
</adminhtml>
|
54 |
+
<default>
|
55 |
+
<conversify>
|
56 |
+
<global>
|
57 |
+
<active>1</active>
|
58 |
+
<api_key>{0}</api_key>
|
59 |
+
<stock_info>1</stock_info>
|
60 |
+
<order_info>1</order_info>
|
61 |
+
</global>
|
62 |
+
</conversify>
|
63 |
+
</default>
|
64 |
+
</config>
|
app/code/community/Conversify/ScriptManager/etc/system.xml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<conversify translate="label" module="conversifyscriptmanager">
|
5 |
+
<label>Conversify</label>
|
6 |
+
<tab>service</tab>
|
7 |
+
<frontend_type>text</frontend_type>
|
8 |
+
<sort_order>101</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>1</show_in_store>
|
12 |
+
<groups>
|
13 |
+
<global translate="label">
|
14 |
+
<label>Conversify Script Manager</label>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>100</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>1</show_in_website>
|
19 |
+
<show_in_store>1</show_in_store>
|
20 |
+
<fields>
|
21 |
+
<active translate="label">
|
22 |
+
<label>Enable</label>
|
23 |
+
<frontend_type>select</frontend_type>
|
24 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
25 |
+
<sort_order>10</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>1</show_in_website>
|
28 |
+
<show_in_store>1</show_in_store>
|
29 |
+
</active>
|
30 |
+
<apikey translate="label">
|
31 |
+
<label>API Key (get yours at Conversify.com)</label>
|
32 |
+
<frontend_type>text</frontend_type>
|
33 |
+
<sort_order>20</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
</apikey>
|
38 |
+
<stock_info translate="label">
|
39 |
+
<label>Enable product stock information</label>
|
40 |
+
<frontend_type>select</frontend_type>
|
41 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
42 |
+
<sort_order>30</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
</stock_info>
|
47 |
+
</fields>
|
48 |
+
</global>
|
49 |
+
</groups>
|
50 |
+
</conversify>
|
51 |
+
</sections>
|
52 |
+
</config>
|
app/design/frontend/base/default/layout/conversifyscriptmanager.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<block type="conversifyscriptmanager/scriptmanager" name="conversify_scriptmanager" as="conversify_scriptmanager" template="conversifyscriptmanager/scriptmanager.phtml" />
|
5 |
+
<reference name="head">
|
6 |
+
<action method="append">
|
7 |
+
<name>conversify_scriptmanager</name>
|
8 |
+
</action>
|
9 |
+
</reference>
|
10 |
+
</default>
|
11 |
+
<checkout_onepage_success>
|
12 |
+
<block type="conversifyscriptmanager/conversion" name="conversify_conversion" as="conversify_conversion" template="conversifyscriptmanager/conversion.phtml" />
|
13 |
+
<reference name="before_body_end">
|
14 |
+
<action method="append">
|
15 |
+
<name>conversify_conversion</name>
|
16 |
+
</action>
|
17 |
+
</reference>
|
18 |
+
</checkout_onepage_success>
|
19 |
+
</layout>
|
app/design/frontend/base/default/template/conversifyscriptmanager/conversion.phtml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (!version_compare(Mage::getVersion(), '1.7', '>=') || (version_compare(Mage::getVersion(), '1.7', '>=') && !Mage::helper('core/cookie')->isUserNotAllowSaveCookie())):
|
3 |
+
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
4 |
+
$order = Mage::getModel('sales/order');
|
5 |
+
$order->loadByIncrementId($order_id);
|
6 |
+
$valueInCents = intval(round($order->getGrandTotal() * 100, 0));
|
7 |
+
?>
|
8 |
+
<!-- Conversify Conversion code -->
|
9 |
+
<script type="text/javascript">
|
10 |
+
var Conversify = window.Conversify || [];
|
11 |
+
Conversify.push(["trackConversion", "default", <?php echo $valueInCents; ?>]);
|
12 |
+
</script>
|
13 |
+
<!-- End Conversify Conversion code -->
|
14 |
+
<?php endif; ?>
|
15 |
+
|
app/design/frontend/base/default/template/conversifyscriptmanager/scriptmanager.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $CFY = $this->getConversifyData(); ?>
|
2 |
+
<!-- Conversify API code -->
|
3 |
+
<script type="text/javascript">
|
4 |
+
var Conversify = Conversify || [];
|
5 |
+
<?php if (is_array($CFY)): ?>
|
6 |
+
Conversify.product = "<?php echo $CFY[Conversify_ScriptManager_Block_Scriptmanager::DATA_PRODUCT]; ?>";
|
7 |
+
Conversify.pagetype = "<?php echo $CFY[Conversify_ScriptManager_Block_Scriptmanager::DATA_PAGETYPE]; ?>";
|
8 |
+
Conversify.cart = "<?php echo $CFY[Conversify_ScriptManager_Block_Scriptmanager::DATA_CART]; ?>";
|
9 |
+
Conversify.orders = "<?php echo $CFY[Conversify_ScriptManager_Block_Scriptmanager::DATA_ORDERS]; ?>";
|
10 |
+
<?php else: ?>
|
11 |
+
Conversify.gibberish = "<?php echo $CFY; ?>";
|
12 |
+
Conversify.pagetype = "<?php echo $this->getPagetype();?>";
|
13 |
+
<?php endif; ?>
|
14 |
+
|
15 |
+
(function(d,e,c,cn,f,cfy) {
|
16 |
+
f=d.cookie.split(cn)[1];f=f?f.split(';')[0]:'';
|
17 |
+
cfy=d.createElement("script");cfy.type="text/javascript";cfy.async=true;
|
18 |
+
cfy.src='//js.conversify.com/v2/<?php echo $this->getAPIKey();?>.js?pt='+e(c.pagetype)+'&ut='+e(f)+'&rf='+e(d.referrer||'');
|
19 |
+
(d.getElementsByTagName('head')[0]||d.getElementsByTagName('body')[0]).appendChild(cfy);
|
20 |
+
})(document, window.encodeURIComponent, Conversify, "__conversify_uid=");
|
21 |
+
</script>
|
22 |
+
<!-- End Conversify API code -->
|
app/etc/modules/Conversify_ScriptManager.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Conversify_ScriptManager>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Conversify_ScriptManager>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/en_US/Conversify_ScriptManager.csv
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
API Key,API Key
|
2 |
+
Enable,Enable
|
3 |
+
Conversify,Conversify
|
4 |
+
Conversify Script Manager,Conversify Script Manager
|
5 |
+
Enable Magento default product stock information,Enable Magento default product stock information
|
6 |
+
Enable Conversify visitor stats for messages (current, daily, monthy and weekly views),Enable Conversify visitor stats for messages (current, daily, monthy and weekly views)
|
package.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>conversify</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://choosealicense.com/licenses/no-license/">Copyright 2014 - Conversify BV</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Conversify: Turn shoppers into buyers. We know your visitors like no one else. Free 30-day trial!</summary>
|
10 |
+
<description>Our plugin learns about your visitors and customers during our data collection. The data we collects consists of hundreds of signals. For example:
|
11 |
+

|
12 |
+

|
13 |
+
- Average visit duration\
|
14 |
+
- Visitor path
|
15 |
+
- Time on page
|
16 |
+
- Types of pages visited
|
17 |
+
- Mouse movements
|
18 |
+
- Basket contents
|
19 |
+
- Average conversion value
|
20 |
+
- Returning visits over time
|
21 |
+
- And much more...
|
22 |
+

|
23 |
+
We immediately start analyzing your customers when we receive data from your site. Our data scientists are using the latest techniques in big data analysis & machine learn
|
24 |
+
ing. These algorithms are looking real time at your data and are trying to see patterns amongst your visitors to gain insight in what could be potential revenue uplifts for you. More specifically, they try to cluster your customers in different groups. 
|
25 |
+

|
26 |
+
We are now able to influence your visitors to buy your product.
|
27 |
+

|
28 |
+
One of the ways to influence (we have several tools to influence visitors!) is to show a non-intrusive message on their screen. You’ve probably seen these messages (maybe also one of ours!) on the major booking sites for hotels and some other e-commerce properties. It adapts to the user’s environment (operating system, browser, screen width etc) and grabs the attention with the right message at the right time (thanks to our algorithms). See an example on our site: https://www.conversify.com/how-does-it-work/
|
29 |
+

|
30 |
+
Our promise: simply more revenue, and that’s what we do. We are so confident that we can increase you conversion rate and average revenue per visitor that we give your money back if it doesn’t work.
|
31 |
+

|
32 |
+
Sign up at Conversify.com for your API key.</description>
|
33 |
+
<notes>Optimized production ready release.
|
34 |
+
</notes>
|
35 |
+
<authors><author><name>Conversify.com</name><user>conversify</user><email>info@conversify.com</email></author></authors>
|
36 |
+
<date>2014-10-07</date>
|
37 |
+
<time>13:48:43</time>
|
38 |
+
<contents><target name="magecommunity"><dir name="Conversify"><dir name="ScriptManager"><dir name="Block"><file name="Conversion.php" hash="a46b1e6741e23938812da9f809bd4d5a"/><file name="Scriptmanager.php" hash="7be5414ac97566736255497c2cce402e"/></dir><dir name="Helper"><file name="Crypt.php" hash="ba27bacdeaabb7879372db9b2423b83a"/><file name="Data.php" hash="afae2a7a305821aa7899d1788dfeee44"/><file name="Orderinfo.php" hash="624b84c2d5249626412bcc0448f00ffb"/><file name="Pagetype.php" hash="cc816b448dec978590fe6c12456b05d1"/><file name="Productinfo.php" hash="89960073f1315988fa3f94875c117c32"/><file name="Shoppingcart.php" hash="f6adbde97caed001de4670dc015baa4e"/><dir name="vendor"><file name="GibberishAES.php" hash="08d3c538a81738a731a0f71f7023ad55"/></dir></dir><dir name="Model"><file name="Observer.php" hash="989a2c1e5f2193ad5e90760786857572"/></dir><dir name="etc"><file name="adminhtml.xml" hash="feff6e703461239de97fed63bd037108"/><file name="config.xml" hash="68be366a1659d021f5b37220be3978c5"/><file name="system.xml" hash="40043c990e0996b045d381d1e56f2fbd"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="conversifyscriptmanager.xml" hash="dcd624da6ab311441bb0b0c33e62db45"/></dir><dir name="template"><dir name="conversifyscriptmanager"><file name="conversion.phtml" hash="8aa1a019bef3c062a7178eb1f83dab68"/><file name="scriptmanager.phtml" hash="46fba5373c4b10b5201e6753366fa5e8"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Conversify_ScriptManager.xml" hash="726343acc86ba73b0a20c6eb50fd0825"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Conversify_ScriptManager.csv" hash="72e9bd05bfc8fb47ae196c2534dee277"/></dir></dir></target></contents>
|
39 |
+
<compatible/>
|
40 |
+
<dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
|
41 |
+
</package>
|