Exemple #1
0
function settings()
{
    global $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user;
    /* you cannot have per-user graph settings if cacti's user management is not turned on */
    if (read_config_option('auth_method') == 0) {
        raise_message(6);
        display_output_messages();
        return;
    }
    if ($_REQUEST['action'] == 'edit') {
        if (isset($_SERVER['HTTP_REFERER'])) {
            $timespan_sel_pos = strpos($_SERVER['HTTP_REFERER'], '&predefined_timespan');
            if ($timespan_sel_pos) {
                $_SERVER['HTTP_REFERER'] = substr($_SERVER['HTTP_REFERER'], 0, $timespan_sel_pos);
            }
        }
        $_SESSION['profile_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'graph_view.php';
    }
    print "<form method='post' action='auth_profile.php'>\n";
    html_start_box('<strong>User Settings</strong>', '100%', '', '3', 'center', '');
    $current_user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id']));
    if (!sizeof($current_user)) {
        return;
    }
    /* file: user_admin.php, action: user_edit (host) */
    $fields_user = array('username' => array('method' => 'value', 'friendly_name' => 'User Name', 'description' => 'The login name for this user.', 'value' => '|arg1:username|', 'max_length' => '40', 'size' => '40'), 'full_name' => array('method' => 'textbox', 'friendly_name' => 'Full Name', 'description' => 'A more descriptive name for this user, that can include spaces or special characters.', 'value' => '|arg1:full_name|', 'max_length' => '120', 'size' => '60'), 'email_address' => array('method' => 'textbox', 'friendly_name' => 'E-Mail Address', 'description' => 'An E-Mail Address you be reached at.', 'value' => '|arg1:email_address|', 'max_length' => '60', 'size' => '60'));
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_user, isset($current_user) ? $current_user : array())));
    html_end_box();
    if (is_view_allowed('graph_settings') == true) {
        if (read_config_option('auth_method') != 0) {
            $settings_graphs['tree']['default_tree_id']['sql'] = get_graph_tree_array(true);
        }
        html_start_box('<strong>Graph Settings</strong>', '100%', '', '3', 'center', '');
        while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
            $collapsible = true;
            print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$tab_short_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $tabs_graphs[$tab_short_name] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n";
            $form_array = array();
            while (list($field_name, $field_array) = each($tab_fields)) {
                $form_array += array($field_name => $tab_fields[$field_name]);
                if (isset($field_array['items']) && is_array($field_array['items'])) {
                    while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) {
                        if (graph_config_value_exists($sub_field_name, $_SESSION['sess_user_id'])) {
                            $form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1;
                        }
                        $form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, $_SESSION['sess_user_id']));
                    }
                } else {
                    if (graph_config_value_exists($field_name, $_SESSION['sess_user_id'])) {
                        $form_array[$field_name]['form_id'] = 1;
                    }
                    $form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($field_name, $_SESSION['sess_user_id']));
                }
            }
            draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
        }
        html_end_box();
    }
    ?>
	<script type="text/javascript">
	<!--
	var themeFonts=<?php 
    print read_config_option('font_method');
    ?>
