Version Notes
Stable version, fully functional on our website.
Download this release
Release Info
| Developer | Velica Onel |
| Extension | Briel_VisitorIpSecurity |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Blocked.php +48 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Grid.php +48 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Logurl.php +48 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Oneip.php +28 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Blocked/Grid.php +201 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Grid.php +271 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Logurl/Grid.php +164 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Oneip/Block.php +29 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer.php +28 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Blockthisip.php +40 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Count.php +80 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Firstvisit.php +74 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Google.php +35 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Lasturl.php +104 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Lastvisit.php +74 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Notes.php +36 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Pretty.php +57 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Watchthisip.php +38 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Whitethisip.php +40 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Watch/Grid.php +284 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/White/Grid.php +200 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Watch.php +46 -0
- app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/White.php +46 -0
- app/code/local/Briel/Visitoripsecurity/Helper/Data.php +137 -0
- app/code/local/Briel/Visitoripsecurity/Model/Log/Remoteaddr/Notes.php +29 -0
- app/code/local/Briel/Visitoripsecurity/Model/Log/Url.php +29 -0
- app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Remoteaddr/Notes.php +26 -0
- app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Remoteaddr/Notes/Collection.php +29 -0
- app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Url.php +26 -0
- app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Url/Collection.php +9 -0
- app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Visitoripsecurity.php +29 -0
- app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Visitoripsecurity/Collection.php +53 -0
- app/code/local/Briel/Visitoripsecurity/Model/Notes.php +29 -0
- app/code/local/Briel/Visitoripsecurity/Model/Observer.php +204 -0
- app/code/local/Briel/Visitoripsecurity/controllers/Adminhtml/VisitoripsecurityController.php +482 -0
- app/code/local/Briel/Visitoripsecurity/controllers/IndexController.php +27 -0
- app/code/local/Briel/Visitoripsecurity/etc/adminhtml.xml +26 -0
- app/code/local/Briel/Visitoripsecurity/etc/config.xml +188 -0
- app/code/local/Briel/Visitoripsecurity/etc/system.xml +68 -0
- app/code/local/Briel/Visitoripsecurity/sql/visitoripsecurity_setup/mysql4-install-0.1.0.php +24 -0
- app/design/adminhtml/default/default/layout/briel_visitoripsecurity.xml +48 -0
- app/design/adminhtml/default/default/template/briel/visitoripsecurity/inline-edit.phtml +78 -0
- app/design/adminhtml/default/default/template/briel/visitoripsecurity/oneip.phtml +154 -0
- app/etc/modules/Briel_Visitoripsecurity.xml +9 -0
- app/locale/ro_RO/Briel_Visitoripsecurity.csv +37 -0
- package.xml +24 -0
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Blocked.php
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Blocked extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
$this->_controller = 'adminhtml_visitoripsecurity_blocked';
|
| 28 |
+
$this->_blockGroup = 'visitoripsecurity';
|
| 29 |
+
$this->_headerText = Mage::helper('visitoripsecurity')->__('Blocked ip list');
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
$this->_addButton("view_list", array('label' => Mage::helper('visitoripsecurity')->__('View list'),
|
| 33 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/index')."')"));
|
| 34 |
+
$this->_addButton("view_blocked", array('label' => Mage::helper('visitoripsecurity')->__('View blocked'),
|
| 35 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/blocked')."')"));
|
| 36 |
+
$this->_addButton("view_white", array('label' => Mage::helper('visitoripsecurity')->__('View white list'),
|
| 37 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/white')."')"));
|
| 38 |
+
$this->_addButton("view_watch", array('label' => Mage::helper('visitoripsecurity')->__('View watch list'),
|
| 39 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/watch')."')"));
|
| 40 |
+
$this->_addButton("one_ip", array('label' => Mage::helper('visitoripsecurity')->__('Block ip classes'),
|
| 41 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/oneip')."')"));
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
parent::__construct();
|
| 45 |
+
$this->removeButton('add');
|
| 46 |
+
|
| 47 |
+
}
|
| 48 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Grid.php
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
$this->_controller = 'adminhtml_visitoripsecurity';
|
| 28 |
+
$this->_blockGroup = 'visitoripsecurity';
|
| 29 |
+
$this->_headerText = Mage::helper('visitoripsecurity')->__('Visitors ip list');
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
$this->_addButton("view_list", array('label' => Mage::helper('visitoripsecurity')->__('View list'),
|
| 33 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/index')."')"));
|
| 34 |
+
$this->_addButton("view_blocked", array('label' => Mage::helper('visitoripsecurity')->__('View blocked'),
|
| 35 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/blocked')."')"));
|
| 36 |
+
$this->_addButton("view_white", array('label' => Mage::helper('visitoripsecurity')->__('View white list'),
|
| 37 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/white')."')"));
|
| 38 |
+
$this->_addButton("view_watch", array('label' => Mage::helper('visitoripsecurity')->__('View watch list'),
|
| 39 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/watch')."')"));
|
| 40 |
+
$this->_addButton("one_ip", array('label' => Mage::helper('visitoripsecurity')->__('Block ip classes'),
|
| 41 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/oneip')."')"));
|
| 42 |
+
|
| 43 |
+
parent::__construct();
|
| 44 |
+
$this->removeButton('add');
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
}
|
| 48 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Logurl.php
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Logurl extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
$this->_controller = 'adminhtml_visitoripsecurity_logurl';
|
| 28 |
+
$this->_blockGroup = 'visitoripsecurity';
|
| 29 |
+
$this->_headerText = Mage::helper('visitoripsecurity')->__('Visited urls');
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
$this->_addButton("view_list", array('label' => Mage::helper('visitoripsecurity')->__('View list'),
|
| 33 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/index')."')"));
|
| 34 |
+
$this->_addButton("view_blocked", array('label' => Mage::helper('visitoripsecurity')->__('View blocked'),
|
| 35 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/blocked')."')"));
|
| 36 |
+
$this->_addButton("view_white", array('label' => Mage::helper('visitoripsecurity')->__('View white list'),
|
| 37 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/white')."')"));
|
| 38 |
+
$this->_addButton("view_watch", array('label' => Mage::helper('visitoripsecurity')->__('View watch list'),
|
| 39 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/watch')."')"));
|
| 40 |
+
$this->_addButton("one_ip", array('label' => Mage::helper('visitoripsecurity')->__('Block ip classes'),
|
| 41 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/oneip')."')"));
|
| 42 |
+
|
| 43 |
+
parent::__construct();
|
| 44 |
+
$this->removeButton('add');
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
}
|
| 48 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Oneip.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Oneip extends Mage_Adminhtml_Block_Widget_Container
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
parent::__construct();
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Blocked/Grid.php
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Blocked_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
parent::__construct();
|
| 27 |
+
|
| 28 |
+
$this->setId('blockedGrid');
|
| 29 |
+
// This is the primary key of the database
|
| 30 |
+
//$this->setDefaultSort('url_c');
|
| 31 |
+
$this->setDefaultDir('DESC');
|
| 32 |
+
$this->setSaveParametersInSession(true);
|
| 33 |
+
$this->setUseAjax(false);
|
| 34 |
+
|
| 35 |
+
//echo 'asd';used
|
| 36 |
+
}
|
| 37 |
+
protected function _prepareCollection(){
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 41 |
+
$collection = $model->getCollection();
|
| 42 |
+
|
| 43 |
+
$rs = Mage::getSingleton('core/resource');
|
| 44 |
+
|
| 45 |
+
$visitor = $rs->getTableName('log_visitor');
|
| 46 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 47 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 48 |
+
|
| 49 |
+
$log_url = $rs->getTableName('log_url');
|
| 50 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 51 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 52 |
+
|
| 53 |
+
$select = $collection->getSelect();
|
| 54 |
+
|
| 55 |
+
$select->where('main_table.blocked = 1');
|
| 56 |
+
|
| 57 |
+
$this->setCollection($collection);
|
| 58 |
+
|
| 59 |
+
//$collection->printLogQuery(true);
|
| 60 |
+
|
| 61 |
+
//die();
|
| 62 |
+
|
| 63 |
+
return parent::_prepareCollection();
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
protected function _prepareColumns()
|
| 67 |
+
{
|
| 68 |
+
|
| 69 |
+
$this->addColumn('url_c', array(
|
| 70 |
+
'header' => Mage::helper('visitoripsecurity')->__('Count'),
|
| 71 |
+
'width' => '50px',
|
| 72 |
+
'align' => 'center',
|
| 73 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_count',
|
| 74 |
+
'sortable' => false,
|
| 75 |
+
'filter'=> false
|
| 76 |
+
));
|
| 77 |
+
|
| 78 |
+
$this->addColumn('remote_addr', array(
|
| 79 |
+
'header' => Mage::helper('visitoripsecurity')->__('IP address'),
|
| 80 |
+
'index' => 'remote_addr',
|
| 81 |
+
'width' => '80px',
|
| 82 |
+
'align' => 'center',
|
| 83 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_google'
|
| 84 |
+
));
|
| 85 |
+
|
| 86 |
+
$this->addColumn('action',
|
| 87 |
+
array(
|
| 88 |
+
'header' => Mage::helper('customer')->__('View'),
|
| 89 |
+
'width' => '50px',
|
| 90 |
+
'type' => 'action',
|
| 91 |
+
'getter' => 'getRemoteAddr',
|
| 92 |
+
'align' => 'center',
|
| 93 |
+
'actions' => array(
|
| 94 |
+
array(
|
| 95 |
+
'caption' => Mage::helper('customer')->__('View'),
|
| 96 |
+
'url' => array('base'=> '*/*/logurl'),
|
| 97 |
+
'field' => 'remote_addr'
|
| 98 |
+
)
|
| 99 |
+
),
|
| 100 |
+
'filter' => false,
|
| 101 |
+
'sortable' => false,
|
| 102 |
+
'index' => 'view',
|
| 103 |
+
'is_system' => true,
|
| 104 |
+
));
|
| 105 |
+
$this->addColumn('note', array(
|
| 106 |
+
|
| 107 |
+
'header' => Mage::helper('visitoripsecurity')->__('Notes'),
|
| 108 |
+
'align' => 'left',
|
| 109 |
+
'width' => '80px',
|
| 110 |
+
'index' => 'note',
|
| 111 |
+
'type' => 'text',
|
| 112 |
+
'align' => 'center',
|
| 113 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_notes'
|
| 114 |
+
));
|
| 115 |
+
|
| 116 |
+
$this->addColumn('block',
|
| 117 |
+
array(
|
| 118 |
+
'header' => Mage::helper('customer')->__('Block'),
|
| 119 |
+
'width' => '50px',
|
| 120 |
+
'type' => 'action',
|
| 121 |
+
'getter' => 'getId',
|
| 122 |
+
'align' => 'center',
|
| 123 |
+
'filter' => false,
|
| 124 |
+
'sortable' => false,
|
| 125 |
+
'index' => 'block',
|
| 126 |
+
'is_system' => true,
|
| 127 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_blockthisip'
|
| 128 |
+
));
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
//$this->print_a($this);
|
| 132 |
+
//var_dump($this);
|
| 133 |
+
|
| 134 |
+
return parent::_prepareColumns();
|
| 135 |
+
}
|
| 136 |
+
protected function _addColumnFilterToCollection($column)
|
| 137 |
+
{
|
| 138 |
+
$rs = Mage::getSingleton('core/resource');
|
| 139 |
+
|
| 140 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 141 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 142 |
+
$log_url = $rs->getTableName('log_url');
|
| 143 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 144 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 145 |
+
|
| 146 |
+
if ($this->getCollection()) {
|
| 147 |
+
if ($column->getId() == 'remote_addr') {
|
| 148 |
+
|
| 149 |
+
$cond = $column->getFilter()->getCondition();
|
| 150 |
+
if(!empty($cond)){
|
| 151 |
+
$field = new Zend_Db_Expr('INET_NTOA(main_table.remote_addr)');
|
| 152 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
return $this;
|
| 156 |
+
}elseif ($column->getId() == 'last_visit_at') {
|
| 157 |
+
|
| 158 |
+
$cond = $column->getFilter()->getCondition();
|
| 159 |
+
if(!empty($cond)){
|
| 160 |
+
$field = 'main_table.last_visit_at';
|
| 161 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
return $this;
|
| 165 |
+
}elseif ($column->getId() == 'first_visit_at') {
|
| 166 |
+
|
| 167 |
+
$cond = $column->getFilter()->getCondition();
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
if(!empty($cond)){
|
| 171 |
+
$field = 'main_table.first_visit_at';
|
| 172 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
return $this;
|
| 176 |
+
}elseif ($column->getId() == 'note') {
|
| 177 |
+
|
| 178 |
+
$cond = $column->getFilter()->getCondition();
|
| 179 |
+
if(!empty($cond)){
|
| 180 |
+
$field = 'main_table.note';
|
| 181 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 182 |
+
}
|
| 183 |
+
return $this;
|
| 184 |
+
|
| 185 |
+
}else{
|
| 186 |
+
return parent::_addColumnFilterToCollection($column);
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
public function getRowUrl($row)
|
| 191 |
+
{
|
| 192 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
public function getGridUrl()
|
| 196 |
+
{
|
| 197 |
+
return $this->getUrl('*/*/blocked', array('_current'=>true));
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Grid.php
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
parent::__construct();
|
| 27 |
+
|
| 28 |
+
$this->setId('visitoripsecurityGrid');
|
| 29 |
+
// This is the primary key of the database
|
| 30 |
+
$this->setDefaultSort('url_c');
|
| 31 |
+
$this->setDefaultDir('DESC');
|
| 32 |
+
$this->setSaveParametersInSession(true);
|
| 33 |
+
$this->setUseAjax(false);
|
| 34 |
+
|
| 35 |
+
$this->_headerText = Mage::helper('visitoripsecurity')->__('Ip logs');
|
| 36 |
+
|
| 37 |
+
}
|
| 38 |
+
protected function _prepareCollection(){
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
$model = Mage::getModel('log/visitor');
|
| 42 |
+
$collection = $model->getCollection();
|
| 43 |
+
|
| 44 |
+
$rs = Mage::getSingleton('core/resource');
|
| 45 |
+
|
| 46 |
+
$visitor = $rs->getTableName('log_visitor');
|
| 47 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 48 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 49 |
+
|
| 50 |
+
$log_url = $rs->getTableName('log_url');
|
| 51 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 52 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 53 |
+
|
| 54 |
+
$select = $collection->getSelect();
|
| 55 |
+
$select->reset('columns');
|
| 56 |
+
$select->reset('from');
|
| 57 |
+
|
| 58 |
+
$select->from(array('main_table'=>$visitor), array('main_table.visitor_id', 'MAX(main_table.last_visit_at) AS last_visit_time'));
|
| 59 |
+
|
| 60 |
+
$select->joinLeft(array('vi'=>$visitor_info), 'vi.visitor_id=main_table.visitor_id', 'vi.remote_addr');
|
| 61 |
+
$select->joinLeft(array('lu'=>$log_url), 'lu.visitor_id=main_table.visitor_id', array('url_c'=>'COUNT(*)'));
|
| 62 |
+
//$select->joinLeft(array('lui'=>$log_url_info), 'lui.url_id=last_url_id', array('last_url'=>'lui.url'));
|
| 63 |
+
$select->joinLeft(array('lrn'=>$ip_notes), 'lrn.remote_addr=vi.remote_addr', array('blocked','white','note','watch'));
|
| 64 |
+
|
| 65 |
+
$select->group('vi.remote_addr');
|
| 66 |
+
$select->having('lrn.blocked=0 OR lrn.blocked IS NULL');
|
| 67 |
+
$select->having('lrn.white=0 OR lrn.white IS NULL');
|
| 68 |
+
$select->having('lrn.watch=0 OR lrn.watch IS NULL');
|
| 69 |
+
|
| 70 |
+
$this->setCollection($collection);
|
| 71 |
+
|
| 72 |
+
//$collection->printLogQuery(true);
|
| 73 |
+
|
| 74 |
+
//die();
|
| 75 |
+
|
| 76 |
+
return parent::_prepareCollection();
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
protected function _prepareColumns()
|
| 80 |
+
{
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
$this->addColumn('url_c', array(
|
| 84 |
+
'header' => Mage::helper('visitoripsecurity')->__('Count'),
|
| 85 |
+
'width' => '50px',
|
| 86 |
+
'index' => 'url_c',
|
| 87 |
+
'align' => 'center',
|
| 88 |
+
));
|
| 89 |
+
|
| 90 |
+
$this->addColumn('remote_addr', array(
|
| 91 |
+
'header' => Mage::helper('visitoripsecurity')->__('IP address'),
|
| 92 |
+
'index' => 'remote_addr',
|
| 93 |
+
'width' => '80px',
|
| 94 |
+
'align' => 'center',
|
| 95 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_google'
|
| 96 |
+
));
|
| 97 |
+
|
| 98 |
+
$this->addColumn('action',
|
| 99 |
+
array(
|
| 100 |
+
'header' => Mage::helper('customer')->__('View'),
|
| 101 |
+
'width' => '50px',
|
| 102 |
+
'type' => 'action',
|
| 103 |
+
'getter' => 'getRemoteAddr',
|
| 104 |
+
'align' => 'center',
|
| 105 |
+
'actions' => array(
|
| 106 |
+
array(
|
| 107 |
+
'caption' => Mage::helper('customer')->__('View'),
|
| 108 |
+
'url' => array('base'=> '*/*/logurl'),
|
| 109 |
+
'field' => 'remote_addr'
|
| 110 |
+
)
|
| 111 |
+
),
|
| 112 |
+
'filter' => false,
|
| 113 |
+
'sortable' => false,
|
| 114 |
+
'index' => 'view',
|
| 115 |
+
'is_system' => true,
|
| 116 |
+
));
|
| 117 |
+
$this->addColumn('note', array(
|
| 118 |
+
|
| 119 |
+
'header' => Mage::helper('visitoripsecurity')->__('Notes'),
|
| 120 |
+
'align' => 'left',
|
| 121 |
+
'width' => '80px',
|
| 122 |
+
'index' => 'note',
|
| 123 |
+
'type' => 'text',
|
| 124 |
+
'align' => 'center',
|
| 125 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_notes'
|
| 126 |
+
));
|
| 127 |
+
|
| 128 |
+
$this->addColumn('block',
|
| 129 |
+
array(
|
| 130 |
+
'header' => Mage::helper('customer')->__('Block'),
|
| 131 |
+
'width' => '50px',
|
| 132 |
+
'type' => 'action',
|
| 133 |
+
'getter' => 'getId',
|
| 134 |
+
'align' => 'center',
|
| 135 |
+
'filter' => false,
|
| 136 |
+
'sortable' => false,
|
| 137 |
+
'index' => 'block',
|
| 138 |
+
'is_system' => true,
|
| 139 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_blockthisip'
|
| 140 |
+
));
|
| 141 |
+
$this->addColumn('whitelist',
|
| 142 |
+
array(
|
| 143 |
+
'header' => Mage::helper('customer')->__('Whitelist'),
|
| 144 |
+
'width' => '50px',
|
| 145 |
+
'type' => 'action',
|
| 146 |
+
'getter' => 'getId',
|
| 147 |
+
'align' => 'center',
|
| 148 |
+
'filter' => false,
|
| 149 |
+
'sortable' => false,
|
| 150 |
+
'index' => 'whitelist',
|
| 151 |
+
'is_system' => true,
|
| 152 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_whitethisip'
|
| 153 |
+
));
|
| 154 |
+
$this->addColumn('watchlist',
|
| 155 |
+
array(
|
| 156 |
+
'header' => Mage::helper('customer')->__('Watchlist'),
|
| 157 |
+
'width' => '50px',
|
| 158 |
+
'type' => 'action',
|
| 159 |
+
'getter' => 'getId',
|
| 160 |
+
'align' => 'center',
|
| 161 |
+
'filter' => false,
|
| 162 |
+
'sortable' => false,
|
| 163 |
+
'index' => 'watchlist',
|
| 164 |
+
'is_system' => true,
|
| 165 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_watchthisip'
|
| 166 |
+
));
|
| 167 |
+
|
| 168 |
+
$this->addColumn('first_visit_at', array(
|
| 169 |
+
'header' => Mage::helper('visitoripsecurity')->__('First visit Time'),
|
| 170 |
+
'align' => 'center',
|
| 171 |
+
'width' => '120px',
|
| 172 |
+
'type' => 'datetime',
|
| 173 |
+
'default' => '--',
|
| 174 |
+
'index' => 'first_visit_at',
|
| 175 |
+
'sortable' => true,
|
| 176 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_firstvisit'
|
| 177 |
+
));
|
| 178 |
+
|
| 179 |
+
$this->addColumn('last_visit_at', array(
|
| 180 |
+
'header' => Mage::helper('visitoripsecurity')->__('Last visit Time'),
|
| 181 |
+
'align' => 'center',
|
| 182 |
+
'width' => '120px',
|
| 183 |
+
'type' => 'datetime',
|
| 184 |
+
'default' => '--',
|
| 185 |
+
'index' => 'last_visit_time',
|
| 186 |
+
'sortable' => true
|
| 187 |
+
));
|
| 188 |
+
/*
|
| 189 |
+
$this->addColumn('last_url', array(
|
| 190 |
+
'header' => Mage::helper('visitoripsecurity')->__('Last url'),
|
| 191 |
+
'align' => 'center',
|
| 192 |
+
'width' => '120px',
|
| 193 |
+
'type' => 'text',
|
| 194 |
+
'default' => '--',
|
| 195 |
+
'index' => 'last_url',
|
| 196 |
+
'filter' => false,
|
| 197 |
+
'sortable' => false,
|
| 198 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_lasturl'
|
| 199 |
+
));
|
| 200 |
+
*/
|
| 201 |
+
//$this->print_a($this);
|
| 202 |
+
//var_dump($this);
|
| 203 |
+
|
| 204 |
+
return parent::_prepareColumns();
|
| 205 |
+
}
|
| 206 |
+
protected function _addColumnFilterToCollection($column)
|
| 207 |
+
{
|
| 208 |
+
$rs = Mage::getSingleton('core/resource');
|
| 209 |
+
|
| 210 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 211 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 212 |
+
$log_url = $rs->getTableName('log_url');
|
| 213 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 214 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 215 |
+
|
| 216 |
+
if ($this->getCollection()) {
|
| 217 |
+
if ($column->getId() == 'remote_addr') {
|
| 218 |
+
|
| 219 |
+
$cond = $column->getFilter()->getCondition();
|
| 220 |
+
if(!empty($cond)){
|
| 221 |
+
$field = new Zend_Db_Expr('INET_NTOA(vi.remote_addr)');
|
| 222 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
return $this;
|
| 226 |
+
}elseif ($column->getId() == 'last_visit_at') {
|
| 227 |
+
|
| 228 |
+
$cond = $column->getFilter()->getCondition();
|
| 229 |
+
if(!empty($cond)){
|
| 230 |
+
$field = 'main_table.last_visit_at';
|
| 231 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
return $this;
|
| 235 |
+
}elseif ($column->getId() == 'first_visit_at') {
|
| 236 |
+
|
| 237 |
+
$cond = $column->getFilter()->getCondition();
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
if(!empty($cond)){
|
| 241 |
+
$field = 'main_table.first_visit_at';
|
| 242 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
return $this;
|
| 246 |
+
}elseif ($column->getId() == 'note') {
|
| 247 |
+
|
| 248 |
+
$cond = $column->getFilter()->getCondition();
|
| 249 |
+
if(!empty($cond)){
|
| 250 |
+
$field = new Zend_Db_Expr('lrn.note');
|
| 251 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 252 |
+
}
|
| 253 |
+
return $this;
|
| 254 |
+
|
| 255 |
+
}else{
|
| 256 |
+
return parent::_addColumnFilterToCollection($column);
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
}
|
| 260 |
+
public function getRowUrl($row)
|
| 261 |
+
{
|
| 262 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
public function getGridUrl()
|
| 266 |
+
{
|
| 267 |
+
return $this->getUrl('*/*/index', array('_current'=>true));
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Logurl/Grid.php
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Logurl_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
parent::__construct();
|
| 27 |
+
|
| 28 |
+
$this->setId('logurlGrid');
|
| 29 |
+
// This is the primary key of the database
|
| 30 |
+
$this->setDefaultSort('visit_time');
|
| 31 |
+
$this->setDefaultDir('DESC');
|
| 32 |
+
$this->setSaveParametersInSession(true);
|
| 33 |
+
$this->setUseAjax(false);
|
| 34 |
+
|
| 35 |
+
//echo 'asd';used
|
| 36 |
+
}
|
| 37 |
+
protected function _prepareCollection(){
|
| 38 |
+
|
| 39 |
+
//var_dump($this->getRequest());
|
| 40 |
+
|
| 41 |
+
$model = Mage::getModel('visitoripsecurity/log_url');
|
| 42 |
+
$collection = $model->getCollection();
|
| 43 |
+
|
| 44 |
+
$rs = Mage::getSingleton('core/resource');
|
| 45 |
+
|
| 46 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 47 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 48 |
+
$log_url = $rs->getTableName('log_url');
|
| 49 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 50 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 51 |
+
|
| 52 |
+
$select = $collection->getSelect();
|
| 53 |
+
|
| 54 |
+
$select->joinLeft(array('lui'=>$log_url_info), 'main_table.url_id=lui.url_id',array('url'));
|
| 55 |
+
$select->joinLeft(array('vi'=>$visitor_info), 'main_table.visitor_id=vi.visitor_id',array('remote_addr'));
|
| 56 |
+
|
| 57 |
+
$select->where("vi.remote_addr = '".$this->getRequest()->getParam('remote_addr')."'");
|
| 58 |
+
|
| 59 |
+
$this->setCollection($collection);
|
| 60 |
+
|
| 61 |
+
//$collection->printLogQuery(true);
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
return parent::_prepareCollection();
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
protected function _prepareColumns()
|
| 69 |
+
{
|
| 70 |
+
|
| 71 |
+
$this->addColumn('id', array(
|
| 72 |
+
'header' => Mage::helper('visitoripsecurity')->__('ID'),
|
| 73 |
+
'width' => '50px',
|
| 74 |
+
'index' => 'url_id',
|
| 75 |
+
'align' => 'center',
|
| 76 |
+
));
|
| 77 |
+
$this->addColumn('url', array(
|
| 78 |
+
'header' => Mage::helper('visitoripsecurity')->__('Last url'),
|
| 79 |
+
'align' => 'left',
|
| 80 |
+
'width' => '120px',
|
| 81 |
+
'type' => 'text',
|
| 82 |
+
'default' => '--',
|
| 83 |
+
'index' => 'url',
|
| 84 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_pretty'
|
| 85 |
+
));
|
| 86 |
+
$this->addColumn('visit_time', array(
|
| 87 |
+
'header' => Mage::helper('visitoripsecurity')->__('Visit Time'),
|
| 88 |
+
'align' => 'center',
|
| 89 |
+
'width' => '120px',
|
| 90 |
+
'type' => 'datetime',
|
| 91 |
+
'default' => '--',
|
| 92 |
+
'index' => 'visit_time',
|
| 93 |
+
'sortable' => true
|
| 94 |
+
));
|
| 95 |
+
$this->addColumn('remote_addr', array(
|
| 96 |
+
'header' => Mage::helper('visitoripsecurity')->__('IP address'),
|
| 97 |
+
'index' => 'remote_addr',
|
| 98 |
+
'width' => '80px',
|
| 99 |
+
'align' => 'center',
|
| 100 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_google'
|
| 101 |
+
));
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
//$this->print_a($this);
|
| 106 |
+
//var_dump($this);
|
| 107 |
+
|
| 108 |
+
return parent::_prepareColumns();
|
| 109 |
+
}
|
| 110 |
+
protected function _addColumnFilterToCollection($column)
|
| 111 |
+
{
|
| 112 |
+
$rs = Mage::getSingleton('core/resource');
|
| 113 |
+
|
| 114 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 115 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 116 |
+
$log_url = $rs->getTableName('log_url');
|
| 117 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 118 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 119 |
+
|
| 120 |
+
if ($this->getCollection()) {
|
| 121 |
+
if ($column->getId() == 'remote_addr') {
|
| 122 |
+
|
| 123 |
+
$cond = $column->getFilter()->getCondition();
|
| 124 |
+
if(!empty($cond)){
|
| 125 |
+
$field = new Zend_Db_Expr('INET_NTOA(vi.remote_addr)');
|
| 126 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
return $this;
|
| 130 |
+
}elseif ($column->getId() == 'visit_time') {
|
| 131 |
+
|
| 132 |
+
$cond = $column->getFilter()->getCondition();
|
| 133 |
+
if(!empty($cond)){
|
| 134 |
+
$field = 'main_table.visit_time';
|
| 135 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
return $this;
|
| 139 |
+
}elseif ($column->getId() == 'id') {
|
| 140 |
+
|
| 141 |
+
$cond = $column->getFilter()->getCondition();
|
| 142 |
+
if(!empty($cond)){
|
| 143 |
+
$field = 'main_table.url_id';
|
| 144 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
return $this;
|
| 148 |
+
}else{
|
| 149 |
+
return parent::_addColumnFilterToCollection($column);
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
public function getRowUrl($row)
|
| 154 |
+
{
|
| 155 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
public function getGridUrl()
|
| 159 |
+
{
|
| 160 |
+
return $this->getUrl('*/*/logurl', array('_current'=>true));
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Oneip/Block.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Oneip_Block extends Mage_Adminhtml_Block_Widget
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
parent::__construct();
|
| 27 |
+
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_VisitoripsecurityGrid_Block_Adminhtml_Visitoripsecurity_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
$html = parent::render($row);
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Blockthisip.php
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Blockthisip extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Input
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
if(!Mage::helper('visitoripsecurity')->checkIfBlocked($row->_data['remote_addr'])){
|
| 28 |
+
if(!Mage::helper('visitoripsecurity')->checkIfWhite($row->_data['remote_addr'])){
|
| 29 |
+
$html = '<button onclick="blockThisIp(this, '. $row->_data['remote_addr'] .'); return false">' . Mage::helper('visitoripsecurity')->__('Block') . '</button>';
|
| 30 |
+
}else{
|
| 31 |
+
$html = '';
|
| 32 |
+
}
|
| 33 |
+
}else{
|
| 34 |
+
$html = '<button onclick="unBlockThisIp(this, '. $row->_data['remote_addr'] .'); return false">' . Mage::helper('visitoripsecurity')->__('UnBlock') . '</button>';
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
return $html;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Count.php
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Count extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
/* Get The Email Address Using query From Model Using id of the customer as
|
| 27 |
+
$id=$row->getId();
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
$rs = Mage::getSingleton('core/resource');
|
| 31 |
+
|
| 32 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 33 |
+
$log_url = $rs->getTableName('log_url');
|
| 34 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 38 |
+
$this->setCollection($collection);
|
| 39 |
+
$select = $collection->getSelect();
|
| 40 |
+
$select->reset('from');
|
| 41 |
+
$select->from(array('main_table' => $visitor_info));
|
| 42 |
+
$select->where("remote_addr = '".$row->_data['remote_addr']."'");
|
| 43 |
+
|
| 44 |
+
//$collection->printLogQuery(true);
|
| 45 |
+
|
| 46 |
+
$arrData = $collection->getData();
|
| 47 |
+
if(empty($arrData)){
|
| 48 |
+
return '';
|
| 49 |
+
}
|
| 50 |
+
$in = "(";
|
| 51 |
+
foreach ($arrData as $k =>$v){
|
| 52 |
+
$in .= "'".$v['visitor_id']."',";
|
| 53 |
+
}
|
| 54 |
+
$in = trim($in, ",");
|
| 55 |
+
$in .= ")";
|
| 56 |
+
|
| 57 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 58 |
+
$this->setCollection($collection);
|
| 59 |
+
$select = $collection->getSelect();
|
| 60 |
+
$select->reset();
|
| 61 |
+
$select->from(array('main_table' => $log_url), array(new Zend_Db_Expr('COUNT(main_table.url_id) AS url_c')));
|
| 62 |
+
$select->where(new Zend_Db_Expr('main_table.visitor_id IN'.$in));
|
| 63 |
+
//$collection->printLogQuery(true);
|
| 64 |
+
|
| 65 |
+
$arrUrls = $collection->getData();
|
| 66 |
+
|
| 67 |
+
if(!empty($arrUrls)){
|
| 68 |
+
//var_dump($arrUrls);
|
| 69 |
+
$url_c = $arrUrls[0]['url_c'];
|
| 70 |
+
}else{
|
| 71 |
+
$url_c = '0';
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
return '<div style="word-wrap: break-word;">'.$url_c.'</div>';
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
?>
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Firstvisit.php
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Firstvisit extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
/* Get The Email Address Using query From Model Using id of the customer as
|
| 27 |
+
$id=$row->getId();
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
$rs = Mage::getSingleton('core/resource');
|
| 31 |
+
|
| 32 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 33 |
+
$log_url = $rs->getTableName('log_url');
|
| 34 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 35 |
+
|
| 36 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 37 |
+
$this->setCollection($collection);
|
| 38 |
+
$select = $collection->getSelect();
|
| 39 |
+
$select->reset('from');
|
| 40 |
+
$select->from(array('main_table' => $visitor_info));
|
| 41 |
+
$select->where("remote_addr = '".$row->_data['remote_addr']."'");
|
| 42 |
+
|
| 43 |
+
//$collection->printLogQuery(true);
|
| 44 |
+
|
| 45 |
+
$arrData = $collection->getData();
|
| 46 |
+
//var_dump($arrData);
|
| 47 |
+
if(empty($arrData)){
|
| 48 |
+
return '';
|
| 49 |
+
}
|
| 50 |
+
$in = "(";
|
| 51 |
+
foreach ($arrData as $k =>$v){
|
| 52 |
+
$in .= "'".$v['visitor_id']."',";
|
| 53 |
+
}
|
| 54 |
+
$in = trim($in, ",");
|
| 55 |
+
$in .= ")";
|
| 56 |
+
|
| 57 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 58 |
+
$this->setCollection($collection);
|
| 59 |
+
$select = $collection->getSelect();
|
| 60 |
+
$select->reset();
|
| 61 |
+
$select->from(array('main_table' => $log_url));
|
| 62 |
+
$select->joinLeft($log_url_info, $log_url_info.'.url_id=main_table.url_id');
|
| 63 |
+
$select->where(new Zend_Db_Expr('main_table.visitor_id IN'.$in));
|
| 64 |
+
$select->order('visit_time ASC');
|
| 65 |
+
$select->limit(1);
|
| 66 |
+
|
| 67 |
+
$arrUrls = $collection->getData();
|
| 68 |
+
//$collection->printLogQuery(true);
|
| 69 |
+
|
| 70 |
+
return $arrUrls[0]['visit_time'];
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
?>
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Google.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Google extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
/* Get The Email Address Using query From Model Using id of the customer as
|
| 27 |
+
$id=$row->getId();
|
| 28 |
+
*/
|
| 29 |
+
$ip = long2ip($row->getData($this->getColumn()->getIndex()));
|
| 30 |
+
|
| 31 |
+
return '<a href="http://www.google.com/search?q=whois:+'.$ip.'" target="_blank">'.$ip.'</a>';
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
?>
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Lasturl.php
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Lasturl extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
/* Get The Email Address Using query From Model Using id of the customer as
|
| 27 |
+
$id=$row->getId();
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
$rs = Mage::getSingleton('core/resource');
|
| 31 |
+
|
| 32 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 33 |
+
$log_url = $rs->getTableName('log_url');
|
| 34 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 38 |
+
$this->setCollection($collection);
|
| 39 |
+
$select = $collection->getSelect();
|
| 40 |
+
$select->reset('from');
|
| 41 |
+
$select->from(array('main_table' => $visitor_info));
|
| 42 |
+
$select->where("remote_addr = '".$row->_data['remote_addr']."'");
|
| 43 |
+
|
| 44 |
+
//$collection->printLogQuery(true);
|
| 45 |
+
|
| 46 |
+
$arrData = $collection->getData();
|
| 47 |
+
if(empty($arrData)){
|
| 48 |
+
return '';
|
| 49 |
+
}
|
| 50 |
+
$in = "(";
|
| 51 |
+
foreach ($arrData as $k =>$v){
|
| 52 |
+
$in .= "'".$v['visitor_id']."',";
|
| 53 |
+
}
|
| 54 |
+
$in = trim($in, ",");
|
| 55 |
+
$in .= ")";
|
| 56 |
+
|
| 57 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 58 |
+
$this->setCollection($collection);
|
| 59 |
+
$select = $collection->getSelect();
|
| 60 |
+
$select->reset();
|
| 61 |
+
$select->from(array('main_table' => $log_url));
|
| 62 |
+
$select->joinLeft($log_url_info, $log_url_info.'.url_id=main_table.url_id');
|
| 63 |
+
$select->where(new Zend_Db_Expr('main_table.visitor_id IN'.$in));
|
| 64 |
+
$select->order('visit_time DESC');
|
| 65 |
+
$select->limit(1);
|
| 66 |
+
|
| 67 |
+
$arrUrls = $collection->getData();
|
| 68 |
+
//$collection->printLogQuery(true);
|
| 69 |
+
|
| 70 |
+
$url = $arrUrls[0]['url'];
|
| 71 |
+
$base_url = Mage::getBaseUrl();
|
| 72 |
+
|
| 73 |
+
$url = str_ireplace($base_url, '', $url);
|
| 74 |
+
|
| 75 |
+
$collection = Mage::getModel('core/url_rewrite')->getCollection();
|
| 76 |
+
|
| 77 |
+
$select = $collection->getSelect();
|
| 78 |
+
$select->where("main_table.target_path LIKE '".$url."'");
|
| 79 |
+
|
| 80 |
+
//$collection->printLogQuery(true);
|
| 81 |
+
|
| 82 |
+
$arrData = $collection->getData();
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
if(!empty($arrData)){
|
| 86 |
+
foreach ($arrData as $k => $v){
|
| 87 |
+
if(!empty($v['request_path'])){
|
| 88 |
+
$pretty = $base_url.$v['request_path'];
|
| 89 |
+
break;
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
if(!empty($pretty)){
|
| 94 |
+
$pretty_url = $pretty;
|
| 95 |
+
}else{
|
| 96 |
+
$pretty_url = $arrUrls[0]['url'];
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
return '<div style="word-wrap: break-word;">'.$pretty_url.'</div>';
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
?>
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Lastvisit.php
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Lastvisit extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
/* Get The Email Address Using query From Model Using id of the customer as
|
| 27 |
+
$id=$row->getId();
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
$rs = Mage::getSingleton('core/resource');
|
| 31 |
+
|
| 32 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 33 |
+
$log_url = $rs->getTableName('log_url');
|
| 34 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 38 |
+
$this->setCollection($collection);
|
| 39 |
+
$select = $collection->getSelect();
|
| 40 |
+
$select->reset('from');
|
| 41 |
+
$select->from(array('main_table' => $visitor_info));
|
| 42 |
+
$select->where("remote_addr = '".$row->_data['remote_addr']."'");
|
| 43 |
+
|
| 44 |
+
//$collection->printLogQuery(true);
|
| 45 |
+
|
| 46 |
+
$arrData = $collection->getData();
|
| 47 |
+
if(empty($arrData)){
|
| 48 |
+
return '';
|
| 49 |
+
}
|
| 50 |
+
$in = "(";
|
| 51 |
+
foreach ($arrData as $k =>$v){
|
| 52 |
+
$in .= "'".$v['visitor_id']."',";
|
| 53 |
+
}
|
| 54 |
+
$in = trim($in, ",");
|
| 55 |
+
$in .= ")";
|
| 56 |
+
|
| 57 |
+
$collection = Mage::getModel('log/visitor')->getCollection();
|
| 58 |
+
$this->setCollection($collection);
|
| 59 |
+
$select = $collection->getSelect();
|
| 60 |
+
$select->reset();
|
| 61 |
+
$select->from(array('main_table' => $log_url));
|
| 62 |
+
$select->joinLeft($log_url_info, $log_url_info.'.url_id=main_table.url_id');
|
| 63 |
+
$select->where(new Zend_Db_Expr('main_table.visitor_id IN'.$in));
|
| 64 |
+
$select->order('visit_time DESC');
|
| 65 |
+
$select->limit(1);
|
| 66 |
+
|
| 67 |
+
$arrUrls = $collection->getData();
|
| 68 |
+
//$collection->printLogQuery(true);
|
| 69 |
+
|
| 70 |
+
return $arrUrls[0]['visit_time'];
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
?>
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Notes.php
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Notes extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Input
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
//$html = parent::render($row);
|
| 28 |
+
|
| 29 |
+
$html = '<input class="input-text " type="text" value="'.$row->_data['note'].'" onblur="updateNote(this, '. $row->_data['remote_addr'] .'); return false" name="note">';
|
| 30 |
+
|
| 31 |
+
//$html .= '<button onclick="updateNote(this, '. $row->_data['remote_addr'] .'); return false">' . Mage::helper('visitoripsecurity')->__('Update') . '</button>';
|
| 32 |
+
|
| 33 |
+
return $html;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Pretty.php
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Pretty extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
$url = $row->_data['url'];
|
| 28 |
+
$base_url = Mage::getBaseUrl();
|
| 29 |
+
|
| 30 |
+
$url = str_ireplace($base_url, '', $url);
|
| 31 |
+
|
| 32 |
+
$collection = Mage::getModel('core/url_rewrite')->getCollection();
|
| 33 |
+
|
| 34 |
+
$select = $collection->getSelect();
|
| 35 |
+
$select->where("main_table.target_path LIKE '".$url."'");
|
| 36 |
+
|
| 37 |
+
//$collection->printLogQuery(true);
|
| 38 |
+
|
| 39 |
+
$arrData = $collection->getData();
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
if(!empty($arrData)){
|
| 43 |
+
foreach ($arrData as $k => $v){
|
| 44 |
+
if(!empty($v['request_path'])){
|
| 45 |
+
$pretty = $base_url.$v['request_path'];
|
| 46 |
+
break;
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
if(!empty($pretty)){
|
| 51 |
+
echo $pretty;
|
| 52 |
+
}else{
|
| 53 |
+
echo $row->_data['url'];
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
}
|
| 57 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Watchthisip.php
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Watchthisip extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Input
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
if(!Mage::helper('visitoripsecurity')->checkIfWatch($row->_data['remote_addr'])){
|
| 29 |
+
$html = '<button onclick="watchThisIp(this, '. $row->_data['remote_addr'] .'); return false">' . Mage::helper('visitoripsecurity')->__('Watchlist') . '</button>';
|
| 30 |
+
}else{
|
| 31 |
+
$html = '<button onclick="unWatchThisIp(this, '. $row->_data['remote_addr'] .'); return false">' . Mage::helper('visitoripsecurity')->__('Remove watch') . '</button>';
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
return $html;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Renderer/Whitethisip.php
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Renderer_Whitethisip extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Input
|
| 23 |
+
{
|
| 24 |
+
public function render(Varien_Object $row)
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
if(!Mage::helper('visitoripsecurity')->checkIfBlocked($row->_data['remote_addr'])){
|
| 28 |
+
if(!Mage::helper('visitoripsecurity')->checkIfWhite($row->_data['remote_addr'])){
|
| 29 |
+
$html = '<button onclick="whiteThisIp(this, '. $row->_data['remote_addr'] .'); return false">' . Mage::helper('visitoripsecurity')->__('Whitelist') . '</button>';
|
| 30 |
+
}else{
|
| 31 |
+
$html = '<button onclick="unWhiteThisIp(this, '. $row->_data['remote_addr'] .'); return false">' . Mage::helper('visitoripsecurity')->__('Remove white') . '</button>';
|
| 32 |
+
}
|
| 33 |
+
}else{
|
| 34 |
+
$html = '';
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
return $html;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/Watch/Grid.php
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_Watch_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
parent::__construct();
|
| 27 |
+
|
| 28 |
+
$this->setId('watchGrid');
|
| 29 |
+
// This is the primary key of the database
|
| 30 |
+
$this->setDefaultSort('url_c');
|
| 31 |
+
$this->setDefaultDir('DESC');
|
| 32 |
+
$this->setSaveParametersInSession(true);
|
| 33 |
+
$this->setUseAjax(false);
|
| 34 |
+
|
| 35 |
+
$this->_headerText = Mage::helper('visitoripsecurity')->__('Ip logs');
|
| 36 |
+
|
| 37 |
+
}
|
| 38 |
+
protected function _prepareCollection(){
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
$model = Mage::getModel('log/visitor');
|
| 42 |
+
$collection = $model->getCollection();
|
| 43 |
+
|
| 44 |
+
$rs = Mage::getSingleton('core/resource');
|
| 45 |
+
|
| 46 |
+
$visitor = $rs->getTableName('log_visitor');
|
| 47 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 48 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 49 |
+
|
| 50 |
+
$log_url = $rs->getTableName('log_url');
|
| 51 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 52 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 53 |
+
|
| 54 |
+
$select = $collection->getSelect();
|
| 55 |
+
$select->reset('columns');
|
| 56 |
+
$select->reset('from');
|
| 57 |
+
|
| 58 |
+
$select->from(array('main_table'=>$visitor), array('main_table.visitor_id', 'MAX(main_table.last_visit_at) AS last_visit_time'));
|
| 59 |
+
|
| 60 |
+
$select->joinLeft(array('vi'=>$visitor_info), 'vi.visitor_id=main_table.visitor_id', 'vi.remote_addr');
|
| 61 |
+
$select->joinLeft(array('lu'=>$log_url), 'lu.visitor_id=main_table.visitor_id', array('url_c'=>'COUNT(*)'));
|
| 62 |
+
$select->joinLeft(array('lui'=>$log_url_info), 'lui.url_id=last_url_id', array('last_url'=>'lui.url'));
|
| 63 |
+
$select->joinLeft(array('lrn'=>$ip_notes), 'lrn.remote_addr=vi.remote_addr', array('blocked','white','note','watch'));
|
| 64 |
+
|
| 65 |
+
$select->group('vi.remote_addr');
|
| 66 |
+
$select->having('lrn.watch=1');
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
//$collection->addFieldToSelect(new Zend_Db_Expr('t.*'));
|
| 70 |
+
//$collection->addAtributeToFilter('url_c');
|
| 71 |
+
//$collection->addFieldToSelect(new Zend_Db_Expr($visitor_online.'.last_visit_at AS last_vis_at'));
|
| 72 |
+
//$collection->getSelect()->joinLeft(new Zend_Db_Expr('(SELECT '.$log_url.'.url_id, '.$log_url.'.visitor_id, '.$log_url.'.visit_time AS last_visit_time FROM '.$log_url.' ORDER BY '.$log_url.'.visit_time DESC LIMIT 1)'), 't.visitor_id = main_table.visitor_id');
|
| 73 |
+
|
| 74 |
+
//$collection->getSelect()->joinLeft(new Zend_Db_Expr('(SELECT COUNT('.$log_url.'.url_id) AS url_c,'.$log_url.'.visitor_id FROM '.$log_url.')'), 't_2.visitor_id = main_table.visitor_id');
|
| 75 |
+
|
| 76 |
+
//$collection->getSelect()->joinLeft($visitor_info, $visitor_info.'.visitor_id = main_table.visitor_id');
|
| 77 |
+
//$collection->getSelect()->joinLeft($visitor_online, $visitor_online.'.visitor_id = main_table.visitor_id');
|
| 78 |
+
//$collection->getSelect()->joinLeft($log_url_info, $log_url_info.'.url_id = t.url_id');
|
| 79 |
+
//$collection->getSelect()->joinLeft(array('ip' => $ip_notes), 'ip.remote_addr = '.$visitor_info.'.remote_addr', array('note'));
|
| 80 |
+
//$collection->getSelect()->group($visitor_info.'.remote_addr');
|
| 81 |
+
//$collection->addFieldToSelect(new Zend_Db_Expr($log_url_info.'.url'), 'last_url');
|
| 82 |
+
|
| 83 |
+
$this->setCollection($collection);
|
| 84 |
+
|
| 85 |
+
//$collection->printLogQuery(true);
|
| 86 |
+
|
| 87 |
+
//die();
|
| 88 |
+
|
| 89 |
+
return parent::_prepareCollection();
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
protected function _prepareColumns()
|
| 93 |
+
{
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
$this->addColumn('url_c', array(
|
| 97 |
+
'header' => Mage::helper('visitoripsecurity')->__('Count'),
|
| 98 |
+
'width' => '50px',
|
| 99 |
+
'index' => 'url_c',
|
| 100 |
+
'align' => 'center',
|
| 101 |
+
));
|
| 102 |
+
|
| 103 |
+
$this->addColumn('remote_addr', array(
|
| 104 |
+
'header' => Mage::helper('visitoripsecurity')->__('IP address'),
|
| 105 |
+
'index' => 'remote_addr',
|
| 106 |
+
'width' => '80px',
|
| 107 |
+
'align' => 'center',
|
| 108 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_google'
|
| 109 |
+
));
|
| 110 |
+
|
| 111 |
+
$this->addColumn('action',
|
| 112 |
+
array(
|
| 113 |
+
'header' => Mage::helper('customer')->__('View'),
|
| 114 |
+
'width' => '50px',
|
| 115 |
+
'type' => 'action',
|
| 116 |
+
'getter' => 'getRemoteAddr',
|
| 117 |
+
'align' => 'center',
|
| 118 |
+
'actions' => array(
|
| 119 |
+
array(
|
| 120 |
+
'caption' => Mage::helper('customer')->__('View'),
|
| 121 |
+
'url' => array('base'=> '*/*/logurl'),
|
| 122 |
+
'field' => 'remote_addr'
|
| 123 |
+
)
|
| 124 |
+
),
|
| 125 |
+
'filter' => false,
|
| 126 |
+
'sortable' => false,
|
| 127 |
+
'index' => 'view',
|
| 128 |
+
'is_system' => true,
|
| 129 |
+
));
|
| 130 |
+
$this->addColumn('note', array(
|
| 131 |
+
|
| 132 |
+
'header' => Mage::helper('visitoripsecurity')->__('Notes'),
|
| 133 |
+
'align' => 'left',
|
| 134 |
+
'width' => '80px',
|
| 135 |
+
'index' => 'note',
|
| 136 |
+
'type' => 'text',
|
| 137 |
+
'align' => 'center',
|
| 138 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_notes'
|
| 139 |
+
));
|
| 140 |
+
|
| 141 |
+
$this->addColumn('block',
|
| 142 |
+
array(
|
| 143 |
+
'header' => Mage::helper('customer')->__('Block'),
|
| 144 |
+
'width' => '50px',
|
| 145 |
+
'type' => 'action',
|
| 146 |
+
'getter' => 'getId',
|
| 147 |
+
'align' => 'center',
|
| 148 |
+
'filter' => false,
|
| 149 |
+
'sortable' => false,
|
| 150 |
+
'index' => 'block',
|
| 151 |
+
'is_system' => true,
|
| 152 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_blockthisip'
|
| 153 |
+
));
|
| 154 |
+
$this->addColumn('whitelist',
|
| 155 |
+
array(
|
| 156 |
+
'header' => Mage::helper('customer')->__('Whitelist'),
|
| 157 |
+
'width' => '50px',
|
| 158 |
+
'type' => 'action',
|
| 159 |
+
'getter' => 'getId',
|
| 160 |
+
'align' => 'center',
|
| 161 |
+
'filter' => false,
|
| 162 |
+
'sortable' => false,
|
| 163 |
+
'index' => 'whitelist',
|
| 164 |
+
'is_system' => true,
|
| 165 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_whitethisip'
|
| 166 |
+
));
|
| 167 |
+
$this->addColumn('watchlist',
|
| 168 |
+
array(
|
| 169 |
+
'header' => Mage::helper('customer')->__('Watchlist'),
|
| 170 |
+
'width' => '50px',
|
| 171 |
+
'type' => 'action',
|
| 172 |
+
'getter' => 'getId',
|
| 173 |
+
'align' => 'center',
|
| 174 |
+
'filter' => false,
|
| 175 |
+
'sortable' => false,
|
| 176 |
+
'index' => 'watchlist',
|
| 177 |
+
'is_system' => true,
|
| 178 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_watchthisip'
|
| 179 |
+
));
|
| 180 |
+
|
| 181 |
+
$this->addColumn('first_visit_at', array(
|
| 182 |
+
'header' => Mage::helper('visitoripsecurity')->__('First visit Time'),
|
| 183 |
+
'align' => 'center',
|
| 184 |
+
'width' => '120px',
|
| 185 |
+
'type' => 'datetime',
|
| 186 |
+
'default' => '--',
|
| 187 |
+
'index' => 'first_visit_at',
|
| 188 |
+
'sortable' => true,
|
| 189 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_firstvisit'
|
| 190 |
+
));
|
| 191 |
+
|
| 192 |
+
$this->addColumn('last_visit_at', array(
|
| 193 |
+
'header' => Mage::helper('visitoripsecurity')->__('Last visit Time'),
|
| 194 |
+
'align' => 'center',
|
| 195 |
+
'width' => '120px',
|
| 196 |
+
'type' => 'datetime',
|
| 197 |
+
'default' => '--',
|
| 198 |
+
'index' => 'last_visit_time',
|
| 199 |
+
'sortable' => true
|
| 200 |
+
));
|
| 201 |
+
|
| 202 |
+
$this->addColumn('last_url', array(
|
| 203 |
+
'header' => Mage::helper('visitoripsecurity')->__('Last url'),
|
| 204 |
+
'align' => 'center',
|
| 205 |
+
'width' => '120px',
|
| 206 |
+
'type' => 'text',
|
| 207 |
+
'default' => '--',
|
| 208 |
+
'index' => 'last_url',
|
| 209 |
+
'filter' => false,
|
| 210 |
+
'sortable' => false,
|
| 211 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_lasturl'
|
| 212 |
+
));
|
| 213 |
+
|
| 214 |
+
//$this->print_a($this);
|
| 215 |
+
//var_dump($this);
|
| 216 |
+
|
| 217 |
+
return parent::_prepareColumns();
|
| 218 |
+
}
|
| 219 |
+
protected function _addColumnFilterToCollection($column)
|
| 220 |
+
{
|
| 221 |
+
$rs = Mage::getSingleton('core/resource');
|
| 222 |
+
|
| 223 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 224 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 225 |
+
$log_url = $rs->getTableName('log_url');
|
| 226 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 227 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 228 |
+
|
| 229 |
+
if ($this->getCollection()) {
|
| 230 |
+
if ($column->getId() == 'remote_addr') {
|
| 231 |
+
|
| 232 |
+
$cond = $column->getFilter()->getCondition();
|
| 233 |
+
if(!empty($cond)){
|
| 234 |
+
$field = new Zend_Db_Expr('INET_NTOA(vi.remote_addr)');
|
| 235 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
return $this;
|
| 239 |
+
}elseif ($column->getId() == 'last_visit_at') {
|
| 240 |
+
|
| 241 |
+
$cond = $column->getFilter()->getCondition();
|
| 242 |
+
if(!empty($cond)){
|
| 243 |
+
$field = 'main_table.last_visit_at';
|
| 244 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
return $this;
|
| 248 |
+
}elseif ($column->getId() == 'first_visit_at') {
|
| 249 |
+
|
| 250 |
+
$cond = $column->getFilter()->getCondition();
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
if(!empty($cond)){
|
| 254 |
+
$field = 'main_table.first_visit_at';
|
| 255 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
return $this;
|
| 259 |
+
}elseif ($column->getId() == 'note') {
|
| 260 |
+
|
| 261 |
+
$cond = $column->getFilter()->getCondition();
|
| 262 |
+
if(!empty($cond)){
|
| 263 |
+
$field = new Zend_Db_Expr('lrn.note');
|
| 264 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 265 |
+
}
|
| 266 |
+
return $this;
|
| 267 |
+
|
| 268 |
+
}else{
|
| 269 |
+
return parent::_addColumnFilterToCollection($column);
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
public function getRowUrl($row)
|
| 274 |
+
{
|
| 275 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
public function getGridUrl()
|
| 279 |
+
{
|
| 280 |
+
return $this->getUrl('*/*/watch', array('_current'=>true));
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Visitoripsecurity/White/Grid.php
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Visitoripsecurity_White_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
parent::__construct();
|
| 27 |
+
|
| 28 |
+
$this->setId('whiteGrid');
|
| 29 |
+
// This is the primary key of the database
|
| 30 |
+
//$this->setDefaultSort('url_c');
|
| 31 |
+
$this->setDefaultDir('DESC');
|
| 32 |
+
$this->setSaveParametersInSession(true);
|
| 33 |
+
$this->setUseAjax(false);
|
| 34 |
+
|
| 35 |
+
//echo 'asd';used
|
| 36 |
+
}
|
| 37 |
+
protected function _prepareCollection(){
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 41 |
+
$collection = $model->getCollection();
|
| 42 |
+
|
| 43 |
+
$rs = Mage::getSingleton('core/resource');
|
| 44 |
+
|
| 45 |
+
$visitor = $rs->getTableName('log_visitor');
|
| 46 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 47 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 48 |
+
|
| 49 |
+
$log_url = $rs->getTableName('log_url');
|
| 50 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 51 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 52 |
+
|
| 53 |
+
$select = $collection->getSelect();
|
| 54 |
+
|
| 55 |
+
$select->where('main_table.white = 1');
|
| 56 |
+
|
| 57 |
+
$this->setCollection($collection);
|
| 58 |
+
|
| 59 |
+
//$collection->printLogQuery(true);
|
| 60 |
+
|
| 61 |
+
//die();
|
| 62 |
+
|
| 63 |
+
return parent::_prepareCollection();
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
protected function _prepareColumns()
|
| 67 |
+
{
|
| 68 |
+
|
| 69 |
+
$this->addColumn('url_c', array(
|
| 70 |
+
'header' => Mage::helper('visitoripsecurity')->__('Count'),
|
| 71 |
+
'width' => '50px',
|
| 72 |
+
'align' => 'center',
|
| 73 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_count',
|
| 74 |
+
'sortable' => false,
|
| 75 |
+
'filter'=> false
|
| 76 |
+
));
|
| 77 |
+
$this->addColumn('remote_addr', array(
|
| 78 |
+
'header' => Mage::helper('visitoripsecurity')->__('IP address'),
|
| 79 |
+
'index' => 'remote_addr',
|
| 80 |
+
'width' => '80px',
|
| 81 |
+
'align' => 'center',
|
| 82 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_google'
|
| 83 |
+
));
|
| 84 |
+
|
| 85 |
+
$this->addColumn('action',
|
| 86 |
+
array(
|
| 87 |
+
'header' => Mage::helper('customer')->__('View'),
|
| 88 |
+
'width' => '50px',
|
| 89 |
+
'type' => 'action',
|
| 90 |
+
'getter' => 'getRemoteAddr',
|
| 91 |
+
'align' => 'center',
|
| 92 |
+
'actions' => array(
|
| 93 |
+
array(
|
| 94 |
+
'caption' => Mage::helper('customer')->__('View'),
|
| 95 |
+
'url' => array('base'=> '*/*/logurl'),
|
| 96 |
+
'field' => 'remote_addr'
|
| 97 |
+
)
|
| 98 |
+
),
|
| 99 |
+
'filter' => false,
|
| 100 |
+
'sortable' => false,
|
| 101 |
+
'index' => 'view',
|
| 102 |
+
'is_system' => true,
|
| 103 |
+
));
|
| 104 |
+
$this->addColumn('note', array(
|
| 105 |
+
|
| 106 |
+
'header' => Mage::helper('visitoripsecurity')->__('Notes'),
|
| 107 |
+
'align' => 'left',
|
| 108 |
+
'width' => '80px',
|
| 109 |
+
'index' => 'note',
|
| 110 |
+
'type' => 'text',
|
| 111 |
+
'align' => 'center',
|
| 112 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_notes'
|
| 113 |
+
));
|
| 114 |
+
|
| 115 |
+
$this->addColumn('whitelist',
|
| 116 |
+
array(
|
| 117 |
+
'header' => Mage::helper('customer')->__('Whitelist'),
|
| 118 |
+
'width' => '50px',
|
| 119 |
+
'type' => 'action',
|
| 120 |
+
'getter' => 'getId',
|
| 121 |
+
'align' => 'center',
|
| 122 |
+
'filter' => false,
|
| 123 |
+
'sortable' => false,
|
| 124 |
+
'index' => 'whitelist',
|
| 125 |
+
'is_system' => true,
|
| 126 |
+
'renderer' => 'visitoripsecurity/adminhtml_visitoripsecurity_renderer_whitethisip'
|
| 127 |
+
));
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
//$this->print_a($this);
|
| 131 |
+
//var_dump($this);
|
| 132 |
+
|
| 133 |
+
return parent::_prepareColumns();
|
| 134 |
+
}
|
| 135 |
+
protected function _addColumnFilterToCollection($column)
|
| 136 |
+
{
|
| 137 |
+
$rs = Mage::getSingleton('core/resource');
|
| 138 |
+
|
| 139 |
+
$visitor_online = $rs->getTableName('log_visitor_online');
|
| 140 |
+
$visitor_info = $rs->getTableName('log_visitor_info');
|
| 141 |
+
$log_url = $rs->getTableName('log_url');
|
| 142 |
+
$log_url_info = $rs->getTableName('log_url_info');
|
| 143 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 144 |
+
|
| 145 |
+
if ($this->getCollection()) {
|
| 146 |
+
if ($column->getId() == 'remote_addr') {
|
| 147 |
+
|
| 148 |
+
$cond = $column->getFilter()->getCondition();
|
| 149 |
+
if(!empty($cond)){
|
| 150 |
+
$field = new Zend_Db_Expr('INET_NTOA(main_table.remote_addr)');
|
| 151 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
return $this;
|
| 155 |
+
}elseif ($column->getId() == 'last_visit_at') {
|
| 156 |
+
|
| 157 |
+
$cond = $column->getFilter()->getCondition();
|
| 158 |
+
if(!empty($cond)){
|
| 159 |
+
$field = 'main_table.last_visit_at';
|
| 160 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
return $this;
|
| 164 |
+
}elseif ($column->getId() == 'first_visit_at') {
|
| 165 |
+
|
| 166 |
+
$cond = $column->getFilter()->getCondition();
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
if(!empty($cond)){
|
| 170 |
+
$field = 'main_table.first_visit_at';
|
| 171 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
return $this;
|
| 175 |
+
}elseif ($column->getId() == 'note') {
|
| 176 |
+
|
| 177 |
+
$cond = $column->getFilter()->getCondition();
|
| 178 |
+
if(!empty($cond)){
|
| 179 |
+
$field = 'main_table.note';
|
| 180 |
+
$this->getCollection()->addFieldToFilter($field , $cond);
|
| 181 |
+
}
|
| 182 |
+
return $this;
|
| 183 |
+
|
| 184 |
+
}else{
|
| 185 |
+
return parent::_addColumnFilterToCollection($column);
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
public function getRowUrl($row)
|
| 190 |
+
{
|
| 191 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
public function getGridUrl()
|
| 195 |
+
{
|
| 196 |
+
return $this->getUrl('*/*/white', array('_current'=>true));
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/Watch.php
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_Watch extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
$this->_controller = 'adminhtml_visitoripsecurity_watch';
|
| 28 |
+
$this->_blockGroup = 'visitoripsecurity';
|
| 29 |
+
$this->_headerText = Mage::helper('visitoripsecurity')->__('Watch list');
|
| 30 |
+
|
| 31 |
+
$this->_addButton("view_list", array('label' => Mage::helper('visitoripsecurity')->__('View list'),
|
| 32 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/index')."')"));
|
| 33 |
+
$this->_addButton("view_blocked", array('label' => Mage::helper('visitoripsecurity')->__('View blocked'),
|
| 34 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/blocked')."')"));
|
| 35 |
+
$this->_addButton("view_white", array('label' => Mage::helper('visitoripsecurity')->__('View white list'),
|
| 36 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/white')."')"));
|
| 37 |
+
$this->_addButton("view_watch", array('label' => Mage::helper('visitoripsecurity')->__('View watch list'),
|
| 38 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/watch')."')"));
|
| 39 |
+
$this->_addButton("one_ip", array('label' => Mage::helper('visitoripsecurity')->__('Block ip classes'),
|
| 40 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/oneip')."')"));
|
| 41 |
+
|
| 42 |
+
parent::__construct();
|
| 43 |
+
$this->removeButton('add');
|
| 44 |
+
|
| 45 |
+
}
|
| 46 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Block/Adminhtml/White.php
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Block_Adminhtml_White extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 23 |
+
{
|
| 24 |
+
public function __construct()
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
$this->_controller = 'adminhtml_visitoripsecurity_white';
|
| 28 |
+
$this->_blockGroup = 'visitoripsecurity';
|
| 29 |
+
$this->_headerText = Mage::helper('visitoripsecurity')->__('White list');
|
| 30 |
+
|
| 31 |
+
$this->_addButton("view_list", array('label' => Mage::helper('visitoripsecurity')->__('View list'),
|
| 32 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/index')."')"));
|
| 33 |
+
$this->_addButton("view_blocked", array('label' => Mage::helper('visitoripsecurity')->__('View blocked'),
|
| 34 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/blocked')."')"));
|
| 35 |
+
$this->_addButton("view_white", array('label' => Mage::helper('visitoripsecurity')->__('View white list'),
|
| 36 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/white')."')"));
|
| 37 |
+
$this->_addButton("view_watch", array('label' => Mage::helper('visitoripsecurity')->__('View watch list'),
|
| 38 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/watch')."')"));
|
| 39 |
+
$this->_addButton("one_ip", array('label' => Mage::helper('visitoripsecurity')->__('Block ip classes'),
|
| 40 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/oneip')."')"));
|
| 41 |
+
|
| 42 |
+
parent::__construct();
|
| 43 |
+
$this->removeButton('add');
|
| 44 |
+
|
| 45 |
+
}
|
| 46 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Helper/Data.php
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Helper_Data extends Mage_Core_Helper_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function __construct() {
|
| 25 |
+
$this->cacheFile = Mage::getBaseDir('cache') . '/blocked_ips.dat';
|
| 26 |
+
$this->cacheFileWhite = Mage::getBaseDir('cache') . '/white_ips.dat';
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public function getBlocked() {
|
| 30 |
+
if(file_exists($this->cacheFile)) {
|
| 31 |
+
$arrBlocked = unserialize(file_get_contents($this->cacheFile));
|
| 32 |
+
} else {
|
| 33 |
+
file_put_contents($this->cacheFile,'');
|
| 34 |
+
}
|
| 35 |
+
if(empty($arrBlocked)){
|
| 36 |
+
$arrBlocked = array();
|
| 37 |
+
}
|
| 38 |
+
return $arrBlocked;
|
| 39 |
+
}
|
| 40 |
+
public function getWhite() {
|
| 41 |
+
if(file_exists($this->cacheFileWhite)) {
|
| 42 |
+
$arrWhite = unserialize(file_get_contents($this->cacheFileWhite));
|
| 43 |
+
} else {
|
| 44 |
+
file_put_contents($this->cacheFileWhite,'');
|
| 45 |
+
}
|
| 46 |
+
if(empty($arrWhite)){
|
| 47 |
+
$arrWhite = array();
|
| 48 |
+
}
|
| 49 |
+
return $arrWhite;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
public function checkIfBlocked($ip){
|
| 53 |
+
|
| 54 |
+
if(stripos($ip, '.')===false){
|
| 55 |
+
$ip = long2ip($ip);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
$arrIp = explode('.', $ip);
|
| 59 |
+
|
| 60 |
+
if(file_exists($this->cacheFile)) {
|
| 61 |
+
$arrBlocked = unserialize(file_get_contents($this->cacheFile));
|
| 62 |
+
}
|
| 63 |
+
if(!empty($arrBlocked)){
|
| 64 |
+
foreach($arrBlocked as $v){
|
| 65 |
+
|
| 66 |
+
$tmp_ip = explode('.', $v);
|
| 67 |
+
$found = 0;
|
| 68 |
+
foreach($tmp_ip as $key => $val){
|
| 69 |
+
if($val == '*'){
|
| 70 |
+
$found++;
|
| 71 |
+
}elseif($arrIp[$key] == $val){
|
| 72 |
+
$found++;
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
if($found == 4){
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
return false;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
public function checkIfWhite($ip){
|
| 84 |
+
|
| 85 |
+
if(stripos($ip, '.')===false){
|
| 86 |
+
$ip = long2ip($ip);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
$arrIp = explode('.', $ip);
|
| 90 |
+
|
| 91 |
+
if(file_exists($this->cacheFileWhite)) {
|
| 92 |
+
$arrWhite = unserialize(file_get_contents($this->cacheFileWhite));
|
| 93 |
+
}
|
| 94 |
+
if(!empty($arrWhite)){
|
| 95 |
+
foreach($arrWhite as $v){
|
| 96 |
+
|
| 97 |
+
$tmp_ip = explode('.', $v);
|
| 98 |
+
$found = 0;
|
| 99 |
+
foreach($tmp_ip as $key => $val){
|
| 100 |
+
if($val == '*'){
|
| 101 |
+
$found++;
|
| 102 |
+
}elseif($arrIp[$key] == $val){
|
| 103 |
+
$found++;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
if($found == 4){
|
| 107 |
+
return true;
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
return false;
|
| 113 |
+
}
|
| 114 |
+
public function checkIfWatch($ip){
|
| 115 |
+
|
| 116 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 117 |
+
$collection = $model->getCollection();
|
| 118 |
+
|
| 119 |
+
$select = $collection->getSelect();
|
| 120 |
+
$select->where("main_table.watch = '1'");
|
| 121 |
+
$select->where("main_table.remote_addr = '".$ip."'");
|
| 122 |
+
|
| 123 |
+
$arrData = $collection->getData();
|
| 124 |
+
|
| 125 |
+
if(empty($arrData)){
|
| 126 |
+
return false;
|
| 127 |
+
}else{
|
| 128 |
+
return true;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
}
|
| 133 |
+
public function clearCache() {
|
| 134 |
+
unlink($this->cacheFile);
|
| 135 |
+
unlink($this->cacheFileWhite);
|
| 136 |
+
}
|
| 137 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Log/Remoteaddr/Notes.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Log_Remoteaddr_Notes extends Mage_Core_Model_Abstract{
|
| 23 |
+
|
| 24 |
+
protected function _construct(){
|
| 25 |
+
parent::_construct();
|
| 26 |
+
$this->_init('visitoripsecurity/log_remoteaddr_notes');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Log/Url.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Log_Url extends Mage_Core_Model_Abstract{
|
| 23 |
+
|
| 24 |
+
protected function _construct(){
|
| 25 |
+
parent::_construct();
|
| 26 |
+
$this->_init('visitoripsecurity/log_url');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Remoteaddr/Notes.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Mysql4_Log_Remoteaddr_Notes extends Mage_Core_Model_Mysql4_Abstract{
|
| 23 |
+
public function _construct(){
|
| 24 |
+
$this->_init('visitoripsecurity/log_remoteaddr_notes', 'id');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Remoteaddr/Notes/Collection.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Mysql4_Log_Remoteaddr_Notes_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function _construct()
|
| 25 |
+
{
|
| 26 |
+
parent::_construct();
|
| 27 |
+
$this->_init('visitoripsecurity/log_remoteaddr_notes');
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Url.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Mysql4_Log_Url extends Mage_Core_Model_Mysql4_Abstract{
|
| 23 |
+
public function _construct(){
|
| 24 |
+
$this->_init('visitoripsecurity/log_url', 'id');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Log/Url/Collection.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Briel_Visitoripsecurity_Model_Mysql4_Log_Url_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function _construct()
|
| 5 |
+
{
|
| 6 |
+
parent::_construct();
|
| 7 |
+
$this->_init('visitoripsecurity/log_url');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Visitoripsecurity.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Mysql4_Visitoripsecurity extends Mage_Core_Model_Mysql4_Abstract
|
| 23 |
+
{
|
| 24 |
+
public function _construct()
|
| 25 |
+
{
|
| 26 |
+
|
| 27 |
+
$this->_init('log/visitor', 'visitor_id');
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Mysql4/Visitoripsecurity/Collection.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Mysql4_Visitoripsecurity_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 23 |
+
{
|
| 24 |
+
|
| 25 |
+
public function getSelectCountSql()
|
| 26 |
+
{
|
| 27 |
+
$this -> _renderFilters();
|
| 28 |
+
|
| 29 |
+
$rs = Mage::getSingleton('core/resource');
|
| 30 |
+
|
| 31 |
+
//$log_visitor_info = $rs->getTableName('log_visitor_info');
|
| 32 |
+
$ip_notes = $rs->getTableName('log_remoteaddr_notes');
|
| 33 |
+
|
| 34 |
+
//echo 'visitoripsecurity collection';
|
| 35 |
+
$countSelect = clone $this -> getSelect();
|
| 36 |
+
$countSelect -> reset(Zend_Db_Select::ORDER);
|
| 37 |
+
$countSelect -> reset(Zend_Db_Select::LIMIT_COUNT);
|
| 38 |
+
$countSelect -> reset(Zend_Db_Select::LIMIT_OFFSET);
|
| 39 |
+
$countSelect -> reset(Zend_Db_Select::COLUMNS);
|
| 40 |
+
|
| 41 |
+
$countSelect -> from('', 'COUNT(DISTINCT vi.remote_addr)');
|
| 42 |
+
|
| 43 |
+
$countSelect -> resetJoinLeft();
|
| 44 |
+
|
| 45 |
+
//$countSelect -> joinLeft(array('lrn'=>$ip_notes), 'lrn.remote_addr=vi.remote_addr', array('blocked','white','note'));
|
| 46 |
+
$countSelect -> reset('group');
|
| 47 |
+
$countSelect -> reset('having');
|
| 48 |
+
|
| 49 |
+
return $countSelect;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Notes.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Notes extends Mage_Core_Model_Abstract{
|
| 23 |
+
|
| 24 |
+
protected function _construct(){
|
| 25 |
+
parent::_construct();
|
| 26 |
+
$this->_init('visitoripsecurity/log_remoteaddr_notes');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
}
|
app/code/local/Briel/Visitoripsecurity/Model/Observer.php
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Model_Observer {
|
| 23 |
+
|
| 24 |
+
protected $_sendEmails = null;
|
| 25 |
+
protected $_sendEmailsTo = null;
|
| 26 |
+
protected $_firstVisitsLimit = null;
|
| 27 |
+
protected $_secondVisitsLimit = null;
|
| 28 |
+
|
| 29 |
+
public function checkBlocked() {
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
$this->_sendEmails = Mage::getStoreConfig('brielvisitoripsecurity/visitoripsecurityadmin/send_emails');
|
| 33 |
+
$this->_sendEmailsTo = Mage::getStoreConfig('brielvisitoripsecurity/visitoripsecurityadmin/email_to');
|
| 34 |
+
$this->_firstVisitsLimit = Mage::getStoreConfig('brielvisitoripsecurity/visitoripsecurityadmin/first_limit');
|
| 35 |
+
$this->_secondVisitsLimit = Mage::getStoreConfig('brielvisitoripsecurity/visitoripsecurityadmin/second_limit');
|
| 36 |
+
|
| 37 |
+
if(empty($this->_sendEmailsTo)){
|
| 38 |
+
$this->_sendEmailsTo = Mage::getStoreConfig('trans_email/ident_general/email');
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
$helper = Mage::helper ( 'visitoripsecurity' );
|
| 42 |
+
|
| 43 |
+
$ip = $_SERVER ['REMOTE_ADDR'];
|
| 44 |
+
if ($helper->checkIfBlocked ( $ip )) {
|
| 45 |
+
header ( 'HTTP/1.0 403 Access Denied/Forbidden' );
|
| 46 |
+
exit ();
|
| 47 |
+
} elseif ($helper->checkIfWhite ( $ip )) {
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
if($this->_sendEmails){
|
| 53 |
+
|
| 54 |
+
$this->sendFirstLimit($ip);
|
| 55 |
+
|
| 56 |
+
$this->sendSecondLimit($ip);
|
| 57 |
+
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
public function sendFirstLimit($ip){
|
| 64 |
+
|
| 65 |
+
$collection = Mage::getModel ( 'log/visitor' )->getCollection ();
|
| 66 |
+
|
| 67 |
+
$rs = Mage::getSingleton ( 'core/resource' );
|
| 68 |
+
|
| 69 |
+
$ip_notes = $rs->getTableName ( 'log_remoteaddr_notes' );
|
| 70 |
+
$table_visitor_info = $rs->getTableName ( 'log_visitor_info' );
|
| 71 |
+
$table_log_url = $rs->getTableName ( 'log_url' );
|
| 72 |
+
|
| 73 |
+
$select = $collection->getSelect ();
|
| 74 |
+
$select->reset ( 'from' );
|
| 75 |
+
$select->reset ( 'columns' );
|
| 76 |
+
$select->from ( array ('main_table' => $table_visitor_info ), array ('visitor_id', 'remote_addr' ) );
|
| 77 |
+
|
| 78 |
+
$select->joinLeft ( array ('lu' => $table_log_url ), 'lu.visitor_id = main_table.visitor_id', array ('url_count' => new Zend_Db_Expr ( 'COUNT(lu.url_id)' ) ) );
|
| 79 |
+
$select->where ( "main_table.remote_addr = '" . ip2long ( $ip ) . "'" );
|
| 80 |
+
$select->where ( "lu.visit_time > DATE(NOW() - INTERVAL 1 DAY)" );
|
| 81 |
+
// $collection->printLogQuery(true);
|
| 82 |
+
|
| 83 |
+
$arrData = $collection->getData ();
|
| 84 |
+
//var_dump($arrData);
|
| 85 |
+
$arr = array ();
|
| 86 |
+
|
| 87 |
+
foreach ( $arrData as $k => $v ) {
|
| 88 |
+
$html = '';
|
| 89 |
+
if ($v ['url_count'] > $this->_firstVisitsLimit) {
|
| 90 |
+
|
| 91 |
+
$model = Mage::getModel ( 'visitoripsecurity/log_remoteaddr_notes' );
|
| 92 |
+
$collection = $model->getCollection ();
|
| 93 |
+
$select = $collection->getSelect ();
|
| 94 |
+
$select->where ( "remote_addr = '" . ip2long ( $ip ) . "'" );
|
| 95 |
+
|
| 96 |
+
$tmpData = $collection->getData ();
|
| 97 |
+
$html .= '<br /> IP: ' . long2ip ( $v ['remote_addr'] ) . ' - visits: ' . $v ['url_count'];
|
| 98 |
+
|
| 99 |
+
if (! empty ( $tmpData )) {
|
| 100 |
+
|
| 101 |
+
if ($tmpData [0] ['first_email_sent_at'] == 0) {
|
| 102 |
+
|
| 103 |
+
$time_now = time ();
|
| 104 |
+
$model->load ( $tmpData [0] ['id'] );
|
| 105 |
+
$model->setData ( 'first_email_sent_at', time () );
|
| 106 |
+
$model->save ();
|
| 107 |
+
$this->sendNoticeEmail ( $html );
|
| 108 |
+
|
| 109 |
+
}
|
| 110 |
+
}else{
|
| 111 |
+
//insert into notes
|
| 112 |
+
//echo $html;
|
| 113 |
+
$data = array('remote_addr'=>ip2long($ip), 'note'=>'','first_email_sent_at'=>time());
|
| 114 |
+
$model->setData($data);
|
| 115 |
+
$model->save();
|
| 116 |
+
$this->sendNoticeEmail($html);
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
}
|
| 122 |
+
public function sendSecondLimit($ip){
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
$collection = Mage::getModel ( 'log/visitor' )->getCollection ();
|
| 126 |
+
|
| 127 |
+
$rs = Mage::getSingleton ( 'core/resource' );
|
| 128 |
+
|
| 129 |
+
$ip_notes = $rs->getTableName ( 'log_remoteaddr_notes' );
|
| 130 |
+
$table_visitor_info = $rs->getTableName ( 'log_visitor_info' );
|
| 131 |
+
$table_log_url = $rs->getTableName ( 'log_url' );
|
| 132 |
+
|
| 133 |
+
$select = $collection->getSelect ();
|
| 134 |
+
$select->reset ( 'from' );
|
| 135 |
+
$select->reset ( 'columns' );
|
| 136 |
+
$select->from ( array ('main_table' => $table_visitor_info ), array ('visitor_id', 'remote_addr' ) );
|
| 137 |
+
|
| 138 |
+
$select->joinLeft ( array ('lu' => $table_log_url ), 'lu.visitor_id = main_table.visitor_id', array ('url_count' => new Zend_Db_Expr ( 'COUNT(lu.url_id)' ) ) );
|
| 139 |
+
$select->where ( "main_table.remote_addr = '" . ip2long ( $ip ) . "'" );
|
| 140 |
+
$select->where ( "lu.visit_time > DATE(NOW() - INTERVAL 7 DAY)" );
|
| 141 |
+
// $collection->printLogQuery(true);
|
| 142 |
+
|
| 143 |
+
$arrData = $collection->getData ();
|
| 144 |
+
//var_dump($arrData);
|
| 145 |
+
$arr = array ();
|
| 146 |
+
|
| 147 |
+
foreach ( $arrData as $k => $v ) {
|
| 148 |
+
$html = '';
|
| 149 |
+
if ($v ['url_count'] > $this->_secondVisitsLimit) {
|
| 150 |
+
|
| 151 |
+
$model = Mage::getModel ( 'visitoripsecurity/log_remoteaddr_notes' );
|
| 152 |
+
$collection = $model->getCollection ();
|
| 153 |
+
$select = $collection->getSelect ();
|
| 154 |
+
$select->where ( "remote_addr = '" . ip2long ( $ip ) . "'" );
|
| 155 |
+
|
| 156 |
+
$tmpData = $collection->getData ();
|
| 157 |
+
$html .= '<br /> IP: ' . long2ip ( $v ['remote_addr'] ) . ' - visits: ' . $v ['url_count'];
|
| 158 |
+
|
| 159 |
+
if (! empty ( $tmpData )) {
|
| 160 |
+
|
| 161 |
+
if ($tmpData [0] ['second_email_sent_at'] == 0) {
|
| 162 |
+
$time_now = time ();
|
| 163 |
+
|
| 164 |
+
$model->load ( $tmpData [0] ['id'] );
|
| 165 |
+
$model->setData ( 'second_email_sent_at', time () );
|
| 166 |
+
$model->save ();
|
| 167 |
+
$this->sendNoticeEmail ( $html );
|
| 168 |
+
}
|
| 169 |
+
}else{
|
| 170 |
+
//insert into notes
|
| 171 |
+
//echo $html;
|
| 172 |
+
$data = array('remote_addr'=>ip2long($ip), 'note'=>'','second_email_sent_at'=>time());
|
| 173 |
+
$model->setData($data);
|
| 174 |
+
$model->save();
|
| 175 |
+
$this->sendNoticeEmail($html);
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
public function sendNoticeEmail($body) {
|
| 183 |
+
|
| 184 |
+
$mail = Mage::getModel ( 'core/email' );
|
| 185 |
+
|
| 186 |
+
$mail->setToName ( 'admin' );
|
| 187 |
+
|
| 188 |
+
$mail->setBody ( $body );
|
| 189 |
+
$mail->setSubject ( 'IP to watch' );
|
| 190 |
+
$mail->setFromEmail ( $this->_sendEmailsTo );
|
| 191 |
+
$mail->setFromName ( "Customer flood notice" );
|
| 192 |
+
$mail->setType ( 'html' );
|
| 193 |
+
|
| 194 |
+
try {
|
| 195 |
+
$mail->setToEmail ( $this->_sendEmailsTo );
|
| 196 |
+
$mail->send ();
|
| 197 |
+
|
| 198 |
+
} catch ( Exception $e ) {
|
| 199 |
+
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
}
|
app/code/local/Briel/Visitoripsecurity/controllers/Adminhtml/VisitoripsecurityController.php
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_Adminhtml_VisitoripsecurityController extends Mage_Adminhtml_Controller_Action
|
| 23 |
+
{
|
| 24 |
+
|
| 25 |
+
protected function _initAction()
|
| 26 |
+
{
|
| 27 |
+
$this->loadLayout()
|
| 28 |
+
->_setActiveMenu('visitoripsecurity/items')
|
| 29 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 30 |
+
return $this;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public function indexAction() {
|
| 34 |
+
|
| 35 |
+
$this->_initAction();
|
| 36 |
+
//$this->_addContent($this->getLayout()->createBlock('visitoripsecurity/adminhtml_visitoripsecurity_grid'));
|
| 37 |
+
$this->renderLayout();
|
| 38 |
+
//exit();
|
| 39 |
+
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
public function logurlAction() {
|
| 43 |
+
|
| 44 |
+
$this->_initAction();
|
| 45 |
+
//$this->_addContent($this->getLayout()->createBlock('visitoripsecurity/adminhtml_visitoripsecurity_logurl_grid'));
|
| 46 |
+
$this->renderLayout();
|
| 47 |
+
//exit();
|
| 48 |
+
|
| 49 |
+
}
|
| 50 |
+
public function blockedAction() {
|
| 51 |
+
|
| 52 |
+
$this->_initAction();
|
| 53 |
+
//$this->_addContent($this->getLayout()->createBlock('visitoripsecurity/adminhtml_visitoripsecurity_blocked_grid'));
|
| 54 |
+
$this->renderLayout();
|
| 55 |
+
//exit();
|
| 56 |
+
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function whiteAction() {
|
| 60 |
+
|
| 61 |
+
$this->_initAction();
|
| 62 |
+
//$this->_addContent($this->getLayout()->createBlock('visitoripsecurity/adminhtml_visitoripsecurity_blocked_grid'));
|
| 63 |
+
$this->renderLayout();
|
| 64 |
+
//exit();
|
| 65 |
+
|
| 66 |
+
}
|
| 67 |
+
public function watchAction() {
|
| 68 |
+
|
| 69 |
+
$this->_initAction();
|
| 70 |
+
//$this->_addContent($this->getLayout()->createBlock('visitoripsecurity/adminhtml_visitoripsecurity_watch_grid'));
|
| 71 |
+
$this->renderLayout();
|
| 72 |
+
//exit();
|
| 73 |
+
|
| 74 |
+
}
|
| 75 |
+
public function oneipAction() {
|
| 76 |
+
|
| 77 |
+
$this->_initAction();
|
| 78 |
+
$this->_addContent($this->getLayout()->createBlock('visitoripsecurity/adminhtml_visitoripsecurity_oneip_block'));
|
| 79 |
+
$this->renderLayout();
|
| 80 |
+
//exit();
|
| 81 |
+
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
public function updateNoteAction()
|
| 85 |
+
{
|
| 86 |
+
$remote_addr = (int) $this->getRequest()->getParam('id');
|
| 87 |
+
$note = $this->getRequest()->getParam('note');
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
if ($remote_addr) {
|
| 91 |
+
$rs = Mage::getSingleton('core/resource');
|
| 92 |
+
$table = $rs->getTableName('log_remoteaddr_notes');
|
| 93 |
+
|
| 94 |
+
//$model2 = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 95 |
+
|
| 96 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 97 |
+
$collection = $model->getCollection();
|
| 98 |
+
$select = $collection->getSelect();
|
| 99 |
+
$select->where("remote_addr = '".$remote_addr."'");
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
$arrData = $collection->getData();
|
| 103 |
+
|
| 104 |
+
//var_dump($arrData);
|
| 105 |
+
|
| 106 |
+
if(!empty($arrData)){
|
| 107 |
+
//update
|
| 108 |
+
$model->load($arrData[0]['id']);
|
| 109 |
+
$model->setData('note', $note);
|
| 110 |
+
$model->save();
|
| 111 |
+
|
| 112 |
+
}else{
|
| 113 |
+
//insert
|
| 114 |
+
|
| 115 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 116 |
+
$data = array('remote_addr'=>$remote_addr, 'note'=>$note);
|
| 117 |
+
$model->setData($data);
|
| 118 |
+
$model->save();
|
| 119 |
+
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
public function blockOneIpAction()
|
| 126 |
+
{
|
| 127 |
+
|
| 128 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 129 |
+
$ip = trim($ip);
|
| 130 |
+
if(stripos($ip, '.') !== false){
|
| 131 |
+
$long_ip = ip2long($ip);
|
| 132 |
+
}else{
|
| 133 |
+
$long_ip = $ip;
|
| 134 |
+
$ip = long2ip($ip);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
$cacheFile = Mage::getBaseDir('cache') . '/blocked_ips.dat';
|
| 138 |
+
|
| 139 |
+
$arrBlocked = Mage::helper('visitoripsecurity')->getBlocked();
|
| 140 |
+
if(!Mage::helper('visitoripsecurity')->checkIfBlocked($ip)){
|
| 141 |
+
if(!Mage::helper('visitoripsecurity')->checkIfWhite($ip)){
|
| 142 |
+
array_push($arrBlocked, $ip);
|
| 143 |
+
}else{
|
| 144 |
+
echo $html = $this->__('IP ').$ip.$this->__(' is in whitelist');
|
| 145 |
+
return;
|
| 146 |
+
}
|
| 147 |
+
}else{
|
| 148 |
+
echo $html = $this->__('IP ').$ip.$this->__(' is allready blocked');
|
| 149 |
+
return;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
file_put_contents($cacheFile,serialize($arrBlocked));
|
| 153 |
+
|
| 154 |
+
echo 'blocked';
|
| 155 |
+
}
|
| 156 |
+
public function unblockOneIpAction()
|
| 157 |
+
{
|
| 158 |
+
|
| 159 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 160 |
+
$ip = trim($ip);
|
| 161 |
+
if(stripos($ip, '.') !== false){
|
| 162 |
+
$long_ip = ip2long($ip);
|
| 163 |
+
}else{
|
| 164 |
+
$long_ip = $ip;
|
| 165 |
+
$ip = long2ip($ip);
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
$cacheFile = Mage::getBaseDir('cache') . '/blocked_ips.dat';
|
| 169 |
+
$tmp_arr = array();
|
| 170 |
+
$arrBlocked = Mage::helper('visitoripsecurity')->getBlocked();
|
| 171 |
+
if(Mage::helper('visitoripsecurity')->checkIfBlocked($ip)){
|
| 172 |
+
foreach($arrBlocked as $k => $v){
|
| 173 |
+
if($v != trim($ip)){
|
| 174 |
+
array_push($tmp_arr, $v);
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
$arrBlocked = $tmp_arr;
|
| 178 |
+
}else{
|
| 179 |
+
echo $html = 'IP '.$ip.' is not blocked';
|
| 180 |
+
return;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
file_put_contents($cacheFile,serialize($arrBlocked));
|
| 184 |
+
|
| 185 |
+
echo $html = 'IP '.$ip.' was unblocked';
|
| 186 |
+
}
|
| 187 |
+
public function blockThisIpAction()
|
| 188 |
+
{
|
| 189 |
+
|
| 190 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 191 |
+
$ip = trim($ip);
|
| 192 |
+
$long_ip = $ip;
|
| 193 |
+
$ip = long2ip($ip);
|
| 194 |
+
$cacheFile = Mage::getBaseDir('cache') . '/blocked_ips.dat';
|
| 195 |
+
|
| 196 |
+
$arrBlocked = Mage::helper('visitoripsecurity')->getBlocked();
|
| 197 |
+
if(!Mage::helper('visitoripsecurity')->checkIfBlocked($ip)){
|
| 198 |
+
if(!Mage::helper('visitoripsecurity')->checkIfWhite($ip)){
|
| 199 |
+
array_push($arrBlocked, $ip);
|
| 200 |
+
}else{
|
| 201 |
+
echo '';
|
| 202 |
+
return;
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
file_put_contents($cacheFile,serialize($arrBlocked));
|
| 207 |
+
|
| 208 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 209 |
+
$collection = $model->getCollection();
|
| 210 |
+
$select = $collection->getSelect();
|
| 211 |
+
$select->where("remote_addr = '".$long_ip."'");
|
| 212 |
+
|
| 213 |
+
$arrData = $collection->getData();
|
| 214 |
+
|
| 215 |
+
//var_dump($arrData);
|
| 216 |
+
|
| 217 |
+
if(!empty($arrData)){
|
| 218 |
+
//update
|
| 219 |
+
$model->load($arrData[0]['id']);
|
| 220 |
+
$model->setData('blocked', '1');
|
| 221 |
+
$model->save();
|
| 222 |
+
|
| 223 |
+
}else{
|
| 224 |
+
//insert
|
| 225 |
+
|
| 226 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 227 |
+
$data = array('remote_addr'=>$long_ip, 'blocked'=>'1');
|
| 228 |
+
$model->setData($data);
|
| 229 |
+
$model->save();
|
| 230 |
+
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
echo $html = '<button onclick="unBlockThisIp(this, '. $long_ip .'); return false">' . Mage::helper('visitoripsecurity')->__('Unblock') . '</button>';
|
| 234 |
+
}
|
| 235 |
+
public function whiteThisIpAction()
|
| 236 |
+
{
|
| 237 |
+
|
| 238 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 239 |
+
$ip = trim($ip);
|
| 240 |
+
$long_ip = $ip;
|
| 241 |
+
$ip = long2ip($ip);
|
| 242 |
+
$cacheFile = Mage::getBaseDir('cache') . '/white_ips.dat';
|
| 243 |
+
|
| 244 |
+
$arrWhite = Mage::helper('visitoripsecurity')->getWhite();
|
| 245 |
+
if(!Mage::helper('visitoripsecurity')->checkIfWhite($ip)){
|
| 246 |
+
if(!Mage::helper('visitoripsecurity')->checkIfBlocked($ip)){
|
| 247 |
+
array_push($arrWhite, $ip);
|
| 248 |
+
}else{
|
| 249 |
+
echo '';
|
| 250 |
+
return;
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
file_put_contents($cacheFile,serialize($arrWhite));
|
| 255 |
+
|
| 256 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 257 |
+
$collection = $model->getCollection();
|
| 258 |
+
$select = $collection->getSelect();
|
| 259 |
+
$select->where("remote_addr = '".$long_ip."'");
|
| 260 |
+
|
| 261 |
+
$arrData = $collection->getData();
|
| 262 |
+
|
| 263 |
+
//var_dump($arrData);
|
| 264 |
+
|
| 265 |
+
if(!empty($arrData)){
|
| 266 |
+
//update
|
| 267 |
+
$model->load($arrData[0]['id']);
|
| 268 |
+
$model->setData('white', '1');
|
| 269 |
+
$model->save();
|
| 270 |
+
|
| 271 |
+
}else{
|
| 272 |
+
//insert
|
| 273 |
+
|
| 274 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 275 |
+
$data = array('remote_addr'=>$long_ip, 'white'=>'1');
|
| 276 |
+
$model->setData($data);
|
| 277 |
+
$model->save();
|
| 278 |
+
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
echo $html = '<button onclick="unWhiteThisIp(this, '. $long_ip .'); return false">' . Mage::helper('visitoripsecurity')->__('Remove white') . '</button>';
|
| 283 |
+
}
|
| 284 |
+
public function watchThisIpAction()
|
| 285 |
+
{
|
| 286 |
+
|
| 287 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 288 |
+
$ip = trim($ip);
|
| 289 |
+
$long_ip = $ip;
|
| 290 |
+
$ip = long2ip($ip);
|
| 291 |
+
|
| 292 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 293 |
+
$collection = $model->getCollection();
|
| 294 |
+
$select = $collection->getSelect();
|
| 295 |
+
$select->where("remote_addr = '".$long_ip."'");
|
| 296 |
+
|
| 297 |
+
$arrData = $collection->getData();
|
| 298 |
+
|
| 299 |
+
//var_dump($arrData);
|
| 300 |
+
|
| 301 |
+
if(!empty($arrData)){
|
| 302 |
+
//update
|
| 303 |
+
$model->load($arrData[0]['id']);
|
| 304 |
+
$model->setData('watch', '1');
|
| 305 |
+
$model->save();
|
| 306 |
+
|
| 307 |
+
}else{
|
| 308 |
+
//insert
|
| 309 |
+
|
| 310 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 311 |
+
$data = array('remote_addr'=>$long_ip, 'watch'=>'1');
|
| 312 |
+
$model->setData($data);
|
| 313 |
+
$model->save();
|
| 314 |
+
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
echo $html = '<button onclick="unWhatchThisIp(this, '. $long_ip .'); return false">' . Mage::helper('visitoripsecurity')->__('Remove whatch') . '</button>';
|
| 319 |
+
}
|
| 320 |
+
public function unBlockThisIpAction()
|
| 321 |
+
{
|
| 322 |
+
|
| 323 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 324 |
+
$ip = trim($ip);
|
| 325 |
+
$long_ip = $ip;
|
| 326 |
+
$ip = long2ip($ip);
|
| 327 |
+
$arrIp = explode('.', $ip);
|
| 328 |
+
$cacheFile = Mage::getBaseDir('cache') . '/blocked_ips.dat';
|
| 329 |
+
|
| 330 |
+
$arrBlocked = Mage::helper('visitoripsecurity')->getBlocked();
|
| 331 |
+
$arrData = array();
|
| 332 |
+
if(Mage::helper('visitoripsecurity')->checkIfBlocked($ip)){
|
| 333 |
+
foreach ($arrBlocked as $v){
|
| 334 |
+
|
| 335 |
+
$tmp_ip = explode('.', $v);
|
| 336 |
+
$found = 0;
|
| 337 |
+
foreach($tmp_ip as $key => $val){
|
| 338 |
+
if($val == '*'){
|
| 339 |
+
$found++;
|
| 340 |
+
}elseif($arrIp[$key] == $val){
|
| 341 |
+
$found++;
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
if($found != 4){
|
| 345 |
+
array_push($arrData, $v);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
}
|
| 349 |
+
}else{
|
| 350 |
+
$arrData = $arrBlocked;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
file_put_contents($cacheFile,serialize($arrData));
|
| 355 |
+
|
| 356 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 357 |
+
$collection = $model->getCollection();
|
| 358 |
+
$select = $collection->getSelect();
|
| 359 |
+
$select->where("remote_addr = '".$long_ip."'");
|
| 360 |
+
|
| 361 |
+
$arrData = $collection->getData();
|
| 362 |
+
|
| 363 |
+
//var_dump($arrData);
|
| 364 |
+
|
| 365 |
+
if(!empty($arrData)){
|
| 366 |
+
//update
|
| 367 |
+
$model->load($arrData[0]['id']);
|
| 368 |
+
$model->setData('blocked', '0');
|
| 369 |
+
$model->save();
|
| 370 |
+
|
| 371 |
+
}else{
|
| 372 |
+
//insert
|
| 373 |
+
|
| 374 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 375 |
+
$data = array('remote_addr'=>$long_ip, 'blocked'=>'0');
|
| 376 |
+
$model->setData($data);
|
| 377 |
+
$model->save();
|
| 378 |
+
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
echo $html = '<button onclick="blockThisIp(this, '. $long_ip .'); return false">' . Mage::helper('visitoripsecurity')->__('Block') . '</button>';
|
| 382 |
+
}
|
| 383 |
+
public function unWhiteThisIpAction()
|
| 384 |
+
{
|
| 385 |
+
|
| 386 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 387 |
+
$ip = trim($ip);
|
| 388 |
+
$long_ip = $ip;
|
| 389 |
+
$ip = long2ip($ip);
|
| 390 |
+
$arrIp = explode('.', $ip);
|
| 391 |
+
$cacheFile = Mage::getBaseDir('cache') . '/white_ips.dat';
|
| 392 |
+
|
| 393 |
+
$arrWhite = Mage::helper('visitoripsecurity')->getWhite();
|
| 394 |
+
$arrData = array();
|
| 395 |
+
if(Mage::helper('visitoripsecurity')->checkIfWhite($ip)){
|
| 396 |
+
foreach ($arrWhite as $v){
|
| 397 |
+
|
| 398 |
+
$tmp_ip = explode('.', $v);
|
| 399 |
+
$found = 0;
|
| 400 |
+
foreach($tmp_ip as $key => $val){
|
| 401 |
+
if($val == '*'){
|
| 402 |
+
$found++;
|
| 403 |
+
}elseif($arrIp[$key] == $val){
|
| 404 |
+
$found++;
|
| 405 |
+
}
|
| 406 |
+
}
|
| 407 |
+
if($found != 4){
|
| 408 |
+
array_push($arrData, $v);
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
}
|
| 412 |
+
}else{
|
| 413 |
+
$arrData = $arrWhite;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
file_put_contents($cacheFile,serialize($arrData));
|
| 418 |
+
|
| 419 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 420 |
+
$collection = $model->getCollection();
|
| 421 |
+
$select = $collection->getSelect();
|
| 422 |
+
$select->where("remote_addr = '".$long_ip."'");
|
| 423 |
+
|
| 424 |
+
$arrData = $collection->getData();
|
| 425 |
+
|
| 426 |
+
//var_dump($arrData);
|
| 427 |
+
|
| 428 |
+
if(!empty($arrData)){
|
| 429 |
+
//update
|
| 430 |
+
$model->load($arrData[0]['id']);
|
| 431 |
+
$model->setData('white', '0');
|
| 432 |
+
$model->save();
|
| 433 |
+
|
| 434 |
+
}else{
|
| 435 |
+
//insert
|
| 436 |
+
|
| 437 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 438 |
+
$data = array('remote_addr'=>$long_ip, 'white'=>'0');
|
| 439 |
+
$model->setData($data);
|
| 440 |
+
$model->save();
|
| 441 |
+
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
echo $html = '<button onclick="whiteThisIp(this, '. $long_ip .'); return false">' . Mage::helper('visitoripsecurity')->__('Whitelist') . '</button>';
|
| 445 |
+
}
|
| 446 |
+
public function unWatchThisIpAction()
|
| 447 |
+
{
|
| 448 |
+
|
| 449 |
+
$ip = $this->getRequest()->getParam('ip');
|
| 450 |
+
$ip = trim($ip);
|
| 451 |
+
$long_ip = $ip;
|
| 452 |
+
$ip = long2ip($ip);
|
| 453 |
+
|
| 454 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 455 |
+
$collection = $model->getCollection();
|
| 456 |
+
$select = $collection->getSelect();
|
| 457 |
+
$select->where("remote_addr = '".$long_ip."'");
|
| 458 |
+
|
| 459 |
+
$arrData = $collection->getData();
|
| 460 |
+
|
| 461 |
+
//var_dump($arrData);
|
| 462 |
+
|
| 463 |
+
if(!empty($arrData)){
|
| 464 |
+
//update
|
| 465 |
+
$model->load($arrData[0]['id']);
|
| 466 |
+
$model->setData('watch', '0');
|
| 467 |
+
$model->save();
|
| 468 |
+
|
| 469 |
+
}else{
|
| 470 |
+
//insert
|
| 471 |
+
|
| 472 |
+
$model = Mage::getModel('visitoripsecurity/log_remoteaddr_notes');
|
| 473 |
+
$data = array('remote_addr'=>$long_ip, 'watch'=>'0');
|
| 474 |
+
$model->setData($data);
|
| 475 |
+
$model->save();
|
| 476 |
+
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
echo $html = '<button onclick="whatchThisIp(this, '. $long_ip .'); return false">' . Mage::helper('visitoripsecurity')->__('Whatchlist') . '</button>';
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
}
|
app/code/local/Briel/Visitoripsecurity/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Briel Software SRL
|
| 4 |
+
* http://www.briel.ro
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to radu@briel.ro so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category Briel
|
| 17 |
+
* @package Visitoripsecurity
|
| 18 |
+
* @author Radu Parvan <radu@briel.ro>
|
| 19 |
+
* @copyright Copyright (c) 2012 (http://www.briel.ro)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
class Briel_Visitoripsecurity_IndexController extends Mage_Core_Controller_Front_Action{
|
| 23 |
+
public function indexAction(){
|
| 24 |
+
$this->loadLayout();
|
| 25 |
+
$this->renderLayout();
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/local/Briel/Visitoripsecurity/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<acl>
|
| 4 |
+
<resources>
|
| 5 |
+
<all>
|
| 6 |
+
<title>Allow Everything</title>
|
| 7 |
+
</all>
|
| 8 |
+
<admin>
|
| 9 |
+
<children>
|
| 10 |
+
<system>
|
| 11 |
+
<children>
|
| 12 |
+
<config>
|
| 13 |
+
<children>
|
| 14 |
+
<brielvisitoripsecurity translate="title" module="visitoripsecurity">
|
| 15 |
+
<title>Visitor IP security</title>
|
| 16 |
+
<sort_order>100</sort_order>
|
| 17 |
+
</brielvisitoripsecurity>
|
| 18 |
+
</children>
|
| 19 |
+
</config>
|
| 20 |
+
</children>
|
| 21 |
+
</system>
|
| 22 |
+
</children>
|
| 23 |
+
</admin>
|
| 24 |
+
</resources>
|
| 25 |
+
</acl>
|
| 26 |
+
</config>
|
app/code/local/Briel/Visitoripsecurity/etc/config.xml
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Briel_Visitoripsecurity>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Briel_Visitoripsecurity>
|
| 7 |
+
</modules>
|
| 8 |
+
<default>
|
| 9 |
+
<brielvisitoripsecurity>
|
| 10 |
+
<visitoripsecurityfront>
|
| 11 |
+
<send_emails>0</send_emails>
|
| 12 |
+
<first_limit>1000</first_limit>
|
| 13 |
+
<second_limit>10000</second_limit>
|
| 14 |
+
</visitoripsecurityfront>
|
| 15 |
+
<visitoripsecurityadmin>
|
| 16 |
+
<send_emails>0</send_emails>
|
| 17 |
+
<first_limit>1000</first_limit>
|
| 18 |
+
<second_limit>10000</second_limit>
|
| 19 |
+
</visitoripsecurityadmin>
|
| 20 |
+
</brielvisitoripsecurity>
|
| 21 |
+
</default>
|
| 22 |
+
|
| 23 |
+
<admin>
|
| 24 |
+
<routers>
|
| 25 |
+
<visitoripsecurity>
|
| 26 |
+
<use>admin</use>
|
| 27 |
+
<args>
|
| 28 |
+
<module>Visitoripsecurity_Visitoripsecurity</module>
|
| 29 |
+
<frontName>visitoripsecurity</frontName>
|
| 30 |
+
</args>
|
| 31 |
+
</visitoripsecurity>
|
| 32 |
+
</routers>
|
| 33 |
+
<routers>
|
| 34 |
+
<adminhtml>
|
| 35 |
+
<args>
|
| 36 |
+
<modules>
|
| 37 |
+
<visitoripsecurity before="Mage_Adminhtml">Briel_Visitoripsecurity_Adminhtml</visitoripsecurity>
|
| 38 |
+
</modules>
|
| 39 |
+
</args>
|
| 40 |
+
</adminhtml>
|
| 41 |
+
</routers>
|
| 42 |
+
</admin>
|
| 43 |
+
<adminhtml>
|
| 44 |
+
<menu>
|
| 45 |
+
<customer translate="title" module="customer">
|
| 46 |
+
<children>
|
| 47 |
+
<first_page module="visitoripsecurity">
|
| 48 |
+
<title>Visitor IP security</title>
|
| 49 |
+
<sort_order>150</sort_order>
|
| 50 |
+
<action>adminhtml/visitoripsecurity</action>
|
| 51 |
+
<children>
|
| 52 |
+
<viewList module="visitoripsecurity">
|
| 53 |
+
<title>View visitor list</title>
|
| 54 |
+
<sort_order>100</sort_order>
|
| 55 |
+
<action>adminhtml/visitoripsecurity</action>
|
| 56 |
+
</viewList>
|
| 57 |
+
</children>
|
| 58 |
+
<children>
|
| 59 |
+
<viewBlocked module="visitoripsecurity">
|
| 60 |
+
<title>View blocked</title>
|
| 61 |
+
<sort_order>200</sort_order>
|
| 62 |
+
<action>adminhtml/visitoripsecurity/blocked</action>
|
| 63 |
+
</viewBlocked>
|
| 64 |
+
</children>
|
| 65 |
+
<children>
|
| 66 |
+
<viewWhite module="visitoripsecurity">
|
| 67 |
+
<title>View white list</title>
|
| 68 |
+
<sort_order>200</sort_order>
|
| 69 |
+
<action>adminhtml/visitoripsecurity/white</action>
|
| 70 |
+
</viewWhite>
|
| 71 |
+
</children>
|
| 72 |
+
<children>
|
| 73 |
+
<viewWhite module="visitoripsecurity">
|
| 74 |
+
<title>View white list</title>
|
| 75 |
+
<sort_order>300</sort_order>
|
| 76 |
+
<action>adminhtml/visitoripsecurity/white</action>
|
| 77 |
+
</viewWhite>
|
| 78 |
+
</children>
|
| 79 |
+
<children>
|
| 80 |
+
<viewWatch module="visitoripsecurity">
|
| 81 |
+
<title>View watch list</title>
|
| 82 |
+
<sort_order>400</sort_order>
|
| 83 |
+
<action>adminhtml/visitoripsecurity/watch</action>
|
| 84 |
+
</viewWatch>
|
| 85 |
+
</children>
|
| 86 |
+
<children>
|
| 87 |
+
<blockOne module="visitoripsecurity">
|
| 88 |
+
<title>Block ip classes</title>
|
| 89 |
+
<sort_order>500</sort_order>
|
| 90 |
+
<action>adminhtml/visitoripsecurity/oneip</action>
|
| 91 |
+
</blockOne>
|
| 92 |
+
</children>
|
| 93 |
+
<children>
|
| 94 |
+
<blockOne module="visitoripsecurity">
|
| 95 |
+
<title>Settings</title>
|
| 96 |
+
<sort_order>600</sort_order>
|
| 97 |
+
<action>adminhtml/system_config/edit/section/brielvisitoripsecurity</action>
|
| 98 |
+
</blockOne>
|
| 99 |
+
</children>
|
| 100 |
+
</first_page>
|
| 101 |
+
</children>
|
| 102 |
+
</customer>
|
| 103 |
+
</menu>
|
| 104 |
+
<layout>
|
| 105 |
+
<updates>
|
| 106 |
+
<visitoripsecurity>
|
| 107 |
+
<file>briel_visitoripsecurity.xml</file>
|
| 108 |
+
</visitoripsecurity>
|
| 109 |
+
</updates>
|
| 110 |
+
</layout>
|
| 111 |
+
<translate>
|
| 112 |
+
<modules>
|
| 113 |
+
<visitoripsecurity>
|
| 114 |
+
<files>
|
| 115 |
+
<default>Briel_Visitoripsecurity.csv</default>
|
| 116 |
+
</files>
|
| 117 |
+
</visitoripsecurity>
|
| 118 |
+
</modules>
|
| 119 |
+
</translate>
|
| 120 |
+
</adminhtml>
|
| 121 |
+
<global>
|
| 122 |
+
<events>
|
| 123 |
+
<controller_front_init_before>
|
| 124 |
+
<observers>
|
| 125 |
+
<briel_visitoripsecurity_observer>
|
| 126 |
+
<type>model</type>
|
| 127 |
+
<class>Briel_Visitoripsecurity_Model_Observer</class>
|
| 128 |
+
<method>checkBlocked</method>
|
| 129 |
+
</briel_visitoripsecurity_observer>
|
| 130 |
+
</observers>
|
| 131 |
+
</controller_front_init_before>
|
| 132 |
+
</events>
|
| 133 |
+
<models>
|
| 134 |
+
<log_mysql4>
|
| 135 |
+
<rewrite>
|
| 136 |
+
<visitor_collection>Briel_Visitoripsecurity_Model_Mysql4_Visitoripsecurity_Collection</visitor_collection>
|
| 137 |
+
</rewrite>
|
| 138 |
+
</log_mysql4>
|
| 139 |
+
<visitoripsecurity>
|
| 140 |
+
<class>Briel_Visitoripsecurity_Model</class>
|
| 141 |
+
<resourceModel>visitoripsecurity_mysql4</resourceModel>
|
| 142 |
+
</visitoripsecurity>
|
| 143 |
+
<visitoripsecurity_mysql4>
|
| 144 |
+
<class>Briel_Visitoripsecurity_Model_Mysql4</class>
|
| 145 |
+
<entities>
|
| 146 |
+
<log_remoteaddr_notes>
|
| 147 |
+
<table>log_remoteaddr_notes</table>
|
| 148 |
+
</log_remoteaddr_notes>
|
| 149 |
+
</entities>
|
| 150 |
+
<entities>
|
| 151 |
+
<log_url>
|
| 152 |
+
<table>log_url</table>
|
| 153 |
+
</log_url>
|
| 154 |
+
</entities>
|
| 155 |
+
</visitoripsecurity_mysql4>
|
| 156 |
+
</models>
|
| 157 |
+
<resources>
|
| 158 |
+
<visitoripsecurity_setup>
|
| 159 |
+
<setup>
|
| 160 |
+
<module>Briel_Visitoripsecurity</module>
|
| 161 |
+
</setup>
|
| 162 |
+
<connection>
|
| 163 |
+
<use>core_setup</use>
|
| 164 |
+
</connection>
|
| 165 |
+
</visitoripsecurity_setup>
|
| 166 |
+
<visitoripsecurity_write>
|
| 167 |
+
<connection>
|
| 168 |
+
<use>core_write</use>
|
| 169 |
+
</connection>
|
| 170 |
+
</visitoripsecurity_write>
|
| 171 |
+
<visitoripsecurity_read>
|
| 172 |
+
<connection>
|
| 173 |
+
<use>core_read</use>
|
| 174 |
+
</connection>
|
| 175 |
+
</visitoripsecurity_read>
|
| 176 |
+
</resources>
|
| 177 |
+
<blocks>
|
| 178 |
+
<visitoripsecurity>
|
| 179 |
+
<class>Briel_Visitoripsecurity_Block</class>
|
| 180 |
+
</visitoripsecurity>
|
| 181 |
+
</blocks>
|
| 182 |
+
<helpers>
|
| 183 |
+
<visitoripsecurity>
|
| 184 |
+
<class>Briel_Visitoripsecurity_Helper</class>
|
| 185 |
+
</visitoripsecurity>
|
| 186 |
+
</helpers>
|
| 187 |
+
</global>
|
| 188 |
+
</config>
|
app/code/local/Briel/Visitoripsecurity/etc/system.xml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<brielall translate="label">
|
| 5 |
+
<label>Briel ext</label>
|
| 6 |
+
<sort_order>390</sort_order>
|
| 7 |
+
</brielall>
|
| 8 |
+
</tabs>
|
| 9 |
+
<sections>
|
| 10 |
+
<brielvisitoripsecurity translate="label" module="visitoripsecurity">
|
| 11 |
+
<label>Visitor IP security</label>
|
| 12 |
+
<tab>brielall</tab>
|
| 13 |
+
<frontend_type>text</frontend_type>
|
| 14 |
+
<sort_order>100</sort_order>
|
| 15 |
+
<show_in_default>1</show_in_default>
|
| 16 |
+
<show_in_website>1</show_in_website>
|
| 17 |
+
<show_in_store>1</show_in_store>
|
| 18 |
+
<groups>
|
| 19 |
+
<visitoripsecurityadmin translate="label comment">
|
| 20 |
+
<label>Visitor IP security settings</label>
|
| 21 |
+
<sort_order>20</sort_order>
|
| 22 |
+
<show_in_default>1</show_in_default>
|
| 23 |
+
<show_in_website>1</show_in_website>
|
| 24 |
+
<show_in_store>1</show_in_store>
|
| 25 |
+
<fields>
|
| 26 |
+
<send_emails translate="label comment">
|
| 27 |
+
<label>Send notification emails?</label>
|
| 28 |
+
<comment><![CDATA[Send notification emails when the visits limit is passed.]]></comment>
|
| 29 |
+
<frontend_type>select</frontend_type>
|
| 30 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 31 |
+
<sort_order>10</sort_order>
|
| 32 |
+
<show_in_default>1</show_in_default>
|
| 33 |
+
<show_in_website>1</show_in_website>
|
| 34 |
+
<show_in_store>1</show_in_store>
|
| 35 |
+
</send_emails>
|
| 36 |
+
<email_to translate="label comment">
|
| 37 |
+
<label>Send mail to</label>
|
| 38 |
+
<comment><![CDATA[Write here the email address where you will receive notices]]></comment>
|
| 39 |
+
<frontend_type>text</frontend_type>
|
| 40 |
+
<sort_order>50</sort_order>
|
| 41 |
+
<show_in_default>1</show_in_default>
|
| 42 |
+
<show_in_website>1</show_in_website>
|
| 43 |
+
<show_in_store>1</show_in_store>
|
| 44 |
+
</email_to>
|
| 45 |
+
<first_limit translate="label comment">
|
| 46 |
+
<label>First visits limit</label>
|
| 47 |
+
<comment><![CDATA[If an user passes this number of visits in the last 24 hours, an email will be sent]]></comment>
|
| 48 |
+
<frontend_type>text</frontend_type>
|
| 49 |
+
<sort_order>100</sort_order>
|
| 50 |
+
<show_in_default>1</show_in_default>
|
| 51 |
+
<show_in_website>1</show_in_website>
|
| 52 |
+
<show_in_store>1</show_in_store>
|
| 53 |
+
</first_limit>
|
| 54 |
+
<second_limit translate="label comment">
|
| 55 |
+
<comment><![CDATA[If an user passes this number of visits in the last 7 days, an email will be sent]]></comment>
|
| 56 |
+
<label>Second visits limit</label>
|
| 57 |
+
<frontend_type>text</frontend_type>
|
| 58 |
+
<sort_order>150</sort_order>
|
| 59 |
+
<show_in_default>1</show_in_default>
|
| 60 |
+
<show_in_website>1</show_in_website>
|
| 61 |
+
<show_in_store>1</show_in_store>
|
| 62 |
+
</second_limit>
|
| 63 |
+
</fields>
|
| 64 |
+
</visitoripsecurityadmin>
|
| 65 |
+
</groups>
|
| 66 |
+
</brielvisitoripsecurity>
|
| 67 |
+
</sections>
|
| 68 |
+
</config>
|
app/code/local/Briel/Visitoripsecurity/sql/visitoripsecurity_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
|
| 7 |
+
$installer->run("SET NAMES utf8;
|
| 8 |
+
SET FOREIGN_KEY_CHECKS = 0;
|
| 9 |
+
DROP TABLE IF EXISTS `{$this->getTable('log_remoteaddr_notes')}`;
|
| 10 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('log_remoteaddr_notes')}` (
|
| 11 |
+
`id` int(12) NOT NULL AUTO_INCREMENT,
|
| 12 |
+
`remote_addr` bigint(16) NOT NULL,
|
| 13 |
+
`note` varchar(255) DEFAULT NULL,
|
| 14 |
+
`first_email_sent_at` bigint(16) NOT NULL DEFAULT '0',
|
| 15 |
+
`second_email_sent_at` bigint(16) NOT NULL DEFAULT '0',
|
| 16 |
+
`blocked` tinyint(1) NOT NULL DEFAULT '0',
|
| 17 |
+
`white` tinyint(1) NOT NULL DEFAULT '0',
|
| 18 |
+
`watch` tinyint(1) NOT NULL DEFAULT '0',
|
| 19 |
+
PRIMARY KEY (`id`),
|
| 20 |
+
KEY `remote_addr` (`remote_addr`),
|
| 21 |
+
KEY `note` (`note`)
|
| 22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;");
|
| 23 |
+
|
| 24 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/briel_visitoripsecurity.xml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<adminhtml_visitoripsecurity_index>
|
| 4 |
+
<reference name="js">
|
| 5 |
+
<block type="core/template" template="briel/visitoripsecurity/inline-edit.phtml" />
|
| 6 |
+
</reference>
|
| 7 |
+
<reference name="content">
|
| 8 |
+
<block type="visitoripsecurity/adminhtml_grid" name="visitoripsecurity" />
|
| 9 |
+
</reference>
|
| 10 |
+
</adminhtml_visitoripsecurity_index>
|
| 11 |
+
<adminhtml_visitoripsecurity_blocked>
|
| 12 |
+
<reference name="js">
|
| 13 |
+
<block type="core/template" template="briel/visitoripsecurity/inline-edit.phtml" />
|
| 14 |
+
</reference>
|
| 15 |
+
<reference name="content">
|
| 16 |
+
<block type="visitoripsecurity/adminhtml_blocked" name="visitoripsecurity" />
|
| 17 |
+
</reference>
|
| 18 |
+
</adminhtml_visitoripsecurity_blocked>
|
| 19 |
+
<adminhtml_visitoripsecurity_white>
|
| 20 |
+
<reference name="js">
|
| 21 |
+
<block type="core/template" template="briel/visitoripsecurity/inline-edit.phtml" />
|
| 22 |
+
</reference>
|
| 23 |
+
<reference name="content">
|
| 24 |
+
<block type="visitoripsecurity/adminhtml_white" name="visitoripsecurity" />
|
| 25 |
+
</reference>
|
| 26 |
+
</adminhtml_visitoripsecurity_white>
|
| 27 |
+
<adminhtml_visitoripsecurity_watch>
|
| 28 |
+
<reference name="js">
|
| 29 |
+
<block type="core/template" template="briel/visitoripsecurity/inline-edit.phtml" />
|
| 30 |
+
</reference>
|
| 31 |
+
<reference name="content">
|
| 32 |
+
<block type="visitoripsecurity/adminhtml_watch" name="visitoripsecurity" />
|
| 33 |
+
</reference>
|
| 34 |
+
</adminhtml_visitoripsecurity_watch>
|
| 35 |
+
<adminhtml_visitoripsecurity_logurl>
|
| 36 |
+
<reference name="js">
|
| 37 |
+
<block type="core/template" template="briel/visitoripsecurity/inline-edit.phtml" />
|
| 38 |
+
</reference>
|
| 39 |
+
<reference name="content">
|
| 40 |
+
<block type="visitoripsecurity/adminhtml_logurl" name="visitoripsecurity" />
|
| 41 |
+
</reference>
|
| 42 |
+
</adminhtml_visitoripsecurity_logurl>
|
| 43 |
+
<adminhtml_visitoripsecurity_oneip>
|
| 44 |
+
<reference name="content">
|
| 45 |
+
<block type="core/template" template="briel/visitoripsecurity/oneip.phtml" />
|
| 46 |
+
</reference>
|
| 47 |
+
</adminhtml_visitoripsecurity_oneip>
|
| 48 |
+
</layout>
|
app/design/adminhtml/default/default/template/briel/visitoripsecurity/inline-edit.phtml
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script type="text/javascript">
|
| 2 |
+
function updateNote(button, fieldId)
|
| 3 |
+
{
|
| 4 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/updateNote") ?>', {
|
| 5 |
+
method: 'post',
|
| 6 |
+
parameters: { id: fieldId, note: $(button).getValue() }
|
| 7 |
+
});
|
| 8 |
+
}
|
| 9 |
+
function blockThisIp(button, fieldId)
|
| 10 |
+
{
|
| 11 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/blockThisIp") ?>', {
|
| 12 |
+
method: 'post',
|
| 13 |
+
parameters: { ip: fieldId },
|
| 14 |
+
onSuccess: function(response){
|
| 15 |
+
$(button).up(1).hide();
|
| 16 |
+
//$(button).up().update(response.responseText);
|
| 17 |
+
|
| 18 |
+
}
|
| 19 |
+
});
|
| 20 |
+
}
|
| 21 |
+
function unBlockThisIp(button, fieldId)
|
| 22 |
+
{
|
| 23 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/unBlockThisIp") ?>', {
|
| 24 |
+
method: 'post',
|
| 25 |
+
parameters: { ip: fieldId },
|
| 26 |
+
onSuccess: function(response){
|
| 27 |
+
$(button).up(1).hide();
|
| 28 |
+
//$(button).up().update(response.responseText);
|
| 29 |
+
}
|
| 30 |
+
});
|
| 31 |
+
}
|
| 32 |
+
function whiteThisIp(button, fieldId)
|
| 33 |
+
{
|
| 34 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/whiteThisIp") ?>', {
|
| 35 |
+
method: 'post',
|
| 36 |
+
parameters: { ip: fieldId },
|
| 37 |
+
onSuccess: function(response){
|
| 38 |
+
$(button).up(1).hide();
|
| 39 |
+
//$(button).up().update(response.responseText);
|
| 40 |
+
}
|
| 41 |
+
});
|
| 42 |
+
}
|
| 43 |
+
function unWhiteThisIp(button, fieldId)
|
| 44 |
+
{
|
| 45 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/unWhiteThisIp") ?>', {
|
| 46 |
+
method: 'post',
|
| 47 |
+
parameters: { ip: fieldId },
|
| 48 |
+
onSuccess: function(response){
|
| 49 |
+
$(button).up(1).hide();
|
| 50 |
+
//$(button).up().update(response.responseText);
|
| 51 |
+
}
|
| 52 |
+
});
|
| 53 |
+
}
|
| 54 |
+
function watchThisIp(button, fieldId)
|
| 55 |
+
{
|
| 56 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/watchThisIp") ?>', {
|
| 57 |
+
method: 'post',
|
| 58 |
+
parameters: { ip: fieldId },
|
| 59 |
+
onSuccess: function(response){
|
| 60 |
+
$(button).up(1).hide();
|
| 61 |
+
//$(button).up().update(response.responseText);
|
| 62 |
+
}
|
| 63 |
+
});
|
| 64 |
+
}
|
| 65 |
+
function unWatchThisIp(button, fieldId)
|
| 66 |
+
{
|
| 67 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/unWatchThisIp") ?>', {
|
| 68 |
+
method: 'post',
|
| 69 |
+
parameters: { ip: fieldId },
|
| 70 |
+
onSuccess: function(response){
|
| 71 |
+
$(button).up(1).hide();
|
| 72 |
+
//$(button).up().update(response.responseText);
|
| 73 |
+
}
|
| 74 |
+
});
|
| 75 |
+
}
|
| 76 |
+
</script>
|
| 77 |
+
|
| 78 |
+
<?php
|
app/design/adminhtml/default/default/template/briel/visitoripsecurity/oneip.phtml
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<div class="content-header">
|
| 3 |
+
<table cellspacing="0">
|
| 4 |
+
<tr>
|
| 5 |
+
<td>
|
| 6 |
+
<h3 class="icon-head"><?php echo $this->__('Block IP classes or single IP'); ?></h3></td>
|
| 7 |
+
<td class="form-buttons">
|
| 8 |
+
<button title="<?php echo $this->__('View list'); ?>" type="button" class="scalable " onclick="setLocation('<?php echo Mage::helper("adminhtml")->getUrl('*/*/index'); ?>')" style="">
|
| 9 |
+
<span><span><span><?php echo $this->__('View list'); ?></span></span></span>
|
| 10 |
+
</button>
|
| 11 |
+
<button title="<?php echo $this->__('View blocked'); ?>" type="button" class="scalable " onclick="setLocation('<?php echo Mage::helper("adminhtml")->getUrl('*/*/blocked'); ?>')" style="">
|
| 12 |
+
<span><span><span><?php echo $this->__('View blocked'); ?></span></span></span>
|
| 13 |
+
</button>
|
| 14 |
+
<button title="<?php echo $this->__('View white list'); ?>" type="button" class="scalable " onclick="setLocation('<?php echo Mage::helper("adminhtml")->getUrl('*/*/white'); ?>')" style="">
|
| 15 |
+
<span><span><span><?php echo $this->__('View white list'); ?></span></span></span>
|
| 16 |
+
</button>
|
| 17 |
+
<button title="<?php echo $this->__('View watch list'); ?>" type="button" class="scalable " onclick="setLocation('<?php echo Mage::helper("adminhtml")->getUrl('*/*/watch'); ?>')" style="">
|
| 18 |
+
<span><span><span><?php echo $this->__('View watch list'); ?></span></span></span>
|
| 19 |
+
</button>
|
| 20 |
+
<button title="<?php echo $this->__('Block ip classes'); ?>" type="button" class="scalable " onclick="setLocation('<?php echo Mage::helper("adminhtml")->getUrl('*/*/oneip'); ?>')" style="">
|
| 21 |
+
<span><span><span><?php echo $this->__('Block ip classes'); ?></span></span></span>
|
| 22 |
+
</button>
|
| 23 |
+
</td>
|
| 24 |
+
</tr>
|
| 25 |
+
</table>
|
| 26 |
+
</div>
|
| 27 |
+
<div>
|
| 28 |
+
<ul class="messages">
|
| 29 |
+
<li class="notice-msg">
|
| 30 |
+
<ul>
|
| 31 |
+
<li>
|
| 32 |
+
<?php echo $this->__('You can use * as a wildcard to block an entire IP class. Ex: 192.168.0.*'); ?>
|
| 33 |
+
</li>
|
| 34 |
+
</ul>
|
| 35 |
+
</li>
|
| 36 |
+
</ul>
|
| 37 |
+
</div>
|
| 38 |
+
<br />
|
| 39 |
+
<div class="grid" style="width: 500px;">
|
| 40 |
+
<table class="data" cellspacing="0">
|
| 41 |
+
<thead>
|
| 42 |
+
<tr class="headings">
|
| 43 |
+
<th colspan="2" style="padding: 5px;">
|
| 44 |
+
<?php echo $this->__('Block this ip'); ?>
|
| 45 |
+
</th>
|
| 46 |
+
</tr>
|
| 47 |
+
</thead>
|
| 48 |
+
<tbody>
|
| 49 |
+
<tr class="even">
|
| 50 |
+
<td style="padding: 15px;" width="60%">
|
| 51 |
+
<input type="text" class="input-text" id="ip_to_block" value="" style="width: 220px;" />
|
| 52 |
+
</td>
|
| 53 |
+
<td style="padding: 15px; text-align: center;">
|
| 54 |
+
<button title="<?php echo $this->__('Block this ip'); ?>" type="button" class="scalable " onclick="block_one_ip();" style="">
|
| 55 |
+
<span><span><span><?php echo $this->__('Block this ip'); ?></span></span></span>
|
| 56 |
+
</button>
|
| 57 |
+
</td>
|
| 58 |
+
</tr>
|
| 59 |
+
</tbody>
|
| 60 |
+
</table>
|
| 61 |
+
</div>
|
| 62 |
+
<br />
|
| 63 |
+
|
| 64 |
+
<div class="grid" style="width: 500px;">
|
| 65 |
+
<table class="data" cellspacing="0" id="blocked_ip_classes">
|
| 66 |
+
<thead>
|
| 67 |
+
<tr class="headings">
|
| 68 |
+
<th colspan="2" style="padding: 5px;">
|
| 69 |
+
<?php echo $this->__('Blocked ip classes'); ?>
|
| 70 |
+
</th>
|
| 71 |
+
</tr>
|
| 72 |
+
</thead>
|
| 73 |
+
<tbody>
|
| 74 |
+
<?php
|
| 75 |
+
|
| 76 |
+
$arrBlocked = Mage::helper('visitoripsecurity')->getBlocked();
|
| 77 |
+
$i = 0;
|
| 78 |
+
foreach ($arrBlocked as $k => $v){
|
| 79 |
+
if(stripos($v, "*") !== false){
|
| 80 |
+
$i++;
|
| 81 |
+
?>
|
| 82 |
+
<tr class="even">
|
| 83 |
+
<td style="padding: 5px;" width="60%"><?php echo $v; ?></td>
|
| 84 |
+
<td style="padding: 5px; text-align: center;">
|
| 85 |
+
<button title="<?php echo $this->__('Unblock this ip'); ?>" type="button" class="scalable " onclick="unblock_one_ip('<?php echo $v; ?>', this);" style="">
|
| 86 |
+
<span><span><span><?php echo $this->__('Unblock this ip'); ?></span></span></span>
|
| 87 |
+
</button>
|
| 88 |
+
</td>
|
| 89 |
+
</tr>
|
| 90 |
+
|
| 91 |
+
<?php
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
//var_dump($arrBlocked);
|
| 96 |
+
?>
|
| 97 |
+
</tbody>
|
| 98 |
+
</table>
|
| 99 |
+
</div>
|
| 100 |
+
<?php
|
| 101 |
+
$button = '<button title="'.$this->__('Unblock this ip').'" type="button" class="scalable " onclick="unblock_one_ip('.$v.', this);" style="">';
|
| 102 |
+
$button .= '<span><span><span>'.$this->__('Unblock this ip').'</span></span></span>';
|
| 103 |
+
$button .= '</button>';
|
| 104 |
+
?>
|
| 105 |
+
<script type="text/javascript">
|
| 106 |
+
function block_one_ip(){
|
| 107 |
+
var ip_to_bl = document.getElementById('ip_to_block').value;
|
| 108 |
+
if(ip_to_bl){
|
| 109 |
+
//alert(ip_to_bl);
|
| 110 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/blockOneIp") ?>', {
|
| 111 |
+
method: 'post',
|
| 112 |
+
parameters: { ip: ip_to_bl},
|
| 113 |
+
onSuccess: function(response){
|
| 114 |
+
//alert(response.responseText);
|
| 115 |
+
if(response.responseText == 'blocked'){
|
| 116 |
+
$('messages').update('<ul class="messages"><li class="notice-msg"><ul><li><?php echo $this->__('IP'); ?> '+ip_to_bl+' <?php echo $this->__('was blocked'); ?></li></ul></li></ul>');
|
| 117 |
+
//$('blocked_ip_classes').insert('<tr class="even"><td style="padding: 5px;">'+ip_to_bl+'</td><td style="padding: 5px; text-align: center;"></td></tr>');
|
| 118 |
+
tr = new Element('tr').addClassName('even');
|
| 119 |
+
tr.insert(new Element('td').setStyle({'padding': '5px'}).update(ip_to_bl));
|
| 120 |
+
tr.insert(new Element('td').setStyle({'textAlign': 'center', 'padding': '5px'}).update('<?php echo $button; ?>'));
|
| 121 |
+
$('blocked_ip_classes').down('tbody').insert(tr);
|
| 122 |
+
}else{
|
| 123 |
+
$('messages').update('<ul class="messages"><li class="notice-msg"><ul><li>'+response.responseText+'</li></ul></li></ul>');
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
//$(button).up().update(response.responseText);
|
| 127 |
+
|
| 128 |
+
}
|
| 129 |
+
});
|
| 130 |
+
}else{
|
| 131 |
+
alert('<?php echo $this->__('Ip field cannot be empty!'); ?>');
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
function unblock_one_ip(ip, field){
|
| 135 |
+
|
| 136 |
+
//alert(ip_to_bl);
|
| 137 |
+
new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl("*/*/unblockOneIp") ?>', {
|
| 138 |
+
method: 'post',
|
| 139 |
+
parameters: { ip: ip},
|
| 140 |
+
onSuccess: function(response){
|
| 141 |
+
//alert(response.responseText);
|
| 142 |
+
$('messages').update('<ul class="messages"><li class="notice-msg"><ul><li>'+response.responseText+'</li></ul></li></ul>');
|
| 143 |
+
$(field).up(1).hide();
|
| 144 |
+
//$(button).up().update(response.responseText);
|
| 145 |
+
|
| 146 |
+
}
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
</script>
|
| 152 |
+
|
| 153 |
+
<?php
|
| 154 |
+
?>
|
app/etc/modules/Briel_Visitoripsecurity.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Briel_Visitoripsecurity>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</Briel_Visitoripsecurity>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
app/locale/ro_RO/Briel_Visitoripsecurity.csv
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"View blocked","Vezi blocate"
|
| 2 |
+
"View list","Vezi lista"
|
| 3 |
+
"View white list","Vezi white list"
|
| 4 |
+
"View watch list","Vezi watch list"
|
| 5 |
+
"Block ip classes","Blocheaza clasa ip"
|
| 6 |
+
"You can use * as a wildcard to block an entire IP class. Ex: 192.168.0.*","Puteti folosi * ca si wildcard pentru a bloca o clasa intreaga de ip-uri. Ex: 192.168.0.*"
|
| 7 |
+
"Block this ip","Blocheaza acest IP"
|
| 8 |
+
"Blocked ip classes","Clase de ip-uri blocate"
|
| 9 |
+
"Unblock","Deblocheaza"
|
| 10 |
+
"Unblock this ip","Deblocheaza acest ip"
|
| 11 |
+
"View visitor list","Vezi lista vizitatorilor"
|
| 12 |
+
"Block IP classes or single IP","Blocheaza o clasa de ip-uri sau un singur ip"
|
| 13 |
+
"Count","Vizite"
|
| 14 |
+
"IP address","Adresa IP"
|
| 15 |
+
"View","Vezi"
|
| 16 |
+
"Notes","Note"
|
| 17 |
+
"Block","Blocheaza"
|
| 18 |
+
"UnBlock","Deblocheaza"
|
| 19 |
+
"Whitelist","Whitelist"
|
| 20 |
+
"Remove white","Scoate din whitelist"
|
| 21 |
+
"Watchlist","Watchlist"
|
| 22 |
+
"Remove watch","Scoate din watchlist"
|
| 23 |
+
"First visit Time","Prima vizita"
|
| 24 |
+
"Last visit Time","Ultima vizita"
|
| 25 |
+
"From","De la"
|
| 26 |
+
"To","Pana"
|
| 27 |
+
"Last url","Ultimul url"
|
| 28 |
+
"Visitors ip list","Lista ip-uri vizitatori"
|
| 29 |
+
"Blocked ip list","Lista ip-uri blocate"
|
| 30 |
+
"White list","Lista ip-uri permise"
|
| 31 |
+
"Watch list","Lista ip-uri supravegheate"
|
| 32 |
+
"is allready blocked","este deja blocat"
|
| 33 |
+
"Ip field cannot be empty!","Campul ip nu poate fi gol!"
|
| 34 |
+
"IP ","IP-ul "
|
| 35 |
+
" is in whitelist"," este in white list"
|
| 36 |
+
" is allready blocked"," este deja blocat"
|
| 37 |
+
" was unblocked"," a fost deblocat"
|
package.xml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Briel_VisitorIpSecurity</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Allows user to see what ip's visited the store, block, watch, whitelist those ip's</summary>
|
| 10 |
+
<description>Allows the following actions on visitors ip:
|
| 11 |
+
- add to block list
|
| 12 |
+
- add to watch list
|
| 13 |
+
- add to white list
|
| 14 |
+
- detailed information about a certain ip, like all the pages that ip visited, total number of visits.
|
| 15 |
+
- works in correlation with magento default visitor logs.
|
| 16 |
+
- email notification when any ip has more then a certain number of visits</description>
|
| 17 |
+
<notes>Stable version, fully functional on our website.</notes>
|
| 18 |
+
<authors><author><name>Velica Onel</name><user>mage_briel</user><email>mage@briel.ro</email></author></authors>
|
| 19 |
+
<date>2013-04-15</date>
|
| 20 |
+
<time>09:59:36</time>
|
| 21 |
+
<contents><target name="magelocal"><dir name="Briel"><dir name="Visitoripsecurity"><dir name="Block"><dir name="Adminhtml"><file name="Blocked.php" hash="33a3043d5a87b31a5da1baa44e38189e"/><file name="Grid.php" hash="4248a2b9f787ceb5bc7e597abdfb5f4d"/><file name="Logurl.php" hash="cc8c46363a2dd600f620e4c7e17b0e92"/><file name="Oneip.php" hash="b57cd3ce62b33fb8f1c486106035cec4"/><dir name="Visitoripsecurity"><dir name="Blocked"><file name="Grid.php" hash="d321f1bd3329c3b6ab640bfc37e04034"/></dir><file name="Grid.php" hash="105d4ec67128ee9aa4f945e1d9475e93"/><dir name="Logurl"><file name="Grid.php" hash="6d37f6a97fcaa46c31883e1dc05ee158"/></dir><dir name="Oneip"><file name="Block.php" hash="bdbd31b85d8cc3bbb2affbaf2e3dbceb"/></dir><dir name="Renderer"><file name="Blockthisip.php" hash="36b650bf097db55b92bf1bb1dd92ced1"/><file name="Count.php" hash="2350b63f23c6f70a5c926a2647320183"/><file name="Firstvisit.php" hash="0f35b6e245e5d107d9e1cb7d598a1928"/><file name="Google.php" hash="32de8dc43091331794a455d6ef866256"/><file name="Lasturl.php" hash="8ca49c2016294db423823879a3eae866"/><file name="Lastvisit.php" hash="24312fcd960774793d22fb70d849064a"/><file name="Notes.php" hash="0ec22910ca8838f0dca025cfc6fad999"/><file name="Pretty.php" hash="a19a856a05afa57df2eb43a781d2d0c9"/><file name="Watchthisip.php" hash="e76fc4de0c64d40304b0fa701726f959"/><file name="Whitethisip.php" hash="66a77f968542d8078c4da42d444e8c0b"/></dir><file name="Renderer.php" hash="68b74b3d0da4582cfbadb9b39cff0ea6"/><dir name="Watch"><file name="Grid.php" hash="08e7d30bd586f288d8b34e89486b597f"/></dir><dir name="White"><file name="Grid.php" hash="5cb80b664833cb4236bb25fadaf4dcf9"/></dir></dir><file name="Watch.php" hash="cfcd4d46cecf14b22520034080e0fe8e"/><file name="White.php" hash="68554d80f01ca19883dc7cacc5edf141"/></dir></dir><dir name="Helper"><file name="Data.php" hash="047ed0a80bb55c95b1b59517fd518901"/></dir><dir name="Model"><dir name="Log"><dir name="Remoteaddr"><file name="Notes.php" hash="438b0b61d28f73d08894c38ae9c0bb7c"/></dir><file name="Url.php" hash="a9dd406c9de369a95aabc1350765c566"/></dir><dir name="Mysql4"><dir name="Log"><dir name="Remoteaddr"><dir name="Notes"><file name="Collection.php" hash="3a0fbe8040b0522fe9f75443f357763b"/></dir><file name="Notes.php" hash="8126aa142aa289b71c905133335476e2"/></dir><dir name="Url"><file name="Collection.php" hash="51d54a1cbd4f9b7d3e84255bdac31bc1"/></dir><file name="Url.php" hash="d80317d7998b812928938e68f9c16784"/></dir><dir name="Visitoripsecurity"><file name="Collection.php" hash="8eacc6635320ef3865134e0fc5d5def5"/></dir><file name="Visitoripsecurity.php" hash="adc846eb0382fa63781ec109d044599d"/></dir><file name="Notes.php" hash="ef56f20501a4b4206d6f9908ec3f3376"/><file name="Observer.php" hash="c9b36a67f3675e64d622122e03ffa2a1"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="VisitoripsecurityController.php" hash="5358c5c1ecc08eebef482aded55a4322"/></dir><file name="IndexController.php" hash="65dd524e63822785eb5ed11a009cc1b8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="00fbd9aec0c828c5e62a82314ee98dba"/><file name="config.xml" hash="b8f298948ce3236f098b5936bf26134f"/><file name="system.xml" hash="33216eab7c16ab17905ce2d69835817c"/></dir><dir name="sql"><dir name="visitoripsecurity_setup"><file name="mysql4-install-0.1.0.php" hash="eb018ad2b85783c8856e322c5a5a8f25"/></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Briel_Visitoripsecurity.xml" hash="57b66b169d5072e54f7b173a849df631"/></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="briel_visitoripsecurity.xml" hash="b449d538b7c27ee019d4a3ed1171b639"/></dir><dir name="template"><dir name="briel"><dir name="visitoripsecurity"><file name="inline-edit.phtml" hash="1b42183608c087284a9c20fbb0276d87"/><file name="oneip.phtml" hash="8a319a97ab497f3c166aed5d39deeb19"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="ro_RO"><file name="Briel_Visitoripsecurity.csv" hash="a659926cc3b9af5af83c43063b33699a"/></dir></dir></target></contents>
|
| 22 |
+
<compatible/>
|
| 23 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 24 |
+
</package>
|
