PluginProbe ʕ •ᴥ•ʔ
SiteGuard WP Plugin / 1.6.0
SiteGuard WP Plugin v1.6.0
1.8.7 1.8.6 1.8.6-beta1 1.8.6-beta2 1.8.4 1.8.5 1.8.3 1.8.2 1.8.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.4.3 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.7.0 1.7.1 1.7.10 1.7.11 1.7.12 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.0-beta1 1.8.0-beta2 1.8.0-beta3 1.8.0-beta4
siteguard / siteguard.php
siteguard Last commit date
admin 5 years ago classes 5 years ago css 5 years ago images 11 years ago languages 5 years ago really-simple-captcha 8 years ago test 8 years ago license.txt 11 years ago readme.txt 4 years ago siteguard.php 5 years ago uninstall.php 9 years ago
siteguard.php
280 lines
1 <?php
2 /*
3 Plugin Name: SiteGuard WP Plugin
4 Plugin URI: http://www.jp-secure.com/cont/products/siteguard_wp_plugin/index_en.html
5 Description: Only installing SiteGuard WP Plugin on WordPress, its security can be improved. SiteGurad WP Plugin is the plugin specialized for the protection against the attack to the management page and login. It also have the function to create the exclude rule for WAF (SiteGuard Lite, to use it, WAF should be installed on the Web server.)
6 Author: JP-Secure
7 Author URI: http://www.jp-secure.com/eng/
8 Text Domain: siteguard
9 Domain Path: /languages/
10 Version: 1.6.0
11 */
12
13 /* Copyright 2014 JP-Secure Inc
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License, version 2, as
17 published by the Free Software Foundation.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 */
28
29 if ( ! defined( 'ABSPATH' ) ) {
30 exit;
31 }
32
33 $data = get_file_data( __FILE__, array( 'version' => 'Version' ) );
34 define( 'SITEGUARD_VERSION', $data['version'] );
35
36 define( 'SITEGUARD_PATH', plugin_dir_path( __FILE__ ) );
37 define( 'SITEGUARD_URL_PATH', plugin_dir_url( __FILE__ ) );
38
39 define( 'SITEGUARD_LOGIN_NOSELECT', 4 );
40 define( 'SITEGUARD_LOGIN_SUCCESS', 0 );
41 define( 'SITEGUARD_LOGIN_FAILED', 1 );
42 define( 'SITEGUARD_LOGIN_FAIL_ONCE', 2 );
43 define( 'SITEGUARD_LOGIN_LOCKED', 3 );
44
45 define( 'SITEGUARD_LOGIN_TYPE_NOSELECT', 2 );
46 define( 'SITEGUARD_LOGIN_TYPE_NORMAL', 0 );
47 define( 'SITEGUARD_LOGIN_TYPE_XMLRPC', 1 );
48
49 require_once( 'classes/siteguard-base.php' );
50 require_once( 'classes/siteguard-config.php' );
51 require_once( 'classes/siteguard-htaccess.php' );
52 require_once( 'classes/siteguard-admin-filter.php' );
53 require_once( 'classes/siteguard-rename-login.php' );
54 require_once( 'classes/siteguard-login-history.php' );
55 require_once( 'classes/siteguard-login-lock.php' );
56 require_once( 'classes/siteguard-login-alert.php' );
57 require_once( 'classes/siteguard-captcha.php' );
58 require_once( 'classes/siteguard-disable-xmlrpc.php' );
59 require_once( 'classes/siteguard-disable-pingback.php' );
60 require_once( 'classes/siteguard-disable-author-query.php' );
61 require_once( 'classes/siteguard-waf-exclude-rule.php' );
62 require_once( 'classes/siteguard-updates-notify.php' );
63 require_once( 'admin/siteguard-menu-init.php' );
64
65 global $siteguard_htaccess;
66 global $siteguard_config;
67 global $siteguard_admin_filter;
68 global $siteguard_rename_login;
69 global $siteguard_loginlock;
70 global $siteguard_loginalert;
71 global $siteguard_captcha;
72 global $siteguard_login_history;
73 global $siteguard_xmlrpc;
74 global $siteguard_pingback;
75 global $siteguard_author_query;
76 global $siteguard_waf_exclude_rule;
77 global $siteguard_updates_notify;
78
79 $siteguard_htaccess = new SiteGuard_Htaccess( );
80 $siteguard_config = new SiteGuard_Config( );
81 $siteguard_admin_filter = new SiteGuard_AdminFilter( );
82 $siteguard_rename_login = new SiteGuard_RenameLogin( );
83 $siteguard_loginlock = new SiteGuard_LoginLock( );
84 $siteguard_loginalert = new SiteGuard_LoginAlert( );
85 $siteguard_login_history = new SiteGuard_LoginHistory( );
86 $siteguard_captcha = new SiteGuard_CAPTCHA( );
87 $siteguard_xmlrpc = new SiteGuard_Disable_XMLRPC( );
88 $siteguard_pingback = new SiteGuard_Disable_Pingback( );
89 $siteguard_author_query = new SiteGuard_Disable_Author_Query( );
90 $siteguard_waf_exclude_rule = new SiteGuard_WAF_Exclude_Rule( );
91 $siteguard_updates_notify = new SiteGuard_UpdatesNotify( );
92
93 function siteguard_activate( ) {
94 global $siteguard_config, $siteguard_admin_filter, $siteguard_rename_login, $siteguard_login_history, $siteguard_captcha, $siteguard_loginlock, $siteguard_loginalert, $siteguard_xmlrpc, $siteguard_pingback, $siteguard_author_query, $siteguard_waf_exclude_rule, $siteguard_updates_notify;
95
96 load_plugin_textdomain(
97 'siteguard',
98 false,
99 dirname( plugin_basename( __FILE__ ) ) . '/languages'
100 );
101
102 $siteguard_config->set( 'show_admin_notices', '0' );
103 $siteguard_config->update( );
104 $siteguard_admin_filter->init();
105 $siteguard_rename_login->init();
106 $siteguard_login_history->init();
107 $siteguard_captcha->init();
108 $siteguard_loginlock->init();
109 $siteguard_loginalert->init();
110 $siteguard_xmlrpc->init();
111 $siteguard_pingback->init();
112 $siteguard_author_query->init();
113 $siteguard_waf_exclude_rule->init();
114 $siteguard_updates_notify->init();
115 }
116 register_activation_hook( __FILE__, 'siteguard_activate' );
117
118 function siteguard_deactivate( ) {
119 global $siteguard_config;
120 $siteguard_config->set( 'show_admin_notices', '0' );
121 $siteguard_config->update( );
122 SiteGuard_RenameLogin::feature_off( );
123 SiteGuard_AdminFilter::feature_off( );
124 SiteGuard_Disable_XMLRPC::feature_off( );
125 SiteGuard_WAF_Exclude_Rule::feature_off( );
126 SiteGuard_UpdatesNotify::feature_off( );
127 }
128 register_deactivation_hook( __FILE__, 'siteguard_deactivate' );
129
130
131 class SiteGuard extends SiteGuard_Base {
132 protected $menu_init;
133 function __construct( ) {
134 global $siteguard_config;
135 add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
136 $this->htaccess_check( );
137 if ( is_admin( ) ) {
138 include ( 'admin/siteguard-menu-login-history.php' );
139 $this->menu_init = new SiteGuard_Menu_Init( );
140 add_action( 'init', array( $this, 'set_cookie' ) );
141 add_action( 'admin_init', array( $this, 'upgrade' ) );
142 if ( '0' === $siteguard_config->get( 'show_admin_notices' ) && '1' === $siteguard_config->get( 'renamelogin_enable' ) ) {
143 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
144 $siteguard_config->set( 'show_admin_notices', '1' );
145 $siteguard_config->update( );
146 }
147 }
148 }
149 function set_cookie( ) {
150 SiteGuard_Menu_Login_History::set_cookie( );
151 }
152 function plugins_loaded( ) {
153 load_plugin_textdomain(
154 'siteguard',
155 false,
156 dirname( plugin_basename( __FILE__ ) ) . '/languages'
157 );
158 }
159 function htaccess_check( ) {
160 global $siteguard_config;
161
162 $can_use_htaccess = true;
163 if ( false === SiteGuard_Htaccess::test_htaccess( ) ) {
164 $can_use_htaccess = false;
165 }
166 if ( '1' === $siteguard_config->get( 'admin_filter_enable' ) ) {
167 if ( false === $can_use_htaccess || ! SiteGuard_Htaccess::is_exists_setting( SiteGuard_AdminFilter::get_mark( ) ) ) {
168 $siteguard_config->set( 'admin_filter_enable', '0' );
169 $siteguard_config->update( );
170 }
171 }
172 if ( '1' === $siteguard_config->get( 'renamelogin_enable' ) ) {
173 if ( false === $can_use_htaccess || ! SiteGuard_Htaccess::is_exists_setting( SiteGuard_RenameLogin::get_mark( ) ) ) {
174 $siteguard_config->set( 'renamelogin_enable', '0' );
175 $siteguard_config->update( );
176 }
177 }
178 if ( '1' === $siteguard_config->get( 'disable_xmlrpc_enable' ) ) {
179 if ( false === $can_use_htaccess || ! SiteGuard_Htaccess::is_exists_setting( SiteGuard_Disable_XMLRPC::get_mark( ) ) ) {
180 $siteguard_config->set( 'disable_xmlrpc_enable', '0' );
181 $siteguard_config->update( );
182 }
183 }
184 if ( '1' === $siteguard_config->get( 'waf_exclude_rule_enable' ) ) {
185 if ( false === $can_use_htaccess || ! SiteGuard_Htaccess::is_exists_setting( SiteGuard_WAF_Exclude_Rule::get_mark( ) ) ) {
186 $siteguard_config->set( 'waf_exclude_rule_enable', '0' );
187 $siteguard_config->update( );
188 }
189 }
190 if ( '1' === $siteguard_config->get( 'captcha_enable' ) ) {
191 if ( false === $can_use_htaccess) {
192 $siteguard_config->set( 'captcha_enable', '0' );
193 $siteguard_config->update( );
194 }
195 }
196 }
197 function admin_notices( ) {
198 global $siteguard_rename_login;
199 echo '<div class="updated" style="background-color:#719f1d;"><p><span style="border: 4px solid #def1b8;padding: 4px 4px;color:#fff;font-weight:bold;background-color:#038bc3;">';
200 echo esc_html__( 'Login page URL was changed.', 'siteguard' ) . '</span>';
201 echo '<span style="color:#eee;">';
202 echo esc_html__( ' Please bookmark ', 'siteguard' ) . '<a style="color:#fff;text-decoration:underline;" href="' . esc_url( wp_login_url( ) ) . '">';
203 echo esc_html__( 'new login URL', 'siteguard' ) . '</a>';
204 echo esc_html__( '. Setting change is ', 'siteguard' ) . '<a style="color:#fff;text-decoration:underline;" href="' . esc_url( menu_page_url( 'siteguard_rename_login', false ) ) . '">';
205 echo esc_html__( 'here', 'siteguard' ) . '</a>';
206 echo '.</span></p></div>';
207 $siteguard_rename_login->send_notify( );
208 }
209 function upgrade( ) {
210 global $siteguard_config, $siteguard_rename_login, $siteguard_admin_filter, $siteguard_loginalert, $siteguard_updates_notify, $siteguard_login_history, $siteguard_xmlrpc, $siteguard_author_query;
211 $upgrade_ok = true;
212 $old_version = $siteguard_config->get( 'version' );
213 if ( '' === $old_version ) {
214 $old_version = '0.0.0';
215 }
216 if ( $old_version === SITEGUARD_VERSION ) {
217 return;
218 }
219 if ( version_compare( $old_version, '1.0.6' ) < 0 ) {
220 if ( '1' === $siteguard_config->get( 'admin_filter_enable' ) ) {
221 if ( true !== $siteguard_admin_filter->feature_on( $this->get_ip( ) ) ) {
222 siteguard_error_log( 'Failed to update at admin_filter from ' . $old_version . ' to ' . SITEGUARD_VERSION . '.' );
223 $upgrade_ok = false;
224 }
225 }
226 }
227 if ( version_compare( $old_version, '1.1.1' ) < 0 ) {
228 $siteguard_loginalert->init();
229 }
230 if ( version_compare( $old_version, '1.2.0' ) < 0 ) {
231 $siteguard_updates_notify->init();
232 }
233 if ( version_compare( $old_version, '1.2.5' ) < 0 ) {
234 if ( '1' === $siteguard_config->get( 'admin_filter_enable' ) ) {
235 $siteguard_admin_filter->cvt_status_for_1_2_5( $this->get_ip( ) );
236 }
237 if ( '1' === $siteguard_config->get( 'renamelogin_enable' ) ) {
238 if ( true !== $siteguard_rename_login->feature_on( ) ) {
239 siteguard_error_log( 'Failed to update at rename_login from ' . $old_version . ' to ' . SITEGUARD_VERSION . '.' );
240 $upgrade_ok = false;
241 }
242 }
243 }
244 if ( version_compare( $old_version, '1.3.0' ) < 0 ) {
245 $siteguard_login_history->init( );
246 $siteguard_xmlrpc->init( );
247 }
248 if ( version_compare( $old_version, '1.5.0' ) < 0 ) {
249 $admin_filter_exclude_path = $siteguard_config->get( 'admin_filter_exclude_path' );
250 if( false === strpos( $admin_filter_exclude_path, 'site-health.php' ) ){
251 $admin_filter_exclude_path .= ', site-health.php';
252 $siteguard_config->set( 'admin_filter_exclude_path', $admin_filter_exclude_path );
253 $siteguard_config->update( );
254 }
255 }
256 if ( version_compare( $old_version, '1.5.1' ) < 0 ) {
257 if ( '1' === $siteguard_config->get( 'admin_filter_enable' ) ) {
258 if ( true !== $siteguard_admin_filter->feature_on( $this->get_ip( ) ) ) {
259 siteguard_error_log( 'Failed to update at admin_filter from ' . $old_version . ' to ' . SITEGUARD_VERSION . '.' );
260 $upgrade_ok = false;
261 }
262 }
263 if ( '1' === $siteguard_config->get( 'disable_xmlrpc_enable' ) ) {
264 if ( true !== $siteguard_xmlrpc->feature_on( ) ) {
265 siteguard_error_log( 'Failed to update at disable_xmlrpc from ' . $old_version . ' to ' . SITEGUARD_VERSION . '.' );
266 $upgrade_ok = false;
267 }
268 }
269 }
270 if ( version_compare( $old_version, '1.6.0' ) < 0 ) {
271 $siteguard_author_query->init();
272 }
273 if ( $upgrade_ok && SITEGUARD_VERSION !== $old_version ) {
274 $siteguard_config->set( 'version', SITEGUARD_VERSION );
275 $siteguard_config->update( );
276 }
277 }
278 }
279 $siteguard = new SiteGuard;
280