;

	function graphSettings() {
		if (themeFonts == 1) {
				$('#row_fonts').hide();
				$('#row_custom_fonts').hide();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
		}else{
			var custom_fonts = $('#custom_fonts').is(':checked');

			switch(custom_fonts) {
			case true:
				$('#row_fonts').show();
				$('#row_title_size').show();
				$('#row_title_font').show();
				$('#row_legend_size').show();
				$('#row_legend_font').show();
				$('#row_axis_size').show();
				$('#row_axis_font').show();
				$('#row_unit_size').show();
				$('#row_unit_font').show();
				break;
			case false:
				$('#row_fonts').show();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
				break;
			}
		}

		if ($('#timespan_sel').is(':checked')) {
			$('#row_default_rra_id').hide();
			$('#row_default_timespan').show();
			$('#row_default_timeshift').show();
			$('#row_allow_graph_dates_in_future').show();
			$('#row_first_weekdayid').show();
			$('#row_day_shift_start').show();
			$('#row_day_shift_end').show();
		} else {
			$('#row_default_rra_id').show();
			$('#row_default_timespan').hide();
			$('#row_default_timeshift').hide();
			$('#row_allow_graph_dates_in_future').hide();
			$('#row_first_weekdayid').hide();
			$('#row_day_shift_start').hide();
			$('#row_day_shift_end').hide();
		}
	}

	$(function() {
		graphSettings();

		$('#navigation').show();
		$('#navigation_right').show();

		$('input[value="Save"]').unbind().click(function(event) {
			event.preventDefault();
			href='<?php 
    print $_SERVER['HTTP_REFERER'];
    ?>
';
			href=href+(href.indexOf('?') > 0 ? '&':'?')+'header=false';
			$.post('auth_profile.php?header=false', $('input, select, textarea').serialize()).done(function(data) {
				$.get('auth_profile.php?action=noreturn&header=false', function(data) {
					$('#main').html(data);
					applySkin();
				});
			});
		});

		$('input[value="Return"]').unbind().click(function(event) {
			console.log('The refer is:<?php 
    print $_SESSION['profile_referer'];
    ?>
');
			document.location = '<?php 
    print $_SESSION['profile_referer'];
    ?>
';
		});

		$('#timespan_sel').change(function() {
			graphSettings();
		});
	});

	-->
	</script>
	<?php 
    form_hidden_box('save_component_graph_config', '1', '');
    form_save_buttons(array(array('id' => 'return', 'value' => 'Return'), array('id' => 'save', 'value' => 'Save')));
}
Exemple #2
0
function settings()
{
    global $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user;
    $current_user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id']));
    /* you cannot have per-user graph settings if cacti's user management is not turned on */
    if (read_config_option('auth_method') == 0) {
        raise_message(6);
        display_output_messages();
        return;
    }
    /* Find out whether this user has right here */
    if (!is_view_allowed('graph_settings')) {
        print "<strong><font class='txtErrorTextBox'>YOU DO NOT HAVE RIGHTS TO CHANGE GRAPH SETTINGS</font></strong>";
        bottom_footer();
        exit;
    }
    if (read_config_option('auth_method') != 0) {
        $settings_graphs['tree']['default_tree_id']['sql'] = get_graph_tree_array(true);
    }
    print "<form method='post' action='graph_settings.php'>\n";
    html_start_box('<strong>Graph Settings</strong>', '100%', '', '3', 'center', '');
    while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
        $collapsible = true;
        print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$tab_short_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $tabs_graphs[$tab_short_name] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n";
        $form_array = array();
        while (list($field_name, $field_array) = each($tab_fields)) {
            $form_array += array($field_name => $tab_fields[$field_name]);
            if (isset($field_array['items']) && is_array($field_array['items'])) {
                while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) {
                    if (graph_config_value_exists($sub_field_name, $_SESSION['sess_user_id'])) {
                        $form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1;
                    }
                    $form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, $_SESSION['sess_user_id']));
                }
            } else {
                if (graph_config_value_exists($field_name, $_SESSION['sess_user_id'])) {
                    $form_array[$field_name]['form_id'] = 1;
                }
                $form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($field_name, $_SESSION['sess_user_id']));
            }
        }
        draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
    }
    html_end_box();
    ?>
	<script type="text/javascript">
	<!--
	var themeFonts=<?php 
    print read_config_option('font_method');
    ?>
