Plugin Directory

Changeset 1522317


Ignore:
Timestamp:
10/26/2016 09:49:57 AM (9 years ago)
Author:
manky
Message:

v1.2.2

Location:
ivguard
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • ivguard/trunk/IVGuard.php

    r1471472 r1522317  
    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.1
     7Version: 1.2.2
    88Author URI: http://www.ignitevision.bg
    99*/
     
    2424    add_action('login_form', array('IVGuard', 'onLoginForm'));
    2525    add_action('password_reset', array('IVGuard', 'onPasswordReset'), 10, 2);
     26    add_action('admin_post_ivguard_settings', array('IVGuard', 'setSettings'));
    2627    add_filter('login_redirect', array('IVGuard', 'onLoginRedirect'), 10, 3);
    2728    add_filter('authenticate', array('IVGuard', 'onAuthenticate'), 30, 3);
     
    3031        const CRAWLER = 'crawler.ivguard.net';
    3132        const APIKEY = 'ivGuardKey';
     33        const API_VERIFY_IP = 'ivGuardAPIVerifyIP';
    3234        const ALLOWED_IPS_KEY = 'ivGuardAllowedIPs';
    3335        const WEBSITE = 'https://ivguard.net/';
     
    4850                add_option(IVGuard::APIKEY, md5((rand(999, 9999) * rand(666, 6666)) + time()));
    4951
     52            if(!get_option(IVGuard::API_VERIFY_IP))
     53                add_option(IVGuard::API_VERIFY_IP, 1);
     54
    5055            if(!function_exists('dbDelta'))
    5156                require_once(ABSPATH.DIRECTORY_SEPARATOR.'wp-admin'.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'upgrade.php');
     
    120125            $wpdb->query('DROP TABLE IF EXISTS `'.$wpdb->prefix.IVGuard::DB_TABLE_LOGIN_FAIL.'`');
    121126            delete_option(IVGuard::APIKEY);
     127            delete_option(IVGuard::API_VERIFY_IP);
    122128        }
    123129
     
    146152            echo '  <div class="welcome-panel" style="background-color:rgba(255,255,255,.5)">';
    147153            echo '      <h2>Activation</h2>';
    148             echo '      <p style="font-size:1.1em">To start the monitoring process copy the following code, and paste it in the Activation Code field on the "Secure Site" Tab. Remember you must be registered and logged in <a target="_blank" href="'.IVGuard::WEBSITE.'">'.IVGuard::WEBSITE.'</a> before you proceed with this step.</p>';
     154            echo '      <hr>';
     155            echo '      <p style="font-size:1.1em">';
     156            echo '          To start the monitoring process copy the following code, and paste it in the Activation Code field on the "Secure Site" Tab. Remember you must be registered and logged in <a target="_blank" href="'.IVGuard::WEBSITE.'">'.IVGuard::WEBSITE.'</a> before you proceed with this step.';
     157            echo '          <br><br><b>Never share this activation code with anyone else</b>';
     158            echo '      </p>';
    149159            echo '      <label for="activationCode">Activation Code:</label>';
    150160            echo '      <textarea id="activationCode" style="width:100%" readonly>' . $activationCode . '</textarea>';
    151161            echo '      <p style="text-align:center"><button data-clipboard-target="#activationCode" class="button">Copy To Clipboard</button></p>';
    152162            echo '  </div>';
     163            echo '  <div class="welcome-panel" style="background-color:rgba(255,255,255,.5)">';
     164            echo '      <h2>Settings</h2>';
     165            echo '      <hr>';
     166            echo '      <label for="apiVerifyIp">Enable requests behind proxy</label>';
     167            echo '      <select id="apiVerifyIp" name="apiVerifyIp">';
     168            echo '          <option value="1">No</option>';
     169            echo '          <option value="0"'.(get_option(IVGuard::API_VERIFY_IP, 1) == 0 ? ' selected' : null).'>Yes</option>';
     170            echo '      </select>';
     171            echo '      <p style="font-size:1.1em">If your website is running behind a proxy like CloudFlare or this is not your IP address <b>'.$_SERVER['REMOTE_ADDR'].'</b> you need to set this option to "Yes".</p>';
     172            echo '  </div>';
    153173            echo '</div>';
    154174            echo '<script>';
    155175            echo 'jQuery(function() {';
    156             echo 'jQuery("body").css({"background-image":"url('.IVGuard::getLogo().')","background-size":"80%","background-repeat":"no-repeat","background-position":"center 10vh","background-attachment":"fixed"});';
    157             echo 'new Clipboard("button[data-clipboard-target]");';
     176            echo '  jQuery("body").css({"background-image":"url('.IVGuard::getLogo().')","background-size":"80%","background-repeat":"no-repeat","background-position":"center 10vh","background-attachment":"fixed"});';
     177            echo '  new Clipboard("button[data-clipboard-target]");';
     178            echo '  jQuery("select#apiVerifyIp").on("change", function() {';
     179            echo '      jQuery.post("'.admin_url('admin-post.php').'", {action: "ivguard_settings", '.IVGuard::API_VERIFY_IP.': jQuery(this).val()});';
     180            echo '  });';
    158181            echo '})';
    159182            echo '</script>';
     183        }
     184
     185        public static function setSettings() {
     186            if(array_key_exists(IVGuard::API_VERIFY_IP, $_POST) && in_array($_POST[IVGuard::API_VERIFY_IP], array(0, 1)))
     187                update_option(IVGuard::API_VERIFY_IP, $_POST[IVGuard::API_VERIFY_IP]);
    160188        }
    161189
     
    360388
    361389        public static function authorize() {
    362             if(!in_array($_SERVER['REMOTE_ADDR'], IVGuard::getAllowedIPs()))
    363                 throw new Exception('Unauthorized actions have been detected! [BAD IP]');
     390            if(get_option(IVGuard::API_VERIFY_IP, 1) != 0) {
     391                if(!in_array($_SERVER['REMOTE_ADDR'], IVGuard::getAllowedIPs()))
     392                    throw new Exception('Unauthorized actions have been detected! [BAD IP]');
     393            }
    364394            if(!($ivGuardKey = get_option(IVGuard::APIKEY)))
    365395                throw new Exception('Unauthorized actions have been detected! [NO KEY]');
     
    375405            if(!$data) {
    376406                $allowedIPs = dns_get_record(IVGuard::CRAWLER, DNS_A + DNS_AAAA);
    377                 if(!is_array($allowedIPs))
     407                if(!is_array($allowedIPs) || empty($allowedIPs))
    378408                    throw new Exception('Unable to get a list with allowed IP addresses! [DNS Error]');
    379409                array_walk($allowedIPs, function(&$item, $key) { $item = $item['type'] == 'A' ? $item['ip'] : $item['ipv6']; });
    380                 $data = array('expire' => time() + 3600, 'allowedIPs' => $allowedIPs);
     410                $data = array('expire' => time() + 300, 'allowedIPs' => $allowedIPs);
    381411                update_option(IVGuard::ALLOWED_IPS_KEY, json_encode($data));
    382412            }
  • ivguard/trunk/readme.txt

    r1471472 r1522317  
    44Tags: security, secure, protection, protect, prevention, guard, monitoring, backup, ban, block, bots, hack, anti-virus, malware, attack, injection, brute-force
    55Requires at least: 4.4
    6 Tested up to: 4.6
    7 Stable tag: 1.2.1
     6Tested up to: 4.6.1
     7Stable tag: 1.2.2
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    9696== Changelog ==
    9797
     98= 1.2.2 =
     99* Add - Option to disable IP verification (for the API Requests)
     100
    98101= 1.2.1 =
    99102* Add - DNS Cache
Note: See TracChangeset for help on using the changeset viewer.