Plugin Directory

Changeset 1471472


Ignore:
Timestamp:
08/10/2016 11:11:53 AM (10 years ago)
Author:
manky
Message:

v1.2.1

Location:
ivguard
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • ivguard/trunk/IVGuard.php

    r1470852 r1471472  
    55Description: IVGuard is one of the most powerful protection and monitoring services for WordPress. You will be informed immediately for any changes and discrepancies in your website and our team will be always on standby to help you resolve any security threats. Have full control of your website once and for all.
    66Author: Ignite Vision Ltd
    7 Version: 1.2
     7Version: 1.2.1
    88Author URI: http://www.ignitevision.bg
    99*/
     
    3030        const CRAWLER = 'crawler.ivguard.net';
    3131        const APIKEY = 'ivGuardKey';
     32        const ALLOWED_IPS_KEY = 'ivGuardAllowedIPs';
    3233        const WEBSITE = 'https://ivguard.net/';
    3334        const API = 'https://dashboard.ivguard.net/api/';
     
    359360
    360361        public static function authorize() {
    361             $allowIPs = dns_get_record(IVGuard::CRAWLER, DNS_A + DNS_AAAA);
    362             if(is_array($allowIPs))
    363                 array_walk($allowIPs, function(&$item, $key) { $item = $item['type'] == 'A' ? $item['ip'] : $item['ipv6']; });
    364             if(!in_array($_SERVER['REMOTE_ADDR'], $allowIPs))
     362            if(!in_array($_SERVER['REMOTE_ADDR'], IVGuard::getAllowedIPs()))
    365363                throw new Exception('Unauthorized actions have been detected! [BAD IP]');
    366364            if(!($ivGuardKey = get_option(IVGuard::APIKEY)))
     
    368366            if(!isset($_POST['ivGuardKey']) || $_POST['ivGuardKey'] != $ivGuardKey)
    369367                throw new Exception('Unauthorized actions have been detected! [BAD KEY]');
     368        }
     369
     370        public static function getAllowedIPs() {
     371            if(($data = get_option(IVGuard::ALLOWED_IPS_KEY))) {
     372                if(!is_array($data = json_decode($data, true)) || !array_key_exists('expire', $data) || !array_key_exists('allowedIPs', $data) || $data['expire'] < time())
     373                    $data = false;
     374            }
     375            if(!$data) {
     376                $allowedIPs = dns_get_record(IVGuard::CRAWLER, DNS_A + DNS_AAAA);
     377                if(!is_array($allowedIPs))
     378                    throw new Exception('Unable to get a list with allowed IP addresses! [DNS Error]');
     379                array_walk($allowedIPs, function(&$item, $key) { $item = $item['type'] == 'A' ? $item['ip'] : $item['ipv6']; });
     380                $data = array('expire' => time() + 3600, 'allowedIPs' => $allowedIPs);
     381                update_option(IVGuard::ALLOWED_IPS_KEY, json_encode($data));
     382            }
     383            return $data['allowedIPs'];
    370384        }
    371385
  • ivguard/trunk/readme.txt

    r1470852 r1471472  
    55Requires at least: 4.4
    66Tested up to: 4.6
    7 Stable tag: 1.2
     7Stable tag: 1.2.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    9696== Changelog ==
    9797
     98= 1.2.1 =
     99* Add - DNS Cache
     100
    98101= 1.2 =
    99102* Add - Brute-Force Protection
     
    106109= 1.0 =
    107110* Initial release
    108 
    109 == Upgrade Notice ==
    110 
    111 = 1.2 =
    112 Version 1.2 content a new features (Brute-Force Protection). It is recommended for all users.
    113 
    114 = 1.1 =
    115 Version 1.1 contains a new feature (Bad Bots Block) and a bug fix that fixes API output. It is recommended for all users.
    116 
    117 = 1.0 =
    118 First Release
Note: See TracChangeset for help on using the changeset viewer.