diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index e4592e0a22..4ef27c2c0c 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -125,6 +125,7 @@ $config['show_locations'] = 1; # Enable Locations on menu $config['show_locations_dropdown'] = 1; # Enable Locations dropdown on menu $config['show_services'] = 0; # Enable Services on menu $config['int_customers'] = 1; # Enable Customer Port Parsing +$config['customers_descr'] = 'cust'; // The description to look for in ifDescr. Can be an array as well array('cust','cid'); $config['int_transit'] = 1; # Enable Transit Types $config['int_peering'] = 1; # Enable Peering Types $config['int_core'] = 1; # Enable Core Port Types diff --git a/html/includes/graphs/customer/bits.inc.php b/html/includes/graphs/customer/bits.inc.php index fe438c8999..e279c8691a 100644 --- a/html/includes/graphs/customer/bits.inc.php +++ b/html/includes/graphs/customer/bits.inc.php @@ -2,7 +2,13 @@ // Generate a list of ports and then call the multi_bits grapher to generate from the list $i=0; -foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ? AND D.device_id = I.device_id", array($vars['id'])) as $port) + +if (!is_array($config['customers_descr'])) { + $config['customers_descr'] = array($config['customers_descr']); +} +$descr_type = "'". implode("', '", $config['customers_descr']) ."'"; + +foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id", array(array($descr_type),$vars['id'])) as $port) { if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) { diff --git a/html/pages/customers.inc.php b/html/pages/customers.inc.php index fc2d8b14ab..c8a57a80a4 100644 --- a/html/pages/customers.inc.php +++ b/html/pages/customers.inc.php @@ -18,7 +18,12 @@ $i = 1; $pagetitle[] = "Customers"; -foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`") as $customer) +if (!is_array($config['customers_descr'])) { + $config['customers_descr'] = array($config['customers_descr']); +} +$descr_type = "'". implode("', '", $config['customers_descr']) ."'"; + +foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` IN (?) GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`", array(array($descr_type))) as $customer) { $i++; @@ -26,7 +31,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GRO if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) + foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ?", array(array($descr_type),$customer['port_descr_descr'])) as $port) { $device = device_by_id_cache($port['device_id']); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 30ed7df075..e2d9b48ce7 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -128,6 +128,7 @@ $config['public_status'] = false; // Enable public accessable status page $config['old_graphs'] = 1; // RRDfiles from before the great rra reform. This is default for a while. $config['int_customers'] = 1; # Enable Customer Port Parsing +$config['customers_descr'] = 'cust'; $config['int_transit'] = 1; # Enable Transit Types $config['int_peering'] = 1; # Enable Peering Types $config['int_core'] = 1; # Enable Core Port Types