| 1 |
<?php |
| 2 |
|
| 3 |
// Do not allow the file to be called directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* This class is used to register all the options that Patchstack uses and anything |
| 10 |
* related to options. |
| 11 |
*/ |
| 12 |
class P_Admin_Options extends P_Core { |
| 13 |
|
| 14 |
/** |
| 15 |
* Add the actions required for the otions. |
| 16 |
* |
| 17 |
* @param Patchstack $core |
| 18 |
* @return void |
| 19 |
*/ |
| 20 |
public function __construct( $core ) { |
| 21 |
parent::__construct( $core ); |
| 22 |
add_action( 'admin_init', [ $this, 'settings_init' ] ); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* All options and their default values. |
| 27 |
* |
| 28 |
* @var array |
| 29 |
*/ |
| 30 |
public $options = [ |
| 31 |
// Hardening options. |
| 32 |
'patchstack_pluginedit' => 1, |
| 33 |
'patchstack_userenum' => 1, |
| 34 |
'patchstack_basicscanblock' => 1, |
| 35 |
'patchstack_hidewpcontent' => 1, |
| 36 |
'patchstack_hidewpversion' => 1, |
| 37 |
'patchstack_rm_readme' => 1, |
| 38 |
'patchstack_activity_log_is_enabled' => 1, |
| 39 |
'patchstack_activity_log_failed_logins' => 1, |
| 40 |
'patchstack_activity_log_failed_logins_db' => 0, |
| 41 |
'patchstack_activity_log_posts' => 0, |
| 42 |
'patchstack_activity_log_comments' => 0, |
| 43 |
'patchstack_xmlrpc_is_disabled' => 1, |
| 44 |
'patchstack_captcha_type' => 'v2', |
| 45 |
'patchstack_captcha_public_key_v3' => '', |
| 46 |
'patchstack_captcha_private_key_v3' => '', |
| 47 |
'patchstack_captcha_public_key_v3_new' => '', |
| 48 |
'patchstack_captcha_private_key_v3_new' => '', |
| 49 |
'patchstack_captcha_public_key_turnstile' => '', |
| 50 |
'patchstack_captcha_private_key_turnstile' => '', |
| 51 |
'patchstack_captcha_public_key' => '', |
| 52 |
'patchstack_captcha_private_key' => '', |
| 53 |
'patchstack_captcha_login_form' => 0, |
| 54 |
'patchstack_captcha_registration_form' => 0, |
| 55 |
'patchstack_captcha_reset_pwd_form' => 0, |
| 56 |
'patchstack_captcha_on_comments' => 0, |
| 57 |
'patchstack_prevent_default_file_access' => 1, |
| 58 |
'patchstack_register_email_blacklist' => '', |
| 59 |
'patchstack_json_is_disabled' => 0, |
| 60 |
'patchstack_auto_update' => [], |
| 61 |
'patchstack_application_passwords_disabled' => 1, |
| 62 |
|
| 63 |
// The firewall and whitelist rules. |
| 64 |
'patchstack_firewall_rules' => '', |
| 65 |
'patchstack_firewall_rules_v3' => '[]', |
| 66 |
'patchstack_whitelist_rules' => '', |
| 67 |
'patchstack_whitelist_rules_v3' => '[]', |
| 68 |
'patchstack_whitelist_keys_rules' => '', |
| 69 |
|
| 70 |
// Firewall options. |
| 71 |
'patchstack_basic_firewall' => 1, |
| 72 |
'patchstack_basic_firewall_roles' => [ 'administrator', 'editor', 'author', 'contributor' ], |
| 73 |
'patchstack_firewall_ip_header' => '', |
| 74 |
'patchstack_ip_header_computed' => 0, |
| 75 |
'patchstack_disable_htaccess' => 0, |
| 76 |
'patchstack_known_blacklist' => 0, |
| 77 |
'patchstack_block_debug_log_access' => 1, |
| 78 |
'patchstack_block_fake_bots' => 1, |
| 79 |
'patchstack_index_views' => 1, |
| 80 |
'patchstack_proxy_comment_posting' => 1, |
| 81 |
'patchstack_bad_query_strings' => 0, |
| 82 |
'patchstack_advanced_character_string_filter' => 0, |
| 83 |
'patchstack_advanced_blacklist_firewall' => 0, |
| 84 |
'patchstack_forbid_rfi' => 0, |
| 85 |
'patchstack_image_hotlinking' => 0, |
| 86 |
'patchstack_firewall_custom_rules' => '', |
| 87 |
'patchstack_firewall_custom_rules_loc' => 'bottom', |
| 88 |
'patchstack_add_security_headers' => 1, |
| 89 |
'patchstack_blocked_attacks' => 0, |
| 90 |
'patchstack_ip_block_list' => '', |
| 91 |
'patchstack_geo_block_enabled' => 0, |
| 92 |
'patchstack_geo_block_inverse' => 0, |
| 93 |
'patchstack_geo_block_countries' => [], |
| 94 |
|
| 95 |
// Login and firewall brute force options. |
| 96 |
'patchstack_block_bruteforce_ips' => 0, |
| 97 |
'patchstack_anti_bruteforce_attempts' => 10, |
| 98 |
'patchstack_anti_bruteforce_minutes' => 5, |
| 99 |
'patchstack_anti_bruteforce_blocktime' => 60, |
| 100 |
'patchstack_autoblock_attempts' => 10, |
| 101 |
'patchstack_autoblock_minutes' => 30, |
| 102 |
'patchstack_autoblock_blocktime' => 60, |
| 103 |
'patchstack_login_time_block' => 0, |
| 104 |
'patchstack_login_time_start' => '00:00', |
| 105 |
'patchstack_login_time_end' => '23:59', |
| 106 |
'patchstack_login_2fa' => 0, |
| 107 |
'patchstack_login_whitelist' => '', |
| 108 |
|
| 109 |
// General options. |
| 110 |
'patchstack_blackhole_log' => '', |
| 111 |
'patchstack_software_data_hash' => '', |
| 112 |
'patchstack_software_upload_attempted' => false, |
| 113 |
'patchstack_firewall_htaccess_hash' => '', |
| 114 |
'patchstack_license_expiry' => '', |
| 115 |
'patchstack_clientid' => false, |
| 116 |
'patchstack_secretkey' => false, |
| 117 |
'patchstack_secretkey_nonce' => '', |
| 118 |
'patchstack_license_free' => 0, |
| 119 |
'patchstack_api_token' => '', |
| 120 |
'patchstack_subscription_class' => '', |
| 121 |
'patchstack_last_license_check' => 0, |
| 122 |
'patchstack_whitelist' => '', |
| 123 |
'patchstack_show_settings' => 0, |
| 124 |
'patchstack_firewall_log_lastid' => 0, |
| 125 |
'patchstack_eventlog_lastid' => 0, |
| 126 |
'patchstack_ott_action' => '', |
| 127 |
'patchstack_enc_nonce' => '', |
| 128 |
'patchstack_managed' => false, |
| 129 |
'patchstack_managed_text' => '', |
| 130 |
'patchstack_latest_vulnerable' => [], |
| 131 |
'patchstack_site_id' => 0, |
| 132 |
'patchstack_activation_secret' => '', |
| 133 |
'patchstack_activation_time' => '', |
| 134 |
|
| 135 |
// Admin page rename options. |
| 136 |
'patchstack_mv_wp_login' => 0, |
| 137 |
'patchstack_rename_wp_login' => 'swlogin', |
| 138 |
'patchstack_rename_wp_login_whitelist' => [], |
| 139 |
|
| 140 |
// Statistics |
| 141 |
'patchstack_vulns_present' => '?', |
| 142 |
'patchstack_fixes_present' => '?', |
| 143 |
'patchstack_vpatches_present' => '?', |
| 144 |
'patchstack_non_vpatches_present' => '?', |
| 145 |
'patchstack_hits_last_30' => [], |
| 146 |
'patchstack_hits_all_time' => 0, |
| 147 |
]; |
| 148 |
|
| 149 |
/** |
| 150 |
* Register all the options, if not set already. |
| 151 |
* |
| 152 |
* @return void |
| 153 |
*/ |
| 154 |
public function settings_init() { |
| 155 |
// Add the options. |
| 156 |
foreach ( $this->options as $name => $value ) { |
| 157 |
add_option( $name, $value ); |
| 158 |
|
| 159 |
// Clone settings for multisite so we can set defaults. |
| 160 |
if ( is_multisite() ) { |
| 161 |
add_site_option( $name, $value ); |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
|