forked from GIPdA/libreBrigade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit.php
173 lines (157 loc) · 6.25 KB
/
audit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
# project: eBrigade
# homepage: https://ebrigade.app
# version: 5.3
# Copyright (C) 2004, 2021 Nicolas MARCHE (eBrigade Technologies)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
include_once ("config.php");
check_all(20);
get_session_parameters();
// ====================================
// data extract
// ====================================
test_permission_level(20);
$query="select p.P_SECTION , p.P_NOM , p.P_PRENOM, a.A_DEBUT, a.A_FIN, p.P_ID,
a.A_OS, a.A_BROWSER, a.A_IP, g.GP_ID, p.GP_ID2, g.GP_DESCRIPTION, g2.GP_DESCRIPTION GP_DESCRIPTION2, s.S_CODE, s.S_ID
from audit a, pompier p left join groupe g2 on p.GP_ID=g2.GP_ID, groupe g, section s
where p.P_ID=a.P_ID
and p.P_SECTION=s.S_ID
and p.GP_ID=g.GP_ID";
if ( $subsections == 1 )
$query .= " and p.P_SECTION in (".get_family("$filter").")";
else
$query .= " and p.P_SECTION =".$filter;
$query .= " and time_to_sec(timediff(now(),a.A_DEBUT)) < (24 * 3600 * ".$days_audit.")";
$query .= " order by a.A_DEBUT desc";
$result=mysqli_query($dbc,$query);
$totalNotFiltered=mysqli_num_rows($result);
if (isset($_GET["data"])) {
header('Content-Type: application/json; charset=ISO-8859-1');
$out = "{
\"total\": ".$totalNotFiltered.",
\"totalNotFiltered\": ".$totalNotFiltered.",
\"rows\": [";
while (custom_fetch_array($result)) {
if ( $GP_ID == 0 and $GP_ID2 <> "") $GP_DESCRIPTION = $GP_DESCRIPTION2;
$out .= "{
\"pid\":\"".$P_ID."\",
\"name\":\"".strtoupper($P_NOM)." ".ucfirst($P_PRENOM)."\",
\"section\":\"".$S_CODE."\",
\"os\":\"".$A_OS."\",
\"last_connect\":\"".$A_DEBUT."\",
\"last_action\": \"".$A_FIN."\",
\"browser\":\"".$A_BROWSER."\",
\"ip_adress\":\"".$A_IP."\",
\"permission\":\"".$GP_DESCRIPTION."\"
},";
}
$out = rtrim($out , ",");
$out .= "
]
}";
print $out;
exit;
}
// ====================================
// display
// ====================================
test_permission_level(20);
$moyenne= round($totalNotFiltered / $days_audit, 0);
echo "<table id='toolbar' class='noBorder noprint' style='margin-top:-2px;'>";
// section
echo "<tr>";
echo "<td style='padding-left: 0;'>";
$responsive_padding = "";
if ( get_children("$filter") <> '' ) {
if ($subsections == 1 ) $checked='checked';
else $checked='';
echo "<div class='toggle-switch'>
<label for='sub2'>Sous-sections</label>
<label class='switch'>
<input type='checkbox' name='sub' id='sub2' $checked class='ml-3'
onClick=\"orderfilter2('history.php',document.getElementById('filter').value, this)\">
<span class='slider round'></span>
</label>
</div>";
$responsive_padding = "responsive-padding";
}
echo "<select id='filter' name='filter' title='filtre par section'
onchange=\"orderfilter1('history.php', document.getElementById('filter').value,'".$subsections."')\"
class='selectpicker' ".datalive_search()." data-style='btn-default' data-container='body'>";
display_children2(-1, 0, $filter, $nbmaxlevels, $sectionorder);
echo "</select></td>";
echo "<td><span class='badge'>$totalNotFiltered</span> connexions sur les $days_audit derniers jours, soit en moyenne <span class='badge'>$moyenne</span> connexions par jour</td>";
echo "</tr>";
echo "</table>";
?>
<div class="table-responsive">
<div class='container-fluid' style='padding-left:0px'>
<table
id="table"
data-locale="fr-FR"
data-toggle="table"
data-sort-class="table-active"
data-sortable="true"
data-ajax="ajaxRequest"
data-show-columns="true"
data-search="true"
data-show-columns-toggle-all="true"
data-minimum-count-columns="3"
data-buttons-align="left"
data-toolbar-align="left"
data-search-align="right"
data-pagination-align="center"
data-pagination="true"
data-toolbar="#toolbar"
data-page-size="12"
data-pagination-parts=["pageSize","pageList"]
data-page-list=[12,24,48,120]
data-loading-template="<i class='fa fa-spinner fa-spin fa-fw fa-lg'></i>"
class="table-sm table-hover new-table"
>
<thead>
<tr class="widget-title">
<th data-field="pid" data-sortable="true" title="identifiant de la personne">Id</th>
<th data-field="name" data-sortable="true" title="Nom et prénom">Nom</th>
<th data-field="section" data-sortable="true" title="Section" >Section</th>
<th data-field="last_connect" data-sortable="true" title="Date de connection" >Date Connexion</th>
<th data-field="last_action" data-sortable="true" title="Dernière action" class="hide_mobile" >Dernière action</th>
<th data-field="os" data-sortable="true" title="Système d'exploitation" class="hide_mobile">OS</th>
<th data-field="browser" data-sortable="true" title="Navigateur utilisé" class="hide_mobile">Browser</th>
<th data-field="ip_adress" data-sortable="true" title="addresse IP" class="hide_mobile">adresse IP</th>
<th data-field="permission" data-sortable="true" title="Organisation type" class="hide_mobile">Permission</th>
</tr>
</thead>
</table>
<style type="text/css">
table {
border-collapse: collapse !important;
}
</style>
<script>
function ajaxRequest(params) {
var url = 'audit.php?data=1';
$.get(url + '?' + $.param(params.data)).then(function (res) {
params.success(res)
})
}
$("#table").on('click', 'tbody > tr', function (e){
var row = $(this);
var pid = row.find("td:nth-child(1)").text();
self.location.href="upd_personnel.php?pompier="+pid;
});
</script>
<?php
echo "</div>";
?>