| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
|
| 5 |
class gdsih_core_scope extends d4p_core_scope { |
| 6 |
public static function instance() { |
| 7 |
static $instance = null; |
| 8 |
|
| 9 |
if (null === $instance) { |
| 10 |
$instance = new gdsih_core_scope(); |
| 11 |
} |
| 12 |
|
| 13 |
return $instance; |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
class gdsih_core_settings extends d4p_plugin_settings_corex { |
| 18 |
public $base = 'gdsih'; |
| 19 |
public $scope = 'network'; |
| 20 |
|
| 21 |
public $features = array(); |
| 22 |
|
| 23 |
public $settings = array( |
| 24 |
'core' => array( |
| 25 |
'activated' => 0, |
| 26 |
'htaccess_added' => false, |
| 27 |
'htaccess_available' => false |
| 28 |
), |
| 29 |
'settings' => array( |
| 30 |
'htaccess' => false, |
| 31 |
), |
| 32 |
'feature' => array( |
| 33 |
'variant' => 'feature-policy', |
| 34 |
'protection' => false |
| 35 |
), |
| 36 |
'csp' => array( |
| 37 |
'mode' => 'report', |
| 38 |
'log' => true, |
| 39 |
'log_original_policy' => false, |
| 40 |
'log_force_ssl' => false, |
| 41 |
|
| 42 |
'extra_google_adsense' => false, |
| 43 |
'extra_google_analytics' => false, |
| 44 |
'extra_google_fonts' => false, |
| 45 |
'extra_google_maps' => false, |
| 46 |
'extra_google_translate' => false, |
| 47 |
'extra_google_youtube' => false, |
| 48 |
'extra_google_tag_manager' => false, |
| 49 |
'extra_gravatar' => true, |
| 50 |
'extra_gleam' => false, |
| 51 |
'extra_vimeo' => false, |
| 52 |
'extra_wordpress' => false, |
| 53 |
|
| 54 |
'cdn' => array(), |
| 55 |
|
| 56 |
'auto_inline_rule' => true, |
| 57 |
'auto_eval_rule' => true, |
| 58 |
'auto_data_rule' => true, |
| 59 |
'auto_blob_rule' => true, |
| 60 |
'auto_mediastream_rule' => true, |
| 61 |
'auto_filesystem_rule' => true, |
| 62 |
|
| 63 |
'upgrade_insecure_requests' => false, |
| 64 |
'block_all_mixed_content' => false, |
| 65 |
'disown_opener' => false, |
| 66 |
|
| 67 |
'default_basic' => 'self', |
| 68 |
'default_custom' => array(), |
| 69 |
'script_basic' => 'no', |
| 70 |
'script_custom' => array(), |
| 71 |
'style_basic' => 'no', |
| 72 |
'style_custom' => array(), |
| 73 |
'img_basic' => 'no', |
| 74 |
'img_custom' => array(), |
| 75 |
'connect_basic' => 'no', |
| 76 |
'connect_custom' => array(), |
| 77 |
'font_basic' => 'no', |
| 78 |
'font_custom' => array(), |
| 79 |
'object_basic' => 'no', |
| 80 |
'object_custom' => array(), |
| 81 |
'media_basic' => 'no', |
| 82 |
'media_custom' => array(), |
| 83 |
'child_basic' => 'no', |
| 84 |
'child_custom' => array(), |
| 85 |
'manifest_basic' => 'no', |
| 86 |
'manifest_custom' => array(), |
| 87 |
'form-action_basic' => 'no', |
| 88 |
'form-action_custom' => array(), |
| 89 |
'frame-ancestors_basic' => 'no', |
| 90 |
'frame-ancestors_custom' => array(), |
| 91 |
'prefetch_basic' => 'no', |
| 92 |
'prefetch_custom' => array(), |
| 93 |
'worker_basic' => 'no', |
| 94 |
'worker_custom' => array(), |
| 95 |
'frame_basic' => 'no', |
| 96 |
'frame_custom' => array() |
| 97 |
), |
| 98 |
'xxp' => array( |
| 99 |
'x_xss_protection' => true, |
| 100 |
'log' => true, |
| 101 |
'log_force_ssl' => false |
| 102 |
), |
| 103 |
'headers' => array( |
| 104 |
'x_content_type_nosniff' => true, |
| 105 |
'x_frame_options_sameorigin' => false, |
| 106 |
'strict_transport_security' => false, |
| 107 |
'referrer_policy' => false, |
| 108 |
|
| 109 |
'referrer_policy_value' => 'no-referrer-when-downgrade', |
| 110 |
'strict_transport_security_max_age' => 31536000, |
| 111 |
'strict_transport_security_extra' => 'includeSubDomains', |
| 112 |
'x_frame_options_sameorigin_value' => 'SAMEORIGIN', |
| 113 |
'x_frame_options_sameorigin_domains' => '' |
| 114 |
) |
| 115 |
); |
| 116 |
|
| 117 |
protected function constructor() { |
| 118 |
$this->info = new gdsih_core_info(); |
| 119 |
|
| 120 |
$this->features = array( |
| 121 |
'accelerometer' => _x("Accelerometer", "Feature/Permissions Policy", "gd-security-headers"), |
| 122 |
'ambient-light-sensor' => _x("Ambient Light Sensor", "Feature/Permissions Policy", "gd-security-headers"), |
| 123 |
'autoplay' => _x("Autoplay", "Feature/Permissions Policy", "gd-security-headers"), |
| 124 |
'camera' => _x("Camera", "Feature/Permissions Policy", "gd-security-headers"), |
| 125 |
'document-domain' => _x("Document Domain", "Feature/Permissions Policy", "gd-security-headers"), |
| 126 |
'encrypted-media' => _x("Encrypted Media", "Feature/Permissions Policy", "gd-security-headers"), |
| 127 |
'fullscreen' => _x("Full Screen", "Feature/Permissions Policy", "gd-security-headers"), |
| 128 |
'geolocation' => _x("GEO Location", "Feature/Permissions Policy", "gd-security-headers"), |
| 129 |
'gyroscope' => _x("Gyroscope", "Feature/Permissions Policy", "gd-security-headers"), |
| 130 |
'legacy-image-formats' => _x("Legacy Image Formats", "Feature/Permissions Policy", "gd-security-headers"), |
| 131 |
'magnetometer' => _x("Magentometer", "Feature/Permissions Policy", "gd-security-headers"), |
| 132 |
'microphone' => _x("Microphone", "Feature/Permissions Policy", "gd-security-headers"), |
| 133 |
'midi' => _x("MIDI", "Feature/Permissions Policy", "gd-security-headers"), |
| 134 |
'notifications' => _x("Notifications", "Feature/Permissions Policy", "gd-security-headers"), |
| 135 |
'oversized-images' => _x("Oversized Images", "Feature/Permissions Policy", "gd-security-headers"), |
| 136 |
'payment' => _x("Payment", "Feature/Permissions Policy", "gd-security-headers"), |
| 137 |
'publickey-credentials-get' => _x("Publickey Credentials Get", "Feature/Permissions Policy", "gd-security-headers"), |
| 138 |
'speaker' => _x("Speaker", "Feature/Permissions Policy", "gd-security-headers"), |
| 139 |
'sync-xhr' => _x("Sync XHR", "Feature/Permissions Policy", "gd-security-headers"), |
| 140 |
'unoptimized-images' => _x("Unoptimized Images", "Feature/Permissions Policy", "gd-security-headers"), |
| 141 |
'unsized-media' => _x("Unsized Media", "Feature/Permissions Policy", "gd-security-headers"), |
| 142 |
'usb' => _x("USB", "Feature/Permissions Policy", "gd-security-headers"), |
| 143 |
'battery' => _x("Battery", "Feature/Permissions Policy", "gd-security-headers").' ('.__("Not widely supported!", "gd-security-headers").')', |
| 144 |
'display-capture' => _x("Display Capture", "Feature/Permissions Policy", "gd-security-headers").' ('.__("Not widely supported!", "gd-security-headers").')', |
| 145 |
'layout-animations' => _x("Layout Animations", "Feature/Permissions Policy", "gd-security-headers").' ('.__("Not widely supported!", "gd-security-headers").')', |
| 146 |
'picture-in-picture' => _x("Picture In Picture", "Feature/Permissions Policy", "gd-security-headers").' ('.__("Not widely supported!", "gd-security-headers").')', |
| 147 |
'vibrate' => _x("Vibrate", "Feature/Permissions Policy", "gd-security-headers").' ('.__("Not widely supported!", "gd-security-headers").')', |
| 148 |
'vr' => _x("VR", "Feature/Permissions Policy", "gd-security-headers").' ('.__("Not widely supported!", "gd-security-headers").')' |
| 149 |
); |
| 150 |
|
| 151 |
foreach (array_keys($this->features) as $feature) { |
| 152 |
$this->settings['feature'][$feature.'_basic'] = 'no'; |
| 153 |
$this->settings['feature'][$feature.'_custom'] = array(); |
| 154 |
} |
| 155 |
|
| 156 |
add_action('gdsih_load_settings', array($this, 'init')); |
| 157 |
} |
| 158 |
|
| 159 |
protected function _db() { |
| 160 |
require_once(GDSIH_PATH.'core/admin/install.php'); |
| 161 |
|
| 162 |
gdsih_install_database(); |
| 163 |
} |
| 164 |
|
| 165 |
protected function _name($name) { |
| 166 |
return 'dev4press_'.$this->info->code.'_'.$name; |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
/** @return gdsih_core_scope */ |
| 171 |
function gdsih_scope() { |
| 172 |
return gdsih_core_scope::instance(); |
| 173 |
} |
| 174 |
|