Wyomind_WatchLog - Version 1.1.0

Version Notes

test

Download this release

Release Info

Developer Wyomind
Extension Wyomind_WatchLog
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.2 to 1.1.0

app/code/community/Wyomind/Watchlog/Helper/Data.php CHANGED
@@ -2,4 +2,51 @@
2
 
3
  class Wyomind_Watchlog_Helper_Data extends Mage_Core_Helper_Abstract {
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
2
 
3
  class Wyomind_Watchlog_Helper_Data extends Mage_Core_Helper_Abstract {
4
 
5
+ public function checkNotification() {
6
+ $last_notification = Mage::getStoreConfig("watchlogpro/settings/last_notification");
7
+ $failed_limit = Mage::getStoreConfig("watchlogpro/settings/failed_limit");
8
+
9
+
10
+ $percent = Mage::getModel("watchlog/watchlog")->getFailedPercentFromDate($last_notification)->getPercent();
11
+
12
+ if ($percent > $failed_limit) {
13
+ // add notif in inbox
14
+ $notification_title = Mage::getStoreConfig("watchlogpro/settings/notification_title");
15
+ $notification_description = Mage::getStoreConfig("watchlogpro/settings/notification_description");
16
+ $notification_link = Mage::helper("adminhtml")->getUrl("watchlog/adminhtml_basic/index/");
17
+ $date = Mage::getSingleton('core/date')->gmtDate('Y-m-d H:i:s');
18
+
19
+ $notify = Mage::getModel('adminnotification/inbox');
20
+ $item = $notify->getCollection()->addFieldToFilter('title', array("eq" => "Watchlog security warning"))->addFieldToFilter('is_remove', array("eq" => 0));
21
+ $data = $item->getLastItem()->getData();
22
+
23
+ if ($data["notification_id"]) {
24
+ $notify->load($data["notification_id"]);
25
+ $notify->setUrl($notification_link);
26
+ $notify->setDescription($this->__($notification_description, round($percent * 100), $notification_link));
27
+ $notify->setData('is_read', 0)->save();
28
+ } else {
29
+
30
+ $notify->setUrl($notification_link);
31
+ $notify->setDescription($this->__($notification_description, round($percent * 100), $notification_link));
32
+ $notify->setTitle($this->__($notification_title));
33
+ $notify->setSeverity(1);
34
+ $notify->save();
35
+ }
36
+ // upate watchlogpro/settings/last_notification config
37
+ Mage::getConfig()->saveConfig("watchlogpro/settings/last_notification", $date, "default", "0");
38
+ }
39
+ }
40
+
41
+ public function checkWarning() {
42
+
43
+
44
+ $last_notification = Mage::getStoreConfig("watchlogpro/settings/last_notification");
45
+ $failed_limit = Mage::getStoreConfig("watchlogpro/settings/failed_limit");
46
+ $percent = Mage::getModel("watchlog/watchlog")->getFailedPercentFromDate()->getPercent();
47
+ $notification_details = Mage::getStoreConfig("watchlogpro/settings/notification_details");
48
+ if ($percent > $failed_limit)
49
+ Mage::getSingleton("core/session")->addError($this->__($notification_details, round($percent * 100)));
50
+ }
51
+
52
  }
app/code/community/Wyomind/Watchlog/Model/Observer.php CHANGED
@@ -18,6 +18,9 @@ class Wyomind_Watchlog_Model_Observer {
18
  "message" => "",
19
  "url" => $url
20
  );
 
 
 
21
 
22
  $model = Mage::getModel('watchlog/watchlog')->load(0);
23
  $model->setData($data);
18
  "message" => "",
19
  "url" => $url
20
  );
21
+
22
+ Mage::helper('watchlog/data')->checkNotification();
23
+
24
 
25
  $model = Mage::getModel('watchlog/watchlog')->load(0);
26
  $model->setData($data);
