show_sunset_banner( $packages );
$this->list_licensed_products( $licensed, $post_data, $action );
if ( $has_patchstack ) {
if ( ( $security_package['total'] > 0 || $security_package['total'] == -1 ) && $patchstack_quota['total'] > 0 ) {
$this->list_patchstack_quota( $patchstack_quota, $post_data, $action );
}
}
$this->list_unlicensed_products( $unlicensed, $post_data, $action );
$this->list_unrecognized_products( $unrecognized );
$this->show_settings();
?>
get_option( 'quick_releases' );
?>
errors ) ) {
$post_data = array(
'username' => '',
'password' => '',
'packages' => array(),
);
}
?>
errors ) ) {
$post_data = array(
'username' => '',
'password' => '',
'patchstack_sites' => array(),
);
}
$patchstack_available = $patchstack['total'] - $patchstack['used'];
?>
errors ) ) {
$post_data = array(
'username' => '',
'password' => '',
'packages' => array(),
);
foreach ( $products as $name => $data )
{$post_data['packages'][] = $data['package'];}
}
?>
SolidWP support and provide them with the details given below.', 'it-l10n-ithemes-security-pro' ), 'https://solidwp.com/support/' ); ?>
show_notices();
$site_url = $GLOBALS['ithemes-updater-settings']->get_licensed_site_url();
if ( empty( $site_url ) ) {
$site_url = network_home_url();
}
if ( empty( $post_data['username'] ) || empty( $this->errors ) ) {
$post_data['username'] = '';
}
if ( empty( $post_data['password'] ) || empty( $this->errors ) ) {
$post_data['password'] = '';
}
if ( ! empty( $post_data['redirect'] ) ) {
$redirect = $post_data['redirect'];
} else if ( ! empty( $_GET['redirect'] ) ) {
$redirect = $_GET['redirect'];
} else {
$redirect = '';
}
?>
errors[] = __( 'The licensed URL cannot be blank.', 'it-l10n-ithemes-security-pro' );
} else if ( false === filter_var( $data['site_url'], FILTER_VALIDATE_URL ) ) {
$this->errors[] = __( 'The licensed URL must be a valid URL.', 'it-l10n-ithemes-security-pro' );
}
if ( ! empty( $this->errors ) ) {
$this->show_licensed_site_url_confirmation_page( $data );
return;
}
$site_url = $GLOBALS['ithemes-updater-settings']->get_site_url( $data['site_url'] );
if ( $this->has_license_keys() ) {
$site_url_from_server = $GLOBALS['ithemes-updater-settings']->get_licensed_site_url_from_server();
if ( $site_url_from_server !== $site_url ) {
$data['site_url'] = $site_url;
$this->show_relicensing_page( $data );
return;
}
}
$GLOBALS['ithemes-updater-settings']->set_licensed_site_url( $site_url );
$this->messages[] = __( 'Successfully set the Licensed URL.', 'it-l10n-ithemes-security-pro' );
if ( empty( $data['redirect'] ) ) {
$redirect = admin_url( 'options-general.php?page=ithemes-licensing&updated_url=true' );
} else {
$redirect = $data['redirect'];
}
echo '
' . "\n";
$this->list_packages();
}
public function show_relicensing_page( $data = array() ) {
$this->show_notices();
$site_url_from_server = $GLOBALS['ithemes-updater-settings']->get_licensed_site_url_from_server();
if ( empty( $data['relicense_option'] ) ) {
$data['relicense_option'] = 'relicense';
}
if ( empty( $data['username'] ) ) {
$data['username'] = '';
}
if ( empty( $data['password'] ) ) {
$data['password'] = '';
}
?>
%s.', 'it-l10n-ithemes-security-pro' ), esc_html( $site_url_from_server ) ); ?>
errors[] = __( 'You must supply a SolidWP membership username and password in order to change the licensed URL.', 'it-l10n-ithemes-security-pro' );
} else if ( empty( $data['username'] ) ) {
$this->errors[] = __( 'You must supply a SolidWP membership username in order to change the licensed URL.', 'it-l10n-ithemes-security-pro' );
} else if ( empty( $data['password'] ) ) {
$this->errors[] = __( 'You must supply a SolidWP membership password in order to change the licensed URL.', 'it-l10n-ithemes-security-pro' );
} else if ( empty( $data['site_url'] ) ) {
$this->errors[] = __( 'The licensed URL cannot be blank.', 'it-l10n-ithemes-security-pro' );
} else if ( false === filter_var( $data['site_url'], FILTER_VALIDATE_URL ) ) {
$this->errors[] = __( 'The licensed URL must be a valid URL.', 'it-l10n-ithemes-security-pro' );
} else if ( empty( $data['relicense_option'] ) || ! in_array( $data['relicense_option'], array( 'relicense', 'update' ) ) ) {
$this->errors[] = __( 'You must pick one of the License Option options.', 'it-l10n-ithemes-security-pro' );
}
if ( ! empty( $this->errors ) ) {
$this->show_relicensing_page( $data );
return;
}
if ( 'update' === $data['relicense_option'] ) {
$response = Ithemes_Updater_API::set_licensed_site_url( $data['username'], $data['password'], $data['site_url'] );
if ( is_wp_error( $response ) ) {
$this->errors[] = Ithemes_Updater_API::get_error_explanation( $response );
$this->show_relicensing_page( $data );
return;
}
$GLOBALS['ithemes-updater-settings']->set_licensed_site_url( $data['site_url'] );
$this->messages[] = __( 'Successfully updated the Licensed URL.', 'it-l10n-ithemes-security-pro' );
} else {
require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' );
$keys = Ithemes_Updater_Keys::get();
$packages = array_keys( $keys );
$response = Ithemes_Updater_API::deactivate_package( $data['username'], $data['password'], $packages );
if ( is_wp_error( $response ) ) {
$this->errors[] = Ithemes_Updater_API::get_error_explanation( $response );
$this->show_relicensing_page( $data );
return;
}
$GLOBALS['ithemes-updater-settings']->set_licensed_site_url( $data['site_url'] );
$this->messages[] = __( 'Successfully updated the Licensed URL.', 'it-l10n-ithemes-security-pro' );
$response = Ithemes_Updater_API::activate_package( $data['username'], $data['password'], $packages );
if ( is_wp_error( $response ) ) {
$this->errors[] = Ithemes_Updater_API::get_error_explanation( $response );
$this->show_relicensing_page( $data );
return;
}
}
if ( empty( $data['redirect'] ) ) {
$redirect = admin_url( 'options-general.php?page=ithemes-licensing&updated_url=true' );
} else {
$redirect = $data['redirect'];
}
echo '
' . "\n";
$this->list_packages();
}
private function show_notices() {
if ( ! empty( $this->messages ) ) {
foreach ( $this->messages as $message ) {
echo "
\n";
}
}
if ( ! empty( $this->errors ) ) {
foreach ( $this->errors as $error ) {
echo "
\n";
}
}
if ( ! empty( $this->soft_errors ) ) {
foreach ( $this->soft_errors as $error ) {
echo "
\n";
}
}
}
private function get_expiration_string( $expiration_timestamp ) {
$time = time();
$time_left = $expiration_timestamp - $time;
$expired = false;
if ( $time_left < 0 ) {
$expired = true;
$time_left = abs( $time_left );
}
if ( $time_left > ( 86400 * 30 ) ) {
$expiration = date( 'Y-m-d', $expiration_timestamp );
} else {
if ( $time_left > 86400 ) {
$expiration = sprintf( _n( '%d day', '%d days', intval( $time_left / 86400 ), 'it-l10n-ithemes-security-pro' ), intval( $time_left / 86400 ) );
} else if ( $time_left > 3600 ) {
$expiration = sprintf( _n( '%d hour', '%d hours', intval( $time_left / 3600 ), 'it-l10n-ithemes-security-pro' ), intval( $time_left / 3600 ) );
} else if ( $time_left > 60 ) {
$expiration = sprintf( _n( '%d minute', '%d minutes', intval( $time_left / 60 ), 'it-l10n-ithemes-security-pro' ), intval( $time_left / 60 ) );
} else {
$expiration = sprintf( _n( '%d second', '%d seconds', $time_left, 'it-l10n-ithemes-security-pro' ), intval( $time_left / 60 ) );
}
if ( $expired ) {
$expiration = sprintf( __( '%s ago', 'it-l10n-ithemes-security-pro' ), $expiration );
}
}
return $expiration;
}
private function has_license_keys() {
require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' );
$keys = Ithemes_Updater_Keys::get();
$legacy_keys = Ithemes_Updater_Keys::get_legacy();
if ( empty( $keys ) && empty( $legacy_keys ) ) {
return false;
}
return true;
}
}
new Ithemes_Updater_Settings_Page();