]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | system("/usr/local/bin/fireinfoctrl &"); | |
59 | } | |
60 | ||
61 | &Header::openpage('Fireinfo', 1, ''); | |
62 | ||
63 | if ($fireinfosettings{'ENABLE_FIREINFO'} ne "on") { | |
64 | &Header::openbox("100%", "left", "$Lang::tr{'fireinfo why enable'}"); | |
65 | ||
66 | print <<END; | |
67 | <font color="$Header::colourred"> | |
68 | <p> | |
69 | $Lang::tr{'fireinfo why descr1'} | |
70 | $Lang::tr{'fireinfo why descr2'}<a href="https://fireinfo.ipfire.org" target="_blank">$Lang::tr{'fireinfo why read more'}</a> | |
71 | </p> | |
72 | </font> | |
73 | END | |
74 | ||
75 | &Header::closebox(); | |
76 | } | |
77 | ||
78 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
79 | ||
80 | if ($errormessage) { | |
81 | &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}"); | |
82 | print "<font class='base'>$errormessage </font>\n"; | |
83 | &Header::closebox(); | |
84 | } | |
85 | ||
86 | my $ipfire_version = `cat /etc/system-release`; | |
87 | my $pakfire_version = `cat /opt/pakfire/etc/pakfire.conf | grep "version =" | cut -d\\" -f2`; | |
88 | my $kernel_version = `uname -a`; | |
89 | ||
90 | &Header::openbox('100%', 'left', $Lang::tr{'fireinfo system version'}); | |
91 | print <<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> | |
106 | END | |
107 | &Header::closebox(); | |
108 | ||
109 | # Read pregenerated profile data | |
110 | my $profile = `cat /var/ipfire/fireinfo/profile`; | |
111 | ||
112 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
113 | ||
114 | # Read profile ID from file | |
115 | my $profile_id = `cat /var/ipfire/fireinfo/public_id`; | |
116 | chomp($profile_id); | |
117 | ||
118 | &Header::openbox('100%', 'left', $Lang::tr{'fireinfo settings'}); | |
119 | print <<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> | |
125 | <a href="https://fireinfo.ipfire.org/profile/$profile_id" target="_blank">$profile_id</a> | |
126 | </td> | |
127 | </tr> | |
128 | <tr> | |
129 | <!-- spacer --> | |
130 | <td colspan="2"> </td> | |
131 | </tr> | |
132 | <tr> | |
133 | <td class='base'> | |
134 | END | |
135 | ||
136 | if ($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 | ||
142 | print "</td><td>"; | |
143 | ||
144 | if ($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 | ||
150 | print <<END; | |
151 | </td> | |
152 | </tr> | |
153 | <tr> | |
154 | <!-- spacer --> | |
155 | <td colspan="2"><font color='$Header::colourgreen'> </font></td> | |
156 | </tr> | |
157 | <tr> | |
158 | <td colspan='2'> | |
159 | <textarea rows="25" cols="75" readonly="readonly">$profile</textarea> | |
160 | </td> | |
161 | </tr> | |
162 | </table> | |
163 | END | |
164 | ; | |
165 | &Header::closebox(); | |
166 | print "</form>\n"; | |
167 | ||
168 | &Header::closebigbox(); | |
169 | &Header::closepage(); |