forked from opendocman/opendocman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccess_log.php
97 lines (80 loc) · 2.87 KB
/
access_log.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
<?php
/*
Copyright (C) 2012-2013 Stephen Lawrence Jr.
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.
*/
// check for session and $_REQUEST['id']
session_start();
include('odm-load.php');
if (!isset($_SESSION['uid'])) {
redirect_visitor();
}
include('udf_functions.php');
// open a connection to the database
$user_obj = new User($_SESSION['uid'], $pdo);
// Check to see if user is admin
if (!$user_obj->isAdmin()) {
header('Location:error.php?ec=4');
exit;
}
$last_message = (isset($_REQUEST['last_message']) ? $_REQUEST['last_message'] : '');
draw_header(msg('accesslogpage_access_log'), $last_message);
$query = "SELECT
a.*,
d.realname,
u.username
FROM
{$GLOBALS['CONFIG']['db_prefix']}access_log a
INNER JOIN
{$GLOBALS['CONFIG']['db_prefix']}data AS d ON a.file_id = d.id
INNER JOIN
{$GLOBALS['CONFIG']['db_prefix']}user AS u ON a.user_id = u.id
";
$stmt = $pdo->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
$actions_array = array(
"A" => msg('accesslogpage_file_added'),
"B" => msg('accesslogpage_reserved'),
"C" => msg('accesslogpage_reserved'),
"V" => msg('accesslogpage_file_viewed'),
"D" => msg('accesslogpage_file_downloaded'),
"M" => msg('accesslogpage_file_modified'),
"I" => msg('accesslogpage_file_checked_in'),
"O" => msg('accesslogpage_file_checked_out'),
"X" => msg('accesslogpage_file_deleted'),
"Y" => msg('accesslogpage_file_authorized'),
"R" => msg('accesslogpage_file_rejected')
);
$accesslog_array = array();
foreach ($result as $row) {
$details_link = 'details.php?id=' . $row['file_id'] . '&state=' . ($_REQUEST['state'] + 1);
$accesslog_array[] = array(
'user_id' => $row['user_id'],
'file_id' => $row['file_id'],
'user_name' => $row['username'],
'realname' => $row['realname'],
'action' => $actions_array[$row['action']],
'details_link' => $details_link,
'timestamp' => $row['timestamp']
);
}
$view->setData([
'accesslog_array' => $accesslog_array,
'showCheckBox' => false,
'form' => 0
]);
$view->setView('access_log');
$view->setLayout('default');
echo $view->__invoke();
draw_footer();