mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
@@ -123,8 +123,7 @@ function check_is_read()
|
||||
|
||||
function check_not_demo()
|
||||
{
|
||||
global $config;
|
||||
if ($config['api_demo'] == 1) {
|
||||
if (Config::get('api_demo') == 1) {
|
||||
api_error(500, 'This feature isn\'t available in the demo');
|
||||
}
|
||||
}
|
||||
@@ -132,7 +131,6 @@ function check_not_demo()
|
||||
function get_graph_by_port_hostname()
|
||||
{
|
||||
// This will return a graph for a given port by the ifName
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
@@ -209,7 +207,6 @@ function get_port_stats_by_port_hostname()
|
||||
function get_graph_generic_by_hostname()
|
||||
{
|
||||
// This will return a graph type given a device id.
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
@@ -378,7 +375,6 @@ function add_device()
|
||||
|
||||
// This will add a device using the data passed encoded with json
|
||||
// FIXME: Execution flow through this function could be improved
|
||||
global $config;
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$additional = array();
|
||||
@@ -392,7 +388,7 @@ function add_device()
|
||||
}
|
||||
|
||||
$hostname = $data['hostname'];
|
||||
$port = $data['port'] ? mres($data['port']) : $config['snmp']['port'];
|
||||
$port = $data['port'] ? mres($data['port']) : Config::get('snmp.port');
|
||||
$transport = $data['transport'] ? mres($data['transport']) : 'udp';
|
||||
$poller_group = $data['poller_group'] ? mres($data['poller_group']) : 0;
|
||||
$force_add = $data['force_add'] ? true : false;
|
||||
@@ -406,7 +402,7 @@ function add_device()
|
||||
);
|
||||
} elseif ($data['version'] == 'v1' || $data['version'] == 'v2c') {
|
||||
if ($data['community']) {
|
||||
$config['snmp']['community'] = array($data['community']);
|
||||
Config::set('snmp.community', [$data['community']]);
|
||||
}
|
||||
|
||||
$snmpver = mres($data['version']);
|
||||
@@ -420,7 +416,9 @@ function add_device()
|
||||
'cryptoalgo' => mres($data['cryptoalgo']),
|
||||
);
|
||||
|
||||
array_unshift($config['snmp']['v3'], $v3);
|
||||
$v3_config = Config::get('snmp.v3');
|
||||
array_unshift($v3_config, $v3);
|
||||
Config::set('snmp.v3', $v3_config);
|
||||
$snmpver = 'v3';
|
||||
} else {
|
||||
api_error(400, 'You haven\'t specified an SNMP version to use');
|
||||
@@ -440,7 +438,6 @@ function del_device()
|
||||
check_is_admin();
|
||||
|
||||
// This will add a device using the data passed encoded with json
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
@@ -503,12 +500,11 @@ function get_vlans()
|
||||
|
||||
function show_endpoints()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$routes = $app->router()->getNamedRoutes();
|
||||
$output = array();
|
||||
foreach ($routes as $route) {
|
||||
$output[$route->getName()] = $config['base_url'].$route->getPattern();
|
||||
$output[$route->getName()] = Config::get('base_url') . $route->getPattern();
|
||||
}
|
||||
|
||||
$app->response->setStatus('200');
|
||||
@@ -634,7 +630,6 @@ function list_ospf()
|
||||
function get_graph_by_portgroup()
|
||||
{
|
||||
check_is_read();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$group = $router['group'] ?: '';
|
||||
@@ -768,7 +763,6 @@ function delete_components()
|
||||
|
||||
function get_graphs()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
@@ -787,7 +781,7 @@ function get_graphs()
|
||||
'name' => 'device_ping_perf',
|
||||
);
|
||||
foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device_id)) as $graph) {
|
||||
$desc = $config['graph_types']['device'][$graph['graph']]['descr'];
|
||||
$desc = Config::get("graph_types.device.{$graph['graph']}.descr");
|
||||
$graphs[] = array(
|
||||
'desc' => $desc,
|
||||
'name' => 'device_'.$graph['graph'],
|
||||
@@ -1246,7 +1240,6 @@ function unmute_alert()
|
||||
|
||||
function get_inventory()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
|
||||
@@ -1282,14 +1275,13 @@ function get_inventory()
|
||||
function list_oxidized()
|
||||
{
|
||||
check_is_read();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
|
||||
$hostname = $router['hostname'];
|
||||
$devices = array();
|
||||
$device_types = "'".implode("','", $config['oxidized']['ignore_types'])."'";
|
||||
$device_os = "'".implode("','", $config['oxidized']['ignore_os'])."'";
|
||||
$device_types = "'" . implode("','", Config::get('oxidized.ignore_types')) . "'";
|
||||
$device_os = "'" . implode("','", Config::get('oxidized.ignore_os')) . "'";
|
||||
|
||||
$sql = '';
|
||||
$params = array();
|
||||
@@ -1303,12 +1295,12 @@ function list_oxidized()
|
||||
$device['ip'] = inet6_ntop($device['ip']);
|
||||
|
||||
// Pre-populate the group with the default
|
||||
if ($config['oxidized']['group_support'] === true && !empty($config['oxidized']['default_group'])) {
|
||||
$device['group'] = $config['oxidized']['default_group'];
|
||||
if (Config::get('oxidized.group_support') === true && !empty(Config::get('oxidized.default_group'))) {
|
||||
$device['group'] = Config::get('oxidized.default_group');
|
||||
}
|
||||
foreach ($config['oxidized']['maps'] as $maps_column => $maps) {
|
||||
foreach (Config::get('oxidized.maps') as $maps_column => $maps) {
|
||||
// Based on Oxidized group support we can apply groups by setting group_support to true
|
||||
if ($maps_column == "group" && (!isset($config['oxidized']['group_support']) or $config['oxidized']['group_support'] !== true)) {
|
||||
if ($maps_column == "group" && Config::get('oxidized.group_support', true) !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1347,7 +1339,6 @@ function list_oxidized()
|
||||
|
||||
function list_bills()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
|
||||
@@ -1422,7 +1413,6 @@ function list_bills()
|
||||
|
||||
function get_bill_graph()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
@@ -1448,7 +1438,6 @@ function get_bill_graph()
|
||||
|
||||
function get_bill_graphdata()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
@@ -1477,7 +1466,6 @@ function get_bill_graphdata()
|
||||
|
||||
function get_bill_history()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
@@ -1496,8 +1484,6 @@ function get_bill_history()
|
||||
|
||||
function get_bill_history_graph()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
@@ -1540,8 +1526,6 @@ function get_bill_history_graph()
|
||||
|
||||
function get_bill_history_graphdata()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
@@ -1755,7 +1739,6 @@ function create_edit_bill()
|
||||
function update_device()
|
||||
{
|
||||
check_is_admin();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
@@ -1797,7 +1780,6 @@ function update_device()
|
||||
function rename_device()
|
||||
{
|
||||
check_is_admin();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
@@ -2186,7 +2168,6 @@ function list_arp()
|
||||
function list_services()
|
||||
{
|
||||
check_is_read();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$services = array();
|
||||
@@ -2304,10 +2285,8 @@ function list_logs()
|
||||
|
||||
function validate_column_list($columns, $tableName)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$column_names = explode(',', $columns);
|
||||
$db_schema = Symfony\Component\Yaml\Yaml::parse(file_get_contents($config['install_dir'] . '/misc/db_schema.yaml'));
|
||||
$db_schema = Symfony\Component\Yaml\Yaml::parse(file_get_contents(Config::get('install_dir') . '/misc/db_schema.yaml'));
|
||||
$valid_columns = array_column($db_schema[$tableName]['Columns'], 'Field');
|
||||
$invalid_columns = array_diff(array_map('trim', $column_names), $valid_columns);
|
||||
|
||||
@@ -2326,7 +2305,6 @@ function validate_column_list($columns, $tableName)
|
||||
|
||||
function add_service_for_host()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
||||
Reference in New Issue
Block a user