\n";
api_plugin_hook('nav_login_after');
}elseif (isset($_SESSION['sess_user_id']) && $using_guest_account == false) {
$user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id']));
api_plugin_hook('nav_login_before');
print "Logged in as
\n";
api_plugin_hook('nav_login_after');
}
}
/* draw_navigation_text - determines the top header navigation text for the current page and displays it to
@arg $type - (string) Either 'url' or 'title'
@returns (string> Either the navigation text or title */
function draw_navigation_text($type = 'url') {
global $config;
$nav_level_cache = (isset($_SESSION['sess_nav_level_cache']) ? $_SESSION['sess_nav_level_cache'] : array());
$nav = array(
'auth_profile.php:' => array(
'title' => 'User Profile (Edit)',
'mapping' => '',
'url' => '',
'level' => '0'
),
'graph_view.php:' => array(
'title' => 'Graphs',
'mapping' => '',
'url' => 'graph_view.php',
'level' => '0'
),
'graph_view.php:tree' => array(
'title' => 'Tree Mode',
'mapping' => 'graph_view.php:',
'url' => 'graph_view.php?action=tree',
'level' => '0'
),
'graph_view.php:tree_content' => array(
'title' => 'Tree Mode',
'mapping' => 'graph_view.php:',
'url' => 'graph_view.php?action=tree',
'level' => '0'
),
'graph_view.php:list' => array(
'title' => 'List Mode',
'mapping' => '',
'url' => 'graph_view.php?action=list',
'level' => '0'
),
'graph_view.php:preview' => array(
'title' => 'Preview Mode',
'mapping' => '',
'url' => 'graph_view.php?action=preview',
'level' => '0'
),
'graph.php:' => array(
'title' => '|current_graph_title|',
'mapping' => 'graph_view.php:,?',
'level' => '2'
),
'graph.php:view' => array(
'title' => '|current_graph_title|',
'mapping' => 'graph_view.php:,?',
'level' => '2'
),
'graph_settings.php:' => array(
'title' => 'Settings',
'mapping' => 'graph_view.php:',
'url' => 'graph_settings.php',
'level' => '1'
),
'index.php:' => array(
'title' => 'Console',
'mapping' => '',
'url' => $config['url_path'] . 'index.php',
'level' => '0'
),
'index.php:login' => array(
'title' => 'Console',
'mapping' => '',
'url' => $config['url_path'] . 'index.php',
'level' => '0'
),
'graphs.php:' => array(
'title' => 'Graph Management',
'mapping' => 'index.php:',
'url' => 'graphs.php',
'level' => '1'
),
'graphs.php:graph_edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,graphs.php:',
'url' => '',
'level' => '2'
),
'graphs.php:graph_diff' => array(
'title' => 'Change Graph Template',
'mapping' => 'index.php:,graphs.php:,graphs.php:graph_edit',
'url' => '',
'level' => '3'
),
'graphs.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,graphs.php:',
'url' => '',
'level' => '2'
),
'graphs_items.php:item_edit' => array(
'title' => 'Graph Items',
'mapping' => 'index.php:,graphs.php:,graphs.php:graph_edit',
'url' => '',
'level' => '3'
),
'graphs_new.php:' => array(
'title' => 'Create New Graphs',
'mapping' => 'index.php:',
'url' => 'graphs_new.php',
'level' => '1'
),
'graphs_new.php:save' => array(
'title' => 'Create Graphs from Data Query',
'mapping' => 'index.php:,graphs_new.php:',
'url' => '',
'level' => '2'
),
'gprint_presets.php:' => array(
'title' => 'GPRINT Presets',
'mapping' => 'index.php:',
'url' => 'gprint_presets.php',
'level' => '1'
),
'gprint_presets.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,gprint_presets.php:',
'url' => '',
'level' => '2'
),
'gprint_presets.php:remove' => array(
'title' => '(Remove)',
'mapping' => 'index.php:,gprint_presets.php:',
'url' => '',
'level' => '2'
),
'cdef.php:' => array(
'title' => 'CDEFs',
'mapping' => 'index.php:',
'url' => 'cdef.php',
'level' => '1'
),
'cdef.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,cdef.php:',
'url' => '',
'level' => '2'
),
'cdef.php:remove' => array(
'title' => '(Remove)',
'mapping' => 'index.php:,cdef.php:',
'url' => '',
'level' => '2'
),
'cdef.php:item_edit' => array(
'title' => 'CDEF Items',
'mapping' => 'index.php:,cdef.php:,cdef.php:edit',
'url' => '',
'level' => '3'
),
'cdef.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,cdef.php:',
'url' => '',
'level' => '2'
),
'clog.php:' => array(
'title' => 'View Cacti Log',
'mapping' => '',
'url' => 'clog.php',
'level' => '0'
),
'clog.php:preview' => array(
'title' => 'View Cacti Log',
'mapping' => '',
'url' => 'clog.php',
'level' => '0'
),
'clog_user.php:' => array(
'title' => 'View Cacti Log',
'mapping' => '',
'url' => 'clog_user.php',
'level' => '0'
),
'clog_user.php:preview' => array(
'title' => 'View Cacti Log',
'mapping' => '',
'url' => 'clog_user.php',
'level' => '0'
),
'tree.php:' => array(
'title' => 'Graph Trees',
'mapping' => 'index.php:',
'url' => 'tree.php',
'level' => '1'
),
'tree.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,tree.php:',
'url' => '',
'level' => '2'
),
'color.php:' => array(
'title' => 'Colors',
'mapping' => 'index.php:',
'url' => 'color.php',
'level' => '1'
),
'color.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,color.php:',
'url' => '',
'level' => '2'
),
'graph_templates.php:' => array(
'title' => 'Graph Templates',
'mapping' => 'index.php:',
'url' => 'graph_templates.php',
'level' => '1'
),
'graph_templates.php:template_edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,graph_templates.php:',
'url' => '',
'level' => '2'
),
'graph_templates.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,graph_templates.php:',
'url' => '',
'level' => '2'
),
'graph_templates_items.php:item_edit' => array(
'title' => 'Graph Template Items',
'mapping' => 'index.php:,graph_templates.php:,graph_templates.php:template_edit',
'url' => '',
'level' => '3'
),
'graph_templates_inputs.php:input_edit' => array(
'title' => 'Graph Item Inputs',
'mapping' => 'index.php:,graph_templates.php:,graph_templates.php:template_edit',
'url' => '',
'level' => '3'
),
'graph_templates_inputs.php:input_remove' => array(
'title' => '(Remove)',
'mapping' => 'index.php:,graph_templates.php:,graph_templates.php:template_edit',
'url' => '',
'level' => '3'
),
'host_templates.php:' => array(
'title' => 'Device Templates',
'mapping' => 'index.php:',
'url' => 'host_templates.php',
'level' => '1'
),
'host_templates.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,host_templates.php:',
'url' => '',
'level' => '2'
),
'host_templates.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,host_templates.php:',
'url' => '',
'level' => '2'
),
'graph_templates.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,graph_templates.php:',
'url' => '',
'level' => '2'
),
'data_templates.php:' => array(
'title' => 'Data Templates',
'mapping' => 'index.php:',
'url' => 'data_templates.php',
'level' => '1'
),
'data_templates.php:template_edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,data_templates.php:',
'url' => '',
'level' => '2'
),
'data_templates.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,data_templates.php:',
'url' => '',
'level' => '2'
),
'data_sources.php:' => array(
'title' => 'Data Sources',
'mapping' => 'index.php:',
'url' => 'data_sources.php',
'level' => '1'
),
'data_sources.php:ds_edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,data_sources.php:',
'url' => '',
'level' => '2'
),
'data_sources.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,data_sources.php:',
'url' => '',
'level' => '2'
),
'host.php:' => array(
'title' => 'Devices',
'mapping' => 'index.php:',
'url' => 'host.php',
'level' => '1'
),
'host.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,host.php:',
'url' => '',
'level' => '2'
),
'host.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,host.php:',
'url' => '',
'level' => '2'
),
'rra.php:' => array(
'title' => 'Round Robin Archives',
'mapping' => 'index.php:',
'url' => 'rra.php',
'level' => '1'
),
'rra.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,rra.php:',
'url' => '',
'level' => '2'
),
'rra.php:remove' => array(
'title' => '(Remove)',
'mapping' => 'index.php:,rra.php:',
'url' => '',
'level' => '2'
),
'data_input.php:' => array(
'title' => 'Data Input Methods',
'mapping' => 'index.php:',
'url' => 'data_input.php',
'level' => '1'
),
'data_input.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,data_input.php:',
'url' => '',
'level' => '2'
),
'data_input.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,data_input.php:',
'url' => '',
'level' => '2'
),
'data_input.php:remove' => array(
'title' => '(Remove)',
'mapping' => 'index.php:,data_input.php:',
'url' => '',
'level' => '2'
),
'data_input.php:field_edit' => array(
'title' => 'Data Input Fields',
'mapping' => 'index.php:,data_input.php:,data_input.php:edit',
'url' => '',
'level' => '3'
),
'data_input.php:field_remove' => array(
'title' => '(Remove Item)',
'mapping' => 'index.php:,data_input.php:,data_input.php:edit',
'url' => '',
'level' => '3'
),
'data_queries.php:' => array(
'title' => 'Data Queries',
'mapping' => 'index.php:',
'url' => 'data_queries.php',
'level' => '1'
),
'data_queries.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,data_queries.php:',
'url' => '',
'level' => '2'
),
'data_queries.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,data_queries.php:',
'url' => '',
'level' => '2'
),
'data_queries.php:item_edit' => array(
'title' => 'Associated Graph Templates',
'mapping' => 'index.php:,data_queries.php:,data_queries.php:edit',
'url' => '',
'level' => '3'
),
'data_queries.php:item_remove' => array(
'title' => '(Remove Item)',
'mapping' => 'index.php:,data_queries.php:,data_queries.php:edit',
'url' => '',
'level' => '3'
),
'rrdcleaner.php:' => array(
'title' => 'RRD Cleaner',
'mapping' => 'index.php:,utilities.php:',
'url' => 'rrdcleaner.php',
'level' => '2'
),
'rrdcleaner.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,rrdcleaner.php:',
'url' => 'rrdcleaner.php?action=actions',
'level' => '2'
),
'rrdcleaner.php:restart' => array(
'title' => 'List unused Files',
'mapping' => 'rrdcleaner.php:',
'url' => 'rrdcleaner.php?action=restart',
'level' => '2'
),
'utilities.php:' => array(
'title' => 'Utilities',
'mapping' => 'index.php:',
'url' => 'utilities.php',
'level' => '1'
),
'utilities.php:view_poller_cache' => array(
'title' => 'View Poller Cache',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:view_snmp_cache' => array(
'title' => 'View SNMP Cache',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:clear_poller_cache' => array(
'title' => 'View Poller Cache',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:view_logfile' => array(
'title' => 'View Cacti Log File',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:clear_logfile' => array(
'title' => 'Clear Cacti Log File',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:view_user_log' => array(
'title' => 'View User Log File',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:clear_user_log' => array(
'title' => 'Clear User Log File',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:view_tech' => array(
'title' => 'Technical Support',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:view_boost_status' => array(
'title' => 'Boost Status',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:view_snmpagent_cache' => array(
'title' => 'View SNMP Agent Cache',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'utilities.php:view_snmpagent_events' => array(
'title' => 'View SNMP Agent Notification Log',
'mapping' => 'index.php:,utilities.php:',
'url' => 'utilities.php',
'level' => '2'
),
'managers.php:' => array(
'title' => 'View SNMP Notification Receivers',
'mapping' => 'index.php:,utilities.php:',
'url' => 'managers.php',
'level' => '2'
),
'managers.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,utilities.php:,managers.php:',
'url' => '',
'level' => '3'
),
'settings.php:' => array(
'title' => 'Cacti Settings',
'mapping' => 'index.php:',
'url' => 'settings.php',
'level' => '1'
),
'user_admin.php:' => array(
'title' => 'Users',
'mapping' => 'index.php:',
'url' => 'user_admin.php',
'level' => '1'
),
'user_admin.php:user_edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,user_admin.php:',
'url' => '',
'level' => '2'
),
'user_admin.php:actions' => array(
'title' => '(Action)',
'mapping' => 'index.php:,user_admin.php:',
'url' => '',
'level' => '2'
),
'user_domains.php:' => array(
'title' => 'User Domains',
'mapping' => 'index.php:',
'url' => 'user_domains.php',
'level' => '1'
),
'user_domains.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'user_domains.php:,index.php:',
'url' => 'user_domains.php:edit',
'level' => '2'
),
'user_group_admin.php:' => array(
'title' => 'User Groups',
'mapping' => 'index.php:',
'url' => 'user_group_admin.php',
'level' => '1'
),
'user_group_admin.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,user_group_admin.php:',
'url' => '',
'level' => '2'
),
'user_group_admin.php:actions' => array(
'title' => '(Action)',
'mapping' => 'index.php:,user_group_admin.php:',
'url' => '',
'level' => '2'
),
'about.php:' => array(
'title' => 'About Cacti',
'mapping' => 'index.php:',
'url' => 'about.php',
'level' => '1'
),
'templates_export.php:' => array(
'title' => 'Export Templates',
'mapping' => 'index.php:',
'url' => 'templates_export.php',
'level' => '1'
),
'templates_export.php:save' => array(
'title' => 'Export Results',
'mapping' => 'index.php:,templates_export.php:',
'url' => 'templates_export.php',
'level' => '2'
),
'templates_import.php:' => array(
'title' => 'Import Templates',
'mapping' => 'index.php:',
'url' => 'templates_import.php',
'level' => '1'
),
'reports_admin.php:' => array(
'title' => 'Reporting',
'mapping' => '',
'url' => 'reports_admin.php',
'level' => '0'
),
'reports_admin.php:actions' => array(
'title' => 'Report Add',
'mapping' => 'reports_admin.php:',
'url' => 'reports_admin.php',
'level' => '1'
),
'reports_admin.php:delete' => array(
'title' => 'Report Delete',
'mapping' => 'reports_admin.php:',
'url' => 'reports_admin.php',
'level' => '1'
),
'reports_admin.php:edit' => array(
'title' => 'Report Edit',
'mapping' => 'reports_admin.php:',
'url' => 'reports_admin.php?action=edit',
'level' => '1'
),
'reports_admin.php:item_edit' => array(
'title' => 'Report Edit Item',
'mapping' => 'reports_admin.php:,reports_admin.php:edit',
'url' => '',
'level' => '2'
),
'reports_user.php:' => array(
'title' => 'Reporting',
'mapping' => '',
'url' => 'reports_user.php',
'level' => '0'
),
'reports_user.php:actions' => array(
'title' => 'Report Add',
'mapping' => 'reports_user.php:',
'url' => 'reports_user.php',
'level' => '1'
),
'reports_user.php:delete' => array(
'title' => 'Report Delete',
'mapping' => 'reports_user.php:',
'url' => 'reports_user.php',
'level' => '1'
),
'reports_user.php:edit' => array(
'title' => 'Report Edit',
'mapping' => 'reports_user.php:',
'url' => 'reports_user.php?action=edit',
'level' => '1'
),
'reports_user.php:item_edit' => array(
'title' => 'Report Edit Item',
'mapping' => 'reports_user.php:,reports_user.php:edit',
'url' => '',
'level' => '2'
),
'color_templates.php:' => array(
'title' => 'Color Templates',
'mapping' => 'index.php:',
'url' => 'color_templates.php',
'level' => '1'
),
'color_templates.php:template_edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,color_templates.php:',
'url' => '',
'level' => '2'
),
'color_templates.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,color_templates.php:',
'url' => '',
'level' => '2'
),
'color_templates_items.php:item_edit' => array(
'title' => 'Color Template Items',
'mapping' => 'index.php:,color_templates.php:,color_templates.php:template_edit',
'url' => '',
'level' => '3'
),
'aggregate_templates.php:' => array(
'title' => 'Aggregate Templates',
'mapping' => 'index.php:',
'url' => 'aggregate_templates.php',
'level' => '1'
),
'aggregate_templates.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,aggregate_templates.php:',
'url' => '',
'level' => '2'
),
'aggregate_templates.php:actions'=> array(
'title' => 'Actions',
'mapping' => 'index.php:,aggregate_templates.php:',
'url' => '',
'level' => '2'
),
'aggregate_graphs.php:' => array(
'title' => 'Aggregate Graphs',
'mapping' => 'index.php:',
'url' => 'aggregate_graphs.php',
'level' => '1'
),
'aggregate_graphs.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,aggregate_graphs.php:',
'url' => '',
'level' => '2'
),
'aggregate_graphs.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,aggregate_graphs.php:',
'url' => '',
'level' => '2'
),
'aggregate_items.php:' => array(
'title' => 'Aggregate Items',
'mapping' => 'index.php:',
'url' => 'aggregate_items.php',
'level' => '1'
),
'aggregate_items.php:item_edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,aggregate_graphs.php:,aggregate_items.php:',
'url' => '',
'level' => '2'
),
'aggregate_items.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,aggregate_items.php:',
'url' => '',
'level' => '2'
),
'automation_graph_rules.php:' => array(
'title' => 'Graph Rules',
'mapping' => 'index.php:',
'url' => 'automation_graph_rules.php',
'level' => '1'
),
'automation_graph_rules.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,automation_graph_rules.php:',
'url' => '',
'level' => '2'
),
'automation_graph_rules.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,automation_graph_rules.php:',
'url' => '',
'level' => '2'
),
'automation_graph_rules.php:item_edit' => array(
'title' => 'Graph Rule Items',
'mapping' => 'index.php:,automation_graph_rules.php:,automation_graph_rules.php:edit',
'url' => '',
'level' => '3'
),
'automation_tree_rules.php:' => array(
'title' => 'Tree Rules',
'mapping' => 'index.php:',
'url' => 'automation_tree_rules.php',
'level' => '1'
),
'automation_tree_rules.php:edit' => array(
'title' => '(Edit)',
'mapping' => 'index.php:,automation_tree_rules.php:',
'url' => '',
'level' => '2'
),
'automation_tree_rules.php:actions' => array(
'title' => 'Actions',
'mapping' => 'index.php:,automation_tree_rules.php:',
'url' => '',
'level' => '2'
),
'automation_tree_rules.php:item_edit' => array(
'title' => 'Tree Rule Items',
'mapping' => 'index.php:,automation_tree_rules.php:,automation_tree_rules.php:edit',
'url' => '',
'level' => '3'
)
);
$nav = api_plugin_hook_function('draw_navigation_text', $nav);
$current_page = basename($_SERVER['PHP_SELF']);
if (!isempty_request_var('action')) {
get_filter_request_var('action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([-a-zA-Z0-9_\s]+)$/')));
}
$current_action = (isset_request_var('action') ? get_request_var('action') : '');
/* find the current page in the big array */
if (isset($nav[$current_page . ':' . $current_action])) {
$current_array = $nav{$current_page . ':' . $current_action};
}else{
$current_array = array('mapping' => 'index.php:', 'title' => ucwords(str_replace('_', ' ', basename($_SERVER['PHP_SELF'], '.php'))), 'level' => 1);
}
$current_mappings = explode(',', $current_array['mapping']);
$current_nav = "
";
$title = '';
$nav_count = 0;
/* resolve all mappings to build the navigation string */
for ($i=0; ($i") . htmlspecialchars(resolve_navigation_variables($nav{$nav_level_cache{$i}['id']}['title'])) . (empty($url) ? '' : '' . (get_selected_theme() == 'classic' ? ' -> ':'') . '');
$title .= htmlspecialchars(resolve_navigation_variables($nav{$nav_level_cache{$i}['id']}['title'])) . ' -> ';
}
}else{
/* there is no '?' - pull from the above array */
$current_nav .= (empty($url) ? '' : "- ") . htmlspecialchars(resolve_navigation_variables($nav{$current_mappings[$i]}['title'])) . (empty($url) ? '' : '' . (get_selected_theme() == 'classic' ? ' -> ':'') . '
');
$title .= htmlspecialchars(resolve_navigation_variables($nav{$current_mappings[$i]}['title'])) . ' -> ';
}
$nav_count++;
}
if ($nav_count) {
$current_nav .= "- " . htmlspecialchars(resolve_navigation_variables($current_array['title'])) . '
';
}else{
$current_array = $nav[$current_page . ':' . $current_action];
$url = (isset($current_array['url']) ? $current_array['url']:'');
$current_nav .= "- " . htmlspecialchars(resolve_navigation_variables($current_array['title'])) . '
';
}
if (isset_request_var('tree_id') || isset_request_var('leaf_id')) {
$leaf_sub = '';
$leaf_name = '';
$tree_name = '';
if (isset_request_var('leaf_id') && get_request_var('leaf_id') != '') {
$leaf = db_fetch_row_prepared('SELECT * FROM graph_tree_items WHERE id = ?', array(get_request_var('leaf_id')));
if (sizeof($leaf)) {
if ($leaf['host_id'] > 0) {
$leaf_name = db_fetch_cell_prepared('SELECT description FROM host WHERE id = ?', array($leaf['host_id']));
}else{
$leaf_name = $leaf['title'];
}
$tree_name = db_fetch_cell_prepared('SELECT name FROM graph_tree WHERE id = ?', array($leaf['graph_tree_id']));
}else{
$leaf_name = 'Leaf';
}
if (isset_request_var('host_group_data') && get_request_var('host_group_data') != '') {
$parts = explode(':', get_request_var('host_group_data'));
input_validate_input_number($parts[1]);
if ($parts[0] == 'graph_template') {
$leaf_sub = db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($parts[1]));
}else{
if ($parts[1] > 0) {
$leaf_sub = db_fetch_cell_prepared('SELECT name FROM snmp_query WHERE id = ?', array($parts[1]));
}else{
$leaf_sub = 'Non Query Based';
}
}
}else{
$leaf_sub = '';
}
}else{
$leaf_name = '';
if (isset_request_var('tree_id')) {
$tree_name = db_fetch_cell_prepared('SELECT name FROM graph_tree WHERE id = ?', array(get_request_var('tree_id')));
}else{
$tree_name = '';
}
}
$tree_title = $tree_name . ($leaf_name != '' ? ' (' . $leaf_name:'') . ($leaf_sub != '' ? ':' . $leaf_sub . ')':($leaf_name != '' ? ')':''));
$current_nav .= "- " . htmlspecialchars($tree_title) . '
';
}else{
$current_nav .= '';
$tree_title = '';
}
$title .= htmlspecialchars(resolve_navigation_variables($current_array['title']) . ' ' . $tree_title);
/* keep a cache for each level we encounter */
$nav_level_cache{$current_array['level']} = array('id' => $current_page . ':' . $current_action, 'url' => get_browser_query_string());
$_SESSION['sess_nav_level_cache'] = $nav_level_cache;
if ($type == 'url') {
return $current_nav;
}else{
return $title;
}
}
/* resolve_navigation_variables - substitute any variables contained in the navigation text
@arg $text - the text to substitute in
@returns - the original navigation text with all substitutions made */
function resolve_navigation_variables($text) {
if (preg_match_all("/\|([a-zA-Z0-9_]+)\|/", $text, $matches)) {
for ($i=0; $i
");
}
/* debug_log_insert_section_end - finalizes the header started with the start function
@arg $type - the 'category' or type of debug message */
function debug_log_insert_section_end($type) {
debug_log_insert($type, " |
|
");
}
/* debug_log_insert - inserts a line of text into the debug log
@arg $type - the 'category' or type of debug message
@arg $text - the actual debug message */
function debug_log_insert($type, $text) {
if (!isset($_SESSION['debug_log'][$type])) {
$_SESSION['debug_log'][$type] = array();
}
array_push($_SESSION['debug_log'][$type], $text);
}
/* debug_log_clear - clears the debug log for a particular category
@arg $type - the 'category' to clear the debug log for. omitting this argument
implies all categories */
function debug_log_clear($type = '') {
if ($type == '') {
kill_session_var('debug_log');
}else{
if (isset($_SESSION['debug_log'])) {
unset($_SESSION['debug_log'][$type]);
}
}
}
/* debug_log_return - returns the debug log for a particular category
@arg $type - the 'category' to return the debug log for.
@returns - the full debug log for a particular category */
function debug_log_return($type) {
$log_text = '';
if ($type == 'new_graphs') {
if (isset($_SESSION['debug_log'][$type])) {
$log_text .= "";
for ($i=0; $i';
}
$log_text .= '
';
}
}else{
if (isset($_SESSION['debug_log'][$type])) {
$log_text .= "";
for ($i=0; $i';
}
$log_text .= '
';
}
}
return $log_text;
}
/* sanitize_search_string - cleans up a search string submitted by the user to be passed
to the database. NOTE: some of the code for this function came from the phpBB project.
@arg $string - the original raw search string
@returns - the sanitized search string */
function sanitize_search_string($string) {
static $drop_char_match = array('^', '$', '<', '>', '`', '\'', '"', '|', ',', '?', '+', '[', ']', '{', '}', '#', ';', '!', '=', '*');
static $drop_char_replace = array(' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
/* Replace line endings by a space */
$string = preg_replace('/[\n\r]/is', ' ', $string);
/* HTML entities like */
$string = preg_replace('/\b&[a-z]+;\b/', ' ', $string);
/* Remove URL's */
$string = preg_replace('/\b[a-z0-9]+:\/\/[a-z0-9\.\-]+(\/[a-z0-9\?\.%_\-\+=&\/]+)?/', ' ', $string);
/* Filter out strange characters like ^, $, &, change "it's" to "its" */
for($i = 0; $i < count($drop_char_match); $i++) {
$string = str_replace($drop_char_match[$i], $drop_char_replace[$i], $string);
}
return $string;
}
/** cleans up a URI, e.g. from REQUEST_URI and/or QUERY_STRING
* in case of XSS attac, expect the result to be broken
* we do NOT sanitize in a way, that attacs are converted to valid HTML
* it is ok, when the result is broken but the application stays alive
* @arg string $uri - the uri to be sanitized
* @returns string - the sanitized uri
*/
function sanitize_uri($uri) {
static $drop_char_match = array('^', '$', '<', '>', '`', '\'', '"', '|', '+', '[', ']', '{', '}', ';', '!');
static $drop_char_replace = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
return str_replace($drop_char_match, $drop_char_replace, urldecode($uri));
}
/** cleans up a CDEF/VDEF string
* the CDEF/VDEF must have passed all magic string replacements beforehand
* @arg string $cdef - the CDEF/VDEF to be sanitized
* @returns string - the sanitized CDEF/VDEF
*/
function sanitize_cdef($cdef) {
static $drop_char_match = array('^', '$', '<', '>', '`', '\'', '"', '|', '[', ']', '{', '}', ';', '!');
static $drop_char_replace = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '');
return str_replace($drop_char_match, $drop_char_replace, $cdef);
}
/** verifies all selected items are numeric to guard against injection
* @arg array $items - an array of serialized items from a post
* @returns array - the sanitized selected items array
*/
function sanitize_unserialize_selected_items($items) {
if ($items != '') {
$items = unserialize(stripslashes($items));
if (is_array($items)) {
for ($i=0;($i^()[]{}$\\";
for ($i=0; $i < strlen($replacements); $i++) {
$string = str_replace($replacements[$i], ' ', $string);
}
return $string;
}
}
/**
* mimics escapeshellarg, even for windows
* @param $string - the string to be escaped
* @param $quote - true: do NOT remove quotes from result; false: do remove quotes
* @return - the escaped [quoted|unquoted] string
*/
function cacti_escapeshellarg($string, $quote=true) {
global $config;
/* we must use an apostrophe to escape community names under Unix in case the user uses
characters that the shell might interpret. the ucd-snmp binaries on Windows flip out when
you do this, but are perfectly happy with a quotation mark. */
if ($config['cacti_server_os'] == 'unix') {
$string = escapeshellarg($string);
if ( $quote ) {
return $string;
} else {
# remove first and last char
return substr($string, 1, (strlen($string)-2));
}
}else{
/* escapeshellarg takes care of different quotation for both linux and windows,
* but unfortunately, it blanks out percent signs
* we want to keep them, e.g. for GPRINT format strings
* so we need to create our own escapeshellarg
* on windows, command injection requires to close any open quotation first
* so we have to escape any quotation here */
if (substr_count($string, CACTI_ESCAPE_CHARACTER)) {
$string = str_replace(CACTI_ESCAPE_CHARACTER, "\\" . CACTI_ESCAPE_CHARACTER, $string);
}
/* ... before we add our own quotation */
if ( $quote ) {
return CACTI_ESCAPE_CHARACTER . $string . CACTI_ESCAPE_CHARACTER;
} else {
return $string;
}
}
}
function bottom_footer() {
global $config;
if (!isset_request_var('header') || get_nfilter_request_var('header') == 'true') {
include($config['base_path'] . '/include/bottom_footer.php');
}else{
?>
name format
* @arg $cc - either a string of comma delimited email addresses, or an array of addresses in email_address => name format
* @arg $bcc - either a string of comma delimited email addresses, or an array of addresses in email_address => name format
* @arg $replyto - a string email address, or an array in array(email_address, name format)
* @arg $subject - the email subject
* @arg $body - the email body, in HTML format. If content_text is not set, the function will attempt to extract
* from the HTML format.
* @arg $body_text - the email body in TEXT format. If set, it will override the stripping tags method
* @arg $attachments - the emails attachments as an array
* @arg $headers - an array of name value pairs representing custom headers.
* @arg $html - if set to true, html is the default, otherwise text format will be used
*/
function mailer($from, $to, $cc, $bcc, $replyto, $subject, $body, $body_text = '', $attachments, $headers, $html = true) {
global $config;
include_once($config['include_path'] . '/phpmailer/PHPMailerAutoload.php');
// Set the to informaiotn
if ($to == '') {
return 'Mailer Error: No TO address set!!
If using the Test Mail link, please set the Alert e-mail setting.';
}
if (is_array($to)) {
$toText = $to[1] . ' <' . $to[0] . '>';
}else{
$toText = $to;
}
if (is_array($from)) {
$fromText = $from[1] . ' <' . $from[0] . '>';
}else{
$fromText = $from;
}
$body = str_replace('', $subject, $body);
$body = str_replace('', $toText, $body);
$body = str_replace('', $fromText, $body);
// Create the PHPMailer instance
$mail = new PHPMailer;
// Set a reasonable timeout of 5 seconds
$timeout = read_config_option('settings_smtp_timeout');
if (empty($timeout) || $timeout < 0 || $timeout > 300) {
$mail->Timeout = 5;
}else{
$mail->Timeout = $timeout;
}
// Set the subject
$mail->Subject = $subject;
$how = read_config_option('settings_how');
if ($how < 0 || $how > 2) {
$how = 0;
}
if ($how == 0) {
$mail->isMail();
} else if ($how == 1) {
$mail->Sendmail = read_config_option('settings_sendmail_path');
$mail->isSendmail();
} else if ($how == 2) {
$mail->isSMTP();
$mail->Host = read_config_option('settings_smtp_host');
$mail->Port = read_config_option('settings_smtp_port');
$mail->Username = read_config_option('settings_smtp_username');
$mail->Password = read_config_option('settings_smtp_password');
if ($mail->Username != '') {
$mail->SMTPAuth = true;
}
// Set a reasonable timeout of 5 seconds
$timeout = read_config_option('settings_smtp_timeout');
if (empty($timeout) || $timeout < 0 || $timeout > 300) {
$mail->Timeout = 5;
}else{
$mail->Timeout = $timeout;
}
$secure = read_config_option('settings_smtp_secure');
if (!empty($secure) && $secure != 'none') {
$smtp->SMTPSecure = $secure;
if (substr_count($mail->Host, ':') == 0) {
$mail->Host = $secure . '://' . $mail->Host;
}
}
}
// Set the from information
if (!is_array($from)) {
$fromname = '';
if ($from == '') {
$from = read_config_option('settings_from_email');
$fromname = read_config_option('settings_from_name');
if (isset($_SERVER['HOSTNAME'])) {
$from = 'Cacti@' . $_SERVER['HOSTNAME'];
} else {
$from = 'Cacti@cacti.net';
}
if ($fromname == '') {
$fromname = 'Cacti';
}
}
$mail->setFrom($from, $fromname);
}else{
$mail->setFrom($from[0], $from[1]);
}
if (!is_array($to)) {
$to = explode(',', $to);
foreach($to as $t) {
$t = trim($t);
if ($t != '') {
$mail->addAddress($t);
}
}
}else{
foreach($to as $email => $name) {
$mail->addAddress($email, $name);
}
}
if (!is_array($cc)) {
if ($cc != '') {
$cc = explode(',', $cc);
foreach($cc as $c) {
$c = trim($c);
$mail->addCC($c);
}
}
}else{
foreach($cc as $email => $name) {
$mail->addCC($email, $name);
}
}
if (!is_array($bcc)) {
if ($bcc != '') {
$bcc = explode(',', $bcc);
foreach($bcc as $bc) {
$bc = trim($bc);
$mail->addBCC($bc);
}
}
}else{
foreach($bcc as $email => $name) {
$mail->addBCC($email, $name);
}
}
if (!is_array($replyto)) {
if ($replyto != '') {
$mail->replyTo($replyto);
}
}else{
$mail->replyTo($replyto[0], $replyto[1]);
}
// Set the wordwrap limits
$wordwrap = read_config_option('settings_wordwrap');
if ($wordwrap == '')
$wordwrap = 76;
if ($wordwrap > 9999)
$wordwrap = 9999;
if ($wordwrap < 0)
$wordwrap = 76;
$mail->WordWrap = $wordwrap;
$mail->setWordWrap();
$i = 0;
// Handle Graph Attachments
if (is_array($attachments) && sizeof($attachments) && substr_count($body, '') > 0) {
foreach($attachments as $val) {
$graph_data_array = array('output_flag'=> RRDTOOL_OUTPUT_STDOUT);
$data = rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array);
if ($data != '') {
/* get content id and create attachment */
$cid = getmypid() . '_' . $i . '@' . 'localhost';
/* attempt to attach */
if ($mail->addStringEmbededImage($data, $cid, $val['filename'].'.png', 'base64', 'image/png', 'inline') === false) {
cacti_log('ERROR: ' . $mail->ErrorInfo, false);
return $mail->ErrorInfo;
}
$body = str_replace('', "
", $body);
} else {
$body = str_replace('', "

Could not open!
" . $val['file'], $body);
}
$i++;
}
}elseif (is_array($attachments) && sizeof($attachments) && substr_count($body, ' 0) {
foreach($attachments as $attachment) {
if ($attachment['attachment'] != '') {
/* get content id and create attachment */
$cid = getmypid() . '_' . $i . '@' . 'localhost';
/* attempt to attach */
if ($mail->addStringEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], 'base64', $attachment['mime_type'], $attachment['inline']) === false) {
cacti_log('ERROR: ' . $mail->ErrorInfo, false);
return $mail->ErrorInfo;
}
/* handle the body text */
switch ($attachment['inline']) {
case 'inline':
$body = str_replace('', "
", $body);
break;
case 'attachment':
$body = str_replace('', '', $body);
break;
}
} else {
$body = str_replace('', "
Could not open!
" . $attachment['filename'], $body);
}
$i++;
}
}
/* process custom headers */
if (is_array($headers) && sizeof($headers)) {
foreach($headers as $name => $value) {
$mail->addCustomHeader($name, $value);
}
}
// Set both html and non-html bodies
$text = array('text' => '', 'html' => '');
if ($body_text != '' && $html == true) {
$text['html'] = $body . '
';
$text['text'] = $body_text;
$mail->isHTML(true);
$mail->Body = $text['html'];
$mail->AltBody = $text['text'];
}elseif ($attachments == '' && $html == false) {
if ($body_text != '') {
$body = $body_text;
}else{
$body = str_replace('
', "\n", $body);
$body = str_replace('
', "\n", $body);
$body = str_replace('', "\n", $body);
}
$text['text'] = strip_tags($body);
$mail->isHTML(false);
$mail->Body = $text['text'];
$mail->AltBody = $text['text'];
} else {
$text['html'] = $body . '
';
$text['text'] = strip_tags(str_replace('
', "\n", $body));
$mail->isHTML(true);
$mail->Body = $text['html'];
$mail->AltBody = $text['text'];
}
if ($mail->send()) {
return '';
}else{
return $mail->ErrorInfo;
}
}
function ping_mail_server($host, $port, $user, $password, $timeout = 5, $secure = 'none') {
global $config;
include_once($config['include_path'] . '/phpmailer/PHPMailerAutoload.php');
//Create a new SMTP instance
$smtp = new SMTP;
if ($secure != 'tls' && $secure != 'none') {
$smtp->SMTPSecure = $secure;
if (substr_count($host, ':') == 0) {
$host = $secure . '://' . $host;
}
}
//Enable connection-level debug output
$smtp->do_debug = 0;
//$smtp->do_debug = SMTP::DEBUG_LOWLEVEL;
$results = true;
try {
//Connect to an SMTP server
if ($smtp->connect($host, $port, $timeout)) {
//Say hello
if ($smtp->hello(gethostbyname(gethostname()))) { //Put your host name in here
//Authenticate
if ($smtp->authenticate($user, $password)) {
$results = true;
} else {
throw new Exception('Authentication failed: ' . $smtp->getLastReply());
}
} else {
throw new Exception('HELO failed: '. $smtp->getLastReply());
}
} else {
throw new Exception('Connect failed');
}
} catch (Exception $e) {
$results = 'SMTP error: ' . $e->getMessage();
}
//Whatever happened, close the connection.
$smtp->quit(true);
return $results;
}
function email_test() {
global $config;
$message = 'This is a test message generated from Cacti. This message was sent to test the configuration of your Mail Settings.
';
$message .= 'Your email settings are currently set as follows
';
$message .= 'Method: ';
print 'Checking Configuration...
';
$ping_results = true;
$how = read_config_option('settings_how');
if ($how < 0 || $how > 2)
$how = 0;
if ($how == 0) {
$mail = "PHP's Mailer Class";
} else if ($how == 1) {
$mail = 'Sendmail
Sendmail Path: ';
$sendmail = read_config_option('settings_sendmail_path');
$mail .= $sendmail;
} else if ($how == 2) {
print 'Method: SMTP
';
$mail = 'SMTP
';
$smtp_host = read_config_option('settings_smtp_host');
$smtp_port = read_config_option('settings_smtp_port');
$smtp_username = read_config_option('settings_smtp_username');
$smtp_password = read_config_option('settings_smtp_password');
$smtp_secure = read_config_option('settings_smtp_secure');
$smtp_timeout = read_config_option('settings_smtp_timeout');
$mail .= "Device: $smtp_host
";
$mail .= "Port: $smtp_port
";
if ($smtp_username != '' && $smtp_password != '') {
$mail .= 'Authentication: true
';
$mail .= "Username: $smtp_username
";
$mail .= 'Password: (Not Shown for Security Reasons)
';
$mail .= "Security: $smtp_secure
";
} else {
$mail .= 'Authentication: false
';
}
$ping_results = ping_mail_server($smtp_host, $smtp_port, $smtp_username, $smtp_password, $smtp_timeout, $smtp_secure);
print 'Ping Results: ' . ($ping_results == 1 ? 'Success':$ping_results) . '
';
if ($ping_results != 1) {
$mail .= 'Ping Results: ' . $ping_results . '
';
}else{
$mail .= 'Ping Results: Success
';
}
}
$message .= $mail;
$message .= '
';
$errors = '';
if ($ping_results == 1) {
print 'Creating Message Text...
';
print "
";
print 'Sending Message...
';
$global_alert_address = read_config_option('settings_test_email');
$errors = send_mail($global_alert_address, '', 'Cacti Test Message', $message, '', '', true);
if ($errors == '') {
$errors = 'Success!';
}
}else{
print 'Message Not Sent due to ping failure.
';
}
print "";
}
/* gethostbyaddr_wtimeout - This function provides a good method of performing
a rapid lookup of a DNS entry for a host so long as you don't have to look far.
*/
function get_dns_from_ip ($ip, $dns, $timeout = 1000) {
/* random transaction number (for routers etc to get the reply back) */
$data = rand(10, 99);
/* trim it to 2 bytes */
$data = substr($data, 0, 2);
/* create request header */
$data .= "\1\0\0\1\0\0\0\0\0\0";
/* split IP into octets */
$octets = explode('.', $ip);
/* perform a quick error check */
if (count($octets) != 4) return 'ERROR';
/* needs a byte to indicate the length of each segment of the request */
for ($x=3; $x>=0; $x--) {
switch (strlen($octets[$x])) {
case 1: // 1 byte long segment
$data .= "\1"; break;
case 2: // 2 byte long segment
$data .= "\2"; break;
case 3: // 3 byte long segment
$data .= "\3"; break;
default: // segment is too big, invalid IP
return 'ERROR';
}
/* and the segment itself */
$data .= $octets[$x];
}
/* and the final bit of the request */
$data .= "\7in-addr\4arpa\0\0\x0C\0\1";
/* create UDP socket */
$handle = @fsockopen("udp://$dns", 53);
@stream_set_timeout($handle, floor($timeout/1000), ($timeout*1000)%1000000);
@stream_set_blocking($handle, 1);
/* send our request (and store request size so we can cheat later) */
$requestsize = @fwrite($handle, $data);
/* get the response */
$response = @fread($handle, 1000);
/* check to see if it timed out */
$info = @stream_get_meta_data($handle);
/* close the socket */
@fclose($handle);
if ($info['timed_out']) {
return 'timed_out';
}
/* more error handling */
if ($response == '') { return $ip; }
/* parse the response and find the response type */
$type = @unpack('s', substr($response, $requestsize+2));
if (isset($type[1]) && $type[1] == 0x0C00) {
/* set up our variables */
$host = '';
$len = 0;
/* set our pointer at the beginning of the hostname uses the request
size from earlier rather than work it out.
*/
$position = $requestsize + 12;
/* reconstruct the hostname */
do {
/* get segment size */
$len = unpack('c', substr($response, $position));
/* null terminated string, so length 0 = finished */
if ($len[1] == 0) {
/* return the hostname, without the trailing '.' */
return strtoupper(substr($host, 0, strlen($host) -1));
}
/* add the next segment to our host */
$host .= substr($response, $position+1, $len[1]) . '.';
/* move pointer on to the next segment */
$position += $len[1] + 1;
} while ($len != 0);
/* error - return the hostname we constructed (without the . on the end) */
return strtoupper($ip);
}
/* error - return the hostname */
return strtoupper($ip);
}
function poller_maintenance () {
global $config;
$command_string = trim(read_config_option('path_php_binary'));
// If its not set, just assume its in the path
if (trim($command_string) == '') {
$command_string = 'php';
}
$extra_args = ' -q ' . $config['base_path'] . '/poller_maintenance.php';
exec_background($command_string, $extra_args);
}
function clog_admin() {
if (!isset($_SESSION['sess_clog_level'])) {
clog_authorized();
}
if ($_SESSION["sess_clog_level"] == CLOG_PERM_ADMIN) {
return true;
}else{
return false;
}
}
function clog_authorized() {
if (!isset($_SESSION['sess_clog_level'])) {
if (isset($_SESSION['sess_user_id'])) {
if (is_realm_allowed(18)) {
$_SESSION['sess_clog_level'] = CLOG_PERM_ADMIN;
}else{
if (is_realm_allowed(19)) {
$_SESSION['sess_clog_level'] = CLOG_PERM_USER;
}else {
$_SESSION['sess_clog_level'] = CLOG_PERM_NONE;
}
}
}else{
$_SESSION['sess_clog_level'] = CLOG_PERM_NONE;
}
}
if ($_SESSION['sess_clog_level'] == CLOG_PERM_USER) {
return true;
}elseif ($_SESSION['sess_clog_level'] == CLOG_PERM_ADMIN) {
return true;
}else{
return false;
}
}
function update_system_mibs($host_id) {
$system_mibs = array(
'snmp_sysDescr' => '.1.3.6.1.2.1.1.1.0',
'snmp_sysObjectID' => '.1.3.6.1.2.1.1.2.0',
'snmp_sysUpTimeInstance' => '.1.3.6.1.2.1.1.3.0',
'snmp_sysContact' => '.1.3.6.1.2.1.1.4.0',
'snmp_sysName' => '.1.3.6.1.2.1.1.5.0',
'snmp_sysLocation' => '.1.3.6.1.2.1.1.6.0'
);
$h = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array($host_id));
if (sizeof($h)) {
foreach($system_mibs as $name => $oid) {
$value = cacti_snmp_get($h['hostname'], $h['snmp_community'], $oid,
$h['snmp_version'], $h['snmp_username'], $h['snmp_password'],
$h['snmp_auth_protocol'], $h['snmp_priv_passphrase'], $h['snmp_priv_protocol'],
$h['snmp_context'], $h['snmp_port'], $h['snmp_timeout'], read_config_option('snmp_retries'), SNMP_CMDPHP);
if (!empty($value)) {
db_execute_prepared("UPDATE host SET $name = ? WHERE id = ?",
array($value, $host_id));
}
}
}
}
function cacti_debug_backtrace($entry = '', $html = false) {
global $config;
$callers = debug_backtrace();
$s = '';
foreach ($callers as $c) {
if (isset($c['file'])) {
$file = str_replace($config['base_path'], '', $c['file']);
}else{
$file = '';
}
if (isset($c['line'])) {
$line = $c['line'];
}else{
$line = '';
}
$func = $c['function'];
$s = "(" . ($file != '' ? "$file: ":'') . ($line != '' ? "$line ":'') . "$func)" . $s;
}
if ($html) {
echo "\n";
}
cacti_log(trim("$entry Backtrace: $s"), false);
}