| @@ -5,226 +5,125 @@ | ||
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | // Determine if the subscription of the account is expired. |
| 9 | -$status = ( $this->plugin->client_id != 'PATCHSTACK_CLIENT_ID' || get_option( 'patchstack_clientid', false ) != false ) && !empty( $this->get_secret_key() ); | |
| 10 | -$free = get_option( 'patchstack_license_free', 0 ) == 1; | |
| 11 | -$planClass = get_option( 'patchstack_subscription_class', ''); | |
| 12 | -$site_id = (int) get_option( 'patchstack_site_id', 0 ); | |
| 13 | -$app_url = $site_id != 0 ? 'https://app.patchstack.com/site/' . $site_id . '/' : 'https://app.patchstack.com/sites/overview'; | |
| 9 | +$status = $this->plugin->client_id != 'PATCHSTACK_CLIENT_ID' || get_option( 'patchstack_clientid', false ) != false; | |
| 10 | +$free = get_option( 'patchstack_license_free', 0 ) == 1; | |
| 11 | +if ( isset( $_GET['activated'] ) && $status ) { | |
| 12 | + echo "<script>window.location = 'admin.php?page=patchstack&tab=license&active=1';</script>"; | |
| 13 | +} | |
| 14 | 14 | |
| 15 | 15 | // Generate the link to turn on settings management. |
| 16 | -$secretToken = get_option( 'patchstack_activation_secret', '' ); | |
| 17 | -$secretTime = get_option( 'patchstack_activation_time', '' ); | |
| 18 | -if (!empty($secretToken) && !$this->is_connected() ){ | |
| 19 | - echo '<script>jQuery(function(){ window.Patchstack.poller(); });</script>'; | |
| 20 | -} | |
| 16 | +$url = '?page=' . esc_attr( $page ) . '&tab=license&action=enable_settings&patchstack_settings_nonce=' . wp_create_nonce( 'patchstack_settings_nonce' ); | |
| 21 | 17 | ?> |
| 22 | -<div class="patchstack-free patchstack-auto-activate" style="<?php echo $status ? 'display: none;' : ''; ?>"> | |
| 18 | +<div class="patchstack-free" style="<?php echo $show_settings ? 'display: none;' : ''; ?>"> | |
| 23 | 19 | <div> |
| 24 | - <div class="is-polling-section has-text-centered"> | |
| 25 | - <img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/polling.svg" class="rotate"> | |
| 20 | + <div class="patchstack-plan patchstack-plan2"> | |
| 21 | + <p>Visit the Patchstack app to monitor and manage your sites</p> | |
| 26 | 22 | |
| 27 | - <p class="is-text-medium"> | |
| 28 | - <?php esc_html_e( 'Checking sync status', 'patchstack' ); ?> | |
| 29 | - </p> | |
| 23 | + <div class="form-table patchstack-form-table"> | |
| 24 | + <label for="patchstack_api_client_id">Site ID</label> | |
| 25 | + <input class="regular-text" type="text" id="patchstack_api_client_id" value="<?php echo esc_attr( get_option( 'patchstack_clientid', false ) ); ?>" placeholder="Enter Site ID"> | |
| 30 | 26 | |
| 31 | - <?php | |
| 32 | - $mins = ! empty( $secretTime ) ? floor( ( ( 1800 ) - ( time() - $secretTime ) ) / 60 ) : 0; | |
| 33 | - if ( $mins >= 1 ) { | |
| 34 | - echo '<p class="patchstack-upsell patchstack-has-text-white patchstack-top-16">' . sprintf('%s %d %s', esc_html__('This plugin is only a connector. Add this website to the Patchstack dashboard within '), $mins, esc_html__(' minutes to initiate automatic sync.')) . '</p>'; | |
| 35 | - } else { | |
| 36 | - if ( ( $this->plugin->client_id != 'PATCHSTACK_CLIENT_ID' || get_option( 'patchstack_clientid', false ) != false ) && empty( $this->get_secret_key() ) ) { | |
| 37 | - echo '<p class="patchstack-upsell patchstack-has-text-danger patchstack-top-16">' . esc_html__('The connection with Patchstack was lost, this can happen when your WordPress salts change or after a migration. Please re-enter your API key.', 'patchstack') . '</p>'; | |
| 38 | - } else { | |
| 39 | - echo '<p class="patchstack-upsell patchstack-has-text-white patchstack-top-16">' . esc_html__('This plugin is only a connector. Add this website to the Patchstack dashboard to sync your unique API key.', 'patchstack') . '</p>'; | |
| 40 | - } | |
| 41 | - } | |
| 42 | - ?> | |
| 43 | - </div> | |
| 27 | + <label for="patchstack_api_client_secret_key">Site Secret Key</label> | |
| 28 | + <input class="regular-text" type="text" id="patchstack_api_client_secret_key" value="<?php echo esc_attr( get_option( 'patchstack_secretkey', false ) ); ?>" placeholder="Enter Site Secret Key"> | |
| 29 | + </div> | |
| 44 | 30 | |
| 45 | - <div class="patchstack-plan patchstack-plan2"> | |
| 46 | - <div class="form-table patchstack-form-table"> | |
| 47 | - <div class="patchstack-activate-wrapper"> | |
| 48 | - <label for="patchstack_api_key"><?php esc_html_e( 'Paste API key for manual sync', 'patchstack' ); ?></label> | |
| 49 | - <input class="regular-text" type="text" id="patchstack_api_key2" placeholder="<?php esc_attr_e( 'Unique API key', 'patchstack' ); ?>"> | |
| 50 | - <input type="submit" id="patchstack-activate" value="<?php echo esc_attr__( 'Sync', 'patchstack' ); ?>" class="button-primary" /> | |
| 51 | - </div> | |
| 31 | + <div class="patchstack-sub"> | |
| 32 | + <span>Subscription Type</span> | |
| 33 | + <span style="color: #fff;" class="patchstack-sub-type"> | |
| 34 | + Professional | |
| 35 | + </span> | |
| 52 | 36 | </div> |
| 53 | 37 | |
| 54 | - <div style="clear: both;"></div> | |
| 38 | + <div class="patchstack-sub" style="width: 30%;"> | |
| 39 | + <span>Status</span> | |
| 40 | + <span style="color: <?php echo $status ? '#B2D675' : '#ED645E'; ?>" class="patchstack-license-status"> | |
| 41 | + <?php echo $status ? 'Active' : 'Inactive'; ?> | |
| 42 | + </span> | |
| 43 | + </div> | |
| 55 | 44 | |
| 56 | - <div class="patchstack-loading"><div></div><div></div><div></div><div></div></div> | |
| 45 | + <input type="submit" id="patchstack-activate" value="<?php echo __( 'Activate', 'patchstack' ); ?>" class="button-primary" style="<?php echo $status ? 'display: none;' : ''; ?>" /> | |
| 46 | + <a href="https://app.patchstack.com/dashboard" class="patchstack-activate button-primary" style="<?php echo ! $status ? 'display: none;' : ''; ?>" target="_blank"><?php echo __( 'Go to App', 'patchstack' ); ?></a> | |
| 57 | 47 | </div> |
| 58 | 48 | <div style="clear: both;"></div> |
| 59 | 49 | </div> |
| 50 | + | |
| 51 | + <p class="patchstack-upsell"> | |
| 52 | + Click <a href="<?php echo esc_url( $url ); ?>">here</a> to manage the Patchstack settings through WordPress. | |
| 53 | + </p> | |
| 60 | 54 | </div> |
| 61 | 55 | |
| 62 | -<p class="patchstack-upsell" style="<?php echo $status ? 'display: none;' : ''; ?>"> | |
| 63 | - <a href="https://app.patchstack.com/login?free=1" target="_blank"><?php esc_html_e( 'Log in to dashboard', 'patchstack' ); ?></a> | |
| 64 | -</p> | |
| 65 | - | |
| 66 | -<div class="patchstack-free" style="<?php echo !$status ? 'display: none;' : ''; ?>"> | |
| 67 | - <div> | |
| 68 | - <p class="patchstack-upsell patchstack-has-text-white" style="<?php echo $managed ? 'display: none;' : ''; ?>"> | |
| 69 | - <?php if ($free) { ?> | |
| 70 | - <?php echo esc_attr__('Log in to our dashboard to access vulnerability data, to manage protection modules and remote settings.', 'patchstack' ); ?> | |
| 71 | - <?php } else { ?> | |
| 72 | - <?php echo sprintf('%s %s %s', esc_attr__('Log in to our dashboard to access vulnerability data, to manage protection modules and remote ', 'patchstack' ), '<a href="' . $app_url . 'hardening/firewall" target="_blank">hardening</a>', esc_attr('settings for this website.', 'patchstack' )); ?> | |
| 73 | - <?php } ?> | |
| 56 | +<div style="<?php echo ! $show_settings ? 'display: none;' : ''; ?>"> | |
| 57 | + <div class="patchstack-font" | |
| 58 | + <?php | |
| 59 | + if ( $show_settings ) { | |
| 60 | + echo ' style="display: none;"'; } | |
| 61 | + ?> | |
| 62 | + > | |
| 63 | + <br /> | |
| 64 | + <h2>Thank you for using Patchstack<?php echo ( $free ? '' : ' Professional' ); ?></h2> | |
| 65 | + <br /> | |
| 66 | + <p> | |
| 67 | + The default settings of Patchstack are tweaked to provide a good baseline of security.<br /> | |
| 68 | + If however you still want to tweak the settings of Patchstack, you can do so through the "Hardening" tab at <a href="https://app.patchstack.com/sites" target="_blank">app.patchstack.com</a> after logging in and clicking on your site.<br /><br /> | |
| 69 | + Alternatively, you can turn on the setting management feature on WordPress itself by clicking <a href="">here</a>. | |
| 74 | 70 | </p> |
| 71 | + <br /> | |
| 72 | + </div> | |
| 75 | 73 | |
| 76 | - <div class="patchstack-plan patchstack-plan2"> | |
| 77 | - <?php | |
| 78 | - if (!isset($_GET['key'])) { | |
| 79 | - ?> | |
| 80 | - <div class="patchstack-rows"> | |
| 81 | - <div class="patchstack-connection-row"> | |
| 82 | - <span class="hint--top" aria-label="<?php !$this->is_connected() ? esc_html_e( 'There is not a proper connection to Patchstack', 'patchstack' ) : esc_html_e( 'Actively monitoring for new vulnerabilities', 'patchstack' ); ?>"> | |
| 83 | - <?php esc_html_e( 'Connection status', 'patchstack' ); ?> | |
| 84 | - <span><img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/info.svg" alt=""></span> | |
| 85 | - <a href="#" class="patchstack-retry-link"><?php esc_html_e( 'Retry', 'patchstack' ); ?></a> | |
| 86 | - </span> | |
| 87 | - | |
| 88 | - <span class="patchstack-connection-status <?php echo $this->is_connected() ? 'is-connected' : 'is-disconnected'; ?>"> | |
| 89 | - <span class="patchstack-last-sync"><?php echo esc_html( $this->format_relative_time( $this->get_last_sync_time() ) ); ?></span> | |
| 90 | - <span class="patchstack-status-dot" aria-hidden="true"></span> | |
| 91 | - </span> | |
| 92 | - </div> | |
| 93 | - | |
| 94 | - <div> | |
| 95 | - <span> | |
| 96 | - <?php esc_html_e( 'Protection', 'patchstack' ); ?> | |
| 97 | - </span> | |
| 98 | - | |
| 99 | - <span class="<?php echo !$this->is_protected() && empty($planClass) ? 'ps-label has-error' : 'ps-label has-success'; ?>"> | |
| 100 | - <?php !$this->is_protected() && empty($planClass) ? esc_html_e( 'Disabled', 'patchstack' ) : esc_html_e( 'Enabled', 'patchstack' ); ?> | |
| 101 | - </span> | |
| 102 | - </div> | |
| 103 | - | |
| 104 | - <div> | |
| 105 | - <span> | |
| 106 | - <?php esc_html_e( 'Vulnerabilities present', 'patchstack' ); ?> | |
| 107 | - </span> | |
| 108 | - | |
| 109 | - <span> | |
| 110 | - <?php echo esc_html(get_option('patchstack_vulns_present', '?')); ?> | |
| 111 | - </span> | |
| 112 | - </div> | |
| 113 | - | |
| 114 | - <div> | |
| 115 | - <span class="hint--top" aria-label="<?php esc_attr_e( 'The number of vulnerabilities which have a fix available through an update.', 'patchstack' ); ?>"> | |
| 116 | - <?php esc_html_e( 'Fixes available', 'patchstack' ); ?> | |
| 117 | - <span><img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/info.svg" alt=""></span> | |
| 118 | - </span> | |
| 119 | - | |
| 120 | - <span> | |
| 121 | - <?php echo esc_attr(get_option('patchstack_fixes_present', '?')); ?> | |
| 122 | - </span> | |
| 123 | - </div> | |
| 124 | - | |
| 125 | - <?php if ($this->is_protected() || !empty($planClass)) { ?> | |
| 126 | - <div> | |
| 127 | - <span class="hint--top" aria-label="<?php esc_attr_e( 'The number of vulnerability specific vPatches. This is 0 when no severe vulnerabilities are present.', 'patchstack' ); ?>"> | |
| 128 | - <?php esc_html_e( 'vPatches present', 'patchstack' ); ?> | |
| 129 | - <span><img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/info.svg" alt=""></span> | |
| 130 | - </span> | |
| 131 | - | |
| 132 | - <span> | |
| 133 | - <?php echo esc_html(get_option('patchstack_vpatches_present', '?')); ?> | |
| 134 | - </span> | |
| 135 | - </div> | |
| 136 | - | |
| 137 | - <div> | |
| 138 | - <span class="hint--top" aria-label="<?php esc_attr_e( 'The number of firewall rules. These are not vulnerability specific.', 'patchstack' ); ?>"> | |
| 139 | - <?php esc_html_e( 'Firewall rules present', 'patchstack' ); ?> | |
| 140 | - <span><img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/info.svg" alt=""></span> | |
| 141 | - </span> | |
| 142 | - | |
| 143 | - <span> | |
| 144 | - <?php echo esc_html(get_option('patchstack_non_vpatches_present', '?')); ?> | |
| 145 | - </span> | |
| 146 | - </div> | |
| 147 | - | |
| 148 | - <div> | |
| 149 | - <span> | |
| 150 | - <?php esc_html_e( 'Attacks blocked last 30 days', 'patchstack' ); ?> | |
| 151 | - </span> | |
| 152 | - | |
| 153 | - <span> | |
| 154 | - <?php echo $this->plugin->firewall_base->get_hits_counter(); ?> | |
| 155 | - </span> | |
| 156 | - </div> | |
| 157 | - | |
| 158 | - <div> | |
| 159 | - <span class="hint--top" aria-label="Since July 9th, 2024."> | |
| 160 | - <?php esc_html_e( 'Attacks blocked in total', 'patchstack' ); ?> | |
| 161 | - <span><img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/info.svg" alt=""></span> | |
| 162 | - </span> | |
| 163 | - | |
| 164 | - <span> | |
| 165 | - <?php echo esc_html(get_option('patchstack_hits_all_time', 0)); ?> | |
| 166 | - </span> | |
| 167 | - </div> | |
| 168 | - <?php } ?> | |
| 169 | - </div> | |
| 170 | - | |
| 171 | - <div class="patchstack-license-button patchstack-login-button" <?php echo $managed ? 'style="display: none;"' : ''; ?>> | |
| 172 | - <a href="<?php echo $app_url; ?>" class="patchstack-button button-primary patchstack-fullwidth" target="_blank"> | |
| 173 | - <?php esc_attr_e( 'Log in to view details', 'patchstack' ); ?> | |
| 174 | - </a> | |
| 175 | - </div> | |
| 176 | - | |
| 177 | - <?php | |
| 178 | - } else { | |
| 179 | - ?> | |
| 180 | - <div class="form-table patchstack-form-table"> | |
| 181 | - <label for="patchstack_api_key"> | |
| 182 | - <?php esc_html_e('API key', 'patchstack'); ?> | |
| 183 | - </label> | |
| 184 | - <input class="regular-text" type="text" id="patchstack_api_key" value="<?php echo get_option( 'patchstack_clientid', false ) ? esc_attr( $this->get_secret_key() . '-' . get_option( 'patchstack_clientid', false ) ) : ''; ?>" placeholder="<?php esc_attr_e('Unique API key', 'patchstack'); ?>"> | |
| 185 | - </div> | |
| 186 | - | |
| 187 | - <?php | |
| 188 | - if ( ! get_option( 'patchstack_clientid', false ) ) { | |
| 189 | - echo '<p class="patchstack-error">' . esc_html__('To use this plugin, login and add it to the App dashboard and sync using the API key provided there.', 'patchstack') . '</p>'; | |
| 190 | - } | |
| 191 | - ?> | |
| 192 | - | |
| 193 | - <div class="patchstack-license-button"> | |
| 194 | - <input type="submit" id="patchstack-activate" value="<?php $status ? esc_attr_e( 'Re-sync with App', 'patchstack' ) : esc_attr_e( 'Activate', 'patchstack' ); ?>" class="button-primary patchstack-fullwidth" /> | |
| 195 | - </div> | |
| 196 | - | |
| 197 | - <div style="clear: both;"></div> | |
| 198 | - | |
| 199 | - <?php | |
| 200 | - } | |
| 201 | - | |
| 202 | - if (isset($_GET['resync'])) { | |
| 203 | - echo '<p class="patchstack-resync">' . esc_html__('The plugin is connected and synchronized.', 'patchstack') . '</p>'; | |
| 204 | - } | |
| 205 | - ?> | |
| 206 | - | |
| 207 | - <div class="patchstack-loading"><div></div><div></div><div></div><div></div></div> | |
| 208 | - | |
| 209 | - <?php | |
| 210 | - if (isset($_GET['ps_autoa'])) { | |
| 211 | - echo '<p class="patchstack-resync">' . esc_html__('Attempting to auto-activate the plugin, this will take a moment...', 'patchstack') . '</p>'; | |
| 212 | - } | |
| 213 | - ?> | |
| 74 | + <h2 class="patchstack-license-h2 patchstack-hover"><?php echo __( 'Settings', 'patchstack' ); ?></h2> | |
| 75 | + <div class="patchstack-font patchstack-license-info"> | |
| 76 | + <div id="hiddenstatusbox" class="patchstackInfo patchstack-font blue"> | |
| 77 | + <span class="label label-success" id="patchstack_license_key_result"></span> | |
| 214 | 78 | </div> |
| 215 | - <div style="clear: both;"></div> | |
| 79 | + <p<?php echo ( $show_settings ? '' : ' style="display: none;"' ); ?>> | |
| 80 | + You can enter your site ID and secret key values below.<br /> | |
| 81 | + You generally do not have to touch these values.<br /><br /> | |
| 82 | + | |
| 83 | + If both are empty and you do not know your site ID and secret key, you can find it by following these steps:<br /> | |
| 84 | + 1. Go to your site on the Patchstack App.<br /> | |
| 85 | + 2. Click on the "Site Settings" button on the right.<br /> | |
| 86 | + 3. Click on "Site Credentials & Download Plugin".<br /> | |
| 87 | + 4. The site ID and secret key will be displayed on this page. | |
| 88 | + </p> | |
| 89 | + <table class="form-table patchstack-form-table"> | |
| 90 | + <tr> | |
| 91 | + <th> | |
| 92 | + <label for="patchstack_api_client_id"><?php echo __( 'Site ID', 'patchstack' ); ?></label> | |
| 93 | + </th> | |
| 94 | + <td> | |
| 95 | + <input class="regular-text" type="text" id="patchstack_api_client_id" value="<?php echo esc_attr( get_option( 'patchstack_clientid', false ) ); ?>" placeholder="Enter your site ID here..."> | |
| 96 | + </td> | |
| 97 | + </tr> | |
| 98 | + <tr> | |
| 99 | + <th><label for="patchstack_api_client_secret_key"><?php echo __( 'Site Secret Key', 'patchstack' ); ?></label></th> | |
| 100 | + <td> | |
| 101 | + <input class="regular-text" type="text" id="patchstack_api_client_secret_key" value="<?php echo esc_attr( get_option( 'patchstack_secretkey', false ) ); ?>" placeholder="Enter your site secret key here..."> | |
| 102 | + </td> | |
| 103 | + </tr> | |
| 104 | + <tr> | |
| 105 | + <th> | |
| 106 | + <label><?php echo __( 'Status', 'patchstack' ); ?></label> | |
| 107 | + </th> | |
| 108 | + <td> | |
| 109 | + <span class="patchstack-license-status" style="font-size: 13px; color: #fff;"><?php echo ( $status ? '' : 'Not ' ); ?>Activated</span> | |
| 110 | + </td> | |
| 111 | + </tr> | |
| 112 | + <tr> | |
| 113 | + <th> | |
| 114 | + <label><?php echo __( 'Subscription Type', 'patchstack' ); ?></label> | |
| 115 | + </th> | |
| 116 | + <td> | |
| 117 | + <span style="font-size: 13px; color: #fff;"><?php echo ( $free ? 'Community (Free)' : 'Professional' ); ?></span> | |
| 118 | + </td> | |
| 119 | + </tr> | |
| 120 | + <tr> | |
| 121 | + <td colspan="2"> | |
| 122 | + <p class="submit"> | |
| 123 | + <input type="submit" id="patchstack-activate" value="<?php echo __( 'Save', 'patchstack' ); ?>" class="button-primary" /> | |
| 124 | + </p> | |
| 125 | + </td> | |
| 126 | + </tr> | |
| 127 | + </table> | |
| 216 | 128 | </div> |
| 217 | - | |
| 218 | - <p class="patchstack-upsell patchstack-footer"> | |
| 219 | - <?php if ( ! $managed && $free ) { ?> | |
| 220 | - <a href="<?php echo $app_url; ?>" target="_blank"><?php esc_html_e( 'Protect this site for $5/mo', 'patchstack' ); ?></a> | |
| 221 | - <span></span> | |
| 222 | - <?php } ?> | |
| 223 | - | |
| 224 | - <?php if ( ! isset( $_GET['key'] ) ) { ?> | |
| 225 | - <a href="options-general.php?page=patchstack&key=1"><?php esc_html_e( 'Change API key', 'patchstack' ); ?></a> | |
| 226 | - <?php } else { ?> | |
| 227 | - <a href="options-general.php?page=patchstack"><?php esc_html_e( 'Back to overview', 'patchstack' ); ?></a> | |
| 228 | - <?php } ?> | |
| 229 | - </p> | |
| 230 | -</div> | |
| 129 | +</div> | |