Version Notes
Reference API
Improved API key and url validation
Download this release
Release Info
Developer | H5mag |
Extension | h5mage-commerceapi |
Version | 0.0.5 |
Comparing to | |
See all releases |
Code changes from version 0.0.4 to 0.0.5
app/code/community/H5mag/ShopApi/controllers/IndexController.php
CHANGED
@@ -17,19 +17,30 @@
|
|
17 |
* @copyright Copyright (c) 2015 H5mag (http://www.h5mag.com)
|
18 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
class H5mag_ShopApi_IndexController extends Mage_Core_Controller_Front_Action {
|
21 |
private function testHash($hash) {
|
|
|
22 |
$previousHashTime = floor((time()-300)/300);
|
23 |
$currentHashTime = floor(time()/300);
|
24 |
$apiKey = Mage::app()->getStore()->getConfig('h5mag_shopapi_magazine/general/apikey');
|
25 |
-
$previousHash = sha1($apiKey . $previousHashTime);
|
26 |
-
$currentHash = sha1($apiKey . $currentHashTime);
|
27 |
-
|
28 |
-
|
29 |
-
} else if (strlen($previousHash) === strlen($hash) && $previousHash === $hash) {
|
30 |
-
return true;
|
31 |
-
}
|
32 |
-
return false;
|
33 |
}
|
34 |
/**
|
35 |
* Get product and variants
|
17 |
* @copyright Copyright (c) 2015 H5mag (http://www.h5mag.com)
|
18 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
*/
|
20 |
+
|
21 |
+
|
22 |
+
/*
|
23 |
+
hash_equals polyfill from:
|
24 |
+
http://php.net/manual/en/function.hash-equals.php#117101
|
25 |
+
*/
|
26 |
+
if(!function_exists('hash_equals')) {
|
27 |
+
function hash_equals($a, $b) {
|
28 |
+
$ret = strlen($a) ^ strlen($b);
|
29 |
+
$ret |= array_sum(unpack("C*", $a^$b));
|
30 |
+
return !$ret;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
class H5mag_ShopApi_IndexController extends Mage_Core_Controller_Front_Action {
|
35 |
private function testHash($hash) {
|
36 |
+
|
37 |
$previousHashTime = floor((time()-300)/300);
|
38 |
$currentHashTime = floor(time()/300);
|
39 |
$apiKey = Mage::app()->getStore()->getConfig('h5mag_shopapi_magazine/general/apikey');
|
40 |
+
$previousHash = sha1($apiKey . $previousHashTime . 'h5magsthesalt');
|
41 |
+
$currentHash = sha1($apiKey . $currentHashTime . 'h5magsthesalt');
|
42 |
+
|
43 |
+
return hash_equals($hash, $previousHash) || hash_equals($hash, $currentHash);
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
/**
|
46 |
* Get product and variants
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>h5mage-commerceapi</name>
|
4 |
-
<version>0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.h5mag.com">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
@@ -10,11 +10,11 @@
|
|
10 |
<description>Sell your products through your H5mag online magazine</description>
|
11 |
<notes>Reference API
|
12 |

|
13 |
-
|
14 |
<authors><author><name>H5mag</name><user>h5mag</user><email>info@h5mag.com</email></author></authors>
|
15 |
-
<date>2015-09-
|
16 |
-
<time>
|
17 |
-
<contents><target name="mageetc"><dir><dir name="modules"><file name="H5mag_ShopApi.xml" hash="a7f3540be0ca960e3c4342c97ff10611"/></dir></dir></target><target name="magecommunity"><dir><dir name="H5mag"><dir name="ShopApi"><dir name="Model"><file name="Generic.php" hash="ee7230ea0371be754c017a4dbbe370d6"/><dir name="Order"><file name="Observer.php" hash="feeb4b145711fda6d0c62d7b8bda8ba7"/></dir><file name="Product.php" hash="711ce6b1c57e5781f43a812394303cb1"/></dir><dir name="controllers"><file name="CheckoutController.php" hash="703ee86056c7d5a5be99b8e856400046"/><file name="IndexController.php" hash="
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.3.10</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>h5mage-commerceapi</name>
|
4 |
+
<version>0.0.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.h5mag.com">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Sell your products through your H5mag online magazine</description>
|
11 |
<notes>Reference API
|
12 |

|
13 |
+
Improved API key and url validation</notes>
|
14 |
<authors><author><name>H5mag</name><user>h5mag</user><email>info@h5mag.com</email></author></authors>
|
15 |
+
<date>2015-09-18</date>
|
16 |
+
<time>11:19:40</time>
|
17 |
+
<contents><target name="mageetc"><dir><dir name="modules"><file name="H5mag_ShopApi.xml" hash="a7f3540be0ca960e3c4342c97ff10611"/></dir></dir></target><target name="magecommunity"><dir><dir name="H5mag"><dir name="ShopApi"><dir name="Model"><file name="Generic.php" hash="ee7230ea0371be754c017a4dbbe370d6"/><dir name="Order"><file name="Observer.php" hash="feeb4b145711fda6d0c62d7b8bda8ba7"/></dir><file name="Product.php" hash="711ce6b1c57e5781f43a812394303cb1"/></dir><dir name="controllers"><file name="CheckoutController.php" hash="703ee86056c7d5a5be99b8e856400046"/><file name="IndexController.php" hash="0e0cc252bfe0c96dc914dbaede84ec54"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4d5313c01a1c7eb331ec9e14b05de9a3"/><file name="config.xml" hash="49001110e909ff73da3765fb9e6195a7"/><file name="system.xml" hash="751a05e3cd64d5dac4798e128d4cb3dc"/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="h5mag"><dir name="shopapi"><file name="emptycart.phtml" hash="d25f087f78a205332406373418880531"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.3.10</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|