]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/fireinfo.cgi
suricata: Fix ownership and file permissions of files inside /var/lib/suricata.
[ipfire-2.x.git] / html / cgi-bin / fireinfo.cgi
CommitLineData
579a39d0
MT
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
856c9bf0 5# Copyright (C) 2011 IPFire Team <info@ipfire.org> #
579a39d0
MT
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22use strict;
23
24# enable only the following on debugging purpose
25use warnings;
26use CGI::Carp 'fatalsToBrowser';
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
31
32my $configfile = "/var/ipfire/main/send_profile";
33
34my %fireinfosettings=();
35my $errormessage='';
36
37&Header::showhttpheaders();
38
39$fireinfosettings{'ENABLE_FIREINFO'} = 'off';
40$fireinfosettings{'ACTION'} = '';
41
42&Header::getcgihash(\%fireinfosettings);
43
44if ( -e "$configfile" ) {
45 $fireinfosettings{'ENABLE_FIREINFO'} = 'on';
46}
47
48if ("$fireinfosettings{'ACTION'}" eq "trigger") {
49 if ($fireinfosettings{'ENABLE_FIREINFO'} eq 'off') {
50 &General::log($Lang::tr{'fireinfo is enabled'});
51 system ('/usr/bin/touch', $configfile);
52 $fireinfosettings{'ENABLE_FIREINFO'} = 'on';
53 } else {
54 &General::log($Lang::tr{'fireinfo is disabled'});
55 unlink "$configfile";
56 $fireinfosettings{'ENABLE_FIREINFO'} = 'off';
57 }
aebf1b54 58 system("/usr/local/bin/fireinfoctrl &");
579a39d0
MT
59}
60
61&Header::openpage('Fireinfo', 1, '');
62
63if ($fireinfosettings{'ENABLE_FIREINFO'} ne "on") {
856c9bf0 64 &Header::openbox("100%", "left", "$Lang::tr{'fireinfo why enable'}");
579a39d0
MT
65
66 print <<END;
67<font color="$Header::colourred">
68 <p>
856c9bf0 69 $Lang::tr{'fireinfo why descr1'}
ff9fdd63 70 $Lang::tr{'fireinfo why descr2'}<a href="https://fireinfo.ipfire.org" target="_blank">$Lang::tr{'fireinfo why read more'}</a>
579a39d0
MT
71 </p>
72</font>
73END
74
75 &Header::closebox();
76}
77
78&Header::openbigbox('100%', 'left', '', $errormessage);
79
80if ($errormessage) {
81 &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}");
56914f12 82 print "<font class='base'>$errormessage&nbsp;</font>\n";
579a39d0
MT
83 &Header::closebox();
84}
85
86my $ipfire_version = `cat /etc/system-release`;
87my $pakfire_version = `cat /opt/pakfire/etc/pakfire.conf | grep "version =" | cut -d\\" -f2`;
88my $kernel_version = `uname -a`;
89
90&Header::openbox('100%', 'left', $Lang::tr{'fireinfo system version'});
91print <<END;
92 <table width="100%">
93 <tr>
94 <td>$Lang::tr{'fireinfo ipfire version'}:</td>
95 <td>$ipfire_version</td>
96 </tr>
97 <tr>
98 <td>$Lang::tr{'fireinfo pakfire version'}:</td>
99 <td>$pakfire_version</td>
100 </tr>
101 <tr>
102 <td>$Lang::tr{'fireinfo kernel version'}:</td>
103 <td>$kernel_version</td>
104 </tr>
105 </table>
106END
107&Header::closebox();
108
109# Read pregenerated profile data
110my $profile = `cat /var/ipfire/fireinfo/profile`;
111
112print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
113
114# Read profile ID from file
115my $profile_id = `cat /var/ipfire/fireinfo/public_id`;
116chomp($profile_id);
117
118&Header::openbox('100%', 'left', $Lang::tr{'fireinfo settings'});
119print <<END;
120<input type='hidden' name='ACTION' value='trigger' />
121<table width='100%'>
122 <tr>
123 <td>$Lang::tr{'fireinfo your profile id'}:</td>
124 <td>
ff9fdd63 125 <a href="https://fireinfo.ipfire.org/profile/$profile_id" target="_blank">$profile_id</a>
579a39d0
MT
126 </td>
127 </tr>
128 <tr>
129 <!-- spacer -->
130 <td colspan="2">&nbsp;</td>
131 </tr>
132 <tr>
133 <td class='base'>
134END
135
136if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") {
137 print "<font color='$Header::colourgreen'>$Lang::tr{'fireinfo is submitted'}</font>";
138} else {
139 print "<font color='$Header::colourred'>$Lang::tr{'fireinfo not submitted'}</font>";
140}
141
142print "</td><td>";
143
144if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") {
145 print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo is submitted button'}\" />";
146} else {
147 print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo not submitted button'}\" />";
148}
149
150print <<END;
151 </td>
152 </tr>
153 <tr>
154 <!-- spacer -->
324bb888 155 <td colspan="2"><font color='$Header::colourgreen'>&nbsp;</font></td>
579a39d0
MT
156 </tr>
157 <tr>
158 <td colspan='2'>
153cf640 159 <textarea rows="25" cols="75" readonly="readonly">$profile</textarea>
579a39d0
MT
160 </td>
161 </tr>
162</table>
163END
164;
165&Header::closebox();
166print "</form>\n";
167
168&Header::closebigbox();
169&Header::closepage();