Issues (2963)

includes/html/pages/device/routing/ospf.inc.php (1 issue)

Labels
Severity
1
<?php
2
3
$i = 0;
4
5
echo '
6
<div>
7
  <div class="panel panel-default">
8
    <div class="panel-body">
9
      <table class="table table-condensed" style="border-collapse:collapse;">
10
        <thead>
11
          <tr>
12
            <th>&nbsp;</th>
13
            <th>Router ID</th>
14
            <th>Status</th>
15
            <th>ABR</th>
16
            <th>ASBR</th>
17
            <th>Areas</th>
18
            <th>Ports(Enabled)</th>
19
            <th>Neighbours</th>
20
          </tr>
21
        </thead>';
22
foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', [$device['device_id']]) as $instance) {
23
    $i++;
24
    $area_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?', [$device['device_id']]);
25
    $port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?', [$device['device_id']]);
26
    $port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", [$device['device_id']]);
27
    $nbr_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?', [$device['device_id']]);
28
29
    $status_color = $abr_status_color = $asbr_status_color = 'default';
30
31
    if ($instance['ospfAdminStat'] == 'enabled') {
32
        $status_color = 'success';
33
    }
34
35
    if ($instance['ospfAreaBdrRtrStatus'] == 'true') {
36
        $abr_status_color = 'success';
37
    }
38
39
    if ($instance['ospfASBdrRtrStatus'] == 'true') {
40
        $asbr_status_color = 'success';
41
    }
42
43
    echo '
44
        <tbody>
45
          <tr data-toggle="collapse" data-target="#ospf-panel' . $i . '" class="accordion-toggle">
46
            <td><button id="ospf-panel_button' . $i . '" class="btn btn-default btn-xs"><span id="ospf-panel_span' . $i . '" class="fa fa-plus"></span></button></td>
47
            <td>' . $instance['ospfRouterId'] . '</td>
48
            <td><span class="label label-' . $status_color . '">' . $instance['ospfAdminStat'] . '</span></td>
49
            <td><span class="label label-' . $abr_status_color . '">' . $instance['ospfAreaBdrRtrStatus'] . '</span></td>
50
            <td><span class="label label-' . $asbr_status_color . '">' . $instance['ospfASBdrRtrStatus'] . '</span></td>
51
            <td>' . $area_count . '</td>
52
            <td>' . $port_count . '(' . $port_count_enabled . ')</td>
53
            <td>' . $nbr_count . '</td>
54
          </tr>
55
          <script type="text/javascript">
56
          $("#ospf-panel_button' . $i . '").on("click", function(){
57
              $("#ospf-panel_span' . $i . '").toggleClass("fa-minus");
58
          });
59
          </script>
60
          <tr>
61
            <td colspan="12" class="hiddenRow">
62
            <div class="accordian-body collapse" id="ospf-panel' . $i . '">
63
                <br>
64
                <div class="col-xs-4">
65
                  <div class="table-responsive">
66
                    <table class="table table-striped table-hover">
67
                      <thead>
68
                        <h4><span class="label label-primary">Areas</span></h4>
69
                        <tr>
70
                          <th>Area ID</th>
71
                          <th>Ports(Enabled)</th>
72
                          <th>Status</th>
73
                        </tr>
74
                      </thead>';
75
    foreach (dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ?', [$device['device_id']]) as $area) {
76
        $area_port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?', [$device['device_id'], $area['ospfAreaId']]);
77
        $area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", [$device['device_id'], $area['ospfAreaId']]);
78
79
        echo '
80
                      <tbody>
81
                        <tr>
82
                          <td>' . $area['ospfAreaId'] . '</td>
83
                          <td>' . $area_port_count . '(' . $area_port_count_enabled . ')</td>
84
                          <td><span class="label label-' . $status_color . '">' . $instance['ospfAdminStat'] . '</span></td>
85
                        </tr>
86
                      </tbody>';
87
    }
88
    echo '
89
                    </table>
90
                  </div>
91
                </div>
92
                <div class="col-xs-4">
93
                  <div class="table-responsive">
94
                    <table class="table table-striped table-hover">
95
                      <thead>
96
                        <h4><span class="label label-primary">Ports</span></h4>
97
                        <tr>
98
                          <th>Port</th>
99
                          <th>Port Type</th>
100
                          <th>Port State</th>
101
                          <th>Cost</th>
102
                          <th>Status</th>
103
                          <th>Area ID</th>
104
                        </tr>
105
                      </thead>
106
                  </div>';
107
    foreach (dbFetchRows("SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND P.port_id = O.port_id ORDER BY O.`ospfIfAreaId`", [$device['device_id']]) as $ospfport) {
108
        $ospfport = cleanPort($ospfport);
109
        $port_status_color = 'default';
110
111
        if ($ospfport['ospfIfAdminStat'] == 'enabled') {
112
            $port_status_color = 'success';
113
        }
114
115
        echo '
116
                  <tbody>
117
                    <tr>
118
                      <td>' . generate_port_link($ospfport) . '</td>
0 ignored issues
show
Are you sure generate_port_link($ospfport) of type array|string can be used in concatenation? ( Ignorable by Annotation )

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

118
                      <td>' . /** @scrutinizer ignore-type */ generate_port_link($ospfport) . '</td>
Loading history...
119
                      <td>' . $ospfport['ospfIfType'] . '</td>
120
                      <td>' . $ospfport['ospfIfState'] . '</td>
121
                      <td>' . $ospfport['ospfIfMetricValue'] . '</td>
122
                      <td><span class="label label-' . $port_status_color . '">' . $ospfport['ospfIfAdminStat'] . '</span></td>
123
                      <td>' . $ospfport['ospfIfAreaId'] . '</td>
124
                    </tr>
125
                  </tbody>';
126
    }
127
    echo '
128
                  </table>
129
                </div>
130
                </div>
131
                <div class="col-xs-4">
132
                  <div class="table-responsive">
133
                    <table class="table table-striped table-hover">
134
                      <thead>
135
                        <h4><span class="label label-primary">Neighbours</span></h4>
136
                        <tr>
137
                          <th>Router ID</th>
138
                          <th>Device</th>
139
                          <th>IP Address</th>
140
                          <th>Status</th>
141
                        </tr>
142
                      </thead>';
143
    foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?', [$device['device_id']]) as $nbr) {
144
        $host = @dbFetchRow('SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', [$nbr['ospfNbrRtrId']]);
145
146
        $rtr_id = 'unknown';
147
        $ospfnbr_status_color = 'default';
148
149
        if (is_array($host)) {
150
            $rtr_id = generate_device_link($host);
151
        }
152
153
        if ($nbr['ospfNbrState'] == 'full') {
154
            $ospfnbr_status_color = 'success';
155
        } elseif ($nbr['ospfNbrState'] == 'down') {
156
            $ospfnbr_status_color = 'danger';
157
        }
158
159
        echo '
160
                    <tbody>
161
                      <tr>
162
                        <td>' . $nbr['ospfNbrRtrId'] . '</td>
163
                        <td>' . $rtr_id . '</td>
164
                        <td>' . $nbr['ospfNbrIpAddr'] . '</td>
165
                        <td><span class="label label-' . $ospfnbr_status_color . '">' . $nbr['ospfNbrState'] . '</span></td>
166
                      </tr>
167
                    </tbody>';
168
    }
169
    echo '
170
                    </table>
171
                  </div>
172
                </div>
173
              </div>
174
            </td>
175
          </tr>
176
        </tbody>';
177
}
178
echo '
179
      </table>
180
    </div>
181
  </div>
182
</div>';
183