roihunter_easy - Version 1.0.1

Version Notes

Created 28th December, 2016 Compatibility: 1.9.2.4 - Main functions: feed generation, tagging your site for remarketing, creating google ads and much more.

Download this release

Release Info

Developer ROI Hunter
Extension roihunter_easy
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

Files changed (19) hide show
  1. app/code/community/Businessfactory/Roihuntereasy/Block/Adminhtml/Admin.php +5 -0
  2. app/code/community/Businessfactory/Roihuntereasy/Model/AddedToCartObserver.php +0 -1
  3. app/code/community/Businessfactory/Roihuntereasy/Model/CheckoutObserver.php +0 -1
  4. app/code/community/Businessfactory/Roihuntereasy/Model/Cron.php +8 -1
  5. app/code/community/Businessfactory/Roihuntereasy/controllers/Adminhtml/RoihuntereasyController.php +5 -0
  6. app/code/community/Businessfactory/Roihuntereasy/controllers/CronController.php +86 -25
  7. app/code/community/Businessfactory/Roihuntereasy/controllers/FeedController.php +2 -3
  8. app/code/community/Businessfactory/Roihuntereasy/controllers/IndexController.php +0 -6
  9. app/code/community/Businessfactory/Roihuntereasy/controllers/ResetController.php +4 -4
  10. app/code/community/Businessfactory/Roihuntereasy/controllers/RoihuntereasyController.php +5 -0
  11. app/code/community/Businessfactory/Roihuntereasy/controllers/StoredetailsController.php +178 -2
  12. app/design/adminhtml/default/default/template/businessfactory_roihuntereasy/admin.phtml +3 -0
  13. app/design/frontend/{rwd → base}/default/layout/businessfactory_roihuntereasy.xml +0 -0
  14. app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/added_to_cart_view_analytics.phtml +0 -0
  15. app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/category_view_analytics.phtml +0 -0
  16. app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/checkout_analytics.phtml +0 -0
  17. app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/index.phtml +0 -0
  18. app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/product_view_analytics.phtml +0 -0
  19. package.xml +4 -4
app/code/community/Businessfactory/Roihuntereasy/Block/Adminhtml/Admin.php CHANGED
@@ -8,6 +8,11 @@ class Businessfactory_Roihuntereasy_Block_Adminhtml_Admin extends Mage_Adminhtml
8
  $this->store = Mage::app()->getStore();
9
  }
10
 
 
 
 
 
 
11
  public function getStoreBaseUrl()
12
  {
13
  return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
8
  $this->store = Mage::app()->getStore();
9
  }
10
 
11
+ public function getDevelopmentMode()
12
+ {
13
+ return Mage::getIsDeveloperMode() ? "developer" : "production";
14
+ }
15
+
16
  public function getStoreBaseUrl()
17
  {
18
  return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
app/code/community/Businessfactory/Roihuntereasy/Model/AddedToCartObserver.php CHANGED
@@ -32,4 +32,3 @@ class Businessfactory_Roihuntereasy_Model_AddedToCartObserver extends Mage_Core_
32
  }
33
  }
34
  }
35
- ?>
32
  }
33
  }
34
  }
 
app/code/community/Businessfactory/Roihuntereasy/Model/CheckoutObserver.php CHANGED
@@ -49,4 +49,3 @@ class Businessfactory_Roihuntereasy_Model_CheckoutObserver extends Mage_Core_Mod
49
  }
50
  }
51
  }
52
- ?>
49
  }
50
  }
51
  }
 
