Advertisement
Guest User

Untitled

a guest
Jan 14th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.46 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for SourceGuardian Encoder)
  6. *
  7. * @ Version : 4.0.8.2
  8. * @ Author : DeZender
  9. * @ Release on : 02.01.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. function route_request()
  15. {
  16. $host = grab_request_var('host', '');
  17. $service = grab_request_var('service', '');
  18. $hostgroup = grab_request_var('hostgroup', '');
  19. $servicegroup = grab_request_var('servicegroup', '');
  20. $auth = true;
  21. if (($service != '') && ($service != 'average')) {
  22. $auth = is_authorized_for_service(0, $host, $service);
  23. }
  24. else if ($host != '') {
  25. $auth = is_authorized_for_host(0, $host);
  26. }
  27. else if ($hostgroup != '') {
  28. $auth = is_authorized_for_hostgroup(0, $hostgroup);
  29. }
  30. else if ($servicegroup != '') {
  31. $auth = is_authorized_for_servicegroup(0, $servicegroup);
  32. }
  33.  
  34. if (!$auth) {
  35. echo _('ERROR: You are not authorized to view this report.');
  36. exit();
  37. }
  38.  
  39. $mode = grab_request_var('mode', '');
  40.  
  41. switch ($mode) {
  42. case 'pdf':
  43. export_report('sla', EXPORT_PDF);
  44. break;
  45. case 'jpg':
  46. export_report('sla', EXPORT_JPG);
  47. break;
  48. case 'getservices':
  49. $host = grab_request_var('host', '');
  50. $args = ['brevity' => 1, 'host_name' => $host, 'orderby' => 'service_description:a'];
  51. $oxml = get_xml_service_objects($args);
  52. echo '<option value="">[' . _('All Services') . ']</option>';
  53.  
  54. if ($oxml) {
  55. foreach ($oxml->service as $serviceobj) {
  56. $name = (string) $serviceobj->service_description;
  57. echo '<option value=\'' . $name . '\' ' . is_selected($service, $name) . '>' . $name . '</option>' . "\n";
  58. }
  59. }
  60.  
  61. break;
  62. case 'getreport':
  63. get_sla_report();
  64. break;
  65. default:
  66. display_sla_report();
  67. break;
  68. }
  69. }
  70.  
  71. function get_availability_data($type = 'host', $args, &$data)
  72. {
  73. $data = get_xml_availability($type, $args);
  74. return true;
  75. }
  76.  
  77. function display_sla_report()
  78. {
  79. global $request;
  80. licensed_feature_check();
  81. $reportperiod = grab_request_var('reportperiod', 'last24hours');
  82. $startdate = grab_request_var('startdate', '');
  83. $enddate = grab_request_var('enddate', '');
  84. $host = grab_request_var('host', '');
  85. $service = grab_request_var('service', '');
  86. $hostgroup = grab_request_var('hostgroup', '');
  87. $servicegroup = grab_request_var('servicegroup', '');
  88. $slalevel = grab_request_var('slalevel', 95);
  89. $dont_count_downtime = checkbox_binary(grab_request_var('dont_count_downtime', 0));
  90. $dont_count_warning = checkbox_binary(grab_request_var('dont_count_warning', 0));
  91. $dont_count_unknown = checkbox_binary(grab_request_var('dont_count_unknown', 0));
  92. $export = grab_request_var('export', 0);
  93. $showonlygraphs = grab_request_var('showonlygraphs', 0);
  94. $showdetail = 1;
  95. if (($host == '') && ($service == '') && ($hostgroup == '') && ($servicegroup == '')) {
  96. $showdetail = 0;
  97. }
  98.  
  99. $showdetail = grab_request_var('showdetail', $showdetail);
  100. get_times_from_report_timeperiod($reportperiod, $starttime, $endtime, $startdate, $enddate);
  101. $timeperiod = grab_request_var('timeperiod', '');
  102. $assumeinitialstates = grab_request_var('assumeinitialstates', 'yes');
  103. $assumestateretention = grab_request_var('assumestateretention', 'yes');
  104. $assumestatesduringdowntime = grab_request_var('assumestatesduringdowntime', 'yes');
  105. $includesoftstates = grab_request_var('includesoftstates', 'no');
  106. $assumedhoststate = grab_request_var('assumedhoststate', 3);
  107. $assumedservicestate = grab_request_var('assumedservicestate', 6);
  108. $advanced = (int) grab_request_var('advanced', 0);
  109. $disable_report_auto_run = get_option('disable_report_auto_run', 0);
  110.  
  111. if ($service != '') {
  112. $title = _('Service SLA Report');
  113. }
  114. else if ($host != '') {
  115. $title = _('Host SLA Report');
  116. }
  117. else if ($hostgroup != '') {
  118. $title = _('Hostgroup SLA Report');
  119. }
  120. else if ($servicegroup != '') {
  121. $title = _('Servicegroup SLA Report');
  122. }
  123. else {
  124. $title = _('SLA Report');
  125. }
  126.  
  127. $dashify = grab_request_var('dashify', 0);
  128. $dashtype = grab_request_var('dashtype', '');
  129. $auto_start_date = get_datetime_string(strtotime('yesterday'), DT_SHORT_DATE);
  130. $auto_end_date = get_datetime_string(strtotime('today'), DT_SHORT_DATE);
  131.  
  132. if (isset($_SESSION['date_format'])) {
  133. $format = $_SESSION['date_format'];
  134. }
  135. else {
  136. if (is_null($format = get_user_meta(0, 'date_format'))) {
  137. $format = get_option('default_date_format');
  138. }
  139. }
  140.  
  141. $f = get_date_formats();
  142. $js_date = 'mm/dd/yy';
  143.  
  144. if ($format == DF_ISO8601) {
  145. $js_date = 'yy-mm-dd';
  146. }
  147. else if ($format == DF_US) {
  148. $js_date = 'mm/dd/yy';
  149. }
  150. else if ($format == DF_EURO) {
  151. $js_date = 'dd/mm/yy';
  152. }
  153.  
  154. do_page_start(['page_title' => $title, 'enterprise' => true], true);
  155. make_enterprise_only_feature();
  156. echo "\n" . '<script type="text/javascript">' . "\n" . '$(document).ready(function () {' . "\n\n" . ' showhidedates();' . "\n\n" . ' // If we should run it right away' . "\n" . ' if (!';
  157. echo $disable_report_auto_run;
  158. 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: \'';
  159. echo $js_date;
  160. 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(\'';
  161. echo $auto_start_date;
  162. echo '\');' . "\n" . ' $(\'#enddateBox\').val(\'';
  163. echo $auto_end_date;
  164. echo '\');' . "\n" . ' }' . "\n" . ' });' . "\n" . ' ' . "\n" . ' $(\'#enddateBox\').click(function () {' . "\n" . ' $(\'#reportperiodDropdown\').val(\'custom\');' . "\n" . ' if ($(\'#startdateBox\').val() == \'\' && $(\'#enddateBox\').val() == \'\') {' . "\n" . ' $(\'#startdateBox\').val(\'';
  165. echo $auto_start_date;
  166. echo '\');' . "\n" . ' $(\'#enddateBox\').val(\'';
  167. echo $auto_end_date;
  168. 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(\'';
  169. echo _('Advanced');
  170. echo ' <i class="fa fa-chevron-up"></i>\');' . "\n" . ' } else {' . "\n" . ' $(\'#advanced-options\').show();' . "\n" . ' $(\'#advanced\').val(1);' . "\n" . ' $(\'#advanced-options-btn\').html(\'';
  171. echo _('Advanced');
  172. 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 = "';
  173. echo get_base_url();
  174. 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="';
  175. echo get_base_url();
  176. echo 'includes/js/reports.js?';
  177. echo get_build_id();
  178. 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="';
  179. echo encode_form_val($host);
  180. echo '">' . "\n" . ' <input type="hidden" name="showdetail" value="';
  181. echo encode_form_val($showdetail);
  182. echo '">' . "\n" . ' <input type="hidden" name="export" value="';
  183. echo (int) $export;
  184. echo '">' . "\n\n" . ' <div class="reportexportlinks">' . "\n" . ' ';
  185. echo get_add_myreport_html($title, $_SERVER['PHP_SELF'], []);
  186. echo ' <div class="btn-group">' . "\n" . ' <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">' . "\n" . ' ';
  187. echo _('Download');
  188. 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="';
  189. echo _('Download as PDF');
  190. echo '"><i class="fa fa-file-pdf-o l"></i> ';
  191. echo _('PDF');
  192. echo '</a></li>' . "\n" . ' <li><a class="btn-export" data-type="jpg" title="';
  193. echo _('Download as JPG');
  194. echo '"><i class="fa fa-file-image-o l"></i> ';
  195. echo _('JPG');
  196. 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">';
  197. echo _('Period');
  198. echo '</label>' . "\n" . ' <select id="reportperiodDropdown" name="reportperiod" class="form-control">' . "\n" . ' ';
  199. $tp = get_report_timeperiod_options();
  200.  
  201. foreach ($tp as $shortname => $longname) {
  202. echo '<option value=\'' . $shortname . '\' ' . is_selected($shortname, $reportperiod) . '>' . $longname . '</option>';
  203. }
  204.  
  205. 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">';
  206. echo _('From');
  207. echo '</label>' . "\n" . ' <input class="form-control datetimepicker" type="text" id=\'startdateBox\' name="startdate" value="';
  208. echo encode_form_val(get_datetime_from_timestring($startdate));
  209. 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;">';
  210. echo _('to');
  211. echo '</label>' . "\n" . ' <input class="form-control datetimepicker" type="text" id=\'enddateBox\' name="enddate" value="';
  212. echo encode_form_val(get_datetime_from_timestring($enddate));
  213. 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">';
  214. echo _('Limit To');
  215. echo '</label>' . "\n" . ' <select name="host" id="hostList" style="width: 150px;" class="form-control">' . "\n" . ' <option value="">';
  216. echo _('Host');
  217. echo ':</option>' . "\n" . ' ';
  218. $args = ['brevity' => 1, 'orderby' => 'host_name:a'];
  219. $oxml = get_xml_host_objects($args);
  220.  
  221. if ($oxml) {
  222. foreach ($oxml->host as $hostobject) {
  223. $name = (string) $hostobject->host_name;
  224. echo '<option value=\'' . $name . '\' ' . is_selected($host, $name) . '>' . $name . '</option>' . "\n";
  225. }
  226. }
  227.  
  228. echo ' </select>' . "\n" . ' <select name="service" id="serviceList" style="width: 200px; ';
  229. if (empty($service) && empty($host)) {
  230. echo 'display: none;';
  231. }
  232.  
  233. echo '" class="form-control">' . "\n" . ' <option value="">[';
  234. echo _('All Services');
  235. echo ']</option>' . "\n" . ' ';
  236. $args = ['brevity' => 1, 'host_name' => $host, 'orderby' => 'service_description:a'];
  237. $oxml = get_xml_service_objects($args);
  238.  
  239. if ($oxml) {
  240. foreach ($oxml->service as $serviceobj) {
  241. $name = (string) $serviceobj->service_description;
  242. echo '<option value=\'' . $name . '\' ' . is_selected($service, $name) . '>' . $name . '</option>' . "\n";
  243. }
  244. }
  245.  
  246. echo ' </select>' . "\n" . ' <select name="hostgroup" id="hostgroupList" style="width: 150px;" class="form-control">' . "\n" . ' <option value="">';
  247. echo _('Hostgroup');
  248. echo ':</option>' . "\n" . ' ';
  249. $args = ['orderby' => 'hostgroup_name:a'];
  250. $oxml = get_xml_hostgroup_objects($args);
  251.  
  252. if ($oxml) {
  253. foreach ($oxml->hostgroup as $hg) {
  254. $name = (string) $hg->hostgroup_name;
  255. echo '<option value=\'' . $name . '\' ' . is_selected($hostgroup, $name) . '>' . $name . '</option>' . "\n";
  256. }
  257. }
  258.  
  259. echo ' </select>' . "\n" . ' <select name="servicegroup" id="servicegroupList" style="width: 150px;" class="form-control">' . "\n" . ' <option value="">';
  260. echo _('Servicegroup');
  261. echo ':</option>' . "\n" . ' ';
  262. $args = ['orderby' => 'servicegroup_name:a'];
  263. $oxml = get_xml_servicegroup_objects($args);
  264.  
  265. if ($oxml) {
  266. foreach ($oxml->servicegroup as $sg) {
  267. $name = (string) $sg->servicegroup_name;
  268. echo '<option value=\'' . $name . '\' ' . is_selected($servicegroup, $name) . '>' . $name . '</option>' . "\n";
  269. }
  270. }
  271.  
  272. echo ' </select>' . "\n" . ' </div>' . "\n\n" . ' <div class="input-group" style="margin-right: 10px;">' . "\n" . ' <label class="input-group-addon">';
  273. echo _('SLA Target');
  274. echo '</label>' . "\n" . ' <input class="textfield form-control" style="width: 60px;" type="text" id="slalevelBox" name="slalevel" value="';
  275. echo (double) $slalevel;
  276. echo '">' . "\n" . ' <label class="input-group-addon">%</label>' . "\n" . ' </div>' . "\n\n" . ' <a id="advanced-options-btn" class="tt-bind" data-placement="bottom" title="';
  277. echo _('Toggle advanced options');
  278. echo '">';
  279. echo _('Advanced');
  280. echo ' ';
  281.  
  282. if (!$advanced) {
  283. echo '<i class="fa fa-chevron-up"></i>';
  284. }
  285. else {
  286. echo '<i class="fa fa-chevron-down"></i>';
  287. }
  288.  
  289. echo '</a>' . "\n" . ' <input type="hidden" value="';
  290. echo $advanced;
  291. echo '" id="advanced" name="advanced">' . "\n\n" . ' <button type="button" id="run" class="btn btn-sm btn-primary" name="reporttimesubmitbutton">';
  292. echo _('Run');
  293. echo '</button>' . "\n\n" . ' </div>' . "\n\n" . ' <div id="advanced-options" style="';
  294.  
  295. if (!$advanced) {
  296. .........................................................................
  297. ...............................................
  298. ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement