| 1 |
<?php |
| 2 |
|
| 3 |
// Do not allow the file to be called directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 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); |
| 10 |
$free = get_option( 'patchstack_license_free', 0 ) == 1; |
| 11 |
$planClass = get_option( 'patchstack_subscription_class', ''); |
| 12 |
$managed = get_option( 'patchstack_managed', false ); |
| 13 |
$site_id = (int) get_option( 'patchstack_site_id', 0 ); |
| 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 |
} |
| 18 |
|
| 19 |
// Generate the link to turn on settings management. |
| 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 |
} |
| 29 |
?> |
| 30 |
<div class="patchstack-free patchstack-auto-activate" style="<?php echo $status ? 'display: none;' : ''; ?>"> |
| 31 |
<div> |
| 32 |
<div class="is-polling-section has-text-centered"> |
| 33 |
<img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/polling.svg" class="rotate"> |
| 34 |
<p class="is-text-medium"> |
| 35 |
Checking sync status |
| 36 |
</p> |
| 37 |
</div> |
| 38 |
|
| 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 |
?> |
| 47 |
|
| 48 |
<div class="patchstack-plan patchstack-plan2"> |
| 49 |
<div class="form-table patchstack-form-table"> |
| 50 |
<div class="patchstack-activate-wrapper"> |
| 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"> |
| 53 |
<input type="submit" id="patchstack-activate" value="<?php echo esc_attr__( 'Sync', 'patchstack' ); ?>" class="button-primary" /> |
| 54 |
</div> |
| 55 |
</div> |
| 56 |
|
| 57 |
|
| 58 |
<div style="clear: both;"></div> |
| 59 |
|
| 60 |
<div class="patchstack-loading"><div></div><div></div><div></div><div></div></div> |
| 61 |
</div> |
| 62 |
<div style="clear: both;"></div> |
| 63 |
</div> |
| 64 |
</div> |
| 65 |
|
| 66 |
<p class="patchstack-upsell" style="<?php echo $status ? 'display: none;' : ''; ?>"> |
| 67 |
<a href="https://app.patchstack.com/login" target="_blank">Log in to dashboard</a> |
| 68 |
</p> |
| 69 |
|
| 70 |
<div class="patchstack-free" style="<?php echo !$status ? 'display: none;' : ''; ?>"> |
| 71 |
<div> |
| 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> |
| 73 |
|
| 74 |
<div class="patchstack-plan patchstack-plan2"> |
| 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> |
| 85 |
|
| 86 |
<div style="clear: both;"></div> |
| 87 |
|
| 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> |
| 91 |
</div> |
| 92 |
|
| 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 |
| 97 |
</a> |
| 98 |
</div> |
| 99 |
|
| 100 |
<?php |
| 101 |
if (!isset($_GET['ps_autoa'])) { |
| 102 |
?> |
| 103 |
<div class="form-table patchstack-form-table" <?php echo $managed ? 'style="margin-top: 32px;"' : ''; ?>> |
| 104 |
<label for="patchstack_api_key"> |
| 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 |
?> |
| 114 |
</label> |
| 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"> |
| 116 |
</div> |
| 117 |
|
| 118 |
<?php |
| 119 |
if ( ! get_option( 'patchstack_clientid', false ) ) { |
| 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>'; |
| 121 |
} |
| 122 |
?> |
| 123 |
|
| 124 |
<div class="patchstack-license-button"> |
| 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" /> |
| 126 |
</div> |
| 127 |
|
| 128 |
<div style="clear: both;"></div> |
| 129 |
|
| 130 |
<?php |
| 131 |
if (isset($_GET['resync'])) { |
| 132 |
echo '<p class="patchstack-resync">The plugin is connected and synchronized.</p>'; |
| 133 |
} |
| 134 |
?> |
| 135 |
<?php |
| 136 |
} |
| 137 |
?> |
| 138 |
<div class="patchstack-loading"><div></div><div></div><div></div><div></div></div> |
| 139 |
<?php |
| 140 |
if (isset($_GET['ps_autoa'])) { |
| 141 |
echo '<p class="patchstack-resync">Attempting to auto-activate the plugin, this will take a moment...</p>'; |
| 142 |
} |
| 143 |
?> |
| 144 |
</div> |
| 145 |
<div style="clear: both;"></div> |
| 146 |
</div> |
| 147 |
|
| 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. |
| 151 |
<?php } ?> |
| 152 |
</p> |
| 153 |
</div> |
| 154 |
<?php |
| 155 |
} |
| 156 |
?> |