immernoch das alte Problem...
[ipfire-2.x.git] / html / cgi-bin / gui.cgi
CommitLineData
cd1a2927
MT
1#!/usr/bin/perl\r
2#\r
3# IPCop CGIs\r
4#\r
5# This code is distributed under the terms of the GPL\r
6#\r
7# (c) Bill Ward\r
8#\r
9# $Id: gui.cgi,v 1.2.2.17 2005/07/06 09:21:22 franck78 Exp $\r
10#\r
11\r
12use strict;\r
13\r
14# enable only the following on debugging purpose\r
15#use warnings;\r
16#use CGI::Carp 'fatalsToBrowser';\r
17\r
18require 'CONFIG_ROOT/general-functions.pl';\r
19require "${General::swroot}/lang.pl";\r
20require "${General::swroot}/header.pl";\r
21\r
22my %cgiparams=();\r
23my %mainsettings=();\r
24my %checked=();\r
25my $errormessage='';\r
26\r
27\r
28$cgiparams{'JAVASCRIPT'} = 'off';\r
29$cgiparams{'WINDOWWITHHOSTNAME'} = 'off';\r
30$cgiparams{'REFRESHINDEX'} = 'off';\r
31$cgiparams{'ACTION'} = '';\r
32&Header::getcgihash(\%cgiparams);\r
33\r
34&Header::showhttpheaders();\r
35&General::readhash("${General::swroot}/main/settings",\%mainsettings);\r
36if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")\r
37{\r
38 open(FILE,"${General::swroot}/langs/list");\r
39 my $found=0;\r
40 while (<FILE>)\r
41 {\r
42 my $lang='';\r
43 my $engname='';\r
44 my $natname='';\r
45 chomp;\r
46 ($lang,$engname,$natname) = split (/:/, $_,3);\r
47 if ($cgiparams{'lang'} eq $lang)\r
48 {\r
49 $found=1;\r
50 }\r
51 }\r
52 close (FILE);\r
53 if ( $found == 0 )\r
54 {\r
55 $errormessage="$errormessage<P>$Lang::tr{'invalid input'}";\r
56 goto SAVE_ERROR;\r
57 }\r
58\r
59 if ($cgiparams{'JAVASCRIPT'} !~ /^(on|off)$/) {\r
60 $errormessage = $Lang::tr{'invalid input'};\r
61 goto SAVE_ERROR;\r
62 } \r
63\r
64 # Set flag if index page is to refresh whilst ppp is up.\r
65 # Default is NO refresh.\r
66 if ($cgiparams{'REFRESHINDEX'} ne 'off') {\r
67 system ('/bin/touch', "${General::swroot}/main/refreshindex");\r
68 } else {\r
69 unlink "${General::swroot}/main/refreshindex";\r
70 }\r
71\r
72 # Beep on ip-up or ip-down. Default is ON.\r
73 if ($cgiparams{'PPPUPDOWNBEEP'} ne 'on') {\r
74 $cgiparams{'PPPUPDOWNBEEP'} = 'off';\r
75 system ('/bin/touch', "${General::swroot}/ppp/nobeeps");\r
76 } else {\r
77 unlink "${General::swroot}/ppp/nobeeps";\r
78 }\r
79\r
80 # write cgi vars to the file.\r
81 $mainsettings{'LANGUAGE'} = $cgiparams{'lang'};\r
82 $mainsettings{'JAVASCRIPT'} = $cgiparams{'JAVASCRIPT'};\r
83 $mainsettings{'WINDOWWITHHOSTNAME'} = $cgiparams{'WINDOWWITHHOSTNAME'};\r
84 $mainsettings{'PPPUPDOWNBEEP'} = $cgiparams{'PPPUPDOWNBEEP'};\r
85 $mainsettings{'REFRESHINDEX'} = $cgiparams{'REFRESHINDEX'};\r
86 &General::writehash("${General::swroot}/main/settings", \%mainsettings);\r
87 &Lang::reload($cgiparams{'lang'});\r
88 SAVE_ERROR:\r
89} else {\r
90 if ($mainsettings{'JAVASCRIPT'}) {\r
91 $cgiparams{'JAVASCRIPT'} = $mainsettings{'JAVASCRIPT'};\r
92 } else {\r
93 $cgiparams{'JAVASCRIPT'} = 'on';\r
94 }\r
95\r
96 if ($mainsettings{'WINDOWWITHHOSTNAME'}) {\r
97 $cgiparams{'WINDOWWITHHOSTNAME'} = $mainsettings{'WINDOWWITHHOSTNAME'};\r
98 } else {\r
99 $cgiparams{'WINDOWWITHHOSTNAME'} = 'off';\r
100 }\r
101\r
102 if ($mainsettings{'PPPUPDOWNBEEP'}) {\r
103 $cgiparams{'PPPUPDOWNBEEP'} = $mainsettings{'PPPUPDOWNBEEP'};\r
104 } else {\r
105 $cgiparams{'PPPUPDOWNBEEP'} = 'on';\r
106 }\r
107\r
108 if($mainsettings{'REFRESHINDEX'}) {\r
109 $cgiparams{'REFRESHINDEX'} = $mainsettings{'REFRESHINDEX'};\r
110 } else {\r
111 $cgiparams{'REFRESHINDEX'} = 'off';\r
112 }\r
113}\r
114\r
115# Default settings\r
116if ($cgiparams{'ACTION'} eq "$Lang::tr{'restore defaults'}")\r
117{\r
118 $cgiparams{'JAVASCRIPT'} = 'on';\r
119 $cgiparams{'WINDOWWITHHOSTNAME'} = 'off';\r
120 $cgiparams{'PPPUPDOWNBEEP'} = 'on';\r
121 $cgiparams{'REFRESHINDEX'} = 'off';\r
122}\r
123\r
124$checked{'JAVASCRIPT'}{'off'} = '';\r
125$checked{'JAVASCRIPT'}{'on'} = '';\r
126$checked{'JAVASCRIPT'}{$cgiparams{'JAVASCRIPT'}} = "checked='checked'";\r
127\r
128$checked{'WINDOWWITHHOSTNAME'}{'off'} = '';\r
129$checked{'WINDOWWITHHOSTNAME'}{'on'} = '';\r
130$checked{'WINDOWWITHHOSTNAME'}{$cgiparams{'WINDOWWITHHOSTNAME'}} = "checked='checked'";\r
131\r
132$checked{'PPPUPDOWNBEEP'}{'off'} = '';\r
133$checked{'PPPUPDOWNBEEP'}{'on'} = '';\r
134$checked{'PPPUPDOWNBEEP'}{$cgiparams{'PPPUPDOWNBEEP'}} = "checked='checked'";\r
135\r
136$checked{'REFRESHINDEX'}{'off'} = '';\r
137$checked{'REFRESHINDEX'}{'on'} = '';\r
138$checked{'REFRESHINDEX'}{$cgiparams{'REFRESHINDEX'}} = "checked='checked'";\r
139\r
140&Header::openpage($Lang::tr{'gui settings'}, 1, '');\r
141&Header::openbigbox('100%', 'left', '', $errormessage);\r
142\r
143if ($errormessage) {\r
144 &Header::openbox('100%','left',$Lang::tr{'error messages'});\r
145 print "<font class='base'>${errormessage}&nbsp;</font>\n";\r
146 &Header::closebox();\r
147}\r
148\r
149&Header::openbox('100%','left',$Lang::tr{'gui settings'});\r
150\r
151print <<END\r
152<form method='post' action='$ENV{'SCRIPT_NAME'}'>\r
153<table width='100%'>\r
154<tr>\r
155 <td colspan='2'><p><b>$Lang::tr{'display'}</b></td>\r
156</tr>\r
157<tr>\r
158 <td><input type='checkbox' name='JAVASCRIPT' $checked{'JAVASCRIPT'}{'on'} />\r
159 <td width='100%'>$Lang::tr{'enable javascript'}</td>\r
160</tr>\r
161<tr>\r
162 <td><input type='checkbox' name='WINDOWWITHHOSTNAME' $checked{'WINDOWWITHHOSTNAME'}{'on'} /></td>\r
163 <td>$Lang::tr{'display hostname in window title'}</td>\r
164</tr>\r
165<tr>\r
166 <td><input type='checkbox' name='REFRESHINDEX' $checked{'REFRESHINDEX'}{'on'} /></td>\r
167 <td>$Lang::tr{'refresh index page while connected'}</td>\r
168</tr>\r
169<tr>\r
170 <td>&nbsp;</td>\r
171 <td>$Lang::tr{'languagepurpose'}</td>\r
172</tr>\r
173<tr>\r
174 <td>&nbsp;</td>\r
175 <td><select name='lang'>\r
176END\r
177;\r
178\r
179my $id=0;\r
180open(FILE,"${General::swroot}/langs/list");\r
181while (<FILE>)\r
182{\r
183 my $lang='';\r
184 my $engname='';\r
185 my $natname='';\r
186 $id++;\r
187 chomp;\r
188 ($lang,$engname,$natname) = split (/:/, $_, 3);\r
189 print "<option value='$lang' ";\r
190 if ($lang =~ /$mainsettings{'LANGUAGE'}/)\r
191 {\r
192 print " selected='selected'";\r
193 }\r
194 print <<END\r
195>$engname ($natname)</option>\r
196END\r
197 ;\r
198}\r
199\r
200print <<END\r
201</select></td></tr>\r
202<tr>\r
203 <td colspan='2'><hr /><p><b>$Lang::tr{'sound'}</b></td>\r
204</tr>\r
205<tr>\r
206 <td><input type ='checkbox' name='PPPUPDOWNBEEP' $checked{'PPPUPDOWNBEEP'}{'on'} /></td>\r
207 <td>$Lang::tr{'beep when ppp connects or disconnects'}</td>\r
208</tr>\r
209<tr>\r
210 <td colspan='2'><hr /></td>\r
211</tr>\r
212</table>\r
213<div align='center'>\r
214<table width='80%'>\r
215<tr>\r
216 <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' /></td>\r
217 <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>\r
218</tr>\r
219</table>\r
220</div>\r
221</form>\r
222END\r
223;\r
224&Header::closebox();\r
225&Header::closebigbox();\r
226&Header::closepage();\r
227\r
228\r
229\r