summaryrefslogtreecommitdiffstats
path: root/frontends/php/audit.php
blob: 31d640a42a46ad7eb2d45bb28dbc2a2c2112d4dd (plain)
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
<?php
/* 
** Zabbix
** Copyright (C) 2000,2001,2002,2003,2004 Alexei Vladishev
**
** 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., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
?>
<?php
	include "include/config.inc.php";
	$page["title"] = S_AUDIT_LOG;
	$page["file"] = "audit.php";
	show_header($page["title"],30,0);
?>

<?php
	if(isset($_GET["start"])&&isset($_GET["do"])&&($_GET["do"]=="<< Prev 100"))
	{
		$_GET["start"]-=100;
	}
	if(isset($_GET["do"])&&($_GET["do"]=="Next 100 >>"))
	{
		if(isset($_GET["start"]))
		{
			$_GET["start"]+=100;
		}
		else
		{
			$_GET["start"]=100;
		}
	}
	if(isset($_GET["start"])&&($_GET["start"]<=0))
	{
		unset($_GET["start"]);
	}
?>

<?php
	show_table3_header_begin();
	echo "&nbsp;".S_AUDIT_LOG_BIG;
	show_table3_h_delimiter(20);
	echo "<form name=\"form2\" method=\"get\" action=\"audit.php\">";
	if(isset($_GET["start"]))
	{
		echo "<input class=\"biginput\" name=\"start\" type=hidden value=".$_GET["start"]." size=8>";
  		echo "<input class=\"button\" type=\"submit\" name=\"do\" value=\"<< Prev 100\">";
	}
	else
	{
  		echo "<input class=\"button\" type=\"submit\" disabled name=\"do\" value=\"<< Prev 100\">";
	}
  	echo "<input class=\"button\" type=\"submit\" name=\"do\" value=\"Next 100 >>\">";
	echo "</form>";
	show_table_header_end();
?>

<FONT COLOR="#000000">
<?php
	$sql="select max(auditid) as max from audit";
	$result=DBselect($sql);
	$row=DBfetch($result);
	$maxauditid=@iif(DBnum_rows($result)>0,$row["max"],0);

	if(!isset($_GET["start"]))
	{
		$sql="select u.alias,a.clock,a.action,a.resource,a.details from audit a, users u where u.userid=a.userid and a.auditid>$maxauditid-200 order by clock desc limit 200";
	}
	else
	{
		$sql="select u.alias,a.clock,a.action,a.resource,a.details from audit a, users u where u.userid=a.userid and a.auditid>$maxauditid-".($_GET["start"]+200)." order by clock desc limit ".($_GET["start"]+200);

	}
	$result=DBselect($sql);

	table_begin();
	table_header(array(S_TIME,S_USER,S_RESOURCE,S_ACTION,S_DETAILS));
	$col=0;
	$i=0;
	while($row=DBfetch($result))
	{
		$i++;
		if(isset($_GET["start"])&&($i<$_GET["start"]))
		{
			continue;
		}
		if($i>100)	break;

		if($row["resource"]==AUDIT_RESOURCE_USER)
		{
			$resource=S_USER;
		}
		else if($row["resource"]==AUDIT_RESOURCE_ZABBIX_CONFIG)
		{
			$resource=S_CONFIGURATION_OF_ZABBIX;
		}
		else if($row["resource"]==AUDIT_RESOURCE_MEDIA_TYPE)
		{
			$resource=S_MEDIA_TYPE;
		}
		else if($row["resource"]==AUDIT_RESOURCE_HOST)
		{
			$resource=S_HOST;
		}
		else if($row["resource"]==AUDIT_RESOURCE_ACTION)
		{
			$resource=S_ACTION;
		}
		else if($row["resource"]==AUDIT_RESOURCE_GRAPH)
		{
			$resource=S_GRAPH;
		}
		else if($row["resource"]==AUDIT_RESOURCE_GRAPH_ELEMENT)
		{
			$resource=S_GRAPH_ELEMENT;
		}
		else
		{
			$resource=S_UNKNOWN_RESOURCE;
		}
		if($row["action"]==AUDIT_ACTION_ADD)
		{
			$action=S_ADDED;
		}
		else if($row["action"]==AUDIT_ACTION_UPDATE)
		{
			$action=S_UPDATED;
		}
		else if($row["action"]==AUDIT_ACTION_DELETE)
		{
			$action=S_DELETED;
		}
		else
		{
			$action=S_UNKNOWN_ACTION;
		}
		table_row(array(
			date("Y.M.d H:i:s",$row["clock"]),
			$row["alias"],
			$resource,
			$action,
			$row["details"]
		),$col++);
	}
	table_end();
?>
</FONT>
</TR>
</TABLE>

<?php
	show_footer();
?>