options;
if (isset($_POST['options']['appinsights_hidden'])
&& isset($_POST['options'])
&& (isset($_POST['appinsights_security'])
&& wp_verify_nonce($_POST['appinsights_security'], 'appinsights_form' )
&& !$reset)) {
if ($_POST ['options']['appinsights_component_list'] && is_string($_POST ['options']['appinsights_component_list'])) {
$_POST ['options']['appinsights_component_list'] = unserialize(stripslashes($_POST ['options']['appinsights_component_list']));
}
$new_options = $_POST ['options'];
$options = array_merge($options, $new_options);
$AppInsights_Config->options = $options;
$AppInsights_Config->set_plugin_options();
}
return $options;
}
public static function appinsights_plugin_options_page() {
global $AppInsights_Config;
include_once ($AppInsights_Config->plugin_path . '/appinsights-tools.php');
$tools = new AppInsights_Tools();
if (!current_user_can ( 'manage_options')) {
return;
}
$options = self::set_get_options();
include_once ($AppInsights_Config->plugin_path . '/appinsights-api.php');
global $AppInsights_API;
if ($_GET['code'] && !$options['appinsights_token']) {
if (isset($_GET['state'])) {
$state = urldecode($_GET['state']);
parse_str($state, $state_vars);
if (isset($state_vars['security_token']) && $state_vars['security_token'] == $_SESSION[ AppInsights_API::ANTIFORGERY_ID_KEY ]) {
$authentication = $AppInsights_API->authenticate($_GET['code']);
if (!is_wp_error($authentication)) {
$AppInsights_Config->options['appinsights_token'] = $AppInsights_API->get_access_token();
$microsoft_token = json_decode($AppInsights_API->get_access_token());
$AppInsights_Config->options['appinsights_refresh_token'] = $microsoft_token->refresh_token;
$AppInsights_Config->set_plugin_options();
$message = "
" . __ ( "Plugin authorization succeeded.", 'appinsights' ) . "
";
$options = self::set_get_options();
} else {
$message = "" . $authentication->get_error_message() . "
";
}
} else {
$message = "" . __ ( "A required anti-forgery token was not supplied or was invalid.", 'appinsights' ) . "
";
}
} else {
$message = "" . __ ( "A required anti-forgery token was not supplied or was invalid.", 'appinsights' ) . "
";
}
}
if ($AppInsights_API->get_access_token()) {
if ($AppInsights_Config->options['appinsights_subscription_list']) {
$subscriptions = $AppInsights_Config->options['appinsights_subscription_list'];
} else {
$subscriptions = $AppInsights_API->refresh_subscriptions();
}
if ($subscriptions) {
$AppInsights_Config->options['appinsights_subscription_list'] = $subscriptions;
if (!$AppInsights_Config->options['appinsights_subscription']) {
$AppInsights_Config->options['appinsights_subscription'] = $subscriptions[0][0];
}
if ($AppInsights_Config->options['appinsights_component_list']) {
$components = $AppInsights_Config->options['appinsights_component_list'];
} else if ($AppInsights_Config->options['appinsights_subscription']) {
$components = $AppInsights_API->appinsights_components($AppInsights_Config->options['appinsights_subscription']);
} else {
$components = $AppInsights_API->appinsights_components($subscriptions[0][0]);
}
$AppInsights_Config->set_plugin_options();
$options = self::set_get_options();
}
}
if (isset($_POST['reset'])) {
if (isset($_POST['appinsights_security']) && wp_verify_nonce($_POST['appinsights_security'], 'appinsights_form')) {
$AppInsights_API->appinsights_reset_token(true);
$tools->appinsights_clear_cache();
$message = "" . __ ( "Token Reseted.", 'appinsights' ) . "
";
$options = self::set_get_options(true);
} else {
$message = "" . __ ( "Nonce is invalid", 'appinsights' ) . "
";
}
}
if (isset($_POST ['options']['appinsights_hidden']) && !isset($_POST['reset'])) {
$message = "" . __ ( "Options saved.", 'appinsights' ) . "
";
if (!(isset($_POST['appinsights_security']) && wp_verify_nonce($_POST['appinsights_security'], 'appinsights_form' ))) {
$message = "" . __ ( "Nonce is invalid", 'appinsights' ) . "
";
}
}
?>
token_request();
} else {
if (isset($message)) {
echo $message;
}
?>
plugin_path . '/appinsights-api.php');
global $AppInsights_API;
$nonce = $_POST['next_nonce'];
if ( ! wp_verify_nonce( $nonce, 'appinsights-next-nonce' ) )
die ( 'Nonce is invalid!');
$subscription_id = $_POST['subscription_id'];
$components = $AppInsights_API->appinsights_components($subscription_id);
$html = '';
if ($components) {
$html .= ' | ';
$html .= '';
$html .= ' | ';
} else {
$html .= '';
$html .= '';
$html .= "" . __ ( "No application insights resource found under this account.", 'appinsights' ) . " | ";
}
echo $html;
die();
}
}
?>