app/code/community/Wyomind/Watchlog/Model/Watchlog.php CHANGED
@@ -3,7 +3,6 @@
3
  class Wyomind_Watchlog_Model_Watchlog extends Mage_Core_Model_Abstract {
4
 
5
  protected function _construct() {
6
-
7
  $this->_init("watchlog/watchlog");
8
  }
9
 
@@ -29,12 +28,12 @@ class Wyomind_Watchlog_Model_Watchlog extends Mage_Core_Model_Abstract {
29
 
30
  $collection->getSelect()
31
  ->columns('COUNT(watchlog_id) as nb')
32
- ->where("date >= '".Mage::getModel('core/date')->gmtDate('Y-m-d H:i:s')."' - interval 23 hour")
33
  ->group("concat(hour(date))")
34
  ->order("date asc")
35
  ->group("type");
36
-
37
-
38
  return $collection;
39
  }
40
 
@@ -45,12 +44,24 @@ class Wyomind_Watchlog_Model_Watchlog extends Mage_Core_Model_Abstract {
45
  $collection->getSelect()
46
  ->columns('COUNT(watchlog_id) as nb')
47
  ->columns("CONCAT(year(date),'-',month(date),'-',day(date)) as date")
48
- ->where("date > '".Mage::getModel('core/date')->gmtDate('Y-m-d H:i:s')."' - INTERVAL 30 DAY")
49
  ->order("date asc")
50
  ->group("concat(year(date),'-',month(date),'-',day(date))")
51
  ->group("type");
52
-
53
  return $collection;
54
  }
55
 
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
3
  class Wyomind_Watchlog_Model_Watchlog extends Mage_Core_Model_Abstract {
4
 
5
  protected function _construct() {
 
6
  $this->_init("watchlog/watchlog");
7
  }
8
 
28
 
29
  $collection->getSelect()
30
  ->columns('COUNT(watchlog_id) as nb')
31
+ ->where("date >= '" . Mage::getModel('core/date')->gmtDate('Y-m-d H:i:s') . "' - interval 23 hour")
32
  ->group("concat(hour(date))")
33
  ->order("date asc")
34
  ->group("type");
35
+
36
+
37
  return $collection;
38
  }
39
 
44
  $collection->getSelect()
45
  ->columns('COUNT(watchlog_id) as nb')
46
  ->columns("CONCAT(year(date),'-',month(date),'-',day(date)) as date")
47
+ ->where("date > '" . Mage::getModel('core/date')->gmtDate('Y-m-d H:i:s') . "' - INTERVAL 30 DAY")
48
  ->order("date asc")
49
  ->group("concat(year(date),'-',month(date),'-',day(date))")
50
  ->group("type");
51
+
52
  return $collection;
53
  }
54
 
55
+ public function getFailedPercentFromDate($date = null) {
56
+
57
+ $collection = Mage::getModel("watchlog/watchlog")->getCollection();
58
+
59
+ $collection->getSelect()
60
+ ->columns('SUM(IF(`type`=0,1,0))/COUNT(watchlog_id) as percent')
61
+ ->where("date >= '" . $date . "'");
62
+
63
+
64
+ return $collection->getFirstItem();
65
+ }
66
+
67
+ }
app/code/community/Wyomind/Watchlog/controllers/Adminhtml/AdvancedController.php CHANGED
@@ -3,7 +3,10 @@
3
  class Wyomind_Watchlog_Adminhtml_AdvancedController extends Mage_Adminhtml_Controller_Action {
4
 
5
  protected function _initAction() {
6
- $this->loadLayout()->_setActiveMenu("watchlog/watchlog")->_addBreadcrumb(Mage::helper("adminhtml")->__("Watchlog Manager"), Mage::helper("adminhtml")->__("Watchlog Manager"));
 
 
 
7
  return $this;
8
  }
9
 
@@ -14,12 +17,10 @@ class Wyomind_Watchlog_Adminhtml_AdvancedController extends Mage_Adminhtml_Contr
14
  $this->_initAction();
15
  $this->renderLayout();
16
  }
