BotDefender_by_Lokad - Version 1.2.0

Version Notes

V1.2.0 // API authentication fix

Download this release

Release Info

Developer Magento Core Team
Extension BotDefender_by_Lokad
Version 1.2.0
Comparing to
See all releases


Code changes from version 1.1.0 to 1.2.0

app/code/community/Wyomind/Botdefender/Helper/Data.php CHANGED
@@ -10,7 +10,7 @@ class Wyomind_Botdefender_Helper_Data extends Mage_Core_Helper_Data {
10
  public $_BAD_REQUEST = "BAD REQUEST";
11
  public $_CONNECTION_SUCCEEDED = "Installation complete.";
12
  public $_BOTDEFENDER_API = "https://bdapi.lokad.com/rest/stub/";
13
- public $_BOTDEFENDER_URL = "https://botdefender.lokad.com/";
14
  public $_error = false;
15
 
16
  function apiCall($productPriceId = false, $price = 0) {
@@ -31,8 +31,9 @@ class Wyomind_Botdefender_Helper_Data extends Mage_Core_Helper_Data {
31
  $service_url = $this->_BOTDEFENDER_API;
32
  if ($productPriceId)
33
  $service_url .=$productPriceId . "/" . $price;
34
- else
35
- $this->_BAD_REQUEST = $this->_CONNECTION_SUCCEEDED;
 
36
 
37
  $curl = curl_init($service_url);
38
  curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
@@ -78,7 +79,7 @@ class Wyomind_Botdefender_Helper_Data extends Mage_Core_Helper_Data {
78
  }
79
  }
80
 
81
- public function getMessage($status) {
82
 
83
  switch ($status) {
84
  case "-5": return $this->_AUTHENTIFICATION_ERROR;
@@ -94,7 +95,10 @@ class Wyomind_Botdefender_Helper_Data extends Mage_Core_Helper_Data {
94
  case "0": return $this->_BAD_REQUEST;
95
  break;
96
  default :
97
- return $status;
 
 
 
98
  }
99
  }
100
 
@@ -106,22 +110,25 @@ class Wyomind_Botdefender_Helper_Data extends Mage_Core_Helper_Data {
106
  function getData($htmlOutput, $_id, $_storeId, $_price_id) {
107
  if (Mage::getStoreConfig("botdefender/settings/enabled")) {
108
  $_botDefenderId = $_id . "_" . $_storeId . "_" . $_price_id;
109
- preg_match("/([0-9.,]+)/", $htmlOutput, $matches);
110
  $curl_response = $this->apiCall($_botDefenderId, $matches[0]);
111
  $ips = array_filter(explode(",", Mage::getStoreConfig("botdefender/settings/ips")), array("Wyomind_Botdefender_Helper_Data", "cleanArray"));
112
-
113
  //debug enabled and ips match
114
  if (!count($ips) || in_array(Mage::helper('core/http')->getRemoteAddr(), $ips))
115
  if (Mage::getStoreConfig("botdefender/settings/debug", $_storeId))
116
- echo "<div style='border:1px dotted red; color:red;padding:10px;'><b>BotDefender</b> <br>" . $this->_BOTDEFENDER_API . "" . $_botDefenderId . "/" . $matches[0] . " <br> Response : " . $this->getMessage($curl_response) . "</div>";
117
  // if error return skip the api response
118
  if ($this->_error) {
119
  //log error
 
120
  if (Mage::getStoreConfig("botdefender/settings/log"))
121
  Mage::log("\n>>" . $this->_BOTDEFENDER_API . "\n*ID: " . $_botDefenderId . "\n*Price: " . $matches[0] . "\n*status: " . $curl_response . "\n*message: " . $this->getMessage($curl_response) . "\n\n", null, "BotDefender.log");
122
  return $htmlOutput;
123
  }
124
- return str_replace($matches[0], $curl_response, $htmlOutput);
 
 
125
  }
126
  else
127
  return $htmlOutput;
10
  public $_BAD_REQUEST = "BAD REQUEST";
11
  public $_CONNECTION_SUCCEEDED = "Installation complete.";
12
  public $_BOTDEFENDER_API = "https://bdapi.lokad.com/rest/stub/";
13
+ public $_BOTDEFENDER_URL = "https://botdefender.lokad.com/";
14
  public $_error = false;
15
 
16
  function apiCall($productPriceId = false, $price = 0) {
31
  $service_url = $this->_BOTDEFENDER_API;
32
  if ($productPriceId)
33
  $service_url .=$productPriceId . "/" . $price;
34
+ else {
35
+ $service_url .= "botdefendertest/0.00";
36
+ }
37
 
38
  $curl = curl_init($service_url);
39
  curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
79
  }
80
  }
81
 
82
+ public function getMessage($status, $testCnx = false) {
83
 
84
  switch ($status) {
85
  case "-5": return $this->_AUTHENTIFICATION_ERROR;
95
  case "0": return $this->_BAD_REQUEST;
96
  break;
97
  default :
98
+ if (!$testCnx)
99
+ return $status;
100
+ else
101
+ return $this->_CONNECTION_SUCCEEDED;
102
  }
103
  }
104
 
110
  function getData($htmlOutput, $_id, $_storeId, $_price_id) {
111
  if (Mage::getStoreConfig("botdefender/settings/enabled")) {
112
  $_botDefenderId = $_id . "_" . $_storeId . "_" . $_price_id;
113
+ preg_match("/([0-9]|\.|\,){1,16}/", $htmlOutput, $matches);
114
  $curl_response = $this->apiCall($_botDefenderId, $matches[0]);
115
  $ips = array_filter(explode(",", Mage::getStoreConfig("botdefender/settings/ips")), array("Wyomind_Botdefender_Helper_Data", "cleanArray"));
116
+ $debug=null;
117
  //debug enabled and ips match
118
  if (!count($ips) || in_array(Mage::helper('core/http')->getRemoteAddr(), $ips))
119
  if (Mage::getStoreConfig("botdefender/settings/debug", $_storeId))
120
+ $debug= "<div style='border:1px dotted red; color:red;padding:10px;'><b>BotDefender</b> <br>" . $this->_BOTDEFENDER_API . "" . $_botDefenderId . "/" . $matches[0] . " <br> Response : " . $this->getMessage($curl_response) . "</div>";
121
  // if error return skip the api response
122
  if ($this->_error) {
123
  //log error
124
+
125
  if (Mage::getStoreConfig("botdefender/settings/log"))
126
  Mage::log("\n>>" . $this->_BOTDEFENDER_API . "\n*ID: " . $_botDefenderId . "\n*Price: " . $matches[0] . "\n*status: " . $curl_response . "\n*message: " . $this->getMessage($curl_response) . "\n\n", null, "BotDefender.log");
127
  return $htmlOutput;
128
  }
129
+
130
+ return $debug.str_replace($matches[0], $curl_response, $htmlOutput);
131
+
132
  }
133
  else
134
  return $htmlOutput;
app/code/community/Wyomind/Botdefender/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <Wyomind_Botdefender>
6
- <version>1.0.0</version>
7
  </Wyomind_Botdefender>
8
  </modules>
9
  <default>
3
  <config>
4
  <modules>
5
  <Wyomind_Botdefender>
6
+ <version>1.2.0</version>
7
  </Wyomind_Botdefender>
8
  </modules>
9
  <default>
lib/Varien/Data/Form/Element/Botdefender.php CHANGED
@@ -20,7 +20,7 @@ class Varien_Data_Form_Element_Botdefender extends Varien_Data_Form_Element_Abst
20
 
21
 
22
  $apiCall = Mage::helper("botdefender")->apiCall();
23
- $message = Mage::helper('botdefender')->getMessage($apiCall);
24
 
25
 
26
  $html .= '<a id="' . $this->getHtmlId() . '" href="' . Mage::helper("botdefender")->_BOTDEFENDER_URL . '" target="_blank">' . $message . "</a>\n";
20
 
21
 
22
  $apiCall = Mage::helper("botdefender")->apiCall();
23
+ $message = Mage::helper('botdefender')->getMessage($apiCall,true);
24
 
25
 
26
  $html .= '<a id="' . $this->getHtmlId() . '" href="' . Mage::helper("botdefender")->_BOTDEFENDER_URL . '" target="_blank">' . $message . "</a>\n";
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>BotDefender_by_Lokad</name>
4
- <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.wyomind.com/terms-and-conditions.html">OSL v3.0</license>
7
  <channel>community</channel>
@@ -11,11 +11,11 @@ Stop being outpriced every time you make a move. Best suited for retailers.</sum
11
  <description>&lt;h2 class="thin"&gt;Stop competitors from getting your prices&lt;/h2&gt;&#xD;
12
  &lt;span style="font-size:140%"&gt;stop being outpriced&lt;/span&gt; customer acquisition costs are higher than ever. Why should you lose a costly customer acquisition just because your competitor always aligns itself $1 below your price?&lt;br&gt;&lt;br&gt;&lt;span style="font-size:140%"&gt;stop price wars&lt;/span&gt; if your competitors react in near real-time to your prices, then anytime you lower a price, they will lower their price as well. Let competitors pick other opponents to run their price wars.&lt;br&gt;&lt;br&gt;&lt;span style="font-size:140%"&gt;drive competition crazy&lt;/span&gt; reverse-engineering BotDefender takes 1000 more time than setting it up. Keep competition distracted for months, while you make decisive moves on your core business.&lt;br&gt;&lt;br&gt;&lt;span style="font-size:140%"&gt;it's free, no catch&lt;/span&gt; the Express Plan is free and does not expire. No hidden costs or catch involved. We have a paid plan with extra features but the Express Plan is fully functional.&lt;br&gt;&lt;br&gt;&lt;h2 class="thin"&gt;Obfuscation (Enterprise Plan)&lt;/h2&gt;&#xD;
13
  Obfuscation is a more advanced protection method only made available in the Enterprise Plan. The snippet returned by BotDefender is an intricate price of HTML and JavaScript designed to be very hard to decipher, no matter if it's the raw HTML or the DOM (Domain Object Model) that are analyzed.&lt;br&gt;&lt;br&gt;Advantages of obfuscation over tar pitting are:&lt;br&gt;&lt;br&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Zero overhead&lt;/b&gt; caused by an extra HTTP request to be made by the end-user. The snippet is self-contained and does not require any external resources to be rendered as the price.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Zero liability&lt;/b&gt; as the snippet is self-contained; it does not matter whether the BotDefender servers are up or down: the mechanism keeps working without any dependency on BotDefender.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Zero leakage&lt;/b&gt; when obfuscation is used Lokad &lt;i&gt;cannot&lt;/i&gt; collect any information about your web traffic. As far data leakage is concerned, it can't be made more secure than that.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br&gt;Lokad recommends obfuscation for high-traffic websites.</description>
14
- <notes>V1.1.0 // fix conflict with Wyomind Notification Manager</notes>
15
  <authors><author><name>Wyomind</name><user>auto-converted</user><email>contact@wyomind.com</email></author></authors>
16
- <date>2013-11-17</date>
17
- <time>20:47:30</time>
18
- <contents><target name="magecommunity"><dir name="Wyomind"><dir name="Botdefender"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="1e70daf7287709d6c33cec793a561d8b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="bc1e57e4cd9aba35e800e894258b8e17"/></dir><dir name="Model"><dir name="Resource"><file name="Setup.php" hash="31e494bb0f0d0e6c56ab1df0a5930efb"/></dir><file name="Observer.php" hash="3ecd42c88e337b0861c614b5201dc3ae"/></dir><dir name="Varien"><dir name="Data"><dir name="Form"><dir name="Element"><file name="Installation.php" hash="9cb39374d4788934f028c23c8be38f92"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="bc7e3f5de9c60e9e0bd8ae041e4a5f87"/><file name="system.xml" hash="ab0166b8f6d1e8f25c7601ddc2091eb5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wyomind_Botdefender.xml" hash="6961224077915480f64d4c30c6a1e3fa"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="botdefender.xml" hash="e75f14ad7cb6a185f472831cf40a17be"/></dir><dir name="template"><dir name="botdefender"><dir name="bundle"><dir name="catalog"><dir name="product"><dir name="view"><file name="price.phtml" hash="bf7e73a0038d1aadbf31da8820523ce9"/></dir><file name="price.phtml" hash="893eed0a24df8c168b83250447e5ed83"/></dir></dir></dir><dir name="catalog"><dir name="product"><file name="price.phtml" hash="99ad8fa9ddbdbedfb2626ab33abe69b9"/></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="botdefender.xml" hash="db56f289d4ba772caaff40d4968c1edf"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="lib"><dir name="Varien"><dir name="Data"><dir name="Form"><dir name="Element"><file name="Botdefender.php" hash="1e0cf283d9c855d292c7072178a6909f"/></dir></dir></dir></dir></dir></target></contents>
19
  <compatible/>
20
  <dependencies/>
21
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>BotDefender_by_Lokad</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.wyomind.com/terms-and-conditions.html">OSL v3.0</license>
7
  <channel>community</channel>
11
  <description>&lt;h2 class="thin"&gt;Stop competitors from getting your prices&lt;/h2&gt;&#xD;
12
  &lt;span style="font-size:140%"&gt;stop being outpriced&lt;/span&gt; customer acquisition costs are higher than ever. Why should you lose a costly customer acquisition just because your competitor always aligns itself $1 below your price?&lt;br&gt;&lt;br&gt;&lt;span style="font-size:140%"&gt;stop price wars&lt;/span&gt; if your competitors react in near real-time to your prices, then anytime you lower a price, they will lower their price as well. Let competitors pick other opponents to run their price wars.&lt;br&gt;&lt;br&gt;&lt;span style="font-size:140%"&gt;drive competition crazy&lt;/span&gt; reverse-engineering BotDefender takes 1000 more time than setting it up. Keep competition distracted for months, while you make decisive moves on your core business.&lt;br&gt;&lt;br&gt;&lt;span style="font-size:140%"&gt;it's free, no catch&lt;/span&gt; the Express Plan is free and does not expire. No hidden costs or catch involved. We have a paid plan with extra features but the Express Plan is fully functional.&lt;br&gt;&lt;br&gt;&lt;h2 class="thin"&gt;Obfuscation (Enterprise Plan)&lt;/h2&gt;&#xD;
13
  Obfuscation is a more advanced protection method only made available in the Enterprise Plan. The snippet returned by BotDefender is an intricate price of HTML and JavaScript designed to be very hard to decipher, no matter if it's the raw HTML or the DOM (Domain Object Model) that are analyzed.&lt;br&gt;&lt;br&gt;Advantages of obfuscation over tar pitting are:&lt;br&gt;&lt;br&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Zero overhead&lt;/b&gt; caused by an extra HTTP request to be made by the end-user. The snippet is self-contained and does not require any external resources to be rendered as the price.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Zero liability&lt;/b&gt; as the snippet is self-contained; it does not matter whether the BotDefender servers are up or down: the mechanism keeps working without any dependency on BotDefender.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Zero leakage&lt;/b&gt; when obfuscation is used Lokad &lt;i&gt;cannot&lt;/i&gt; collect any information about your web traffic. As far data leakage is concerned, it can't be made more secure than that.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br&gt;Lokad recommends obfuscation for high-traffic websites.</description>
14
+ <notes>V1.2.0 // API authentication fix</notes>
15
  <authors><author><name>Wyomind</name><user>auto-converted</user><email>contact@wyomind.com</email></author></authors>
16
+ <date>2013-11-20</date>
17
+ <time>13:02:34</time>
18
+ <contents><target name="magecommunity"><dir name="Wyomind"><dir name="Botdefender"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="1e70daf7287709d6c33cec793a561d8b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="e46311866ae2b12131dc933e4f394e46"/></dir><dir name="Model"><dir name="Resource"><file name="Setup.php" hash="31e494bb0f0d0e6c56ab1df0a5930efb"/></dir><file name="Observer.php" hash="3ecd42c88e337b0861c614b5201dc3ae"/></dir><dir name="Varien"><dir name="Data"><dir name="Form"><dir name="Element"><file name="Installation.php" hash="9cb39374d4788934f028c23c8be38f92"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="15478a2b20d74116036b1dc1d128bedd"/><file name="system.xml" hash="ab0166b8f6d1e8f25c7601ddc2091eb5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wyomind_Botdefender.xml" hash="6961224077915480f64d4c30c6a1e3fa"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="botdefender.xml" hash="e75f14ad7cb6a185f472831cf40a17be"/></dir><dir name="template"><dir name="botdefender"><dir name="bundle"><dir name="catalog"><dir name="product"><dir name="view"><file name="price.phtml" hash="bf7e73a0038d1aadbf31da8820523ce9"/></dir><file name="price.phtml" hash="893eed0a24df8c168b83250447e5ed83"/></dir></dir></dir><dir name="catalog"><dir name="product"><file name="price.phtml" hash="99ad8fa9ddbdbedfb2626ab33abe69b9"/></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="botdefender.xml" hash="db56f289d4ba772caaff40d4968c1edf"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="lib"><dir name="Varien"><dir name="Data"><dir name="Form"><dir name="Element"><file name="Botdefender.php" hash="03bf9c9f7bfddded751dbdb024bf384c"/></dir></dir></dir></dir></dir></target></contents>
19
  <compatible/>
20
  <dependencies/>
21
  </package>