Issues (2963)

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

1
<?php
2
use Librenms\Config;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Config. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
3
4
$no_refresh = true;
5
?>
6
<table id="routes" class="table table-condensed table-hover table-striped">
7
    <thead>
8
        <tr>
9
            <th data-column-id="context_name" data-width="125px" data-formatter="tooltip">VRF</th>
10
            <th data-column-id="inetCidrRouteDestType" data-width="70px">Proto</th>
11
            <th data-column-id="inetCidrRouteDest" data-formatter="tooltip">Destination</th>
12
            <th data-column-id="inetCidrRoutePfxLen" data-width="80px">Mask</th>
13
            <th data-column-id="inetCidrRouteNextHop" data-formatter="tooltip">Next hop</th>
14
            <th data-column-id="inetCidrRouteIfIndex" data-formatter="tooltip">Interface</th>
15
            <th data-column-id="inetCidrRouteMetric1" data-width="85px">Metric</th>
16
            <th data-column-id="inetCidrRouteType" data-width="85px">Type</th>
17
            <th data-column-id="inetCidrRouteProto" data-width="85px">Proto</th>
18
            <th data-column-id="created_at" data-width="165px" data-formatter="tooltip">First seen</th>
19
            <th data-column-id="updated_at" data-width="165px" data-formatter="tooltip">Last seen</th>
20
        </tr>
21
    </thead>
22
</table>
23
<div>Warning: Routing Table is only retrieved during device discovery. Devices are skipped if they have more than <?php echo Config::get('routes_max_number'); ?> routes.</div>
24
<script>
25
var grid = $("#routes").bootgrid({
26
    ajax: true,
27
    post: function ()
28
    {
29
        var check_showAllRoutes = document.getElementById('check_showAllRoutes');
30
        if (check_showAllRoutes) {
31
            var showAllRoutes = document.getElementById('check_showAllRoutes').checked;
32
        } else {
33
            var showAllRoutes = false;
34
        }
35
36
        var list_showProtocols = document.getElementById('list_showProtocols');
37
        if (list_showProtocols) {
38
            var list_showProtocols = document.getElementById('list_showProtocols').value;
39
        } else {
40
            var list_showProtocols = 'all';
41
        }
42
43
        return {
44
            device_id: "<?php echo $device['device_id']; ?>",
45
            showAllRoutes: showAllRoutes,
46
            showProtocols: list_showProtocols
47
        };
48
    },
49
    formatters: {
50
        "tooltip": function (column, row) {
51
                var value = row[column.id];
52
                if (value.includes('onmouseover=')) {
53
                    return value;
54
                }
55
                return "<span title=\'" + value + "\' data-toggle=\'tooltip\'>" + value + "</span>";
56
            },
57
    },
58
    url: "ajax/table/routes"
59
});
60
61
var add = $(".actionBar").append(
62
        '<div class="search form-group pull-left" style="width:auto">' +
63
        '<?php echo csrf_field() ?>' +
64
        '<select name="list_showProtocols" id="list_showProtocols" class="input-sm" onChange="updateTable();">' +
65
        '<option value="all">all Protocols</option>' +
66
        '<option value="ipv4">IPv4 only</option>' +
67
        '<option value="ipv6">IPv6 only</option>' +
68
        '</select>&nbsp;' +
69
        '<input type="checkbox" name="check_showAllRoutes" data-size="small" id="check_showAllRoutes">' +
70
        '&nbsp;Include historical routes in the table' +
71
        '</div>');
72
73
$("#check_showAllRoutes").bootstrapSwitch({
74
    'onSwitchChange': function(event, state){
75
         updateTable();
76
    }
77
});
78
79
function updateTable() {
80
    $('#routes').bootgrid('reload');
81
};
82
</script>
83