forked from opendocman/opendocman
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AccessLog_class.php
97 lines (86 loc) · 2.79 KB
/
AccessLog_class.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
/**
* Description of AccessLog_class.php
*
* This class provides the ability to track various changes to a file by
* utilizing an access log
*
Copyright (C) 2012 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.
*
* @author Stephen Lawrence Jr.
* @param string $accesslog
*/
class AccessLog extends Plugin
{
public $accesslog='';
/**
* AccessLog constructor for the AccessLog plugin
* @param string $_accesslog Message to display
*/
public function AccessLog($_accesslog='')
{
$this->name = 'AccessLog';
$this->author = 'Stephen Lawrence Jr';
$this->version = '1.0';
$this->homepage = 'http://www.opendocman.com';
$this->description = 'AccessLog Plugin for OpenDocMan';
$this->accesslog = $_accesslog;
}
/**
* @param string $_var The string to display
*/
public function setAccessLog($_var)
{
$this->accesslog = $_var;
}
/**
* @returns string $var Get the value of accesslog var
*/
public function getAccessLog()
{
$var = $this->accesslog;
return $var;
}
/**
* Draw the admin menu
* Required if you want an admin menu to show for your plugin
*/
public function onAdminMenu()
{
$curdir = dirname(__FILE__);
$GLOBALS['smarty']->display('file:' . $curdir . '/templates/accesslog.tpl');
}
/**
* Create the entry into the access_log database
* @param int $fileId
* @param string $type The type of entry to describe what happened
* @param PDO $pdo
*/
public static function addLogEntry($fileId, $type, PDO $pdo)
{
if ($fileId == 0) {
global $id;
$fileId = $id;
}
$query = "INSERT INTO {$GLOBALS['CONFIG']['db_prefix']}access_log (file_id,user_id,timestamp,action) VALUES ( :file_id, :uid, NOW(), :type)";
$stmt = $pdo->prepare($query);
$stmt->execute(
array(
':file_id' => $fileId,
':uid' => $_SESSION['uid'],
':type' => $type
)
);
}
}