app/code/community/Businessfactory/Roihuntereasy/Model/Cron.php CHANGED
@@ -18,9 +18,9 @@ class Businessfactory_Roihuntereasy_Model_Cron extends Mage_Core_Model_Abstract
18
  {
19
  Mage::log(__METHOD__ . " cron", null, 'cron.log');
20
  $filename = "businessFactoryRoiHunterEasyFeedSign";
 
21
 
22
  try {
23
- $io = new Varien_Io_File();
24
  $io->setAllowCreateFolders(true);
25
  $io->open(array('path' => Mage::getBaseDir()));
26
 
@@ -39,6 +39,8 @@ class Businessfactory_Roihuntereasy_Model_Cron extends Mage_Core_Model_Abstract
39
  // Delete file
40
  $io->rm($filename);
41
 
 
 
42
  return true;
43
  } catch (Exception $exception) {
44
  Mage::log(__METHOD__ . " exception.", null, 'errors.log');
@@ -47,6 +49,8 @@ class Businessfactory_Roihuntereasy_Model_Cron extends Mage_Core_Model_Abstract
47
  // Try delete file also when exception occurred.
48
  try {
49
  $io->rm($filename);
 
 
50
  } catch (Exception $exception) {
51
  Mage::log(__METHOD__ . " exception.", null, 'errors.log');
52
  Mage::log($exception, null, 'errors.log');
@@ -160,6 +164,9 @@ class Businessfactory_Roihuntereasy_Model_Cron extends Mage_Core_Model_Abstract
160
  } catch (Exception $e) {
161
  Mage::throwException($e);
162
  }
 
 
 
163
  return true;
164
  }
165
 
18
  {
19
  Mage::log(__METHOD__ . " cron", null, 'cron.log');
20
  $filename = "businessFactoryRoiHunterEasyFeedSign";
21
+ $io = new Varien_Io_File();
22
 
23
  try {
 
24
  $io->setAllowCreateFolders(true);
25
  $io->open(array('path' => Mage::getBaseDir()));
26
 
39
  // Delete file
40
  $io->rm($filename);
41
 
42
+ $io->close();
43
+
44
  return true;
45
  } catch (Exception $exception) {
46
  Mage::log(__METHOD__ . " exception.", null, 'errors.log');
49
  // Try delete file also when exception occurred.
50
  try {
51
  $io->rm($filename);
52
+
53
+ $io->close();
54
  } catch (Exception $exception) {
55
  Mage::log(__METHOD__ . " exception.", null, 'errors.log');
56
  Mage::log($exception, null, 'errors.log');
164
  } catch (Exception $e) {
165
  Mage::throwException($e);
166
  }
167
+
168
+ $io->close();
169
+
170
  return true;
171
  }
172
 
app/code/community/Businessfactory/Roihuntereasy/controllers/Adminhtml/RoihuntereasyController.php CHANGED
@@ -11,5 +11,10 @@ class Businessfactory_Roihuntereasy_Adminhtml_RoihuntereasyController extends Ma
11
  $result = 1;
12
  Mage::app()->getResponse()->setBody($result);
13
  }
 
 
 
 
 
14
  }
15
 
11
  $result = 1;
12
  Mage::app()->getResponse()->setBody($result);
13
  }
14
+
15
+ protected function _isAllowed()
16
+ {
17
+ return Mage::getSingleton('admin/session')->isAllowed('businessfactory/businessfactory_roihuntereasy');
18
+ }
19
  }
20
 
app/code/community/Businessfactory/Roihuntereasy/controllers/CronController.php CHANGED
@@ -25,7 +25,34 @@ class Businessfactory_Roihuntereasy_CronController extends Mage_Core_Controller_
25
  $response->setHeader('Access-Control-Allow-Headers', 'X-Authorization', true);
26
 
27
  if ($request->getMethod() === 'GET') {
28
- $this->processGET();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  } else if ($request->getMethod() === 'OPTIONS') {
30
 
31
  } else {
@@ -34,39 +61,73 @@ class Businessfactory_Roihuntereasy_CronController extends Mage_Core_Controller_
34
  }
35
 
36
  /**
37
- * GET
38
- * http://store.com/roihuntereasy/cron/index
39
  */
40
- function processGET()
41
  {
 
 
42
  $request = $this->getRequest();
43
  $response = $this->getResponse();
44
 
45
- try {
46
- $authorizationHeader = $request->getHeader('X-Authorization');
47
 
48
- $mainItemCollection = Mage::getModel('businessfactory_roihuntereasy/main')->getCollection();
49
- $clientToken = $mainItemCollection->getLastItem()->getClientToken();
50
- if ($clientToken == NULL || $clientToken !== $authorizationHeader) {
51
- $response->setBody(json_encode("Not authorized"));
52
- $response->setHttpResponseCode(403);
53
- return;
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- Mage::log("Cron generating started manually.", null, 'cron.log');
57
- $resultCode = $this->cron->createFeed();
58
- if($resultCode == true){
59
- $response->setBody(json_encode('Feed generated.'));
60
- } else {
61
- $response->setBody(json_encode('Feed not generated.'));
 
 
 
 
 
 
 
62
  }
63
- } catch (Exception $exception) {
64
- Mage::log(__METHOD__ . " exception.", null, 'errors.log');
65
- Mage::log($exception, null, 'errors.log');
66
- Mage::log($request, null, 'errors.log');
67
- $response->setHttpResponseCode(500);
68
- $response->setBody(json_encode('Feed generation failed.'));
69
  }
70
  }
 
71
  }
72
 
25
  $response->setHeader('Access-Control-Allow-Headers', 'X-Authorization', true);
26
 
27
  if ($request->getMethod() === 'GET') {
28
+ $request = $this->getRequest();
29
+ $response = $this->getResponse();
30
+
31
+ try {
32
+ $authorizationHeader = $request->getHeader('X-Authorization');
33
+
34
+ $mainItemCollection = Mage::getModel('businessfactory_roihuntereasy/main')->getCollection();
35
+ $clientToken = $mainItemCollection->getLastItem()->getClientToken();
36
+ if ($clientToken == NULL || $clientToken !== $authorizationHeader) {
37
+ $response->setBody(json_encode("Not authorized"));
38
+ $response->setHttpResponseCode(403);
39
+ return;
40
+ }
41
+
42
+ Mage::log("Cron generating started manually.", null, 'cron.log');
43
+ $resultCode = $this->cron->createFeed();
44
+ if($resultCode == true){
45
+ $response->setBody(json_encode('Feed generated.'));
46
+ } else {
47
+ $response->setBody(json_encode('Feed not generated.'));
48
+ }
49
+ } catch (Exception $exception) {
50
+ Mage::log(__METHOD__ . " exception.", null, 'errors.log');
51
+ Mage::log($exception, null, 'errors.log');
52
+ Mage::log($request, null, 'errors.log');
53
+ $response->setHttpResponseCode(500);
54
+ $response->setBody(json_encode('Feed generation failed.'));
55
+ }
56
  } else if ($request->getMethod() === 'OPTIONS') {
57
 
58
  } else {
61
  }
