| @@ -5,53 +5,57 @@ | ||
| 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() ); | |
| 9 | +$status = ($this->plugin->client_id != 'PATCHSTACK_CLIENT_ID' || get_option( 'patchstack_clientid', false ) != false); | |
| 10 | 10 | $free = get_option( 'patchstack_license_free', 0 ) == 1; |
| 11 | 11 | $planClass = get_option( 'patchstack_subscription_class', ''); |
| 12 | +$managed = get_option( 'patchstack_managed', false ); | |
| 12 | 13 | $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'; | |
| 14 | +$app_url = $site_id != 0 ? 'https://app.patchstack.com/app/' . $site_id . '/"' : 'https://app.patchstack.com/apps/overview'; | |
| 15 | +if ( isset( $_GET['ps_activated'] ) && $status ) { | |
| 16 | + echo "<script>window.location = 'admin.php?page=patchstack&tab=license&active=1';</script>"; | |
| 17 | +} | |
| 14 | 18 | |
| 15 | 19 | // 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 | -} | |
| 20 | +$url = '?page=' . esc_attr( $page ) . '&tab=license&action=enable_settings&patchstack_settings_nonce=' . wp_create_nonce( 'patchstack_settings_nonce' ); | |
| 21 | +$url_enabled = '?page=patchstack' . (!$free ? '&tab=firewall' : ''); | |
| 22 | + | |
| 23 | +if (!$show_settings) { | |
| 24 | + $secretToken = get_option( 'patchstack_activation_secret', '' ); | |
| 25 | + $secretTime = get_option( 'patchstack_activation_time', '' ); | |
| 26 | + if (!empty($secretToken)) { | |
| 27 | + echo '<script>jQuery(function(){ window.Patchstack.poller(); });</script>'; | |
| 28 | + } | |
| 21 | 29 | ?> |
| 22 | 30 | <div class="patchstack-free patchstack-auto-activate" style="<?php echo $status ? 'display: none;' : ''; ?>"> |
| 23 | 31 | <div> |
| 24 | 32 | <div class="is-polling-section has-text-centered"> |
| 25 | 33 | <img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/polling.svg" class="rotate"> |
| 26 | - | |
| 27 | 34 | <p class="is-text-medium"> |
| 28 | - <?php esc_html_e( 'Checking sync status', 'patchstack' ); ?> | |
| 35 | + Checking sync status | |
| 29 | 36 | </p> |
| 37 | + </div> | |
| 30 | 38 | |
| 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> | |
| 39 | + <?php | |
| 40 | + $mins = ! empty( $secretTime ) ? floor( ( ( 1800 ) - ( time() - $secretTime ) ) / 60 ) : 0; | |
| 41 | + if ( $mins >= 1 ) { | |
| 42 | + echo '<p class="patchstack-upsell patchstack-has-text-white">This plugin is only a connector. Add this website to the Patchstack dashboard within ' . $mins . ' minutes to initiate automatic sync.</p>'; | |
| 43 | + } else { | |
| 44 | + echo '<p class="patchstack-upsell patchstack-has-text-white">This plugin is only a connector. Add this website to the Patchstack dashboard to sync your unique API key.</p>'; | |
| 45 | + } | |
| 46 | + ?> | |
| 44 | 47 | |
| 45 | 48 | <div class="patchstack-plan patchstack-plan2"> |
| 46 | 49 | <div class="form-table patchstack-form-table"> |
| 47 | 50 | <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' ); ?>"> | |
| 51 | + <label for="patchstack_api_key">Paste API key for manual sync</label> | |
| 52 | + <input class="regular-text" type="text" id="patchstack_api_key2" placeholder="Unique API key"> | |
| 50 | 53 | <input type="submit" id="patchstack-activate" value="<?php echo esc_attr__( 'Sync', 'patchstack' ); ?>" class="button-primary" /> |
| 51 | 54 | </div> |
| 52 | 55 | </div> |
| 53 | 56 | |
| 57 | + | |
| 54 | 58 | <div style="clear: both;"></div> |
| 55 | 59 | |
| 56 | 60 | <div class="patchstack-loading"><div></div><div></div><div></div><div></div></div> |
| 57 | 61 | </div> |
| @@ -59,172 +63,94 @@ | ||
| 59 | 63 | </div> |
| 60 | 64 | </div> |
| 61 | 65 | |
| 62 | 66 | <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> | |
| 67 | + <a href="https://app.patchstack.com/login" target="_blank">Log in to dashboard</a> | |
| 64 | 68 | </p> |
| 65 | 69 | |
| 66 | 70 | <div class="patchstack-free" style="<?php echo !$status ? 'display: none;' : ''; ?>"> |
| 67 | 71 | <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 } ?> | |
| 74 | - </p> | |
| 72 | + <p class="patchstack-upsell patchstack-has-text-white" style="<?php echo $managed ? 'display: none;' : ''; ?>">This plugin is only a connector. <a href="<?php echo $app_url; ?>" target="_blank"><?php echo esc_attr__( 'Log in to our dashboard', 'patchstack' ); ?></a> to access vulnerability data, protection modules and remote settings.</p> | |
| 75 | 73 | |
| 76 | 74 | <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> | |
| 75 | + <div class="patchstack-status"> | |
| 76 | + <span>Sync status</span> | |
| 77 | + <?php | |
| 78 | + if ($this->is_connected()) { | |
| 79 | + echo '<span class="patchstack-status-label">Connected</span>'; | |
| 80 | + } else { | |
| 81 | + echo '<span class="patchstack-status-label patchstack-status-label-error">Disconnected</span>'; | |
| 82 | + } | |
| 83 | + ?> | |
| 84 | + </div> | |
| 87 | 85 | |
| 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> | |
| 86 | + <div style="clear: both;"></div> | |
| 93 | 87 | |
| 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 } ?> | |
| 88 | + <div class="patchstack-protection" <?php echo !$this->is_protected() && empty($planClass) ? 'style="display: none;"' : ''; ?>> | |
| 89 | + <img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/shield.svg"> | |
| 90 | + <span>Protection enabled</span> | |
| 169 | 91 | </div> |
| 170 | 92 | |
| 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' ); ?> | |
| 93 | + <div class="patchstack-protection" <?php echo $this->is_protected() || $planClass > 0 || $managed ? 'style="display: none;"' : ''; ?>> | |
| 94 | + <span>Protection disabled</span> | |
| 95 | + <a href="<?php echo $app_url; ?>" target="_blank" class="button-primary"> | |
| 96 | + Activate for $5 / mo | |
| 174 | 97 | </a> |
| 175 | 98 | </div> |
| 176 | 99 | |
| 177 | - <?php | |
| 178 | - } else { | |
| 100 | + <?php | |
| 101 | + if (!isset($_GET['ps_autoa'])) { | |
| 179 | 102 | ?> |
| 180 | - <div class="form-table patchstack-form-table"> | |
| 103 | + <div class="form-table patchstack-form-table" <?php echo $managed ? 'style="margin-top: 32px;"' : ''; ?>> | |
| 181 | 104 | <label for="patchstack_api_key"> |
| 182 | - <?php esc_html_e('API key', 'patchstack'); ?> | |
| 105 | + API key | |
| 106 | + <?php | |
| 107 | + if ($planClass != '' && !$managed ) { | |
| 108 | + $plan = $this->get_subscription_name( $planClass ); | |
| 109 | + ?> | |
| 110 | + <span><?php echo $plan; ?> plan</span> | |
| 111 | + <?php | |
| 112 | + } | |
| 113 | + ?> | |
| 183 | 114 | </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'); ?>"> | |
| 115 | + <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="Unique API key"> | |
| 185 | 116 | </div> |
| 186 | 117 | |
| 187 | 118 | <?php |
| 188 | 119 | 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>'; | |
| 120 | + echo '<p class="patchstack-error">To use this plugin, login and add it to the App dashboard and sync using the API key provided there.</p>'; | |
| 190 | 121 | } |
| 191 | 122 | ?> |
| 192 | 123 | |
| 193 | 124 | <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" /> | |
| 125 | + <input type="submit" id="patchstack-activate" value="<?php echo $status ? esc_attr__( 'Re-sync with App', 'patchstack' ) : esc_attr__( 'Activate', 'patchstack' ); ?>" class="button-primary patchstack-fullwidth" /> | |
| 195 | 126 | </div> |
| 196 | 127 | |
| 197 | 128 | <div style="clear: both;"></div> |
| 198 | 129 | |
| 199 | 130 | <?php |
| 200 | - } | |
| 201 | - | |
| 202 | 131 | if (isset($_GET['resync'])) { |
| 203 | - echo '<p class="patchstack-resync">' . esc_html__('The plugin is connected and synchronized.', 'patchstack') . '</p>'; | |
| 132 | + echo '<p class="patchstack-resync">The plugin is connected and synchronized.</p>'; | |
| 204 | 133 | } |
| 205 | 134 | ?> |
| 206 | - | |
| 135 | + <?php | |
| 136 | + } | |
| 137 | + ?> | |
| 207 | 138 | <div class="patchstack-loading"><div></div><div></div><div></div><div></div></div> |
| 208 | - | |
| 209 | 139 | <?php |
| 210 | 140 | 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>'; | |
| 141 | + echo '<p class="patchstack-resync">Attempting to auto-activate the plugin, this will take a moment...</p>'; | |
| 212 | 142 | } |
| 213 | 143 | ?> |
| 214 | 144 | </div> |
| 215 | 145 | <div style="clear: both;"></div> |
| 216 | 146 | </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 | 147 | |
| 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> | |
| 148 | + <p class="patchstack-upsell" style="<?php echo $managed ? 'display: none;' : ''; ?>"> | |
| 149 | + <?php if ( ! $free && $planClass >= 1 ) { ?> | |
| 150 | + <a href="<?php echo $this->get_option( 'patchstack_show_settings', 0 ) == 1 ? $url_enabled : esc_url( $url ); ?>">Manage</a> the Patchstack plugin settings through WordPress. | |
| 228 | 151 | <?php } ?> |
| 229 | 152 | </p> |
| 230 | -</div> | |
| 153 | +</div> | |
| 154 | +<?php | |
| 155 | +} | |
| 156 | +?> | |