]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/fireinfo.cgi
fireinfo.cgi: Use new system methods
[people/pmueller/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";
fd90cadc 31require '/opt/pakfire/lib/functions.pl';
579a39d0
MT
32
33my $configfile = "/var/ipfire/main/send_profile";
34
35my %fireinfosettings=();
36my $errormessage='';
37
38&Header::showhttpheaders();
39
40$fireinfosettings{'ENABLE_FIREINFO'} = 'off';
41$fireinfosettings{'ACTION'} = '';
42
43&Header::getcgihash(\%fireinfosettings);
44
45if ( -e "$configfile" ) {
46 $fireinfosettings{'ENABLE_FIREINFO'} = 'on';
47}
48
49if ("$fireinfosettings{'ACTION'}" eq "trigger") {
50 if ($fireinfosettings{'ENABLE_FIREINFO'} eq 'off') {
51 &General::log($Lang::tr{'fireinfo is enabled'});
f5f18183 52 &General::system('/usr/bin/touch', $configfile);
579a39d0
MT
53 $fireinfosettings{'ENABLE_FIREINFO'} = 'on';
54 } else {
55 &General::log($Lang::tr{'fireinfo is disabled'});
56 unlink "$configfile";
57 $fireinfosettings{'ENABLE_FIREINFO'} = 'off';
58 }
f5f18183 59 &General::system_background("/usr/local/bin/fireinfoctrl");
579a39d0
MT
60}
61
62&Header::openpage('Fireinfo', 1, '');
63
64if ($fireinfosettings{'ENABLE_FIREINFO'} ne "on") {
856c9bf0 65 &Header::openbox("100%", "left", "$Lang::tr{'fireinfo why enable'}");
579a39d0
MT
66
67 print <<END;
68<font color="$Header::colourred">
69 <p>
856c9bf0 70 $Lang::tr{'fireinfo why descr1'}
ff9fdd63 71 $Lang::tr{'fireinfo why descr2'}<a href="https://fireinfo.ipfire.org" target="_blank">$Lang::tr{'fireinfo why read more'}</a>
579a39d0
MT
72 </p>
73</font>
74END
75
76 &Header::closebox();
77}
78
79&Header::openbigbox('100%', 'left', '', $errormessage);
80
81if ($errormessage) {
82 &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}");
56914f12 83 print "<font class='base'>$errormessage&nbsp;</font>\n";
579a39d0
MT
84 &Header::closebox();
85}
86
87my $ipfire_version = `cat /etc/system-release`;
fd90cadc 88my $pakfire_version = &Pakfire::make_version();
579a39d0
MT
89my $kernel_version = `uname -a`;
90
91&Header::openbox('100%', 'left', $Lang::tr{'fireinfo system version'});
92print <<END;
99644aba 93 <table cellspacing='1' cellpadding='0' class='tbl'>
579a39d0 94 <tr>
99644aba
PM
95 <td align='center' bgcolor='#F0F0F0' width='15%'>$Lang::tr{'fireinfo ipfire version'}</td>
96 <td bgcolor='#F0F0F0'><code>$ipfire_version</code></td>
579a39d0
MT
97 </tr>
98 <tr>
99644aba
PM
99 <td align='center' bgcolor='#D6D6D6' width='15%'>$Lang::tr{'fireinfo pakfire version'}</td>
100 <td bgcolor='#D6D6D6'><code>$pakfire_version</code></td>
579a39d0
MT
101 </tr>
102 <tr>
99644aba
PM
103 <td align='center' bgcolor='#F0F0F0' width='15%'>$Lang::tr{'fireinfo kernel version'}</td>
104 <td bgcolor='#F0F0F0'><code>$kernel_version</code></td>
579a39d0
MT
105 </tr>
106 </table>
107END
108&Header::closebox();
109
110# Read pregenerated profile data
111my $profile = `cat /var/ipfire/fireinfo/profile`;
112
113print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
114
115# Read profile ID from file
116my $profile_id = `cat /var/ipfire/fireinfo/public_id`;
117chomp($profile_id);
118
119&Header::openbox('100%', 'left', $Lang::tr{'fireinfo settings'});
120print <<END;
121<input type='hidden' name='ACTION' value='trigger' />
122<table width='100%'>
123 <tr>
124 <td>$Lang::tr{'fireinfo your profile id'}:</td>
125 <td>
ff9fdd63 126 <a href="https://fireinfo.ipfire.org/profile/$profile_id" target="_blank">$profile_id</a>
579a39d0
MT
127 </td>
128 </tr>
129 <tr>
130 <!-- spacer -->
131 <td colspan="2">&nbsp;</td>
132 </tr>
133 <tr>
134 <td class='base'>
135END
136
137if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") {
138 print "<font color='$Header::colourgreen'>$Lang::tr{'fireinfo is submitted'}</font>";
139} else {
140 print "<font color='$Header::colourred'>$Lang::tr{'fireinfo not submitted'}</font>";
141}
142
143print "</td><td>";
144
145if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") {
146 print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo is submitted button'}\" />";
147} else {
148 print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo not submitted button'}\" />";
149}
150
151print <<END;
152 </td>
153 </tr>
154 <tr>
155 <!-- spacer -->
324bb888 156 <td colspan="2"><font color='$Header::colourgreen'>&nbsp;</font></td>
579a39d0
MT
157 </tr>
158 <tr>
159 <td colspan='2'>
153cf640 160 <textarea rows="25" cols="75" readonly="readonly">$profile</textarea>
579a39d0
MT
161 </td>
162 </tr>
163</table>
164END
165;
166&Header::closebox();
167print "</form>\n";
168
169&Header::closebigbox();
170&Header::closepage();