;

	function graphSettings() {
		if (themeFonts == 1) {
				$('#row_fonts').hide();
				$('#row_custom_fonts').hide();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
		}else{
			var custom_fonts = $('#custom_fonts').is(':checked');

			switch(custom_fonts) {
			case true:
				$('#row_fonts').show();
				$('#row_title_size').show();
				$('#row_title_font').show();
				$('#row_legend_size').show();
				$('#row_legend_font').show();
				$('#row_axis_size').show();
				$('#row_axis_font').show();
				$('#row_unit_size').show();
				$('#row_unit_font').show();
				break;
			case false:
				$('#row_fonts').show();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
				break;
			}
		}

		if ($('#timespan_sel').is(':checked')) {
			$('#row_default_rra_id').hide();
			$('#row_default_timespan').show();
			$('#row_default_timeshift').show();
			$('#row_allow_graph_dates_in_future').show();
			$('#row_first_weekdayid').show();
			$('#row_day_shift_start').show();
			$('#row_day_shift_end').show();
		} else {
			$('#row_default_rra_id').show();
			$('#row_default_timespan').hide();
			$('#row_default_timeshift').hide();
			$('#row_allow_graph_dates_in_future').hide();
			$('#row_first_weekdayid').hide();
			$('#row_day_shift_start').hide();
			$('#row_day_shift_end').hide();
		}
	}

	$(function() {
		graphSettings();

		$('#navigation').show();
		$('#navigation_right').show();

		$('input[value="Save"]').click(function(event) {
			event.preventDefault();
			href='<?php 
    print $_SERVER['HTTP_REFERER'];
    ?>
';
			href=href+(href.indexOf('?') > 0 ? '&':'?')+'header=false';
			$.post('graph_settings.php?header=false', $('input, select, textarea').serialize()).done(function(data) {
				document.location='<?php 
    print $_SERVER['HTTP_REFERER'];
    ?>
';
			});
		});

		$('#timespan_sel').change(function() {
			graphSettings();
		});
	});

	-->
	</script>
	<?php 
    if (isset($_SERVER['HTTP_REFERER'])) {
        $timespan_sel_pos = strpos($_SERVER['HTTP_REFERER'], '&predefined_timespan');
        if ($timespan_sel_pos) {
            $_SERVER['HTTP_REFERER'] = substr($_SERVER['HTTP_REFERER'], 0, $timespan_sel_pos);
        }
    }
    $_SESSION['graph_settings_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'graph_view.php';
    form_hidden_box('save_component_graph_config', '1', '');
    form_save_button('graph_settings.php', 'save');
}
Exemple #3
0
function html_graph_tabs_right($current_user)
{
    global $config, $tabs_right;
    if (read_config_option("selected_theme") == 'classic') {
        if (is_view_allowed('graph_settings')) {
            print '<a href="' . $config['url_path'] . 'graph_settings.php"><img src="' . $config['url_path'] . 'images/tab_settings';
            if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") {
                print "_down";
            }
            print '.gif" border="0" alt="Settings" align="absmiddle"></a>';
        }
        ?>
&nbsp;&nbsp;<?php 
        if (is_view_allowed('show_tree')) {
            ?>
<a href="<?php 
            print htmlspecialchars($config['url_path'] . "graph_view.php?action=tree");
            ?>
"><img src="<?php 
            echo $config['url_path'];
            ?>
images/tab_mode_tree<?php 
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "tree") {
                print "_down";
            }
            ?>
.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php 
        }
        if (is_view_allowed('show_list')) {
            ?>
<a href="<?php 
            print htmlspecialchars($config['url_path'] . "graph_view.php?action=list");
            ?>
"><img src="<?php 
            echo $config['url_path'];
            ?>
images/tab_mode_list<?php 
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "list") {
                print "_down";
            }
            ?>
.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php 
        }
        if (is_view_allowed('show_preview')) {
            ?>
<a href="<?php 
            print htmlspecialchars($config['url_path'] . "graph_view.php?action=preview");
            ?>
"><img src="<?php 
            echo $config['url_path'];
            ?>
images/tab_mode_preview<?php 
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") {
                print "_down";
            }
            ?>
.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php 
        }
        ?>