17
-
18
  public function purgeAction() {
19
  $log = Mage::helper('watchlog')->purgeData();
20
  $this->_redirect('*/*');
21
  }
22
 
23
-
24
-
25
  }
3
  class Wyomind_Watchlog_Adminhtml_AdvancedController extends Mage_Adminhtml_Controller_Action {
4
 
5
  protected function _initAction() {
6
+
7
+ Mage::helper('watchlog')->checkWarning();
8
+
9
+ $this->loadLayout()->_setActiveMenu("watchlog/watchlog")->_addBreadcrumb(Mage::helper("adminhtml")->__("Watchlog"), Mage::helper("adminhtml")->__("Watchlog"));
10
  return $this;
11
  }
12
 
17
  $this->_initAction();
18
  $this->renderLayout();
19
  }
20
+
21
  public function purgeAction() {
22
  $log = Mage::helper('watchlog')->purgeData();
23
  $this->_redirect('*/*');
24
  }
25
 
 
 
26
  }
app/code/community/Wyomind/Watchlog/controllers/Adminhtml/BasicController.php CHANGED
@@ -3,7 +3,13 @@
3
  class Wyomind_Watchlog_Adminhtml_BasicController extends Mage_Adminhtml_Controller_Action {
4
 
5
  protected function _initAction() {
6
- $this->loadLayout()->_setActiveMenu("watchlog/watchlog")->_addBreadcrumb(Mage::helper("adminhtml")->__("Watchlog Manager"), Mage::helper("adminhtml")->__("Watchlog Manager"));
 
 
 
 
 
 
7
  return $this;
8
  }
9
 
@@ -13,13 +19,12 @@ class Wyomind_Watchlog_Adminhtml_BasicController extends Mage_Adminhtml_Controll
13
  $this->_initAction();
14
  $this->renderLayout();
15
  }
16
-
17
  public function purgeAction() {
18
  $log = Mage::helper('watchlog')->purgeData();
19
  $this->_redirect('*/*');
20
  }
21
 
