refactor: Remove inappropriate usages of truncate() (#5028)

Where truncate() is used as substr(), replace with substr()
This commit is contained in:
Tony Murray
2016-11-20 05:12:25 -06:00
committed by Neil Lathwood
parent e469aa97b0
commit a83e126b40
27 changed files with 34 additions and 34 deletions

View File

@@ -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;

View File

@@ -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';

View File

@@ -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;

View File

@@ -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)) {

View File

@@ -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;

View File

@@ -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>';

View File

@@ -42,7 +42,7 @@ foreach ($vlan_ports as $port) {
<img src=\'graph.php?type=$graph_type&amp;id=".$port['port_id'].'&amp;from='.$config['time']['twoday'].'&amp;to='.$config['time']['now']."&amp;width=450&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"."<img src='graph.php?type=$graph_type&amp;id=".$port['port_id'].'&amp;from='.$config['time']['twoday'].'&amp;to='.$config['time']['now']."&amp;width=132&amp;height=40&amp;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']));

View File

@@ -25,7 +25,7 @@ foreach (dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?'
<img src=\'graph.php?type=$graph_type&amp;id=".$port['port_id'].'&amp;from='.$config['time']['twoday'].'&amp;to='.$config['time']['now']."&amp;width=450&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"."<img src='graph.php?type=$graph_type&amp;id=".$port['port_id'].'&amp;from='.$config['time']['twoday'].'&amp;to='.$config['time']['now']."&amp;width=132&amp;height=40&amp;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']));

View File

@@ -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') {

View File

@@ -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),