-
Notifications
You must be signed in to change notification settings - Fork 4
/
history.php
478 lines (450 loc) · 15.7 KB
/
history.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<?php
require_once(__DIR__."/src/config.php");
require_once(__DIR__."/src/lib/usercake/init.php");
if (!UCUser::CanUserAccessUrl($_SERVER['PHP_SELF'])){die();}
$user = UCUser::getCurrentUser();
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php echo $user_settings->WebsiteName() ?></title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet" href="plugins/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables/css/dataTables.bootstrap.css">
<link rel="stylesheet" href="plugins/datatables/extensions/Buttons/css/buttons.bootstrap.min.css">
<link rel="stylesheet" href="plugins/datatables/extensions/Select/css/select.bootstrap.min.css">
<link rel="stylesheet" href="plugins/datatables/extensions/Editor/css/editor.bootstrap.min.css">
<link rel="stylesheet" href="plugins/datatables/extensions/Responsive/css/responsive.bootstrap.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. We have chosen the skin-blue for this starter
page. However, you can choose any other skin. Make sure you
apply the skin class to the body tag so the changes take effect.
-->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- Pace style -->
<link rel="stylesheet" href="plugins/pace/pace.min.css">
<!-- tags -->
<link rel="stylesheet" href="plugins/tagmanager/css/tagmanager.css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style type="text/css">
.form-group input[type="checkbox"] {
display: none;
}
.form-group input[type="checkbox"] + .btn-group > label span {
width: 20px;
}
.form-group input[type="checkbox"] + .btn-group > label span:first-child {
display: none;
}
.form-group input[type="checkbox"] + .btn-group > label span:last-child {
display: inline-block;
}
.form-group input[type="checkbox"]:checked + .btn-group > label span:first-child {
display: inline-block;
}
.form-group input[type="checkbox"]:checked + .btn-group > label span:last-child {
display: none;
}
.myTag
{
background-color: #428bca !important;
color: #fff !important;
font-size: 14px;
}
.tm-input
{
margin-bottom: 0px !important;
}
body .modal-dialog
{
width: 60%;
}
.content
{
min-height: 0px !important;
padding-bottom: 0px !important;
}
pre
{
padding: 5px;
margin: 5px;
height: auto;
max-height: 500px;
overflow: auto;
word-break: normal !important;
word-wrap: normal !important;
white-space: pre !important;
}
.string { color: green; }
.number { color: darkorange; }
.boolean { color: blue; }
.null { color: magenta; }
.key { color: red; }
</style>
</head>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to get the
desired effect
|---------------------------------------------------------|
| SKINS | skin-blue |
| | skin-black |
| | skin-purple |
| | skin-yellow |
| | skin-red |
| | skin-green |
|---------------------------------------------------------|
|LAYOUT OPTIONS | fixed |
| | layout-boxed |
| | layout-top-nav |
| | sidebar-collapse |
| | sidebar-mini |
|---------------------------------------------------------|
-->
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<?php include(__DIR__."/top-nav.php"); ?>
<?php include(__DIR__."/left-nav.php"); ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Modifications History <small></small>
</h1>
<ol class="breadcrumb">
<li><a href="<?php echo $GLOBALS["config"]["urls"]["baseUrl"]; ?>index.php"><i class="fa fa-home"></i> Home</a></li>
<li class="active" id="bc-rule-name">History</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div id='alert'></div>
<!-- Horizontal Form -->
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">History Items</h3>
</div>
<div class="box-body">
<table id="history" class="table table-bordered table-striped dt-responsive" width="100%" cellspacing="0">
<thead>
<tr>
<th>Date</th>
<th>User</th>
<th>Item</th>
<th>Name</th>
<th>Action</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
<div class="modal fade" id="confirm-action" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<form class="form-horizontal" role="form">
<fieldset>
<span id="modal-message"></span>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a class="btn btn-danger btn-ok" OnClick="">Confirm</a>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- /.content-wrapper -->
<?php include(__DIR__."/footer.php"); ?>
<?php include(__DIR__."/right-nav.php"); ?>
</div>
<!-- ./wrapper -->
<!-- REQUIRED JS SCRIPTS -->
<!-- jQuery 2.2.3 -->
<script src="plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="plugins/jQueryUI/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
$.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.6 -->
<script src="plugins/bootstrap/js/bootstrap.min.js"></script>
<!-- PACE -->
<script src="plugins/pace/pace.min.js"></script>
<!-- ChartJS 2.2.2 -->
<script src="plugins/chartjs/2.2.2/Chart.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<!-- AdminLTE App -->
<script src="plugins/ace/ace.js"></script>
<!-- tags -->
<script type="text/javascript" src="plugins/tagmanager/js/tagmanager.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/js/jquery.dataTables.js"></script>
<script src="plugins/datatables/js/dataTables.bootstrap.js"></script>
<script src="plugins/datatables/extensions/Buttons/js/dataTables.buttons.js"></script>
<script src="plugins/datatables/extensions/Buttons/js/buttons.bootstrap.js"></script>
<script src="plugins/datatables/extensions/Select/js/dataTables.select.js"></script>
<script src="plugins/datatables/extensions/Editor/js/dataTables.editor.js"></script>
<script src="plugins/datatables/extensions/Editor/js/editor.bootstrap.js"></script>
<script src="plugins/datatables/extensions/Editor/js/editor.tinymce.js"></script>
<script src="plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables/extensions/Responsive/js/responsive.bootstrap.min.js"></script>
<!-- Charts -->
<script src="dist/js/main.js"></script>
<script>
function do_clear_history()
{
Pace.start();
clear_history(
function(data, code) {
$('#confirm-action').modal('hide');
Pace.stop();
refresh_history();
},
function(message, error) {
$('#confirm-action').modal('hide');
$("#alert").html('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><span class="glyphicon glyphicon-exclamation-sign"></span> Unable to clear history</div>');
}
);
}
function confirm_clear_history()
{
$('#confirm-action').find('.modal-header').html("Clear History");
$('#confirm-action').find('#modal-message').html("This will remove all entries, do you want to proceed?");
$('#confirm-action').find('.btn-ok').show();
$('#confirm-action').find('.btn-ok').attr('OnClick', 'do_clear_history()');
$('#confirm-action').modal('show');
}
function syntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 2);
}
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
function display_data(title, data)
{
var pretty_data = '<pre>' + syntaxHighlight(data) + '</pre>';
$('#confirm-action').find('.modal-header').html(title);
$('#confirm-action').find('#modal-message').html(pretty_data);
$('#confirm-action').find('.btn-ok').hide();
$('#confirm-action').modal('show');
}
function refresh_history()
{
$('#history').DataTable().ajax.reload();
}
function initHistoryTable()
{
// Load table
var table;
table = $('#history').DataTable({
dom: "Bfrtip",
paging: true,
pageLength: 25,
lengthChange: true,
searching: true,
ordering: true,
info: true,
autoWidth: false,
processing: false,
serverSide: false,
responsive: true,
//deferLoading: 0,
fnInitComplete: function (oSettings, json) {
Pace.stop();
},
ajax: {
type: "GET",
dataType: "json",
url: "api.php",
data: function( data ) {
data.action = 'gethistory';
data.limit = 100;
}
},
columns: [
{ data: "date", width: "20%" },
{ data: "user_name", width: "10%" },
{
data: "item_type",
width: "15%",
render: function (data, type, row)
{
if (data != undefined) {
var icon_label = 'fa-question-o';
var text_label = data;
if (data == 'file') {
icon_label = 'fa-file-o';
text_label = 'File';
} else if (data == 'rule') {
icon_label = 'fa-star';
text_label = 'Rule';
} else if (data == 'comment') {
icon_label = 'fa-comment';
text_label = 'Comment';
}
return "<span class='fa " + icon_label + " table-menu'></span> " + text_label;
}
else {
return "";
}
}
},
{
data: "item_name",
width: "15%",
render: function (data, type, row)
{
var text_label = data;
if (row.action == 'delete' && row.item_type != 'comment') {
text_label = "<i><span class='fa fa-lock table-menu' data-toggle='tooltip' title='Removed items cannot be open' style='padding-right: 5px;'></span> " + text_label + "</i>";
}
else if (row.action == 'recyclebin') {
text_label = "<span class='fa fa-lock table-menu' data-toggle='tooltip' title='Removed items cannot be open' style='padding-right: 5px;'></span> "
+ "<a href='" + "<?php echo $GLOBALS["config"]["urls"]["baseUrl"] ?>recycle.php'>" + text_label + " (#" + row.item_id + ")" + "</a>";
}
else if (row.item_type == 'file') {
text_label = "<a href='" + "<?php echo $GLOBALS["config"]["urls"]["baseUrl"] ?>file.php?id=" + row.item_id + "'>" + text_label + " (#" + row.item_id + ")" + "</a>";
}
else if (row.item_type == 'rule') {
text_label = "<a href='" + "<?php echo $GLOBALS["config"]["urls"]["baseUrl"] ?>view.php?id=" + row.item_id + "'>" + text_label + " (#" + row.item_id + ")" + "</a>";
}
else if (row.item_type == 'comment') {
text_label = "<a href='" + "<?php echo $GLOBALS["config"]["urls"]["baseUrl"] ?>view.php?id=" + row.item_id + "'>" + text_label + " (#" + row.item_id + ")" + "</a>";
}
return text_label;
}
},
{
data: "action",
width: "20%",
render: function (data, type, row)
{
var text_label = data;
if (data != undefined) {
var class_label = 'label-primary';
if (data == 'delete') {
class_label = 'label-danger';
text_label = 'Deleted';
} else if (data == 'edit') {
class_label = 'label-warning';
text_label = 'Edited';
} else if (data == 'add') {
class_label = 'label-success';
text_label = 'Added';
} else if (data == 'recyclebin') {
class_label = 'label-danger';
text_label = 'Recycle Bin';
} else if (data == 'restore') {
class_label = 'label-success';
text_label = 'Restored';
}
return "<span class='label " + class_label + "' style='font-size: 12px;'>" + text_label + "</span>";
}
else {
return "";
}
}
},
{
data: "actions",
width: "15%",
render: function (data, type, row)
{
return ""
+ "<button type='button' class='btn btn-sm btn-primary' data-toggle='tooltip' title='View new data' OnClick='display_data(\"New data\", " + row.item_value + ")'>"
+ "<span class='fa fa-eye table-menu'></span>"
+ "</button> "
+ "<button type='button' class='btn btn-sm btn-primary' data-toggle='tooltip' title='View old data' OnClick='display_data(\"Old data\", " + row.item_old_value + ")'>"
+ "<span class='fa fa-eye table-menu'></span>"
+ "</button> ";
}
}
],
order: [[ 0, "desc" ]],
select: true,
buttons: [
{
text: "<i class='fa fa-ban'></i>",
titleAttr: 'Clear History',
action: confirm_clear_history
},
{
text: "<i class='fa fa-refresh'></i>",
titleAttr: 'Refresh',
action: refresh_history
}
],
});
}
function initHistory()
{
'use strict';
$.when(
initHistoryTable()
).always(function(a1, a2, a3, a4) {
Pace.stop();
});
}
$(function () {
initHistory();
});
</script>
<!-- Optionally, you can add Slimscroll and FastClick plugins.
Both of these plugins are recommended to enhance the
user experience. Slimscroll is required when using the
fixed layout. -->
</body>
</html>