| 1 |
<?php |
| 2 |
|
| 3 |
// Do not allow the file to be called directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
// Determine the active tab and account activation state. |
| 9 |
$tabs = [ 'hardening', 'firewall', 'login', 'logs', 'license', 'multisite' ]; |
| 10 |
$active_tab = isset( $_GET['tab'] ) && in_array( $_GET['tab'], $tabs ) ? esc_attr( $_GET['tab'] ) : 'license'; // default active tab |
| 11 |
$activated = ( ( isset( $_GET['ps_activated'] ) && $_GET['ps_activated'] == 1 ) || ( isset( $_GET['active'] ) && $_GET['active'] == 1 ) ); |
| 12 |
$status = ( get_option( 'patchstack_license_expiry', '' ) == '' || time() >= strtotime( get_option( 'patchstack_license_expiry', '' ) ) ); |
| 13 |
$show_settings = $this->get_option( 'patchstack_show_settings', 0 ) == 1 && !isset($_GET['tab']) || isset($_GET['tab']) && $_GET['tab'] != 'license'; |
| 14 |
$is_free = $this->get_option( 'patchstack_license_free', 0 ) == 1; |
| 15 |
$class = get_option( 'patchstack_subscription_class', '' ); |
| 16 |
$managed = get_option( 'patchstack_managed', false ); |
| 17 |
$managed_text = get_option( 'patchstack_managed_text', '' ); |
| 18 |
|
| 19 |
if ( ( ! $show_settings && $_GET['page'] != 'patchstack-multisite-settings' ) || ( $status && $active_tab != 'license' && $_GET['page'] != 'patchstack-multisite-settings' ) ) { |
| 20 |
$_GET['tab'] = $active_tab = 'license'; |
| 21 |
} |
| 22 |
|
| 23 |
if ( ( $is_free || ! $is_free && $status ) && $active_tab != 'license' && $_GET['page'] == 'patchstack-multisite-settings' ) { |
| 24 |
$_GET['tab'] = $active_tab = 'multisite'; |
| 25 |
} |
| 26 |
|
| 27 |
if ($active_tab == 'license') { |
| 28 |
$show_settings = false; |
| 29 |
} |
| 30 |
|
| 31 |
// Determine the URL's. |
| 32 |
$page = $_GET['page'] == 'patchstack-multisite-settings' ? 'patchstack-multisite-settings' : $this->plugin->name; |
| 33 |
?> |
| 34 |
<div class="patchstack-content-wrap<?php echo ( ! $show_settings || $this->get_option( 'patchstack_license_free', 0 ) == 1 ? ' patchstack-free' : '' ); ?>"> |
| 35 |
<div class="patchstack-top"> |
| 36 |
<div class="patchstack-top-logo" |
| 37 |
<?php |
| 38 |
if ( $show_settings && $this->get_option( 'patchstack_license_free', 0 ) == 1 ) { |
| 39 |
echo ' style="float: right; width: 80%; margin-right: -15px;"'; |
| 40 |
} |
| 41 |
?> |
| 42 |
> |
| 43 |
<img src="<?php echo esc_url( $this->plugin->url ); ?>assets/images/logo.svg" alt=""> |
| 44 |
</div> |
| 45 |
<h1 <?php echo $show_settings || !$managed ? 'style="display: none;"' : ''; ?>> |
| 46 |
<?php echo $managed_text; ?> |
| 47 |
</h1> |
| 48 |
<?php |
| 49 |
if ( $_GET['page'] != 'patchstack-multisite-settings' && $show_settings && is_multisite() ) { |
| 50 |
$site_info = get_blog_details(); |
| 51 |
echo "<h2 style='color:white;padding-left: 95px; margin-top: -12px; margin-left: 150px;'>" . esc_html( $site_info->domain ) . '</h2>'; |
| 52 |
} |
| 53 |
?> |
| 54 |
</div> |
| 55 |
|
| 56 |
<div class="patchstack-content-table"> |
| 57 |
<?php |
| 58 |
if ($show_settings) { |
| 59 |
echo '<div class="notice notice-error"><p>'; |
| 60 |
_e( 'Note that this is a legacy settings page and will be inaccessible on May 1st, 2024. After this you will be required to view and manage your settings through the <a href="https://app.patchstack.com/" target="_blank">Patchstack App</a>.', 'patchstack' ); |
| 61 |
echo '</p></div><br />'; |
| 62 |
} |
| 63 |
|
| 64 |
if ( is_multisite() && $show_settings ) { |
| 65 |
?> |
| 66 |
<div class="notice notice-warning"> |
| 67 |
<p> |
| 68 |
<?php |
| 69 |
if ( isset( $_GET['page'] ) && $_GET['page'] == 'patchstack-multisite-settings' ) { |
| 70 |
_e( 'Note that because this is a multisite/network environment, this settings page will define all default settings of all sites.<br />If you would like to change the settings of a specific site, visit the administration panel of the site in question. Click <a href="' . network_admin_url( 'admin.php?page=patchstack-multisite' ) . '">here</a> for an overview of sites.', 'patchstack' ); |
| 71 |
} else { |
| 72 |
_e( 'Note that because this is a multisite/network environment, certain settings can only be managed by the super administrator of the WordPress network.', 'patchstack' ); |
| 73 |
} |
| 74 |
?> |
| 75 |
</p> |
| 76 |
</div><br /> |
| 77 |
<?php } ?> |
| 78 |
<h2 class="nav-tab-wrapper patchstack-nav-tab-wrapper" |
| 79 |
<?php |
| 80 |
if ( ! $show_settings ) { |
| 81 |
echo ' style="display: none;"'; } |
| 82 |
?> |
| 83 |
> |
| 84 |
<?php if ( $class >= 1 || $class === '' ) { ?> |
| 85 |
<a href="?page=<?php echo esc_attr( $page ); ?>&tab=hardening" class="nav-tab patchstack-nav-tab <?php echo $active_tab == 'hardening' ? 'nav-tab-active patchstack-nav-tab-active' : ''; ?>"> |
| 86 |
<span class="patchstack-icon-wrapper"><span class="patchstack-nav-tab-icon ic-services white"></span></span> |
| 87 |
<span class="patchstack-icon-text"><?php echo esc_attr__( 'Hardening', 'patchstack' ); ?><br /><span>General Security Tweaks</span></span> |
| 88 |
</a> |
| 89 |
<?php } ?> |
| 90 |
|
| 91 |
<a href="?page=<?php echo esc_attr( $page ); ?>&tab=firewall" class="nav-tab patchstack-nav-tab <?php echo $active_tab == 'firewall' ? 'nav-tab-active patchstack-nav-tab-active' : ''; ?>"> |
| 92 |
<span class="patchstack-icon-wrapper"><span class="patchstack-nav-tab-icon ic-firewall white"></span></span> |
| 93 |
<span class="patchstack-icon-text"><?php echo esc_attr__( 'Firewall', 'patchstack' ); ?><br /><span>Whitelist & Blacklist & Firewall</span></span> |
| 94 |
</a> |
| 95 |
|
| 96 |
<?php if ( $class >= 1 || $class === '' ) { ?> |
| 97 |
<a href="?page=<?php echo esc_attr( $page ); ?>&tab=login" class="nav-tab patchstack-nav-tab <?php echo $active_tab == 'login' ? 'nav-tab-active patchstack-nav-tab-active' : ''; ?>"> |
| 98 |
<span class="patchstack-icon-wrapper"><span class="patchstack-nav-tab-icon ic-login white"></span></span> |
| 99 |
<span class="patchstack-icon-text"><?php echo esc_attr__( 'Login Protection', 'patchstack' ); ?><br /><span>Protect your login page</span></span> |
| 100 |
</a> |
| 101 |
<?php } ?> |
| 102 |
|
| 103 |
<?php if ( $page != 'patchstack-multisite-settings' ) { ?> |
| 104 |
<a href="?page=<?php echo esc_attr( $page ); ?>&tab=logs" class="nav-tab patchstack-nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active patchstack-nav-tab-active' : ''; ?>"> |
| 105 |
<span class="patchstack-icon-wrapper"><span class="patchstack-nav-tab-icon ic-logs white"></span></span> |
| 106 |
<span class="patchstack-icon-text"><?php echo esc_attr__( 'Logs', 'patchstack' ); ?><br /><span>Firewall & Activity Logs</span></span> |
| 107 |
</a> |
| 108 |
<?php } ?> |
| 109 |
|
| 110 |
<?php if ( ! is_multisite() || ( isset( $_GET['page'] ) && $_GET['page'] != 'patchstack-multisite-settings' ) ) { ?> |
| 111 |
<a href="?page=<?php echo esc_attr( $page ); ?>&tab=license" class="nav-tab patchstack-nav-tab <?php echo $active_tab == 'license' ? 'nav-tab-active patchstack-nav-tab-active' : ''; ?>"> |
| 112 |
<span class="patchstack-icon-wrapper"><span class="patchstack-nav-tab-icon ic-license white"></span></span> |
| 113 |
<span class="patchstack-icon-text"><?php echo esc_attr__( 'License', 'patchstack' ); ?><br /><span>Your license information</span></span> |
| 114 |
</a> |
| 115 |
<?php } ?> |
| 116 |
</h2> |
| 117 |
<div class="patchstack-content-inner patchstack-active-tab-<?php echo esc_attr( $active_tab ); ?> <?php echo ! $show_settings && $this->get_option( 'patchstack_license_free', 0 ) == 0 ? 'patchstack-premium' : ''; ?>"> |
| 118 |
<?php |
| 119 |
if ( $status && $_GET['page'] != 'patchstack-multisite-settings' ) { |
| 120 |
require 'license.php'; |
| 121 |
} else { |
| 122 |
$form_action = is_multisite() ? '' : 'options.php'; |
| 123 |
switch ( $active_tab ) { |
| 124 |
case 'hardening': |
| 125 |
require 'hardening.php'; |
| 126 |
break; |
| 127 |
case 'firewall': |
| 128 |
require 'firewall.php'; |
| 129 |
break; |
| 130 |
case 'login': |
| 131 |
require 'login.php'; |
| 132 |
break; |
| 133 |
case 'logs': |
| 134 |
require 'logs.php'; |
| 135 |
break; |
| 136 |
case 'license': |
| 137 |
require 'license.php'; |
| 138 |
break; |
| 139 |
case 'multisite': |
| 140 |
require 'multisite-activation.php'; |
| 141 |
break; |
| 142 |
default: |
| 143 |
require 'license.php'; |
| 144 |
break; |
| 145 |
} |
| 146 |
} |
| 147 |
?> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
|