]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/fireinfo.cgi
IPsec: Allow sending DNS server addresses to RW clients
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / fireinfo.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 IPFire Team <info@ipfire.org> #
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
22 use strict;
23
24 # enable only the following on debugging purpose
25 use warnings;
26 use CGI::Carp 'fatalsToBrowser';
27
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31 require '/opt/pakfire/lib/functions.pl';
32
33 my $configfile = "/var/ipfire/main/send_profile";
34
35 my %fireinfosettings=();
36 my $errormessage='';
37
38 &Header::showhttpheaders();
39
40 $fireinfosettings{'ENABLE_FIREINFO'} = 'off';
41 $fireinfosettings{'ACTION'} = '';
42
43 &Header::getcgihash(\%fireinfosettings);
44
45 if ( -e "$configfile" ) {
46 $fireinfosettings{'ENABLE_FIREINFO'} = 'on';
47 }
48
49 if ("$fireinfosettings{'ACTION'}" eq "trigger") {
50 if ($fireinfosettings{'ENABLE_FIREINFO'} eq 'off') {
51 &General::log($Lang::tr{'fireinfo is enabled'});
52 system ('/usr/bin/touch', $configfile);
53 $fireinfosettings{'ENABLE_FIREINFO'} = 'on';
54 } else {
55 &General::log($Lang::tr{'fireinfo is disabled'});
56 unlink "$configfile";
57 $fireinfosettings{'ENABLE_FIREINFO'} = 'off';
58 }
59 system("/usr/local/bin/fireinfoctrl &");
60 }
61
62 &Header::openpage('Fireinfo', 1, '');
63
64 if ($fireinfosettings{'ENABLE_FIREINFO'} ne "on") {
65 &Header::openbox("100%", "left", "$Lang::tr{'fireinfo why enable'}");
66
67 print <<END;
68 <font color="$Header::colourred">
69 <p>
70 $Lang::tr{'fireinfo why descr1'}
71 $Lang::tr{'fireinfo why descr2'}<a href="https://fireinfo.ipfire.org" target="_blank">$Lang::tr{'fireinfo why read more'}</a>
72 </p>
73 </font>
74 END
75
76 &Header::closebox();
77 }
78
79 &Header::openbigbox('100%', 'left', '', $errormessage);
80
81 if ($errormessage) {
82 &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}");
83 print "<font class='base'>$errormessage&nbsp;</font>\n";
84 &Header::closebox();
85 }
86
87 my $ipfire_version = `cat /etc/system-release`;
88 my $pakfire_version = &Pakfire::make_version();
89 my $kernel_version = `uname -a`;
90
91 &Header::openbox('100%', 'left', $Lang::tr{'fireinfo system version'});
92 print <<END;
93 <table cellspacing='1' cellpadding='0' class='tbl'>
94 <tr>
95 <td align='center' bgcolor='#F0F0F0' width='15%'>$Lang::tr{'fireinfo ipfire version'}</td>
96 <td bgcolor='#F0F0F0'><code>$ipfire_version</code></td>
97 </tr>
98 <tr>
99 <td align='center' bgcolor='#D6D6D6' width='15%'>$Lang::tr{'fireinfo pakfire version'}</td>
100 <td bgcolor='#D6D6D6'><code>$pakfire_version</code></td>
101 </tr>
102 <tr>
103 <td align='center' bgcolor='#F0F0F0' width='15%'>$Lang::tr{'fireinfo kernel version'}</td>
104 <td bgcolor='#F0F0F0'><code>$kernel_version</code></td>
105 </tr>
106 </table>
107 END
108 &Header::closebox();
109
110 # Read pregenerated profile data
111 my $profile = `cat /var/ipfire/fireinfo/profile`;
112
113 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
114
115 # Read profile ID from file
116 my $profile_id = `cat /var/ipfire/fireinfo/public_id`;
117 chomp($profile_id);
118
119 &Header::openbox('100%', 'left', $Lang::tr{'fireinfo settings'});
120 print <<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>
126 <a href="https://fireinfo.ipfire.org/profile/$profile_id" target="_blank">$profile_id</a>
127 </td>
128 </tr>
129 <tr>
130 <!-- spacer -->
131 <td colspan="2">&nbsp;</td>
132 </tr>
133 <tr>
134 <td class='base'>
135 END
136
137 if ($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
143 print "</td><td>";
144
145 if ($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
151 print <<END;
152 </td>
153 </tr>
154 <tr>
155 <!-- spacer -->
156 <td colspan="2"><font color='$Header::colourgreen'>&nbsp;</font></td>
157 </tr>
158 <tr>
159 <td colspan='2'>
160 <textarea rows="25" cols="75" readonly="readonly">$profile</textarea>
161 </td>
162 </tr>
163 </table>
164 END
165 ;
166 &Header::closebox();
167 print "</form>\n";
168
169 &Header::closebigbox();
170 &Header::closepage();