mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
@@ -134,11 +134,9 @@ function escape_quotes($text)
|
||||
|
||||
function generate_overlib_content($graph_array, $text)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$overlib_content = '<div class=overlib><span class=overlib-text>' . $text . '</span><br />';
|
||||
foreach (array('day', 'week', 'month', 'year') as $period) {
|
||||
$graph_array['from'] = $config['time'][$period];
|
||||
$graph_array['from'] = Config::get("time.$period");
|
||||
$overlib_content .= escape_quotes(generate_graph_tag($graph_array));
|
||||
}
|
||||
|
||||
@@ -168,14 +166,12 @@ function generate_device_url($device, $vars = array())
|
||||
|
||||
function generate_device_link($device, $text = null, $vars = array(), $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!$start) {
|
||||
$start = $config['time']['day'];
|
||||
$start = Config::get('time.day');
|
||||
}
|
||||
|
||||
if (!$end) {
|
||||
$end = $config['time']['now'];
|
||||
$end = Config::get('time.now');
|
||||
}
|
||||
|
||||
$class = devclass($device);
|
||||
@@ -186,13 +182,13 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0
|
||||
$text = format_hostname($device, $text);
|
||||
|
||||
if ($device['snmp_disable']) {
|
||||
$graphs = $config['os']['ping']['over'];
|
||||
} elseif (isset($config['os'][$device['os']]['over'])) {
|
||||
$graphs = $config['os'][$device['os']]['over'];
|
||||
} elseif (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) {
|
||||
$graphs = $config['os'][$device['os_group']]['over'];
|
||||
$graphs = Config::get('os.ping.over');
|
||||
} elseif (Config::has("os.{$device['os']}.over")) {
|
||||
$graphs = Config::get("os.{$device['os']}.over");
|
||||
} elseif (isset($device['os_group']) && Config::has("os.{$device['os_group']}.over")) {
|
||||
$graphs = Config::get("os.{$device['os_group']}.over");
|
||||
} else {
|
||||
$graphs = $config['os']['default']['over'];
|
||||
$graphs = Config::get('os.default.over');
|
||||
}
|
||||
|
||||
$url = generate_device_url($device, $vars);
|
||||
@@ -204,7 +200,7 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0
|
||||
}
|
||||
|
||||
if ($device['os']) {
|
||||
$contents .= ' - ' . mres($config['os'][$device['os']]['text']);
|
||||
$contents .= ' - ' . Config::get("os.{$device['os']}.text");
|
||||
}
|
||||
|
||||
if ($device['version']) {
|
||||
@@ -227,7 +223,7 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0
|
||||
$contents .= '<div class="overlib-box">';
|
||||
$contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
|
||||
$contents .= generate_minigraph_image($device, $start, $end, $graph);
|
||||
$contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph);
|
||||
$contents .= generate_minigraph_image($device, Config::get('time.week'), $end, $graph);
|
||||
$contents .= '</div>';
|
||||
}
|
||||
|
||||
@@ -257,8 +253,6 @@ function overlib_link($url, $text, $contents, $class = null)
|
||||
|
||||
function generate_graph_popup($graph_array)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Take $graph_array and print day,week,month,year graps in overlib, hovered over graph
|
||||
$original_from = $graph_array['from'];
|
||||
|
||||
@@ -268,13 +262,13 @@ function generate_graph_popup($graph_array)
|
||||
$graph_array['legend'] = 'yes';
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['from'] = Config::get('time.day');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$graph_array['from'] = Config::get('time.week');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$graph_array['from'] = Config::get('time.month');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$graph_array['from'] = Config::get('time.year');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= '</div>';
|
||||
|
||||
@@ -436,7 +430,7 @@ function print_percentage_bar($width, $height, $percent, $left_text, $left_colou
|
||||
|
||||
function generate_entity_link($type, $entity, $text = null, $graph_type = null)
|
||||
{
|
||||
global $config, $entity_cache;
|
||||
global $entity_cache;
|
||||
|
||||
if (is_numeric($entity)) {
|
||||
$entity = get_entity_by_id_cache($type, $entity);
|
||||
@@ -465,8 +459,6 @@ function generate_entity_link($type, $entity, $text = null, $graph_type = null)
|
||||
|
||||
function generate_port_link($port, $text = null, $type = null, $overlib = 1, $single_graph = 0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$graph_array = array();
|
||||
|
||||
if (!$text) {
|
||||
@@ -497,16 +489,16 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
|
||||
$graph_array['legend'] = 'yes';
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['to'] = Config::get('time.now');
|
||||
$graph_array['from'] = Config::get('time.day');
|
||||
$graph_array['id'] = $port['port_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
if ($single_graph == 0) {
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$graph_array['from'] = Config::get('time.week');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$graph_array['from'] = Config::get('time.month');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$graph_array['from'] = Config::get('time.year');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
}
|
||||
|
||||
@@ -611,10 +603,9 @@ function generate_port_image($args)
|
||||
|
||||
function generate_port_thumbnail($port)
|
||||
{
|
||||
global $config;
|
||||
$port['graph_type'] = 'port_bits';
|
||||
$port['from'] = $config['time']['day'];
|
||||
$port['to'] = $config['time']['now'];
|
||||
$port['from'] = Config::get('time.day');
|
||||
$port['to'] = Config::get('time.now');
|
||||
$port['width'] = 150;
|
||||
$port['height'] = 21;
|
||||
return generate_port_image($port);
|
||||
@@ -731,8 +722,6 @@ function foldersize($path)
|
||||
|
||||
function generate_ap_link($args, $text = null, $type = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$args = cleanPort($args);
|
||||
if (!$text) {
|
||||
$text = fixIfName($args['label']);
|
||||
@@ -761,15 +750,15 @@ function generate_ap_link($args, $text = null, $type = null)
|
||||
$graph_array['legend'] = 'yes';
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['to'] = Config::get('time.now');
|
||||
$graph_array['from'] = Config::get('time.day');
|
||||
$graph_array['id'] = $args['accesspoint_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$graph_array['from'] = Config::get('time.week');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$graph_array['from'] = Config::get('time.month');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$graph_array['from'] = Config::get('time.year');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= '</div>';
|
||||
|
||||
@@ -789,8 +778,7 @@ function generate_ap_url($ap, $vars = array())
|
||||
|
||||
function report_this_text($message)
|
||||
{
|
||||
global $config;
|
||||
return $message . '\nPlease report this to the ' . $config['project_name'] . ' developers at ' . $config['project_issues'] . '\n';
|
||||
return $message . '\nPlease report this to the ' . Config::get('project_name') . ' developers at ' . Config::get('project_issues') . '\n';
|
||||
}//end report_this_text()
|
||||
|
||||
|
||||
@@ -799,8 +787,6 @@ function report_this_text($message)
|
||||
|
||||
function get_matching_files($dir, $match = '/\.php$/')
|
||||
{
|
||||
global $config;
|
||||
|
||||
$list = array();
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
@@ -1176,8 +1162,6 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
||||
*/
|
||||
function get_ports_from_type($given_types)
|
||||
{
|
||||
global $config;
|
||||
|
||||
# Make the arg an array if it isn't, so subsequent steps only have to handle arrays.
|
||||
if (!is_array($given_types)) {
|
||||
$given_types = array($given_types);
|
||||
@@ -1187,13 +1171,14 @@ function get_ports_from_type($given_types)
|
||||
# be key/valued to some other string that's actually searched for in the DB. Merge or append the
|
||||
# configured value if it's an array or a string. Or append the argument itself if there's no matching
|
||||
# entry in config.
|
||||
$search_types = array();
|
||||
$search_types = [];
|
||||
foreach ($given_types as $type) {
|
||||
if (isset($config[$type . '_descr']) === true) {
|
||||
if (is_array($config[$type . '_descr']) === true) {
|
||||
$search_types = array_merge($search_types, $config[$type . '_descr']);
|
||||
if (Config::has($type . '_descr')) {
|
||||
$type_descr = Config::get($type . '_descr');
|
||||
if (is_array($type_descr)) {
|
||||
$search_types = array_merge($search_types, $type_descr);
|
||||
} else {
|
||||
$search_types[] = $config[$type . '_descr'];
|
||||
$search_types[] = $type_descr;
|
||||
}
|
||||
} else {
|
||||
$search_types[] = $type;
|
||||
@@ -1242,14 +1227,12 @@ function file_download($filename, $content)
|
||||
|
||||
function get_rules_from_json()
|
||||
{
|
||||
global $config;
|
||||
return json_decode(file_get_contents($config['install_dir'] . '/misc/alert_rules.json'), true);
|
||||
return json_decode(file_get_contents(Config::get('install_dir') . '/misc/alert_rules.json'), true);
|
||||
}
|
||||
|
||||
function search_oxidized_config($search_in_conf_textbox)
|
||||
{
|
||||
global $config;
|
||||
$oxidized_search_url = $config['oxidized']['url'] . '/nodes/conf_search?format=json';
|
||||
$oxidized_search_url = Config::get('oxidized.url') . '/nodes/conf_search?format=json';
|
||||
$postdata = http_build_query(
|
||||
array(
|
||||
'search_in_conf_textbox' => $search_in_conf_textbox,
|
||||
@@ -1312,9 +1295,7 @@ function set_image_type()
|
||||
|
||||
function get_image_type()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($config['webui']['graph_type'] === 'svg') {
|
||||
if (Config::get('webui.graph_type') === 'svg') {
|
||||
return 'image/svg+xml';
|
||||
} else {
|
||||
return 'image/png';
|
||||
@@ -1323,15 +1304,13 @@ function get_image_type()
|
||||
|
||||
function get_oxidized_nodes_list()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$context = stream_context_create(array(
|
||||
'http' => array(
|
||||
'header' => "Accept: application/json",
|
||||
)
|
||||
));
|
||||
|
||||
$data = json_decode(file_get_contents($config['oxidized']['url'] . '/nodes?format=json', false, $context), true);
|
||||
$data = json_decode(file_get_contents(Config::get('oxidized.url') . '/nodes?format=json', false, $context), true);
|
||||
|
||||
foreach ($data as $object) {
|
||||
$device = device_by_name($object['name']);
|
||||
|
Reference in New Issue
Block a user