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