PluginProbe ʕ •ᴥ•ʔ
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) / 9.5.7
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) v9.5.7
9.5.11 9.5.10.1 9.5.10 trunk 9.4.0 9.4.1 9.4.2 9.4.3 9.5.0 9.5.0.1 9.5.0.2 9.5.1 9.5.2 9.5.2.2 9.5.2.3 9.5.3 9.5.3.1 9.5.3.2 9.5.4 9.5.5 9.5.6 9.5.7 9.5.8 9.5.9
really-simple-ssl / rlrsssl-really-simple-ssl.php
really-simple-ssl Last commit date
assets 3 months ago core 3 months ago languages 3 months ago lets-encrypt 4 months ago lib 6 months ago mailer 7 months ago modal 3 months ago placeholders 9 months ago progress 1 year ago security 3 months ago settings 3 months ago testssl 5 years ago upgrade 7 months ago .wp-env.json 10 months ago SECURITY.md 9 months ago class-admin.php 3 months ago class-cache.php 4 months ago class-certificate.php 2 years ago class-front-end.php 6 months ago class-installer.php 10 months ago class-mixed-content-fixer.php 3 years ago class-multisite.php 4 months ago class-server.php 4 months ago class-site-health.php 1 year ago class-wp-cli.php 5 months ago compatibility.php 1 year ago force-deactivate.txt 1 year ago functions.php 5 months ago index.php 2 years ago readme.txt 3 months ago rector.php 1 year ago rlrsssl-really-simple-ssl.php 3 months ago rsssl-auto-loader.php 1 year ago sbom.json.gz 3 months ago ssl-test-page.php 2 years ago system-status.php 8 months ago uninstall.php 4 months ago upgrade.php 4 months ago
rlrsssl-really-simple-ssl.php
322 lines
1 <?php
2 /**
3 * Plugin Name: Really Simple Security
4 * Plugin URI: https://really-simple-ssl.com
5 * Description: Easily improve site security with WordPress Hardening, Two-Factor Authentication (2FA), Login Protection, Vulnerability Detection and SSL certificate generation.
6 * Version: 9.5.7
7 * Requires at least: 6.6
8 * Requires PHP: 7.4
9 * Author: Really Simple Security
10 * Author URI: https://really-simple-ssl.com/about-us
11 * License: GPL2
12 * Text Domain: really-simple-ssl
13 * Domain Path: /languages
14 * Network: true
15 */
16 /* Copyright 2023 Really Simple Plugins BV (email : support@really-simple-ssl.com)
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License, version 2, as
19 published by the Free Software Foundation.
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 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 defined('ABSPATH') or die("you do not have access to this page!");
30
31 if ( ! defined( 'rsssl_file' ) ) {
32 define( 'rsssl_file', __FILE__ );
33 }
34
35 if (!function_exists('rsssl_activation_check')) {
36 function rsssl_activation_check()
37 {
38 update_option('rsssl_activation', true, false );
39 update_option('rsssl_show_onboarding', true, false );
40 update_option('rsssl_redirect_to_settings_page', true, HOUR_IN_SECONDS );
41 }
42 register_activation_hook( __FILE__, 'rsssl_activation_check' );
43 }
44
45 if ( class_exists('REALLY_SIMPLE_SSL') ) {
46 // Normally we can assume the function exists as class REALLY_SIMPLE_SSL
47 // also exists. But as this function is new we should be extra sure.
48 if (!function_exists('rsssl_deactivate_alternate')) {
49 $rsssl_path = trailingslashit( plugin_dir_path( __FILE__ ) );
50 require_once $rsssl_path . 'functions.php';
51 }
52
53 rsssl_deactivate_alternate('pro');
54 } else {
55 class REALLY_SIMPLE_SSL {
56
57 private static $instance;
58 public $front_end;
59 public $mixed_content_fixer;
60 public $multisite;
61 public $cache;
62 public $server;
63 public $admin;
64 public $progress;
65 public $onboarding;
66 public $placeholder;
67 public $certificate;
68 public $wp_cli;
69 public $mailer_admin;
70 public $site_health;
71 public $vulnerabilities;
72 public $settingsConfigService;
73
74 private function __construct()
75 {
76 if (isset($_GET['rsssl_apitoken']) && $_GET['rsssl_apitoken'] == get_option('rsssl_csp_report_token') ) {
77 if ( !defined('RSSSL_LEARNING_MODE') ) define( 'RSSSL_LEARNING_MODE' , true );
78 }
79 }
80
81 public static function instance()
82 {
83 if (!isset(self::$instance) && !(self::$instance instanceof REALLY_SIMPLE_SSL)) {
84 self::$instance = new REALLY_SIMPLE_SSL;
85 self::$instance->setup_constants();
86 self::$instance->includes();
87 self::$instance->front_end = new rsssl_front_end();
88 self::$instance->mixed_content_fixer = new rsssl_mixed_content_fixer();
89
90 if ( is_multisite() ) {
91 self::$instance->multisite = new rsssl_multisite();
92 }
93 if ( rsssl_admin_logged_in() ) {
94 self::$instance->cache = new rsssl_cache();
95 self::$instance->placeholder = new rsssl_placeholder();
96 self::$instance->server = new rsssl_server();
97 self::$instance->admin = new rsssl_admin();
98 self::$instance->mailer_admin = new rsssl_mailer_admin();
99 self::$instance->progress = new rsssl_progress();
100 self::$instance->certificate = new rsssl_certificate();
101 self::$instance->site_health = new rsssl_site_health();
102
103 if (class_exists('\ReallySimplePlugins\RSS\Core\Services\SettingsConfigService')) {
104 self::$instance->settingsConfigService = new \ReallySimplePlugins\RSS\Core\Services\SettingsConfigService();
105 }
106
107 if ( defined( 'WP_CLI' ) && WP_CLI ) {
108 self::$instance->wp_cli = new rsssl_wp_cli();
109 }
110 }
111 self::$instance->hooks();
112 }
113 return self::$instance;
114 }
115
116 private function setup_constants()
117 {
118 define('rsssl_url', plugin_dir_url(__FILE__));
119 define('rsssl_path', trailingslashit(plugin_dir_path(__FILE__)));
120 define('rsssl_template_path', trailingslashit(plugin_dir_path(__FILE__)).'grid/templates/');
121 define('rsssl_plugin', plugin_basename(__FILE__));
122 define('rsssl_version', '9.5.7');
123 define('rsssl_le_cron_generation_renewal_check', 20);
124 define('rsssl_le_manual_generation_renewal_check', 15);
125 }
126 private function includes()
127 {
128 require_once(rsssl_path . 'class-front-end.php');
129 require_once(rsssl_path . 'functions.php');
130 require_once(rsssl_path . 'class-mixed-content-fixer.php');
131 if ( defined( 'WP_CLI' ) && WP_CLI ) {
132 require_once( rsssl_path . 'class-wp-cli.php');
133 }
134 if ( is_multisite() ) {
135 require_once( rsssl_path . 'class-multisite.php');
136 }
137 if ( rsssl_admin_logged_in() ) {
138 require_once( rsssl_path . 'compatibility.php');
139 require_once( rsssl_path . 'upgrade.php');
140 require_once( rsssl_path . 'settings/settings.php' );
141 require_once( rsssl_path . 'modal/modal.php' );
142 require_once( rsssl_path . 'placeholders/class-placeholder.php' );
143 require_once( rsssl_path . 'class-admin.php');
144 require_once( rsssl_path . 'mailer/class-mail-admin.php');
145 require_once( rsssl_path . 'class-cache.php');
146 require_once( rsssl_path . 'class-server.php');
147 require_once( rsssl_path . 'progress/class-progress.php');
148 require_once( rsssl_path . 'class-certificate.php');
149 require_once( rsssl_path . 'class-site-health.php');
150 require_once( rsssl_path . 'mailer/class-mail.php');
151 require_once( rsssl_path . 'lets-encrypt/letsencrypt.php' );
152 if ( isset($_GET['install_pro'])) {
153 require_once( rsssl_path . 'upgrade/upgrade-to-pro.php');
154 }
155 }
156
157 require_once( rsssl_path . 'lets-encrypt/cron.php' );
158 require_once( rsssl_path . '/security/security.php');
159 require_once( rsssl_path . '/rsssl-auto-loader.php' );
160 }
161
162 private function hooks()
163 {
164 /**
165 * Fire custom hook
166 */
167 if ( rsssl_admin_logged_in() ) {
168 add_action('admin_notices', array( $this, 'admin_notices'));
169 if ( is_multisite() ) {
170 add_action('network_admin_notices', array( $this, 'admin_notices'));
171 }
172 }
173
174 add_action('wp_loaded', array(self::$instance->front_end, 'force_ssl'), 20);
175 if ( rsssl_admin_logged_in() ) {
176 add_action('plugins_loaded', array(self::$instance->admin, 'init'), 10);
177 }
178 }
179
180 /**
181 * Notice about possible compatibility issues with add ons
182 */
183 public static function admin_notices() {
184 //prevent showing on edit screen, as gutenberg removes the class which makes it editable.
185 $screen = get_current_screen();
186 if ( $screen && $screen->base === 'post' ) return;
187 if ( self::has_old_addon('really-simple-ssl-pro/really-simple-ssl-pro.php') ||
188 self::has_old_addon('really-simple-ssl-pro-multisite/really-simple-ssl-pro-multisite.php' )
189 ) {
190 ?>
191 <div id="message" class="error notice really-simple-plugins">
192 <p><?php echo __("Update Really Simple SSL Pro: the plugin needs to be updated to the latest version to be compatible.","really-simple-ssl");?></p>
193 <p>
194 <?php printf(__("Visit the plugins overview or %srenew your license%s.","really-simple-ssl"),'<a href="https://really-simple-ssl.com/pro/?mtm_campaign=renew&mtm_source=free&mtm_content=upgrade" target="_blank" rel="noopener noreferrer">','</a>'); ?>
195 </p>
196 </div>
197 <?php
198 }
199 }
200
201 /**
202 * Check if we have a pre 4.0 add on active which should be upgraded
203 * @param $file
204 *
205 * @return bool
206 */
207
208 public static function has_old_addon($file) {
209 require_once(ABSPATH.'wp-admin/includes/plugin.php');
210 $data = false;
211 if ( is_plugin_active($file)) $data = get_plugin_data( trailingslashit(WP_PLUGIN_DIR) . $file, false, false );
212 if ($data && version_compare($data['Version'], '7.0.6', '<')) {
213 return true;
214 }
215
216 if ($data && $data['Name']==='Really Simple SSL social' && version_compare($data['Version'], '4.0.8', '<')) {
217 return true;
218 }
219 return false;
220 }
221 }
222 }
223
224 if ( !defined('RSSSL_DEACTIVATING_ALTERNATE')
225 && !function_exists('RSSSL')
226 ) {
227 function RSSSL() {
228 return REALLY_SIMPLE_SSL::instance();
229 }
230 add_action('plugins_loaded', 'RSSSL', 8);
231
232 if (file_exists(__DIR__ . '/core/really-simple-security-core.php')) {
233 require_once __DIR__ . '/core/really-simple-security-core.php';
234 }
235 }
236
237 if ( ! function_exists('rsssl_add_manage_security_capability')){
238 /**
239 * Add a user capability to WordPress and add to admin and editor role
240 */
241 function rsssl_add_manage_security_capability(){
242 $role = get_role( 'administrator' );
243 if( $role && !$role->has_cap( 'manage_security' ) ){
244 $role->add_cap( 'manage_security' );
245 }
246 }
247
248 register_activation_hook( __FILE__, 'rsssl_add_manage_security_capability' );
249 }
250
251 if ( ! function_exists( 'rsssl_user_can_manage' ) ) {
252 /**
253 * Check if user has required capability
254 * @return bool
255 */
256 function rsssl_user_can_manage() {
257 if ( current_user_can('manage_security') ) {
258 return true;
259 }
260
261 #allow wp-cli access to activate ssl
262 if ( defined( 'WP_CLI' ) && WP_CLI ){
263 return true;
264 }
265 return false;
266 }
267 }
268
269 if ( !function_exists('rsssl_admin_logged_in')){
270 function rsssl_admin_logged_in(){
271 $wpcli = defined( 'WP_CLI' ) && WP_CLI;
272 return (is_admin() && rsssl_user_can_manage()) || rsssl_is_logged_in_rest() || wp_doing_cron() || $wpcli || defined('RSSSL_DOING_SYSTEM_STATUS') || defined('RSSSL_LEARNING_MODE');
273 }
274 }
275
276
277
278 if ( ! function_exists( 'rsssl_is_logged_in_rest' ) ) {
279 function rsssl_is_logged_in_rest() {
280 // Check if the request URI is valid
281 if (!isset($_SERVER['REQUEST_URI'])) {
282 return false;
283 }
284
285 $request_uri = $_SERVER['REQUEST_URI'];
286
287 // Check for a direct REST API path
288 if (strpos($request_uri, '/really-simple-security/v1/') !== false) {
289 return is_user_logged_in();
290 }
291
292 // Check for rest_route parameter with really-simple-security (plain permalinks)
293 if (strpos($request_uri, 'rest_route=') !== false &&
294 strpos($request_uri, 'really-simple-security') !== false) {
295 return is_user_logged_in();
296 }
297
298 return false;
299 }
300 }
301
302 if ( ! function_exists( 'rsssl_maybe_activate_recommended_features_extendify' ) ) {
303 function rsssl_maybe_activate_recommended_features_extendify() {
304 if ( get_option( 'rsssl_activated_recommended_features_extendify' ) || ! defined( 'EXTENDIFY_PARTNER_ID' ) || defined( 'rsssl_pro' ) ) {
305 return;
306 }
307
308 try {
309 RSSSL()->admin->activate_recommended_features();
310 } catch ( Exception $e ) {
311 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
312 error_log( 'Really Simple Security: recommended features activation failed: ' . $e->getMessage() );
313 return;
314 }
315 }
316
317 update_option( 'rsssl_activated_recommended_features_extendify', true );
318 }
319
320 add_action( 'admin_init', 'rsssl_maybe_activate_recommended_features_extendify', 99 );
321 }
322