]>
Commit | Line | Data |
---|---|---|
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 | ||
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"; | |
fd90cadc | 31 | require '/opt/pakfire/lib/functions.pl'; |
579a39d0 MT |
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'}); | |
2ccb63bc SS |
52 | |
53 | # Write empty configfile. | |
54 | open(FILE, ">$configfile"); | |
55 | close(FILE); | |
56 | ||
579a39d0 MT |
57 | $fireinfosettings{'ENABLE_FIREINFO'} = 'on'; |
58 | } else { | |
59 | &General::log($Lang::tr{'fireinfo is disabled'}); | |
60 | unlink "$configfile"; | |
61 | $fireinfosettings{'ENABLE_FIREINFO'} = 'off'; | |
62 | } | |
f5f18183 | 63 | &General::system_background("/usr/local/bin/fireinfoctrl"); |
579a39d0 MT |
64 | } |
65 | ||
66 | &Header::openpage('Fireinfo', 1, ''); | |
67 | ||
68 | if ($fireinfosettings{'ENABLE_FIREINFO'} ne "on") { | |
856c9bf0 | 69 | &Header::openbox("100%", "left", "$Lang::tr{'fireinfo why enable'}"); |
579a39d0 MT |
70 | |
71 | print <<END; | |
72 | <font color="$Header::colourred"> | |
73 | <p> | |
856c9bf0 | 74 | $Lang::tr{'fireinfo why descr1'} |
ff9fdd63 | 75 | $Lang::tr{'fireinfo why descr2'}<a href="https://fireinfo.ipfire.org" target="_blank">$Lang::tr{'fireinfo why read more'}</a> |
579a39d0 MT |
76 | </p> |
77 | </font> | |
78 | END | |
79 | ||
80 | &Header::closebox(); | |
81 | } | |
82 | ||
83 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
84 | ||
85 | if ($errormessage) { | |
86 | &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}"); | |
56914f12 | 87 | print "<font class='base'>$errormessage </font>\n"; |
579a39d0 MT |
88 | &Header::closebox(); |
89 | } | |
90 | ||
2ccb63bc SS |
91 | # Get IPFire version string. |
92 | open(FILE, "/etc/system-release"); | |
93 | my $ipfire_version = <FILE>; | |
94 | close(FILE); | |
95 | ||
fd90cadc | 96 | my $pakfire_version = &Pakfire::make_version(); |
0fd28c36 | 97 | my @kernel_version = &General::system_output("uname", "-a"); |
579a39d0 MT |
98 | |
99 | &Header::openbox('100%', 'left', $Lang::tr{'fireinfo system version'}); | |
100 | print <<END; | |
99644aba | 101 | <table cellspacing='1' cellpadding='0' class='tbl'> |
579a39d0 | 102 | <tr> |
99644aba PM |
103 | <td align='center' bgcolor='#F0F0F0' width='15%'>$Lang::tr{'fireinfo ipfire version'}</td> |
104 | <td bgcolor='#F0F0F0'><code>$ipfire_version</code></td> | |
579a39d0 MT |
105 | </tr> |
106 | <tr> | |
99644aba PM |
107 | <td align='center' bgcolor='#D6D6D6' width='15%'>$Lang::tr{'fireinfo pakfire version'}</td> |
108 | <td bgcolor='#D6D6D6'><code>$pakfire_version</code></td> | |
579a39d0 MT |
109 | </tr> |
110 | <tr> | |
99644aba | 111 | <td align='center' bgcolor='#F0F0F0' width='15%'>$Lang::tr{'fireinfo kernel version'}</td> |
0fd28c36 | 112 | <td bgcolor='#F0F0F0'><code>@kernel_version</code></td> |
579a39d0 MT |
113 | </tr> |
114 | </table> | |
115 | END | |
116 | &Header::closebox(); | |
117 | ||
118 | # Read pregenerated profile data | |
2ccb63bc | 119 | open(FILE, "/var/ipfire/fireinfo/profile"); |
5153fcc9 | 120 | my @profile = <FILE>; |
2ccb63bc | 121 | close(FILE); |
579a39d0 MT |
122 | |
123 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
124 | ||
125 | # Read profile ID from file | |
2ccb63bc SS |
126 | open(FILE, "/var/ipfire/fireinfo/public_id"); |
127 | my $profile_id = <FILE>; | |
128 | close(FILE); | |
579a39d0 MT |
129 | chomp($profile_id); |
130 | ||
131 | &Header::openbox('100%', 'left', $Lang::tr{'fireinfo settings'}); | |
132 | print <<END; | |
133 | <input type='hidden' name='ACTION' value='trigger' /> | |
134 | <table width='100%'> | |
135 | <tr> | |
136 | <td>$Lang::tr{'fireinfo your profile id'}:</td> | |
137 | <td> | |
ff9fdd63 | 138 | <a href="https://fireinfo.ipfire.org/profile/$profile_id" target="_blank">$profile_id</a> |
579a39d0 MT |
139 | </td> |
140 | </tr> | |
141 | <tr> | |
142 | <!-- spacer --> | |
143 | <td colspan="2"> </td> | |
144 | </tr> | |
145 | <tr> | |
146 | <td class='base'> | |
147 | END | |
148 | ||
149 | if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") { | |
150 | print "<font color='$Header::colourgreen'>$Lang::tr{'fireinfo is submitted'}</font>"; | |
151 | } else { | |
152 | print "<font color='$Header::colourred'>$Lang::tr{'fireinfo not submitted'}</font>"; | |
153 | } | |
154 | ||
155 | print "</td><td>"; | |
156 | ||
157 | if ($fireinfosettings{'ENABLE_FIREINFO'} eq "on") { | |
158 | print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo is submitted button'}\" />"; | |
159 | } else { | |
160 | print "<input type='submit' name='submit' value=\"$Lang::tr{'fireinfo not submitted button'}\" />"; | |
161 | } | |
162 | ||
163 | print <<END; | |
164 | </td> | |
165 | </tr> | |
166 | <tr> | |
167 | <!-- spacer --> | |
324bb888 | 168 | <td colspan="2"><font color='$Header::colourgreen'> </font></td> |
579a39d0 MT |
169 | </tr> |
170 | <tr> | |
171 | <td colspan='2'> | |
5153fcc9 | 172 | <textarea rows="25" cols="75" readonly="readonly">@profile</textarea> |
579a39d0 MT |
173 | </td> |
174 | </tr> | |
175 | </table> | |
176 | END | |
177 | ; | |
178 | &Header::closebox(); | |
179 | print "</form>\n"; | |
180 | ||
181 | &Header::closebigbox(); | |
182 | &Header::closepage(); |