forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
views_logs.load.php
283 lines (273 loc) · 10.3 KB
/
views_logs.load.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<?php
/**
* @file views_logs.load.php
* @author Nils Laumaillé
* @version 2.1.27
* @copyright (c) 2009-2017 Nils Laumaillé
* @licensing GNU AFFERO GPL 3.0
* @link http://www.teampass.net
*
* This library 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.
*/
if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1) {
die('Hacking attempt...');
}
?>
<script type="text/javascript">
//<![CDATA[
var oTable0;
var oTable1;
var oTable2;
var oTable3;
var oTable4;
var oTable5;
var oTable6;
/**
* Manage display of divs
*/
function manage_div_display(show_id){
var all_divs = new Array();
all_divs[0] = "tab6_0";
all_divs[1] = "tab6_1";
all_divs[2] = "tab6_2";
all_divs[3] = "tab6_3";
all_divs[4] = "tab6_4";
all_divs[5] = "tab6_5";
all_divs[6] = "tab6_6";
for (i=0;i<all_divs.length;i++) {
if (all_divs[i] == show_id) {
$("#"+all_divs[i]).show();
} else {
$("#"+all_divs[i]).hide();
}
}
}
/**
* Loads the associated data table
*/
function loadTable(table_id)
{
if (table_id == "t_connections") {
$("#type_log_displayed").val("connections_logs");
oTable0 = $("#t_connections").dataTable({
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $SETTINGS['cpassman_url']; ?>/sources/datatable/datatable.logs.php?action=connections",
"bJQueryUI": true,
"oLanguage": {
"sUrl": "<?php echo $SETTINGS['cpassman_url']; ?>/includes/language/datatables.<?php echo $_SESSION['user_language']; ?>.txt"
},
"fnInitComplete": function() {
$("#t_connections_page input").focus();
}
});
} else if (table_id == "t_errors") {
$("#type_log_displayed").val("errors_logs");
oTable1 = $("#t_errors").dataTable({
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $SETTINGS['cpassman_url']; ?>/sources/datatable/datatable.logs.php?action=errors",
"bJQueryUI": true,
"oLanguage": {
"sUrl": "<?php echo $SETTINGS['cpassman_url']; ?>/includes/language/datatables.<?php echo $_SESSION['user_language']; ?>.txt"
},
"fnInitComplete": function() {
$("#t_errors_page input").focus();
}
});
} else if (table_id == "t_access") {
$("#type_log_displayed").val("access_logs");
oTable2 = $("#t_access").dataTable({
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $SETTINGS['cpassman_url']; ?>/sources/datatable/datatable.logs.php?action=access",
"bJQueryUI": true,
"oLanguage": {
"sUrl": "<?php echo $SETTINGS['cpassman_url']; ?>/includes/language/datatables.<?php echo $_SESSION['user_language']; ?>.txt"
},
"fnInitComplete": function() {
$("#t_access_page input").focus();
}
});
} else if (table_id == "t_copy") {
$("#type_log_displayed").val("copy_logs");
oTable3 = $("#t_copy").dataTable({
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $SETTINGS['cpassman_url']; ?>/sources/datatable/datatable.logs.php?action=copy",
"bJQueryUI": true,
"oLanguage": {
"sUrl": "<?php echo $SETTINGS['cpassman_url']; ?>/includes/language/datatables.<?php echo $_SESSION['user_language']; ?>.txt"
},
"fnInitComplete": function() {
$("#t_copy_page input").focus();
}
});
} else if (table_id == "t_admin") {
$("#type_log_displayed").val("admin_logs");
oTable4 = $("#t_admin").dataTable({
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $SETTINGS['cpassman_url']; ?>/sources/datatable/datatable.logs.php?action=admin",
"bJQueryUI": true,
"oLanguage": {
"sUrl": "<?php echo $SETTINGS['cpassman_url']; ?>/includes/language/datatables.<?php echo $_SESSION['user_language']; ?>.txt"
},
"fnInitComplete": function() {
$("#t_admin_page input").focus();
}
});
} else if (table_id == "t_items") {
$("#type_log_displayed").val("items_logs");
oTable5 = $("#t_items").dataTable({
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $SETTINGS['cpassman_url']; ?>/sources/datatable/datatable.logs.php?action=items",
"bJQueryUI": true,
"oLanguage": {
"sUrl": "<?php echo $SETTINGS['cpassman_url']; ?>/includes/language/datatables.<?php echo $_SESSION['user_language']; ?>.txt"
},
"fnInitComplete": function() {
$("#t_items_page input").focus();
}
});
} else if (table_id == "t_failed_auth") {
$("#type_log_displayed").val("failed_auth_logs");
oTable6 = $("#t_failed_auth").dataTable({
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $SETTINGS['cpassman_url']; ?>/sources/datatable/datatable.logs.php?action=failed_auth",
"bJQueryUI": true,
"oLanguage": {
"sUrl": "<?php echo $SETTINGS['cpassman_url']; ?>/includes/language/datatables.<?php echo $_SESSION['user_language']; ?>.txt"
},
"fnInitComplete": function() {
$("#t_items_page input").focus();
}
});
}
}
$(function() {
$("#radio_log")
.buttonset()
.click(function(e) {
$("#div_log_purge").show();
});
$(".button").button();
$("#log_jours").datepicker({
regional: 'fr',
dateFormat : 'dd/mm/yy'
});
$("#div_dialog_message").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 400,
height: 150,
title: "<?php echo $LANG["admin_action"]; ?>",
buttons: {
"<?php echo $LANG["ok"]; ?>": function() {
$.post(
"sources/users.queries.php",
{
type : "disconnect_all_users",
key : "<?php echo $_SESSION["key"]; ?>"
},
function(data) {
oTable2.fnDraw(false);
$(this).dialog("close");
}
);
},
"<?php echo $LANG["cancel_button"]; ?>": function() {
$(this).dialog("close");
}
}
});
/*
* PURGE
*/
$("#butPurge").button().click(function(e) {
// prepare dialogbox
$("#div_dialog_message").dialog("option", "title", "<?php echo $LANG['admin_main']; ?>");
$("#div_dialog_message").dialog("option", "buttons", {
"<?php echo $LANG['ok']; ?>": function() {
$(this).dialog("close");
}
});
// send query
$.post(
"sources/views.queries.php",
{
type : "purgeLogs",
purgeTo : $("#purgeTo").val(),
purgeFrom : $("#purgeFrom").val(),
logType : $("#type_log_displayed").val(),
key : "<?php echo $_SESSION["key"]; ?>"
},
function(data) {
if (data[0].status == "ok") {
$("#div_dialog_message_text").html("<?php echo $LANG['purge_done']; ?> "+data[0].nb);
$("#div_dialog_message").dialog("open");
// refresh table
if ($("#type_log_displayed").val() == "connections_logs") oTable0.api().ajax.reload();
else if ($("#type_log_displayed").val() == "errors_logs") oTable1.api().ajax.reload();
else if ($("#type_log_displayed").val() == "access_logs") oTable2.api().ajax.reload();
else if ($("#type_log_displayed").val() == "copy_logs") oTable3.api().ajax.reload();
else if ($("#type_log_displayed").val() == "admin_logs") oTable4.api().ajax.reload();
else if ($("#type_log_displayed").val() == "items_logs") oTable5.api().ajax.reload();
else if ($("#type_log_displayed").val() == "failed_auth_logs") oTable6.api().ajax.reload();
}
$("#purgeTo, #purgeFrom").val("");
},
"json"
);
});
$( "#purgeFrom" ).datepicker({
defaultDate: "today",
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
onClose: function( selectedDate ) {
var minDate = new Date(Date.parse(selectedDate));
minDate.setDate(minDate.getDate() + 1);
$( "#to" ).datepicker( "option", "minDate", minDate );
}
});
$( "#purgeTo" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
onClose: function( selectedDate ) {
var maxDate = new Date(Date.parse(selectedDate));
maxDate.setDate(maxDate.getDate() + 1);
$( "#from" ).datepicker( "option", "maxDate", maxDate );
}
});
});
//]]>
</script>