]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/gui.cgi
Drop "Extra Query" for Shutdown and Reboot from gui.cgi.
[ipfire-2.x.git] / html / cgi-bin / gui.cgi
index 991a31fceb21d6daaa7d40bd489ad410fda073e3..80a059675a8b752228dd16f367156faee866c5c8 100644 (file)
@@ -1,13 +1,24 @@
 #!/usr/bin/perl
-#
-# IPFire CGIs
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) Bill Ward
-#
-# $Id: gui.cgi,v 1.2.2.17 2005/07/06 09:21:22 franck78 Exp $
-#
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
 
 use strict;
 
@@ -15,7 +26,7 @@ use strict;
 #use warnings;
 #use CGI::Carp 'fatalsToBrowser';
 
-require 'CONFIG_ROOT/general-functions.pl';
+require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
@@ -25,7 +36,7 @@ my %checked=();
 my $errormessage='';
 
 
-$cgiparams{'JAVASCRIPT'} = 'off';
+$cgiparams{'SPEED'} = 'off';
 $cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
 $cgiparams{'REFRESHINDEX'} = 'off';
 $cgiparams{'ACTION'} = '';
@@ -59,7 +70,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
         # Set flag if index page is to refresh whilst ppp is up.
         # Default is NO refresh.
         if ($cgiparams{'REFRESHINDEX'} ne 'off') {
-            system ('/bin/touch', "${General::swroot}/main/refreshindex");
+            system ('/usr/bin/touch', "${General::swroot}/main/refreshindex");
         } else {
             unlink "${General::swroot}/main/refreshindex";
         }
@@ -67,7 +78,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
         # Beep on ip-up or ip-down. Default is ON.
         if ($cgiparams{'PPPUPDOWNBEEP'} ne 'on') {
             $cgiparams{'PPPUPDOWNBEEP'} = 'off';
-            system ('/bin/touch', "${General::swroot}/ppp/nobeeps");
+            system ('/usr/bin/touch', "${General::swroot}/ppp/nobeeps");
         } else {
             unlink "${General::swroot}/ppp/nobeeps";
         }
@@ -76,6 +87,8 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
        $mainsettings{'LANGUAGE'} = $cgiparams{'lang'};
        $mainsettings{'WINDOWWITHHOSTNAME'} = $cgiparams{'WINDOWWITHHOSTNAME'};
        $mainsettings{'PPPUPDOWNBEEP'} = $cgiparams{'PPPUPDOWNBEEP'};
+       $mainsettings{'SPEED'} = $cgiparams{'SPEED'};
+       $mainsettings{'THEME'} = $cgiparams{'theme'};
        $mainsettings{'REFRESHINDEX'} = $cgiparams{'REFRESHINDEX'};
        &General::writehash("${General::swroot}/main/settings", \%mainsettings);
        &Lang::reload($cgiparams{'lang'});
@@ -84,7 +97,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
        if ($mainsettings{'WINDOWWITHHOSTNAME'}) {
                $cgiparams{'WINDOWWITHHOSTNAME'} = $mainsettings{'WINDOWWITHHOSTNAME'};
        } else {
-               $cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
+               $cgiparams{'WINDOWWITHHOSTNAME'} = 'on';
        }
 
        if ($mainsettings{'PPPUPDOWNBEEP'}) {
@@ -93,19 +106,35 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}")
                $cgiparams{'PPPUPDOWNBEEP'} = 'on';
        }
 
+       if ($mainsettings{'THEME'}) {
+               $cgiparams{'THEME'} = $mainsettings{'THEME'};
+       } else {
+               $cgiparams{'THEME'} = 'ipfire';
+       }
+
        if($mainsettings{'REFRESHINDEX'}) {
                $cgiparams{'REFRESHINDEX'} = $mainsettings{'REFRESHINDEX'};
        } else {
                $cgiparams{'REFRESHINDEX'} = 'off';
        }
+       if($mainsettings{'SPEED'}) {
+               $cgiparams{'SPEED'} = $mainsettings{'SPEED'};
+       } else {
+       # if var is not defined it will be set to on because after installation var
+       # is not set and the speedmeter should be displayed, it can only be deactivated
+       # by manually setting the var to off
+               $cgiparams{'SPEED'} = 'on';
+       }
 }
 
 # Default settings
 if ($cgiparams{'ACTION'} eq "$Lang::tr{'restore defaults'}")
 {
-       $cgiparams{'WINDOWWITHHOSTNAME'} = 'off';
+       $cgiparams{'WINDOWWITHHOSTNAME'} = 'on';
        $cgiparams{'PPPUPDOWNBEEP'} = 'on';
        $cgiparams{'REFRESHINDEX'} = 'off';
+       $cgiparams{'SPEED'} = 'on';
+       $cgiparams{'THEME'} = 'ipfire';
 }
 
 $checked{'WINDOWWITHHOSTNAME'}{'off'} = '';
@@ -120,6 +149,10 @@ $checked{'REFRESHINDEX'}{'off'} = '';
 $checked{'REFRESHINDEX'}{'on'} = '';
 $checked{'REFRESHINDEX'}{$cgiparams{'REFRESHINDEX'}} = "checked='checked'";
 
+$checked{'SPEED'}{'off'} = '';
+$checked{'SPEED'}{'on'} = '';
+$checked{'SPEED'}{$cgiparams{'SPEED'}} = "checked='checked'";
+
 &Header::openpage($Lang::tr{'gui settings'}, 1, '');
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
@@ -129,14 +162,11 @@ if ($errormessage) {
        &Header::closebox();
 }
 
-&Header::openbox('100%','left',$Lang::tr{'gui settings'});
+&Header::openbox('100%','left',$Lang::tr{'display'});
 
 print <<END
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='100%'>
-<tr>
-    <td colspan='2'><p><b>$Lang::tr{'display'}</b></td>
-</tr>
 <tr>
     <td><input type='checkbox' name='WINDOWWITHHOSTNAME' $checked{'WINDOWWITHHOSTNAME'}{'on'} /></td>
     <td>$Lang::tr{'display hostname in window title'}</td>
@@ -145,6 +175,10 @@ print <<END
     <td><input type='checkbox' name='REFRESHINDEX' $checked{'REFRESHINDEX'}{'on'} /></td>
     <td>$Lang::tr{'refresh index page while connected'}</td>
 </tr>
+<tr>
+    <td><input type='checkbox' name='SPEED' $checked{'SPEED'}{'on'} /></td>
+    <td>$Lang::tr{'show ajax speedmeter in footer'}</td>
+</tr>
 <tr>
     <td>&nbsp;</td>
     <td>$Lang::tr{'languagepurpose'}</td>
@@ -178,22 +212,63 @@ END
 
 print <<END
 </select></td></tr>
+</table>
+END
+;
+&Header::closebox();
+&Header::openbox('100%','left',$Lang::tr{'theme'});
+print<<END;
+<table>
 <tr>
-    <td colspan='2'><hr /><p><b>$Lang::tr{'sound'}</b></td>
-</tr>
+    <td>&nbsp;</td>
+    <td><select name='theme'>
+END
+;
+
+my $dir = "/srv/web/ipfire/html/themes";
+local *DH;
+my ($item, $file);
+my @files;
+
+# Foreach directory create am theme entry to be selected by user
+
+opendir (DH, $dir);
+while ($file = readdir (DH)) {
+       next if ( $file =~ /^\./ );
+       push (@files, $file);
+}
+closedir (DH);
+
+foreach $item (sort (@files)) {
+       if ( "$mainsettings{'THEME'}" eq "$item" ) {
+               print "<option value='$item' selected='selected'>$item</option>\n";
+       } else {
+               print "<option value='$item'>$item</option>\n";
+       }
+}
+
+print <<END
+</select></td></tr>
+</table>
+END
+;
+&Header::closebox();
+&Header::openbox('100%','left',$Lang::tr{'sound'});
+print <<END
 <tr>
     <td><input type ='checkbox' name='PPPUPDOWNBEEP' $checked{'PPPUPDOWNBEEP'}{'on'} /></td>
     <td>$Lang::tr{'beep when ppp connects or disconnects'}</td>
 </tr>
 <tr>
-    <td colspan='2'><hr /></td>
+    <td colspan='2'></td>
 </tr>
 </table>
-<div align='center'>
-<table width='80%'>
+<div align='right'>
+<br>
+<table width='100%'>
 <tr>
-    <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' /></td>
-    <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
+    <td width='90%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'restore defaults'}' /></td>
+    <td width='10%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
 </tr>
 </table>
 </div>