]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/gui.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
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. #
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. #
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/>. #
20 ###############################################################################
25 # enable only the following on debugging purpose
27 #use CGI::Carp 'fatalsToBrowser';
29 require '/var/ipfire/general-functions.pl';
30 require "${General::swroot}/lang.pl";
31 require "${General::swroot}/header.pl";
39 $cgiparams{'SPEED'} = 'off';
40 $cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
41 $cgiparams{'REFRESHINDEX'} = 'off';
42 $cgiparams{'ACTION'} = '';
43 &Header
::getcgihash
(\
%cgiparams);
45 &Header
::showhttpheaders
();
46 &General
::readhash
("${General::swroot}/main/settings",\
%mainsettings);
47 if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
49 open(FILE
,"${General::swroot}/langs/list");
57 ($lang,$engname,$natname) = split (/:/, $_,3);
58 if ($cgiparams{'lang'} eq $lang)
66 $errormessage="$errormessage<p>$Lang::tr{'invalid input'}</p>";
70 # Set flag if index page is to refresh whilst ppp is up.
71 # Default is NO refresh.
72 if ($cgiparams{'REFRESHINDEX'} ne 'off') {
73 system ('/usr/bin/touch', "${General::swroot}/main/refreshindex");
75 unlink "${General::swroot}/main/refreshindex";
78 # Beep on ip-up or ip-down. Default is ON.
79 if ($cgiparams{'PPPUPDOWNBEEP'} ne 'on') {
80 $cgiparams{'PPPUPDOWNBEEP'} = 'off';
81 system ('/usr/bin/touch', "${General::swroot}/ppp/nobeeps");
83 unlink "${General::swroot}/ppp/nobeeps";
86 # write cgi vars to the file.
87 $mainsettings{'LANGUAGE'} = $cgiparams{'lang'};
88 $mainsettings{'WINDOWWITHHOSTNAME'} = $cgiparams{'WINDOWWITHHOSTNAME'};
89 $mainsettings{'PPPUPDOWNBEEP'} = $cgiparams{'PPPUPDOWNBEEP'};
90 $mainsettings{'SPEED'} = $cgiparams{'SPEED'};
91 $mainsettings{'THEME'} = $cgiparams{'theme'};
92 $mainsettings{'REFRESHINDEX'} = $cgiparams{'REFRESHINDEX'};
93 &General
::writehash
("${General::swroot}/main/settings", \
%mainsettings);
94 &Lang
::reload
($cgiparams{'lang'});
97 if ($mainsettings{'WINDOWWITHHOSTNAME'}) {
98 $cgiparams{'WINDOWWITHHOSTNAME'} = $mainsettings{'WINDOWWITHHOSTNAME'};
100 $cgiparams{'WINDOWWITHHOSTNAME'} = 'on';
103 if ($mainsettings{'PPPUPDOWNBEEP'}) {
104 $cgiparams{'PPPUPDOWNBEEP'} = $mainsettings{'PPPUPDOWNBEEP'};
106 $cgiparams{'PPPUPDOWNBEEP'} = 'on';
109 if ($mainsettings{'THEME'}) {
110 $cgiparams{'THEME'} = $mainsettings{'THEME'};
112 $cgiparams{'THEME'} = 'ipfire';
115 if($mainsettings{'REFRESHINDEX'}) {
116 $cgiparams{'REFRESHINDEX'} = $mainsettings{'REFRESHINDEX'};
118 $cgiparams{'REFRESHINDEX'} = 'off';
120 if($mainsettings{'SPEED'}) {
121 $cgiparams{'SPEED'} = $mainsettings{'SPEED'};
123 # if var is not defined it will be set to on because after installation var
124 # is not set and the speedmeter should be displayed, it can only be deactivated
125 # by manually setting the var to off
126 $cgiparams{'SPEED'} = 'on';
131 if ($cgiparams{'ACTION'} eq "$Lang::tr{'restore defaults'}")
133 $cgiparams{'WINDOWWITHHOSTNAME'} = 'on';
134 $cgiparams{'PPPUPDOWNBEEP'} = 'on';
135 $cgiparams{'REFRESHINDEX'} = 'off';
136 $cgiparams{'SPEED'} = 'on';
137 $cgiparams{'THEME'} = 'ipfire';
140 $checked{'WINDOWWITHHOSTNAME'}{'off'} = '';
141 $checked{'WINDOWWITHHOSTNAME'}{'on'} = '';
142 $checked{'WINDOWWITHHOSTNAME'}{$cgiparams{'WINDOWWITHHOSTNAME'}} = "checked='checked'";
144 $checked{'PPPUPDOWNBEEP'}{'off'} = '';
145 $checked{'PPPUPDOWNBEEP'}{'on'} = '';
146 $checked{'PPPUPDOWNBEEP'}{$cgiparams{'PPPUPDOWNBEEP'}} = "checked='checked'";
148 $checked{'REFRESHINDEX'}{'off'} = '';
149 $checked{'REFRESHINDEX'}{'on'} = '';
150 $checked{'REFRESHINDEX'}{$cgiparams{'REFRESHINDEX'}} = "checked='checked'";
152 $checked{'SPEED'}{'off'} = '';
153 $checked{'SPEED'}{'on'} = '';
154 $checked{'SPEED'}{$cgiparams{'SPEED'}} = "checked='checked'";
156 &Header
::openpage
($Lang::tr
{'gui settings'}, 1, '');
157 &Header
::openbigbox
('100%', 'left', '', $errormessage);
160 &Header
::openbox
('100%','left',$Lang::tr
{'error messages'});
161 print "<font class='base'>${errormessage} </font>\n";
165 &Header
::openbox
('100%','left',$Lang::tr
{'display'});
168 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
171 <td><input type='checkbox' name='WINDOWWITHHOSTNAME' $checked{'WINDOWWITHHOSTNAME'}{'on'} /></td>
172 <td>$Lang::tr{'display hostname in window title'}</td>
175 <td><input type='checkbox' name='REFRESHINDEX' $checked{'REFRESHINDEX'}{'on'} /></td>
176 <td>$Lang::tr{'refresh index page while connected'}</td>
179 <td><input type='checkbox' name='SPEED' $checked{'SPEED'}{'on'} /></td>
180 <td>$Lang::tr{'show ajax speedmeter in footer'}</td>
184 <td>$Lang::tr{'languagepurpose'}</td>
188 <td><select name='lang'>
193 open(FILE
,"${General::swroot}/langs/list");
201 ($lang,$engname,$natname) = split (/:/, $_, 3);
202 print "<option value='$lang' ";
203 if ($lang =~ /$mainsettings{'LANGUAGE'}/)
205 print " selected='selected'";
208 >$engname ($natname)</option>
219 &Header
::openbox
('100%','left',$Lang::tr
{'theme'});
224 <td><select name='theme'>
228 my $dir = "/srv/web/ipfire/html/themes";
233 # Foreach directory create am theme entry to be selected by user
236 while ($file = readdir (DH
)) {
237 next if ( $file =~ /^\./ );
238 push (@files, $file);
242 foreach $item (sort (@files)) {
243 if ( "$mainsettings{'THEME'}" eq "$item" ) {
244 print "<option value='$item' selected='selected'>$item</option>\n";
246 print "<option value='$item'>$item</option>\n";
256 &Header
::openbox
('100%','left',$Lang::tr
{'sound'});
259 <td><input type ='checkbox' name='PPPUPDOWNBEEP' $checked{'PPPUPDOWNBEEP'}{'on'} /></td>
260 <td>$Lang::tr{'beep when ppp connects or disconnects'}</td>
263 <td colspan='2'></td>
270 <td width='90%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' /></td>
271 <td width='10%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
279 &Header
::closebigbox
();
280 &Header
::closepage
();