]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/fireinfo.cgi
Add webinterface frontend for fireinfo.
[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) 2007 Michael Tremer & Christian Schmidt #
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
32 my $configfile = "/var/ipfire/main/send_profile";
33
34 my %fireinfosettings=();
35 my $errormessage='';
36
37 &Header::showhttpheaders();
38
39 $fireinfosettings{'ENABLE_FIREINFO'} = 'off';
40 $fireinfosettings{'ACTION'} = '';
41
42 &Header::getcgihash(\%fireinfosettings);
43
44 if ( -e "$configfile" ) {
45 $fireinfosettings{'ENABLE_FIREINFO'} = 'on';
46 }
47
48 if ("$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 }
58 }
59
60 &Header::openpage('Fireinfo', 1, '');
61
62 if ($fireinfosettings{'ENABLE_FIREINFO'} ne "on") {
63 &Header::openbox("100%", "left", "Why should I enable fireinfo?");
64
65 print <<END;
66 <font color="$Header::colourred">
67 <p>
68 It is very important for the development of IPFire that you enable this
69 service. <a href="http://fireinfo.ipfire.org" target="_blank">Read more about the reasons.</a>
70 </p>
71 </font>
72 END
73
74 &Header::closebox();
75 }
76
77 &Header::openbigbox('100%', 'left', '', $errormessage);
78
79 if ($errormessage) {
80 &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}");
81 print "<FONT CLASS='base'>$errormessage&nbsp;</FONT>\n";
82 &Header::closebox();
83 }
84
85 my $ipfire_version = `cat /etc/system-release`;
86 my $pakfire_version = `cat /opt/pakfire/etc/pakfire.conf | grep "version =" | cut -d\\" -f2`;
87 my $kernel_version = `uname -a`;
88
89 &Header::openbox('100%', 'left', $Lang::tr{'fireinfo system version'});
90 print <<END;
91 <table width="100%">
92 <tr>
93 <td>$Lang::tr{'fireinfo ipfire version'}:</td>
94 <td>$ipfire_version</td>
95 </tr>
96 <tr>
97 <td>$Lang::tr{'fireinfo pakfire version'}:</td>
98 <td>$pakfire_version</td>
99 </tr>
100 <tr>
101 <td>$Lang::tr{'fireinfo kernel version'}:</td>
102 <td>$kernel_version</td>
103 </tr>
104 </table>
105 END
106 &Header::closebox();
107
108 # Read pregenerated profile data
109 my $profile = `cat /var/ipfire/fireinfo/profile`;
110
111 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
112
113 # Read profile ID from file
114 my $profile_id = `cat /var/ipfire/fireinfo/public_id`;
115 chomp($profile_id);
116
117 &Header::openbox('100%', 'left', $Lang::tr{'fireinfo settings'});
118 print <<END;
119 <input type='hidden' name='ACTION' value='trigger' />
120 <table width='100%'>
121 <tr>
122 <td>$Lang::tr{'fireinfo your profile id'}:</td>
123 <td>
124 <a href="http://fireinfo.ipfire.org/profile/$profile_id" target="_blank">$profile_id</a>
125 </td>
126 </tr>
127 <tr>
128 <!-- spacer -->
129 <td colspan="2">&nbsp;</td>
130 </tr>
131 <tr>
132 <td class='base'>
133 END
134
135 if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") {
136 print "<font color='$Header::colourgreen'>$Lang::tr{'fireinfo is submitted'}</font>";
137 } else {
138 print "<font color='$Header::colourred'>$Lang::tr{'fireinfo not submitted'}</font>";
139 }
140
141 print "</td><td>";
142
143 if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") {
144 print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo is submitted button'}\" />";
145 } else {
146 print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo not submitted button'}\" />";
147 }
148
149 print <<END;
150 </td>
151 </tr>
152 <tr>
153 <!-- spacer -->
154 <td colspan="2">&nbsp;</td>
155 </tr>
156 <tr>
157 <td colspan='2'>
158 <textarea rows="25" cols="75" readonly="true">$profile</textarea>
159 </td>
160 </tr>
161 </table>
162 END
163 ;
164 &Header::closebox();
165 print "</form>\n";
166
167 &Header::closebigbox();
168 &Header::closepage();