62
 
63
  /**
64
+ * http://store.com/roihuntereasy/cron/init
 
65
  */
66
+ public function initAction()
67
  {
68
+ Mage::log(__METHOD__ . "- FeedReset called.");
69
+
70
  $request = $this->getRequest();
71
  $response = $this->getResponse();
72
 
73
+ Mage::log($request);
 
74
 
75
+ $response->setHeader('Content-type', 'application/json');
76
+ $response->setHeader('Access-Control-Allow-Origin', '*', true);
77
+ $response->setHeader('Access-Control-Allow-Methods', 'OPTIONS,GET', true);
78
+ $response->setHeader('Access-Control-Max-Age', '60', true);
79
+ $response->setHeader('Access-Control-Allow-Headers', 'X-Authorization', true);
80
+
81
+ if ($request->getMethod() === 'GET') {
82
+ try {
83
+ // If table not empty, require authorization.
84
+ $mainItemCollection = Mage::getModel('businessfactory_roihuntereasy/main')->getCollection();
85
+ if ($mainItemCollection->count() > 0) {
86
+ $authorizationHeader = $this->getRequest()->getHeader('X-Authorization');
87
+ $dataEntity = $mainItemCollection->getLastItem();
88
+ // If data exist check for client token.
89
+ if ($dataEntity->getClientToken() != null && $dataEntity->getClientToken() !== $authorizationHeader) {
90
+ $response->setBody(json_encode("Not authorized"));
91
+ $response->setHttpResponseCode(403);
92
+ return;
93
+ }
94
+ }
95
+
96
+ $filename = "businessFactoryRoiHunterEasyFeedSign";
97
+ $io = new Varien_Io_File();
98
+ $io->open(array('path' => Mage::getBaseDir()));
99
+
100
+ if (!$io->fileExists($filename)) {
101
+ $response->setBody(json_encode("Reset already completed."));
102
+ }
103
+ else {
104
+ // try to delete feed generation sign.
105
+ $io->rm($filename);
106
+ $response->setBody(json_encode("Reset completed."));
107
+ }
108
+
109
+ $io->close();
110
 
111
+ Mage::log("Cron generating started manually.", null, 'cron.log');
112
+ $resultCode = $this->cron->createFeed();
113
+ if($resultCode == true){
114
+ $response->setBody(json_encode('Feed generated.'));
115
+ } else {
116
+ $response->setBody(json_encode('Feed not generated.'));
117
+ }
118
+ } catch (Exception $exception) {
119
+ Mage::log(__METHOD__ . " exception.", null, 'errors.log');
120
+ Mage::log($exception, null, 'errors.log');
121
+ Mage::log($request, null, 'errors.log');
122
+ $response->setHttpResponseCode(500);
123
+ $response->setBody(json_encode('Feed generation failed.'));
124
  }
125
+ } else if ($request->getMethod() === 'OPTIONS') {
126
+
127
+ } else {
128
+ $response->setHttpResponseCode(400);
 
 
129
  }
130
  }
131
+
132
  }
133
 
app/code/community/Businessfactory/Roihuntereasy/controllers/FeedController.php CHANGED
@@ -17,13 +17,12 @@ class Businessfactory_Roihuntereasy_FeedController extends Mage_Core_Controller_
17
  header('Cache-Control: must-revalidate');
18
  header('Pragma: public');
19
  readfile($file);
20
- exit;
21
  }
22
  else {
23
  Mage::log("Product feed file does not exist.", null, 'feed.log');
24
  $this->getResponse()->setHttpResponseCode(404);
25
  $this->getResponse()->setBody(json_encode(
26
- ['error_message' => 'Feed not found. Please look to log file for more information.']
27
  ));
28
  }
29
  } catch (Exception $exception) {
@@ -33,7 +32,7 @@ class Businessfactory_Roihuntereasy_FeedController extends Mage_Core_Controller_
33
 
34
  $this->getResponse()->setHttpResponseCode(500);
35
  $this->getResponse()->setBody(json_encode(
36
- ['error_message' => 'Cannot return feed. Please look to log file for more information.']
37
  ));
38
  }
39
  }
17
  header('Cache-Control: must-revalidate');
18
  header('Pragma: public');
19
  readfile($file);
 
20
  }
21
  else {
22
  Mage::log("Product feed file does not exist.", null, 'feed.log');
23
  $this->getResponse()->setHttpResponseCode(404);
24
  $this->getResponse()->setBody(json_encode(
25
+ array('error_message' => 'Feed not found. Please look to log file for more information.')
26
  ));
27
  }
