Issues (2963)

includes/html/graphs/generic_v3_multiline.inc.php (1 issue)

1
<?php
2
3
require 'includes/html/graphs/common.inc.php';
4
5
if ($width > '500') {
6
    $descr_len = $bigdescrlen;
7
} else {
8
    $descr_len = $smalldescrlen;
9
}
10
11
if ($printtotal === 1) {
12
    $descr_len += '2';
13
    $unitlen += '2';
14
}
15
16
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
0 ignored issues
show
It seems like truncate($unit_text, $unitlen) can also be of type array; however, parameter $string of str_pad() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

16
$unit_text = str_pad(/** @scrutinizer ignore-type */ truncate($unit_text, $unitlen), $unitlen);
Loading history...
17
18
if ($width > '500') {
19
    $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now         Min         Max        Avg\l'";
20
    if ($printtotal === 1) {
21
        $rrd_options .= " COMMENT:'Total      '";
22
    }
23
    $rrd_options .= " COMMENT:'\l'";
24
} else {
25
    $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now         Min         Max        Avg\l'";
26
}
27
28
foreach ($rrd_list as $rrd) {
29
    if ($rrd['colour']) {
30
        $colour = $rrd['colour'];
31
    } else {
32
        if (! \LibreNMS\Config::get("graph_colours.$colours.$colour_iter")) {
33
            $colour_iter = 0;
34
        }
35
36
        $colour = \LibreNMS\Config::get("graph_colours.$colours.$colour_iter");
37
        $colour_iter++;
38
    }
39
40
    $ds = $rrd['ds'];
41
    $filename = $rrd['filename'];
42
43
    $descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr'], $descr_len);
44
    $id = 'ds' . $i;
45
46
    $rrd_options .= ' DEF:' . $rrd['ds'] . $i . '=' . $rrd['filename'] . ':' . $rrd['ds'] . ':AVERAGE ';
47
48
    if ($simple_rrd) {
49
        $rrd_options .= ' CDEF:' . $rrd['ds'] . $i . 'min=' . $rrd['ds'] . $i . ' ';
50
        $rrd_options .= ' CDEF:' . $rrd['ds'] . $i . 'max=' . $rrd['ds'] . $i . ' ';
51
    } else {
52
        $rrd_options .= ' DEF:' . $rrd['ds'] . $i . 'min=' . $rrd['filename'] . ':' . $rrd['ds'] . ':MIN ';
53
        $rrd_options .= ' DEF:' . $rrd['ds'] . $i . 'max=' . $rrd['filename'] . ':' . $rrd['ds'] . ':MAX ';
54
    }
55
56
    if ($_GET['previous']) {
57
        $rrd_options .= ' DEF:' . $i . 'X=' . $rrd['filename'] . ':' . $rrd['ds'] . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
58
        $rrd_options .= ' SHIFT:' . $i . "X:$period";
59
        $thingX .= $seperatorX . $i . 'X,UN,0,' . $i . 'X,IF';
60
        $plusesX .= $plusX;
61
        $seperatorX = ',';
62
        $plusX = ',+';
63
    }
64
65
    if ($printtotal === 1) {
66
        $rrd_options .= ' VDEF:tot' . $rrd['ds'] . $i . '=' . $rrd['ds'] . $i . ',TOTAL';
67
    }
68
69
    $g_defname = $rrd['ds'];
70
    if (is_numeric($multiplier)) {
71
        $g_defname = $rrd['ds'] . '_cdef';
72
        $rrd_options .= ' CDEF:' . $g_defname . $i . '=' . $rrd['ds'] . $i . ',' . $multiplier . ',*';
73
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'min=' . $rrd['ds'] . $i . 'min,' . $multiplier . ',*';
74
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'max=' . $rrd['ds'] . $i . 'max,' . $multiplier . ',*';
75
    } elseif (is_numeric($divider)) {
76
        $g_defname = $rrd['ds'] . '_cdef';
77
        $rrd_options .= ' CDEF:' . $g_defname . $i . '=' . $rrd['ds'] . $i . ',' . $divider . ',/';
78
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'min=' . $rrd['ds'] . $i . 'min,' . $divider . ',/';
79
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'max=' . $rrd['ds'] . $i . 'max,' . $divider . ',/';
80
    }
81
82
    if (isset($text_orig) && $text_orig) {
83
        $t_defname = $rrd['ds'];
84
    } else {
85
        $t_defname = $g_defname;
86
    }
87
88
    if ($i && ($dostack === 1)) {
89
        $stack = ':STACK';
90
    }
91
92
    $rrd_options .= ' LINE2:' . $g_defname . $i . '#' . $colour . ":'" . $descr . "'$stack";
93
    if ($addarea === 1) {
94
        $rrd_options .= ' AREA:' . $g_defname . $i . '#' . $colour . $transparency . ":''$stack";
95
    }
96
    $rrd_options .= ' GPRINT:' . $t_defname . $i . ':LAST:%8.0lf%s GPRINT:' . $t_defname . $i . 'min:MIN:%8.0lf%s';
97
    $rrd_options .= ' GPRINT:' . $t_defname . $i . 'max:MAX:%8.0lf%s GPRINT:' . $t_defname . $i . ":AVERAGE:'%8.0lf%s\\n'";
98
99
    if ($printtotal === 1) {
100
        $rrd_options .= ' GPRINT:tot' . $rrd['ds'] . $i . ":%8.0lf%s'" . Rrd::safeDescr($total_units) . "'";
101
    }
102
103
    $rrd_options .= " COMMENT:'\\n'";
104
}//end foreach
105
106
if ($_GET['previous'] == 'yes') {
107
    if (is_numeric($multiplier)) {
108
        $rrd_options .= ' CDEF:X=' . $thingX . $plusesX . ',' . $multiplier . ',*';
109
    } elseif (is_numeric($divider)) {
110
        $rrd_options .= ' CDEF:X=' . $thingX . $plusesX . ',' . $divider . ',/';
111
    } else {
112
        $rrd_options .= ' CDEF:X=' . $thingX . $plusesX;
113
    }
114
    $rrd_options .= ' HRULE:0#555555';
115
}
116