array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_user_setting('preview_graphs_per_page', 20) ), 'page' => array( 'filter' => FILTER_VALIDATE_INT, 'default' => '1' ), 'graph_template_id' => array( 'filter' => FILTER_VALIDATE_IS_NUMERIC_LIST, 'pageset' => true, 'default' => '-1', ), 'columns' => array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_user_setting('num_columns', '2') ), 'host_id' => array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' ), 'rfilter' => array( 'filter' => FILTER_VALIDATE_IS_REGEX, 'pageset' => true, 'default' => '', ), 'thumbnails' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array('options' => array('regexp' => '(true|false)')), 'default' => read_user_setting('thumbnail_section_preview', '') == 'on' ? 'true':'false' ), 'graph_list' => array( 'filter' => FILTER_VALIDATE_IS_NUMERIC_LIST, 'default' => '' ), 'graph_add' => array( 'filter' => FILTER_VALIDATE_IS_NUMERIC_LIST, 'default' => '' ), 'graph_remove' => array( 'filter' => FILTER_VALIDATE_IS_NUMERIC_LIST, 'default' => '' ), 'style' => array( 'filter' => FILTER_DEFAULT, 'default' => '' ) ); validate_store_request_vars($filters, 'sess_grview'); /* ================= input validation ================= */ } function html_graph_preview_filter($page, $action, $devices_where = '', $templates_where = '') { global $graphs_per_page, $realtime_window, $realtime_refresh, $graph_timeshifts, $graph_timespans, $config; initialize_realtime_step_and_window(); ?>
' title=''> ' title=''> ' title=''>
'> '> '> '> '> '> ' name='button_refresh_x' title='' onClick='refreshGraphTimespanFilter()'> ' title='' onClick='clearGraphTimespanFilter()'>
$form_array) { foreach ($form_array as $form_id1 => $form_array2) { ob_start(); $count = html_graph_custom_data($host_id, $host_template_id, $snmp_query_id, $form_type, $form_id1, $form_array2); if (array_sum($count)) { if (!$output_started) { $output_started = true; top_header(); } ob_end_flush(); } else { ob_end_clean(); } } } /* no fields were actually drawn on the form; just save without prompting the user */ if (!$output_started) { /* since the user didn't actually click "Create" to POST the data; we have to pretend like they did here */ set_request_var('save_component_new_graphs', '1'); set_request_var('selected_graphs_array', serialize($selected_graphs_array)); host_new_graphs_save($host_id); header('Location: ' . $page . '?host_id=' . $host_id . '&header=false'); exit; } form_hidden_box('host_template_id', $host_template_id, '0'); form_hidden_box('host_id', $host_id, '0'); form_hidden_box('save_component_new_graphs', '1', ''); form_hidden_box('selected_graphs_array', serialize($selected_graphs_array), ''); if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'graphs_new') === false) { set_request_var('returnto', basename($_SERVER['HTTP_REFERER'])); } load_current_session_value('returnto', 'sess_grn_returnto', ''); form_save_button(get_nfilter_request_var('returnto')); bottom_footer(); } function html_graph_custom_data($host_id, $host_template_id, $snmp_query_id, $form_type, $form_id1, $form_array2) { /* ================= input validation ================= */ input_validate_input_number($form_id1); /* ==================================================== */ $num_output_fields = array(); $display = false; if ($form_type == 'cg') { $graph_template_id = $form_id1; $graph_template_name = db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($graph_template_id)); if (graph_template_has_override($graph_template_id)) { $display = true; $header = __('Create Graph from %s', html_escape($graph_template_name)); } } elseif ($form_type == 'sg') { foreach ($form_array2 as $form_id2 => $form_array3) { /* ================= input validation ================= */ input_validate_input_number($snmp_query_id); input_validate_input_number($form_id2); /* ==================================================== */ $snmp_query_id = $form_id1; $snmp_query_graph_id = $form_id2; $num_graphs = cacti_sizeof($form_array3); $snmp_query = db_fetch_cell_prepared('SELECT name FROM snmp_query WHERE id = ?', array($snmp_query_id)); $graph_template_id = db_fetch_cell_prepared('SELECT graph_template_id FROM snmp_query_graph WHERE id = ?', array($snmp_query_graph_id)); } if (graph_template_has_override($graph_template_id)) { $display = true; if ($num_graphs > 1) { $header = __('Create %s Graphs from %s', $num_graphs, html_escape($snmp_query)); } else { $header = __('Create Graph from %s', html_escape($snmp_query)); } } } if ($display) { form_start('graphs_new.php', 'new_graphs'); html_start_box($header, '100%', '', '3', 'center', ''); } /* ================= input validation ================= */ input_validate_input_number($graph_template_id); /* ==================================================== */ $data_templates = db_fetch_assoc_prepared('SELECT data_template.name AS data_template_name, data_template_rrd.data_source_name, data_template_data.* FROM (data_template, data_template_rrd, data_template_data, graph_templates_item) WHERE graph_templates_item.task_item_id = data_template_rrd.id AND data_template_rrd.data_template_id = data_template.id AND data_template_data.data_template_id = data_template.id AND data_template_rrd.local_data_id = 0 AND data_template_data.local_data_id = 0 AND graph_templates_item.local_graph_id = 0 AND graph_templates_item.graph_template_id = ? GROUP BY data_template.id ORDER BY data_template.name', array($graph_template_id)); $graph_template = db_fetch_row_prepared('SELECT gt.name AS graph_template_name, gtg.* FROM graph_templates AS gt INNER JOIN graph_templates_graph AS gtg ON gt.id = gtg.graph_template_id WHERE gt.id = ? AND gtg.local_graph_id = 0', array($graph_template_id)); array_push($num_output_fields, draw_nontemplated_fields_graph($graph_template_id, $graph_template, "g_$snmp_query_id" . '_' . $graph_template_id . '_|field|', __('Graph [Template: %s]', html_escape($graph_template['graph_template_name'])), true, false, (isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0))); array_push($num_output_fields, draw_nontemplated_fields_graph_item($graph_template_id, 0, 'gi_' . $snmp_query_id . '_' . $graph_template_id . '_|id|_|field|', __('Graph Items [Template: %s]', html_escape($graph_template['graph_template_name'])), true)); /* DRAW: Data Sources */ if (cacti_sizeof($data_templates)) { foreach ($data_templates as $data_template) { array_push($num_output_fields, draw_nontemplated_fields_data_source($data_template['data_template_id'], 0, $data_template, 'd_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|field|', __('Data Source [Template: %s]', html_escape($data_template['data_template_name'])), true, false, (isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0))); $data_template_items = db_fetch_assoc_prepared('SELECT data_template_rrd.* FROM data_template_rrd WHERE data_template_rrd.data_template_id = ? AND local_data_id = 0', array($data_template['data_template_id'])); array_push($num_output_fields, draw_nontemplated_fields_data_source_item($data_template['data_template_id'], $data_template_items, 'di_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|_|field|', '', true, false, false, (isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0))); array_push($num_output_fields, draw_nontemplated_fields_custom_data($data_template['id'], 'c_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|', __('Custom Data [Template: %s]', html_escape($data_template['data_template_name'])), true, false, $snmp_query_id)); } } if ($display) { html_end_box(false); } return $num_output_fields; }