28
  } catch (Exception $exception) {
32
 
33
  $this->getResponse()->setHttpResponseCode(500);
34
  $this->getResponse()->setBody(json_encode(
35
+ array('error_message' => 'Cannot return feed. Please look to log file for more information.')
36
  ));
37
  }
38
  }
app/code/community/Businessfactory/Roihuntereasy/controllers/IndexController.php CHANGED
@@ -4,14 +4,8 @@ class Businessfactory_Roihuntereasy_IndexController extends Mage_Core_Controller
4
  {
5
  public function indexAction()
6
  {
7
- echo "<h1>Hello Holly.</h1>";
8
  $this->loadLayout();
9
  $this->renderLayout();
10
  }
11
-
12
- public function mamethodeAction()
13
- {
14
- echo "test mamethode";
15
- }
16
  }
17
 
4
  {
5
  public function indexAction()
6
  {
 
7
  $this->loadLayout();
8
  $this->renderLayout();
9
  }
 
 
 
 
 
10
  }
11
 
app/code/community/Businessfactory/Roihuntereasy/controllers/ResetController.php CHANGED
@@ -28,13 +28,13 @@ class Businessfactory_Roihuntereasy_ResetController extends Mage_Core_Controller
28
  $client->setMethod(Varien_Http_Client::GET);
29
  $client->setConfig(array(
30
  'adapter' => 'Zend_Http_Client_Adapter_Curl',
31
- 'curloptions' => [CURLOPT_FOLLOWLOCATION => true],
32
  'maxredirects' => 5,
33
  'timeout' => 60
34
  ));
35
- $client->setHeaders([
36
  'X-Authorization' => $accessToken
37
- ]);
38
 
39
  try{
40
  $goostav_response = $client->request();
@@ -76,7 +76,7 @@ class Businessfactory_Roihuntereasy_ResetController extends Mage_Core_Controller
76
  else {
77
  return $response->setBody(json_encode("Reset already completed."));
78
  }
79
-
80
  } catch (Exception $e) {
81
  Mage::log($e, null, 'errors.log');
82
  return $response->setBody(json_encode("Reset cron failed. Please check logs and contact support at easy@roihunter.com."));
28
  $client->setMethod(Varien_Http_Client::GET);
29
  $client->setConfig(array(
30
  'adapter' => 'Zend_Http_Client_Adapter_Curl',
31
+ 'curloptions' => array(CURLOPT_FOLLOWLOCATION => true),
32
  'maxredirects' => 5,
33
  'timeout' => 60
34
  ));
35
+ $client->setHeaders(array(
36
  'X-Authorization' => $accessToken
37
+ ));
38
 
39
  try{
40
  $goostav_response = $client->request();
76
  else {
77
  return $response->setBody(json_encode("Reset already completed."));
78
  }
79
+ $io->close();
80
  } catch (Exception $e) {
81
  Mage::log($e, null, 'errors.log');
82
  return $response->setBody(json_encode("Reset cron failed. Please check logs and contact support at easy@roihunter.com."));
app/code/community/Businessfactory/Roihuntereasy/controllers/RoihuntereasyController.php CHANGED
@@ -8,4 +8,9 @@ class Businessfactory_Roihuntereasy_RoihuntereasyController extends Mage_Adminht
8
  $this->loadLayout()->_setActiveMenu('businessfactory');
9
  $this->renderLayout();
10
  }
 
 
 
 
 
11
  }
8
  $this->loadLayout()->_setActiveMenu('businessfactory');
9
  $this->renderLayout();
10
  }
11
+
12
+ protected function _isAllowed()
13
+ {
14
+ return Mage::getSingleton('admin/session')->isAllowed('businessfactory/businessfactory_roihuntereasy');
15
+ }
16
  }