22
-
23
  public function deleteAction() {
24
  if ($this->getRequest()->getParam("id") > 0) {
25
  try {
@@ -49,6 +54,4 @@ class Wyomind_Watchlog_Adminhtml_BasicController extends Mage_Adminhtml_Controll
49
  $this->_redirect('*/*/');
50
  }
51
 
52
-
53
-
54
  }
3
  class Wyomind_Watchlog_Adminhtml_BasicController extends Mage_Adminhtml_Controller_Action {
4
 
5
  protected function _initAction() {
6
+
7
+ Mage::helper('watchlog')->checkWarning();
8
+
9
+ $this->loadLayout()->_setActiveMenu("watchlog/watchlog")->_addBreadcrumb(Mage::helper("adminhtml")->__("Watchlog"), Mage::helper("adminhtml")->__("Watchlog"));
10
+
11
+
12
+
13
  return $this;
14
  }
15
 
19
  $this->_initAction();
20
  $this->renderLayout();
21
  }
22
+
23
  public function purgeAction() {
24
  $log = Mage::helper('watchlog')->purgeData();
25
  $this->_redirect('*/*');
26
  }
27
 
 
28
  public function deleteAction() {
29
  if ($this->getRequest()->getParam("id") > 0) {
30
  try {
54
  $this->_redirect('*/*/');
55
  }
56
 
 
 
57
  }
app/code/community/Wyomind/Watchlog/etc/config.xml CHANGED
@@ -2,13 +2,13 @@
2
  <config>
3
  <modules>
4
  <Wyomind_Watchlog>
5
- <version>1.0.2</version>
6
  </Wyomind_Watchlog>
7
  </modules>
8
  <default>
9
  <watchlogpro>
10
  <license>
11
- <version>1.0.2</version>
12
  </license>
13
  <settings>
14
  <history>30</history>
@@ -16,6 +16,14 @@
16
  <report_period>1</report_period>
17
  <report_title>Watchlog report</report_title>
18
  <last_report>2000-01-01 00:00:00</last_report>
 
 
 
 
 
 
 
 
19
  </settings>
20
  </watchlogpro>
21
  </default>
2
  <config>
3
  <modules>
4
  <Wyomind_Watchlog>
5
+ <version>1.1.0</version>
6
  </Wyomind_Watchlog>
7
  </modules>
8
  <default>
9
  <watchlogpro>
10
  <license>
11
+ <version>1.1.0</version>
12
  </license>
13
  <settings>
14
  <history>30</history>
16
  <report_period>1</report_period>
17
  <report_title>Watchlog report</report_title>
18
  <last_report>2000-01-01 00:00:00</last_report>
19
+ <last_notification>2000-01-01 00:00:00</last_notification>
20
+ <failed_limit>0.9</failed_limit>
21
+ <notification_title>Watchlog security warning</notification_title>
22
+ <notification_description><![CDATA[Watchlog has detected an abnormaly high level of failed connection attempts to your backoffice (%s&#37;).
23
+ <br/> Please check <a href='%s'>Watchlog panel</a> for further details.]]></notification_description>
24
+ <notification_details><![CDATA[Watchlog has detected an abnormaly high level of failed connection attempts to your backoffice (%s&#37;).
25
+ <br/> <b>Upgrade Watchlog to <a href="https://www.wyomind.com/watchlog-security-enhancement-magento.html" target="_blank">Watchlog Pro</a> to protect your store!</b>]]></notification_details>
26
+
27
  </settings>
28
  </watchlogpro>
29
  </default>
app/design/adminhtml/default/default/template/watchlog/chart.phtml CHANGED
@@ -1,4 +1,6 @@
1
- <div class="content-header">
 
 
2
  <table cellspacing="0" style="width:50%; float:left">
3
  <tbody><tr>
4
  <td style="width:50%;"><h3 class="icon-head head-adminhtml-watchlog"><?php echo $this->__("Watchlog charts"); ?></h3></td>
@@ -18,57 +20,52 @@ $data_day = $this->getChartDataSummaryDay();
18
  ?>
19
 
20
  <script type="text/javascript">
21
- google.setOnLoadCallback(drawChart);
22
- function drawChart() {
23
-
24
-
25
- var options = {
26
  title: 'Logging attempts (last 30 days)',
27
- legend: { position: 'bottom' },
28
- series: {
29
- 0: { color: 'darkgreen' },
30
- 1: { color: 'red' },
31
- 2: { color: 'orange' },
32
- },
33
- hAxis : {
34
- format : 'd/M/y'
35
- },
36
- tooltip: {isHtml: false},
37
- pointSize : 5,
38
- };
39
-
40
- var formatter = new google.visualization.DateFormat({pattern: "d/M/y"});
41
-
42
- // last 30 days
43
- var data = google.visualization.arrayToDataTable(<?php echo str_replace(array('"#', '#"'), '', json_encode($data)); ?>);
44
- var chart = new google.visualization.LineChart(document.getElementById('summary'));
45
- formatter.format(data, 0);
46
- chart.draw(data, options);
47
 
48
-
49
- // last 24 hours
50
-
51
- var options = {
52
- title: 'Logging attempts (last 24 hours)',
53
- legend: { position: 'bottom' },
54
- series: {
55
- 0: { color: 'darkgreen' },
56
- 1: { color: 'red' },
57
- 2: { color: 'orange' },
58
- },
59
- hAxis : {
60
- format : 'h:00 a'
61
- },
62
- tooltip: {isHtml: false},
63
- pointSize : 5
64
- };
65
-
66
- var formatter = new google.visualization.DateFormat({pattern: "d/M/y - h:00 a"});
67
- var data_day = google.visualization.arrayToDataTable(<?php echo str_replace(array('"#', '#"'), '', json_encode($data_day)); ?>);
68
- var chart = new google.visualization.LineChart(document.getElementById('summary_day'));
69
- formatter.format(data_day, 0);
70
- chart.draw(data_day, options);
71
- }
72
  </script>
73
  <div id="summary" style="width: 49%; height: 500px; float:left;"></div>
74
 
1
+
2
+
3
+ <div class="content-header" >
4
  <table cellspacing="0" style="width:50%; float:left">
5
  <tbody><tr>
6
  <td style="width:50%;"><h3 class="icon-head head-adminhtml-watchlog"><?php echo $this->__("Watchlog charts"); ?></h3></td>
20
  ?>
21
 
22
  <script type="text/javascript">
23
+ google.setOnLoadCallback(drawChart);
24
+ function drawChart() {
25
+
26
+
27
+ var options = {
28
  title: 'Logging attempts (last 30 days)',
29
+ legend: {position: 'bottom'},
30
+ series: {
31
+ 0: {color: 'darkgreen'},
32
+ 1: {color: 'red'},
33
+ 2: {color: 'orange'},
34
+ },
35
+ hAxis: {
36
+ format: 'd/M/y'
37
+ },
38
+ tooltip: {isHtml: false},
39
+ pointSize: 5,
40
+ };
41
+ var formatter = new google.visualization.DateFormat({pattern: "d/M/y"});
42
+ // last 30 days
43
+ var data = google.visualization.arrayToDataTable(<?php echo str_replace(array('"#', '#"'), '', json_encode($data)); ?>);
44
+ var chart = new google.visualization.LineChart(document.getElementById('summary'));
45
+ formatter.format(data, 0);
46
+ chart.draw(data, options);
47
+ // last 24 hours
 
48
 
49
+ var options = {
50
+ title: 'Logging attempts (last 24 hours)',
51
+ legend: {position: 'bottom'},
52
+ series: {
53
+ 0: {color: 'darkgreen'},
54
+ 1: {color: 'red'},
55
+ 2: {color: 'orange'},
56
+ },
57
+ hAxis: {
58
+ format: 'h:00 a'
59
+ },
60
+ tooltip: {isHtml: false},
61
+ pointSize: 5
62
+ };
63
+ var formatter = new google.visualization.DateFormat({pattern: "d/M/y - h:00 a"});
64
+ var data_day = google.visualization.arrayToDataTable(<?php echo str_replace(array('"#', '#"'), '', json_encode($data_day)); ?>);
65
+ var chart = new google.visualization.LineChart(document.getElementById('summary_day'));
66
+ formatter.format(data_day, 0);
67
+ chart.draw(data_day, options);
68
+ }
 
 
 
 
69
  </script>
70
  <div id="summary" style="width: 49%; height: 500px; float:left;"></div>
71
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wyomind_WatchLog</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license>Commercial</license>
7
  <channel>community</channel>
@@ -16,8 +16,8 @@
16
  <email>contact@wyomind.com</email>
17
  </author>
18
  </authors>
19
- <date>2015-04-20</date>
20
- <time>12:07:51</time>
21
  <contents>
22
  <target name="magecommunity">
23
  <dir name="Wyomind">
@@ -49,7 +49,7 @@
49
  </dir>
50
  </dir>
51
  <dir name="Helper">
52
- <file name="Data.php" hash="ee75b0a1f3a8b8e02fb318c7761d1825"/>
53
  </dir>
54
  <dir name="Model">
55
  <dir name="Mysql4">
@@ -58,7 +58,7 @@
58
  </dir>
59
  <file name="Watchlog.php" hash="091d0b82dabc51de01108b29ac6f1f2b"/>
60
  </dir>
61
- <file name="Observer.php" hash="bada2ae607210a68c3f85ca4eb9ad715"/>
62
  <dir name="System">
63
  <dir name="Config">
64
  <dir name="Source">
@@ -66,16 +66,16 @@
66
  </dir>
67
  </dir>
68
  </dir>
69
- <file name="Watchlog.php" hash="7b4b8e7b838ba59c1aa80e3e2e11eaf3"/>
70
  </dir>
71
  <dir name="controllers">
72
  <dir name="Adminhtml">
73
- <file name="AdvancedController.php" hash="0b8800a3a1fc33e7ebb57e2b3d2ebaf6"/>
74
- <file name="BasicController.php" hash="e56ce29ba89c81e1d7aac1084af21961"/>
75
  </dir>
76
  </dir>
77
  <dir name="etc">
78
- <file name="config.xml" hash="c901bc0f28c70248478378efeb4a99fb"/>
79
  <file name="system.xml" hash="401cd5b8c13f9c092f2838172da714ff"/>
80
  </dir>
81
  <dir name="sql">
@@ -97,7 +97,7 @@
97
  <dir name="watchlog">
98
  <file name="advanced.phtml" hash="87761a8bb08926299cbb2abae2b7f25d"/>
99
  <file name="basic.phtml" hash="5f31f62449b9dc014975f4b9c33b1fd7"/>
100
- <file name="chart.phtml" hash="d310e9a644ca2b2c7c0740a47cb6e0c4"/>
101
  <dir name="email">
102
  <file name="report.phtml" hash="8fbbc89b71371cbd73478582c9c41be8"/>
103
  </dir>
@@ -107,10 +107,7 @@
107
  </dir>
108
  </dir>
109
  </target>
110
- <target name="mageetc">
111
- <dir name="modules">
112
- <file name="Wyomind_Watchlog.xml" hash="7555645803666036cdd714ac9e5c1e15"/>
113
- </dir>
114
  </target>
115
  </contents>
116
  <compatible/>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wyomind_WatchLog</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license>Commercial</license>
7
  <channel>community</channel>
16
  <email>contact@wyomind.com</email>
17
  </author>
18
  </authors>
19
+ <date>2015-05-21</date>
20
+ <time>14:39:18</time>
21
  <contents>
22
  <target name="magecommunity">
23
  <dir name="Wyomind">
49
  </dir>
50
  </dir>
51
  <dir name="Helper">
52
+ <file name="Data.php" hash="e287e9c1da2a49f76d409a51738dd947"/>
53
  </dir>
54
  <dir name="Model">
55
  <dir name="Mysql4">
58
  </dir>
59
  <file name="Watchlog.php" hash="091d0b82dabc51de01108b29ac6f1f2b"/>
60
  </dir>
61
+ <file name="Observer.php" hash="b72745556b0a472b62e44a44442426c9"/>
62
  <dir name="System">
63
  <dir name="Config">
64
  <dir name="Source">
66
  </dir>
67
  </dir>
68
  </dir>
69
+ <file name="Watchlog.php" hash="6b8c24a306f22dbd6ff79a21f88e17c6"/>
70
  </dir>
71
  <dir name="controllers">
72
  <dir name="Adminhtml">
73
+ <file name="AdvancedController.php" hash="738d4938627b38dc5c744d1d33e913ea"/>
74
+ <file name="BasicController.php" hash="a8a0d4c9b9f012a825074caf49bf463e"/>
75
  </dir>
76
  </dir>
77
  <dir name="etc">
78
+ <file name="config.xml" hash="b71d538e0fe1d8c059d7f8a6aea91409"/>
79
  <file name="system.xml" hash="401cd5b8c13f9c092f2838172da714ff"/>
80
  </dir>
81
  <dir name="sql">
97
  <dir name="watchlog">
98
  <file name="advanced.phtml" hash="87761a8bb08926299cbb2abae2b7f25d"/>
99
  <file name="basic.phtml" hash="5f31f62449b9dc014975f4b9c33b1fd7"/>
100
+ <file name="chart.phtml" hash="7308920f035447e2ed2ec4787f5fd311"/>
101
  <dir name="email">
102
  <file name="report.phtml" hash="8fbbc89b71371cbd73478582c9c41be8"/>
103
  </dir>
107
  </dir>
108
  </dir>
109
  </target>
110
+ <target name="mageetc">@FILES3@
 
 
 
111
  </target>
112
  </contents>
113
  <compatible/>