mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Remove inappropriate usages of truncate() (#5028)
Where truncate() is used as substr(), replace with substr()
This commit is contained in:
committed by
Neil Lathwood
parent
e469aa97b0
commit
a83e126b40
@@ -11,7 +11,7 @@ $i = 0;
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
foreach ($oids as $oid) {
|
||||
$oid = str_replace('dot3Stats', '', $oid);
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$oid_ds = substr($oid, 0, 19);
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $oid;
|
||||
$rrd_list[$i]['ds'] = $oid_ds;
|
||||
|
@@ -7,8 +7,8 @@ if ($config['old_graphs']) {
|
||||
// args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, percentile
|
||||
include 'includes/graphs/common.inc.php';
|
||||
|
||||
$unit_text = str_pad(truncate($unit_text, 18, ''), 18);
|
||||
$line_text = str_pad(truncate($line_text, 12, ''), 12);
|
||||
$unit_text = str_pad(substr($unit_text, 0, 18), 18);
|
||||
$line_text = str_pad(substr($line_text, 0, 12), 12);
|
||||
|
||||
if ($multiplier) {
|
||||
$rrd_options .= ' DEF:'.$ds.'_o='.$rrd_filename.':'.$ds.':AVERAGE';
|
||||
|
@@ -8,7 +8,7 @@ $oids = array(
|
||||
$i = 0;
|
||||
|
||||
foreach ($oids as $oid) {
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$oid_ds = substr($oid, 0, 19);
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $oid;
|
||||
$rrd_list[$i]['ds'] = $oid_ds;
|
||||
|
@@ -4,8 +4,8 @@
|
||||
// args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, percentile
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$unit_text = str_pad(truncate($unit_text, 18, ''), 18);
|
||||
$line_text = str_pad(truncate($line_text, 12, ''), 12);
|
||||
$unit_text = str_pad(substr($unit_text, 0, 18), 18);
|
||||
$line_text = str_pad(substr($line_text, 0, 12), 12);
|
||||
|
||||
if ($multiplier) {
|
||||
if (empty($multiplier_action)) {
|
||||
|
@@ -23,7 +23,7 @@ $rrd_filename = get_port_rrdfile_path($device['hostname'], $port['port_id'], 'do
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
foreach ($oids as $oid) {
|
||||
$oid = str_replace('dot3Stats', '', $oid);
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$oid_ds = substr($oid, 0, 19);
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $oid;
|
||||
$rrd_list[$i]['ds'] = $oid_ds;
|
||||
|
@@ -62,6 +62,6 @@ echo '</td>';
|
||||
echo ' <td>'.$device['hardware'].' '.$device['features'].'</td>';
|
||||
echo ' <td>'.formatUptime($device['uptime'], 'short').' <br />';
|
||||
|
||||
echo ' '.truncate($device['location'], 32, '').'</td>';
|
||||
echo ' '.substr($device['location'], 0, 32).'</td>';
|
||||
|
||||
echo ' </tr>';
|
||||
|
@@ -42,7 +42,7 @@ foreach ($vlan_ports as $port) {
|
||||
<img src=\'graph.php?type=$graph_type&id=".$port['port_id'].'&from='.$config['time']['twoday'].'&to='.$config['time']['now']."&width=450&height=150\'>\
|
||||
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"."<img src='graph.php?type=$graph_type&id=".$port['port_id'].'&from='.$config['time']['twoday'].'&to='.$config['time']['now']."&width=132&height=40&legend=no'>
|
||||
</a>
|
||||
<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 22, '').'</div>
|
||||
<div style='font-size: 9px;'>".substr(short_port_descr($port['ifAlias']), 0, 22).'</div>
|
||||
</div>';
|
||||
} else {
|
||||
echo $vlan['port_sep'].generate_port_link($port, makeshortif($port['label']));
|
||||
|
@@ -25,7 +25,7 @@ foreach (dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?'
|
||||
<img src=\'graph.php?type=$graph_type&id=".$port['port_id'].'&from='.$config['time']['twoday'].'&to='.$config['time']['now']."&width=450&height=150\'>\
|
||||
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"."<img src='graph.php?type=$graph_type&id=".$port['port_id'].'&from='.$config['time']['twoday'].'&to='.$config['time']['now']."&width=132&height=40&legend=no'>
|
||||
</a>
|
||||
<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 22, '').'</div>
|
||||
<div style='font-size: 9px;'>".substr(short_port_descr($port['ifAlias']), 0, 22).'</div>
|
||||
</div>';
|
||||
} else {
|
||||
echo $vrf['port_sep'].generate_port_link($port, makeshortif($port['ifDescr']));
|
||||
|
@@ -190,7 +190,7 @@ foreach (dbFetchRows($sql, $param) as $device) {
|
||||
if (extension_loaded('mbstring')) {
|
||||
$location = mb_substr($device['location'], 0, 32, 'utf8');
|
||||
} else {
|
||||
$location = truncate($device['location'], 32, '');
|
||||
$location = substr($device['location'], 0, 32);
|
||||
}
|
||||
|
||||
if ($subformat == 'detail') {
|
||||
|
@@ -93,7 +93,7 @@ foreach (dbFetchRows($sql, $param) as $sensor) {
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$sensor_minigraph = generate_lazy_graph_tag($graph_array);
|
||||
|
||||
$sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, '');
|
||||
$sensor['sensor_descr'] = substr($sensor['sensor_descr'], 0, 48);
|
||||
|
||||
$response[] = array(
|
||||
'hostname' => generate_device_link($sensor),
|
||||
|
Reference in New Issue
Block a user