Example #1
0
                    if (isset($_GET['warning']) && is_numeric($_GET['warning'])) {
                        $items["warning"] = $_GET['warning'];
                    }
                    if (isset($_GET['critical']) && is_numeric($_GET['critical'])) {
                        $items["critical"] = $_GET['critical'];
                    }
                    $view['items'][] = $items;
                } else {
                    $view['items'][] = array("hostname" => $_GET['host_name'], "graph" => $_GET['metric_name']);
                }
            }
            $view_filename = $view['file_name'];
            // Remove the file_name attribute, it is not stored in the view defn.
            unset($view['file_name']);
            $json = json_encode($view);
            if (file_put_contents($view_filename, json_prettyprint($json)) === FALSE) {
                $output = "<strong>Alert:</strong>" . " Can't write to file: \"{$view_filename}\"." . " Perhaps permissions are wrong.";
            } else {
                $output = "View has been updated successfully.";
            }
        }
    }
    ?>
<div class="ui-widget">
  <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
    <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
    <?php 
    echo $output;
    ?>
</p>
  </div>
            case "included":
                # Check if report is already included by default
                if (!in_array($report_name, $default_reports["included_reports"])) {
                    $reports["included_reports"][] = $report_name;
                }
                break;
            case "excluded":
                if (!in_array($report_name, $default_reports["excluded_reports"])) {
                    $reports["excluded_reports"][] = $report_name;
                }
                break;
        }
    }
    if (isset($reports) && is_array($reports)) {
        $json = json_encode($reports);
        if (file_put_contents($override_file, json_prettyprint($json)) === FALSE) {
            ?>
    <div class="ui-widget">
              <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
                  <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
                  <strong>Alert:</strong> Can't write to file <?php 
            print $override_file;
            ?>
. Perhaps permissions are wrong.</p>
              </div>
    </div>
  <?php 
        } else {
            ?>
      <div class="ui-widget">
              <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;">