Version Notes
stable release version
Download this release
Release Info
| Developer | SSTech |
| Extension | SSTech_Secure |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
app/code/community/SSTech/Secure/Model/Observer.php
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class SSTech_Secure_Model_Observer
|
| 3 |
+
{
|
| 4 |
+
private $redirect_page = null;
|
| 5 |
+
private $redirect_blank = null;
|
| 6 |
+
private $raw_allow_ip_data = null;
|
| 7 |
+
private $raw_block_ip_data = null;
|
| 8 |
+
|
| 9 |
+
public function __construct()
|
| 10 |
+
{
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/*
|
| 14 |
+
@Comment to check the Frontend configuration
|
| 15 |
+
@author SSTech
|
| 16 |
+
*/
|
| 17 |
+
public function apply_seecurefrontend_check_frontend($observer)
|
| 18 |
+
{
|
| 19 |
+
$this->redirect_page = $this->trim_slashes(Mage::getUrl(Mage::getStoreConfig('admin/securefrontend/redirect_page')));
|
| 20 |
+
$this->redirect_blank = Mage::getStoreConfig('admin/securefrontend/redirect_blank');
|
| 21 |
+
$this->raw_allow_ip_data = Mage::getStoreConfig('admin/securefrontend/allow');
|
| 22 |
+
$this->raw_block_ip_data = Mage::getStoreConfig('admin/securefrontend/block');
|
| 23 |
+
$this->apply_ip_check($observer);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/*
|
| 27 |
+
@Comment to check the Admin configuration
|
| 28 |
+
@author SSTech
|
| 29 |
+
*/
|
| 30 |
+
|
| 31 |
+
public function apply_secureadmin_check_admin($observer)
|
| 32 |
+
{
|
| 33 |
+
$this->redirect_page = $this->trim_slashes(Mage::getUrl(Mage::getStoreConfig('admin/secureadmin/redirect_page')));
|
| 34 |
+
$this->redirect_blank = Mage::getStoreConfig('admin/secureadmin/redirect_blank');
|
| 35 |
+
$this->raw_allow_ip_data = Mage::getStoreConfig('admin/secureadmin/allow');
|
| 36 |
+
$this->raw_block_ip_data = Mage::getStoreConfig('admin/secureadmin/block');
|
| 37 |
+
$this->apply_ip_check($observer);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/*
|
| 41 |
+
@Comment to restrict and Secure Ip
|
| 42 |
+
@author SSTech
|
| 43 |
+
*/
|
| 44 |
+
public function apply_ip_check($observer)
|
| 45 |
+
{
|
| 46 |
+
$current_ip = $_SERVER['REMOTE_ADDR'];
|
| 47 |
+
$allow = true;
|
| 48 |
+
$allow_ips = null;
|
| 49 |
+
$block_ips = null;
|
| 50 |
+
$current_page = $this->trim_slashes(Mage::helper('core/url')->getCurrentUrl());
|
| 51 |
+
|
| 52 |
+
if(strlen($this->redirect_page)){$this->trim_slashes(Mage::getUrl('no-route'));}
|
| 53 |
+
|
| 54 |
+
$allow_ips = explode("\r\n", $this->raw_allow_ip_data);
|
| 55 |
+
$block_ips = explode("\r\n", $this->raw_block_ip_data);
|
| 56 |
+
|
| 57 |
+
if(trim($this->raw_allow_ip_data)>0){
|
| 58 |
+
$allow = false;
|
| 59 |
+
if($this->find_ip($current_ip,$allow_ips)){
|
| 60 |
+
$allow = true;
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
if(trim($this->raw_block_ip_data)>0){
|
| 64 |
+
if($this->find_ip($current_ip,$block_ips)){
|
| 65 |
+
$allow = false;
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
if($this->redirect_blank==1 && !$allow){
|
| 69 |
+
exit();
|
| 70 |
+
}
|
| 71 |
+
if($current_page!=$this->redirect_page && !$allow){
|
| 72 |
+
header('Location: '.$this->redirect_page);
|
| 73 |
+
exit();
|
| 74 |
+
}
|
| 75 |
+
return $this;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/*
|
| 79 |
+
@Comment To Find IP
|
| 80 |
+
@author SSTech
|
| 81 |
+
*/
|
| 82 |
+
private function find_ip($search_ip,$array)
|
| 83 |
+
{
|
| 84 |
+
$found = false;
|
| 85 |
+
if(count($array)>0){
|
| 86 |
+
foreach($array as $ip){
|
| 87 |
+
if(preg_match('/^'.str_replace(array('\*','\?'), array('(.*?)','[0-9]'), preg_quote($ip)).'$/',$search_ip)){
|
| 88 |
+
$found = true;
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
return $found;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
private function trim_slashes($str)
|
| 96 |
+
{
|
| 97 |
+
$str = trim($str);
|
| 98 |
+
return $str == '/' ? $str : rtrim($str, '/');
|
| 99 |
+
}
|
| 100 |
+
}
|
app/code/community/SSTech/Secure/etc/config.xml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SSTech_Secure>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</SSTech_Secure>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<sstechsecure>
|
| 11 |
+
<class>SSTech_Secure_Model</class>
|
| 12 |
+
</sstechsecure>
|
| 13 |
+
</models>
|
| 14 |
+
</global>
|
| 15 |
+
<frontend>
|
| 16 |
+
<events>
|
| 17 |
+
<controller_action_predispatch>
|
| 18 |
+
<observers>
|
| 19 |
+
<sstech_secure_observer>
|
| 20 |
+
<type>singleton</type>
|
| 21 |
+
<class>sstechsecure/observer</class>
|
| 22 |
+
<method>apply_securefrontend_check_frontend</method>
|
| 23 |
+
</sstech_secure_observer>
|
| 24 |
+
</observers>
|
| 25 |
+
</controller_action_predispatch>
|
| 26 |
+
</events>
|
| 27 |
+
</frontend>
|
| 28 |
+
<adminhtml>
|
| 29 |
+
<events>
|
| 30 |
+
<controller_action_predispatch>
|
| 31 |
+
<observers>
|
| 32 |
+
<sstech_secure_observer>
|
| 33 |
+
<type>singleton</type>
|
| 34 |
+
<class>sstechsecure/observer</class>
|
| 35 |
+
<method>apply_secureadmin_check_admin</method>
|
| 36 |
+
</sstech_secure_observer>
|
| 37 |
+
</observers>
|
| 38 |
+
</controller_action_predispatch>
|
| 39 |
+
</events>
|
| 40 |
+
</adminhtml>
|
| 41 |
+
</config>
|
app/code/community/SSTech/Secure/etc/system.xml
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<dev>
|
| 5 |
+
<groups>
|
| 6 |
+
<securefrontend translate="label">
|
| 7 |
+
<label>Secure - Frontend</label>
|
| 8 |
+
<sort_order>500</sort_order>
|
| 9 |
+
<show_in_default>1</show_in_default>
|
| 10 |
+
<show_in_website>1</show_in_website>
|
| 11 |
+
<show_in_store>1</show_in_store>
|
| 12 |
+
<fields>
|
| 13 |
+
<allow translate="label">
|
| 14 |
+
<label>Allow these IPs</label>
|
| 15 |
+
<frontend_type>textarea</frontend_type>
|
| 16 |
+
<sort_order>100</sort_order>
|
| 17 |
+
<show_in_default>1</show_in_default>
|
| 18 |
+
<show_in_website>1</show_in_website>
|
| 19 |
+
<show_in_store>1</show_in_store>
|
| 20 |
+
</allow>
|
| 21 |
+
<block translate="label">
|
| 22 |
+
<label>Lock these IPs</label>
|
| 23 |
+
<frontend_type>textarea</frontend_type>
|
| 24 |
+
<sort_order>200</sort_order>
|
| 25 |
+
<show_in_default>1</show_in_default>
|
| 26 |
+
<show_in_website>1</show_in_website>
|
| 27 |
+
<show_in_store>1</show_in_store>
|
| 28 |
+
</block>
|
| 29 |
+
<redirect_blank translate="label">
|
| 30 |
+
<label>Redirect to blank page</label>
|
| 31 |
+
<frontend_type>select</frontend_type>
|
| 32 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 33 |
+
<comment><![CDATA[Will redirect to blank page if "No"!]]></comment>
|
| 34 |
+
<sort_order>300</sort_order>
|
| 35 |
+
<show_in_default>1</show_in_default>
|
| 36 |
+
<show_in_website>1</show_in_website>
|
| 37 |
+
<show_in_store>1</show_in_store>
|
| 38 |
+
</redirect_blank>
|
| 39 |
+
<redirect_page translate="label">
|
| 40 |
+
<label>Redirect to CMS page</label>
|
| 41 |
+
<frontend_type>select</frontend_type>
|
| 42 |
+
<source_model>adminhtml/system_config_source_cms_page</source_model>
|
| 43 |
+
<comment><![CDATA[Assign the Cms page which you need to assign for redirect!]]></comment>
|
| 44 |
+
<sort_order>400</sort_order>
|
| 45 |
+
<show_in_default>1</show_in_default>
|
| 46 |
+
<show_in_website>1</show_in_website>
|
| 47 |
+
<show_in_store>1</show_in_store>
|
| 48 |
+
</redirect_page>
|
| 49 |
+
</fields>
|
| 50 |
+
</securefrontend>
|
| 51 |
+
<secureadmin translate="label">
|
| 52 |
+
<label>Secure - Admin</label>
|
| 53 |
+
<sort_order>600</sort_order>
|
| 54 |
+
<show_in_default>1</show_in_default>
|
| 55 |
+
<show_in_website>1</show_in_website>
|
| 56 |
+
<show_in_store>1</show_in_store>
|
| 57 |
+
<fields>
|
| 58 |
+
<allow translate="label comment">
|
| 59 |
+
<label>Allow these IPs</label>
|
| 60 |
+
<frontend_type>textarea</frontend_type>
|
| 61 |
+
<comment><![CDATA[Be careful not to lock yourself out!]]></comment>
|
| 62 |
+
<sort_order>100</sort_order>
|
| 63 |
+
<show_in_default>1</show_in_default>
|
| 64 |
+
<show_in_website>1</show_in_website>
|
| 65 |
+
<show_in_store>1</show_in_store>
|
| 66 |
+
</allow>
|
| 67 |
+
<block translate="label">
|
| 68 |
+
<label>Lock these IPs</label>
|
| 69 |
+
<frontend_type>textarea</frontend_type>
|
| 70 |
+
<sort_order>200</sort_order>
|
| 71 |
+
<show_in_default>1</show_in_default>
|
| 72 |
+
<show_in_website>1</show_in_website>
|
| 73 |
+
<show_in_store>1</show_in_store>
|
| 74 |
+
</block>
|
| 75 |
+
<redirect_blank translate="label">
|
| 76 |
+
<label>Redirect to blank page</label>
|
| 77 |
+
<frontend_type>select</frontend_type>
|
| 78 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 79 |
+
<comment><![CDATA[Will redirect to blank page if "No"!]]></comment>
|
| 80 |
+
<sort_order>300</sort_order>
|
| 81 |
+
<show_in_default>1</show_in_default>
|
| 82 |
+
<show_in_website>1</show_in_website>
|
| 83 |
+
<show_in_store>1</show_in_store>
|
| 84 |
+
</redirect_blank>
|
| 85 |
+
<redirect_page translate="label">
|
| 86 |
+
<label>Redirect to CMS page</label>
|
| 87 |
+
<frontend_type>select</frontend_type>
|
| 88 |
+
<source_model>adminhtml/system_config_source_cms_page</source_model>
|
| 89 |
+
<comment><![CDATA[Assign the Cms page which you need to assign for redirect!]]></comment>
|
| 90 |
+
<sort_order>400</sort_order>
|
| 91 |
+
<show_in_default>1</show_in_default>
|
| 92 |
+
<show_in_website>1</show_in_website>
|
| 93 |
+
<show_in_store>1</show_in_store>
|
| 94 |
+
</redirect_page>
|
| 95 |
+
</fields>
|
| 96 |
+
</secureadmin>
|
| 97 |
+
</groups>
|
| 98 |
+
</dev>
|
| 99 |
+
</sections>
|
| 100 |
+
</config>
|
app/etc/modules/SSTech_Secure.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SSTech_Secure>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</SSTech_Secure>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>SSTech_Secure</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>Open Source License</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Extension which will allow to Seecure and Restrict User by adding the IP location</summary>
|
| 10 |
+
<description>Extension which will allow to Seecure and Restrict User by adding the IP location</description>
|
| 11 |
+
<notes>stable release version</notes>
|
| 12 |
+
<authors><author><name>SSTech</name><user>SSTech</user><email>sanynaresh@gmail.com</email></author></authors>
|
| 13 |
+
<date>2014-08-30</date>
|
| 14 |
+
<time>08:17:26</time>
|
| 15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="SSTech_Secure.xml" hash="5d19b83b03d6b149697ef1dadb14fa96"/></dir></target><target name="magecommunity"><dir name="SSTech"><dir name="Secure"><dir name="Model"><file name="Observer.php" hash="c92a19096fb2a945f37e9b8fe6165921"/></dir><dir name="etc"><file name="config.xml" hash="710b316d00f14f7fe47bebcf8e9bbf7c"/><file name="system.xml" hash="6b38f5bfa84eb8e76b6936a17fb046d0"/></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
