1<?php
2
3/**
4 * Script to display subnet changelog
5 ***********************************************/
6
7# verify that user is logged in
8$User->check_user_session();
9
10# strip tags - XSS
11$_GET = $User->strip_input_tags ($_GET);
12
13# get clog entries for current subnet
14$clogs = $Log->fetch_changlog_entries("subnet", $_GET['subnetId'], true);
15# subnet changelog for all slave subnets
16$clogsSlaves = $Log->fetch_subnet_slaves_changlog_entries_recursive($_GET['subnetId']);
17# changelog for each IP address, also in slave subnets
18$clogsAddresses = $Log->fetch_subnet_addresses_changelog_recursive($_GET['subnetId']);  //se ne dela !
19
20# get subnet details
21$subnet = (array) $Subnets-> fetch_subnet("id",$_GET['subnetId']);
22
23
24# permissions
25$permission = $Subnets->check_permission ($User->user, $_GET['subnetId']);
26if($permission == 0)	{ $Result->show("danger", _('You do not have permission to access this network'), true); }
27
28# header
29print "<h4>"._('Subnet')." - "._('Changelog')."</h4><hr>";
30
31# back
32if($subnet['isFolder']==1) {
33	print "<a class='btn btn-sm btn-default' href='".create_link("folder",$_GET['section'],$_GET['subnetId'])."'><i class='fa fa-gray fa-chevron-left'></i>  "._('Back to subnet')."</a>";
34} else {
35	print "<a class='btn btn-sm btn-default' href='".create_link("subnets",$_GET['section'],$_GET['subnetId'])."'><i class='fa fa-gray fa-chevron-left'></i> "._('Back to subnet')."</a>";
36}
37
38
39/* current subnet changelog */
40
41# empty
42if(sizeof($clogs)==0) {
43	print "<blockquote style='margin-top:20px;margin-left:20px;'>";
44	print "<p>"._("No changelogs available")."</p>";
45	print "<small>"._("No changelog entries are available for this subnet")."</small>";
46	print "</blockquote>";
47}
48# result
49else {
50	# printout
51	print "<table class='table table-striped table-top table-condensed' style='margin-top:30px;'>";
52
53	# headers
54	print "<tr>";
55	print "	<th>"._('User')."</th>";
56	print "	<th>"._('Subnet')."</th>";
57	print "	<th>"._('Description')."</th>";
58	print "	<th>"._('Action')."</th>";
59	print "	<th>"._('Result')."</th>";
60	print "	<th>"._('Date')."</th>";
61	print "	<th>"._('Change')."</th>";
62	print "</tr>";
63
64	# logs
65	foreach($clogs as $l) {
66		$l = (array) $l;
67		# format diff
68		$l['cdiff'] = str_replace("\n", "<br>", $l['cdiff']);
69
70		print "<tr>";
71		print "	<td>$l[real_name]</td>";
72		# folder?
73		if($subnet['isFolder']==1)			{ print "	<td><a href='".create_link("subnets",$_GET['section'],$_GET['subnetId'])."'>$subnet[description]</a></td>"; }
74		else 								{ print "	<td><a href='".create_link("subnets",$_GET['section'],$_GET['subnetId'])."'>$subnet[ip]/$subnet[mask]</a></td>"; }
75		print "	<td>$l[description]</td>";
76		print "	<td>"._("$l[caction]")."</td>";
77		print "	<td>"._("$l[cresult]")."</td>";
78		print "	<td>$l[cdate]</td>";
79		print "	<td>$l[cdiff]</td>";
80		print "</tr>";
81
82	}
83
84	print "</table>";
85}
86
87
88/* Subnet slaves changelog */
89
90# empty
91if($clogsSlaves) {
92	# header
93	print "<h4 style='margin-top:30px;'>"._('Slave subnets')." "._('Changelog')."</h4><hr>";
94
95	# printout
96	print "<table class='table table-striped table-top table-condensed'>";
97
98	# headers
99	print "<tr>";
100	print "	<th>"._('User')."</th>";
101	print "	<th>"._('Subnet')."</th>";
102	print "	<th>"._('Description')."</th>";
103	print "	<th>"._('Action')."</th>";
104	print "	<th>"._('Result')."</th>";
105	print "	<th>"._('Date')."</th>";
106	print "	<th>"._('Change')."</th>";
107	print "</tr>";
108
109	# logs
110	foreach($clogsSlaves as $l) {
111		$l = (array) $l;
112		# format diff
113		$l['cdiff'] = str_replace("\n", "<br>", $l['cdiff']);
114
115		print "<tr>";
116		print "	<td>$l[real_name]</td>";
117		# folder?
118		if($l['isFolder']==1)				{ print "	<td><a href='".create_link("subnets",$l['sectionId'],$l['id'])."'>$l[description]</a></td>"; }
119		else 								{ print "	<td><a href='".create_link("subnets",$l['sectionId'],$l['id'])."'>".$Subnets->transform_to_dotted($l['subnet'])."/$l[mask]</a></td>"; }
120		print "	<td>$l[description]</td>";
121		print "	<td>"._("$l[caction]")."</td>";
122		print "	<td>"._("$l[cresult]")."</td>";
123		print "	<td>$l[cdate]</td>";
124		print "	<td>$l[cdiff]</td>";
125		print "</tr>";
126
127	}
128
129	print "</table>";
130}
131
132
133/* IP changelog */
134
135if($clogsAddresses) {
136	# header
137	print "<h4 style='margin-top:30px;'>"._('Underlying hosts')." "._('Changelog')."</h4><hr>";
138
139	# printout
140	print "<table class='table table-striped table-top table-condensed'>";
141
142	# headers
143	print "<tr>";
144	print "	<th>"._('User')."</th>";
145	print "	<th>"._('IP')."</th>";
146	print "	<th>"._('Action')."</th>";
147	print "	<th>"._('Result')."</th>";
148	print "	<th>"._('Date')."</th>";
149	print "	<th>"._('Change')."</th>";
150	print "</tr>";
151
152	# logs
153	foreach($clogsAddresses as $l) {
154		$l = (array) $l;
155		# format diff
156		$l['cdiff'] = str_replace("\n", "<br>", $l['cdiff']);
157
158		print "<tr>";
159		print "	<td>$l[real_name]</td>";
160		print "	<td><a href='".create_link("subnets",$_GET['section'],$_GET['subnetId'],"address-details",$l['id'])."'>".$Subnets->transform_to_dotted($l['ip_addr'])."</a></td>";
161		print "	<td>"._("$l[caction]")."</td>";
162		print "	<td>"._("$l[cresult]")."</td>";
163		print "	<td>$l[cdate]</td>";
164		print "	<td>$l[cdiff]</td>";
165		print "</tr>";
166
167	}
168
169	print "</table>";
170}
171
172
173?>