1 | <?php |
||
2 | |||
3 | use LibreNMS\Config; |
||
0 ignored issues
–
show
|
|||
4 | |||
5 | ?> |
||
6 | <form class="form-horizontal"> |
||
7 | <?php echo csrf_field() ?> |
||
8 | <div class="modal fade" id="alert_ack_modal" tabindex="-1" role="dialog" aria-labelledby="alert_notes" aria-hidden="true"> |
||
9 | <div class="modal-dialog modal-lg"> |
||
10 | <div class="modal-content"> |
||
11 | <div class="modal-header"> |
||
12 | <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
||
13 | <h5 class="modal-title" id="alert_notes">Acknowledge Alert</h5> |
||
14 | </div> |
||
15 | <div class="modal-body"> |
||
16 | <div class='form-group'> |
||
17 | <label for='ack_msg' class='col-sm-4 col-md-3 control-label' title="Add a message to the acknowledgement">(Un)Acknowledgement note: </label> |
||
18 | <div class="col-sm-8 col-md-9"> |
||
19 | <input type='text' id='ack_msg' name='ack_msg' class='form-control' autofocus> |
||
20 | </div> |
||
21 | </div> |
||
22 | <div class="form-group" id="ack_section"> |
||
23 | <label for="ack_until_clear" class="col-sm-4 col-md-3 control-label" title="Acknowledge until alert clears">Acknowledge until clear:</label> |
||
24 | <div class="col-sm-8 col-md-9"> |
||
25 | <input type='checkbox' name='ack_until_clear' id='ack_until_clear'> |
||
26 | </div> |
||
27 | </div> |
||
28 | <div class="form-group"> |
||
29 | <div class="col-sm-offset-4 col-md-offset-3 col-sm-3 col-md-2"> |
||
30 | <input type="hidden" id="ack_alert_id" name="ack_alert_id" value=""> |
||
31 | <input type="hidden" id="ack_alert_state" name="ack_alert_state" value=""> |
||
32 | <button class="btn btn-success" id="ack-alert" name="ack-alert">Ack alert</button> |
||
33 | </div> |
||
34 | </div> |
||
35 | </div> |
||
36 | </div> |
||
37 | </div> |
||
38 | </div> |
||
39 | </form> |
||
40 | |||
41 | <script> |
||
42 | $('#alert_ack_modal').on('show.bs.modal', function () { |
||
43 | if ($("#ack_alert_state").val() == 2) { |
||
44 | var button_label = 'Un-acknowledge alert'; |
||
45 | $('#ack_section').hide(); |
||
46 | } else { |
||
47 | var button_label = 'Acknowledge alert'; |
||
48 | $('#ack_section').show(); |
||
49 | } |
||
50 | document.getElementById('ack-alert').innerText = button_label; |
||
51 | $("#ack_until_clear").bootstrapSwitch('state', <?php echo Config::get('alert.ack_until_clear') ? 'true' : 'false'; ?>); |
||
52 | }); |
||
53 | $("#ack-alert").on("click", function(event) { |
||
54 | event.preventDefault(); |
||
55 | var ack_alert_id = $("#ack_alert_id").val(); |
||
56 | var ack_alert_note = $('#ack_msg').val(); |
||
57 | var ack_alert_state = $("#ack_alert_state").val(); |
||
58 | var ack_until_clear = $("#ack_until_clear").bootstrapSwitch('state'); |
||
59 | $.ajax({ |
||
60 | type: "POST", |
||
61 | url: "ajax_form.php", |
||
62 | dataType: "json", |
||
63 | data: { type: "ack-alert", alert_id: ack_alert_id, state: ack_alert_state, ack_msg: ack_alert_note, ack_until_clear: ack_until_clear }, |
||
64 | success: function (data) { |
||
65 | if (data.status === "ok") { |
||
66 | toastr.success(data.message); |
||
67 | var $table = $('table.alerts'); |
||
68 | var sortDictionary = $table.bootgrid("getSortDictionary"); |
||
69 | $table.bootgrid('reload'); |
||
70 | $table.bootgrid("sort", sortDictionary); |
||
71 | $("#alert_ack_modal").modal('hide'); |
||
72 | } else { |
||
73 | toastr.error(data.message); |
||
74 | } |
||
75 | }, |
||
76 | error: function(){ |
||
77 | toastr.error(data.message); |
||
78 | } |
||
79 | }); |
||
80 | }); |
||
81 | </script> |
||
82 |
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: