1 | <?php |
||
2 | /* |
||
3 | * This program is free software: you can redistribute it and/or modify it |
||
4 | * under the terms of the GNU General Public License as published by the |
||
5 | * Free Software Foundation, either version 3 of the License, or (at your |
||
6 | * option) any later version. Please see LICENSE.txt at the top level of |
||
7 | * the source code distribution for details. |
||
8 | * |
||
9 | * @package LibreNMS |
||
10 | * @subpackage webui |
||
11 | * @link https://www.librenms.org |
||
12 | * @copyright 2017 LibreNMS |
||
13 | * @author LibreNMS Contributors |
||
14 | */ |
||
15 | |||
16 | use Carbon\Carbon; |
||
17 | use LibreNMS\Config; |
||
0 ignored issues
–
show
|
|||
18 | |||
19 | $no_refresh = true; |
||
20 | $param = []; |
||
21 | $device_id = (int) $vars['device']; |
||
22 | |||
23 | $pagetitle[] = 'Outages'; |
||
24 | ?> |
||
25 | <div class="panel panel-default panel-condensed"> |
||
26 | <div class="panel-heading"> |
||
27 | <strong>Outages</strong> |
||
28 | </div> |
||
29 | |||
30 | <?php |
||
31 | require_once 'includes/html/common/outages.inc.php'; |
||
32 | echo implode('', $common_output); |
||
33 | ?> |
||
34 | </div> |
||
35 | <script> |
||
36 | $('.actionBar').append( |
||
37 | '<div class="pull-left">' + |
||
38 | '<form method="post" action="" class="form-inline" role="form" id="result_form">' + |
||
39 | '<?php echo csrf_field() ?>'+ |
||
40 | '<div class="form-group">' + |
||
41 | <?php |
||
42 | if (! isset($vars['fromdevice'])) { |
||
43 | ?> |
||
44 | '<select name="device" id="device" class="form-control">' + |
||
45 | '<option value="">All Devices </option>' + |
||
46 | <?php |
||
47 | if ($device_id) { |
||
48 | echo "'<option value=$device_id>" . format_hostname(device_by_id_cache($device_id)) . "</option>' +"; |
||
49 | } ?> |
||
50 | '</select>' + |
||
51 | <?php |
||
52 | } else { |
||
53 | echo "' <input type=\"hidden\" name=\"device\" id=\"device\" value=\"" . $device_id . "\">' + "; |
||
54 | } |
||
55 | ?> |
||
56 | '</div>' + |
||
57 | ' <div class="form-group">' + |
||
58 | '<input name="from" type="text" class="form-control" id="dtpickerfrom" maxlength="16" value="<?php echo $vars['from']; ?>" placeholder="From" data-date-format="YYYY-MM-DD HH:mm">' + |
||
59 | '</div>' + |
||
60 | '<div class="form-group">' + |
||
61 | ' <input name="to" type="text" class="form-control" id="dtpickerto" maxlength="16" value="<?php echo $vars['to']; ?>" placeholder="To" data-date-format="YYYY-MM-DD HH:mm">' + |
||
62 | '</div>' + |
||
63 | ' <button type="submit" class="btn btn-default">Filter</button>' + |
||
64 | '</form>' + |
||
65 | '</div>' |
||
66 | ); |
||
67 | |||
68 | $(function () { |
||
69 | $("#dtpickerfrom").datetimepicker({ |
||
70 | icons: { |
||
71 | time: 'fa fa-clock-o', |
||
72 | date: 'fa fa-calendar', |
||
73 | up: 'fa fa-chevron-up', |
||
74 | down: 'fa fa-chevron-down', |
||
75 | previous: 'fa fa-chevron-left', |
||
76 | next: 'fa fa-chevron-right', |
||
77 | today: 'fa fa-calendar-check-o', |
||
78 | clear: 'fa fa-trash-o', |
||
79 | close: 'fa fa-close' |
||
80 | }, |
||
81 | defaultDate: '<?php echo Carbon::now()->subMonth()->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>' |
||
82 | }); |
||
83 | $("#dtpickerfrom").on("dp.change", function (e) { |
||
84 | $("#dtpickerto").data("DateTimePicker").minDate(e.date); |
||
85 | }); |
||
86 | $("#dtpickerto").datetimepicker({ |
||
87 | icons: { |
||
88 | time: 'fa fa-clock-o', |
||
89 | date: 'fa fa-calendar', |
||
90 | up: 'fa fa-chevron-up', |
||
91 | down: 'fa fa-chevron-down', |
||
92 | previous: 'fa fa-chevron-left', |
||
93 | next: 'fa fa-chevron-right', |
||
94 | today: 'fa fa-calendar-check-o', |
||
95 | clear: 'fa fa-trash-o', |
||
96 | close: 'fa fa-close' |
||
97 | }, |
||
98 | defaultDate: '<?php echo Carbon::now()->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>' |
||
99 | }); |
||
100 | $("#dtpickerto").on("dp.change", function (e) { |
||
101 | $("#dtpickerfrom").data("DateTimePicker").maxDate(e.date); |
||
102 | }); |
||
103 | if ($("#dtpickerfrom").val() != "") { |
||
104 | $("#dtpickerto").data("DateTimePicker").minDate($("#dtpickerfrom").val()); |
||
105 | } |
||
106 | if ($("#dtpickerto").val() != "") { |
||
107 | $("#dtpickerfrom").data("DateTimePicker").maxDate($("#dtpickerto").val()); |
||
108 | } else { |
||
109 | $("#dtpickerto").data("DateTimePicker").maxDate('<?php echo Carbon::now()->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>'); |
||
110 | } |
||
111 | }); |
||
112 | |||
113 | <?php if (! isset($vars['fromdevice'])) { ?> |
||
114 | $("#device").select2({ |
||
115 | theme: "bootstrap", |
||
116 | dropdownAutoWidth : true, |
||
117 | width: "auto", |
||
118 | allowClear: true, |
||
119 | placeholder: "All Devices", |
||
120 | ajax: { |
||
121 | url: '<?php echo url('/ajax/select/device'); ?>', |
||
122 | delay: 200 |
||
123 | } |
||
124 | })<?php echo $device_id ? ".val($device_id).trigger('change');" : ''; ?>; |
||
125 | <?php } ?> |
||
126 | </script> |
||
127 | |||
128 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/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 beforeOtherDir/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: