Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for SourceGuardian Encoder)
- *
- * @ Version : 4.0.8.2
- * @ Author : DeZender
- * @ Release on : 02.01.2019
- * @ Official site : http://DeZender.Net
- *
- */
- function route_request()
- {
- $host = grab_request_var('host', '');
- $service = grab_request_var('service', '');
- $hostgroup = grab_request_var('hostgroup', '');
- $servicegroup = grab_request_var('servicegroup', '');
- $auth = true;
- if (($service != '') && ($service != 'average')) {
- $auth = is_authorized_for_service(0, $host, $service);
- }
- else if ($host != '') {
- $auth = is_authorized_for_host(0, $host);
- }
- else if ($hostgroup != '') {
- $auth = is_authorized_for_hostgroup(0, $hostgroup);
- }
- else if ($servicegroup != '') {
- $auth = is_authorized_for_servicegroup(0, $servicegroup);
- }
- if (!$auth) {
- echo _('ERROR: You are not authorized to view this report.');
- exit();
- }
- $mode = grab_request_var('mode', '');
- switch ($mode) {
- case 'pdf':
- export_report('sla', EXPORT_PDF);
- break;
- case 'jpg':
- export_report('sla', EXPORT_JPG);
- break;
- case 'getservices':
- $host = grab_request_var('host', '');
- $args = ['brevity' => 1, 'host_name' => $host, 'orderby' => 'service_description:a'];
- $oxml = get_xml_service_objects($args);
- echo '<option value="">[' . _('All Services') . ']</option>';
- if ($oxml) {
- foreach ($oxml->service as $serviceobj) {
- $name = (string) $serviceobj->service_description;
- echo '<option value=\'' . $name . '\' ' . is_selected($service, $name) . '>' . $name . '</option>' . "\n";
- }
- }
- break;
- case 'getreport':
- get_sla_report();
- break;
- default:
- display_sla_report();
- break;
- }
- }
- function get_availability_data($type = 'host', $args, &$data)
- {
- $data = get_xml_availability($type, $args);
- return true;
- }
- function display_sla_report()
- {
- global $request;
- licensed_feature_check();
- $reportperiod = grab_request_var('reportperiod', 'last24hours');
- $startdate = grab_request_var('startdate', '');
- $enddate = grab_request_var('enddate', '');
- $host = grab_request_var('host', '');
- $service = grab_request_var('service', '');
- $hostgroup = grab_request_var('hostgroup', '');
- $servicegroup = grab_request_var('servicegroup', '');
- $slalevel = grab_request_var('slalevel', 95);
- $dont_count_downtime = checkbox_binary(grab_request_var('dont_count_downtime', 0));
- $dont_count_warning = checkbox_binary(grab_request_var('dont_count_warning', 0));
- $dont_count_unknown = checkbox_binary(grab_request_var('dont_count_unknown', 0));
- $export = grab_request_var('export', 0);
- $showonlygraphs = grab_request_var('showonlygraphs', 0);
- $showdetail = 1;
- if (($host == '') && ($service == '') && ($hostgroup == '') && ($servicegroup == '')) {
- $showdetail = 0;
- }
- $showdetail = grab_request_var('showdetail', $showdetail);
- get_times_from_report_timeperiod($reportperiod, $starttime, $endtime, $startdate, $enddate);
- $timeperiod = grab_request_var('timeperiod', '');
- $assumeinitialstates = grab_request_var('assumeinitialstates', 'yes');
- $assumestateretention = grab_request_var('assumestateretention', 'yes');
- $assumestatesduringdowntime = grab_request_var('assumestatesduringdowntime', 'yes');
- $includesoftstates = grab_request_var('includesoftstates', 'no');
- $assumedhoststate = grab_request_var('assumedhoststate', 3);
- $assumedservicestate = grab_request_var('assumedservicestate', 6);
- $advanced = (int) grab_request_var('advanced', 0);
- $disable_report_auto_run = get_option('disable_report_auto_run', 0);
- if ($service != '') {
- $title = _('Service SLA Report');
- }
- else if ($host != '') {
- $title = _('Host SLA Report');
- }
- else if ($hostgroup != '') {
- $title = _('Hostgroup SLA Report');
- }
- else if ($servicegroup != '') {
- $title = _('Servicegroup SLA Report');
- }
- else {
- $title = _('SLA Report');
- }
- $dashify = grab_request_var('dashify', 0);
- $dashtype = grab_request_var('dashtype', '');
- $auto_start_date = get_datetime_string(strtotime('yesterday'), DT_SHORT_DATE);
- $auto_end_date = get_datetime_string(strtotime('today'), DT_SHORT_DATE);
- if (isset($_SESSION['date_format'])) {
- $format = $_SESSION['date_format'];
- }
- else {
- if (is_null($format = get_user_meta(0, 'date_format'))) {
- $format = get_option('default_date_format');
- }
- }
- $f = get_date_formats();
- $js_date = 'mm/dd/yy';
- if ($format == DF_ISO8601) {
- $js_date = 'yy-mm-dd';
- }
- else if ($format == DF_US) {
- $js_date = 'mm/dd/yy';
- }
- else if ($format == DF_EURO) {
- $js_date = 'dd/mm/yy';
- }
- do_page_start(['page_title' => $title, 'enterprise' => true], true);
- make_enterprise_only_feature();
- echo "\n" . '<script type="text/javascript">' . "\n" . '$(document).ready(function () {' . "\n\n" . ' showhidedates();' . "\n\n" . ' // If we should run it right away' . "\n" . ' if (!';
- echo $disable_report_auto_run;
- echo ') {' . "\n" . ' run_sla_ajax();' . "\n" . ' }' . "\n\n" . ' $(\'#hostList\').searchable({maxMultiMatch: 9999});' . "\n" . ' $(\'#serviceList\').searchable({maxMultiMatch: 9999});' . "\n" . ' $(\'#hostgroupList\').searchable({maxMultiMatch: 9999});' . "\n" . ' $(\'#servicegroupList\').searchable({maxMultiMatch: 9999});' . "\n" . ' ' . "\n" . ' if ($(\'#serviceList\').is(\':visible\')) {' . "\n" . ' $(\'.serviceList-sbox\').show();' . "\n" . ' } else {' . "\n" . ' $(\'.serviceList-sbox\').hide();' . "\n" . ' }' . "\n\n" . ' $(\'.datetimepicker\').datetimepicker({' . "\n" . ' dateFormat: \'';
- echo $js_date;
- echo '\',' . "\n" . ' timeFormat: \'HH:mm:ss\',' . "\n" . ' showHour: true,' . "\n" . ' showMinute: true,' . "\n" . ' showSecond: true' . "\n" . ' });' . "\n\n" . ' $(\'.btn-datetimepicker\').click(function() {' . "\n" . ' var id = $(this).data(\'picker\');' . "\n" . ' $(\'#\' + id).datetimepicker(\'show\');' . "\n" . ' });' . "\n\n" . ' $(\'#startdateBox\').click(function () {' . "\n" . ' $(\'#reportperiodDropdown\').val(\'custom\');' . "\n" . ' if ($(\'#startdateBox\').val() == \'\' && $(\'#enddateBox\').val() == \'\') {' . "\n" . ' $(\'#startdateBox\').val(\'';
- echo $auto_start_date;
- echo '\');' . "\n" . ' $(\'#enddateBox\').val(\'';
- echo $auto_end_date;
- echo '\');' . "\n" . ' }' . "\n" . ' });' . "\n" . ' ' . "\n" . ' $(\'#enddateBox\').click(function () {' . "\n" . ' $(\'#reportperiodDropdown\').val(\'custom\');' . "\n" . ' if ($(\'#startdateBox\').val() == \'\' && $(\'#enddateBox\').val() == \'\') {' . "\n" . ' $(\'#startdateBox\').val(\'';
- echo $auto_start_date;
- echo '\');' . "\n" . ' $(\'#enddateBox\').val(\'';
- echo $auto_end_date;
- echo '\');' . "\n" . ' }' . "\n" . ' });' . "\n\n" . ' $(\'#reportperiodDropdown\').change(function () {' . "\n" . ' showhidedates();' . "\n" . ' });' . "\n\n" . ' $(\'#hostList\').change(function () {' . "\n" . ' $(\'#hostgroupList\').val(\'\');' . "\n" . ' $(\'#servicegroupList\').val(\'\');' . "\n\n" . ' if ($(this).val() != \'\') {' . "\n" . ' update_service_list();' . "\n" . ' $(\'#serviceList\').show();' . "\n" . ' $(\'.serviceList-sbox\').show();' . "\n" . ' } else {' . "\n" . ' $(\'#serviceList\').val(\'\').hide();' . "\n" . ' $(\'.serviceList-sbox\').hide();' . "\n" . ' }' . "\n" . ' });' . "\n\n" . ' $(\'#servicegroupList\').change(function () {' . "\n" . ' $(\'#hostList\').val(\'\');' . "\n" . ' $(\'#hostgroupList\').val(\'\');' . "\n" . ' $(\'#serviceList\').val(\'\').hide();' . "\n" . ' $(\'.serviceList-sbox\').hide();' . "\n" . ' });' . "\n\n" . ' $(\'#hostgroupList\').change(function () {' . "\n" . ' $(\'#servicegroupList\').val(\'\');' . "\n" . ' $(\'#hostList\').val(\'\');' . "\n" . ' $(\'#serviceList\').val(\'\').hide();' . "\n" . ' $(\'.serviceList-sbox\').hide();' . "\n" . ' });' . "\n\n" . ' // Add the ability to show the advanced options section' . "\n" . ' $(\'#advanced-options-btn\').click(function () {' . "\n" . ' if ($(\'#advanced-options\').is(":visible")) {' . "\n" . ' $(\'#advanced-options\').hide();' . "\n" . ' $(\'#advanced\').val(0);' . "\n" . ' $(\'#advanced-options-btn\').html(\'';
- echo _('Advanced');
- echo ' <i class="fa fa-chevron-up"></i>\');' . "\n" . ' } else {' . "\n" . ' $(\'#advanced-options\').show();' . "\n" . ' $(\'#advanced\').val(1);' . "\n" . ' $(\'#advanced-options-btn\').html(\'';
- echo _('Advanced');
- echo ' <i class="fa fa-chevron-down"></i>\');' . "\n" . ' }' . "\n" . ' });' . "\n\n" . ' // Actually return the report' . "\n" . ' $(\'#run\').click(function() {' . "\n" . ' run_sla_ajax();' . "\n" . ' });' . "\n\n" . ' // Get the export button link and send user to it' . "\n" . ' $(\'.btn-export\').on(\'mousedown\', function(e) {' . "\n" . ' var type = $(this).data(\'type\');' . "\n" . ' var formvalues = $("form").serialize();' . "\n" . ' var url = "';
- echo get_base_url();
- echo 'reports/sla.php?" + formvalues + "&mode=" + type;' . "\n" . ' if (e.which == 2) {' . "\n" . ' window.open(url);' . "\n" . ' } else if (e.which == 1) {' . "\n" . ' window.location = url;' . "\n" . ' }' . "\n" . ' });' . "\n\n" . '});' . "\n\n" . 'var report_sym = 0;' . "\n" . 'function run_sla_ajax() {' . "\n" . ' report_sym = 1;' . "\n" . ' setTimeout(\'show_loading_report()\', 500);' . "\n\n" . ' var formvalues = $("form").serialize();' . "\n" . ' formvalues += \'&mode=getreport\';' . "\n" . ' var url = \'sla.php?\'+formvalues;' . "\n\n" . ' $.get(url, {}, function(data) {' . "\n" . ' report_sym = 0;' . "\n" . ' hide_throbber();' . "\n" . ' $(\'#report\').html(data);' . "\n" . ' });' . "\n" . '}' . "\n" . '</script>' . "\n\n" . '<script type="text/javascript" src="';
- echo get_base_url();
- echo 'includes/js/reports.js?';
- echo get_build_id();
- echo '"></script>' . "\n\n" . '<form method="get" data-type="sla">' . "\n" . ' <div class="well report-options form-inline">' . "\n\n" . ' <input type="hidden" name="host" value="';
- echo encode_form_val($host);
- echo '">' . "\n" . ' <input type="hidden" name="showdetail" value="';
- echo encode_form_val($showdetail);
- echo '">' . "\n" . ' <input type="hidden" name="export" value="';
- echo (int) $export;
- echo '">' . "\n\n" . ' <div class="reportexportlinks">' . "\n" . ' ';
- echo get_add_myreport_html($title, $_SERVER['PHP_SELF'], []);
- echo ' <div class="btn-group">' . "\n" . ' <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">' . "\n" . ' ';
- echo _('Download');
- echo ' <i class="fa fa-caret-down r"></i>' . "\n" . ' </button>' . "\n" . ' <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">' . "\n" . ' <li><a class="btn-export" data-type="pdf" title="';
- echo _('Download as PDF');
- echo '"><i class="fa fa-file-pdf-o l"></i> ';
- echo _('PDF');
- echo '</a></li>' . "\n" . ' <li><a class="btn-export" data-type="jpg" title="';
- echo _('Download as JPG');
- echo '"><i class="fa fa-file-image-o l"></i> ';
- echo _('JPG');
- echo '</a></li>' . "\n" . ' </ul>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n\n" . ' <div class="reportoptionpicker">' . "\n\n" . ' <div class="input-group" style="margin-right: 10px;">' . "\n" . ' <label class="input-group-addon">';
- echo _('Period');
- echo '</label>' . "\n" . ' <select id="reportperiodDropdown" name="reportperiod" class="form-control">' . "\n" . ' ';
- $tp = get_report_timeperiod_options();
- foreach ($tp as $shortname => $longname) {
- echo '<option value=\'' . $shortname . '\' ' . is_selected($shortname, $reportperiod) . '>' . $longname . '</option>';
- }
- echo ' </select>' . "\n" . ' </div>' . "\n" . ' <div id="customdates" class="cal">' . "\n" . ' <div class="input-group" style="width: 450px; margin-right: 10px;">' . "\n" . ' <label class="input-group-addon">';
- echo _('From');
- echo '</label>' . "\n" . ' <input class="form-control datetimepicker" type="text" id=\'startdateBox\' name="startdate" value="';
- echo encode_form_val(get_datetime_from_timestring($startdate));
- echo '">' . "\n" . ' <div data-picker="startdateBox" class="input-group-btn btn btn-sm btn-default btn-datetimepicker">' . "\n" . ' <i class="fa fa-calendar fa-14"></i>' . "\n" . ' </div>' . "\n" . ' <label class="input-group-addon" style="border-left: 0; border-right: 0;">';
- echo _('to');
- echo '</label>' . "\n" . ' <input class="form-control datetimepicker" type="text" id=\'enddateBox\' name="enddate" value="';
- echo encode_form_val(get_datetime_from_timestring($enddate));
- echo '">' . "\n" . ' <div data-picker="enddateBox" class="input-group-btn btn btn-sm btn-default btn-datetimepicker">' . "\n" . ' <i class="fa fa-calendar fa-14"></i>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n\n" . ' <div class="input-group" style="margin-right: 10px;">' . "\n" . ' <label class="input-group-addon">';
- echo _('Limit To');
- echo '</label>' . "\n" . ' <select name="host" id="hostList" style="width: 150px;" class="form-control">' . "\n" . ' <option value="">';
- echo _('Host');
- echo ':</option>' . "\n" . ' ';
- $args = ['brevity' => 1, 'orderby' => 'host_name:a'];
- $oxml = get_xml_host_objects($args);
- if ($oxml) {
- foreach ($oxml->host as $hostobject) {
- $name = (string) $hostobject->host_name;
- echo '<option value=\'' . $name . '\' ' . is_selected($host, $name) . '>' . $name . '</option>' . "\n";
- }
- }
- echo ' </select>' . "\n" . ' <select name="service" id="serviceList" style="width: 200px; ';
- if (empty($service) && empty($host)) {
- echo 'display: none;';
- }
- echo '" class="form-control">' . "\n" . ' <option value="">[';
- echo _('All Services');
- echo ']</option>' . "\n" . ' ';
- $args = ['brevity' => 1, 'host_name' => $host, 'orderby' => 'service_description:a'];
- $oxml = get_xml_service_objects($args);
- if ($oxml) {
- foreach ($oxml->service as $serviceobj) {
- $name = (string) $serviceobj->service_description;
- echo '<option value=\'' . $name . '\' ' . is_selected($service, $name) . '>' . $name . '</option>' . "\n";
- }
- }
- echo ' </select>' . "\n" . ' <select name="hostgroup" id="hostgroupList" style="width: 150px;" class="form-control">' . "\n" . ' <option value="">';
- echo _('Hostgroup');
- echo ':</option>' . "\n" . ' ';
- $args = ['orderby' => 'hostgroup_name:a'];
- $oxml = get_xml_hostgroup_objects($args);
- if ($oxml) {
- foreach ($oxml->hostgroup as $hg) {
- $name = (string) $hg->hostgroup_name;
- echo '<option value=\'' . $name . '\' ' . is_selected($hostgroup, $name) . '>' . $name . '</option>' . "\n";
- }
- }
- echo ' </select>' . "\n" . ' <select name="servicegroup" id="servicegroupList" style="width: 150px;" class="form-control">' . "\n" . ' <option value="">';
- echo _('Servicegroup');
- echo ':</option>' . "\n" . ' ';
- $args = ['orderby' => 'servicegroup_name:a'];
- $oxml = get_xml_servicegroup_objects($args);
- if ($oxml) {
- foreach ($oxml->servicegroup as $sg) {
- $name = (string) $sg->servicegroup_name;
- echo '<option value=\'' . $name . '\' ' . is_selected($servicegroup, $name) . '>' . $name . '</option>' . "\n";
- }
- }
- echo ' </select>' . "\n" . ' </div>' . "\n\n" . ' <div class="input-group" style="margin-right: 10px;">' . "\n" . ' <label class="input-group-addon">';
- echo _('SLA Target');
- echo '</label>' . "\n" . ' <input class="textfield form-control" style="width: 60px;" type="text" id="slalevelBox" name="slalevel" value="';
- echo (double) $slalevel;
- echo '">' . "\n" . ' <label class="input-group-addon">%</label>' . "\n" . ' </div>' . "\n\n" . ' <a id="advanced-options-btn" class="tt-bind" data-placement="bottom" title="';
- echo _('Toggle advanced options');
- echo '">';
- echo _('Advanced');
- echo ' ';
- if (!$advanced) {
- echo '<i class="fa fa-chevron-up"></i>';
- }
- else {
- echo '<i class="fa fa-chevron-down"></i>';
- }
- echo '</a>' . "\n" . ' <input type="hidden" value="';
- echo $advanced;
- echo '" id="advanced" name="advanced">' . "\n\n" . ' <button type="button" id="run" class="btn btn-sm btn-primary" name="reporttimesubmitbutton">';
- echo _('Run');
- echo '</button>' . "\n\n" . ' </div>' . "\n\n" . ' <div id="advanced-options" style="';
- if (!$advanced) {
- .........................................................................
- ...............................................
- ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement