Ejemplo n.º 1
0
function flowview_gettimespan()
{
    global $config;
    include_once $config['base_path'] . '/lib/time.php';
    $timespan = get_filter_request_var('timespan');
    $date1 = get_nfilter_request_var('date1');
    $date2 = get_nfilter_request_var('date2');
    $span = array();
    if ($timespan > 0) {
        get_timespan($span, time(), $timespan, read_user_setting('first_weekdayid'));
    } else {
        $span['current_value_date1'] = $date1;
        $span['current_value_date2'] = $date2;
        $span['begin_now'] = strtotime($date1);
        $span['end_now'] = strtotime($date2);
    }
    print json_encode($span);
}
Ejemplo n.º 2
0
function set_preset_timespan(&$timespan)
{
    # no current timespan: get default timespan
    if (!isset($_SESSION["sess_current_timespan"]) || read_graph_config_option("timespan_sel") == "") {
        $_SESSION["sess_current_timespan"] = read_graph_config_option("default_timespan");
    }
    # get config option for first-day-of-the-week
    $first_weekdayid = read_graph_config_option("first_weekdayid");
    # get start/end time-since-epoch for actual time (now()) and given current-session-timespan
    get_timespan($timespan, time(), $_SESSION["sess_current_timespan"], $first_weekdayid);
    $_SESSION["custom"] = 0;
}
Ejemplo n.º 3
0
$graphpp = get_request_var('graphs');
$cols = get_request_var('cols');
$filter = get_request_var('filter');
$id = get_request_var('id');
$width = get_request_var('width');
$height = get_request_var('height');
if (empty($tree_id)) {
    $tree_id = db_fetch_cell('SELECT id FROM graph_tree ORDER BY name LIMIT 1');
}
if (empty($id)) {
    $id = -1;
}
/* get the start and end times for the graph */
$timespan = array();
$first_weekdayid = read_user_setting('first_weekdayid');
get_timespan($timespan, time(), get_request_var('timespan'), $first_weekdayid);
$graph_tree = $tree_id;
$html = '';
$out = '';
/* detect the next graph regardless of type */
get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id);
switch (read_config_option('cycle_custom_graphs_type')) {
    case '0':
    case '1':
        /* will only use the filter for full rotation */
        break;
    case '2':
        $tree_list = get_graph_tree_array();
        if (sizeof($tree_list)) {
            $html = "<td><select id='tree_id' name='tree_id' onChange='newTree()' title='" . __('Select Tree to View') . "'>\n";
            foreach ($tree_list as $tree) {
Ejemplo n.º 4
0
/**
 * expand a tree for including into report
 * @param array $report		- parameters for this report mail report
 * @param int $item			- current graph item
 * @param int $output		- type of output
 * @param bool $format_ok	- use css styling
 * @param bool $nested		- nested tree?
 * @return string			- html
 */
function reports_expand_tree($report, $item, $output, $format_ok, $nested = false)
{
    global $colors, $config, $alignment;
    include $config["include_path"] . "/global_arrays.php";
    include_once $config["library_path"] . "/data_query.php";
    include_once $config["library_path"] . "/tree.php";
    include_once $config["library_path"] . "/html_tree.php";
    include_once $config["library_path"] . "/html_utility.php";
    $tree_id = $item["tree_id"];
    $leaf_id = $item["branch_id"];
    $time = time();
    # get config option for first-day-of-the-week
    $first_weekdayid = read_graph_config_option("first_weekdayid");
    /* check if we have enough data */
    if (isset($_SESSION["sess_current_user"])) {
        $current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . $_SESSION["sess_user_id"]);
    } else {
        $current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . $report["user_id"]);
    }
    /*todo*/
    $host_group_data = "";
    $timespan = array();
    # get start/end time-since-epoch for actual time (now()) and given current-session-timespan
    get_timespan($timespan, $time, $item["timespan"], $first_weekdayid);
    if (empty($tree_id)) {
        return;
    }
    $sql_where = "";
    $sql_join = "";
    $title = "";
    $title_delimeter = "";
    $search_key = "";
    $outstr = "";
    $leaf = db_fetch_row("SELECT order_key, title, host_id, host_grouping_type FROM graph_tree_items WHERE id={$leaf_id}");
    $leaf_type = get_tree_item_type($leaf_id);
    /* get the "starting leaf" if the user clicked on a specific branch */
    if (!empty($leaf_id)) {
        $search_key = substr($leaf["order_key"], 0, tree_tier($leaf["order_key"]) * CHARS_PER_TIER);
    }
    /* graph permissions */
    if (read_config_option("auth_method") != 0) {
        /* get policy information for the sql where clause */
        $sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
        $sql_where = empty($sql_where) ? "" : "AND {$sql_where}";
        $sql_join = "\n\t\t\tLEFT JOIN host ON (host.id=graph_local.host_id)\n\t\t\tLEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\n\t\t\tLEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id AND user_auth_perms.type=1 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 and user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
    }
    /* get information for the headers */
    if (!empty($tree_id)) {
        $tree_name = db_fetch_cell("SELECT name FROM graph_tree WHERE id={$tree_id}");
    }
    if (!empty($leaf_id)) {
        $leaf_name = $leaf["title"];
    }
    if (!empty($leaf_id)) {
        $host_name = db_fetch_cell("SELECT host.description FROM (graph_tree_items,host) WHERE graph_tree_items.host_id=host.id AND graph_tree_items.id={$leaf_id}");
    }
    $host_group_data_array = explode(":", $host_group_data);
    if ($host_group_data_array[0] == "graph_template") {
        $host_group_data_name = "<strong>Graph Template:</strong> " . db_fetch_cell("SELECT name FROM graph_templates WHERE id=" . $host_group_data_array[1]) . "</td></tr>";
        $graph_template_id = $host_group_data_array[1];
    } elseif ($host_group_data_array[0] == "data_query") {
        $host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("SELECT name FROM snmp_query WHERE id=" . $host_group_data_array[1])) . "</td></tr>";
        $data_query_id = $host_group_data_array[1];
    } elseif ($host_group_data_array[0] == "data_query_index") {
        $host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("SELECT name FROM snmp_query WHERE id=" . $host_group_data_array[1])) . "-> " . (empty($host_group_data_array[2]) ? "Template Based" : get_formatted_data_query_index($leaf["host_id"], $host_group_data_array[1], $host_group_data_array[2])) . "</td></tr>";
        $data_query_id = $host_group_data_array[1];
        $data_query_index = $host_group_data_array[2];
    }
    if (!empty($tree_name) && empty($leaf_name) && empty($host_name) && !$nested) {
        $title .= $title_delimeter . "<strong>Tree:</strong> {$tree_name}";
        $title_delimeter = "-> ";
    } elseif (!empty($leaf_name)) {
        $title .= $title_delimeter . "<strong>Leaf:</strong> {$leaf_name}";
        $title_delimeter = "-> ";
    } elseif (!empty($host_name)) {
        $title .= $title_delimeter . "<strong>Host:</strong> {$host_name}";
        $title_delimeter = "-> ";
    } elseif (!empty($host_group_data_name)) {
        $title .= $title_delimeter . " {$host_group_data_name}";
        $title_delimeter = "-> ";
    }
    if (isset($_REQUEST["tree_id"])) {
        $nodeid = "tree_" . $_REQUEST["tree_id"];
    }
    if (isset($_REQUEST["leaf_id"])) {
        $nodeid .= "_leaf" . $_REQUEST["leaf_id"];
    }
    /* start graph display */
    if (strlen($title)) {
        $outstr .= "\t\t<tr class='text_row'>\n";
        if ($format_ok) {
            $outstr .= "\t\t\t<td class='text' align='" . $alignment[$item["align"]] . "'>\n";
        } else {
            $outstr .= "\t\t\t<td class='text' align='" . $alignment[$item["align"]] . "' style='font-size: " . $item["font_size"] . "pt;'>\n";
        }
        $outstr .= "\t\t\t\t{$title}\n";
        $outstr .= "\t\t\t</td>\n";
        $outstr .= "\t\t</tr>\n";
    }
    if (strlen($item["graph_name_regexp"])) {
        $sql_where .= " AND title_cache REGEXP '" . $item["graph_name_regexp"] . "'";
    }
    if ($leaf_type == "header" || empty($leaf_id)) {
        $heirarchy = db_fetch_assoc("SELECT\n\t\t\tgraph_tree_items.local_graph_id\n\t\t\tFROM (graph_tree_items,graph_local)\n\t\t\tLEFT JOIN graph_templates_graph ON (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id AND graph_tree_items.local_graph_id>0)\n\t\t\t{$sql_join}\n\t\t\tWHERE graph_tree_items.graph_tree_id={$tree_id}\n\t\t\tAND graph_local.id=graph_templates_graph.local_graph_id\n\t\t\tAND graph_tree_items.order_key like '{$search_key}" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', MAX_TREE_DEPTH * CHARS_PER_TIER - (strlen($search_key) + CHARS_PER_TIER)) . "'\n\t\t\tAND graph_tree_items.local_graph_id>0\n\t\t\t{$sql_where}\n\t\t\tGROUP BY graph_tree_items.id\n\t\t\tORDER BY graph_tree_items.order_key");
        $outstr .= reports_graph_area($heirarchy, $report, $item, $timespan, $output, $format_ok);
    } elseif ($leaf_type == "host") {
        /* graph template grouping */
        if ($leaf["host_grouping_type"] == HOST_GROUPING_GRAPH_TEMPLATE) {
            $graph_templates = db_fetch_assoc("SELECT\n\t\t\t\tgraph_templates.id,\n\t\t\t\tgraph_templates.name\n\t\t\t\tFROM (graph_local,graph_templates,graph_templates_graph)\n\t\t\t\tWHERE graph_local.id=graph_templates_graph.local_graph_id\n\t\t\t\tAND graph_templates_graph.graph_template_id=graph_templates.id\n\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t" . (empty($graph_template_id) ? "" : "AND graph_templates.id={$graph_template_id}") . "\n\t\t\t\tGROUP BY graph_templates.id\n\t\t\t\tORDER BY graph_templates.name");
            /* for graphs without a template */
            array_push($graph_templates, array("id" => "0", "name" => "(No Graph Template)"));
            $outgraphs = array();
            if (sizeof($graph_templates) > 0) {
                foreach ($graph_templates as $graph_template) {
                    $graphs = db_fetch_assoc("SELECT\n\t\t\t\t\t\tgraph_templates_graph.title_cache,\n\t\t\t\t\t\tgraph_templates_graph.local_graph_id\n\t\t\t\t\t\tFROM (graph_local,graph_templates_graph)\n\t\t\t\t\t\t{$sql_join}\n\t\t\t\t\t\tWHERE graph_local.id=graph_templates_graph.local_graph_id\n\t\t\t\t\t\tAND graph_local.graph_template_id=" . $graph_template["id"] . "\n\t\t\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t\t\t{$sql_where}\n\t\t\t\t\t\tORDER BY graph_templates_graph.title_cache");
                    $outgraphs = array_merge($outgraphs, $graphs);
                }
                if (sizeof($outgraphs) > 0) {
                    /* let's sort the graphs naturally */
                    usort($outgraphs, 'necturally_sort_graphs');
                    $outstr .= reports_graph_area($outgraphs, $report, $item, $timespan, $output, $format_ok);
                }
            }
            /* data query index grouping */
        } elseif ($leaf["host_grouping_type"] == HOST_GROUPING_DATA_QUERY_INDEX) {
            $data_queries = db_fetch_assoc("SELECT\n\t\t\t\tsnmp_query.id,\n\t\t\t\tsnmp_query.name\n\t\t\t\tFROM (graph_local,snmp_query)\n\t\t\t\tWHERE graph_local.snmp_query_id=snmp_query.id\n\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t" . (!isset($data_query_id) ? "" : "AND snmp_query.id={$data_query_id}") . "\n\t\t\t\tGROUP BY snmp_query.id\n\t\t\t\tORDER BY snmp_query.name");
            /* for graphs without a data query */
            if (empty($data_query_id)) {
                array_push($data_queries, array("id" => "0", "name" => "Non Query Based"));
            }
            if (sizeof($data_queries) > 0) {
                foreach ($data_queries as $data_query) {
                    /* fetch a list of field names that are sorted by the preferred sort field */
                    $sort_field_data = get_formatted_data_query_indexes($leaf["host_id"], $data_query["id"]);
                    /* grab a list of all graphs for this host/data query combination */
                    $graphs = db_fetch_assoc("SELECT\n\t\t\t\t\tgraph_templates_graph.title_cache,\n\t\t\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\t\t\tgraph_local.snmp_index\n\t\t\t\t\tFROM (graph_local,graph_templates_graph)\n\t\t\t\t\t{$sql_join}\n\t\t\t\t\tWHERE graph_local.id=graph_templates_graph.local_graph_id\n\t\t\t\t\tAND graph_local.snmp_query_id=" . $data_query["id"] . "\n\t\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t\t" . (empty($data_query_index) ? "" : "AND graph_local.snmp_index='{$data_query_index}'") . "\n\t\t\t\t\t{$sql_where}\n\t\t\t\t\tGROUP BY graph_templates_graph.local_graph_id\n\t\t\t\t\tORDER BY graph_templates_graph.title_cache");
                    /* re-key the results on data query index */
                    if (sizeof($graphs) > 0) {
                        $outstr .= "\t\t<tr class='text_row'>\n";
                        if ($format_ok) {
                            $outstr .= "\t\t\t<td class='text' align='" . $alignment[$item["align"]] . "'><strong>Data Query:</strong> " . $data_query["name"] . "\n";
                            $outstr .= "\t\t\t</td>\n";
                            $outstr .= "\t\t</tr>\n";
                        } else {
                            $outstr .= "\t\t\t<td class='text' align='" . $alignment[$item["align"]] . "' style='font-size: " . $item["font_size"] . "pt;'><strong>Data Query:</strong> " . $data_query["name"] . "\n";
                            $outstr .= "\t\t\t</td>\n";
                            $outstr .= "\t\t</tr>\n";
                        }
                        /* let's sort the graphs naturally */
                        usort($graphs, 'necturally_sort_graphs');
                        foreach ($graphs as $graph) {
                            $snmp_index_to_graph[$graph["snmp_index"]][$graph["local_graph_id"]] = $graph["title_cache"];
                        }
                    }
                    /* using the sorted data as they key; grab each snmp index from the master list */
                    $graph_list = array();
                    while (list($snmp_index, $sort_field_value) = each($sort_field_data)) {
                        /* render each graph for the current data query index */
                        if (isset($snmp_index_to_graph[$snmp_index])) {
                            while (list($local_graph_id, $graph_title) = each($snmp_index_to_graph[$snmp_index])) {
                                /* reformat the array so it's compatable with the html_graph* area functions */
                                array_push($graph_list, array("local_graph_id" => $local_graph_id, "title_cache" => $graph_title));
                            }
                        }
                    }
                    if (sizeof($graph_list)) {
                        $outstr .= reports_graph_area($graph_list, $report, $item, $timespan, $output, $format_ok);
                    }
                }
            }
        }
    }
    return $outstr;
}
Ejemplo n.º 5
0
function reports_item_edit()
{
    global $config;
    global $fields_reports_item_edit;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    input_validate_input_number(get_request_var_request('item_id'));
    input_validate_input_number(get_request_var_request('item_type'));
    input_validate_input_number(get_request_var_request('branch_id'));
    input_validate_input_number(get_request_var_request('tree_id'));
    input_validate_input_number(get_request_var_request('host_id'));
    input_validate_input_number(get_request_var_request('host_template_id'));
    input_validate_input_number(get_request_var_request('graph_template_id'));
    /* ==================================================== */
    # fetch the current report record
    $report = db_fetch_row('SELECT *
		FROM reports 
		WHERE id=' . get_request_var_request('id'));
    # if an existing item was requested, fetch data for it
    if (isset($_REQUEST['item_id']) && $_REQUEST['item_id'] > 0) {
        $reports_item = db_fetch_row('SELECT *
			FROM reports_items
			WHERE id=' . get_request_var_request('item_id'));
        $header_label = '[edit Report Item: ' . $report['name'] . ']';
    } else {
        $header_label = '[new Report Item: ' . $report['name'] . ']';
        $reports_item = array();
        $reports_item['report_id'] = get_request_var_request('id');
        $reports_item['sequence'] = get_sequence('', 'sequence', 'reports_items', 'report_id=' . get_request_var_request('id'));
        $reports_item['host_id'] = REPORTS_HOST_NONE;
    }
    # if a different host_template_id was selected, use it
    if (get_request_var_request('item_type', '') !== '') {
        $reports_item['item_type'] = get_request_var_request('item_type');
    }
    if (get_request_var_request('tree_id', '') !== '') {
        $reports_item['tree_id'] = get_request_var_request('tree_id');
    } else {
        if (!isset($reports_item['tree_id'])) {
            $reports_item['tree_id'] = 0;
        }
    }
    if (get_request_var_request('host_template_id', '') !== '') {
        $reports_item['host_template_id'] = get_request_var_request('host_template_id');
    } else {
        if (!isset($reports_item['host_template_id'])) {
            $reports_item['host_template_id'] = 0;
        }
    }
    # if a different host_id was selected, use it
    if (get_request_var_request('host_id', '') !== '') {
        $reports_item['host_id'] = get_request_var_request('host_id');
    }
    # if a different graph_template_id was selected, use it
    if (get_request_var_request('graph_template_id', '') !== '') {
        $reports_item['graph_template_id'] = get_request_var_request('graph_template_id');
    } else {
        if (!isset($reports_item['graph_template_id'])) {
            $reports_item['graph_template_id'] = 0;
        }
    }
    load_current_session_value('host_template_id', 'sess_reports_edit_host_template_id', 0);
    load_current_session_value('host_id', 'sess_reports_edit_host_id', 0);
    load_current_session_value('tree_id', 'sess_reports_edit_tree_id', 0);
    /* set the default item alignment */
    $fields_reports_item_edit['align']['default'] = $report['alignment'];
    /* set the default item alignment */
    $fields_reports_item_edit['font_size']['default'] = $report['font_size'];
    print "<form method='post' action='" . basename($_SERVER['PHP_SELF']) . "' name='reports_item_edit'>\n";
    # ready for displaying the fields
    html_start_box("<strong>Report Item</strong> {$header_label}", '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_reports_item_edit, isset($reports_item) ? $reports_item : array(), isset($report) ? $report : array())));
    html_end_box();
    form_hidden_box('id', isset($reports_item['id']) ? $reports_item['id'] : '0', '');
    form_hidden_box('report_id', isset($reports_item['report_id']) ? $reports_item['report_id'] : '0', '');
    form_hidden_box('save_component_report_item', '1', '');
    echo "<table id='graphdiv' style='display:none;' align='center' width='100%'><tr><td align='center' id='graph'></td></tr></table>";
    form_save_button(htmlspecialchars(get_reports_page() . '?action=edit&tab=items&id=' . get_request_var_request('id')), 'return');
    if (isset($item['item_type']) && $item['item_type'] == REPORTS_ITEM_GRAPH) {
        $timespan = array();
        # get config option for first-day-of-the-week
        $first_weekdayid = read_graph_config_option('first_weekdayid');
        # get start/end time-since-epoch for actual time (now()) and given current-session-timespan
        get_timespan($timespan, time(), $item['timespan'], $first_weekdayid);
    }
    /* don't cache previews */
    $_SESSION['custom'] = 'true';
    ?>
	<script type='text/javascript'>

	useCss=<?php 
    print $report['cformat'] == 'on' ? 'true' : 'false';
    ?>
;

	toggle_item_type();
	graphImage(document.getElementById('local_graph_id').value);

	function toggle_item_type() {
		// right bracket ')' does not come with a field
		if (document.getElementById('item_type').value == '<?php 
    print REPORTS_ITEM_GRAPH;
    ?>
') {
			document.getElementById('row_align').style.display='';
			document.getElementById('row_tree_id').style.display='none';
			document.getElementById('row_branch_id').style.display='none';
			document.getElementById('row_tree_cascade').style.display='none';
			document.getElementById('row_graph_name_regexp').style.display='none';
			document.getElementById('row_host_template_id').style.display='';
			document.getElementById('row_host_id').style.display='';
			document.getElementById('row_graph_template_id').style.display='';
			document.getElementById('row_local_graph_id').style.display='';
			document.getElementById('row_timespan').style.display='';
			document.getElementById('item_text').value = '';
			document.getElementById('row_item_text').style.display='none';
			document.getElementById('row_font_size').style.display='none';
		} else if (document.getElementById('item_type').value == '<?php 
    print REPORTS_ITEM_TEXT;
    ?>
') {
			document.getElementById('row_align').style.display='';
			document.getElementById('row_tree_id').style.display='none';
			document.getElementById('row_branch_id').style.display='none';
			document.getElementById('row_tree_cascade').style.display='none';
			document.getElementById('row_graph_name_regexp').style.display='none';
			document.getElementById('row_host_template_id').style.display='none';
			document.getElementById('row_host_id').style.display='none';
			document.getElementById('row_graph_template_id').style.display='none';
			document.getElementById('row_local_graph_id').style.display='none';
			document.getElementById('row_timespan').style.display='none';
			document.getElementById('row_item_text').style.display='';
			if (useCss) {
				document.getElementById('row_font_size').style.display='none';
			}else{
				document.getElementById('row_font_size').style.display='';
			}
		} else if (document.getElementById('item_type').value == '<?php 
    print REPORTS_ITEM_TREE;
    ?>
') {
			document.getElementById('row_align').style.display='';
			document.getElementById('row_tree_id').style.display='';
			document.getElementById('row_branch_id').style.display='';
			document.getElementById('row_tree_cascade').style.display='';
			document.getElementById('row_graph_name_regexp').style.display='';
			document.getElementById('row_host_template_id').style.display='none';
			document.getElementById('row_host_id').style.display='none';
			document.getElementById('row_graph_template_id').style.display='none';
			document.getElementById('row_local_graph_id').style.display='none';
			document.getElementById('row_timespan').style.display='';
			document.getElementById('row_item_text').style.display='none';
			if (useCss) {
				document.getElementById('row_font_size').style.display='none';
			}else{
				document.getElementById('row_font_size').style.display='';
			}
		} else {
			document.getElementById('row_tree_id').style.display='none';
			document.getElementById('row_branch_id').style.display='none';
			document.getElementById('row_tree_cascade').style.display='none';
			document.getElementById('row_graph_name_regexp').style.display='none';
			document.getElementById('row_host_template_id').style.display='none';
			document.getElementById('row_host_id').style.display='none';
			document.getElementById('row_graph_template_id').style.display='none';
			document.getElementById('row_local_graph_id').style.display='none';
			document.getElementById('row_timespan').style.display='none';
			document.getElementById('row_item_text').style.display='none';
			document.getElementById('row_font_size').style.display='none';
			document.getElementById('row_align').style.display='none';
		}
	}

	function applyChange(objForm) {
		strURL = '?action=item_edit'
		strURL = strURL + '&id=' + objForm.report_id.value
		strURL = strURL + '&item_id=' + objForm.id.value
		strURL = strURL + '&item_type=' + objForm.item_type.value;
		strURL = strURL + '&tree_id=' + objForm.tree_id.value;
		strURL = strURL + '&branch_id=' + objForm.branch_id.value;
		strURL = strURL + '&host_template_id=' + objForm.host_template_id.value;
		strURL = strURL + '&host_id=' + objForm.host_id.value;
		strURL = strURL + '&graph_template_id=' + objForm.graph_template_id.value;
		document.location = strURL;
	}

	function graphImage(graphId) {
		if (graphId > 0) {
			document.getElementById('graphdiv').style.display='';
			document.getElementById('graph').innerHTML="<img align='center' src='<?php 
    print $config['url_path'];
    ?>
graph_image.php"+
					"?local_graph_id="+graphId+
					"<?php 
    print $report["graph_width"] > 0 ? "&graph_width=" . $report["graph_width"] : "";
    ?>
"+
					"<?php 
    print $report["graph_height"] > 0 ? "&graph_height=" . $report["graph_height"] : "";
    ?>
"+
					"<?php 
    print $report["thumbnails"] == "on" ? "&graph_nolegend=true" : "";
    ?>
"+
					"<?php 
    print isset($timespan["begin_now"]) ? "&graph_start=" . $timespan["begin_now"] : "";
    ?>
"+
					"<?php 
    print isset($timespan["end_now"]) ? "&graph_end=" . $timespan["end_now"] : "";
    ?>
"+
					"&rra_id=0'>";
		}else{
			document.getElementById('graphdiv').style.display='none';
			document.getElementById('graph').innerHTML='';
		}
	}
	</script>
	<?php 
}
Ejemplo n.º 6
0
    $_POST['print_report'] = $print_report = $q['printed'];
    $_POST['resolve_addresses'] = $resolve_addresses = $q['resolve'];
} else {
    $device = '';
    if (isset_request_var('device_name')) {
        $device = get_nfilter_request_var('device_name');
    } else {
        $device = db_fetch_cell("SELECT folder FROM plugin_flowview_devices ORDER BY id LIMIT 1");
        $_POST['device_name'] = $device;
    }
    $timespan = 0;
    if (isset_request_var('predefined_timespan') && get_filter_request_var('predefined_timespan') > 0) {
        $timespan = get_request_var('predefined_timespan');
        set_request_var('predefined_timespan', $timespan);
        $span = array();
        get_timespan($span, time(), $timespan, read_user_setting('first_weekdayid'));
        $_POST['date1'] = $date1 = $span['current_value_date1'];
        $_POST['date2'] = $date2 = $span['current_value_date2'];
    } else {
        set_request_var('predefined_timespan', '0');
        $timespan = 0;
        $date1 = date('Y-m-d H:i:s', time() - 8 * 3600);
        if (isset_request_var('date1')) {
            $date1 = get_nfilter_request_var('date1');
        }
        $date2 = date('Y-m-d H:i:s');
        if (isset_request_var('date2')) {
            $date2 = get_nfilter_request_var('date2');
        }
    }
    $tos_fields = '';