&nbsp;<br>
		<?php 
    } else {
        $tabs_right = array(array('title' => 'Settings', 'image' => '', 'id' => 'settings', 'url' => 'graph_settings.php'), array('title' => 'Tree View', 'image' => 'images/tab_tree.gif', 'id' => 'tree', 'url' => 'graph_view.php?action=tree'), array('title' => 'List View', 'image' => 'images/tab_list.gif', 'id' => 'list', 'url' => 'graph_view.php?action=list'), array('title' => 'Preview', 'image' => 'images/tab_preview.gif', 'id' => 'preview', 'url' => 'graph_view.php?action=preview'));
        $i = 0;
        foreach ($tabs_right as $tab) {
            if ($tab['url'] == 'graph_settings.php' && basename($_SERVER['PHP_SELF']) == 'graph_settings.php') {
                $tabs_right[$i]['selected'] = true;
            } elseif ($tab['id'] == 'tree') {
                if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'tree') {
                    $tabs_right[$i]['selected'] = true;
                }
            } elseif ($tab['id'] == 'list') {
                if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'list') {
                    $tabs_right[$i]['selected'] = true;
                }
            } elseif ($tab['id'] == 'preview') {
                if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'preview') {
                    $tabs_right[$i]['selected'] = true;
                }
            } elseif (strstr($_SERVER['PHP_SELF'], $tab['url'])) {
                $tabs_right[$i]['selected'] = true;
            }
            $i++;
        }
        print "<div class='tabs' style='float:right;'><nav><ul>\n";
        foreach ($tabs_right as $tab) {
            switch ($tab['id']) {
                case 'settings':
                    if (is_view_allowed('graph_settings') == true) {
                        if (isset($tab['image']) && $tab['image'] != '') {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'><img src='" . $config['url_path'] . $tab['image'] . "' border='0' align='bottom'></a></li>\n";
                        } else {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'>" . $tab['title'] . "</a></li>\n";
                        }
                        break;
                    }
                    break;
                case 'tree':
                    if (is_view_allowed('show_tree')) {
                        if (isset($tab['image']) && $tab['image'] != '') {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'><img src='" . $config['url_path'] . $tab['image'] . "' border='0' align='bottom'></a></li>\n";
                        } else {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'>" . $tab['title'] . "</a></li>\n";
                        }
                        break;
                    }
                    break;
                case 'list':
                    if (is_view_allowed('show_list')) {
                        if (isset($tab['image']) && $tab['image'] != '') {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'><img src='" . $config['url_path'] . $tab['image'] . "' border='0' align='bottom'></a></li>\n";
                        } else {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'>" . $tab['title'] . "</a></li>\n";
                        }
                        break;
                    }
                    break;
                case 'preview':
                    if (is_view_allowed('show_preview')) {
                        if (isset($tab['image']) && $tab['image'] != '') {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'><img src='" . $config['url_path'] . $tab['image'] . "' border='0' align='bottom'></a></li>\n";
                        } else {
                            print "<li><a title='" . $tab['title'] . "' class='" . (isset($tab['selected']) ? 'selected' : '') . "' href='" . $tab['url'] . "'>" . $tab['title'] . "</a></li>\n";
                        }
                        break;
                    }
                    break;
            }
        }
        print "</ul></nav></div>\n";
    }
}
Exemple #4
0
     if (get_request_var_request('thumbnails') == 'true') {
         html_graph_thumbnail_area($graphs, '', 'graph_start=' . get_current_graph_start() . '&graph_end=' . get_current_graph_end(), '', get_request_var_request('columns'));
     } else {
         html_graph_area($graphs, '', 'graph_start=' . get_current_graph_start() . '&graph_end=' . get_current_graph_end(), '', get_request_var_request('columns'));
     }
     if ($total_rows > 0) {
         print $nav;
     }
     html_end_box();
     if (!isset($_REQUEST['header']) || $_REQUEST['header'] == false) {
         bottom_footer();
     }
     break;
 case 'list':
     top_graph_header();
     if (!is_view_allowed('show_list')) {
         print "<strong><font class='txtErrorTextBox'>YOU DO NOT HAVE RIGHTS FOR LIST VIEW</font></strong>";
         return;
     }
     /* ================= input validation ================= */
     input_validate_input_number(get_request_var_request('host_id'));
     input_validate_input_number(get_request_var_request('graph_template_id'));
     input_validate_input_number(get_request_var_request('rows'));
     input_validate_input_number(get_request_var_request('page'));
     /* ==================================================== */
     /* clean up search string */
     if (isset($_REQUEST['filter'])) {
         $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter'));
     }
     /* reset the graph list on a new viewing */
     if (!isset($_REQUEST['page'])) {