app/code/community/Businessfactory/Roihuntereasy/controllers/StoredetailsController.php CHANGED
@@ -4,12 +4,187 @@ class Businessfactory_Roihuntereasy_StoredetailsController extends Mage_Core_Con
4
  {
5
  public function indexAction()
6
  {
7
- echo "<h1>Hello Store Details.</h1>";
8
-
9
  $this->loadLayout();
10
  $this->renderLayout();
11
  }
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  /**
14
  * http://store.com/roihuntereasy/storedetails/state
15
  */
@@ -295,6 +470,7 @@ class Businessfactory_Roihuntereasy_StoredetailsController extends Mage_Core_Con
295
  $io->streamWrite($content);
296
  $io->streamClose();
297
 
 
298
  // Nginx - check if it is necessary to create file in public folder
299
 
300
  } else {
4
  {
5
  public function indexAction()
6
  {
 
 
7
  $this->loadLayout();
8
  $this->renderLayout();
9
  }
10
 
11
+ /**
12
+ * http://store.com/roihuntereasy/storedetails/check
13
+ */
14
+ public function checkAction()
15
+ {
16
+ Mage::log(__METHOD__ . "- Check called.");
17
+
18
+ $request = $this->getRequest();
19
+ $response = $this->getResponse();
20
+
21
+ $response->setHeader('Content-type', 'application/json');
22
+ $response->setHeader('Access-Control-Allow-Origin', '*', true);
23
+ $response->setHeader('Access-Control-Allow-Methods', 'OPTIONS,GET,POST', true);
24
+ $response->setHeader('Access-Control-Max-Age', '60', true);
25
+ $response->setHeader('Access-Control-Allow-Headers', 'X-Authorization', true);
26
+
27
+ $response->setBody(json_encode("rh-easy-active."));
28
+ }
29
+
30
+ /**
31
+ * http://store.com/roihuntereasy/storedetails/check
32
+ */
33
+ public function debugAction()
34
+ {
35
+ Mage::log(__METHOD__ . "- Debug called.");
36
+
37
+ $request = $this->getRequest();
38
+ $response = $this->getResponse();
39
+
40
+ $response->setHeader('Content-type', 'application/json');
41
+ $response->setHeader('Access-Control-Allow-Origin', '*', true);
42
+ $response->setHeader('Access-Control-Allow-Methods', 'OPTIONS,GET,POST', true);
43
+ $response->setHeader('Access-Control-Max-Age', '60', true);
44
+ $response->setHeader('Access-Control-Allow-Headers', 'X-Authorization', true);
45
+
46
+ if ($request->getMethod() === 'GET') {
47
+ $this->processDebugGET();
48
+ }
49
+ }
50
+
51
+ /**
52
+ * GET
53
+ * http://store.com/roihuntereasy/storedetails/debug
54
+ *
55
+ */
56
+ function processDebugGET()
57
+ {
58
+ $request = $this->getRequest();
59
+ $response = $this->getResponse();
60
+
61
+ try {
62
+ // If table not empty, require authorization.
63
+ $mainItemCollection = Mage::getModel('businessfactory_roihuntereasy/main')->getCollection();
64
+ if ($mainItemCollection->count() > 0) {
65
+ $authorizationHeader = $this->getRequest()->getHeader('X-Authorization');
66
+ $dataEntity = $mainItemCollection->getLastItem();
67
+ // If data exist check for client token.
68
+ if ($dataEntity->getClientToken() != null && $dataEntity->getClientToken() !== $authorizationHeader) {
69
+ $response->setBody(json_encode("Not authorized"));
70
+ $response->setHttpResponseCode(403);
71
+ return;
72
+ }
73
+ }
74
+
75
+ $resultData = $_SERVER;
76
+ $resultData['Magento_Mode'] = Mage::getIsDeveloperMode() ? "developer" : "production";;
77
+ $resultData['Php_Version'] = phpversion();
78
+
79
+ $response->setBody(json_encode($resultData));
80
+ } catch (Exception $exception) {
81
+ Mage::log(__METHOD__ . " exception.", null, 'errors.log');
82
+ Mage::log($exception, null, 'errors.log');
83
+ Mage::log($request, null, 'errors.log');
84
+ $response->setHttpResponseCode(500);
85
+ }
86
+ }
87
+
88
+ /**
89
+ * http://store.com/roihuntereasy/storedetails/logs
90
+ */
91
+ public function logsAction()
92
+ {
93
+ Mage::log(__METHOD__ . "- Debug called.", 'debug.log');
94
+
95
+ $request = $this->getRequest();
96
+ $response = $this->getResponse();
97
+
98
+ $response->setHeader('Content-type', 'application/json');
99
+ $response->setHeader('Access-Control-Allow-Origin', '*', true);
100
+ $response->setHeader('Access-Control-Allow-Methods', 'OPTIONS,GET,POST', true);
101
+ $response->setHeader('Access-Control-Max-Age', '60', true);
102
+ $response->setHeader('Access-Control-Allow-Headers', 'X-Authorization', true);
103
+
104
+ if ($request->getMethod() === 'GET') {
105
+ $this->processLogsGET();
106
+ }
107
+ }
108
+
109
+ /**
110
+ * GET
111
+ * http://store.com/roihuntereasy/storedetails/logs
112
+ *
113
+ */
114
+ function processLogsGET()
115
+ {
116
+ $request = $this->getRequest();
117
+ $response = $this->getResponse();
118
+
119
+ try {
120
+ // If table not empty, require authorization.
121
+ $mainItemCollection = Mage::getModel('businessfactory_roihuntereasy/main')->getCollection();
122
+ if ($mainItemCollection->count() > 0) {
123
+ $authorizationHeader = $this->getRequest()->getHeader('X-Authorization');
124
+ $dataEntity = $mainItemCollection->getLastItem();
125
+ // If data exist check for client token.
126
+ if ($dataEntity->getClientToken() != null && $dataEntity->getClientToken() !== $authorizationHeader) {
127
+ $response->setBody(json_encode("Not authorized"));
128
+ $response->setHttpResponseCode(403);
129
+ return;
130
+ }
131
+ }
132
+
133
+ $zipFilename = "all_logs.zip";
134
+ $rootPath = Mage::getBaseDir('log');
135
+ $zipAbsolutePath = $rootPath . '/' . $zipFilename;
136
+
137
+
138
+ $zip = new ZipArchive();
139
+ if ($zip->open($zipAbsolutePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
140
+ Mage::log("cannot open zip", null);
141
+ $response->setBody("cannot open zip");
142
+ return;
143
+ }
144
+ else {
145
+ Mage::log("zip opened", null);
146
+ }
147
+
148
+ // Create recursive directory iterator
149
+ /** @var SplFileInfo[] $files */
150
+ $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath),
151
+ RecursiveIteratorIterator::LEAVES_ONLY);
152
+
153
+ foreach ($files as $name => $file) {
154
+ // Skip directories (they would be added automatically)
155
+ if (!$file->isDir() && strpos($file->getFilename(), 'all_logs.zip') === false) {
156
+ // Get real and relative path for current file
157
+ $filePath = $file->getRealPath();
158
+ $relativePath = substr($filePath, strlen($rootPath));
159
+ // Add current file to archive
160
+ if ($zip->addFile($filePath, $relativePath) !== true) {
161
+ Mage::log("cannot add file to zip", null, 'cro.log');
162
+ $response->setBody("cannot add file to zip");
163
+ return;
164
+ }
165
+ else {
166
+ Mage::log("added file to zip", null, 'cro.log');
167
+ }
168
+ }
169
+ }
170
+ // Zip archive will be created only after closing object
171
+ $zip->close();
172
+
173
+ header('Content-Description: File Transfer');
174
+ header('Content-Type: application/octet-stream');
175
+ header('Content-Disposition: attachment; filename="' . basename($zipAbsolutePath) .'"');
176
+ header('Expires: 0');
177
+ header('Cache-Control: must-revalidate');
178
+ header('Pragma: public');
179
+ readfile($zipAbsolutePath);
180
+ } catch (Exception $exception) {
181
+ Mage::log(__METHOD__ . " exception.", null, 'errors.log');
182
+ Mage::log($exception, null, 'errors.log');
183
+ Mage::log($request, null, 'errors.log');
184
+ $response->setHttpResponseCode(500);
185
+ }
186
+ }
187
+
188
  /**
189
  * http://store.com/roihuntereasy/storedetails/state
190
  */
470
  $io->streamWrite($content);
471
  $io->streamClose();
472
 
473
+ $io->close();
474
  // Nginx - check if it is necessary to create file in public folder
475
 
476
  } else {
app/design/adminhtml/default/default/template/businessfactory_roihuntereasy/admin.phtml CHANGED
@@ -36,7 +36,9 @@
36
  var status = "<?php echo($this->getMainItemEntry() ? $this->getMainItemEntry()->getStatus() : null); ?>";
37
  var errors = "<?php echo($this->getMainItemEntry() ? $this->getMainItemEntry()->getErrors() : null); ?>";
38
  var creationState = "<?php echo($this->getMainItemEntry() ? $this->getMainItemEntry()->getCreationState() : null); ?>";
 
39
 
 
40
 
41
  var iFrame = document.getElementById('RoihuntereasyIFrame');
42
  var loadingMessageEl = document.getElementById('loadingMessage');
@@ -53,6 +55,7 @@
53
  "storeCurrency": storeCurrency,
54
  "storeLanguage": storeLanguage,
55
  "storeCountry": storeCountry,
 
56
 
57
  // Database part
58
  "customerId": customerId,
36
  var status = "<?php echo($this->getMainItemEntry() ? $this->getMainItemEntry()->getStatus() : null); ?>";
37
  var errors = "<?php echo($this->getMainItemEntry() ? $this->getMainItemEntry()->getErrors() : null); ?>";
38
  var creationState = "<?php echo($this->getMainItemEntry() ? $this->getMainItemEntry()->getCreationState() : null); ?>";
39
+ var magentoMode = "<?php echo $this->getDevelopmentMode(); ?>";
40
 
41
+ console.log("mode" + magentoMode)
42
 
43
  var iFrame = document.getElementById('RoihuntereasyIFrame');
44
  var loadingMessageEl = document.getElementById('loadingMessage');
55
  "storeCurrency": storeCurrency,
56
  "storeLanguage": storeLanguage,
57
  "storeCountry": storeCountry,
58
+ "magentoMode": magentoMode,
59
 
60
  // Database part
61
  "customerId": customerId,
app/design/frontend/{rwd → base}/default/layout/businessfactory_roihuntereasy.xml RENAMED
File without changes
app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/added_to_cart_view_analytics.phtml RENAMED
File without changes
app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/category_view_analytics.phtml RENAMED
File without changes
app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/checkout_analytics.phtml RENAMED
File without changes
app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/index.phtml RENAMED
File without changes
app/design/frontend/{rwd → base}/default/template/businessfactory_roihuntereasy/product_view_analytics.phtml RENAMED
File without changes
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>roihunter_easy</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>AFL 3.0</license>
7
  <channel>community</channel>
@@ -42,9 +42,9 @@ No contract duration&amp;#xD;&#xD;
42
  * Extension do not cover your Google Adwords Ad Spend. </description>
43
  <notes>Created 28th December, 2016 Compatibility: 1.9.2.4 - Main functions: feed generation, tagging your site for remarketing, creating google ads and much more.</notes>
44
  <authors><author><name>ROI Hunter</name><user>MAG003490427</user><email>petr.skornok@b.cz</email></author></authors>
45
- <date>2017-01-10</date>
46
- <time>09:12:41</time>
47
- <contents><target name="magecommunity"><dir name="Businessfactory"><dir name="Roihuntereasy"><dir name="Block"><file name="AddedToCartAnalytics.php" hash="eeb701f487b06ed82e0754aefb192fab"/><dir name="Adminhtml"><file name="Admin.php" hash="6cc0936cb52dde8cf2419f23974410a8"/><dir name="System"><dir name="Config"><file name="Cronbutton.php" hash="a07a6cfbd52a9a96fb4ec78cc8270924"/><file name="Resetbutton.php" hash="7721bb62feafe5d9d2951e70bfb0c30e"/></dir></dir></dir><file name="CategoryViewAnalytics.php" hash="739f1993bbc42c5df4b1a96956e97770"/><file name="CheckoutAnalytics.php" hash="831094424cf896e6644d66b0c70c3688"/><file name="Database.php" hash="4333ce4f66b762097cb50b4f04a7a4d2"/><file name="ProductViewAnalytics.php" hash="033e6702927d92ae5f2d388f00b46bd5"/></dir><dir name="Helper"><file name="Data.php" hash="05ee8de6f74805d4a2b4643b0b0fe33a"/></dir><dir name="Model"><file name="AddedToCartObserver.php" hash="904468a570b1d4f24862a0fe0e46ea59"/><file name="CheckoutObserver.php" hash="9088d55f2384a9dd3e4cc8b77d8b63ca"/><file name="Cron.php" hash="dec77226a3ec0c081c50fc53b7131b16"/><file name="Main.php" hash="06766b59391b52aaa701d8bf01e80d1a"/><file name="Options.php" hash="f6ecd5ab10cfcc5e0948b236bb873932"/><dir name="Resource"><dir name="Main"><file name="Collection.php" hash="9b66b73b312ac16e270c1435a789fdb9"/></dir><file name="Main.php" hash="1432c450ff554fb5057d1d6c4fd26c3c"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RoihuntereasyController.php" hash="ecb41ae805a34ef450e849da610fc2ed"/></dir><file name="CronController.php" hash="3bebd548376a9bf7cf26689ca903f441"/><file name="FeedController.php" hash="7284f777ef57cd027fd70074195c6979"/><file name="IndexController.php" hash="6201b3c08113a1fb220dc3601dcbe43d"/><file name="ResetController.php" hash="91e83d54fd5e85e0acd7e3d001fcee98"/><file name="RoihuntereasyController.php" hash="68612c9bef815ce8b1bc2048a31a9721"/><file name="StoredetailsController.php" hash="1a2d7bd8e89fc7a7647da3140965b479"/></dir><dir name="etc"><file name="adminhtml.xml" hash="bbab6af370448895030570a657469a15"/><file name="config.xml" hash="4b044240a4b1e4081250b429400681f9"/><file name="system.xml" hash="718ea25db00b6a500b8783f9c8e1ba5c"/></dir><dir name="sql"><dir name="businessfactory_roihuntereasy_setup"><file name="install-1.0.0.php" hash="f490ddfd229eb5680e68fb7ec55a5820"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="businessfactory_roihuntereasy.xml" hash="fa2e345d2461459e15c641731d1b114a"/></dir><dir name="template"><dir name="businessfactory_roihuntereasy"><file name="admin.phtml" hash="142ab9a7c4119f0b47c228fb831737bf"/><dir name="system"><dir name="config"><file name="cronbutton.phtml" hash="758b97b5da81c92aaeb175e4b0142288"/><file name="resetbutton.phtml" hash="7aedce71c5d21bfce1a08c77e603143d"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="rwd"><dir name="default"><dir name="layout"><file name="businessfactory_roihuntereasy.xml" hash="e1379f4d0a022d6740d0a6d96fd9fbed"/></dir><dir name="template"><dir name="businessfactory_roihuntereasy"><file name="added_to_cart_view_analytics.phtml" hash="8679d7940136d046ce46d2bc9aa2b522"/><file name="category_view_analytics.phtml" hash="420fe9c183c444e655250efa0b037da4"/><file name="checkout_analytics.phtml" hash="f06507f3867d78e0e6f1791fc210797d"/><file name="index.phtml" hash="a69cff3727b7bba2be7154b94b86ff08"/><file name="product_view_analytics.phtml" hash="0c6581a84fbf2bd89a220bb1e3669928"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Businessfactory_Roihuntereasy.xml" hash="d46e92b8a1b158bfdc47b9daa3274a3d"/></dir></target></contents>
48
  <compatible/>
49
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
50
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>roihunter_easy</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>AFL 3.0</license>
7
  <channel>community</channel>
42
  * Extension do not cover your Google Adwords Ad Spend. </description>
43
  <notes>Created 28th December, 2016 Compatibility: 1.9.2.4 - Main functions: feed generation, tagging your site for remarketing, creating google ads and much more.</notes>
44
  <authors><author><name>ROI Hunter</name><user>MAG003490427</user><email>petr.skornok@b.cz</email></author></authors>
45
+ <date>2017-03-02</date>
46
+ <time>08:54:23</time>
47
+ <contents><target name="magecommunity"><dir name="Businessfactory"><dir name="Roihuntereasy"><dir name="Block"><file name="AddedToCartAnalytics.php" hash="eeb701f487b06ed82e0754aefb192fab"/><dir name="Adminhtml"><file name="Admin.php" hash="87c29e0e4de22b3b73189e1897ca781d"/><dir name="System"><dir name="Config"><file name="Cronbutton.php" hash="a07a6cfbd52a9a96fb4ec78cc8270924"/><file name="Resetbutton.php" hash="7721bb62feafe5d9d2951e70bfb0c30e"/></dir></dir></dir><file name="CategoryViewAnalytics.php" hash="739f1993bbc42c5df4b1a96956e97770"/><file name="CheckoutAnalytics.php" hash="831094424cf896e6644d66b0c70c3688"/><file name="Database.php" hash="4333ce4f66b762097cb50b4f04a7a4d2"/><file name="ProductViewAnalytics.php" hash="033e6702927d92ae5f2d388f00b46bd5"/></dir><dir name="Helper"><file name="Data.php" hash="05ee8de6f74805d4a2b4643b0b0fe33a"/></dir><dir name="Model"><file name="AddedToCartObserver.php" hash="e8d63910fbee0e80affa3616c8d131d4"/><file name="CheckoutObserver.php" hash="988b2f83a43db339fa938d5b11866eea"/><file name="Cron.php" hash="2a4f7466a609e3129b43606c90cef2f3"/><file name="Main.php" hash="06766b59391b52aaa701d8bf01e80d1a"/><file name="Options.php" hash="f6ecd5ab10cfcc5e0948b236bb873932"/><dir name="Resource"><dir name="Main"><file name="Collection.php" hash="9b66b73b312ac16e270c1435a789fdb9"/></dir><file name="Main.php" hash="1432c450ff554fb5057d1d6c4fd26c3c"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RoihuntereasyController.php" hash="687380dafaffd792a281e2bfd653d027"/></dir><file name="CronController.php" hash="f160c324b60ce92b249731bb97aa1e75"/><file name="FeedController.php" hash="e185b7550c6ef091b5fbcf51f315dc5a"/><file name="IndexController.php" hash="33c2a22770591cbeb7fb394d3654d904"/><file name="ResetController.php" hash="1a6c578829957c0a2ec2a4085ed5a089"/><file name="RoihuntereasyController.php" hash="b2b37f613badb75be2198e6643ef8d85"/><file name="StoredetailsController.php" hash="c4eb4f5f60a80169a561f45ff8587f6e"/></dir><dir name="etc"><file name="adminhtml.xml" hash="bbab6af370448895030570a657469a15"/><file name="config.xml" hash="4b044240a4b1e4081250b429400681f9"/><file name="system.xml" hash="718ea25db00b6a500b8783f9c8e1ba5c"/></dir><dir name="sql"><dir name="businessfactory_roihuntereasy_setup"><file name="install-1.0.0.php" hash="f490ddfd229eb5680e68fb7ec55a5820"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="businessfactory_roihuntereasy.xml" hash="fa2e345d2461459e15c641731d1b114a"/></dir><dir name="template"><dir name="businessfactory_roihuntereasy"><file name="admin.phtml" hash="9fa63b7a1aa7aacce63c949025469fff"/><dir name="system"><dir name="config"><file name="cronbutton.phtml" hash="758b97b5da81c92aaeb175e4b0142288"/><file name="resetbutton.phtml" hash="7aedce71c5d21bfce1a08c77e603143d"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="businessfactory_roihuntereasy.xml" hash="e1379f4d0a022d6740d0a6d96fd9fbed"/></dir><dir name="template"><dir name="businessfactory_roihuntereasy"><file name="added_to_cart_view_analytics.phtml" hash="8679d7940136d046ce46d2bc9aa2b522"/><file name="category_view_analytics.phtml" hash="420fe9c183c444e655250efa0b037da4"/><file name="checkout_analytics.phtml" hash="f06507f3867d78e0e6f1791fc210797d"/><file name="index.phtml" hash="a69cff3727b7bba2be7154b94b86ff08"/><file name="product_view_analytics.phtml" hash="0c6581a84fbf2bd89a220bb1e3669928"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Businessfactory_Roihuntereasy.xml" hash="d46e92b8a1b158bfdc47b9daa3274a3d"/></dir></target></contents>
48
  <compatible/>
49
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
50
  </package>