PluginProbe
IP Location Block / 1.3.9
IP Location Block v1.3.9
1.4.1 1.4.0 1.4.0-rc.1 1.4.0-rc.2 1.4.0-rc.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.1.3 1.1.5 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 All 34 releases
ip-location-block / ip-location-block.php

ip-location-block.php in IP Location Block 1.3.9, at ip-location-block.php

159 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * IP Location Block
4 *
5 * A WordPress plugin that blocks undesired access based on geolocation of IP address.
6 *
7 * @package IP_Location_Block
8 * @author Darko Gjorgjijoski <dg@darkog.com>
9 * @license GPL-3.0
10 * @link https://iplocationblock.com/
11 * @copyright 2021 darkog
12 * @copyright 2013-2019 tokkonopapa
13 *
14 * Plugin Name: IP Location Block
15 * Plugin URI: https://wordpress.org/plugins/ip-location-block/
16 * Description: Easily setup location block based on the visitor country, city, state or provider. Also protects your site from spam, login attempts, zero-day exploits, malicious access & more.
17 * Version: 1.3.9
18 * Author: IP Location Block
19 * Author URI: https://iplocationblock.com/
20 * Text Domain: ip-location-block
21 * License: GPL-3.0
22 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
23 * Domain Path: /languages
24 */
25
26 defined( 'WPINC' ) or die; // If this file is called directly, abort.
27
28 if(!defined("AUTH_KEY") || !defined("SECURE_AUTH_KEY") || !defined("LOGGED_IN_KEY") || !defined("NONCE_KEY") ||
29 !defined("AUTH_SALT") || !defined("SECURE_AUTH_SALT") || !defined("LOGGED_IN_SALT") || !defined("NONCE_SALT")) {
30 if(isset($GLOBALS['ip_location_block_hash_keys_notice']) && $GLOBALS['ip_location_block_hash_keys_notice']) {
31 return;
32 }
33 add_action('admin_notices', function (){
34 ?>
35 <div class="notice notice-error">
36 <p><strong><?php _e( 'IP Location Block Error:', 'ip-location-block' ); ?></strong></p>
37 <p><?php _e( 'WordPress security keys and salts are not properly configured in wp-config.php. This plugin requires all authentication constants (AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, NONCE_SALT) to be defined for security reasons.', 'ip-location-block' ); ?></p>
38 <p><?php printf(
39 __( 'Please generate new security keys at %s and add them to your wp-config.php file.', 'ip-location-block' ),
40 '<a href="https://api.wordpress.org/secret-key/1.1/salt/" target="_blank">https://api.wordpress.org/secret-key/1.1/salt/</a>'
41 ); ?></p>
42 </div>
43 <?php
44 });
45 $GLOBALS['ip_location_block_hash_keys_notice'] = true;
46 return;
47 }
48
49
50 if ( ! class_exists( 'IP_Location_Block', false ) ):
51
52 /*----------------------------------------------------------------------------*
53 * Global definition
54 *----------------------------------------------------------------------------*/
55 define( 'IP_LOCATION_BLOCK_VERSION', '1.3.9' );
56 define( 'IP_LOCATION_BLOCK_PATH', plugin_dir_path( __FILE__ ) ); // @since 0.2.8
57 define( 'IP_LOCATION_BLOCK_BASE', plugin_basename( __FILE__ ) ); // @since 1.5
58
59 /*----------------------------------------------------------------------------*
60 * Public-Facing Functionality
61 *----------------------------------------------------------------------------*/
62
63 /**
64 * Load class
65 *
66 */
67 require_once ABSPATH . 'wp-admin/includes/plugin.php';
68 require IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block.php';
69 require IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-util.php';
70 require IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-load.php';
71 require IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-logs.php';
72 require IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-apis.php';
73 require IP_LOCATION_BLOCK_PATH . 'classes/db-providers/ip2location/class-ip2location.php';
74 require IP_LOCATION_BLOCK_PATH . 'classes/db-providers/maxmind/class-maxmind-geolite2.php';
75
76
77 function ip_location_block_activate( $network_wide = false ) {
78 require_once IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-actv.php';
79 IP_Location_Block_Activate::activate( $network_wide );
80 }
81
82 function ip_location_block_deactivate( $network_wide = false ) {
83 require_once IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-actv.php';
84 IP_Location_Block_Activate::deactivate( $network_wide );
85 }
86
87 register_activation_hook( __FILE__, 'ip_location_block_activate' );
88 register_deactivation_hook( __FILE__, 'ip_location_block_deactivate' );
89
90 function ip_location_block_upgrader_process_complete( $upgrader_object, $options ) {
91 // If an update has taken place and the updated type is plugins and the plugins element exists
92 if ( isset( $options['action']) && $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) {
93 foreach( $options['plugins'] as $plugin ) {
94 if( $plugin == plugin_basename( __FILE__ ) ) {
95 require_once IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-util.php';
96 require_once IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-opts.php';
97 require_once IP_LOCATION_BLOCK_PATH . 'classes/class-ip-location-block-logs.php';
98 IP_Location_Block_Opts::upgrade();
99 }
100 }
101 }
102 }
103 add_action( 'upgrader_process_complete', 'ip_location_block_upgrader_process_complete', 10, 2 );
104
105 /**
106 * check version and update before instantiation
107 *
108 * @see https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks/
109 * @see https://wordpress.stackexchange.com/questions/144870/wordpress-update-plugin-hook-action-since-3-9
110 */
111 function ip_location_block_update() {
112 $settings = IP_Location_Block::get_option();
113 if ( version_compare( $settings['version'], IP_LOCATION_BLOCK_VERSION ) < 0 ) {
114 ip_location_block_activate( is_plugin_active_for_network( IP_LOCATION_BLOCK_BASE ) );
115 }
116 }
117
118 add_action( 'plugins_loaded', 'ip_location_block_update' );
119
120 /**
121 * Instantiate class
122 *
123 */
124 add_action( 'plugins_loaded', array( 'IP_Location_Block', 'get_instance' ) );
125
126 /*----------------------------------------------------------------------------*
127 * Dashboard and Administrative Functionality
128 *----------------------------------------------------------------------------*/
129
130 /**
131 * Load class in case of wp-admin/*.php
132 *
133 */
134 if ( is_admin() ) {
135 require IP_LOCATION_BLOCK_PATH . 'admin/class-ip-location-block-admin.php';
136 add_action( 'plugins_loaded', array( 'IP_Location_Block_Admin', 'get_instance' ) );
137 }
138
139 /*----------------------------------------------------------------------------*
140 * Emergency Functionality
141 *----------------------------------------------------------------------------*/
142
143 /**
144 * Invalidate blocking behavior in case yourself is locked out.
145 *
146 * How to use: Activate the following code and upload this file via FTP.
147 */
148 /* -- ADD `/` TO THE TOP OR END OF THIS LINE TO ACTIVATE THE FOLLOWINGS -- *
149 function ip_location_block_emergency( $validate, $settings ) {
150 $validate['result'] = 'passed';
151 return $validate;
152 }
153 add_filter( 'ip-location-block-login', 'ip_location_block_emergency', 1, 2 );
154 add_filter( 'ip-location-block-admin', 'ip_location_block_emergency', 1, 2 );
155 add_filter( 'ip-location-block-public', 'ip_location_block_emergency', 1, 2 );
156 // */
157
158 endif; // ! class_exists( 'IP_Location_Block', FALSE )
159